From 9b709859db5310444052d13ed8ebccec6ead1669 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Sat, 11 Feb 2012 10:42:40 -0500 Subject: Actually remove the #ifdef OLD_COMPAT and NEW_COMPAT code To my knowledge, this hasn't been enabled by anyone in ages --- server/subscr.c | 205 -------------------------------------------------------- 1 file changed, 205 deletions(-) (limited to 'server/subscr.c') diff --git a/server/subscr.c b/server/subscr.c index a646f72..7c5099b 100644 --- a/server/subscr.c +++ b/server/subscr.c @@ -66,22 +66,6 @@ C_Block serv_key; Sched serv_ksched; #endif -/* for compatibility when sending subscription information to old clients */ - -#ifdef OLD_COMPAT -#define OLD_ZEPHYR_VERSION "ZEPH0.0" -#define OLD_CLIENT_INCOMPSUBS "INCOMP" -static void old_compat_subscr_sendlist(ZNotice_t *notice, int auth, - struct sockaddr_in *who); -extern int old_compat_count_subscr; /* counter of old use */ -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT -#define NEW_OLD_ZEPHYR_VERSION "ZEPH0.1" -static void new_old_compat_subscr_sendlist(ZNotice_t *notice, int auth, - struct sockaddr_in *who); -extern int new_compat_count_subscr; /* counter of old use */ -#endif /* NEW_COMPAT */ - static Code_t add_subscriptions(Client *who, Destlist *subs_queue, ZNotice_t *notice, Server *server); static Destlist *extract_subscriptions(ZNotice_t *notice); @@ -444,22 +428,6 @@ subscr_sendlist(ZNotice_t *notice, struct sockaddr_in send_to_who; Code_t retval; -#ifdef OLD_COMPAT - if (strcmp(notice->z_version, OLD_ZEPHYR_VERSION) == 0) { - /* we are talking to an old client; use the old-style - acknowledgement-message */ - old_compat_subscr_sendlist(notice, auth, who); - return; - } -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT - if (strcmp(notice->z_version, NEW_OLD_ZEPHYR_VERSION) == 0) { - /* we are talking to a new old client; use the new-old-style - acknowledgement-message */ - new_old_compat_subscr_sendlist(notice, auth, who); - return; - } -#endif /* NEW_COMPAT */ answer = subscr_marshal_subs(notice, auth, who, &found); send_to_who = *who; send_to_who.sin_port = notice->z_port; /* Return port */ @@ -588,179 +556,6 @@ subscr_marshal_subs(ZNotice_t *notice, return answer; } -#ifdef NEW_COMPAT -static void -new_old_compat_subscr_sendlist(notice, auth, who) - ZNotice_t *notice; - int auth; - struct sockaddr_in *who; -{ - Code_t retval; - ZNotice_t reply; - ZPacket_t reppacket; - int packlen, found, count, initfound, zerofound; - char buf[64]; - const char **answer; - struct sockaddr_in send_to_who; - int i; - - new_compat_count_subscr++; - - syslog(LOG_INFO, "new old subscr, %s", inet_ntoa(who->sin_addr)); - reply = *notice; - reply.z_kind = SERVACK; - reply.z_authent_len = 0; /* save some space */ - reply.z_auth = 0; - - send_to_who = *who; - send_to_who.sin_port = notice->z_port; /* Return port */ - - retval = ZSetDestAddr(&send_to_who); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "new_old_subscr_sendlist set addr: %s", - error_message(retval)); - return; - } - - /* retrieve the subscriptions */ - answer = subscr_marshal_subs(notice, auth, who, &found); - - /* note that when there are no subscriptions, found == 0, so - we needn't worry about answer being NULL since - ZFormatSmallRawNoticeList won't reference the pointer */ - - /* send 5 at a time until we are finished */ - count = found?((found-1) / 5 + 1):1; /* total # to be sent */ - i = 0; /* pkt # counter */ - initfound = found; - zerofound = (found == 0); - while (found > 0 || zerofound) { - packlen = sizeof(reppacket); - sprintf(buf, "%d/%d", ++i, count); - reply.z_opcode = buf; - retval = ZFormatSmallRawNoticeList(&reply, - answer + (initfound - found) - * NUM_FIELDS, - ((found > 5) ? 5 : found) - * NUM_FIELDS, - reppacket, &packlen); - if (retval != ZERR_NONE) { - syslog(LOG_ERR, "subscr_sendlist format: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSendPacket(reppacket, packlen, 0); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist xmit: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - found -= 5; - zerofound = 0; - } - if (answer) - free(answer); -} -#endif /* NEW_COMPAT */ - -#ifdef OLD_COMPAT -static void -old_compat_subscr_sendlist(notice, auth, who) - ZNotice_t *notice; - int auth; - struct sockaddr_in *who; -{ - Client *client = client_find(&who->sin_addr, notice->z_port); - Destlist *subs; - Code_t retval; - ZNotice_t reply; - ZPacket_t reppacket; - int packlen, i, found = 0; - char **answer = NULL; - - old_compat_count_subscr++; - - syslog(LOG_INFO, "old old subscr, %s", inet_ntoa(who->sin_addr)); - if (client && client->subs) { - - /* check authenticity here. The user must be authentic to get - a list of subscriptions. If he is not subscribed to - anything, the above test fails, and he gets a response - indicating no subscriptions */ - - if (!auth) { - clt_ack(notice, who, AUTH_FAILED); - return; - } - - for (subs = client->subs; subs; subs = subs->next) - found++; - /* found is now the number of subscriptions */ - - /* coalesce the subscription information into a list of char *'s */ - answer = (char **) malloc(found * NUM_FIELDS * sizeof(char *)); - if (!answer) { - syslog(LOG_ERR, "old_subscr_sendlist no mem(answer)"); - found = 0; - } else { - i = 0; - for (subs = client->subs; subs; subs = subs->next) { - answer[i*NUM_FIELDS] = subs->dest.classname->string; - answer[i*NUM_FIELDS + 1] = subs->dest.inst->string; - answer[i*NUM_FIELDS + 2] = subs->dest.recip->string; - i++; - } - } - } - - /* note that when there are no subscriptions, found == 0, so - we needn't worry about answer being NULL */ - - reply = *notice; - reply.z_kind = SERVACK; - reply.z_authent_len = 0; /* save some space */ - reply.z_auth = 0; - - /* if it's too long, chop off one at a time till it fits */ - while ((retval = ZFormatSmallRawNoticeList(&reply, answer, - found * NUM_FIELDS, - reppacket, - &packlen)) != ZERR_PKTLEN) { - found--; - reply.z_opcode = OLD_CLIENT_INCOMPSUBS; - } - if (retval != ZERR_NONE) { - syslog(LOG_ERR, "old_subscr_sendlist format: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSetDestAddr(who); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist set addr: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSendPacket(reppacket, packlen, 0); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist xmit: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - if (answer) - free(answer); -} -#endif /* OLD_COMPAT */ - static Code_t subscr_send_some_subs(char *opcode, struct sockaddr_in *addr, Destlist *subs, char *subject) { -- cgit v1.2.3