--------------------- PatchSet 2983 Date: 2001/09/09 09:49:48 Author: serassio Branch: nt-2_3-tolsty Tag: (none) Log: Fixed indent problems Members: snmplib/asn1.c:1.1.1.1.136.1->1.1.1.1.136.2 snmplib/coexistance.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/mib.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/parse.c:1.1.1.2.70.1.2.1->1.1.1.2.70.1.2.2 snmplib/snmp_api.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/snmp_api_error.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/snmp_error.c:1.1.1.1.136.1->1.1.1.1.136.2 snmplib/snmp_msg.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/snmp_pdu.c:1.1.1.1.76.1->1.1.1.1.76.2 snmplib/snmp_vars.c:1.1.1.2.122.1->1.1.1.2.122.2 snmplib/snmplib_debug.c:1.1.1.2.126.1->1.1.1.2.126.2 test-suite/hash.c:1.1.1.1.44.1.2.1->1.1.1.1.44.1.2.2 test-suite/hash.h:1.1.1.1.76.1->1.1.1.1.76.2 test-suite/membanger.c:1.1.1.1.76.1->1.1.1.1.76.2 test-suite/pconn-banger.c:1.1.1.1.76.1->1.1.1.1.76.2 test-suite/tcp-banger2.c:1.1.1.3.30.1.2.1->1.1.1.3.30.1.2.2 test-suite/tcp-banger3.c:1.1.1.2.76.1->1.1.1.2.76.2 test-suite/waiter.c:1.1.1.1.76.1->1.1.1.1.76.2 Index: squid/snmplib/asn1.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/asn1.c,v retrieving revision 1.1.1.1.136.1 retrieving revision 1.1.1.1.136.2 diff -u -r1.1.1.1.136.1 -r1.1.1.1.136.2 --- squid/snmplib/asn1.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.136.1 +++ squid/snmplib/asn1.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.136.2 @@ -87,7 +87,7 @@ u_char * asn_build_header(u_char * data, /* IN - ptr to start of object */ int *datalength, /* IN/OUT - # of valid bytes */ - /* left in buffer */ + /* left in buffer */ u_char type, /* IN - ASN type of object */ int length) { /* IN - length of object */ @@ -539,7 +539,8 @@ * Returns NULL on any error. */ u_char * -asn_build_sequence(u_char * data, int *datalength, u_char type, int length) +asn_build_sequence(u_char * data, int *datalength, + u_char type, int length) /* u_char *data; IN - pointer to start of object */ /* int *datalength; IN/OUT - # of valid bytes left in buffer */ /* u_char type; IN - ASN type of object */ @@ -600,7 +601,8 @@ u_char * -asn_build_length(u_char * data, int *datalength, int length, int truth) +asn_build_length(u_char * data, int *datalength, + int length, int truth) /* u_char *data; IN - pointer to start of object */ /* int *datalength; IN/OUT - # of valid bytes left in buf */ /* int length; IN - length of object */ @@ -792,7 +794,7 @@ /* testmask *MUST* !!!! be of an unsigned type */ for (testmask = 0x7F, testbits = 0; testmask != 0; testmask <<= 7, testbits += 7) { - if (subid & testmask) { /* if any bits set */ + if (subid & testmask) { /* if any bits set */ mask = testmask; bits = testbits; } Index: squid/snmplib/coexistance.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/coexistance.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/coexistance.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/coexistance.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -100,7 +100,7 @@ * valid V1 responses. (I think. XXXXX) * */ -int +int snmp_coexist_V2toV1(struct snmp_pdu *PDU) { /* Per 3.1.1: @@ -121,8 +121,7 @@ break; default: - snmplib_debug(2, "Unable to translate PDU %d to SNMPv1!\n", - PDU->command); + snmplib_debug(2, "Unable to translate PDU %d to SNMPv1!\n", PDU->command); snmp_set_api_error(SNMPERR_PDU_TRANSLATION); return (0); } Index: squid/snmplib/mib.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/mib.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/mib.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/mib.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -1,5 +1,7 @@ + /*********************************************************** Copyright 1988, 1989 by Carnegie Mellon University + All Rights Reserved Permission to use, copy, modify, and distribute this software and its @@ -105,16 +107,14 @@ if (days == 0) { snprintf(buf, 32, "%d:%02d:%02d", hours, minutes, seconds); } else if (days == 1) { - snprintf(buf, 32, "%d day, %d:%02d:%02d", days, hours, minutes, - seconds); + snprintf(buf, 32, "%d day, %d:%02d:%02d", days, hours, minutes, seconds); } else { - snprintf(buf, 32, "%d days, %d:%02d:%02d", days, hours, minutes, - seconds); + snprintf(buf, 32, "%d days, %d:%02d:%02d", days, hours, minutes, seconds); } return buf; } -static void +static void sprint_hexstring(buf, cp, len) char *buf; u_char *cp; @@ -122,12 +122,10 @@ { for (; len >= 16; len -= 16) { - snprintf(buf, 26, "%02X %02X %02X %02X %02X %02X %02X %02X ", cp[0], - cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + snprintf(buf, 26, "%02X %02X %02X %02X %02X %02X %02X %02X ", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); buf += strlen(buf); cp += 8; - snprintf(buf, 26, "%02X %02X %02X %02X %02X %02X %02X %02X\n", cp[0], - cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + snprintf(buf, 26, "%02X %02X %02X %02X %02X %02X %02X %02X\n", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); buf += strlen(buf); cp += 8; } @@ -138,7 +136,7 @@ *buf = '\0'; } -static void +static void sprint_asciistring(buf, cp, len) char *buf; u_char *cp; @@ -258,7 +256,8 @@ buf += strlen(buf); } sprintf(buf, "(%u) %s", - *(var->val.integer), uptimeString(*(var->val.integer), timebuf)); + *(var->val.integer), + uptimeString(*(var->val.integer), timebuf)); } static void @@ -480,7 +479,8 @@ static struct snmp_mib_tree *get_symbol(); -oid RFC1066_MIB[] = { 1, 3, 6, 1, 2, 1 }; +oid RFC1066_MIB[] = +{1, 3, 6, 1, 2, 1}; unsigned char RFC1066_MIB_text[] = ".iso.org.dod.internet.mgmt.mib"; struct snmp_mib_tree *Mib; @@ -531,7 +531,7 @@ } #endif -void +void init_mib(char *file) { if (Mib != NULL) @@ -609,7 +609,8 @@ * No empty strings. Can happen if there is a trailing '.' or two '.'s * in a row, i.e. "..". */ - if ((*input == '\0') || (*input == '.')) + if ((*input == '\0') || + (*input == '.')) return (0); if (isdigit(*input)) { @@ -629,7 +630,8 @@ /* * Read the name into a buffer. */ - while ((*input != '\0') && (*input != '.')) { + while ((*input != '\0') && + (*input != '.')) { *to++ = *input++; } *to = '\0'; @@ -667,13 +669,12 @@ if (*input != '.') return (1); if ((*out_len = - parse_subtree(tp ? tp->child_list : NULL, ++input, output, - out_len)) == 0) + parse_subtree(tp ? tp->child_list : NULL, ++input, output, out_len)) == 0) return (0); return (++*out_len); } -int +int read_objid(input, output, out_len) char *input; oid *output; @@ -708,7 +709,7 @@ return (1); } -void +void print_objid(objid, objidlen) oid *objid; int objidlen; /* number of subidentifiers */ @@ -722,7 +723,7 @@ } -void +void sprint_objid(buf, objid, objidlen) char *buf; oid *objid; @@ -735,7 +736,7 @@ } #if 0 -void +void print_variable(objid, objidlen, pvariable) oid *objid; int objidlen; @@ -747,8 +748,7 @@ *buf = '.'; /* this is a fully qualified name */ subtree = get_symbol(objid, objidlen, subtree, buf + 1); cp = buf; - if ((strlen(buf) >= strlen((char *) RFC1066_MIB_text)) - && !memcmp(buf, (char *) RFC1066_MIB_text, + if ((strlen(buf) >= strlen((char *) RFC1066_MIB_text)) && !memcmp(buf, (char *) RFC1066_MIB_text, strlen((char *) RFC1066_MIB_text))) { cp += sizeof(RFC1066_MIB_text); } @@ -763,7 +763,7 @@ } -void +void sprint_variable(buf, objid, objidlen, pvariable) char *buf; oid *objid; @@ -776,8 +776,7 @@ *tempbuf = '.'; /* this is a fully qualified name */ subtree = get_symbol(objid, objidlen, subtree, tempbuf + 1); cp = tempbuf; - if ((strlen(buf) >= strlen((char *) RFC1066_MIB_text)) - && !memcmp(buf, (char *) RFC1066_MIB_text, + if ((strlen(buf) >= strlen((char *) RFC1066_MIB_text)) && !memcmp(buf, (char *) RFC1066_MIB_text, strlen((char *) RFC1066_MIB_text))) { cp += sizeof(RFC1066_MIB_text); } @@ -791,7 +790,7 @@ strcat(buf, "\n"); } -void +void sprint_value(buf, objid, objidlen, pvariable) char *buf; oid *objid; @@ -809,7 +808,7 @@ } } -void +void print_value(objid, objidlen, pvariable) oid *objid; int objidlen; @@ -859,8 +858,7 @@ buf++; *buf++ = '.'; *buf = '\0'; - return_tree = - get_symbol(objid + 1, objidlen - 1, subtree->child_list, buf); + return_tree = get_symbol(objid + 1, objidlen - 1, subtree->child_list, buf); } if (return_tree != NULL) return return_tree; @@ -872,21 +870,20 @@ #if 0 -void +void print_variable_list(variable_list * V) { print_variable(V->name, V->name_length, V); } -void +void print_variable_list_value(variable_list * pvariable) { char buf[512]; struct snmp_mib_tree *subtree = Mib; *buf = '.'; /* this is a fully qualified name */ - subtree = - get_symbol(pvariable->name, pvariable->name_length, subtree, buf + 1); + subtree = get_symbol(pvariable->name, pvariable->name_length, subtree, buf + 1); *buf = '\0'; if (subtree->printer) @@ -898,7 +895,7 @@ } #endif -void +void print_type(variable_list * var) { switch (var->type) { @@ -935,7 +932,7 @@ } } -void +void print_oid_nums(oid * O, int len) { int x; Index: squid/snmplib/parse.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/parse.c,v retrieving revision 1.1.1.2.70.1.2.1 retrieving revision 1.1.1.2.70.1.2.2 diff -u -r1.1.1.2.70.1.2.1 -r1.1.1.2.70.1.2.2 --- squid/snmplib/parse.c 27 Aug 2001 21:48:18 -0000 1.1.1.2.70.1.2.1 +++ squid/snmplib/parse.c 9 Sep 2001 09:49:48 -0000 1.1.1.2.70.1.2.2 @@ -1,5 +1,6 @@ /*********************************************************** Copyright 1989 by Carnegie Mellon University + All Rights Reserved Permission to use, copy, modify, and distribute this software and its @@ -74,6 +75,7 @@ #include #endif + #include "asn1.h" #include "snmp_vars.h" #include "parse.h" @@ -87,8 +89,7 @@ * or a textual string label, or both. * The subid is -1 if not present, and label is NULL if not present. */ -struct subid -{ +struct subid { int subid; char *label; }; @@ -96,8 +97,7 @@ /* * A linked list of nodes. */ -struct node -{ +struct node { struct node *next; char label[64]; /* This node's (unique) textual name */ u_int subid; /* This node's integer subidentifier */ @@ -153,8 +153,7 @@ #define INDEX 36 #define QUOTE 37 -struct tok -{ +struct tok { char *name; /* token name */ int len; /* length not counting nul */ int token; /* value */ @@ -163,90 +162,52 @@ }; -struct tok tokens[] = { - {"obsolete", sizeof("obsolete") - 1, OBSOLETE} - , - {"Opaque", sizeof("Opaque") - 1, OPAQUE} - , - {"recommended", sizeof("recommended") - 1, RECOMMENDED} - , - {"optional", sizeof("optional") - 1, OPTIONAL} - , - {"mandatory", sizeof("mandatory") - 1, MANDATORY} - , - {"current", sizeof("current") - 1, MANDATORY} - , - {"not-accessible", sizeof("not-accessible") - 1, NOACCESS} - , - {"write-only", sizeof("write-only") - 1, WRITEONLY} - , - {"read-write", sizeof("read-write") - 1, READWRITE} - , - {"TimeTicks", sizeof("TimeTicks") - 1, TIMETICKS} - , - {"OBJECTIDENTIFIER", sizeof("OBJECTIDENTIFIER") - 1, OBJID} - , - /* - * This CONTINUE appends the next word onto OBJECT, - * hopefully matching OBJECTIDENTIFIER above. - */ - {"OBJECT", sizeof("OBJECT") - 1, CONTINUE} - , - {"NetworkAddress", sizeof("NetworkAddress") - 1, NETADDR} - , - {"Gauge", sizeof("Gauge") - 1, GAUGE} - , - {"OCTETSTRING", sizeof("OCTETSTRING") - 1, OCTETSTR} - , - {"OCTET", sizeof("OCTET") - 1, -1} - , - {"OF", sizeof("OF") - 1, OF} - , - {"SEQUENCE", sizeof("SEQUENCE") - 1, SEQUENCE} - , - {"NULL", sizeof("NULL") - 1, NUL} - , - {"IpAddress", sizeof("IpAddress") - 1, IPADDR} - , - {"INTEGER", sizeof("INTEGER") - 1, INTEGER} - , - {"Counter", sizeof("Counter") - 1, COUNTER} - , - {"read-only", sizeof("read-only") - 1, READONLY} - , - {"ACCESS", sizeof("ACCESS") - 1, ACCESS} - , - {"MAX-ACCESS", sizeof("MAX-ACCESS") - 1, ACCESS} - , - {"STATUS", sizeof("STATUS") - 1, STATUS} - , - {"SYNTAX", sizeof("SYNTAX") - 1, SYNTAX} - , - {"OBJECT-TYPE", sizeof("OBJECT-TYPE") - 1, OBJTYPE} - , - {"{", sizeof("{") - 1, LEFTBRACKET} - , - {"}", sizeof("}") - 1, RIGHTBRACKET} - , - {"::=", sizeof("::=") - 1, EQUALS} - , - {"(", sizeof("(") - 1, LEFTPAREN} - , - {")", sizeof(")") - 1, RIGHTPAREN} - , - {",", sizeof(",") - 1, COMMA} - , - {"DESCRIPTION", sizeof("DESCRIPTION") - 1, DESCRIPTION} - , - {"INDEX", sizeof("INDEX") - 1, INDEX} - , - {"\"", sizeof("\"") - 1, QUOTE} - , - {"END", sizeof("END") - 1, ENDOFFILE} - , +struct tok tokens[] = +{ + {"obsolete", sizeof("obsolete") - 1, OBSOLETE}, + {"Opaque", sizeof("Opaque") - 1, OPAQUE}, + {"recommended", sizeof("recommended") - 1, RECOMMENDED}, + {"optional", sizeof("optional") - 1, OPTIONAL}, + {"mandatory", sizeof("mandatory") - 1, MANDATORY}, + {"current", sizeof("current") - 1, MANDATORY}, + {"not-accessible", sizeof("not-accessible") - 1, NOACCESS}, + {"write-only", sizeof("write-only") - 1, WRITEONLY}, + {"read-write", sizeof("read-write") - 1, READWRITE}, + {"TimeTicks", sizeof("TimeTicks") - 1, TIMETICKS}, + {"OBJECTIDENTIFIER", sizeof("OBJECTIDENTIFIER") - 1, OBJID}, + /* + * This CONTINUE appends the next word onto OBJECT, + * hopefully matching OBJECTIDENTIFIER above. + */ + {"OBJECT", sizeof("OBJECT") - 1, CONTINUE}, + {"NetworkAddress", sizeof("NetworkAddress") - 1, NETADDR}, + {"Gauge", sizeof("Gauge") - 1, GAUGE}, + {"OCTETSTRING", sizeof("OCTETSTRING") - 1, OCTETSTR}, + {"OCTET", sizeof("OCTET") - 1, -1}, + {"OF", sizeof("OF") - 1, OF}, + {"SEQUENCE", sizeof("SEQUENCE") - 1, SEQUENCE}, + {"NULL", sizeof("NULL") - 1, NUL}, + {"IpAddress", sizeof("IpAddress") - 1, IPADDR}, + {"INTEGER", sizeof("INTEGER") - 1, INTEGER}, + {"Counter", sizeof("Counter") - 1, COUNTER}, + {"read-only", sizeof("read-only") - 1, READONLY}, + {"ACCESS", sizeof("ACCESS") - 1, ACCESS}, + {"MAX-ACCESS", sizeof("MAX-ACCESS") - 1, ACCESS}, + {"STATUS", sizeof("STATUS") - 1, STATUS}, + {"SYNTAX", sizeof("SYNTAX") - 1, SYNTAX}, + {"OBJECT-TYPE", sizeof("OBJECT-TYPE") - 1, OBJTYPE}, + {"{", sizeof("{") - 1, LEFTBRACKET}, + {"}", sizeof("}") - 1, RIGHTBRACKET}, + {"::=", sizeof("::=") - 1, EQUALS}, + {"(", sizeof("(") - 1, LEFTPAREN}, + {")", sizeof(")") - 1, RIGHTPAREN}, + {",", sizeof(",") - 1, COMMA}, + {"DESCRIPTION", sizeof("DESCRIPTION") - 1, DESCRIPTION}, + {"INDEX", sizeof("INDEX") - 1, INDEX}, + {"\"", sizeof("\"") - 1, QUOTE}, + {"END", sizeof("END") - 1, ENDOFFILE}, /* Hacks for easier MIBFILE coercing */ - {"read-create", sizeof("read-create") - 1, READWRITE} - , + {"read-create", sizeof("read-create") - 1, READWRITE}, {NULL} }; @@ -431,7 +392,7 @@ if (oldnp == NULL) { *headp = np->next; /* fix root of node list */ } else { - oldnp->next = np->next; /* link around this node */ + oldnp->next = np->next; /* link around this node */ } } } @@ -506,15 +467,13 @@ } } if (nodes_left) { - snmplib_debug(0, - "The mib description doesn't seem to be consistent.\n"); - snmplib_debug(0, - "Some nodes couldn't be linked under the \"iso\" tree.\n"); + snmplib_debug(0, "The mib description doesn't seem to be consistent.\n"); + snmplib_debug(0, "Some nodes couldn't be linked under the \"iso\" tree.\n"); snmplib_debug(0, "these nodes are left:\n"); for (bucket = 0; bucket < NHASHSIZE; bucket++) { for (np = nbuckets[bucket]; np; np = np->next) - snmplib_debug(5, "%s ::= { %s %d } (%d)\n", np->label, - np->parent, np->subid, np->type); + snmplib_debug(5, "%s ::= { %s %d } (%d)\n", np->label, np->parent, np->subid, + np->type); } } return tp; @@ -557,7 +516,8 @@ if (ch == '\n') Line++; if (isspace(ch) || ch == '(' || ch == ')' || - ch == '{' || ch == '}' || ch == ',' || ch == '"') { + ch == '{' || ch == '}' || ch == ',' || + ch == '"') { if (!isspace(ch) && *token == 0) { hash += ch; *cp++ = ch; @@ -645,8 +605,7 @@ if (type == NUMBER) { SubOid->subid = atoi(token); if ((type = get_token(fp, token)) != RIGHTPAREN) { - print_error("Unexpected a closing parenthesis", token, - type); + print_error("Unexpected a closing parenthesis", token, type); return 0; } } else { @@ -713,8 +672,8 @@ * For each parent-child subid pair in the subid array, * create a node and link it into the node list. */ - for (count = 0, op = SubOid, nop = SubOid + 1; count < (length - 2); - count++, op++, nop++) { + for (count = 0, op = SubOid, nop = SubOid + 1; count < (length - 2); count++, + op++, nop++) { /* every node must have parent's name and child's name or number */ if (op->label && (nop->label || (nop->subid != -1))) { strcpy(np->parent, op->label); @@ -745,8 +704,7 @@ if (nop->subid != -1) np->subid = nop->subid; else - print_error("Warning: This entry is pretty silly", - np->label, type); + print_error("Warning: This entry is pretty silly", np->label, type); } else { free_node(np); if (oldnp) @@ -931,8 +889,7 @@ return 0; } type = get_token(fp, token); - if (type != MANDATORY && type != OPTIONAL && type != OBSOLETE - && type != RECOMMENDED) { + if (type != MANDATORY && type != OPTIONAL && type != OBSOLETE && type != RECOMMENDED) { print_error("Bad status", token, type); free_node(np); return 0; @@ -1067,8 +1024,7 @@ /* first link in chain */ np = root = parse_objecttype(fp, name); if (np == NULL) { - print_error("Bad parse of object type", (char *) NULL, - type); + print_error("Bad parse of object type", (char *) NULL, type); return NULL; } } else { @@ -1092,8 +1048,7 @@ } else { np->next = parse_objectid(fp, name); if (np->next == NULL) { - print_error("Bad parse of object type", (char *) NULL, - type); + print_error("Bad parse of object type", (char *) NULL, type); return NULL; } } Index: squid/snmplib/snmp_api.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_api.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/snmp_api.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/snmp_api.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -1,3 +1,5 @@ + + /********************************************************************** * * Copyright 1997 by Carnegie Mellon University @@ -106,7 +108,8 @@ */ -oid default_enterprise[] = { 1, 3, 6, 1, 4, 1, 3, 1, 1 }; /* enterprises.cmu.systems.cmuSNMP */ +oid default_enterprise[] = +{1, 3, 6, 1, 4, 1, 3, 1, 1}; /* enterprises.cmu.systems.cmuSNMP */ #define DEFAULT_COMMUNITY "public" #define DEFAULT_RETRIES 4 @@ -126,7 +129,7 @@ */ static int Reqid = 0; -static void +static void init_snmp(void) { struct timeval tv; @@ -140,7 +143,7 @@ /* * Free each element in the input request list. */ -static void +static void free_request_list(rp) struct request_list *rp; { @@ -189,9 +192,7 @@ return (NULL); } /* Internal session */ - isp = - (struct snmp_internal_session *) xmalloc(sizeof(struct - snmp_internal_session)); + isp = (struct snmp_internal_session *) xmalloc(sizeof(struct snmp_internal_session)); if (isp == NULL) { xfree(slp); snmp_set_api_error(SNMPERR_OS_ERR); @@ -209,8 +210,7 @@ snmp_set_api_error(SNMPERR_OS_ERR); return (NULL); } - xmemcpy((char *) slp->session, (char *) session, - sizeof(struct snmp_session)); + xmemcpy((char *) slp->session, (char *) session, sizeof(struct snmp_session)); session = slp->session; /* now link it in. */ slp->next = Sessions; @@ -238,8 +238,7 @@ if (session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) { cp = (u_char *) xmalloc((unsigned) session->community_len); if (cp) - xmemcpy((char *) cp, (char *) session->community, - session->community_len); + xmemcpy((char *) cp, (char *) session->community, session->community_len); } else { session->community_len = strlen(DEFAULT_COMMUNITY); cp = (u_char *) xmalloc((unsigned) session->community_len); @@ -346,12 +345,12 @@ * dequeues any pending requests, and closes any sockets allocated for * the session. Returns 0 on error, 1 otherwise. */ -int +int snmp_close(struct snmp_session *session) { struct session_list *slp = NULL, *oslp = NULL; - if (Sessions->session == session) { /* If first entry */ + if (Sessions->session == session) { /* If first entry */ slp = Sessions; Sessions = slp->next; } else { @@ -401,7 +400,9 @@ u_char *bufp; bufp = snmp_msg_Encode(packet, out_length, - session->community, session->community_len, session->Version, pdu); + session->community, session->community_len, + session->Version, + pdu); snmplib_debug(8, "LIBSNMP: snmp_build(): Packet len %d (requid %d)\n", *out_length, pdu->reqid); @@ -418,7 +419,9 @@ */ u_char * snmp_parse(struct snmp_session * session, - struct snmp_pdu * pdu, u_char * data, int length) + struct snmp_pdu * pdu, + u_char * data, + int length) { u_char Community[128]; u_char *bufp; @@ -426,7 +429,8 @@ /* Decode the entire message. */ data = snmp_msg_Decode(data, &length, - Community, &CommunityLen, &session->Version, pdu); + Community, &CommunityLen, + &session->Version, pdu); if (data == NULL) return (NULL); @@ -448,7 +452,7 @@ * The pdu is freed by snmp_send() unless a failure occured. */ #if 0 -int +int snmp_send(struct snmp_session *session, struct snmp_pdu *pdu) { struct session_list *slp; @@ -473,7 +477,8 @@ } if (pdu->command == SNMP_PDU_GET || pdu->command == SNMP_PDU_GETNEXT || - pdu->command == SNMP_PDU_RESPONSE || pdu->command == SNMP_PDU_SET) { + pdu->command == SNMP_PDU_RESPONSE || + pdu->command == SNMP_PDU_SET) { if (pdu->reqid == SNMP_DEFAULT_REQID) pdu->reqid = ++Reqid; @@ -483,7 +488,8 @@ pdu->errindex = 0; } else if (pdu->command == SNMP_PDU_INFORM || - pdu->command == SNMP_PDU_GETBULK || pdu->command == SNMP_PDU_V2TRAP) { + pdu->command == SNMP_PDU_GETBULK || + pdu->command == SNMP_PDU_V2TRAP) { if (session->Version != SNMP_VERSION_2) { snmplib_debug(3, "Cant send SNMPv2 PDU's in SNMP message.\n"); @@ -540,10 +546,10 @@ if (pdu->command == SNMP_PDU_GET || pdu->command == SNMP_PDU_GETNEXT || pdu->command == SNMP_PDU_SET || - pdu->command == SNMP_PDU_GETBULK || pdu->command == SNMP_PDU_INFORM) { + pdu->command == SNMP_PDU_GETBULK || + pdu->command == SNMP_PDU_INFORM) { - snmplib_debug(6, - "LIBSNMP: Setting up to recieve a response for reqid %d\n", + snmplib_debug(6, "LIBSNMP: Setting up to recieve a response for reqid %d\n", pdu->reqid); /* set up to expect a response */ @@ -592,7 +598,8 @@ isp = slp->internal; fromlength = sizeof from; length = recvfrom(isp->sd, (char *) packet, - PACKET_LENGTH, 0, (struct sockaddr *) &from, &fromlength); + PACKET_LENGTH, 0, (struct sockaddr *) &from, + &fromlength); if (length == -1) perror("recvfrom"); @@ -614,28 +621,23 @@ sp->community = bufp; sp->community_len = strlen((char *) bufp); - snmplib_debug(6, "LIBSNMP: Read PDU %s, ReqId %d\n", - snmp_pdu_type(pdu), pdu->reqid); + snmplib_debug(6, "LIBSNMP: Read PDU %s, ReqId %d\n", snmp_pdu_type(pdu), pdu->reqid); if (pdu->command == SNMP_PDU_RESPONSE) { for (rp = isp->requests; rp; rp = rp->next_request) { if (rp->request_id == pdu->reqid) { - snmplib_debug(6, - "LIBSNMP: ReqId %d: Calling callback\n", - pdu->reqid); - if (sp->callback(RECEIVED_MESSAGE, sp, pdu->reqid, pdu, + snmplib_debug(6, "LIBSNMP: ReqId %d: Calling callback\n", pdu->reqid); + if (sp->callback(RECEIVED_MESSAGE, sp, + pdu->reqid, pdu, sp->callback_magic) == 1) { /* successful, so delete request */ - snmplib_debug(6, - "LIBSNMP: ReqId %d: Success. Removing ReqId.\n", - pdu->reqid); + snmplib_debug(6, "LIBSNMP: ReqId %d: Success. Removing ReqId.\n", pdu->reqid); orp = rp; if (isp->requests == orp) { /* first in list */ isp->requests = orp->next_request; } else { - for (rp = isp->requests; rp; - rp = rp->next_request) { + for (rp = isp->requests; rp; rp = rp->next_request) { if (rp->next_request == orp) { /* link around it */ rp->next_request = orp->next_request; @@ -651,11 +653,11 @@ } } } else if (pdu->command == SNMP_PDU_GET || - pdu->command == SNMP_PDU_GETNEXT || - pdu->command == TRP_REQ_MSG || - pdu->command == SNMP_PDU_SET || - pdu->command == SNMP_PDU_GETBULK || - pdu->command == SNMP_PDU_INFORM || + pdu->command == SNMP_PDU_GETNEXT || + pdu->command == TRP_REQ_MSG || + pdu->command == SNMP_PDU_SET || + pdu->command == SNMP_PDU_GETBULK || + pdu->command == SNMP_PDU_INFORM || pdu->command == SNMP_PDU_V2TRAP) { sp->callback(RECEIVED_MESSAGE, sp, pdu->reqid, pdu, sp->callback_magic); @@ -716,13 +718,13 @@ requests++; for (rp = isp->requests; rp; rp = rp->next_request) { if (!timerisset(&earliest) || - timercmp(&rp->expire, &earliest, <))earliest = rp->expire; + timercmp(&rp->expire, &earliest, <)) + earliest = rp->expire; } } } - snmplib_debug(6, - "LIBSNMP: Select Info: %d active, %d requests pending.\n", active, - requests); + snmplib_debug(6, "LIBSNMP: Select Info: %d active, %d requests pending.\n", + active, requests); if (requests == 0) /* if none are active, skip arithmetic */ return active; @@ -762,7 +764,7 @@ * from the pdu and is resent. If there are no more retries available, the * callback for the session is used to alert the user of the timeout. */ -void +void snmp_timeout(void) { struct session_list *slp; @@ -783,8 +785,7 @@ snmplib_debug(6, "LIBSNMP: Checking session %s\n", (sp->peername != NULL) ? sp->peername : ""); for (rp = isp->requests; rp; rp = rp->next_request) { - snmplib_debug(6, - "LIBSNMP: Checking session request %d, expire at %u, Retry %d/%d\n", + snmplib_debug(6, "LIBSNMP: Checking session request %d, expire at %u, Retry %d/%d\n", rp->request_id, rp->expire.tv_sec, rp->retries, sp->retries); if (freeme != NULL) { @@ -825,9 +826,7 @@ "sending", rp->pdu->address.sin_addr); gettimeofday(&tv, (struct timezone *) 0); - if (sendto(isp->sd, (char *) packet, length, 0, - (struct sockaddr *) &rp->pdu->address, - sizeof(rp->pdu->address)) < 0) { + if (sendto(isp->sd, (char *) packet, length, 0, (struct sockaddr *) &rp->pdu->address, sizeof(rp->pdu->address)) < 0) { perror("sendto"); } rp->time = tv; @@ -848,7 +847,7 @@ /* Print some API stats */ -void +void snmp_api_stats(void *outP) { struct session_list *slp; @@ -889,8 +888,7 @@ } fprintf(out, "LIBSNMP: ----------------------------------------\n"); } - fprintf(out, - "LIBSNMP: Session List: %d active, %d have requests pending.\n", active, - requests); + fprintf(out, "LIBSNMP: Session List: %d active, %d have requests pending.\n", + active, requests); } #endif Index: squid/snmplib/snmp_api_error.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_api_error.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/snmp_api_error.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/snmp_api_error.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -44,7 +44,8 @@ int snmp_errno = 0; -static char *api_errors[17] = { +static char *api_errors[17] = +{ "Unknown Error", "Generic Error", "Invalid local port", @@ -68,7 +69,7 @@ "Unknown Error" }; -void +void snmp_set_api_error(int x) { snmp_errno = x; @@ -78,13 +79,14 @@ snmp_api_error(int err) { int foo = (err * -1); - if ((foo < SNMPERR_GENERR) || (foo > SNMPERR_LAST)) + if ((foo < SNMPERR_GENERR) || + (foo > SNMPERR_LAST)) foo = 0; return (api_errors[foo]); } -int +int snmp_api_errno(void) { return (snmp_errno); Index: squid/snmplib/snmp_error.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_error.c,v retrieving revision 1.1.1.1.136.1 retrieving revision 1.1.1.1.136.2 diff -u -r1.1.1.1.136.1 -r1.1.1.1.136.2 --- squid/snmplib/snmp_error.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.136.1 +++ squid/snmplib/snmp_error.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.136.2 @@ -33,7 +33,8 @@ #include "snmp_error.h" -static char *error_string[19] = { +static char *error_string[19] = +{ "No Error", "Response message would have been too large.", "There is no such variable name in this MIB.", @@ -41,7 +42,7 @@ "This variable is read only", "A general failure occured", - /* SNMPv2 Errors */ + /* SNMPv2 Errors */ "NOACCESS", "WRONGTYPE", "WRONGLENGTH", Index: squid/snmplib/snmp_msg.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_msg.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/snmp_msg.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/snmp_msg.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -126,7 +126,9 @@ u_char * snmp_msg_Encode(u_char * Buffer, int *BufLenP, - u_char * Community, int CommLen, int Version, struct snmp_pdu *PDU) + u_char * Community, int CommLen, + int Version, + struct snmp_pdu * PDU) { u_char *bufp, *tmp; u_char *PDUHeaderPtr, *VARHeaderPtr; @@ -138,10 +140,11 @@ *BufLenP); /* Header for the entire thing, with a false, large length */ bufp = asn_build_header(Buffer, BufLenP, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), (*BufLenP)); + (u_char) (ASN_SEQUENCE | + ASN_CONSTRUCTOR), + (*BufLenP)); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Encode:Error encoding SNMP Message Header (Header)!\n"); + snmplib_debug(4, "snmp_msg_Encode:Error encoding SNMP Message Header (Header)!\n"); return (NULL); } MsgPtr = bufp; @@ -149,22 +152,23 @@ /* Version */ bufp = asn_build_int(bufp, BufLenP, (u_char) (ASN_UNIVERSAL | -ASN_PRIMITIVE | ASN_INTEGER), (int *) (&Version), sizeof(Version)); + ASN_PRIMITIVE | + ASN_INTEGER), + (int *) (&Version), sizeof(Version)); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Encode:Error encoding SNMP Message Header (Version)!\n"); + snmplib_debug(4, "snmp_msg_Encode:Error encoding SNMP Message Header (Version)!\n"); return (NULL); } - snmplib_debug(8, "snmp_msg_Encode: Encoding community (%s) (%d)\n", - Community, CommLen); + snmplib_debug(8, "snmp_msg_Encode: Encoding community (%s) (%d)\n", Community, CommLen); /* Community */ bufp = asn_build_string(bufp, BufLenP, (u_char) (ASN_UNIVERSAL | -ASN_PRIMITIVE | ASN_OCTET_STR), Community, CommLen); + ASN_PRIMITIVE | + ASN_OCTET_STR), + Community, CommLen); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Encode:Error encoding SNMP Message Header (Community)!\n"); + snmplib_debug(4, "snmp_msg_Encode:Error encoding SNMP Message Header (Community)!\n"); return (NULL); } /* Encode the rest. */ @@ -172,12 +176,12 @@ /* A nice header for this PDU. * Encoded with the wrong length. We'll fix it later. */ - snmplib_debug(8, - "snmp_msg_Encode:Encoding PDU Header at 0x%x (fake len %d) (%d bytes so far)\n", + snmplib_debug(8, "snmp_msg_Encode:Encoding PDU Header at 0x%x (fake len %d) (%d bytes so far)\n", bufp, *BufLenP, *BufLenP); PDUHeaderPtr = bufp; bufp = asn_build_header(bufp, BufLenP, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), (*BufLenP)); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + (*BufLenP)); if (bufp == NULL) return (NULL); @@ -189,7 +193,8 @@ VARHeaderPtr = bufp; bufp = asn_build_header(bufp, BufLenP, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), FakeArg); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + FakeArg); if (bufp == NULL) return (NULL); VARDataStart = bufp; @@ -208,7 +213,8 @@ (int) (bufp - PDUDataStart), PDUHeaderPtr, bufp); #endif tmp = asn_build_header(PDUHeaderPtr, &FakeArg, - (u_char) PDU->command, (int) (bufp - PDUDataStart)); + (u_char) PDU->command, + (int) (bufp - PDUDataStart)); /* Length of the PDU and Vars */ if (tmp == NULL) return (NULL); @@ -218,12 +224,16 @@ (int) (bufp - MsgPtr), MsgPtr, bufp); #endif tmp = asn_build_header(Buffer, - &FakeArg, (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), (bufp - MsgPtr)); /* Length of everything */ + &FakeArg, + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + (bufp - MsgPtr)); /* Length of everything */ if (tmp == NULL) return (NULL); tmp = asn_build_header(VARHeaderPtr, - &FakeArg, (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), (bufp - VARDataStart)); /* Length of everything */ + &FakeArg, + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + (bufp - VARDataStart)); /* Length of everything */ if (tmp == NULL) return (NULL); @@ -235,42 +245,40 @@ u_char * snmp_msg_Decode(u_char * Packet, int *PacketLenP, - u_char * Community, int *CommLenP, int *Version, struct snmp_pdu * PDU) + u_char * Community, int *CommLenP, + int *Version, struct snmp_pdu * PDU) { u_char *bufp; u_char type; bufp = asn_parse_header(Packet, PacketLenP, &type); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Decode:Error decoding SNMP Messsage Header (Header)!\n"); + snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Messsage Header (Header)!\n"); ASN_PARSE_ERROR(NULL); } if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) { - snmplib_debug(4, - "snmp_msg_Decode:Error decoding SNMP Messsage Header (Header)!\n"); + snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Messsage Header (Header)!\n"); ASN_PARSE_ERROR(NULL); } bufp = asn_parse_int(bufp, PacketLenP, - &type, (int *) Version, sizeof(*Version)); + &type, + (int *) Version, sizeof(*Version)); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Decode:Error decoding SNMP Messsage Header (Version)!\n"); + snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Messsage Header (Version)!\n"); ASN_PARSE_ERROR(NULL); } bufp = asn_parse_string(bufp, PacketLenP, &type, Community, CommLenP); if (bufp == NULL) { - snmplib_debug(4, - "snmp_msg_Decode:Error decoding SNMP Messsage Header (Community)!\n"); + snmplib_debug(4, "snmp_msg_Decode:Error decoding SNMP Messsage Header (Community)!\n"); ASN_PARSE_ERROR(NULL); } Community[*CommLenP] = '\0'; - if ((*Version != SNMP_VERSION_1) && (*Version != SNMP_VERSION_2)) { + if ((*Version != SNMP_VERSION_1) && + (*Version != SNMP_VERSION_2)) { /* Don't know how to handle this one. */ - snmplib_debug(4, "snmp_msg_Decode:Unable to parse Version %u\n", - *Version); + snmplib_debug(4, "snmp_msg_Decode:Unable to parse Version %u\n", *Version); snmplib_debug(4, "snmp_msg_Decode:Continuing anyway\n"); } /* Now that we know the header, decode the PDU */ @@ -281,8 +289,7 @@ /* snmp_pdu_decode registered failure */ return (NULL); - bufp = - snmp_var_DecodeVarBind(bufp, PacketLenP, &(PDU->variables), *Version); + bufp = snmp_var_DecodeVarBind(bufp, PacketLenP, &(PDU->variables), *Version); if (bufp == NULL) /* snmp_var_DecodeVarBind registered failure */ return (NULL); Index: squid/snmplib/snmp_pdu.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_pdu.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/snmplib/snmp_pdu.c 27 Aug 2001 21:48:18 -0000 1.1.1.1.76.1 +++ squid/snmplib/snmp_pdu.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -155,8 +155,7 @@ xmemcpy((char *) Dest, (char *) Src, sizeof(struct snmp_pdu)); #ifdef DEBUG_PDU - snmplib_debug(8, "PDU %x: Created %x\n", (unsigned int) Src, - (unsigned int) Dest); + snmplib_debug(8, "PDU %x: Created %x\n", (unsigned int) Src, (unsigned int) Dest); #endif return (Dest); } @@ -194,7 +193,8 @@ #endif if (pdu->command != SNMP_PDU_RESPONSE || - pdu->errstat == SNMP_ERR_NOERROR || pdu->errindex <= 0) { + pdu->errstat == SNMP_ERR_NOERROR || + pdu->errindex <= 0) { snmp_set_api_error(SNMPERR_UNABLE_TO_FIX); return (NULL); } @@ -270,7 +270,7 @@ /**********************************************************************/ -void +void snmp_pdu_free(struct snmp_pdu *pdu) { snmp_free_pdu(pdu); @@ -279,7 +279,7 @@ /* * Frees the pdu and any xmalloc'd data associated with it. */ -void +void snmp_free_pdu(struct snmp_pdu *pdu) { struct variable_list *vp, *ovp; @@ -346,7 +346,8 @@ */ u_char * -snmp_pdu_encode(u_char * DestBuf, int *DestBufLen, struct snmp_pdu *PDU) +snmp_pdu_encode(u_char * DestBuf, int *DestBufLen, + struct snmp_pdu *PDU) { u_char *bufp; @@ -388,7 +389,8 @@ /* specific trap */ bufp = asn_build_int(bufp, DestBufLen, (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - (int *) &PDU->specific_type, sizeof(PDU->specific_type)); + (int *) &PDU->specific_type, + sizeof(PDU->specific_type)); if (bufp == NULL) return (NULL); @@ -416,14 +418,16 @@ /* non-repeaters */ bufp = asn_build_int(bufp, DestBufLen, (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &PDU->non_repeaters, sizeof(PDU->non_repeaters)); + &PDU->non_repeaters, + sizeof(PDU->non_repeaters)); if (bufp == NULL) return (NULL); /* max-repetitions */ bufp = asn_build_int(bufp, DestBufLen, (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &PDU->max_repetitions, sizeof(PDU->max_repetitions)); + &PDU->max_repetitions, + sizeof(PDU->max_repetitions)); if (bufp == NULL) return (NULL); break; @@ -520,25 +524,32 @@ /* Agent-addr */ four = 4; bufp = asn_parse_string(bufp, Length, - &ASNType, (u_char *) & PDU->agent_addr.sin_addr.s_addr, &four); + &ASNType, + (u_char *) & PDU->agent_addr.sin_addr.s_addr, + &four); if (bufp == NULL) ASN_PARSE_ERROR(NULL); /* Generic trap */ bufp = asn_parse_int(bufp, Length, - &ASNType, (int *) &PDU->trap_type, sizeof(PDU->trap_type)); + &ASNType, + (int *) &PDU->trap_type, + sizeof(PDU->trap_type)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); /* Specific Trap */ bufp = asn_parse_int(bufp, Length, - &ASNType, (int *) &PDU->specific_type, sizeof(PDU->specific_type)); + &ASNType, + (int *) &PDU->specific_type, + sizeof(PDU->specific_type)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); /* Timestamp */ bufp = asn_parse_unsigned_int(bufp, Length, - &ASNType, &PDU->time, sizeof(PDU->time)); + &ASNType, + &PDU->time, sizeof(PDU->time)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); break; @@ -551,19 +562,22 @@ /* request id */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->reqid, sizeof(PDU->reqid)); + &ASNType, + &PDU->reqid, sizeof(PDU->reqid)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); /* non-repeaters */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->non_repeaters, sizeof(PDU->non_repeaters)); + &ASNType, + &PDU->non_repeaters, sizeof(PDU->non_repeaters)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); /* max-repetitions */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->max_repetitions, sizeof(PDU->max_repetitions)); + &ASNType, + &PDU->max_repetitions, sizeof(PDU->max_repetitions)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); @@ -576,7 +590,8 @@ /* request id */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->reqid, sizeof(PDU->reqid)); + &ASNType, + &PDU->reqid, sizeof(PDU->reqid)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); @@ -586,7 +601,8 @@ /* error status */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->errstat, sizeof(PDU->errstat)); + &ASNType, + &PDU->errstat, sizeof(PDU->errstat)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); @@ -596,7 +612,8 @@ /* error index */ bufp = asn_parse_int(bufp, Length, - &ASNType, &PDU->errindex, sizeof(PDU->errindex)); + &ASNType, + &PDU->errindex, sizeof(PDU->errindex)); if (bufp == NULL) ASN_PARSE_ERROR(NULL); @@ -653,7 +670,7 @@ * Add a null variable with the requested name to the end of the list of * variables for this pdu. */ -void +void snmp_add_null_var(struct snmp_pdu *pdu, oid * name, int name_length) { struct variable_list *vars; @@ -669,7 +686,9 @@ } else { /* Insert at the end */ - for (ptr = pdu->variables; ptr->next_variable; ptr = ptr->next_variable) + for (ptr = pdu->variables; + ptr->next_variable; + ptr = ptr->next_variable) /*EXIT */ ; ptr->next_variable = vars; } Index: squid/snmplib/snmp_vars.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmp_vars.c,v retrieving revision 1.1.1.2.122.1 retrieving revision 1.1.1.2.122.2 diff -u -r1.1.1.2.122.1 -r1.1.1.2.122.2 --- squid/snmplib/snmp_vars.c 27 Aug 2001 21:48:18 -0000 1.1.1.2.122.1 +++ squid/snmplib/snmp_vars.c 9 Sep 2001 09:49:48 -0000 1.1.1.2.122.2 @@ -1,3 +1,4 @@ + /* * SNMP Variable Binding. Complies with: * @@ -199,7 +200,8 @@ Src->name_length * sizeof(oid)); } /* CISCO Catalyst 2900 returns NULL strings as data of length 0. */ - if ((Src->val.string != NULL) && (Src->val_len)) { + if ((Src->val.string != NULL) && + (Src->val_len)) { Dest->val.string = (u_char *) xmalloc(Src->val_len); if (Dest->val.string == NULL) { snmp_set_api_error(SNMPERR_OS_ERR); @@ -210,8 +212,7 @@ #ifdef DEBUG_VARS printf("VARS: Copying value (Size %d)\n", Src->val_len); #endif - xmemcpy((char *) Dest->val.string, (char *) Src->val.string, - Src->val_len); + xmemcpy((char *) Dest->val.string, (char *) Src->val.string, Src->val_len); } #ifdef DEBUG_VARS printf("VARS: Cloned %x.\n", (unsigned int) Dest); @@ -260,7 +261,8 @@ */ u_char * snmp_var_EncodeVarBind(u_char * Buffer, int *BufLenP, - variable_list * VarList, int Version) + variable_list * VarList, + int Version) { struct variable_list *Vars; u_char *bufp; @@ -278,14 +280,17 @@ */ HeaderStart = bufp; HeaderEnd = asn_build_header(HeaderStart, BufLenP, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), FakeArg); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + FakeArg); if (HeaderEnd == NULL) return (NULL); /* Now, let's put the Object Identifier into the buffer */ bufp = asn_build_objid(HeaderEnd, BufLenP, (u_char) (ASN_UNIVERSAL | -ASN_PRIMITIVE | ASN_OBJECT_ID), Vars->name, Vars->name_length); + ASN_PRIMITIVE | + ASN_OBJECT_ID), + Vars->name, Vars->name_length); if (bufp == NULL) return (NULL); @@ -294,7 +299,8 @@ case ASN_INTEGER: bufp = asn_build_int(bufp, - BufLenP, Vars->type, (int *) Vars->val.integer, Vars->val_len); + BufLenP, Vars->type, + (int *) Vars->val.integer, Vars->val_len); break; case SMI_COUNTER32: @@ -302,7 +308,8 @@ /* case SMI_UNSIGNED32: */ case SMI_TIMETICKS: bufp = asn_build_unsigned_int(bufp, BufLenP, - Vars->type, (u_int *) Vars->val.integer, Vars->val_len); + Vars->type, + (u_int *) Vars->val.integer, Vars->val_len); break; case ASN_OCTET_STR: @@ -347,7 +354,8 @@ /* Rebuild the header with the appropriate length */ HeaderEnd = asn_build_header(HeaderStart, &FakeArg, - (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), (bufp - HeaderEnd)); + (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), + (bufp - HeaderEnd)); /* Returns NULL */ if (HeaderEnd == NULL) @@ -365,7 +373,8 @@ /* Parse all Vars from the buffer */ u_char * snmp_var_DecodeVarBind(u_char * Buffer, int *BufLen, - struct variable_list ** VarP, int Version) + struct variable_list ** VarP, + int Version) { struct variable_list *Var, **VarLastP; u_char *bufp, *tmp; @@ -421,8 +430,7 @@ ASN_PARSE_ERROR(NULL); } #ifdef DEBUG_VARS_DECODE - printf("VARS: Header type 0x%x (%d bytes left)\n", VarBindType, - ThisVarLen); + printf("VARS: Header type 0x%x (%d bytes left)\n", VarBindType, ThisVarLen); #endif /* Parse the OBJID */ @@ -432,7 +440,8 @@ ASN_PARSE_ERROR(NULL); if (VarBindType != (u_char) (ASN_UNIVERSAL | - ASN_PRIMITIVE | ASN_OBJECT_ID)) { + ASN_PRIMITIVE | + ASN_OBJECT_ID)) { snmp_set_api_error(SNMPERR_PDU_PARSE); ASN_PARSE_ERROR(NULL); } @@ -467,7 +476,8 @@ } Var->val_len = sizeof(int); bufp = asn_parse_int(DataPtr, &ThisVarLen, - &Var->type, (int *) Var->val.integer, Var->val_len); + &Var->type, (int *) Var->val.integer, + Var->val_len); #ifdef DEBUG_VARS_DECODE printf("VARS: Decoded integer '%d' (%d bytes left)\n", *(Var->val.integer), ThisVarLen); @@ -485,7 +495,8 @@ } Var->val_len = sizeof(u_int); bufp = asn_parse_unsigned_int(DataPtr, &ThisVarLen, - &Var->type, (u_int *) Var->val.integer, Var->val_len); + &Var->type, (u_int *) Var->val.integer, + Var->val_len); #ifdef DEBUG_VARS_DECODE printf("VARS: Decoded timeticks '%d' (%d bytes left)\n", *(Var->val.integer), ThisVarLen); @@ -502,7 +513,8 @@ return (NULL); } bufp = asn_parse_string(DataPtr, &ThisVarLen, - &Var->type, Var->val.string, &Var->val_len); + &Var->type, Var->val.string, + &Var->val_len); #ifdef DEBUG_VARS_DECODE printf("VARS: Decoded string '%s' (length %d) (%d bytes left)\n", (Var->val.string), Var->val_len, ThisVarLen); Index: squid/snmplib/snmplib_debug.c =================================================================== RCS file: /cvsroot/squid-sf//squid/snmplib/snmplib_debug.c,v retrieving revision 1.1.1.2.126.1 retrieving revision 1.1.1.2.126.2 diff -u -r1.1.1.2.126.1 -r1.1.1.2.126.2 --- squid/snmplib/snmplib_debug.c 27 Aug 2001 21:48:18 -0000 1.1.1.2.126.1 +++ squid/snmplib/snmplib_debug.c 9 Sep 2001 09:49:48 -0000 1.1.1.2.126.2 @@ -16,14 +16,14 @@ #endif #if STDC_HEADERS -void (*snmplib_debug_hook) (int, char *, ...) = NULL; +void (*snmplib_debug_hook) (int, char *,...) = NULL; #else void (*snmplib_debug_hook) (va_alist) = NULL; #endif extern void #if STDC_HEADERS -snmplib_debug(int lvl, char *fmt, ...) +snmplib_debug(int lvl, char *fmt,...) { char buf[BUFSIZ]; va_list args; Index: squid/test-suite/hash.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/hash.c,v retrieving revision 1.1.1.1.44.1.2.1 retrieving revision 1.1.1.1.44.1.2.2 diff -u -r1.1.1.1.44.1.2.1 -r1.1.1.1.44.1.2.2 --- squid/test-suite/hash.c 27 Aug 2001 21:48:22 -0000 1.1.1.1.44.1.2.1 +++ squid/test-suite/hash.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.44.1.2.2 @@ -1,5 +1,6 @@ + /* - * $Id: hash.c,v 1.1.1.1.44.1.2.1 2001/08/27 21:48:22 tolsty Exp $ + * $Id: hash.c,v 1.1.1.1.44.1.2.2 2001/09/09 09:49:48 serassio Exp $ * * DEBUG: section 0 Hash Tables * AUTHOR: Harvest Derived @@ -38,7 +39,7 @@ #include #include "hash.h" #undef free -extern void my_free(char *, int, void *); +extern void my_free(char *, int , void *); #define free(a) my_free(__FILE__, __LINE__, a) @@ -175,7 +176,7 @@ /* Add to the given hash table 'hid' */ new = calloc(1, sizeof(hash_link)); if (!new) { - fprintf(stderr, "calloc failed!\n"); + fprintf(stderr,"calloc failed!\n"); print_stats(); exit(1); } @@ -297,7 +298,7 @@ hid->current_ptr = walker->next; if (FreeLink) { if (walker) { - free(walker); + free(walker); } } return 0; @@ -336,10 +337,10 @@ void hashFreeMemory(hash_table * hid) { - if (hid->buckets); + if (hid->buckets); free(hid->buckets); - if (hid) - free(hid); + if (hid) + free(hid); } @@ -370,7 +371,8 @@ while (fgets(buf, BUFSIZ, stdin)) { buf[strlen(buf) - 1] = '\0'; - printf("Inserting '%s' for item %p to hash table: %d\n", buf, buf, hid); + printf("Inserting '%s' for item %p to hash table: %d\n", + buf, buf, hid); hash_insert(hid, xstrdup(buf), (void *) 0x12345678); if (random() % 17 == 0) strcpy(todelete, buf); @@ -400,3 +402,4 @@ exit(0); } #endif + Index: squid/test-suite/hash.h =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/hash.h,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/test-suite/hash.h 27 Aug 2001 21:48:22 -0000 1.1.1.1.76.1 +++ squid/test-suite/hash.h 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -1,7 +1,6 @@ -#define DEFAULT_HASH_SIZE 7951 +#define DEFAULT_HASH_SIZE 7951 typedef unsigned int HASHHASH(const void *, unsigned int); -struct _hash_link -{ +struct _hash_link { char *key; struct _hash_link *next; void *item; @@ -10,8 +9,7 @@ typedef struct _hash_link hash_link; -struct _hash_table -{ +struct _hash_table { int valid; hash_link **buckets; HASHCMP *cmp; @@ -19,17 +17,17 @@ unsigned int size; unsigned int current_slot; hash_link *current_ptr; -}; +}; typedef struct _hash_table hash_table; extern int hash_links_allocated; -extern int store_hash_buckets; /* 0 */ -extern hash_table *store_table; /* NULL */ +extern int store_hash_buckets; /* 0 */ +extern hash_table *store_table; /* NULL */ extern hash_table *hash_create(HASHCMP *, int, HASHHASH *); extern void hash_insert(hash_table *, const char *, void *); extern int hash_delete(hash_table *, const char *); int hash_delete_link(hash_table *, hash_link *); -int hash_unlink(hash_table *, hash_link *, int); +int hash_unlink(hash_table *,hash_link *, int); void hash_join(hash_table *, hash_link *); int hash_remove_link(hash_table *, hash_link *); hash_link *hash_lookup(hash_table *, const void *); Index: squid/test-suite/membanger.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/membanger.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/test-suite/membanger.c 27 Aug 2001 21:48:22 -0000 1.1.1.1.76.1 +++ squid/test-suite/membanger.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -39,7 +39,7 @@ int i; int a; -int run_stats = 0; +int run_stats=0; void *my_xmalloc(size_t); void *my_xcalloc(int, size_t); int my_xfree(void *); @@ -49,176 +49,163 @@ #define xfree my_xfree int *size2id_array[2]; -int size2id_len = 0; -int size2id_alloc = 0; +int size2id_len=0; +int size2id_alloc=0; -typedef struct -{ - char orig_ptr[32]; - void *my_ptr; +typedef struct { + char orig_ptr[32]; + void *my_ptr; #ifdef WITH_LIB - MemPool *pool; + MemPool *pool; #endif - int size; -} -memitem; + int size; +} memitem; -struct -{ - int mallocs, frees, callocs, reallocs; -} -mstat; +struct { + int mallocs,frees,callocs,reallocs; +} mstat; memitem *mi; void size2id(size_t, memitem *); void badformat(); void init_stats(), print_stats(); -void my_hash_insert(hash_table * h, const char *k, memitem * item); -static void *xmemAlloc(memitem * item); -static void xmemFree(memitem * item); +void my_hash_insert(hash_table *h, const char *k, memitem *item); +static void *xmemAlloc(memitem *item); +static void xmemFree(memitem *item); -int -ptrcmp(const void *a, const void *b) +int +ptrcmp(const void *a,const void *b) { - return (strcmp(a, b)); + return (strcmp(a,b)); } -main(int argc, char **argv) +main(int argc,char **argv) { char c; - extern char *optarg; + extern char *optarg; malloc_options = "A"; - a = 0; + a=0; while ((c = getopt(argc, argv, "f:i:M:l:m:r:N")) != -1) { - switch (c) { + switch (c) { case 'N': - mem_pools_on = 0; - break; + mem_pools_on=0; + break; case 'r': - run_stats = atoi(optarg); - break; + run_stats=atoi(optarg); + break; case 'f': - fn = strdup(optarg); - fp = fopen(fn, "r"); - break; + fn=strdup(optarg); + fp=fopen(fn,"r"); + break; case 'i': - initsiz = atoi(optarg); - break; + initsiz=atoi(optarg); + break; case 'l': - mem_max_size = atoi(optarg) * 1024 * 1024; - break; + mem_max_size = atoi(optarg)*1024*1024; + break; case 'M': - maxsiz = atoi(optarg); - break; + maxsiz=atoi(optarg); + break; case 'm': - minchunk = atoi(optarg); - break; + minchunk=atoi(optarg); + break; default: - fprintf(stderr, - "Usage: %s -f file -M maxsiz -i initsiz -m minchunk", argv[0]); - exit(1); - } - + fprintf(stderr, + "Usage: %s -f file -M maxsiz -i initsiz -m minchunk",argv[0]); + exit(1); + } + } if (!fp) { fprintf(stderr, - "%s pummels %s\n%s . o O ( You't supply a valid tracefile.)\n", - argv[0], getenv("USER"), argv[0]); + "%s pummels %s\n%s . o O ( You't supply a valid tracefile.)\n", + argv[0], getenv("USER"), argv[0]); exit(1); } #ifdef WITH_LIB sizeToPoolInit(); #endif - mem_table = hash_create(ptrcmp, 229, hash4); /* small hash table */ + mem_table = hash_create(ptrcmp, 229, hash4); /* small hash table */ init_stats(); - while (fgets(mbuf, 256, fp) != NULL) { - if (run_stats > 0 && (++a) % run_stats == 0) - print_stats(); - p = NULL; - switch (mbuf[0]) { - case 'm': /* malloc */ - p = strtok(&mbuf[2], ":"); - if (!p) - badformat(); - size = atoi(p); - p = strtok(NULL, "\n"); - if (!p) - badformat(); - mi = malloc(sizeof(memitem)); - strcpy(mi->orig_ptr, p); - mi->size = size; - size2id(size, mi); - mi->my_ptr = xmemAlloc(mi); /* (void *)xmalloc(size); */ - assert(mi->my_ptr); - my_hash_insert(mem_table, mi->orig_ptr, mi); - mstat.mallocs++; - break; - case 'c': /* calloc */ - p = strtok(&mbuf[2], ":"); - if (!p) - badformat(); - amt = atoi(p); - p = strtok(NULL, ":"); - if (!p) - badformat(); - size = atoi(p); - p = strtok(NULL, "\n"); - if (!p) - badformat(); - mi = malloc(sizeof(memitem)); - strcpy(mi->orig_ptr, p); - size2id(size, mi); - mi->size = amt * size; - mi->my_ptr = xmemAlloc(mi); /*(void *)xmalloc(amt*size); */ - assert(mi->my_ptr); - my_hash_insert(mem_table, mi->orig_ptr, mi); - mstat.callocs++; - break; + while (fgets(mbuf, 256, fp)!=NULL) { + if (run_stats>0 && (++a)%run_stats==0) print_stats(); + p=NULL; + switch(mbuf[0]) { + case 'm': /* malloc */ + p=strtok(&mbuf[2],":"); + if (!p) badformat(); + size=atoi(p); + p=strtok(NULL,"\n"); + if (!p) badformat(); + mi=malloc(sizeof(memitem)); + strcpy(mi->orig_ptr,p); + mi->size=size; + size2id(size,mi); + mi->my_ptr = xmemAlloc(mi); /* (void *)xmalloc(size); */ + assert(mi->my_ptr); + my_hash_insert(mem_table, mi->orig_ptr, mi); + mstat.mallocs++; + break; + case 'c': /* calloc */ + p=strtok(&mbuf[2],":"); + if (!p) badformat(); + amt=atoi(p); + p=strtok(NULL,":"); + if (!p) badformat(); + size=atoi(p); + p=strtok(NULL,"\n"); + if (!p) badformat(); + mi=malloc(sizeof(memitem)); + strcpy(mi->orig_ptr,p); + size2id(size,mi); + mi->size=amt*size; + mi->my_ptr= xmemAlloc(mi); /*(void *)xmalloc(amt*size);*/ + assert(mi->my_ptr); + my_hash_insert(mem_table, mi->orig_ptr, mi); + mstat.callocs++; + break; case 'r': - p = strtok(&mbuf[2], ":"); - if (!p) - badformat(); - strcpy(abuf, p); - p = strtok(NULL, ":"); - if (!p) - badformat(); - mem_entry = hash_lookup(mem_table, p); - if (mem_entry == NULL) { - fprintf(stderr, "invalid realloc (%s)!\n", p); + p=strtok(&mbuf[2],":"); + if (!p) badformat(); + strcpy(abuf,p); + p=strtok(NULL,":"); + if (!p) badformat(); + mem_entry=hash_lookup(mem_table, p); + if (mem_entry==NULL) { + fprintf(stderr,"invalid realloc (%s)!\n",p); break; - } - mi = (memitem *) (mem_entry->item); - assert(mi->pool); - assert(mi->my_ptr); - xmemFree(mi); /* xfree(mi->my_ptr); */ - size2id(atoi(p), mi); /* we don't need it here I guess? */ - strcpy(mi->orig_ptr, abuf); - p = strtok(NULL, "\n"); - if (!p) - badformat(); - mi->my_ptr = xmemAlloc(mi); /* (char *)xmalloc(atoi(p)); */ - assert(mi->my_ptr); - mstat.reallocs++; - break; + } + mi=(memitem *)(mem_entry->item); + assert(mi->pool); + assert(mi->my_ptr); + xmemFree(mi); /* xfree(mi->my_ptr); */ + size2id(atoi(p),mi); /* we don't need it here I guess? */ + strcpy(mi->orig_ptr,abuf); + p=strtok(NULL,"\n"); + if (!p) badformat(); + mi->my_ptr= xmemAlloc(mi); /* (char *)xmalloc(atoi(p)); */ + assert(mi->my_ptr); + mstat.reallocs++; + break; case 'f': - p = strtok(&mbuf[2], "\n"); - mem_entry = hash_lookup(mem_table, p); - if (mem_entry == NULL) { - if (p[0] != '0') - fprintf(stderr, "invalid free (%s) at line %d!\n", p, a); + p=strtok(&mbuf[2],"\n"); + mem_entry=hash_lookup(mem_table, p); + if (mem_entry==NULL) { + if (p[0]!='0') + fprintf(stderr,"invalid free (%s) at line %d!\n",p,a); break; - } - mi = (memitem *) (mem_entry->item); - assert(mi->pool); - assert(mi->my_ptr); - xmemFree(mi); /* xfree(mi->my_ptr); */ - hash_unlink(mem_table, mem_entry, 1); - free(mi); - mstat.frees++; - break; + } + mi=(memitem *)(mem_entry->item); + assert(mi->pool); + assert(mi->my_ptr); + xmemFree(mi); /* xfree(mi->my_ptr); */ + hash_unlink(mem_table, mem_entry, 1); + free(mi); + mstat.frees++; + break; default: - fprintf(stderr, "%s pummels %s.bad.format\n", argv[0], fn); - exit(1); + fprintf(stderr,"%s pummels %s.bad.format\n", argv[0],fn); + exit(1); } } @@ -229,19 +216,19 @@ void * my_xmalloc(size_t a) { - return NULL; + return NULL; } void * my_xcalloc(int a, size_t b) { - return NULL; + return NULL; } int my_xfree(void *p) { - return 0; + return 0; } void init_stats() @@ -253,36 +240,36 @@ print_stats() { #ifdef WITH_LIB - memReport(stdout); + memReport(stdout); #endif - getrusage(RUSAGE_SELF, &myusage); - printf("m/c/f/r=%d/%d/%d/%d\n", mstat.mallocs, mstat.callocs, - mstat.frees, mstat.reallocs); + getrusage(RUSAGE_SELF, &myusage); + printf("m/c/f/r=%d/%d/%d/%d\n",mstat.mallocs,mstat.callocs, + mstat.frees, mstat.reallocs); #if 0 - printf("types : %d\n", size2id_len); + printf("types : %d\n",size2id_len); #endif - printf("user time used : %d.%d\n", (int) myusage.ru_utime.tv_sec, - (int) myusage.ru_utime.tv_usec); - printf("system time used : %d.%d\n", (int) myusage.ru_stime.tv_sec, - (int) myusage.ru_stime.tv_usec); - printf("max resident set size : %d\n", (int) myusage.ru_maxrss); - printf("page faults : %d\n", (int) myusage.ru_majflt); + printf("user time used : %d.%d\n", (int)myusage.ru_utime.tv_sec, + (int)myusage.ru_utime.tv_usec); + printf("system time used : %d.%d\n", (int)myusage.ru_stime.tv_sec, + (int)myusage.ru_stime.tv_usec); + printf("max resident set size : %d\n",(int)myusage.ru_maxrss); + printf("page faults : %d\n", (int)myusage.ru_majflt); } void -size2id(size_t sz, memitem * mi) +size2id(size_t sz,memitem *mi) { #ifdef WITH_LIB - mi->pool = sizeToPool(sz); - assert(mi->pool); + mi->pool = sizeToPool(sz); + assert(mi->pool); #endif - return; + return; } void badformat() { - fprintf(stderr, "pummel.bad.format\n"); + fprintf(stderr,"pummel.bad.format\n"); exit(1); } @@ -290,22 +277,22 @@ const char * make_nam(int id, int size) { - const char *buf = malloc(30); /* argh */ - sprintf((char *) buf, "pl:%d/%d", id, size); + const char *buf = malloc(30); /* argh */ + sprintf((char *)buf, "pl:%d/%d", id, size); return buf; } void -my_hash_insert(hash_table * h, const char *k, memitem * item) -{ - memitem *l; - assert(item->pool); - assert(item->my_ptr); - hash_insert(h, k, item); +my_hash_insert(hash_table *h, const char *k, memitem *item) +{ + memitem *l; + assert( item->pool); + assert( item->my_ptr); + hash_insert(h,k,item); } static void * -xmemAlloc(memitem * item) +xmemAlloc(memitem *item) { extern MemPool *StringPool; assert(item && item->pool); @@ -316,24 +303,23 @@ } static void -xmemFree(memitem * item) +xmemFree(memitem *item) { extern MemPool *StringPool; assert(item && item->pool); if (StringPool == item->pool) - return memStringFree(item->pool, item->my_ptr, item->size); + return memStringFree(item->pool, item->my_ptr, item->size); else - return memFree(item->pool, item->my_ptr); + return memFree(item->pool, item->my_ptr); } -void -my_free(char *file, int line, void *ptr) +void my_free(char *file, int line, void *ptr) { #if 0 - fprintf(stderr, "{%s:%d:%p", file, line, ptr); +fprintf(stderr,"{%s:%d:%p",file,line,ptr); #endif - free(ptr); -#if 0 - fprintf(stderr, "}\n"); +free(ptr); +#if 0 +fprintf(stderr,"}\n"); #endif } Index: squid/test-suite/pconn-banger.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/pconn-banger.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/test-suite/pconn-banger.c 27 Aug 2001 21:48:22 -0000 1.1.1.1.76.1 +++ squid/test-suite/pconn-banger.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -1,4 +1,6 @@ + #include "config.h" + /* * On some systems, FD_SETSIZE is set to something lower than the * actual number of files which can be opened. IRIX is one case, @@ -110,8 +112,7 @@ #define REPLY_HDR_SZ 8192 -struct _r -{ +struct _r { char url[1024]; int content_length; int hdr_length; @@ -166,6 +167,7 @@ } int + open_http_socket(void) { int s; @@ -189,7 +191,7 @@ int send_request(int fd, const char *data) { - char msg[4096], buf[4096]; + char msg[4096],buf[4096]; int len; time_t w; struct _r *r; @@ -198,24 +200,24 @@ char *tmp = strdup(data); struct stat st; int file_fd = -1; - method = strtok(tmp, " "); - url = strtok(NULL, " "); - file = strtok(NULL, " "); - size = strtok(NULL, " "); - checksum = strtok(NULL, " "); + method=strtok(tmp, " "); + url=strtok(NULL, " "); + file=strtok(NULL, " "); + size=strtok(NULL, " "); + checksum=strtok(NULL, " "); if (!url) { - url = method; - method = "GET"; + url=method; + method="GET"; } - if (file && strcmp(file, "-") == 0) - file = NULL; - if (size && strcmp(size, "-") == 0) - size = NULL; - if (checksum && strcmp(checksum, "-") == 0) - checksum = NULL; + if (file && strcmp(file,"-")==0) + file=NULL; + if (size && strcmp(size,"-")==0) + size=NULL; + if (checksum && strcmp(checksum,"-")==0) + checksum=NULL; msg[0] = '\0'; sprintf(buf, "%s %s HTTP/1.0\r\n", method, url); - strcat(msg, buf); + strcat(msg,buf); strcat(msg, "Accept: */*\r\n"); strcat(msg, "Proxy-Connection: Keep-Alive\r\n"); if (opt_ims && (lrand48() & 0x03) == 0) { @@ -224,11 +226,11 @@ strcat(msg, buf); } if (file) { - if ((file_fd = open(file, O_RDONLY)) < 0) { + if ( (file_fd = open(file,O_RDONLY)) < 0) { perror("open"); return -1; } - if (fstat(file_fd, &st)) { + if ( fstat(file_fd, &st) ) { perror("fstat"); close(file_fd); return -1; @@ -245,7 +247,7 @@ return -1; } if (file) { - while ((len = read(file_fd, buf, sizeof buf)) > 0) { + while((len=read(file_fd, buf, sizeof buf)) > 0) { if (write(fd, buf, len) < 0) { close(fd); perror("body write"); @@ -300,8 +302,8 @@ t += strlen(hdr); while (isspace(*t)) t++; - strcpy(result, ""); - strncat(result, t, strcspn(t, crlf)); + strcpy(result,""); + strncat(result,t,strcspn(t, crlf)); return result; } } @@ -313,19 +315,20 @@ { #if 0 fprintf(stderr, "DONE: %s, (%d+%d)\n", - r->url, r->hdr_length, r->content_length); + r->url, + r->hdr_length, + r->content_length); #endif if (r->content_length != r->bytes_read) fprintf(stderr, "ERROR! Short reply, expected %d bytes got %d\n", r->content_length, r->bytes_read); else if (r->validsize >= 0) { if (r->validsize != r->bytes_read) - fprintf(stderr, - "WARNING: %s Object size mismatch, expected %d got %d\n", - r->url, r->validsize, r->bytes_read); + fprintf(stderr, "WARNING: %s Object size mismatch, expected %d got %d\n", + r->url, r->validsize, r->bytes_read); else if (opt_checksum && r->sum != r->validsum) fprintf(stderr, "WARNING: %s Checksum error. Expected %d got %d\n", - r->url, r->validsum, r->sum); + r->url, r->validsum, r->sum); } } int @@ -335,22 +338,21 @@ const char *end; const char *url; static char buf[READ_BUF_SZ]; - int hlen, blen; - if (len < 0) { + int hlen,blen; + if (len < 0 ) { perror("read"); Requests = r->next; request_done(r); free(r); noutstanding--; if (trace_fd >= 0) - write(trace_fd, "\n[CLOSED]\n", 10); + write(trace_fd,"\n[CLOSED]\n",10); return -1; } total_bytes_read += len; - xmemcpy(buf, inbuf, len); + xmemcpy(buf,inbuf,len); if (len == 0) { - fprintf(stderr, "WARNING: %s, server closed socket after %d+%d bytes\n", - r->url, r->hdr_offset, r->bytes_read); + fprintf(stderr, "WARNING: %s, server closed socket after %d+%d bytes\n", r->url, r->hdr_offset, r->bytes_read); /* XXX, If no data was received and it isn't the first request on this * connection then the request should be restarted rather than aborted * but this is a simple test program an not a full blown HTTP client. @@ -375,15 +377,13 @@ xmemmove(buf, buf + hlen, len); } /* Process headers */ - if (r->hdr_length == 0 - && (end = mime_headers_end(r->reply_hdrs)) != NULL) { + if (r->hdr_length == 0 && (end = mime_headers_end(r->reply_hdrs)) != NULL) { #if 0 - fprintf(stderr, "FOUND EOH FOR %s\n", r->url); - */ + fprintf(stderr, "FOUND EOH FOR %s\n", r->url); */ #endif - r->hdr_length = end - r->reply_hdrs; + r->hdr_length = end - r->reply_hdrs; #if 0 - fprintf(stderr, "HDR_LENGTH = %d\n", r->hdr_length); + fprintf(stderr, "HDR_LENGTH = %d\n", r->hdr_length); #endif /* "unread" any body contents received */ blen = r->hdr_offset - r->hdr_length; @@ -393,22 +393,20 @@ xmemcpy(buf, r->reply_hdrs + r->hdr_length, blen); len += blen; } - r->reply_hdrs[r->hdr_length] = '\0'; /* Null terminate headers */ + r->reply_hdrs[r->hdr_length]='\0'; /* Null terminate headers */ /* Parse headers */ - r->content_length = - get_header_int_value("content-length:", r->reply_hdrs, end); + r->content_length = get_header_int_value("content-length:", r->reply_hdrs, end); /* fprintf(stderr, "CONTENT_LENGTH = %d\n", r->content_length); */ url = get_header_string_value("X-Request-URI:", r->reply_hdrs, end); if (url != NULL && strcmp(r->url, url) != 0) fprintf(stderr, "WARNING: %s got reply %s\n", r->url, url); #if XREQUESTURI || 0 - fprintf(stderr, "LOCATION = %s\n", - get_header_string_value("X-Request-URI:", r->reply_hdrs, end)); + fprintf(stderr, "LOCATION = %s\n", get_header_string_value("X-Request-URI:", r->reply_hdrs, end)); #endif } - if (!(len == 0 || r->hdr_length > 0)) { + if ( !(len==0 || r->hdr_length > 0) ) { fprintf(stderr, "ERROR!!!\n"); - assert((len == 0 || r->hdr_length > 0)); + assert((len==0 || r->hdr_length > 0)); } /* Process body */ if (r->hdr_length != 0) { @@ -417,14 +415,14 @@ if (r->content_length >= 0) { bytes_left = r->content_length - r->bytes_read; assert(bytes_left >= 0); - bytes_used = len < bytes_left ? len : bytes_left; + bytes_used = len < bytes_left ? len : bytes_left; } else { - bytes_left = len + 1; /* Unknown end... */ + bytes_left = len + 1; /* Unknown end... */ bytes_used = len; } if (opt_checksum) { - for (i = 0; i < bytes_used; i++) - r->sum += (int) buf[i] & 0xFF; + for(i=0; isum += (int)buf[i] & 0xFF; } r->bytes_read += bytes_used; len -= bytes_used; @@ -464,7 +462,7 @@ static int pconn_fd = -1; static char buf[8192]; struct timeval to; - struct timeval now, last, start; + struct timeval now,last,start; fd_set R; struct _r *r; struct _r *nextr; @@ -482,10 +480,10 @@ } while (!done_reading_urls || noutstanding) { if (!opt_reopen && pconn_fd < 0) { - fprintf(stderr, "TERMINATED: Connection closed\n"); + fprintf(stderr,"TERMINATED: Connection closed\n"); break; } - if (pconn_fd < 0) { + if (pconn_fd<0) { pconn_fd = open_http_socket(); if (pconn_fd < 0) { perror("socket"); @@ -493,14 +491,14 @@ } nextr = Requests; Requests = NULL; - noutstanding = 0; + noutstanding=0; while ((r = nextr) != NULL) { nextr = r->next; if (send_request(pconn_fd, r->url) != 0) { close(pconn_fd); - pconn_fd = -1; + pconn_fd=-1; nextr = r; - for (r = Requests; r != NULL && r->next; r = r->next); + for (r = Requests; r!=NULL && r->next; r=r->next); if (r != NULL) r->next = nextr; else @@ -510,7 +508,7 @@ free(r); } timeouts = 0; - if (pconn_fd < 0) + if (pconn_fd <0) continue; } if (timeouts == 200) { @@ -522,8 +520,7 @@ free(r); noutstanding--; } - if (pconn_fd >= 0 && noutstanding < max_outstanding - && !done_reading_urls) { + if (pconn_fd>=0 && noutstanding < max_outstanding && !done_reading_urls) { char *t; if (fgets(buf, 8191, stdin) == NULL) { fprintf(stderr, "Done Reading URLS\n"); @@ -535,7 +532,7 @@ *t = '\0'; if (send_request(pconn_fd, buf) != 0) { close(pconn_fd); - pconn_fd = -1; + pconn_fd=-1; continue; } nrequests++; @@ -563,19 +560,21 @@ pconn_fd = -1; } gettimeofday(&now, NULL); - if (now.tv_sec > last.tv_sec) { + if (now.tv_sec > last.tv_sec) { int dt; int nreq; last = now; dt = (int) (now.tv_sec - start.tv_sec); - nreq = 0; - for (r = Requests; r; r = r->next) - nreq++; - printf - ("T+ %6d: %9d req (%+4d), %4d pend, %3d/sec avg, %dmb, %dkb/sec avg\n", - dt, nrequests, reqpersec, nreq, (int) (nrequests / dt), - (int) total_bytes_read / 1024 / 1024, - (int) total_bytes_read / 1024 / dt); + nreq=0; + for (r=Requests; r ; r=r->next) nreq++; + printf("T+ %6d: %9d req (%+4d), %4d pend, %3d/sec avg, %dmb, %dkb/sec avg\n", + dt, + nrequests, + reqpersec, + nreq, + (int) (nrequests / dt), + (int)total_bytes_read / 1024 / 1024, + (int)total_bytes_read / 1024 / dt); reqpersec = 0; } } @@ -584,9 +583,7 @@ void usage(void) { - fprintf(stderr, - "usage: %s: -p port -h host -n max -t tracefile -i -c -l lifetime\n", - progname); + fprintf(stderr, "usage: %s: -p port -h host -n max -t tracefile -i -c -l lifetime\n", progname); } int @@ -619,7 +616,7 @@ lifetime = (time_t) atoi(optarg); break; case 't': - trace_fd = open(optarg, O_WRONLY | O_CREAT | O_TRUNC, 0666); + trace_fd = open(optarg,O_WRONLY|O_CREAT|O_TRUNC,0666); break; case 'r': opt_reopen = !opt_reopen; Index: squid/test-suite/tcp-banger2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/tcp-banger2.c,v retrieving revision 1.1.1.3.30.1.2.1 retrieving revision 1.1.1.3.30.1.2.2 diff -u -r1.1.1.3.30.1.2.1 -r1.1.1.3.30.1.2.2 --- squid/test-suite/tcp-banger2.c 27 Aug 2001 21:48:22 -0000 1.1.1.3.30.1.2.1 +++ squid/test-suite/tcp-banger2.c 9 Sep 2001 09:49:48 -0000 1.1.1.3.30.1.2.2 @@ -1,5 +1,7 @@ #include "config.h" -/* $Id: tcp-banger2.c,v 1.1.1.3.30.1.2.1 2001/08/27 21:48:22 tolsty Exp $ */ + +/* $Id: tcp-banger2.c,v 1.1.1.3.30.1.2.2 2001/09/09 09:49:48 serassio Exp $ */ + /* * On some systems, FD_SETSIZE is set to something lower than the * actual number of files which can be opened. IRIX is one case, @@ -109,15 +111,13 @@ typedef void (CB) (int, void *); -struct _f -{ +struct _f { CB *cb; CB *ccb; void *data; time_t start; }; -struct _request -{ +struct _request { int fd; char *url; char method[16]; @@ -229,8 +229,7 @@ r->content_length = atoi(header + 15); else if (strncasecmp(header, "X-Request-URI:", 14) == 0) { /* Check URI */ - if (strncmp(r->url, header + 15, strcspn(header + 15, - "\r\n"))) { + if (strncmp(r->url, header + 15, strcspn(header + 15, "\r\n"))) { char url[8192]; strncpy(url, header + 15, strcspn(header + 15, "\r\n")); url[strcspn(header + 15, "\r\n")] = '\n'; @@ -273,22 +272,19 @@ r->url, r->bodysize, r->content_length); else if (r->validsize >= 0) { if (r->validsize != r->bodysize) - fprintf(stderr, - "WARNING: %s size mismatch wanted %d bytes got %d\n", r->url, - r->validsize, r->bodysize); + fprintf(stderr, "WARNING: %s size mismatch wanted %d bytes got %d\n", + r->url, r->validsize, r->bodysize); else if (opt_checksum && r->validsum != r->sum) - fprintf(stderr, - "WARNING: %s invalid checksum wanted 0x%lx got 0x%lx\n", r->url, - r->validsum, r->sum); + fprintf(stderr, "WARNING: %s invalid checksum wanted 0x%lx got 0x%lx\n", + r->url, r->validsum, r->sum); } if (trace_file) { if (opt_checksum) fprintf(trace_file, "%s %s %d %s %d 0x%lx\n", - r->method, r->url, r->status, r->requestbodyfile, r->bodysize, - r->sum); + r->method, r->url, r->status, r->requestbodyfile, r->bodysize, r->sum); else - fprintf(trace_file, "%s %s %d %s %d\n", r->method, r->url, - r->status, r->requestbodyfile, r->bodysize); + fprintf(trace_file, "%s %s %d %s %d\n", + r->method, r->url, r->status, r->requestbodyfile, r->bodysize); } free_request(r); } @@ -468,8 +464,7 @@ fprintf(stderr, " -t Save request trace\n"); fprintf(stderr, " -c Check checksum agains trace\n"); fprintf(stderr, " -i Send random If-Modified-Since times\n"); - fprintf(stderr, - " -l Connection lifetime timeout (default 60)\n"); + fprintf(stderr, " -l Connection lifetime timeout (default 60)\n"); fprintf(stderr, " -a Accelerator mode\n"); } @@ -574,9 +569,12 @@ if (now.tv_sec > last.tv_sec) { last = now; dt = (int) (now.tv_sec - start.tv_sec); - printf - ("T+ %6d: %9d req (%+4d), %4d conn, %3d/sec avg, %dmb, %dkb/sec avg\n", - dt, nrequests, reqpersec, nfds, (int) (nrequests / dt), + printf("T+ %6d: %9d req (%+4d), %4d conn, %3d/sec avg, %dmb, %dkb/sec avg\n", + dt, + nrequests, + reqpersec, + nfds, + (int) (nrequests / dt), (int) total_bytes_read / 1024 / 1024, (int) total_bytes_read / 1024 / dt); reqpersec = 0; Index: squid/test-suite/tcp-banger3.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/tcp-banger3.c,v retrieving revision 1.1.1.2.76.1 retrieving revision 1.1.1.2.76.2 diff -u -r1.1.1.2.76.1 -r1.1.1.2.76.2 --- squid/test-suite/tcp-banger3.c 27 Aug 2001 21:48:22 -0000 1.1.1.2.76.1 +++ squid/test-suite/tcp-banger3.c 9 Sep 2001 09:49:48 -0000 1.1.1.2.76.2 @@ -1,4 +1,5 @@ #include "config.h" + /* * On some systems, FD_SETSIZE is set to something lower than the * actual number of files which can be opened. IRIX is one case, @@ -87,8 +88,7 @@ #define READ_BUF_SZ 4096 #define URL_BUF_SZ 4096 -struct _thing -{ +struct _thing { int rfd; int wfd; int state; @@ -150,8 +150,7 @@ S.sin_port = htons(port); S.sin_family = AF_INET; if (debug) - fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntoa(S.sin_addr), - (int) port, path); + fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntoa(S.sin_addr), (int) port, path); s = socket(PF_INET, SOCK_STREAM, 0); if (s < 0) { perror("socket"); @@ -165,7 +164,11 @@ snprintf(request, URL_BUF_SZ, "GET %s HTTP/1.1\r\n" "Accept: */*\r\n" - "Host: %s\r\n" "Connection: close\r\n" "\r\n", path, host); + "Host: %s\r\n" + "Connection: close\r\n" + "\r\n", + path, + host); x = write(s, request, strlen(request)); if (x < 0) { perror("write"); @@ -189,8 +192,7 @@ struct timeval t1; struct timeval t2; if (debug) - fprintf(stderr, "Child PID %d entering child_main_loop\n", - (int) getpid()); + fprintf(stderr, "Child PID %d entering child_main_loop\n", (int) getpid()); setbuf(stdin, NULL); setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -261,7 +263,8 @@ t = create_a_thing(argv); assert(t); if (debug) - fprintf(stderr, "Thing #%d on FD %d/%d\n", i, t->rfd, t->wfd); + fprintf(stderr, "Thing #%d on FD %d/%d\n", + i, t->rfd, t->wfd); *T = t; T = &t->next; } @@ -302,8 +305,7 @@ if (x < 0) perror("write"); if (debug) - fprintf(stderr, "dispatched URL to thing PID %d, %d bytes\n", - (int) t->pid, x); + fprintf(stderr, "dispatched URL to thing PID %d, %d bytes\n", (int) t->pid, x); strncpy(t->url, url, URL_BUF_SZ); if ((s = strchr(t->url, '\n'))) *s = '\0'; @@ -323,8 +325,7 @@ perror("read"); } else if (2 == sscanf(buf, "%d %d", &i, &j)) { gettimeofday(&now, NULL); - printf("%d.%06d %9d %9d %s\n", (int) now.tv_sec, (int) now.tv_usec, i, - j, t->url); + printf("%d.%06d %9d %9d %s\n", (int) now.tv_sec, (int) now.tv_usec, i, j, t->url); } t->state = 0; FD_CLR(t->rfd, &R1); @@ -381,7 +382,7 @@ signal(SIGCHLD, sig_child); create_children(argv); parent_main_loop(); - for (i = 3; i <= maxfd; i++) + for (i=3;i<=maxfd; i++) close(i); sleep(1); } Index: squid/test-suite/waiter.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/waiter.c,v retrieving revision 1.1.1.1.76.1 retrieving revision 1.1.1.1.76.2 diff -u -r1.1.1.1.76.1 -r1.1.1.1.76.2 --- squid/test-suite/waiter.c 27 Aug 2001 21:48:22 -0000 1.1.1.1.76.1 +++ squid/test-suite/waiter.c 9 Sep 2001 09:49:48 -0000 1.1.1.1.76.2 @@ -1,23 +1,24 @@ #include #include + int main(int argc, char *argv[]) { - int i; - struct timeval now; - struct timeval alarm; - struct timeval to; - assert(argc == 2); - i = atoi(argv[1]); - gettimeofday(&now, NULL); - alarm.tv_sec = now.tv_sec + i + (now.tv_sec % i); - alarm.tv_usec = 0; - to.tv_sec = alarm.tv_sec - now.tv_sec; - to.tv_usec = alarm.tv_usec - now.tv_usec; - if (to.tv_usec < 0) { - to.tv_usec += 1000000; - to.tv_sec -= 1; - } - select(1, NULL, NULL, NULL, &to); - return 0; + int i; + struct timeval now; + struct timeval alarm; + struct timeval to; + assert(argc == 2); + i = atoi(argv[1]); + gettimeofday(&now, NULL); + alarm.tv_sec = now.tv_sec + i + (now.tv_sec % i); + alarm.tv_usec = 0; + to.tv_sec = alarm.tv_sec - now.tv_sec; + to.tv_usec = alarm.tv_usec - now.tv_usec; + if (to.tv_usec < 0) { + to.tv_usec += 1000000; + to.tv_sec -= 1; + } + select(1, NULL, NULL, NULL, &to); + return 0; }