Chapter Contents

Previous

Next
GETSHORT, _getshort

GETSHORT, _getshort



Gets a Short Integer from Character Buffer

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
IMPLEMENTATION
RELATED FUNCTIONS


SYNOPSIS

#include <sys/types.h>
#include <arpa/nameser.h>

GETSHORT(s_int, msgp)

u_short _getshort(const u_char *msgp);


DESCRIPTION

The GETSHORT macro and _getshort function extract an unsigned short integer s_int from a character buffer addressed by msgp . The bytes of the extracted integer are assumed to have been stored in the buffer as two consecutive bytes, starting with the high-order byte. The _getshort function returns the value. The GETSHORT macro requires that both arguments are lvalues. mgsp is advanced by two bytes. The extracted unsigned short value is assigned to s_int .

This routine is useful in resolver programming. For information on buffer formats for Internet name servers, refer to Chapter 20, "The Domain Name System," in Internetworking with TCP/IP.


RETURN VALUE

_getshort returns the value of the unsigned short integer. GETSHORT is syntactically a statement rather than an expression, and therefore has no return value.


CAUTION

GETSHORT evaluates its arguments more than once.


IMPLEMENTATION

The GETSHORT macro is defined in the <arpa/nameser.h> header file.


RELATED FUNCTIONS

GETLONG , PUTLONG , PUTSHORT


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.