From def9f9a0706a18cb1bc0f44b39d55e4e81c788ff Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Tue, 24 Aug 2010 07:08:36 +0000 Subject: stop using MAXHOSTNAMELEN in a variety of places. Also nuke-trailing-whitespace. --- zwgc/main.c | 47 +++++++++++++++++++++++------------------------ zwgc/subscriptions.c | 15 ++++++++------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'zwgc') diff --git a/zwgc/main.c b/zwgc/main.c index 2979d73..5335678 100644 --- a/zwgc/main.c +++ b/zwgc/main.c @@ -148,7 +148,7 @@ fake_startup_packet(void) zwgc_version_string); notice->z_message = msgbuf; notice->z_message_len = strlen(notice->z_message)+1; - + #ifdef CMU_ZWGCPLUS list_add_notice(notice); set_notice_fake(notice, 1); @@ -175,7 +175,7 @@ read_in_description_file(void) program = parse_file(input_file); else program = NULL; - + fake_startup_packet(); } @@ -224,10 +224,10 @@ run_initprogs(void) int status; char *progname = ZGetVariable("initprogs"); - + if (!progname) return; - + status = system(progname); if (status == 127) { perror("zwgc initprog exec"); @@ -365,19 +365,19 @@ create_punt_reply(int_dictionary_binding *punt) string binding; int key_len = strlen(punt->key); char *tmp; - + if (!punt_reply.z_message) { punt_reply.z_message = (char *)malloc(PUNT_INC); punt_reply.z_message[0] = 0; } - - if ((punt_reply.z_message_len + key_len + 1) / PUNT_INC > + + if ((punt_reply.z_message_len + key_len + 1) / PUNT_INC > (punt_reply.z_message_len + PUNT_INC - 1) / PUNT_INC) { char *new_message = (char *)malloc((punt_reply.z_message_len / PUNT_INC + 1) * PUNT_INC); - + strcpy(new_message, punt_reply.z_message); - + free(punt_reply.z_message); punt_reply.z_message = new_message; } @@ -385,7 +385,7 @@ create_punt_reply(int_dictionary_binding *punt) strcat (punt_reply.z_message, punt->key); strcat (punt_reply.z_message, "\n"); punt_reply.z_message_len += key_len + 1; - + while (*tmp != '\001') tmp++; *tmp = ','; while (*tmp != '\001') tmp++; @@ -398,7 +398,7 @@ notice_handler(ZNotice_t *notice) { #ifndef HAVE_ARES int ret; - char node[MAXDNAME]; + char node[NS_MAXDNAME]; #endif #if defined(CMU_ZWGCPLUS) @@ -414,7 +414,6 @@ notice_handler(ZNotice_t *notice) sizeof(struct sockaddr_in6) : sizeof(notice->z_sender_sockaddr), ARES_NI_LOOKUPHOST, notice_callback, notice); - #else ret = getnameinfo((const struct sockaddr *)&(notice->z_sender_sockaddr), sizeof(notice->z_sender_sockaddr), @@ -511,7 +510,7 @@ process_notice(ZNotice_t *notice, } else if (!strcasecmp(control_opcode, USER_LIST_SUPPRESSED)) { struct sockaddr_in old, to; int retval; - + if (!notice->z_port) { printf("zwgc: can't reply to LIST-SUPPRESSED request\n"); return; @@ -527,28 +526,28 @@ process_notice(ZNotice_t *notice, punt_reply.z_port = notice->z_port; punt_reply.z_message = NULL; punt_reply.z_message_len = 0; - + if (puntable_addresses_dict) { int_dictionary_Enumerate(puntable_addresses_dict, create_punt_reply); } - + old = ZGetDestAddr(); to = old; - + to.sin_port = notice->z_port; if ((retval = ZSetDestAddr(&to)) != ZERR_NONE) { com_err("zwgc",retval,"while setting destination address"); exit(1); } - + ZSendNotice(&punt_reply, ZNOAUTH); - + if ((retval = ZSetDestAddr(&old)) != ZERR_NONE) { com_err("zwgc",retval,"while resetting destination address"); exit(1); } - + if (punt_reply.z_message) { free(punt_reply.z_message); punt_reply.z_message = NULL; @@ -567,9 +566,9 @@ process_notice(ZNotice_t *notice, if (zwgc_debug) printf("NON-ACTIVE: PUNTED <%s>!!!!\n", notice->z_class_inst); #endif - goto cleanup; + goto cleanup; } - + if (puntable_address_p(notice->z_class, notice->z_class_inst, notice->z_recipient)) { @@ -644,7 +643,7 @@ setup_signals(int dofork) sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - + if (dofork) { sa.sa_handler = SIG_IGN; sigaction(SIGINT, &sa, (struct sigaction *)0); @@ -682,7 +681,7 @@ setup_signals(int dofork) /* clean up on SIGINT; exiting on logout is the user's problem, now. */ signal(SIGINT, signal_exit); } - + /* behavior never changes */ signal(SIGTERM, signal_exit); signal(SIGHUP, signal_exit); @@ -725,4 +724,4 @@ detach(void) } exit(0); } -} +} diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c index 33ff801..e146554 100644 --- a/zwgc/subscriptions.c +++ b/zwgc/subscriptions.c @@ -24,6 +24,7 @@ static const char rcsid_subscriptions_c[] = "$Id$"; #include #include #include +#include #include "new_memory.h" #include "new_string.h" #include "int_dictionary.h" @@ -231,7 +232,7 @@ unsubscribe(string class, #define TOKEN_ME "%me%" #define TOKEN_WILD "*" -char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN]; +char ourhost[NS_MAXDNAME], ourhostcanon[NS_MAXDNAME]; static void inithosts(void) @@ -263,7 +264,7 @@ macro_sub(char *str) if (string_Eq(str, TOKEN_ME)) strcpy(str, ZGetSender()); else if (string_Eq(str, TOKEN_HOSTNAME)) - strcpy(str, ourhost); + strcpy(str, ourhost); else if (string_Eq(str, TOKEN_CANONNAME)) strcpy(str, ourhostcanon); } @@ -278,7 +279,7 @@ load_subscriptions_from_file(FILE *file) char class_buffer[BUFSIZ], instance[BUFSIZ], recipient[BUFSIZ]; char *class, *temp; char c; - + while ((!feof(file)) && (!ferror(file))) { if (fgets(line, BUFSIZ, file)) { class = class_buffer; @@ -299,12 +300,12 @@ load_subscriptions_from_file(FILE *file) c = class[0]; if (c==UNSUBSCRIBE_CHARACTER || c==PUNT_CHARACTER) class++; - + /* perform macro substitutions */ macro_sub(class); macro_sub(instance); macro_sub(recipient); - + /* do the right thing with it */ switch (c) { case UNSUBSCRIBE_CHARACTER: @@ -321,7 +322,7 @@ load_subscriptions_from_file(FILE *file) break; } } - + if (ferror(file)) { com_err("zwgc", errno, "while reading from subscription file"); exit(1); @@ -329,7 +330,7 @@ load_subscriptions_from_file(FILE *file) flush_subscriptions(); flush_unsubscriptions(); - + fclose(file); } -- cgit v1.2.3