From: wessels <> Date: Tue, 6 Jan 1998 03:42:53 +0000 (+0000) Subject: CLEANUP: X-Git-Tag: SQUID_3_0_PRE1~4257 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29cd62b7fa483e864869773e436ae5896d84e4be;p=thirdparty%2Fsquid.git CLEANUP: ANSI function defs s/bcopy/xmemcpy/ prototypes --- diff --git a/snmplib/asn1.c b/snmplib/asn1.c index 5b8c490c92..3fa9b06c1d 100644 --- a/snmplib/asn1.c +++ b/snmplib/asn1.c @@ -70,13 +70,13 @@ SOFTWARE. * Returns NULL on any error. */ u_char * -asn_parse_int(data, datalength, type, intp, intsize) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - asn type of object */ - long *intp; /* IN/OUT - pointer to start of output buffer */ - int intsize; /* IN - size of output buffer */ -{ +asn_parse_int( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - asn type of object */ + long *intp, /* IN/OUT - pointer to start of output buffer */ + int intsize) +{ /* IN - size of output buffer */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ @@ -123,13 +123,13 @@ asn_parse_int(data, datalength, type, intp, intsize) * Returns NULL on any error. */ u_char * -asn_parse_unsigned_int(data, datalength, type, intp, intsize) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - asn type of object */ - u_long *intp; /* IN/OUT - pointer to start of output buffer */ - int intsize; /* IN - size of output buffer */ -{ +asn_parse_unsigned_int( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - asn type of object */ + u_long * intp, /* IN/OUT - pointer to start of output buffer */ + int intsize) +{ /* IN - size of output buffer */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ @@ -177,13 +177,13 @@ asn_parse_unsigned_int(data, datalength, type, intp, intsize) * Returns NULL on any error. */ u_char * -asn_build_int(data, datalength, type, intp, intsize) - u_char *data; /* IN - pointer to start of output buffer */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - asn type of object */ - long *intp; /* IN - pointer to start of long integer */ - int intsize; /* IN - size of *intp */ -{ +asn_build_int( + u_char * data, /* IN - pointer to start of output buffer */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - asn type of object */ + long *intp, /* IN - pointer to start of long integer */ + int intsize) +{ /* IN - size of *intp */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ @@ -236,13 +236,13 @@ asn_build_int(data, datalength, type, intp, intsize) * Returns NULL on any error. */ u_char * -asn_build_unsigned_int(data, datalength, type, intp, intsize) - u_char *data; /* IN - pointer to start of output buffer */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - asn type of object */ - u_long *intp; /* IN - pointer to start of long integer */ - int intsize; /* IN - size of *intp */ -{ +asn_build_unsigned_int( + u_char * data, /* IN - pointer to start of output buffer */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - asn type of object */ + u_long * intp, /* IN - pointer to start of long integer */ + int intsize) +{ /* IN - size of *intp */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ @@ -307,13 +307,13 @@ asn_build_unsigned_int(data, datalength, type, intp, intsize) * Returns NULL on any error. */ u_char * -asn_parse_string(data, datalength, type, string, strlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - asn type of object */ - u_char *string; /* IN/OUT - pointer to start of output buffer */ - int *strlength; /* IN/OUT - size of output buffer */ -{ +asn_parse_string( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - asn type of object */ + u_char * string, /* IN/OUT - pointer to start of output buffer */ + int *strlength) +{ /* IN/OUT - size of output buffer */ /* * ASN.1 octet string ::= primstring | cmpdstring * primstring ::= 0x04 asnlength byte {byte}* @@ -334,7 +334,7 @@ asn_parse_string(data, datalength, type, string, strlength) ERROR("I don't support such long strings"); return NULL; } - bcopy((char *) bufp, (char *) string, (int) asn_length); + xmemcpy(string, bufp, (int) asn_length); *strlength = (int) asn_length; *datalength -= (int) asn_length + (bufp - data); return bufp + asn_length; @@ -352,13 +352,13 @@ asn_parse_string(data, datalength, type, string, strlength) * Returns NULL on any error. */ u_char * -asn_build_string(data, datalength, type, string, strlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of string */ - u_char *string; /* IN - pointer to start of input buffer */ - int strlength; /* IN - size of input buffer */ -{ +asn_build_string( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - ASN type of string */ + u_char * string, /* IN - pointer to start of input buffer */ + int strlength) +{ /* IN - size of input buffer */ /* * ASN.1 octet string ::= primstring | cmpdstring * primstring ::= 0x04 asnlength byte {byte}* @@ -370,7 +370,7 @@ asn_build_string(data, datalength, type, string, strlength) return NULL; if (*datalength < strlength) return NULL; - bcopy((char *) string, (char *) data, strlength); + xmemcpy(data, string, strlength); *datalength -= strlength; return data + strlength; } @@ -386,11 +386,11 @@ asn_build_string(data, datalength, type, string, strlength) * Returns NULL on any error. */ u_char * -asn_parse_header(data, datalength, type) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - ASN type of object */ -{ +asn_parse_header( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type) +{ /* OUT - ASN type of object */ u_char *bufp = data; int header_len; u_long asn_length; @@ -430,12 +430,12 @@ asn_parse_header(data, datalength, type) * Returns NULL on any error. */ u_char * -asn_build_header(data, datalength, type, length) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of object */ - int length; /* IN - length of object */ -{ +asn_build_header( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - ASN type of object */ + int length) +{ /* IN - length of object */ if (*datalength < 1) return NULL; *data++ = type; @@ -458,12 +458,12 @@ asn_build_header(data, datalength, type, length) * Returns NULL on any error. */ u_char * -asn_build_sequence(data, datalength, type, length) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of object */ - int length; /* IN - length of object */ -{ +asn_build_sequence( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - ASN type of object */ + int length) +{ /* IN - length of object */ assert(*datalength >= 0); *datalength -= 4; if (*datalength < 0) { @@ -486,10 +486,10 @@ asn_build_sequence(data, datalength, type, length) * Returns NULL on any error. */ u_char * -asn_parse_length(data, length) - u_char *data; /* IN - pointer to start of length field */ - u_long *length; /* OUT - value of length field */ -{ +asn_parse_length( + u_char * data, /* IN - pointer to start of length field */ + u_long * length) +{ /* OUT - value of length field */ u_char lengthbyte = *data; *length = 0; @@ -503,7 +503,7 @@ asn_parse_length(data, length) ERROR("we can't support data lengths that long"); return NULL; } - bcopy((char *) data + 1, (char *) length, (int) lengthbyte); + xmemcpy(length, data + 1, (int) lengthbyte); /* XXX: is this useable on a 64bit platform ? */ *length = ntohl(*length); *length >>= (8 * ((sizeof(*length)) - lengthbyte)); @@ -515,11 +515,11 @@ asn_parse_length(data, length) } u_char * -asn_build_length(data, datalength, length) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - int length; /* IN - length of object */ -{ +asn_build_length( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + int length) +{ /* IN - length of object */ u_char *start_data = data; /* no indefinite lengths sent */ @@ -563,13 +563,13 @@ asn_build_length(data, datalength, length) * Returns NULL on any error. */ u_char * -asn_parse_objid(data, datalength, type, objid, objidlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - ASN type of object */ - oid *objid; /* IN/OUT - pointer to start of output buffer */ - int *objidlength; /* IN/OUT - number of sub-id's in objid */ -{ +asn_parse_objid( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - ASN type of object */ + oid * objid, /* IN/OUT - pointer to start of output buffer */ + int *objidlength) +{ /* IN/OUT - number of sub-id's in objid */ /* * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}* * subidentifier ::= {leadingbyte}* lastbyte @@ -642,13 +642,13 @@ asn_parse_objid(data, datalength, type, objid, objidlength) * Returns NULL on any error. */ u_char * -asn_build_objid(data, datalength, type, objid, objidlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of object */ - oid *objid; /* IN - pointer to start of input buffer */ - int objidlength; /* IN - number of sub-id's in objid */ -{ +asn_build_objid( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - ASN type of object */ + oid * objid, /* IN - pointer to start of input buffer */ + int objidlength) +{ /* IN - number of sub-id's in objid */ /* * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}* * subidentifier ::= {leadingbyte}* lastbyte @@ -702,7 +702,7 @@ asn_build_objid(data, datalength, type, objid, objidlength) return NULL; if (*datalength < asnlength) return NULL; - bcopy((char *) buf, (char *) data, asnlength); + xmemcpy(data, buf, asnlength); *datalength -= asnlength; return data + asnlength; } @@ -718,11 +718,11 @@ asn_build_objid(data, datalength, type, objid, objidlength) * Returns NULL on any error. */ u_char * -asn_parse_null(data, datalength, type) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - ASN type of object */ -{ +asn_parse_null( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type) +{ /* OUT - ASN type of object */ /* * ASN.1 null ::= 0x05 0x00 */ @@ -753,11 +753,11 @@ asn_parse_null(data, datalength, type) * Returns NULL on any error. */ u_char * -asn_build_null(data, datalength, type) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of object */ -{ +asn_build_null( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type) +{ /* IN - ASN type of object */ /* * ASN.1 null ::= 0x05 0x00 */ @@ -777,13 +777,13 @@ asn_build_null(data, datalength, type) * Returns NULL on any error. */ u_char * -asn_parse_bitstring(data, datalength, type, string, strlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - asn type of object */ - u_char *string; /* IN/OUT - pointer to start of output buffer */ - int *strlength; /* IN/OUT - size of output buffer */ -{ +asn_parse_bitstring( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - asn type of object */ + u_char * string, /* IN/OUT - pointer to start of output buffer */ + int *strlength) +{ /* IN/OUT - size of output buffer */ /* * bitstring ::= 0x03 asnlength unused {byte}* */ @@ -810,7 +810,7 @@ asn_parse_bitstring(data, datalength, type, string, strlength) ERROR("Invalid bitstring"); return NULL; } - bcopy((char *) bufp, (char *) string, (int) asn_length); + xmemcpy(string, bufp, (int) asn_length); *strlength = (int) asn_length; *datalength -= (int) asn_length + (bufp - data); return bufp + asn_length; @@ -829,13 +829,13 @@ asn_parse_bitstring(data, datalength, type, string, strlength) * Returns NULL on any error. */ u_char * -asn_build_bitstring(data, datalength, type, string, strlength) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - ASN type of string */ - u_char *string; /* IN - pointer to start of input buffer */ - int strlength; /* IN - size of input buffer */ -{ +asn_build_bitstring( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - ASN type of string */ + u_char * string, /* IN - pointer to start of input buffer */ + int strlength) +{ /* IN - size of input buffer */ /* * ASN.1 bit string ::= 0x03 asnlength unused {byte}* */ @@ -848,7 +848,7 @@ asn_build_bitstring(data, datalength, type, string, strlength) return NULL; if (*datalength < strlength) return NULL; - bcopy((char *) string, (char *) data, strlength); + xmemcpy(data, string, strlength); *datalength -= strlength; return data + strlength; } @@ -866,13 +866,13 @@ asn_build_bitstring(data, datalength, type, string, strlength) * Returns NULL on any error. */ u_char * -asn_parse_unsigned_int64(data, datalength, type, cp, countersize) - u_char *data; /* IN - pointer to start of object */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char *type; /* OUT - asn type of object */ - struct counter64 *cp; /* IN/OUT -pointer to counter struct */ - int countersize; /* IN - size of output buffer */ -{ +asn_parse_unsigned_int64( + u_char * data, /* IN - pointer to start of object */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char * type, /* OUT - asn type of object */ + struct counter64 * cp, /* IN/OUT -pointer to counter struct */ + int countersize) +{ /* IN - size of output buffer */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ @@ -926,13 +926,13 @@ asn_parse_unsigned_int64(data, datalength, type, cp, countersize) * Returns NULL on any error. */ u_char * -asn_build_unsigned_int64(data, datalength, type, cp, countersize) - u_char *data; /* IN - pointer to start of output buffer */ - int *datalength; /* IN/OUT - number of valid bytes left in buffer */ - u_char type; /* IN - asn type of object */ - struct counter64 *cp; /* IN - pointer to counter struct */ - int countersize; /* IN - size of *intp */ -{ +asn_build_unsigned_int64( + u_char * data, /* IN - pointer to start of output buffer */ + int *datalength, /* IN/OUT - number of valid bytes left in buffer */ + u_char type, /* IN - asn type of object */ + struct counter64 * cp, /* IN - pointer to counter struct */ + int countersize) +{ /* IN - size of *intp */ /* * ASN.1 integer ::= 0x02 asnlength byte {byte}* */ diff --git a/snmplib/mib.c b/snmplib/mib.c index a921c870ad..916eff3d69 100644 --- a/snmplib/mib.c +++ b/snmplib/mib.c @@ -54,6 +54,7 @@ SOFTWARE. #include "mib.h" #include "util.h" +#include "snprintf.h" /* fwd: */ static void sprint_by_type(); @@ -65,9 +66,7 @@ static void sprint_variable(); static struct tree *get_symbol(); static char * -uptimeString(timeticks, buf) - u_long timeticks; - char *buf; +uptimeString(unsigned long timeticks, char *buf) { int seconds, minutes, hours, days; @@ -92,10 +91,7 @@ uptimeString(timeticks, buf) } static void -sprint_hexstring(buf, cp, len) - char *buf; - u_char *cp; - int len; +sprint_hexstring(char *buf, unsigned char *cp, int len) { for (; len >= 16; len -= 16) { @@ -114,10 +110,7 @@ sprint_hexstring(buf, cp, len) } static void -sprint_asciistring(buf, cp, len) - char *buf; - u_char *cp; - int len; +sprint_asciistring(char *buf, unsigned char *cp, int len) { int x; @@ -138,10 +131,7 @@ sprint_asciistring(buf, cp, len) #ifdef UNUSED int -read_rawobjid(input, output, out_len) - char *input; - oid *output; - int *out_len; +read_rawobjid(char *input, oid * output, int *out_len) { char buf[12], *cp; oid *op = output; @@ -188,10 +178,7 @@ read_rawobjid(input, output, out_len) * */ static void -sprint_octet_string(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_octet_string(char *buf, struct variable_list *var, struct enum_list *enums) { int hex, x; u_char *cp; @@ -226,10 +213,7 @@ sprint_octet_string(buf, var, enums) } static void -sprint_opaque(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_opaque(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != OPAQUE) { @@ -244,10 +228,7 @@ sprint_opaque(buf, var, enums) } static void -sprint_object_identifier(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_object_identifier(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != ASN_OBJECT_ID) { sprintf(buf, "Wrong Type (should be OBJECT IDENTIFIER): "); @@ -261,10 +242,7 @@ sprint_object_identifier(buf, var, enums) } static void -sprint_timeticks(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_timeticks(char *buf, struct variable_list *var, struct enum_list *enums) { char timebuf[32]; @@ -279,10 +257,7 @@ sprint_timeticks(buf, var, enums) } static void -sprint_integer(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_integer(char *buf, struct variable_list *var, struct enum_list *enums) { char *enum_string = NULL; @@ -304,10 +279,7 @@ sprint_integer(buf, var, enums) } static void -sprint_uinteger(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_uinteger(char *buf, struct variable_list *var, struct enum_list *enums) { char *enum_string = NULL; @@ -329,10 +301,7 @@ sprint_uinteger(buf, var, enums) } static void -sprint_gauge(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_gauge(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != GAUGE) { sprintf(buf, "Wrong Type (should be Gauge): "); @@ -344,10 +313,7 @@ sprint_gauge(buf, var, enums) } static void -sprint_counter(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_counter(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != COUNTER) { sprintf(buf, "Wrong Type (should be Counter): "); @@ -359,10 +325,7 @@ sprint_counter(buf, var, enums) } static void -sprint_networkaddress(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_networkaddress(char *buf, struct variable_list *var, struct enum_list *enums) { int x, len; u_char *cp; @@ -380,10 +343,7 @@ sprint_networkaddress(buf, var, enums) } static void -sprint_ipaddress(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_ipaddress(char *buf, struct variable_list *var, struct enum_list *enums) { u_char *ip; @@ -399,10 +359,7 @@ sprint_ipaddress(buf, var, enums) #if 0 static void -sprint_unsigned_short(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_unsigned_short(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != ASN_INTEGER) { sprintf(buf, "Wrong Type (should be INTEGER): "); @@ -415,10 +372,7 @@ sprint_unsigned_short(buf, var, enums) #endif static void -sprint_null(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_null(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != ASN_NULL) { sprintf(buf, "Wrong Type (should be NULL): "); @@ -430,10 +384,7 @@ sprint_null(buf, var, enums) } static void -sprint_bitstring(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_bitstring(char *buf, struct variable_list *var, struct enum_list *enums) { int len, bit; u_char *cp; @@ -472,10 +423,7 @@ sprint_bitstring(buf, var, enums) } static void -sprint_nsapaddress(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_nsapaddress(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != NSAP) { sprintf(buf, "Wrong Type (should be NsapAddress): "); @@ -489,10 +437,7 @@ sprint_nsapaddress(buf, var, enums) } static void -sprint_counter64(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_counter64(char *buf, struct variable_list *var, struct enum_list *enums) { if (var->type != COUNTER64) { sprintf(buf, "Wrong Type (should be Counter64): "); @@ -504,38 +449,29 @@ sprint_counter64(buf, var, enums) sprintf(buf, "Counter64: "); buf += strlen(buf); - sprint_hexstring(buf, &var->val.counter64->high, + sprint_hexstring(buf, (unsigned char *) &var->val.counter64->high, sizeof(var->val.counter64->high)); buf += strlen(buf); - sprint_hexstring(buf, &var->val.counter64->low, + sprint_hexstring(buf, (unsigned char *) &var->val.counter64->low, sizeof(var->val.counter64->low)); } static void -sprint_unknowntype(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_unknowntype(char *buf, struct variable_list *var, struct enum_list *enums) { /* sprintf(buf, "Variable has bad type"); */ sprint_by_type(buf, var, NULL); } static void -sprint_badtype(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_badtype(char *buf, struct variable_list *var, struct enum_list *enums) { sprintf(buf, "Variable has bad type"); } static void -sprint_by_type(buf, var, enums) - char *buf; - struct variable_list *var; - struct enum_list *enums; +sprint_by_type(char *buf, struct variable_list *var, struct enum_list *enums) { switch (var->type) { case ASN_INTEGER: @@ -980,9 +916,7 @@ sprint_objid(char *buf, oid * objid, int objidlen) } void -print_objid(objid, objidlen) - oid *objid; - int objidlen; /* number of subidentifiers */ +print_objid(oid * objid, int objidlen) { char buf[256]; @@ -992,10 +926,7 @@ print_objid(objid, objidlen) void -print_variable(objid, objidlen, variable) - oid *objid; - int objidlen; - struct variable_list *variable; +print_variable(oid * objid, int objidlen, struct variable_list *variable) { char buf[2048]; @@ -1004,11 +935,7 @@ print_variable(objid, objidlen, variable) } static void -sprint_variable(buf, objid, objidlen, variable) - char *buf; - oid *objid; - int objidlen; - struct variable_list *variable; +sprint_variable(char *buf, oid * objid, int objidlen, struct variable_list *variable) { char tempbuf[2048]; struct tree *subtree = Mib; @@ -1038,11 +965,7 @@ sprint_variable(buf, objid, objidlen, variable) } void -sprint_value(buf, objid, objidlen, variable) - char *buf; - oid *objid; - int objidlen; - struct variable_list *variable; +sprint_value(char *buf, oid * objid, int objidlen, struct variable_list *variable) { char tempbuf[2048]; struct tree *subtree = Mib; @@ -1064,10 +987,7 @@ sprint_value(buf, objid, objidlen, variable) } void -print_value(objid, objidlen, variable) - oid *objid; - int objidlen; - struct variable_list *variable; +print_value(oid * objid, int objidlen, struct variable_list *variable) { char tempbuf[2048]; @@ -1076,11 +996,7 @@ print_value(objid, objidlen, variable) } static struct tree * -get_symbol(objid, objidlen, subtree, buf) - oid *objid; - int objidlen; - struct tree *subtree; - char *buf; +get_symbol(oid * objid, int objidlen, struct tree *subtree, char *buf) { struct tree *return_tree = NULL; @@ -1117,8 +1033,7 @@ get_symbol(objid, objidlen, subtree, buf) static int -lc_cmp(s1, s2) - char *s1, *s2; +lc_cmp(char *s1, char *s2) { char c1, c2; @@ -1148,10 +1063,7 @@ lc_cmp(s1, s2) * Clone of get_symbol that doesn't take a buffer argument */ static struct tree * -get_tree(objid, objidlen, subtree) - oid *objid; - int objidlen; - struct tree *subtree; +get_tree(oid * objid, int objidlen, struct tree *subtree) { struct tree *return_tree = NULL; @@ -1174,9 +1086,7 @@ get_tree(objid, objidlen, subtree) #if 0 static char * -get_description(objid, objidlen) - oid *objid; - int objidlen; /* number of subidentifiers */ +get_description(oid * objid, int objidlen) { struct tree *subtree = Mib; @@ -1191,9 +1101,7 @@ get_description(objid, objidlen) #if 0 static void -print_description(objid, objidlen) - oid *objid; - int objidlen; /* number of subidentifiers */ +print_description(oid * objid, int objidlen) { char *desc = get_description(objid, objidlen); @@ -1206,9 +1114,7 @@ print_description(objid, objidlen) static struct tree * -find_node(name, subtree) - char *name; - struct tree *subtree; +find_node(char *name, struct tree *subtree) { struct tree *tp, *ret; @@ -1225,10 +1131,7 @@ find_node(name, subtree) #if 0 static int -get_node(name, objid, objidlen) - char *name; - oid *objid; - int *objidlen; +get_node(char *name, oid * objid, int *objidlen) { struct tree *tp; oid newname[64], *op; @@ -1244,7 +1147,7 @@ get_node(name, objid, objidlen) if (newname + 64 - op > *objidlen) return 0; *objidlen = newname + 64 - op; - bcopy(op, objid, (newname + 64 - op) * sizeof(oid)); + xmemcpy(objid, op, (newname + 64 - op) * sizeof(oid)); return 1; } else { return 0; diff --git a/snmplib/parse.c b/snmplib/parse.c index 66da33cef1..4c6c5e9194 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -226,7 +226,7 @@ static int parseQuoteString(); static int tossObjectIdentifier(); static void -hash_init() +hash_init(void) { struct tok *tp; char *cp; @@ -250,8 +250,7 @@ hash_init() struct node *nbuckets[NHASHSIZE]; void -init_node_hash(nodes) - struct node *nodes; +init_node_hash(struct node *nodes) { struct node *np, *nextp; char *cp; @@ -270,8 +269,7 @@ init_node_hash(nodes) } static char * -Malloc(num) - unsigned num; +Malloc(unsigned int num) { /* this is to fix (what seems to be) a problem with the IBM RT C * library malloc */ @@ -281,10 +279,7 @@ Malloc(num) } static void -print_error(string, token, type) - char *string; - char *token; - int type; +print_error(char *string, char *token, int type) { if (type == ENDOFFILE) fprintf(stderr, "%s(EOF): On or around line %d\n", string, Line); @@ -295,9 +290,7 @@ print_error(string, token, type) } #ifdef TEST -print_subtree(tree, count) - struct tree *tree; - int count; +print_subtree(struct tree *tree, int count) { struct tree *tp; int i; @@ -320,7 +313,7 @@ print_subtree(tree, count) int translation_table[256]; void -build_translation_table() +build_translation_table(void) { int count; @@ -376,8 +369,7 @@ build_translation_table() } static struct tree * -build_tree(nodes) - struct node *nodes; +build_tree(struct node *nodes) { struct node *np; struct tree *tp, *lasttp; @@ -457,9 +449,7 @@ build_tree(nodes) * tree and out of the nodes list. */ static void -do_subtree(root, nodes) - struct tree *root; - struct node **nodes; +do_subtree(struct tree *root, struct node **nodes) { struct tree *tp; struct tree *peer = NULL; @@ -549,10 +539,7 @@ do_subtree(root, nodes) * Returns NULL on error. */ static int -getoid(fp, oid, length) - FILE *fp; - struct subid *oid; /* an array of subids */ - int length; /* the length of the array */ +getoid(FILE * fp, struct subid *oid, int length) { int count; int type; @@ -606,8 +593,7 @@ getoid(fp, oid, length) } static void -free_node(np) - struct node *np; +free_node(struct node *np) { struct enum_list *ep, *tep; @@ -627,9 +613,7 @@ free_node(np) * Returns 0 on error. */ static struct node * -parse_objectid(fp, name) - FILE *fp; - char *name; +parse_objectid(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -713,9 +697,7 @@ parse_objectid(fp, name) } static int -get_tc(descriptor, ep) - char *descriptor; - struct enum_list **ep; +get_tc(char *descriptor, struct enum_list **ep) { int i; @@ -735,11 +717,7 @@ get_tc(descriptor, ep) * Returns NULL on error. */ static int -parse_asntype(fp, name, ntype, ntoken) - FILE *fp; - char *name; - int *ntype; - char *ntoken; +parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken) { int type, i; char token[MAXTOKEN]; @@ -850,9 +828,7 @@ parse_asntype(fp, name, ntype, ntoken) * Returns 0 on error. */ static struct node * -parse_objecttype(fp, name) - FILE *fp; - char *name; +parse_objecttype(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -1166,9 +1142,7 @@ parse_objecttype(fp, name) * Returns 0 on error. */ static struct node * -parse_objectgroup(fp, name) - FILE *fp; - char *name; +parse_objectgroup(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -1233,9 +1207,7 @@ parse_objectgroup(fp, name) * Returns 0 on error. */ static struct node * -parse_notificationDefinition(fp, name) - FILE *fp; - char *name; +parse_notificationDefinition(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -1300,9 +1272,7 @@ parse_notificationDefinition(fp, name) * Returns 0 on error. */ static struct node * -parse_compliance(fp, name) - FILE *fp; - char *name; +parse_compliance(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -1350,9 +1320,7 @@ parse_compliance(fp, name) * Returns 0 on error. */ static struct node * -parse_moduleIdentity(fp, name) - FILE *fp; - char *name; +parse_moduleIdentity(FILE * fp, char *name) { int type; char token[MAXTOKEN]; @@ -1394,9 +1362,7 @@ parse_moduleIdentity(fp, name) } int -parse_mib_header(fp, name) - FILE *fp; - char *name; +parse_mib_header(FILE * fp, char *name) { int type = DEFINITIONS; char token[MAXTOKEN]; @@ -1421,8 +1387,7 @@ parse_mib_header(fp, name) * Returns NULL on error. */ static struct node * -parse(fp) - FILE *fp; +parse(FILE * fp) { char token[MAXTOKEN]; char name[MAXTOKEN]; @@ -1621,9 +1586,7 @@ parse(fp) * and the text is placed in the string pointed to by token. */ static int -get_token(fp, token) - FILE *fp; - char *token; +get_token(FILE * fp, char *token) { static char last = ' '; int ch; @@ -1723,9 +1686,7 @@ read_mib(const char *filename) #ifdef TEST -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { FILE *fp; struct node *nodes; @@ -1745,9 +1706,7 @@ main(argc, argv) #endif /* TEST */ static int -parseQuoteString(fp, token) - FILE *fp; - char *token; +parseQuoteString(FILE * fp, char *token) { int ch; @@ -1771,8 +1730,7 @@ parseQuoteString(fp, token) * it is well formed, and NULL if not. */ static int -tossObjectIdentifier(fp) - FILE *fp; +tossObjectIdentifier(FILE * fp) { int ch; diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c index dac0ea2847..1b1f368855 100644 --- a/snmplib/snmp_api.c +++ b/snmplib/snmp_api.c @@ -131,16 +131,11 @@ char *api_errors[4] = }; -void sync_with_agent(); -int parse_app_community_string(); -void snmp_synch_setup(); -int snmp_synch_response(); -void md5Digest(u_char * msg, int length, u_char * key, u_char * digest); +static void sync_with_agent(struct snmp_session *session); #if NO_PRINTFS static char * -api_errstring(snmp_errnumber) - int snmp_errnumber; +api_errstring(int snmp_errnumber) { if (snmp_errnumber <= SNMPERR_BAD_SESSION && snmp_errnumber >= SNMPERR_GENERR) { return api_errors[snmp_errnumber + 4]; @@ -155,7 +150,7 @@ api_errstring(snmp_errnumber) * Gets initial request ID for all transactions. */ static void -init_snmp() +init_snmp(void) { struct timeval tv; @@ -171,11 +166,7 @@ init_snmp() * Dump snmp packet to stdout: */ static void -snmp_print_packet(packet, length, addr, code) - char *packet; - int length; - ipaddr addr; - int code; +snmp_print_packet(char *packet, int length, ipaddr addr, int code) { if (length < 0) { return; @@ -209,10 +200,7 @@ snmp_print_packet(packet, length, addr, code) #define TRACE_RECV (1) #define TRACE_TIMEOUT (2) static void -snmp_print_trace(slp, rp, code) - struct session_list *slp; - struct request_list *rp; - int code; +snmp_print_trace(struct session_list *slp, struct request_list *rp, int code) { int reqid = 0, retries = 1; if (rp) { @@ -246,8 +234,7 @@ snmp_print_trace(slp, rp, code) * and snmp_errno is set to the appropriate error code. */ struct snmp_session * -snmp_open(session) - struct snmp_session *session; +snmp_open(struct snmp_session *session) { struct session_list *slp; struct snmp_internal_session *isp; @@ -265,7 +252,7 @@ snmp_open(session) memset(isp, '\0', sizeof(struct snmp_internal_session)); slp->internal->sd = -1; /* mark it not set */ slp->session = xcalloc(1, sizeof(struct snmp_session)); - bcopy((char *) session, (char *) slp->session, sizeof(struct snmp_session)); + xmemcpy(slp->session, session, sizeof(struct snmp_session)); session = slp->session; /* now link it in. */ slp->next = Sessions; @@ -308,7 +295,7 @@ snmp_open(session) } else { session->community_len = strlen(DEFAULT_COMMUNITY); cp = xcalloc(1, (unsigned) session->community_len); - bcopy((char *) DEFAULT_COMMUNITY, (char *) cp, session->community_len); + xmemcpy(cp, DEFAULT_COMMUNITY, session->community_len); } /* Set up connections */ @@ -328,7 +315,7 @@ snmp_open(session) if (session->peername != SNMP_DEFAULT_PEERNAME) { if ((addr = inet_addr(session->peername)) != -1) { - bcopy((char *) &addr, (char *) &isp->addr.sin_addr, sizeof(isp->addr.sin_addr)); + xmemcpy(&isp->addr.sin_addr, &addr, sizeof(isp->addr.sin_addr)); } else { hp = gethostbyname(session->peername); if (hp == NULL) { @@ -344,7 +331,7 @@ snmp_open(session) } return 0; } else { - bcopy((char *) hp->h_addr, (char *) &isp->addr.sin_addr, hp->h_length); + xmemcpy(&isp->addr.sin_addr, hp->h_addr, hp->h_length); } } isp->addr.sin_family = AF_INET; @@ -390,9 +377,8 @@ snmp_open(session) return session; } -void -sync_with_agent(session) - struct snmp_session *session; +static void +sync_with_agent(struct snmp_session *session) { struct snmp_pdu *pdu, *response = 0; int status; @@ -436,9 +422,7 @@ sync_with_agent(session) * then free it and it's pdu. */ static void -free_one_request(isp, orp) - struct snmp_internal_session *isp; - struct request_list *orp; +free_one_request(struct snmp_internal_session *isp, struct request_list *orp) { struct request_list *rp; if (!orp) @@ -463,8 +447,7 @@ free_one_request(isp, orp) * Free each element in the input request list. */ static void -free_request_list(rp) - struct request_list *rp; +free_request_list(struct request_list *rp) { struct request_list *orp; @@ -483,8 +466,7 @@ free_request_list(rp) * the session. Returns 0 on error, 1 otherwise. */ int -snmp_close(session) - struct snmp_session *session; +snmp_close(struct snmp_session *session) { struct session_list *slp = NULL, *oslp = NULL; @@ -527,12 +509,12 @@ snmp_close(session) * occur, -1 is returned. If all goes well, 0 is returned. */ int -snmp_build(session, pdu, packet, out_length, is_agent) - struct snmp_session *session; - struct snmp_pdu *pdu; - u_char *packet; - int *out_length; - int is_agent; +snmp_build( + struct snmp_session *session, + struct snmp_pdu *pdu, + u_char * packet, + int *out_length, + int is_agent) { u_char buf[PACKET_LENGTH]; u_char *cp; @@ -553,7 +535,7 @@ snmp_build(session, pdu, packet, out_length, is_agent) cp = asn_build_header(buf, &length, (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), totallength); if (cp == NULL) return -1; - bcopy((char *) packet, (char *) cp, totallength); + xmemcpy(cp, packet, totallength); totallength += cp - buf; length = *out_length; @@ -608,7 +590,7 @@ snmp_build(session, pdu, packet, out_length, is_agent) } if (length < totallength) return -1; - bcopy((char *) buf, (char *) cp, totallength); + xmemcpy(cp, buf, totallength); totallength += cp - packet; length = PACKET_LENGTH; @@ -617,7 +599,7 @@ snmp_build(session, pdu, packet, out_length, is_agent) return -1; if (length < totallength) return -1; - bcopy((char *) packet, (char *) cp, totallength); + xmemcpy(cp, packet, totallength); totallength += cp - buf; length = *out_length; @@ -627,7 +609,7 @@ snmp_build(session, pdu, packet, out_length, is_agent) return -1; if ((*out_length - (cp - packet)) < totallength) return -1; - bcopy((char *) buf, (char *) cp, totallength); + xmemcpy(cp, buf, totallength); totallength += cp - packet; *out_length = totallength; @@ -644,11 +626,11 @@ snmp_build(session, pdu, packet, out_length, is_agent) * are encountered, -1 is returned. Otherwise, a 0 is returned. */ static int -snmp_parse(session, pdu, data, length) - struct snmp_session *session; - struct snmp_pdu *pdu; - u_char *data; - int length; +snmp_parse( + struct snmp_session *session, + struct snmp_pdu *pdu, + u_char * data, + int length) { u_char msg_type; u_char type; @@ -704,7 +686,7 @@ snmp_parse(session, pdu, data, length) if (data == NULL) return -1; pdu->enterprise = xcalloc(1, pdu->enterprise_length * sizeof(oid)); - bcopy((char *) objid, (char *) pdu->enterprise, pdu->enterprise_length * sizeof(oid)); + xmemcpy(pdu->enterprise, objid, pdu->enterprise_length * sizeof(oid)); four = 4; data = asn_parse_string(data, &length, &type, (u_char *) & pdu->agent_addr.sin_addr.s_addr, &four); @@ -740,7 +722,7 @@ snmp_parse(session, pdu, data, length) if (data == NULL) return -1; op = xcalloc(1, (unsigned) vp->name_length * sizeof(oid)); - bcopy((char *) objid, (char *) op, vp->name_length * sizeof(oid)); + xmemcpy(op, objid, vp->name_length * sizeof(oid)); vp->name = op; len = PACKET_LENGTH; @@ -777,7 +759,7 @@ snmp_parse(session, pdu, data, length) asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len); vp->val_len *= sizeof(oid); vp->val.objid = xcalloc(1, (unsigned) vp->val_len); - bcopy((char *) objid, (char *) vp->val.objid, vp->val_len); + xmemcpy(vp->val.objid, objid, vp->val_len); break; case SNMP_NOSUCHOBJECT: case SNMP_NOSUCHINSTANCE: @@ -804,9 +786,7 @@ snmp_parse(session, pdu, data, length) * The pdu is freed by snmp_send() unless a failure occured. */ int -snmp_send(session, pdu) - struct snmp_session *session; - struct snmp_pdu *pdu; +snmp_send(struct snmp_session *session, struct snmp_pdu *pdu) { struct session_list *slp; struct snmp_internal_session *isp = NULL; @@ -844,7 +824,7 @@ snmp_send(session, pdu) pdu->reqid = 1; /* give a bogus non-error reqid for traps */ if (pdu->enterprise_length == SNMP_DEFAULT_ENTERPRISE_LENGTH) { pdu->enterprise = xcalloc(1, sizeof(DEFAULT_ENTERPRISE)); - bcopy((char *) DEFAULT_ENTERPRISE, (char *) pdu->enterprise, sizeof(DEFAULT_ENTERPRISE)); + xmemcpy(pdu->enterprise, DEFAULT_ENTERPRISE, sizeof(DEFAULT_ENTERPRISE)); pdu->enterprise_length = sizeof(DEFAULT_ENTERPRISE) / sizeof(oid); } if (pdu->time == SNMP_DEFAULT_TIME) @@ -852,7 +832,7 @@ snmp_send(session, pdu) } if (pdu->address.sin_addr.s_addr == SNMP_DEFAULT_ADDRESS) { if (isp->addr.sin_addr.s_addr != SNMP_DEFAULT_ADDRESS) { - bcopy((char *) &isp->addr, (char *) &pdu->address, sizeof(pdu->address)); + xmemcpy(&pdu->address, &isp->addr, sizeof(pdu->address)); } else { #if NO_PRINTFS fprintf(stderr, "No remote IP address specified\n"); @@ -946,8 +926,7 @@ snmp_free_pdu(struct snmp_pdu *pdu) * routine returns successfully, the pdu and it's request are deleted. */ void -snmp_read(fdset) - fd_set *fdset; +snmp_read(fd_set * fdset) { struct session_list *slp; struct snmp_session *sp; @@ -1050,12 +1029,12 @@ snmp_read(fdset) * number of sessions open) */ int -snmp_select_info(numfds, fdset, timeout, block) - int *numfds; - fd_set *fdset; - struct timeval *timeout; - int *block; /* should the select block until input arrives (i.e. no input) */ -{ +snmp_select_info( + int *numfds, + fd_set * fdset, + struct timeval *timeout, + int *block) +{ /* should the select block until input arrives (i.e. no input) */ struct session_list *slp; struct snmp_internal_session *isp; struct request_list *rp; @@ -1122,7 +1101,7 @@ snmp_select_info(numfds, fdset, timeout, block) * the session is used to alert the user of the timeout. */ void -snmp_timeout() +snmp_timeout(void) { struct session_list *slp; struct snmp_session *sp;