[srvx-commits] CVS: services/src Makefile.am,1.40,1.41 common.h,1.68,1.69 conf.c,1.22,1.23 config.h.
Brought to you by:
entrope
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv20453/src Modified Files: Makefile.am common.h conf.c config.h.in dict-hash.c dict-splay.c dict.h gline.c gline.h hash.c hash.h heap.c log.c log.h main.c md5.c mod_common.c proto.c proto.h proto_bahamut.c proto_ircu_p10.c recdb.c rules.c saxdb.c sockcheck.c timeq.c timeq.h uplink.h Removed Files: md5.h Log Message: squash various lclint warnings Index: Makefile.am =================================================================== RCS file: /cvsroot/srvx/services/src/Makefile.am,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** Makefile.am 2001/09/28 15:21:29 1.40 --- Makefile.am 2001/10/02 16:04:36 1.41 *************** *** 8,12 **** srvx_LDFLAGS = $(export_dynamic_flag_spec) srvx_SOURCES = \ - alias.c alias.h \ compat.c compat.h \ conf.c conf.h \ --- 8,11 ---- *************** *** 19,23 **** log.c log.h \ main.c messages.h common.h \ ! md5.c md5.h \ modules.c modules.h \ policer.c policer.h \ --- 18,22 ---- log.c log.h \ main.c messages.h common.h \ ! md5.c \ modules.c modules.h \ policer.c policer.h \ *************** *** 48,49 **** --- 47,53 ---- globtest_SOURCES = tools.c globtest.c common.h globtest_CFLAGS = -DGLOBTEST + + LINT = lclint + LINTOPTS = +showscan +posixlib -boolops -predboolint -noeffect + lint: + $(LINT) $(LINTOPTS) compat.c conf.c dict-splay.c getopt.c getopt1.c gline.c hash.c heap.c log.c main.c md5.c mod_common.c modules.c policer.c proto.c proto_bahamut.c recdb.c rules.c saxdb.c service.c timeq.c Index: common.h =================================================================== RCS file: /cvsroot/srvx/services/src/common.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** common.h 2001/09/27 21:58:07 1.68 --- common.h 2001/10/02 16:04:36 1.69 *************** *** 51,54 **** --- 51,60 ---- #endif + #ifdef __GNUC__ + #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N))) + #else + #define PRINTF_LIKE(M,N) + #endif + #define SOCKCHECK_USABLE (defined(HAVE_POLL) && defined(HAVE_PTHREAD) && !defined(__CYGWIN__)) *************** *** 65,69 **** #define ArrayLength(x) (sizeof(x)/sizeof(x[0])) ! #define safestrncpy(dest, src, len) do { char *d = (dest); unsigned int l = (len); strncpy(d, (src), l); d[l-1] = 0; } while (0) #if WITH_DMALLOC --- 71,75 ---- #define ArrayLength(x) (sizeof(x)/sizeof(x[0])) ! #define safestrncpy(dest, src, len) do { unsigned char *d = (dest); size_t l = (len); strncpy(d, (src), l); d[l-1] = '\0'; } while (0) #if WITH_DMALLOC *************** *** 73,96 **** #endif - extern time_t now; - - struct userNode *AddService(const char *nick, const char *desc); - struct userNode *AddClone(const char *nick, const char *username, const char *hostname, const char *desc); - - int read_from_socket(void); - void close_socket(void); - - typedef void (*exit_func_t)(void); - void reg_exit_func(exit_func_t handler); - void call_exit_funcs(void); - - typedef void (*db_write_func_t)(void); - void reg_db_write_func(db_write_func_t handler); - void write_databases(void); - - #define MD5_CRYPT_LENGTH 33 - const char *cryptpass(const char *pass, char buffer[MD5_CRYPT_LENGTH]); - int checkpass(const char *pass, const char *crypt); - #define DECLARE_LIST(STRUCTNAME,ITEMTYPE) struct STRUCTNAME {\ unsigned int used, size;\ --- 79,82 ---- *************** *** 130,133 **** --- 116,133 ---- free(list->list);\ } + + extern time_t now; + + typedef void (*exit_func_t)(void); + void reg_exit_func(exit_func_t handler); + void call_exit_funcs(void); + + typedef void (*db_write_func_t)(void); + void reg_db_write_func(db_write_func_t handler); + void write_databases(void); + + #define MD5_CRYPT_LENGTH 33 + const char *cryptpass(const char *pass, char buffer[]); + int checkpass(const char *pass, const char *crypt); #endif /* ifdef _COMMON_H_ */ Index: conf.c =================================================================== RCS file: /cvsroot/srvx/services/src/conf.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** conf.c 2001/08/01 22:14:35 1.22 --- conf.c 2001/10/02 16:04:36 1.23 *************** *** 20,32 **** #include "config.h" ! #ifdef HAVE_ERRNO_H #include <errno.h> - #endif - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> - #endif #include "common.h" --- 20,27 ---- #include "config.h" ! #include <assert.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "common.h" *************** *** 39,44 **** static dict_t conf_db; static dict_t conf_server; static conf_reload_func *reload_funcs; ! static int num_rfs, size_rfs; void --- 34,40 ---- static dict_t conf_db; static dict_t conf_server; + static conf_reload_func *reload_funcs; ! static size_t num_rfs, size_rfs; void *************** *** 46,51 **** { if (num_rfs >= size_rfs) { ! size_rfs <<= 1; ! reload_funcs = realloc(reload_funcs, size_rfs*sizeof(conf_reload_func)); } reload_funcs[num_rfs++] = crf; --- 42,54 ---- { if (num_rfs >= size_rfs) { ! if (!reload_funcs) { ! size_rfs = 8; ! reload_funcs = calloc(size_rfs, sizeof(conf_reload_func)); ! assert(reload_funcs != NULL); ! } else { ! size_rfs <<= 1; ! reload_funcs = realloc(reload_funcs, size_rfs*sizeof(conf_reload_func)); ! assert(reload_funcs != NULL); ! } } reload_funcs[num_rfs++] = crf; *************** *** 55,59 **** conf_call_reload_funcs(void) { ! int i; for (i=0; i<num_rfs; i++) reload_funcs[i](); } --- 58,62 ---- conf_call_reload_funcs(void) { ! size_t i; for (i=0; i<num_rfs; i++) reload_funcs[i](); } *************** *** 62,88 **** conf_read(const char *conf_file_name) { ! dict_t old_conf = conf_db; ! if (!(conf_db = parse_database(conf_file_name))) { ! goto fail; ! } ! if (!(conf_server = database_get_data(conf_db, "server", RECDB_OBJECT))) { ! log(MAIN_LOG, LOG_ERROR, "No server section found in config file.\n"); ! goto fail; ! } ! if (!reload_funcs) { ! size_rfs = 5; ! reload_funcs = malloc(size_rfs*sizeof(conf_reload_func)); ! num_rfs = 0; ! } else { ! conf_call_reload_funcs(); } ! if (old_conf && old_conf != conf_db) free_database(old_conf); return 1; - - fail: - log(MAIN_LOG, LOG_ERROR, "Reverting to previous configuration.\n"); - if (conf_db) free_database(conf_db); - conf_db = old_conf; - return 0; } --- 65,79 ---- conf_read(const char *conf_file_name) { ! dict_t new_conf; ! ! if (!(new_conf = parse_database(conf_file_name)) ! || !(conf_server = database_get_data(new_conf, "server", RECDB_OBJECT))) { ! log(MAIN_LOG, LOG_ERROR, "Reverting to previous configuration\n"); ! return 0; } ! free_database(conf_db); ! conf_db = new_conf; ! conf_call_reload_funcs(); return 1; } *************** *** 93,98 **** free_database(conf_db); conf_db = NULL; } - if (reload_funcs) free(reload_funcs); } --- 84,92 ---- free_database(conf_db); conf_db = NULL; + } + if (reload_funcs) { + free(reload_funcs); + reload_funcs = NULL; } } *************** *** 127,131 **** int conf_server_ping_freq(void) { ! const char *text = database_get_data(conf_server, "ping_freq", RECDB_QSTRING); return text ? (signed)ParseInterval(text) : -1; } --- 121,125 ---- int conf_server_ping_freq(void) { ! const unsigned char *text = database_get_data(conf_server, "ping_freq", RECDB_QSTRING); return text ? (signed)ParseInterval(text) : -1; } *************** *** 133,137 **** int conf_server_ping_timeout(void) { ! const char *text = database_get_data(conf_server, "ping_timeout", RECDB_QSTRING); return text ? (signed)ParseInterval(text) : -1; } --- 127,131 ---- int conf_server_ping_timeout(void) { ! const unsigned char *text = database_get_data(conf_server, "ping_timeout", RECDB_QSTRING); return text ? (signed)ParseInterval(text) : -1; } Index: config.h.in =================================================================== RCS file: /cvsroot/srvx/services/src/config.h.in,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** config.h.in 2001/09/28 15:18:20 1.26 --- config.h.in 2001/10/02 16:04:36 1.27 *************** *** 292,295 **** --- 292,298 ---- #undef HAVE_SYS_RESOURCE_H + /* Define if you have the <sys/select.h> header file. */ + #undef HAVE_SYS_SELECT_H + /* Define if you have the <sys/socket.h> header file. */ #undef HAVE_SYS_SOCKET_H Index: dict-hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/dict-hash.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dict-hash.c 2001/07/18 02:03:02 1.3 --- dict-hash.c 2001/10/02 16:04:36 1.4 *************** *** 38,42 **** struct dict { struct dict_node **table; ! unsigned int used, size; free_f free_keys, free_data; }; --- 38,42 ---- struct dict { struct dict_node **table; ! size_t used, size; free_f free_keys, free_data; }; *************** *** 51,57 **** unsigned int accum; for (i=0; i<256; i++) { ! accum = tolower(i) << 24; for (j=0; j<8; j++) { ! if (accum & 0x8000000) { accum = (accum << 1) ^ POLYNOMIAL; } else { --- 51,57 ---- unsigned int accum; for (i=0; i<256; i++) { ! accum = ((unsigned int)tolower(i)) << 24; for (j=0; j<8; j++) { ! if ((accum & 0x8000000) != 0) { accum = (accum << 1) ^ POLYNOMIAL; } else { *************** *** 66,70 **** dict_hash(dict_t dict, const unsigned char *string) { ! int accum = 0; while (*string) { accum = (accum << 8) ^ crc_table[((accum >> 24) ^ *string++) & 0xFF]; --- 66,70 ---- dict_hash(dict_t dict, const unsigned char *string) { ! unsigned int accum = 0; while (*string) { accum = (accum << 8) ^ crc_table[((accum >> 24) ^ *string++) & 0xFF]; *************** *** 78,96 **** static int crc_init; dict_t dict; ! if (!crc_init) { gen_crc_table(); crc_init = 1; } dict = malloc(sizeof(struct dict)); dict->used = 0; dict->size = 8; - dict->table = malloc(dict->size*sizeof(dict->table[0])); - memset(dict->table, 0, dict->size*sizeof(dict->table[0])); dict->free_keys = NULL; dict->free_data = NULL; return dict; } ! unsigned int dict_size(dict_t dict) { --- 78,100 ---- static int crc_init; dict_t dict; ! if (crc_init == 0) { gen_crc_table(); crc_init = 1; } dict = malloc(sizeof(struct dict)); + if (!dict) return NULL; dict->used = 0; dict->size = 8; dict->free_keys = NULL; dict->free_data = NULL; + dict->table = calloc(dict->size, sizeof(dict->table[0])); + if (!dict->table) { + free(dict); + return NULL; + } return dict; } ! size_t dict_size(dict_t dict) { *************** *** 113,117 **** dict_foreach(dict_t dict, dict_iterator_f it, void *extra) { ! unsigned int i; struct dict_node *node; --- 117,121 ---- dict_foreach(dict_t dict, dict_iterator_f it, void *extra) { ! size_t i; struct dict_node *node; *************** *** 132,137 **** old_size = dict->size; dict->size <<= 1; ! new_table = malloc(dict->size*sizeof(new_table[0])); ! memset(new_table, 0, dict->size*sizeof(new_table[0])); for (i=0; i<old_size; i++) { for (node=dict->table[i]; node; node=next) { --- 136,140 ---- old_size = dict->size; dict->size <<= 1; ! new_table = calloc(dict->size, sizeof(new_table[0])); for (i=0; i<old_size; i++) { for (node=dict->table[i]; node; node=next) { Index: dict-splay.c =================================================================== RCS file: /cvsroot/srvx/services/src/dict-splay.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** dict-splay.c 2001/07/15 14:49:25 1.2 --- dict-splay.c 2001/10/02 16:04:36 1.3 *************** *** 20,23 **** --- 20,24 ---- #include "config.h" + #include <assert.h> #include <stdlib.h> #include <string.h> *************** *** 36,40 **** free_f free_keys, free_data; struct dict_node *root; ! unsigned int count; }; --- 37,41 ---- free_f free_keys, free_data; struct dict_node *root; ! size_t count; }; *************** *** 45,54 **** dict_new(void) { ! dict_t dict; ! dict = malloc(sizeof(struct dict)); ! dict->free_keys = NULL; ! dict->free_data = NULL; ! dict->root = NULL; ! dict->count = 0; return dict; } --- 46,51 ---- dict_new(void) { ! dict_t dict = calloc(1, sizeof(*dict)); ! assert(dict != NULL); return dict; } *************** *** 57,61 **** * Return number of entries in the dictionary. */ ! unsigned int dict_size(dict_t dict) { --- 54,58 ---- * Return number of entries in the dictionary. */ ! size_t dict_size(dict_t dict) { *************** *** 94,101 **** { struct dict_node *halter; ! if (!node) return NULL; ! if ((halter = dict_foreach_subtree(node->l, it, extra))) goto out; if (it(node->key, node->data, extra)) { halter = node; goto out; } ! halter = dict_foreach_subtree(node->r, it, extra); out: return halter; --- 91,97 ---- { struct dict_node *halter; ! if (node->l && (halter = dict_foreach_subtree(node->l, it, extra))) goto out; if (it(node->key, node->data, extra)) { halter = node; goto out; } ! halter = node->r ? dict_foreach_subtree(node->r, it, extra) : NULL; out: return halter; *************** *** 113,117 **** { struct dict_node *halter; ! halter = dict_foreach_subtree(dict->root, it, extra); return halter ? halter->key : NULL; } --- 109,113 ---- { struct dict_node *halter; ! halter = dict->root ? dict_foreach_subtree(dict->root, it, extra) : NULL; return halter ? halter->key : NULL; } *************** *** 126,132 **** { struct dict_node N, *l, *r, *y; ! if (!node) return NULL; N.l = N.r = NULL; l = r = &N; while (1) { --- 122,129 ---- { struct dict_node N, *l, *r, *y; ! N.l = N.r = NULL; l = r = &N; + assert(node != NULL); while (1) { *************** *** 174,177 **** --- 171,176 ---- dict_dispose_node(struct dict_node *node, free_f free_keys, free_f free_data) { + if (node->l) dict_dispose_node(node->l, free_keys, free_data); + if (node->r) dict_dispose_node(node->r, free_keys, free_data); if (free_keys && node->key) free_keys((void*)node->key); if (free_data && node->data) free_data(node->data); *************** *** 187,193 **** dict_insert(dict_t dict, const char *key, void *data) { ! struct dict_node *new_node; ! if (!key) return; ! new_node = malloc(sizeof(struct dict_node)); new_node->key = key; new_node->data = data; --- 186,198 ---- dict_insert(dict_t dict, const char *key, void *data) { ! struct dict_node *new_node = NULL; ! if (!key || !(new_node = malloc(sizeof(*new_node)))) { ! if (dict->free_keys) dict->free_keys((void*)key); ! if (dict->free_data) dict->free_data(data); ! if (new_node) free(new_node); ! return; ! } ! new_node->l = NULL; ! new_node->r = NULL; new_node->key = key; new_node->data = data; *************** *** 216,220 **** } } else { - new_node->l = new_node->r = NULL; dict->root = new_node; } --- 221,224 ---- *************** *** 223,231 **** /* ! * Remove an entry from the dictionary. ! * Return non-zero if it was found, or zero if the key was not in the ! * dictionary. */ ! int dict_remove2(dict_t dict, const char *key, int no_dispose) { --- 227,233 ---- /* ! * Remove an entry from the dictionary (if found). */ ! void dict_remove2(dict_t dict, const char *key, int no_dispose) { *************** *** 242,252 **** free(dict->root); } else { dict_dispose_node(dict->root, dict->free_keys, dict->free_data); } dict->root = new_root; dict->count--; - return 1; } - return 0; } --- 244,254 ---- free(dict->root); } else { + dict->root->r = NULL; + dict->root->l = NULL; dict_dispose_node(dict->root, dict->free_keys, dict->free_data); } dict->root = new_root; dict->count--; } } *************** *** 272,287 **** /* - * Delete a subtree. - */ - static void - delete_subtree(struct dict_node *tree, free_f free_keys, free_f free_data) - { - if (!tree) return; - if (tree->l) delete_subtree(tree->l, free_keys, free_data); - if (tree->r) delete_subtree(tree->r, free_keys, free_data); - dict_dispose_node(tree, free_keys, free_data); - } - - /* * Delete an entire dictionary. */ --- 274,277 ---- *************** *** 289,298 **** dict_delete(dict_t dict) { ! delete_subtree(dict->root, dict->free_keys, dict->free_data); free(dict); } struct dict_sanity_struct { ! unsigned int node_count; struct dict_node *bad_node; char error[128]; --- 279,288 ---- dict_delete(dict_t dict) { ! if (dict->root) dict_dispose_node(dict->root, dict->free_keys, dict->free_data); free(dict); } struct dict_sanity_struct { ! size_t node_count; struct dict_node *bad_node; char error[128]; Index: dict.h =================================================================== RCS file: /cvsroot/srvx/services/src/dict.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** dict.h 2001/03/30 21:20:10 1.6 --- dict.h 2001/10/02 16:04:36 1.7 *************** *** 34,42 **** void dict_set_free_keys(dict_t dict, free_f free_keys); void dict_set_free_data(dict_t dict, free_f free_data); ! unsigned int dict_size(dict_t dict); /* if present!=NULL, then *present=1 iff node was found (if node is * not found, return value is NULL, which may be a valid datum) */ void* dict_find(dict_t dict, const char *key, int *present); ! int dict_remove2(dict_t dict, const char *key, int no_dispose); #define dict_remove(DICT, KEY) dict_remove2(DICT, KEY, 0) char *dict_sanity_check(dict_t dict); --- 34,42 ---- void dict_set_free_keys(dict_t dict, free_f free_keys); void dict_set_free_data(dict_t dict, free_f free_data); ! size_t dict_size(dict_t dict); /* if present!=NULL, then *present=1 iff node was found (if node is * not found, return value is NULL, which may be a valid datum) */ void* dict_find(dict_t dict, const char *key, int *present); ! void dict_remove2(dict_t dict, const char *key, int no_dispose); #define dict_remove(DICT, KEY) dict_remove2(DICT, KEY, 0) char *dict_sanity_check(dict_t dict); Index: gline.c =================================================================== RCS file: /cvsroot/srvx/services/src/gline.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** gline.c 2001/09/27 21:58:07 1.17 --- gline.c 2001/10/02 16:04:36 1.18 *************** *** 20,23 **** --- 20,24 ---- #include "config.h" + #include <assert.h> #include <errno.h> #include <stdlib.h> *************** *** 56,60 **** { const struct gline *ga=a, *gb=b; ! return ga->expires - gb->expires; } --- 57,61 ---- { const struct gline *ga=a, *gb=b; ! return (int)(ga->expires - gb->expires); } *************** *** 63,66 **** --- 64,68 ---- { dict_remove(gline_dict, ent->target); + free(ent->issuer); free(ent->target); free(ent->reason); *************** *** 93,98 **** (void)data; ! pthread_mutex_lock(&gline_mutex); ! while (heap_size(gline_heap)) { heap_peek(gline_heap, &argh, &wraa); if (argh <= now) { --- 95,100 ---- (void)data; ! (void)pthread_mutex_lock(&gline_mutex); ! while (heap_size(gline_heap) > 0) { heap_peek(gline_heap, &argh, &wraa); if (argh <= now) { *************** *** 103,107 **** heap_peek(gline_heap, &argh, &wraa); if (wraa) timeq_add(argh, gline_expire, NULL); ! pthread_mutex_unlock(&gline_mutex); } --- 105,109 ---- heap_peek(gline_heap, &argh, &wraa); if (wraa) timeq_add(argh, gline_expire, NULL); ! (void)pthread_mutex_unlock(&gline_mutex); } *************** *** 109,117 **** gline_remove(const char *target, int announce) { ! pthread_mutex_lock(&gline_mutex); if (heap_remove_pred(gline_heap, delete_gline_for_p, (char*)target)) { void *argh; struct gline *new_first; ! heap_peek(gline_heap, 0, &argh); if (argh) { new_first = argh; --- 111,119 ---- gline_remove(const char *target, int announce) { ! (void)pthread_mutex_lock(&gline_mutex); if (heap_remove_pred(gline_heap, delete_gline_for_p, (char*)target)) { void *argh; struct gline *new_first; ! heap_peek(gline_heap, NULL, &argh); if (argh) { new_first = argh; *************** *** 120,124 **** } } ! pthread_mutex_unlock(&gline_mutex); if (announce) irc_ungline(target); } --- 122,126 ---- } } ! (void)pthread_mutex_unlock(&gline_mutex); if (announce) irc_ungline(target); } *************** *** 135,142 **** ent = dict_find(gline_dict, target, NULL); if (ent) { ! heap_remove_pred(gline_heap, gline_for_p, (char*)target); if (ent->expires < (time_t)(now + duration)) ent->expires = now + duration; } else { ent = malloc(sizeof(*ent)); ent->issuer = strdup(issuer); ent->target = strdup(target); --- 137,145 ---- ent = dict_find(gline_dict, target, NULL); if (ent) { ! (void)heap_remove_pred(gline_heap, gline_for_p, (char*)target); if (ent->expires < (time_t)(now + duration)) ent->expires = now + duration; } else { ent = malloc(sizeof(*ent)); + assert(ent != NULL); ent->issuer = strdup(issuer); ent->target = strdup(target); *************** *** 156,162 **** gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, int announce) { ! pthread_mutex_lock(&gline_mutex); gline_add_int(issuer, target, duration, reason, announce); ! pthread_mutex_unlock(&gline_mutex); } --- 159,165 ---- gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, int announce) { ! (void)pthread_mutex_lock(&gline_mutex); gline_add_int(issuer, target, duration, reason, announce); ! (void)pthread_mutex_unlock(&gline_mutex); } *************** *** 173,182 **** gline_refresh_all(void) { ! pthread_mutex_lock(&gline_mutex); ! heap_remove_pred(gline_heap, gline_refresh_helper, 0); ! pthread_mutex_unlock(&gline_mutex); } ! unsigned int gline_count(void) { --- 176,185 ---- gline_refresh_all(void) { ! (void)pthread_mutex_lock(&gline_mutex); ! (void)heap_remove_pred(gline_heap, gline_refresh_helper, 0); ! (void)pthread_mutex_unlock(&gline_mutex); } ! size_t gline_count(void) { *************** *** 216,220 **** dict_t db; if ((db = parse_database(GLINE_DB_NAME))) { ! dict_foreach(db, gline_add_record, 0); } } --- 219,224 ---- dict_t db; if ((db = parse_database(GLINE_DB_NAME))) { ! (void)dict_foreach(db, gline_add_record, 0); ! free_database(db); } } *************** *** 240,247 **** FILE *dbfile; dict_t db = alloc_database(); ! heap_remove_pred(gline_heap, gline_insert_entry, db); dbfile = fopen(TEMP_DB_NAME, "w"); write_database(dbfile, db); ! fclose(dbfile); if (rename(TEMP_DB_NAME, GLINE_DB_NAME) == -1) { log(MAIN_LOG, LOG_ERROR, "unable to rename new gline db to old: %s\n", strerror(errno)); --- 244,252 ---- FILE *dbfile; dict_t db = alloc_database(); ! (void)heap_remove_pred(gline_heap, gline_insert_entry, db); dbfile = fopen(TEMP_DB_NAME, "w"); + assert(dbfile != NULL); write_database(dbfile, db); ! (void)fclose(dbfile); if (rename(TEMP_DB_NAME, GLINE_DB_NAME) == -1) { log(MAIN_LOG, LOG_ERROR, "unable to rename new gline db to old: %s\n", strerror(errno)); *************** *** 259,263 **** gline_init(void) { ! pthread_mutex_lock(&gline_mutex); gline_heap = heap_new(gline_comparator); gline_dict = dict_new(); --- 264,268 ---- gline_init(void) { ! (void)pthread_mutex_lock(&gline_mutex); gline_heap = heap_new(gline_comparator); gline_dict = dict_new(); *************** *** 265,269 **** reg_exit_func(gline_db_cleanup); reg_db_write_func(gline_db_write); ! pthread_mutex_unlock(&gline_mutex); } --- 270,274 ---- reg_exit_func(gline_db_cleanup); reg_db_write_func(gline_db_write); ! (void)pthread_mutex_unlock(&gline_mutex); } *************** *** 279,284 **** } ! discrim = malloc(sizeof(*discrim)); ! memset(discrim, 0, sizeof(*discrim)); discrim->limit = 50; --- 284,289 ---- } ! discrim = calloc(1, sizeof(*discrim)); ! assert(discrim != NULL); discrim->limit = 50; *************** *** 350,356 **** search.data = data; search.hits = 0; ! pthread_mutex_lock(&gline_mutex); ! heap_remove_pred(gline_heap, gline_search_helper, &search); ! pthread_mutex_unlock(&gline_mutex); return search.hits; } --- 355,361 ---- search.data = data; search.hits = 0; ! (void)pthread_mutex_lock(&gline_mutex); ! (void)heap_remove_pred(gline_heap, gline_search_helper, &search); ! (void)pthread_mutex_unlock(&gline_mutex); return search.hits; } Index: gline.h =================================================================== RCS file: /cvsroot/srvx/services/src/gline.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** gline.h 2001/08/19 03:06:09 1.8 --- gline.h 2001/10/02 16:04:36 1.9 *************** *** 44,47 **** --- 44,49 ---- unsigned int gline_count(void); + struct userNode; + typedef void (*gline_search_func)(struct gline *gline, void *extra); struct gline_discrim *gline_discrim_create(struct userNode *user, struct userNode *src, unsigned int argc, unsigned char *argv[]); Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/hash.c,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -r1.146 -r1.147 *** hash.c 2001/09/28 15:21:29 1.146 --- hash.c 2001/10/02 16:04:36 1.147 *************** *** 20,44 **** #include "config.h" ! #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> - #endif - #ifdef HAVE_STRING_H #include <string.h> - #endif - #ifdef HAVE_CTYPE_H #include <ctype.h> - #endif - #ifdef HAVE_TIME_H #include <time.h> - #endif - #include "chanserv.h" #include "common.h" #include "conf.h" #include "dict.h" - #include "global.h" #include "hash.h" #include "log.h" --- 20,33 ---- #include "config.h" ! #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <time.h> #include "common.h" #include "conf.h" #include "dict.h" #include "hash.h" #include "log.h" *************** *** 59,74 **** void ! init_structs(void) { /* Initialize data structures */ channels = dict_new(); dict_set_free_data(channels, channel_free); clients = dict_new(); dict_set_free_data(clients, client_free); servers = dict_new(); dict_set_free_data(servers, free); userList_init(&curr_opers); /* Register modules, callbacks, etc. */ hash_module = module_register("hash", HASH_VERSION, NULL, NULL); note_register_target("struct userNode"); note_register_target("struct chanNode"); --- 48,67 ---- void ! hash_init(void) { /* Initialize data structures */ channels = dict_new(); + assert(channels != NULL); dict_set_free_data(channels, channel_free); clients = dict_new(); + assert(clients != NULL); dict_set_free_data(clients, client_free); servers = dict_new(); + assert(servers != NULL); dict_set_free_data(servers, free); userList_init(&curr_opers); /* Register modules, callbacks, etc. */ hash_module = module_register("hash", HASH_VERSION, NULL, NULL); + assert(hash_module != NULL); note_register_target("struct userNode"); note_register_target("struct chanNode"); *************** *** 79,83 **** static server_link_func_t *ns_list; ! static unsigned int ns_size, ns_used; void --- 72,76 ---- static server_link_func_t *ns_list; ! static size_t ns_size, ns_used; void *************** *** 85,89 **** { if (ns_used == ns_size) { ! if (ns_size) { ns_size <<= 1; ns_list = realloc(ns_list, ns_size*sizeof(server_link_func_t)); --- 78,82 ---- { if (ns_used == ns_size) { ! if (ns_list) { ns_size <<= 1; ns_list = realloc(ns_list, ns_size*sizeof(server_link_func_t)); *************** *** 92,95 **** --- 85,89 ---- ns_list = malloc(ns_size*sizeof(server_link_func_t)); } + assert(ns_list != NULL); } ns_list[ns_used++] = handler; *************** *** 97,101 **** static server_link_func_t *slf_list; ! static unsigned int slf_size, slf_used; void --- 91,95 ---- static server_link_func_t *slf_list; ! static size_t slf_size, slf_used; void *************** *** 103,107 **** { if (slf_used == slf_size) { ! if (slf_size) { slf_size <<= 1; slf_list = realloc(slf_list, slf_size*sizeof(server_link_func_t)); --- 97,101 ---- { if (slf_used == slf_size) { ! if (slf_list) { slf_size <<= 1; slf_list = realloc(slf_list, slf_size*sizeof(server_link_func_t)); *************** *** 110,113 **** --- 104,108 ---- slf_list = malloc(slf_size*sizeof(server_link_func_t)); } + assert(slf_list != NULL); } slf_list[slf_used++] = handler; *************** *** 115,125 **** struct server * ! AddServer(struct server *uplink, const char *name, int hops, time_t boot, time_t link, const char *description) { struct server* sNode; ! unsigned int nn; ! sNode = malloc(sizeof(*sNode)); ! memset(sNode, 0, sizeof(*sNode)); sNode->uplink = uplink; safestrncpy(sNode->name, name, sizeof(sNode->name)); --- 110,120 ---- struct server * ! AddServer(struct server *uplink, const char *name, unsigned int hops, time_t boot, time_t link, const char *description) { struct server* sNode; ! size_t nn; ! sNode = calloc(1, sizeof(*sNode)); ! assert(sNode != NULL); sNode->uplink = uplink; safestrncpy(sNode->name, name, sizeof(sNode->name)); *************** *** 136,139 **** --- 131,135 ---- * We won't be in a burst quite yet. */ sNode->in_burst = 0; + self = sNode; } else if (!self->uplink) { /* This must be our uplink.. */ *************** *** 157,161 **** } ! if (hops && !self->uplink->in_burst) { for (nn=0; nn<slf_used; nn++) { slf_list[nn](sNode); --- 153,157 ---- } ! if (hops && self->uplink && !self->uplink->in_burst) { for (nn=0; nn<slf_used; nn++) { slf_list[nn](sNode); *************** *** 168,172 **** static del_server_func_t *dsf_list; ! static unsigned int dsf_used, dsf_size; void --- 164,168 ---- static del_server_func_t *dsf_list; ! static size_t dsf_used, dsf_size; void *************** *** 174,178 **** { if (dsf_used == dsf_size) { ! if (dsf_size) { dsf_size <<= 1; dsf_list = realloc(dsf_list, dsf_size*sizeof(del_server_func_t)); --- 170,174 ---- { if (dsf_used == dsf_size) { ! if (dsf_list) { dsf_size <<= 1; dsf_list = realloc(dsf_list, dsf_size*sizeof(del_server_func_t)); *************** *** 181,184 **** --- 177,181 ---- dsf_list = malloc(dsf_size*sizeof(del_server_func_t)); } + assert(dsf_list != NULL); } dsf_list[dsf_used++] = handler; *************** *** 187,191 **** void DelServer(struct server* serv, int announce, const char *message) { ! unsigned int i; /* If we receive an ERROR command before the SERVER --- 184,189 ---- void DelServer(struct server* serv, int announce, const char *message) { ! unsigned int n; ! size_t i; /* If we receive an ERROR command before the SERVER *************** *** 194,199 **** /* must recursively remove servers linked to this one first */ ! for (i=0; i<serv->children.used; i++) { ! DelServer(serv->children.list[i], 0, "Recursive server delete"); } --- 192,197 ---- /* must recursively remove servers linked to this one first */ ! for (n=0; n<serv->children.used; n++) { ! DelServer(serv->children.list[n], 0, "Recursive server delete"); } *************** *** 210,214 **** /* Take ourself out of our uplink's children list */ if (serv->uplink) { ! serverList_remove(&serv->uplink->children, serv); } --- 208,212 ---- /* Take ourself out of our uplink's children list */ if (serv->uplink) { ! (void)serverList_remove(&serv->uplink->children, serv); } *************** *** 237,241 **** static new_user_func_t *nuf_list; ! static unsigned int nuf_size = 0, nuf_used = 0; void --- 235,239 ---- static new_user_func_t *nuf_list; ! static size_t nuf_size = 0, nuf_used = 0; void *************** *** 243,247 **** { if (nuf_used == nuf_size) { ! if (nuf_size) { nuf_size <<= 1; nuf_list = realloc(nuf_list, nuf_size*sizeof(new_user_func_t)); --- 241,245 ---- { if (nuf_used == nuf_size) { ! if (nuf_list) { nuf_size <<= 1; nuf_list = realloc(nuf_list, nuf_size*sizeof(new_user_func_t)); *************** *** 250,253 **** --- 248,252 ---- nuf_list = malloc(nuf_size*sizeof(new_user_func_t)); } + assert(nuf_list != NULL); } nuf_list[nuf_used++] = handler; *************** *** 255,259 **** static del_user_func_t *duf_list; ! static unsigned int duf_size = 0, duf_used = 0; void --- 254,258 ---- static del_user_func_t *duf_list; ! static size_t duf_size = 0, duf_used = 0; void *************** *** 261,265 **** { if (duf_used == duf_size) { ! if (duf_size) { duf_size <<= 1; duf_list = realloc(duf_list, duf_size*sizeof(del_user_func_t)); --- 260,264 ---- { if (duf_used == duf_size) { ! if (duf_list) { duf_size <<= 1; duf_list = realloc(duf_list, duf_size*sizeof(del_user_func_t)); *************** *** 268,271 **** --- 267,271 ---- duf_list = malloc(duf_size*sizeof(del_user_func_t)); } + assert(duf_list != NULL); } duf_list[duf_used++] = handler; *************** *** 275,284 **** unreg_del_user_func(del_user_func_t handler) { ! unsigned int i; for (i=0; i<duf_used; i++) { if (duf_list[i] == handler) break; } if (i == duf_used) return; ! memmove(duf_list+i, duf_list+i+1, (duf_used-i-1)*sizeof(duf_list[0])); duf_used--; } --- 275,284 ---- unreg_del_user_func(del_user_func_t handler) { ! size_t i; for (i=0; i<duf_used; i++) { if (duf_list[i] == handler) break; } if (i == duf_used) return; ! for (; i<duf_used-1; i++) duf_list[i] = duf_list[i+1]; duf_used--; } *************** *** 288,292 **** { struct userNode *uNode; ! unsigned int n; if ((uNode = GetUser(nick))) { --- 288,292 ---- { struct userNode *uNode; ! size_t n; if ((uNode = GetUser(nick))) { *************** *** 301,314 **** /* create new usernode and set all values */ ! uNode = malloc(sizeof(*uNode)); safestrncpy(uNode->nick, nick, sizeof(uNode->nick)); safestrncpy(uNode->username, ident, sizeof(uNode->username)); safestrncpy(uNode->info, userinfo, sizeof(uNode->info)); safestrncpy(uNode->hostname, hostname, sizeof(uNode->hostname)); - uNode->timestamp=timestamp; modeList_init(&uNode->channels); ! uNode->uplink=uplink; uNode->uplink->clients++; - uNode->modes=0; mod_usermode(uNode, modes); --- 301,314 ---- /* create new usernode and set all values */ ! uNode = calloc(1, sizeof(*uNode)); ! assert(uNode != NULL); safestrncpy(uNode->nick, nick, sizeof(uNode->nick)); safestrncpy(uNode->username, ident, sizeof(uNode->username)); safestrncpy(uNode->info, userinfo, sizeof(uNode->info)); safestrncpy(uNode->hostname, hostname, sizeof(uNode->hostname)); modeList_init(&uNode->channels); ! uNode->timestamp = timestamp; ! uNode->uplink = uplink; uNode->uplink->clients++; mod_usermode(uNode, modes); *************** *** 330,337 **** struct userNode *user = data; unsigned int n; /* Call these in reverse order so ChanServ can update presence information before NickServ nukes the handle_info. */ ! for (n = duf_used; n > 0; ) duf_list[--n](user); user->uplink->clients--; --- 330,338 ---- struct userNode *user = data; unsigned int n; + size_t i; /* Call these in reverse order so ChanServ can update presence information before NickServ nukes the handle_info. */ ! for (i = duf_used; i > 0; ) duf_list[--i](user); user->uplink->clients--; *************** *** 376,381 **** if (mn->modes & MODE_CHANOP) modes[pos++] = 'o'; if (mn->modes & MODE_VOICE) modes[pos++] = 'v'; ! modes[pos] = 0; ! if (modes[1]) ChangeChannelModes(mn->channel, user, modes, user, user); } } --- 377,382 ---- if (mn->modes & MODE_CHANOP) modes[pos++] = 'o'; if (mn->modes & MODE_VOICE) modes[pos++] = 'v'; ! modes[pos] = '\0'; ! if (modes[1] != '\0') ChangeChannelModes(mn->channel, user, modes, user, user); } } *************** *** 404,409 **** } ! new_channel_func_t *ncf_list; ! unsigned int ncf_size, ncf_used; void --- 405,410 ---- } ! static new_channel_func_t *ncf_list; ! static size_t ncf_size, ncf_used; void *************** *** 411,415 **** { if (ncf_used == ncf_size) { ! if (ncf_size) { ncf_size <<= 1; ncf_list = realloc(ncf_list, ncf_size*sizeof(ncf_list[0])); --- 412,416 ---- { if (ncf_used == ncf_size) { ! if (ncf_list) { ncf_size <<= 1; ncf_list = realloc(ncf_list, ncf_size*sizeof(ncf_list[0])); *************** *** 418,421 **** --- 419,423 ---- ncf_list = malloc(ncf_size*sizeof(ncf_list[0])); } + assert(ncf_list != NULL); } ncf_list[ncf_used++] = handler; *************** *** 423,427 **** static join_func_t *jf_list; ! static unsigned int jf_size = 0, jf_used = 0; void --- 425,429 ---- static join_func_t *jf_list; ! static size_t jf_size = 0, jf_used = 0; void *************** *** 429,433 **** { if (jf_used == jf_size) { ! if (jf_size) { jf_size <<= 1; jf_list = realloc(jf_list, jf_size*sizeof(join_func_t)); --- 431,435 ---- { if (jf_used == jf_size) { ! if (jf_list) { jf_size <<= 1; jf_list = realloc(jf_list, jf_size*sizeof(join_func_t)); *************** *** 436,439 **** --- 438,442 ---- jf_list = malloc(jf_size*sizeof(join_func_t)); } + assert(jf_list != NULL); } jf_list[jf_used++] = handler; *************** *** 445,449 **** struct chanNode *cNode; int new; - unsigned int n; if (!IsChannelName(name)) { --- 448,451 ---- *************** *** 455,460 **** if (!cNode) { new = 1; ! cNode = malloc(sizeof(*cNode)); ! memset(cNode, 0, sizeof(*cNode)); safestrncpy(cNode->name, name, sizeof(cNode->name)); banList_init(&cNode->banlist); --- 457,462 ---- if (!cNode) { new = 1; ! cNode = calloc(1, sizeof(*cNode)); ! assert(cNode != NULL); safestrncpy(cNode->name, name, sizeof(cNode->name)); banList_init(&cNode->banlist); *************** *** 468,475 **** if (new || cNode->timestamp > time_) { if (key) { safestrncpy(cNode->key, key, sizeof(cNode->key)); } else { ! cNode->key[0] = 0; } cNode->limit = limit; --- 470,479 ---- if (new || cNode->timestamp > time_) { + unsigned int n; + if (key) { safestrncpy(cNode->key, key, sizeof(cNode->key)); } else { ! cNode->key[0] = '\0'; } cNode->limit = limit; *************** *** 490,493 **** --- 494,498 ---- if (new || !self->uplink || self->uplink->in_burst) { + size_t n; for (n=0; n<ncf_used; n++) { ncf_list[n](cNode); Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -r1.71 -r1.72 *** hash.h 2001/09/27 21:58:07 1.71 --- hash.h 2001/10/02 16:04:36 1.72 *************** *** 173,177 **** void reg_server_link_func(server_link_func_t handler); ! struct server *AddServer(struct server *uplink, const char *name, int hops, time_t boot, time_t link, const char *description); typedef void (*del_server_func_t) (struct server *srv); void reg_del_server_func(del_server_func_t handler); --- 173,177 ---- void reg_server_link_func(server_link_func_t handler); ! struct server *AddServer(struct server *uplink, const char *name, unsigned int hops, time_t boot, time_t link, const char *description); typedef void (*del_server_func_t) (struct server *srv); void reg_del_server_func(del_server_func_t handler); *************** *** 182,185 **** --- 182,187 ---- void reg_new_user_func(new_user_func_t handler); struct userNode* AddUser(struct server *uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *userinfo, time_t timestamp); + struct userNode *AddService(const char *nick, const char *desc); + struct userNode *AddClone(const char *nick, const char *username, const char *hostname, const char *desc); typedef void (*del_user_func_t) (struct userNode *user); void reg_del_user_func(del_user_func_t handler); *************** *** 229,233 **** #define IsLocal(USER) ((USER)->uplink == self) ! void init_structs(void); #endif --- 231,235 ---- #define IsLocal(USER) ((USER)->uplink == self) ! void hash_init(void); #endif Index: heap.c =================================================================== RCS file: /cvsroot/srvx/services/src/heap.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** heap.c 2001/07/15 14:37:21 1.16 --- heap.c 2001/10/02 16:04:36 1.17 *************** *** 20,29 **** #include "config.h" ! #ifdef HAVE_STDLIB_H ! #include <stdlib.h> /* just for malloc, though, on BSD. */ ! #endif ! #ifdef HAVE_SYS_TIME_H ! #include <sys/time.h> ! #endif #include "common.h" #include "heap.h" --- 20,26 ---- #include "config.h" ! #include <assert.h> ! #include <stdlib.h> ! #include <time.h> #include "common.h" #include "heap.h" *************** *** 50,57 **** { heap_t heap = malloc(sizeof(struct heap)); heap->used = 0; heap->alloc = 8; ! heap->keys = malloc(heap->alloc*sizeof(heap->keys[0])); ! heap->data = malloc(heap->alloc*sizeof(heap->data[0])); return heap; } --- 47,57 ---- { heap_t heap = malloc(sizeof(struct heap)); + assert(heap != NULL); heap->used = 0; heap->alloc = 8; ! heap->keys = malloc(heap->alloc*sizeof(*heap->keys)); ! assert(heap->keys != NULL); ! heap->data = malloc(heap->alloc*sizeof(*heap->data)); ! assert(heap->data != NULL); return heap; } *************** *** 90,95 **** if (heap->used == heap->alloc) { heap->alloc <<= 1; ! heap->keys = realloc(heap->keys, heap->alloc*sizeof(heap->keys[0])); ! heap->data = realloc(heap->data, heap->alloc*sizeof(heap->data[0])); } heap->keys[heap->used] = key; --- 90,97 ---- if (heap->used == heap->alloc) { heap->alloc <<= 1; ! heap->keys = realloc(heap->keys, heap->alloc*sizeof(*heap->keys)); ! assert(heap->keys != NULL); ! heap->data = realloc(heap->data, heap->alloc*sizeof(*heap->data)); ! assert(heap->data != NULL); } heap->keys[heap->used] = key; *************** *** 115,119 **** */ static void ! heap_heapify_down(heap_t heap, int pos) { unsigned int child; --- 117,121 ---- */ static void ! heap_heapify_down(heap_t heap, unsigned int pos) { unsigned int child; *************** *** 173,179 **** */ int ! heap_remove_pred(heap_t heap, int (*pred)(time_t key, void *data, void *extra), void *extra) { ! unsigned int pos=0, rem_first=0; while (pos < heap->used) { if (pred(heap->keys[pos], heap->data[pos], extra)) { --- 175,182 ---- */ int ! heap_remove_pred(heap_t heap, int (*pred)(time_t key, void *data, /*@null@*/void *extra), void *extra) { ! unsigned int pos=0; ! int rem_first=0; while (pos < heap->used) { if (pred(heap->keys[pos], heap->data[pos], extra)) { Index: log.c =================================================================== RCS file: /cvsroot/srvx/services/src/log.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** log.c 2001/09/27 21:58:07 1.35 --- log.c 2001/10/02 16:04:36 1.36 *************** *** 20,41 **** #include "config.h" ! #ifdef HAVE_ERRNO_H #include <errno.h> - #endif - #ifdef HAVE_STDARG_H #include <stdarg.h> - #endif - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> - #endif - #ifdef HAVE_STRING_H #include <string.h> - #endif - #ifdef HAVE_TIME_H #include <time.h> - #endif #include "common.h" --- 20,30 ---- #include "config.h" ! #include <assert.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "common.h" *************** *** 82,86 **** enum log_type lt; for (lt=1; lt<NUM_LOGS; lt++) { ! if (logs[lt].file) fclose(logs[lt].file); } for (i=0; i<ArrayLength(logEntries); i++) { --- 71,75 ---- enum log_type lt; for (lt=1; lt<NUM_LOGS; lt++) { ! if (logs[lt].file) (void)fclose(logs[lt].file); } for (i=0; i<ArrayLength(logEntries); i++) { *************** *** 97,101 **** for (lt=1; lt<NUM_LOGS;lt++) { if (logs[lt].file) { ! fclose(logs[lt].file); } logs[lt].file = fopen(logs[lt].name, "a"); --- 86,90 ---- for (lt=1; lt<NUM_LOGS;lt++) { if (logs[lt].file) { ! (void)fclose(logs[lt].file); } logs[lt].file = fopen(logs[lt].name, "a"); *************** *** 116,123 **** logEntries[i].size = 80; logEntries[i].text = malloc(logEntries[i].size); ! logEntries[i].text[0] = 0; } reg_exit_func(cleanup_logs); ! return !failed; } --- 105,113 ---- logEntries[i].size = 80; logEntries[i].text = malloc(logEntries[i].size); ! assert(logEntries[i].text != NULL); ! logEntries[i].text[0] = '\0'; } reg_exit_func(cleanup_logs); ! return failed ? 0 : 1; } *************** *** 128,147 **** va_list arg_list; const char *sev; ! unsigned int size; if (!logs[lt].file) return; if (!(logs[lt].severity_mask & (1 << ls))) return; ! entry = logEntries + entries++; entry->type = lt; entry->severity = ls; ! if (entries == ArrayLength(logEntries)) { ! entries = 0; ! } entry->time = now; ! strftime(timestamp, sizeof(timestamp), "[%H:%M:%S %m/%d/%Y] ", localtime(&now)); ! fputs(timestamp, logs[lt].file); switch (ls) { case LOG_INFO: sev = "(info) "; break; --- 118,135 ---- va_list arg_list; const char *sev; ! size_t size; if (!logs[lt].file) return; if (!(logs[lt].severity_mask & (1 << ls))) return; ! entry = logEntries + entries; entry->type = lt; entry->severity = ls; ! if (++entries == ArrayLength(logEntries)) entries = 0; entry->time = now; ! (void)strftime(timestamp, sizeof(timestamp), "[%H:%M:%S %m/%d/%Y] ", localtime(&now)); ! (void)fputs(timestamp, logs[lt].file); switch (ls) { case LOG_INFO: sev = "(info) "; break; *************** *** 150,155 **** case LOG_OTHER: default: sev = ""; break; } ! fputs(sev, logs[lt].file); ! fflush(logs[lt].file); va_start(arg_list, text); --- 138,143 ---- case LOG_OTHER: default: sev = ""; break; } ! (void)fputs(sev, logs[lt].file); ! (void)fflush(logs[lt].file); va_start(arg_list, text); *************** *** 158,164 **** if (size > entry->size) { entry->text = realloc(entry->text, size); entry->size = size; } ! vsprintf(entry->text, text, arg_list); va_end(arg_list); } --- 146,153 ---- if (size > entry->size) { entry->text = realloc(entry->text, size); + assert(entry->text != NULL); entry->size = size; } ! (void)vsprintf(entry->text, text, arg_list); va_end(arg_list); } *************** *** 215,220 **** } ! discrim = malloc(sizeof(struct logSearch)); ! memset(discrim, 0, sizeof(*discrim)); discrim->limit = 25; --- 204,208 ---- } ! discrim = calloc(1, sizeof(*discrim)); discrim->limit = 25; Index: log.h =================================================================== RCS file: /cvsroot/srvx/services/src/log.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** log.h 2001/08/01 22:14:35 1.13 --- log.h 2001/10/02 16:04:36 1.14 *************** *** 56,60 **** char *text; ! unsigned int size; }; --- 56,60 ---- char *text; ! size_t size; }; *************** *** 69,79 **** }; - - #ifdef __GNUC__ - #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N))) - #else - #define PRINTF_LIKE(M,N) - #endif - int init_logs(void); void reopen_logs(void); --- 69,72 ---- *************** *** 83,87 **** struct logSearch* log_discrim_create(struct userNode *service, struct userNode *user, unsigned int argc, unsigned char *argv[]); - unsigned int log_entry_search(struct logSearch *discrim, entry_search_func esf, void *data); int log_modify_logging(const char *logname, const char *mods); int log_get_mask(const char *logname); --- 76,79 ---- Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/main.c,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -r1.113 -r1.114 *** main.c 2001/09/28 15:18:20 1.113 --- main.c 2001/10/02 16:04:36 1.114 *************** *** 24,41 **** #include "config.h" ! #ifdef HAVE_ERRNO_H #include <errno.h> - #endif - #ifdef HAVE_SIGNAL_H #include <signal.h> - #endif - #ifdef HAVE_STDIO_H #include <stdio.h> - #endif - #ifdef HAVE_STDLIB_H #include <stdlib.h> - #endif - #ifdef HAVE_STRING_H #include <string.h> #endif #ifdef HAVE_UNISTD_H --- 24,36 ---- #include "config.h" ! #include <assert.h> #include <errno.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <sys/types.h> + #ifdef HAVE_SYS_SELECT_H + #include <sys/select.h> #endif #ifdef HAVE_UNISTD_H *************** *** 54,58 **** #endif - #include "alias.h" #include "common.h" #include "conf.h" --- 49,52 ---- *************** *** 66,69 **** --- 60,64 ---- #include "proto.h" #include "recdb.h" + #include "service.h" #include "timeq.h" #include "tools.h" *************** *** 89,96 **** struct policer_params *oper_policer_params, *luser_policer_params, *god_policer_params; ! void sigaction_writedb(int x) { - void write_databases(void); - #if defined(HAVE_STRSIGNAL) log(MAIN_LOG, LOG_INFO, "%s -- writing databases.\n", strsignal(x)); --- 84,90 ---- struct policer_params *oper_policer_params, *luser_policer_params, *god_policer_params; ! static void ! sigaction_writedb(int x) { #if defined(HAVE_STRSIGNAL) log(MAIN_LOG, LOG_INFO, "%s -- writing databases.\n", strsignal(x)); *************** *** 101,105 **** } ! void sigaction_rehash(int x) { #if defined(HAVE_STRSIGNAL) --- 95,100 ---- } ! static void ! sigaction_rehash(int x) { #if defined(HAVE_STRSIGNAL) *************** *** 108,122 **** log(MAIN_LOG, LOG_INFO, "Signal %d -- rehashing.\n", x); #endif ! conf_read(services_config); reopen_logs(); } ! static exit_func_t *ef_list; ! static unsigned int ef_size = 0, ef_used = 0; void reg_exit_func(exit_func_t handler) { if (ef_used == ef_size) { ! if (ef_size) { ef_size <<= 1; ef_list = realloc(ef_list, ef_size*sizeof(exit_func_t)); --- 103,117 ---- log(MAIN_LOG, LOG_INFO, "Signal %d -- rehashing.\n", x); #endif ! (void)conf_read(services_config); reopen_logs(); } ! /*@only@*/static exit_func_t *ef_list; ! static size_t ef_size = 0, ef_used = 0; void reg_exit_func(exit_func_t handler) { if (ef_used == ef_size) { ! if (ef_list) { ef_size <<= 1; ef_list = realloc(ef_list, ef_size*sizeof(exit_func_t)); *************** *** 125,135 **** ef_list = malloc(ef_size*sizeof(exit_func_t)); } } ef_list[ef_used++] = handler; } ! void call_exit_funcs(void) { ! unsigned int n = ef_used; /* Call them in reverse order because we initialize logs, then nickserv, --- 120,132 ---- ef_list = malloc(ef_size*sizeof(exit_func_t)); } + assert(ef_list != NULL); } ef_list[ef_used++] = handler; } ! void ! call_exit_funcs(void) { ! size_t n = ef_used; /* Call them in reverse order because we initialize logs, then nickserv, *************** *** 139,156 **** */ ! while (n > 0) { ! ef_list[--n](); ! } free(ef_list); ef_used = ef_size = 0; } ! static db_write_func_t *dw_list; ! static unsigned int dw_size = 0, dw_used = 0; void reg_db_write_func(db_write_func_t handler) { if (dw_used == dw_size) { ! if (dw_size) { dw_size <<= 1; dw_list = realloc(dw_list, dw_size*sizeof(db_write_func_t)); --- 136,151 ---- */ ! while (n > 0) ef_list[--n](); free(ef_list); ef_used = ef_size = 0; } ! /*@only@*/static db_write_func_t *dw_list; ! static size_t dw_size = 0, dw_used = 0; void reg_db_write_func(db_write_func_t handler) { if (dw_used == dw_size) { ! if (dw_list) { dw_size <<= 1; dw_list = realloc(dw_list, dw_size*sizeof(db_write_func_t)); *************** *** 159,177 **** dw_list = malloc(dw_size*sizeof(db_write_func_t)); } } dw_list[dw_used++] = handler; } ! void write_databases(void) { ! unsigned int n = dw_used; ! ! /* Order shouldn't matter, and this is a cut-n-paste hack job anyway. */ ! while (n > 0) { ! dw_list[--n](); ! } } ! void thread_routine(void) { struct timeval select_timeout; --- 154,171 ---- dw_list = malloc(dw_size*sizeof(db_write_func_t)); } + assert(dw_list != NULL); } dw_list[dw_used++] = handler; } ! void ! write_databases(void) { ! size_t n; ! for (n = 0; n < dw_used; n++) dw_list[n](); } ! static void ! thread_routine(void) { struct timeval select_timeout; *************** *** 220,224 **** } } else { ! uplink_connect(); } } --- 214,218 ---- } } else { ! (void)uplink_connect(); } } *************** *** 271,275 **** if ((rd = conf_get_node("rlimits")) && (dict = GET_RECORD_OBJECT(rd))) { ! dict_foreach(dict, set_item_rlimit, values); } dict_delete(values); --- 265,269 ---- if ((rd = conf_get_node("rlimits")) && (dict = GET_RECORD_OBJECT(rd))) { ! (void)dict_foreach(dict, set_item_rlimit, values); } dict_delete(values); *************** *** 285,291 **** #endif ! void main_cleanup(void) { ! unlink(PID_FILE); if (dw_list) free(dw_list); policer_params_delete(oper_policer_params); --- 279,286 ---- #endif ! static void ! main_cleanup(void) { ! (void)unlink(PID_FILE); if (dw_list) free(dw_list); policer_params_delete(oper_policer_params); *************** *** 294,298 **** } ! void usage(char *self) { /* We can assume we have getopt_long(). */ printf("Usage: %s [-c config] [-r log] [-f] [-V] [-v|-h] [-k]\n\ --- 289,294 ---- } ! static void ! usage(char *self) { /* We can assume we have getopt_long(). */ printf("Usage: %s [-c config] [-r log] [-f] [-V] [-v|-h] [-k]\n\ *************** *** 306,310 **** } ! void version() { printf(" --------------------------------------------------\n\ - srvx "VERSION" ("CODENAME"), Built: " __DATE__ ", " __TIME__".\n\ --- 302,307 ---- } ! static void ! version(void) { printf(" --------------------------------------------------\n\ - srvx "VERSION" ("CODENAME"), Built: " __DATE__ ", " __TIME__".\n\ *************** *** 313,317 **** } ! void license() { printf("\n\ This program is free software; you can redistribute it and/or modify\n\ --- 310,315 ---- } ! static void ! license(void) { printf("\n\ This program is free software; you can redistribute it and/or modify\n\ *************** *** 467,473 **** gline_init(); sockcheck_init(); /* could be modularized */ ! init_structs(); proto_init(); ! alias_init(); conf_rlimits(); if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n"); --- 465,471 ---- gline_init(); sockcheck_init(); /* could be modularized */ ! hash_init(); proto_init(); ! service_init(); conf_rlimits(); if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n"); Index: md5.c =================================================================== RCS file: /cvsroot/srvx/services/src/md5.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** md5.c 2001/03/13 04:04:44 1.9 --- md5.c 2001/10/02 16:04:36 1.10 *************** *** 28,33 **** #endif #include "common.h" ! #include "md5.h" /* Constants for MD5Transform routine. */ --- 28,97 ---- #endif #include "common.h" ! #ifndef PROTOTYPES ! #define PROTOTYPES 1 ! #endif ! ! /* GLOBAL.H - RSAREF types and constants */ ! ! /* PROTOTYPES should be set to one if and only if the compiler supports ! function argument prototyping. ! The following makes PROTOTYPES default to 0 if it has not already ! been defined with C compiler flags. ! */ ! ! /* POINTER defines a generic pointer type */ ! typedef unsigned char *POINTER; ! ! /* UINT2 defines a two byte word */ ! typedef unsigned short int UINT2; ! ! /* UINT4 defines a four byte word */ ! #if defined(__alpha) ! typedef unsigned int UINT4; ! #else ! typedef unsigned long int UINT4; ! #endif ! ! /* PROTO_LIST is defined depending on how PROTOTYPES is defined above. ! If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it ! returns an empty list. ! */ ! #if PROTOTYPES ! #define PROTO_LIST(list) list ! #else ! #define PROTO_LIST(list) () ! #endif ! ! /* MD5.H - header file for MD5C.C */ ! ! /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All ! rights reserved. ! ! License to copy and use this software is granted provided that it ! is identified as... [truncated message content] |