pidgin/pidgin

Delete a bunch of unused zephyr stuff

2020-11-23, Elliott Sales de Andrade
6f7bbd42d36c
Parents 6260f39c7c65
Children 56e1a1a5af0b
Delete a bunch of unused zephyr stuff

* Remove unused `ZSetFD`.
* Remove `__HM_set` which is never read.
* Remove `__Zephyr_open` global, which is redundant with `__Zephyr_fd != -1`.
* Remove `ZSetSrv.c`, as `ZSetServerState` is never called.
Consequently, remove `__Zephyr_server` global and all things that check it as it will never be TRUE.
* Remove zephyr internal debug code, as `ZSetDebug` is never called.
Also, make a couple debug messages go to libpurple.
* Remove unused `ZNewLocateUser` compatibility macro.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/249/
--- a/libpurple/protocols/zephyr/ZCkAuth.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZCkAuth.c Mon Nov 23 01:41:50 2020 -0600
@@ -16,7 +16,6 @@
If it doesn't look authentic, return 0
When not using Kerberos, return true if the notice claims to be authentic.
- Only used by clients; the server uses its own routine.
*/
Code_t
ZCheckAuthentication(ZNotice_t *notice, struct sockaddr_in *from)
--- a/libpurple/protocols/zephyr/ZClosePort.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZClosePort.c Mon Nov 23 01:41:50 2020 -0600
@@ -13,11 +13,11 @@
Code_t
ZClosePort(void)
{
- if (__Zephyr_fd >= 0 && __Zephyr_open)
- (void) close(__Zephyr_fd);
+ if (__Zephyr_fd >= 0) {
+ (void) close(__Zephyr_fd);
+ }
__Zephyr_fd = -1;
- __Zephyr_open = 0;
return (ZERR_NONE);
}
--- a/libpurple/protocols/zephyr/ZInit.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZInit.c Mon Nov 23 01:41:50 2020 -0600
@@ -62,39 +62,38 @@
(void) memcpy((char *)&__HM_addr.sin_addr, addr, 4);
- __HM_set = 0;
-
/* Initialize the input queue */
__Q_Tail = NULL;
__Q_Head = NULL;
- /* if the application is a server, there might not be a zhm. The
- code will fall back to something which might not be "right",
- but this is is ok, since none of the servers call krb_rd_req. */
+ /* If there is no zhm, the code will fall back to something which might
+ * not be "right", but this is is ok, since none of the servers call
+ * krb_rd_req. */
- servaddr.s_addr = INADDR_NONE;
- if (! __Zephyr_server) {
- if ((code = ZOpenPort(NULL)) != ZERR_NONE)
- return(code);
+ servaddr.s_addr = INADDR_NONE;
+ if ((code = ZOpenPort(NULL)) != ZERR_NONE) {
+ return code;
+ }
- if ((code = ZhmStat(NULL, &notice)) != ZERR_NONE)
- return(code);
+ if ((code = ZhmStat(NULL, &notice)) != ZERR_NONE) {
+ return code;
+ }
- ZClosePort();
+ ZClosePort();
- /* the first field, which is NUL-terminated, is the server name.
- If this code ever support a multiplexing zhm, this will have to
- be made smarter, and probably per-message */
+ /* the first field, which is NUL-terminated, is the server name.
+ If this code ever support a multiplexing zhm, this will have to
+ be made smarter, and probably per-message */
#ifdef ZEPHYR_USES_KERBEROS
- krealm = krb_realmofhost(notice.z_message);
+ krealm = krb_realmofhost(notice.z_message);
#endif
- hostent = gethostbyname(notice.z_message);
- if (hostent && hostent->h_addrtype == AF_INET)
- memcpy(&servaddr, hostent->h_addr, sizeof(servaddr));
+ hostent = gethostbyname(notice.z_message);
+ if (hostent && hostent->h_addrtype == AF_INET) {
+ memcpy(&servaddr, hostent->h_addr, sizeof(servaddr));
+ }
- ZFreeNotice(&notice);
- }
+ ZFreeNotice(&notice);
#ifdef ZEPHYR_USES_KERBEROS
if (krealm) {
--- a/libpurple/protocols/zephyr/ZNewLocU.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZNewLocU.c Mon Nov 23 01:41:50 2020 -0600
@@ -1,5 +1,5 @@
/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZNewLocateUser function.
+ * It contains source for the ZLocateUser function.
*
* Created by: Robert French
*
--- a/libpurple/protocols/zephyr/ZOpenPort.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZOpenPort.c Mon Nov 23 01:41:50 2020 -0600
@@ -65,7 +65,6 @@
}
__Zephyr_port = bindin.sin_port;
- __Zephyr_open = 1;
if (port)
*port = bindin.sin_port;
--- a/libpurple/protocols/zephyr/ZParseNot.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZParseNot.c Mon Nov 23 01:41:50 2020 -0600
@@ -10,6 +10,8 @@
#include "internal.h"
+#include <purple.h>
+
/* Assume that strlen is efficient on this machine... */
#define next_field(ptr) ptr += strlen (ptr) + 1
@@ -93,9 +95,7 @@
return (ZERR_VERS);
ptr += sizeof(ZVERSIONHDR) - 1;
if (!*ptr) {
-#ifdef Z_DEBUG
- Z_debug ("ZParseNotice: null version string");
-#endif
+ purple_debug_error("zephyr", "ZParseNotice: null version string");
return ZERR_BADPKT;
}
maj = atoi(ptr);
@@ -111,23 +111,13 @@
/*XXX 3 */
numfields -= 2; /* numfields, version, and checksum */
if (numfields < 0) {
+ badpkt:
+#if 0
#ifdef __LINE__
lineno = __LINE__;
- badpkt:
-#ifdef Z_DEBUG
- Z_debug ("ZParseNotice: bad packet from %s/%d (line %d)",
- inet_ntoa (notice->z_uid.zuid_addr.s_addr),
- notice->z_port, lineno);
+ purple_debug_error("zephyr", "ZParseNotice: bad packet from %s/%d (line %d)", inet_ntoa (notice->z_uid.zuid_addr.s_addr), notice->z_port, lineno);
#else
- /* We won't use lineno anywhere else, so let's silence a warning. */
- (void)lineno;
-#endif
-#else
- badpkt:
-#ifdef Z_DEBUG
- Z_debug ("ZParseNotice: bad packet from %s/%d",
- inet_ntoa (notice->z_uid.zuid_addr.s_addr),
- notice->z_port);
+ purple_debug_error("zephyr", "ZParseNotice: bad packet from %s/%d", inet_ntoa (notice->z_uid.zuid_addr.s_addr), notice->z_port);
#endif
#endif
return ZERR_BADPKT;
--- a/libpurple/protocols/zephyr/ZSetDest.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/ZSetDest.c Mon Nov 23 01:41:50 2020 -0600
@@ -15,7 +15,5 @@
{
__HM_addr = *addr;
- __HM_set = 1;
-
return (ZERR_NONE);
}
--- a/libpurple/protocols/zephyr/ZSetFD.c Sun Nov 22 01:44:50 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZSetFD function.
- *
- * Created by: Robert French
- *
- * Copyright (c) 1987 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- */
-
-#include "internal.h"
-
-Code_t
-ZSetFD(int fd)
-{
- (void) ZClosePort();
-
- __Zephyr_fd = fd;
- __Zephyr_open = 0;
-
- return (ZERR_NONE);
-}
--- a/libpurple/protocols/zephyr/ZSetSrv.c Sun Nov 22 01:44:50 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZSetServerState function.
- *
- * Created by: Robert French
- *
- * Copyright (c) 1987 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- */
-
-#include "internal.h"
-
-Code_t
-ZSetServerState(int state)
-{
- __Zephyr_server = state;
-
- return (ZERR_NONE);
-}
--- a/libpurple/protocols/zephyr/Zinternal.c Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/Zinternal.c Mon Nov 23 01:41:50 2020 -0600
@@ -18,7 +18,6 @@
#endif
int __Zephyr_fd = -1;
-int __Zephyr_open;
int __Zephyr_port = -1;
struct in_addr __My_addr;
int __Q_CompleteLength;
@@ -26,8 +25,6 @@
struct _Z_InputQ *__Q_Head, *__Q_Tail;
struct sockaddr_in __HM_addr;
struct sockaddr_in __HM_addr_real;
-int __HM_set;
-int __Zephyr_server;
ZLocations_t *__locate_list;
int __locate_num;
int __locate_next;
@@ -41,11 +38,6 @@
#endif
char __Zephyr_realm[REALM_SZ];
-#ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
-void *__Z_debug_print_closure;
-#endif
-
static int Z_AddField(char **ptr, const char *field, char *end);
static int find_or_insert_uid(ZUnique_Id_t *uid, ZNotice_Kind_t kind);
@@ -254,40 +246,38 @@
return (ZERR_NONE);
}
- /* Parse the notice */
- if ((retval = ZParseNotice(packet, packet_len, &notice)) != ZERR_NONE)
- return (retval);
+ /* Parse the notice */
+ if ((retval = ZParseNotice(packet, packet_len, &notice)) != ZERR_NONE) {
+ return retval;
+ }
- /*
- * If we're not a server and the notice is of an appropriate kind,
- * send back a CLIENTACK to whoever sent it to say we got it.
- */
- if (!__Zephyr_server) {
+ /* If the notice is of an appropriate kind, send back a CLIENTACK to
+ * whoever sent it to say we got it. */
if (notice.z_kind != HMACK && notice.z_kind != SERVACK &&
- notice.z_kind != SERVNAK && notice.z_kind != CLIENTACK) {
- ZNotice_t tmpnotice;
- ZPacket_t pkt;
- int len;
+ notice.z_kind != SERVNAK && notice.z_kind != CLIENTACK) {
+ ZNotice_t tmpnotice;
+ ZPacket_t pkt;
+ int len;
- tmpnotice = notice;
- tmpnotice.z_kind = CLIENTACK;
- tmpnotice.z_message_len = 0;
- olddest = __HM_addr;
- __HM_addr = from;
- if ((retval = ZFormatSmallRawNotice(&tmpnotice, pkt, &len))
- != ZERR_NONE)
- return(retval);
- if ((retval = ZSendPacket(pkt, len, 0)) != ZERR_NONE)
- return (retval);
- __HM_addr = olddest;
+ tmpnotice = notice;
+ tmpnotice.z_kind = CLIENTACK;
+ tmpnotice.z_message_len = 0;
+ olddest = __HM_addr;
+ __HM_addr = from;
+ if ((retval = ZFormatSmallRawNotice(&tmpnotice, pkt, &len)) != ZERR_NONE) {
+ return retval;
+ }
+ if ((retval = ZSendPacket(pkt, len, 0)) != ZERR_NONE) {
+ return retval;
+ }
+ __HM_addr = olddest;
}
- if (find_or_insert_uid(&notice.z_uid, notice.z_kind))
- return(ZERR_NONE);
+ if (find_or_insert_uid(&notice.z_uid, notice.z_kind)) {
+ return ZERR_NONE;
+ }
/* Check authentication on the notice. */
notice.z_checked_auth = ZCheckAuthentication(&notice, &from);
- }
-
/*
* Parse apart the z_multinotice field - if the field is blank for
@@ -311,11 +301,8 @@
if (partof > Z_MAXNOTICESIZE)
return (ZERR_NONE);
- /*
- * If we aren't a server and we can find a notice in the queue
- * with the same multiuid field, insert the current fragment as
- * appropriate.
- */
+ /* If we can find a notice in the queue with the same multiuid field,
+ * insert the current fragment as appropriate. */
switch (notice.z_kind) {
case SERVACK:
case SERVNAK:
@@ -328,17 +315,16 @@
(XXX we assume here that they all carry the same information
regarding failure/success)
*/
- if (!__Zephyr_server &&
- !ZCompareUID(&notice.z_multiuid, &notice.z_uid))
+ if (!ZCompareUID(&notice.z_multiuid, &notice.z_uid)) {
/* they're not the same... throw away this packet. */
return(ZERR_NONE);
+ }
/* fall thru & process it */
default:
/* for HMACK types, we assume no packet loss (local loopback
connections). The other types can be fragmented and MUST
run through this code. */
- if (!__Zephyr_server && (qptr = Z_SearchQueue(&notice.z_multiuid,
- notice.z_kind))) {
+ if ((qptr = Z_SearchQueue(&notice.z_multiuid, notice.z_kind)) != NULL) {
/*
* If this is the first fragment, and we haven't already
* gotten a first fragment, grab the header from it.
@@ -354,12 +340,11 @@
}
}
- /*
- * We'll have to create a new entry...make sure the queue isn't
- * going to get too big.
- */
- if (__Q_Size+(__Zephyr_server ? notice.z_message_len : partof) > Z_MAXQUEUESIZE)
- return (ZERR_NONE);
+ /* We'll have to create a new entry...make sure the queue isn't going
+ * to get too big. */
+ if (__Q_Size + partof > Z_MAXQUEUESIZE) {
+ return ZERR_NONE;
+ }
/*
* This is a notice we haven't heard of, so create a new queue
@@ -387,14 +372,10 @@
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
- * the Unique ID's will be predictable.
- *
- * If a Zephyr Server, we always take the header.
- */
- if (__Zephyr_server || part == 0) {
+ /* 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 the Unique ID's will
+ * be predictable. */
+ if (part == 0) {
qptr->header_len = packet_len-notice.z_message_len;
qptr->header = (char *) malloc((unsigned) qptr->header_len);
if (!qptr->header)
@@ -402,12 +383,9 @@
(void) memcpy(qptr->header, packet, qptr->header_len);
}
- /*
- * If this is not a fragmented notice, then don't bother with a
- * hole list.
- * If we are a Zephyr server, all notices are treated as complete.
- */
- if (__Zephyr_server || (part == 0 && notice.z_message_len == partof)) {
+ /* If this is not a fragmented notice, then don't bother with a hole
+ * list. */
+ if (part == 0 && notice.z_message_len == partof) {
__Q_CompleteLength++;
qptr->holelist = (struct _Z_Hole *) 0;
qptr->complete = 1;
@@ -848,8 +826,7 @@
offset = 0;
- waitforack = ((notice->z_kind == UNACKED || notice->z_kind == ACKED)
- && !__Zephyr_server);
+ waitforack = (notice->z_kind == UNACKED || notice->z_kind == ACKED);
partnotice = *notice;
@@ -894,69 +871,3 @@
{
return(ZSendPacket(buf, len, wait));
}
-
-#ifdef Z_DEBUG
-/* For debugging printing */
-const char *const ZNoticeKinds[] = {
- "UNSAFE", "UNACKED", "ACKED", "HMACK", "HMCTL", "SERVACK", "SERVNAK",
- "CLIENTACK", "STAT"
-};
-#endif
-
-#ifdef Z_DEBUG
-
-#undef Z_debug
-void Z_debug (const char *format, ...)
-{
- va_list pvar;
- if (!__Z_debug_print)
- return;
- va_start (pvar, format);
- (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
- va_end (pvar);
-}
-
-void
-Z_debug_stderr(const char *format, va_list args, void *closure)
-{
- vfprintf (stderr, format, args);
- putc ('\n', stderr);
-}
-
-#undef ZGetFD
-int
-ZGetFD(void)
-{
- return __Zephyr_fd;
-}
-
-#undef ZQLength
-int
-ZQLength(void)
-{
- return __Q_CompleteLength;
-}
-
-#undef ZGetDestAddr
-struct sockaddr_in
-ZGetDestAddr(void)
-{
- return __HM_addr;
-}
-
-#undef ZGetRealm
-Zconst char *
-ZGetRealm(void)
-{
- return __Zephyr_realm;
-}
-
-#undef ZSetDebug
-void
-ZSetDebug(void (*proc)(const char *, va_list, void *), char *arg)
-{
- __Z_debug_print = proc;
- __Z_debug_print_closure = arg;
-}
-#endif /* Z_DEBUG */
-
--- a/libpurple/protocols/zephyr/internal.h Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/internal.h Mon Nov 23 01:41:50 2020 -0600
@@ -46,7 +46,6 @@
#define HM_SVC_FALLBACK htons((unsigned short) 2104)
#define HM_SRV_SVC_FALLBACK htons((unsigned short) 2105)
-#define ZAUTH_CKSUM_FAILED (-2) /* Used only by server. */
#define ZAUTH_UNSET (-3) /* Internal to client library. */
#define Z_MAXFRAGS 500 /* Max number of packet fragments */
#define Z_MAXNOTICESIZE 400000 /* Max size of incoming notice */
@@ -81,10 +80,6 @@
extern struct _Z_InputQ *__Q_Head, *__Q_Tail;
-extern int __Zephyr_open; /* 0 if FD opened, 1 otherwise */
-extern int __HM_set; /* 0 if dest addr set, 1 otherwise */
-extern int __Zephyr_server; /* 0 if normal client, 1 if server or zhm */
-
extern ZLocations_t *__locate_list;
extern int __locate_num;
extern int __locate_next;
--- a/libpurple/protocols/zephyr/meson.build Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/meson.build Mon Nov 23 01:41:50 2020 -0600
@@ -37,8 +37,6 @@
'ZSendNot.c',
'ZSendPkt.c',
'ZSetDest.c',
- 'ZSetFD.c',
- 'ZSetSrv.c',
'ZSubs.c',
'ZVariables.c',
'ZWait4Not.c',
--- a/libpurple/protocols/zephyr/zephyr_internal.h Sun Nov 22 01:44:50 2020 -0600
+++ b/libpurple/protocols/zephyr/zephyr_internal.h Mon Nov 23 01:41:50 2020 -0600
@@ -67,7 +67,6 @@
typedef enum {
UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
} ZNotice_Kind_t;
-extern const char *ZNoticeKinds[9];
/* Unique ID format */
typedef struct {
@@ -129,12 +128,6 @@
char *version;
} ZAsyncLocateData_t;
-/* for ZSetDebug */
-#ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
-void *__Z_debug_print_closure;
-#endif
-
int ZCompareUIDPred(ZNotice_t *, void *);
int ZCompareMultiUIDPred(ZNotice_t *, void *);
@@ -167,8 +160,6 @@
Z_AuthProc);
Code_t ZhmStat(struct in_addr *, ZNotice_t *);
Code_t ZInitialize(void);
-Code_t ZSetServerState(int);
-Code_t ZSetFD(int);
Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
int ZCompareUID(ZUnique_Id_t *, ZUnique_Id_t *);
Code_t ZMakeAscii(char *, int, unsigned char *, int);
@@ -205,12 +196,6 @@
Code_t ZCancelSubscriptions(unsigned int port);
int ZPending(void);
Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
-#ifdef Z_DEBUG
-void Z_debug(const char *, ...);
-#endif
-
-/* Compatibility */
-#define ZNewLocateUser ZLocateUser
/* Macros to retrieve Zephyr library values. */
extern int __Zephyr_fd;
@@ -222,15 +207,6 @@
#define ZGetDestAddr() __HM_addr
#define ZGetRealm() __Zephyr_realm
-#ifdef Z_DEBUG
-void ZSetDebug(void (*)(const char *, va_list, void *), void *);
-#define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
- __Z_debug_print_closure=(closure), \
- (void) 0)
-#else
-#define ZSetDebug(proc,closure)
-#endif
-
/* Maximum queue length */
#define Z_MAXQLEN 30