Fix build with external libzephyr.

Tue, 01 Dec 2020 22:06:48 -0600

author
Arkadiy Illarionov <qarkai@gmail.com>
date
Tue, 01 Dec 2020 22:06:48 -0600
changeset 40633
d884c4b6e202
parent 40632
cb8fd8a527ab
child 40634
4d3018b00ad4

Fix build with external libzephyr.

Testing Done:
Successfully compiled with meson configure -Dzephyr=disabled and meson configure -Dzephyr=enabled.

Reviewed at https://reviews.imfreedom.org/r/254/

libpurple/protocols/zephyr/internal.h file | annotate | diff | comparison | revisions
libpurple/protocols/zephyr/zephyr.c file | annotate | diff | comparison | revisions
libpurple/protocols/zephyr/zephyr_internal.h file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/zephyr/internal.h	Tue Dec 01 01:00:55 2020 -0600
+++ b/libpurple/protocols/zephyr/internal.h	Tue Dec 01 22:06:48 2020 -0600
@@ -9,12 +9,6 @@
 #include <zephyr_internal.h>
 #endif
 
-#ifndef WIN32
-#include <netdb.h>
-#endif
-
-
-
 #ifdef WIN32
 
 #ifndef MAXHOSTNAMELEN
@@ -24,6 +18,7 @@
 #define ETIMEDOUT WSAETIMEDOUT
 #define EADDRINUSE WSAEADDRINUSE
 #else /* !WIN32 */
+#include <netdb.h>
 
 #ifndef MAXHOSTNAMELEN
 #define MAXHOSTNAMELEN 4096
@@ -42,69 +37,4 @@
 #define CLOCK_SKEW	300		/* max time to cache packet ids */
 #endif
 
-#define SERVER_SVC_FALLBACK	htons((unsigned short) 2103)
-#define HM_SVC_FALLBACK		htons((unsigned short) 2104)
-#define HM_SRV_SVC_FALLBACK	htons((unsigned short) 2105)
-
-#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 */
-#define Z_MAXQUEUESIZE		1500000	/* Max size of input queue notices */
-#define Z_FRAGFUDGE		13	/* Room to for multinotice field */
-#define Z_NOTICETIMELIMIT	30	/* Time to wait for fragments */
-#define Z_INITFILTERSIZE	30	/* Starting size of uid filter */
-
-typedef struct {
-	gint first;
-	gint last;
-} Z_Hole;
-
-typedef struct {
-    ZNotice_Kind_t	kind;
-	gint64 time;
-	gint packet_len;
-	gchar *packet;
-	gboolean complete;
-    struct sockaddr_in	from;
-	GSList *holelist; /* element-type: Z_Hole* */
-    ZUnique_Id_t	uid;
-    int			auth;
-	gint header_len;
-	gchar *header;
-	gint msg_len;
-	gchar *msg;
-} Z_InputQ;
-
-extern GQueue Z_input_queue;
-
-extern ZLocations_t *__locate_list;
-extern int __locate_num;
-extern int __locate_next;
-
-extern ZSubscription_t *__subscriptions_list;
-extern int __subscriptions_num;
-extern int __subscriptions_next;
-
-extern int __Zephyr_port;		/* Port number */
-extern struct in_addr __My_addr;
-
-typedef Code_t (*Z_SendProc)(ZNotice_t *, char *, int, int);
-
-Z_InputQ *Z_GetFirstComplete(void);
-Z_InputQ *Z_GetNextComplete(Z_InputQ *);
-Code_t Z_XmitFragment(ZNotice_t *, char *, int, int);
-void Z_RemQueue(Z_InputQ *);
-Code_t Z_AddNoticeToEntry(Z_InputQ *, ZNotice_t *, int);
-Code_t Z_FormatAuthHeader(ZNotice_t *, char *, int, int *, Z_AuthProc);
-Code_t Z_FormatHeader(ZNotice_t *, char *, int, int *, Z_AuthProc);
-Code_t Z_FormatRawHeader(ZNotice_t *, char *, gsize, int *, char **, char **);
-Code_t Z_ReadEnqueue(void);
-Code_t Z_ReadWait(void);
-Code_t Z_SendLocation(char *, char *, Z_AuthProc, char *);
-Code_t Z_SendFragmentedNotice(ZNotice_t *notice, int len, Z_AuthProc cert_func,
-                              Z_SendProc send_func);
-Code_t Z_WaitForComplete(void);
-Code_t Z_WaitForNotice(ZNotice_t *notice, int (*pred)(ZNotice_t *, void *),
-                       void *arg, int timeout);
-
 #endif /* PURPLE_ZEPHYR_INTERNAL_H */
--- a/libpurple/protocols/zephyr/zephyr.c	Tue Dec 01 01:00:55 2020 -0600
+++ b/libpurple/protocols/zephyr/zephyr.c	Tue Dec 01 22:06:48 2020 -0600
@@ -60,8 +60,13 @@
 static PurpleProtocol *my_protocol = NULL;
 static GSList *cmds = NULL;
 
+#ifdef LIBZEPHYR_EXT
+extern char __Zephyr_realm[];
+#else
 extern Code_t ZGetLocations(ZLocations_t *, int *);
 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*);
+#endif
+
 typedef struct _zframe zframe;
 typedef struct _zephyr_triple zephyr_triple;
 typedef struct _zephyr_account zephyr_account;
--- a/libpurple/protocols/zephyr/zephyr_internal.h	Tue Dec 01 01:00:55 2020 -0600
+++ b/libpurple/protocols/zephyr/zephyr_internal.h	Tue Dec 01 22:06:48 2020 -0600
@@ -61,6 +61,18 @@
 #define ZAUTH_YES       	1
 #define ZAUTH_NO        	0
 
+#define SERVER_SVC_FALLBACK	htons((unsigned short) 2103)
+#define HM_SVC_FALLBACK		htons((unsigned short) 2104)
+#define HM_SRV_SVC_FALLBACK	htons((unsigned short) 2105)
+
+#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 */
+#define Z_MAXQUEUESIZE		1500000	/* Max size of input queue notices */
+#define Z_FRAGFUDGE		13	/* Room to for multinotice field */
+#define Z_NOTICETIMELIMIT	30	/* Time to wait for fragments */
+#define Z_INITFILTERSIZE	30	/* Starting size of uid filter */
+
 typedef char ZPacket_t[Z_MAXPKTLEN];
 
 /* Packet type */
@@ -128,6 +140,27 @@
     char		*version;
 } ZAsyncLocateData_t;
 
+typedef struct {
+	gint first;
+	gint last;
+} Z_Hole;
+
+typedef struct {
+	ZNotice_Kind_t kind;
+	gint64 time;
+	gint packet_len;
+	gchar *packet;
+	gboolean complete;
+	struct sockaddr_in from;
+	GSList *holelist; /* element-type: Z_Hole* */
+	ZUnique_Id_t uid;
+	int auth;
+	gint header_len;
+	gchar *header;
+	gint msg_len;
+	gchar *msg;
+} Z_InputQ;
+
 int ZCompareUIDPred(ZNotice_t *, void *);
 int ZCompareMultiUIDPred(ZNotice_t *, void *);
 
@@ -197,6 +230,38 @@
 int ZPending(void);
 Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
 
+typedef Code_t (*Z_SendProc)(ZNotice_t *, char *, int, int);
+
+Z_InputQ *Z_GetFirstComplete(void);
+Z_InputQ *Z_GetNextComplete(Z_InputQ *);
+Code_t Z_XmitFragment(ZNotice_t *, char *, int, int);
+void Z_RemQueue(Z_InputQ *);
+Code_t Z_AddNoticeToEntry(Z_InputQ *, ZNotice_t *, int);
+Code_t Z_FormatAuthHeader(ZNotice_t *, char *, int, int *, Z_AuthProc);
+Code_t Z_FormatHeader(ZNotice_t *, char *, int, int *, Z_AuthProc);
+Code_t Z_FormatRawHeader(ZNotice_t *, char *, gsize, int *, char **, char **);
+Code_t Z_ReadEnqueue(void);
+Code_t Z_ReadWait(void);
+Code_t Z_SendLocation(char *, char *, Z_AuthProc, char *);
+Code_t Z_SendFragmentedNotice(ZNotice_t *notice, int len, Z_AuthProc cert_func,
+                              Z_SendProc send_func);
+Code_t Z_WaitForComplete(void);
+Code_t Z_WaitForNotice(ZNotice_t *notice, int (*pred)(ZNotice_t *, void *),
+                       void *arg, int timeout);
+
+extern GQueue Z_input_queue;
+
+extern ZLocations_t *__locate_list;
+extern int __locate_num;
+extern int __locate_next;
+
+extern ZSubscription_t *__subscriptions_list;
+extern int __subscriptions_num;
+extern int __subscriptions_next;
+
+extern int __Zephyr_port;		/* Port number */
+extern struct in_addr __My_addr;
+
 /* Macros to retrieve Zephyr library values. */
 extern int __Zephyr_fd;
 extern int __Q_CompleteLength;

mercurial