--- a/libpurple/protocols/zephyr/Zinternal.c Tue Jan 04 06:42:45 2011 +0000 +++ b/libpurple/protocols/zephyr/Zinternal.c Tue Jan 04 06:55:30 2011 +0000 @@ -6,7 +6,7 @@ * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of * Technology. * For copying and distribution information, see the file - * "mit-copyright.h". + * "mit-copyright.h". */ #include "internal.h" @@ -25,7 +25,7 @@ p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL); return 0; } -#endif +#endif #else #include <arpa/inet.h> @@ -151,7 +151,7 @@ FD_ZERO(&read); FD_SET(ZGetFD(), &read); return (select(ZGetFD() + 1, &read, NULL, NULL, &tv)); -} +} /* Wait for a complete notice to become available */ @@ -179,7 +179,7 @@ if (ZGetFD() < 0) return (ZERR_NOPORT); - + while (Z_PacketWaiting()) if ((retval = Z_ReadWait()) != ZERR_NONE) return (retval); @@ -238,7 +238,7 @@ if (ZGetFD() < 0) return (ZERR_NOPORT); - + FD_ZERO(&fds); FD_SET(ZGetFD(), &fds); tv.tv_sec = 60; @@ -251,7 +251,7 @@ from_len = sizeof(struct sockaddr_in); - packet_len = recvfrom(ZGetFD(), packet, sizeof(packet), 0, + packet_len = recvfrom(ZGetFD(), packet, sizeof(packet), 0, (struct sockaddr *)&from, &from_len); if (packet_len < 0) @@ -265,7 +265,7 @@ if (packet_len < zvlen || memcmp(packet, ZVERSIONHDR, zvlen) != 0) { Z_discarded_packets++; return (ZERR_NONE); - } + } /* Parse the notice */ if ((retval = ZParseNotice(packet, packet_len, ¬ice)) != ZERR_NONE) @@ -393,13 +393,13 @@ if (!__Q_Head) __Q_Head = qptr; - + /* Copy the from field, multiuid, kind, and checked authentication. */ qptr->from = from; qptr->uid = notice.z_multiuid; qptr->kind = notice.z_kind; qptr->auth = notice.z_checked_auth; - + /* * If this is the first part of the notice, we take the header * from it. We only take it if this is the first fragment so that @@ -486,7 +486,7 @@ (void) gettimeofday(&tv, (struct timezone *)0); qptr->timep = tv.tv_sec; - + last = part+notice->z_message_len-1; hole = qptr->holelist; @@ -578,7 +578,7 @@ (void) memcpy(qptr->packet+qptr->header_len, qptr->msg, qptr->msg_len); } - + return (ZERR_NONE); } @@ -610,11 +610,11 @@ } notice->z_multinotice = ""; - + (void) gettimeofday(¬ice->z_uid.tv, (struct timezone *)0); notice->z_uid.tv.tv_sec = htonl((unsigned long) notice->z_uid.tv.tv_sec); notice->z_uid.tv.tv_usec = htonl((unsigned long) notice->z_uid.tv.tv_usec); - + (void) memcpy(¬ice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr)); notice->z_multiuid = notice->z_uid; @@ -642,10 +642,10 @@ return (Z_FormatRawHeader(notice, buffer, buffer_len, len, NULL, NULL)); } - + return ((*cert_routine)(notice, buffer, buffer_len, len)); -} - +} + Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) ZNotice_t *notice; char *buffer; @@ -690,7 +690,7 @@ return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid, + if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid, sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; @@ -728,7 +728,7 @@ (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm); if (Z_AddField(&ptr, newrecip, end)) return (ZERR_HEADERLEN); - } + } if (Z_AddField(&ptr, notice->z_default_format, end)) return (ZERR_HEADERLEN); @@ -744,17 +744,17 @@ if (Z_AddField(&ptr, notice->z_multinotice, end)) return (ZERR_HEADERLEN); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_multiuid, + if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_multiuid, sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - + for (i=0;i<notice->z_num_other_fields;i++) if (Z_AddField(&ptr, notice->z_other_fields[i], end)) return (ZERR_HEADERLEN); - + *len = ptr-buffer; - + return (ZERR_NONE); } @@ -808,39 +808,39 @@ struct _Z_InputQ *qptr; { struct _Z_Hole *hole, *nexthole; - + if (qptr->complete) __Q_CompleteLength--; __Q_Size -= qptr->msg_len; - + if (qptr->header) free(qptr->header); if (qptr->msg) free(qptr->msg); if (qptr->packet) free(qptr->packet); - + hole = qptr->holelist; while (hole) { nexthole = hole->next; free((char *)hole); hole = nexthole; } - + if (qptr == __Q_Head && __Q_Head == __Q_Tail) { free ((char *)qptr); __Q_Head = (struct _Z_InputQ *)0; __Q_Tail = (struct _Z_InputQ *)0; return; } - + if (qptr == __Q_Head) { __Q_Head = qptr->next; __Q_Head->prev = (struct _Z_InputQ *)0; free ((char *)qptr); return; - } + } if (qptr == __Q_Tail) { __Q_Tail = qptr->prev; __Q_Tail->next = (struct _Z_InputQ *)0; @@ -864,15 +864,15 @@ char multi[64]; int offset, hdrsize, fragsize, ret_len, message_len, waitforack; Code_t retval; - + hdrsize = len-notice->z_message_len; fragsize = Z_MAXPKTLEN-hdrsize-Z_FRAGFUDGE; - + offset = 0; waitforack = ((notice->z_kind == UNACKED || notice->z_kind == ACKED) && !__Zephyr_server); - + partnotice = *notice; while (offset < notice->z_message_len || !notice->z_message_len) { @@ -885,7 +885,7 @@ htonl((unsigned long) partnotice.z_uid.tv.tv_sec); partnotice.z_uid.tv.tv_usec = htonl((unsigned long) partnotice.z_uid.tv.tv_usec); - (void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr, + (void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr, sizeof(__My_addr)); } message_len = min(notice->z_message_len-offset, fragsize);