annotate src/protocols/zephyr/Zinternal.c @ 2197:8f1ca76e46f5

[gaim-migrate @ 2207] able to send out buddy icon now (i keep typing "buggy icon" - freudian slip?). just have to be able to choose it now. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 30 Aug 2001 02:37:36 +0000
parents 424a40f12a6c
children 7ba69b8e0de5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* This file is part of the Project Athena Zephyr Notification System.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * It contains source for the internal Zephyr routines.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Created by: Robert French
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * $Source$
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * $Author: warmenhoven $
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * Technology.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * For copying and distribution information, see the file
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * "mit-copyright.h".
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 /* $Header$ */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #include <internal.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 #include <arpa/inet.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 #include <sys/socket.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #include <utmp.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #ifndef lint
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 static const char rcsid_Zinternal_c[] =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 "$Id: Zinternal.c 2096 2001-07-31 01:00:39Z warmenhoven $";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 static const char copyright[] =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 "Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology.";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 extern char *inet_ntoa ();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 int __Zephyr_fd = -1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 int __Zephyr_open;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 int __Zephyr_port = -1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 int __My_length;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 char *__My_addr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 int __Q_CompleteLength;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 int __Q_Size;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 struct _Z_InputQ *__Q_Head, *__Q_Tail;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 struct sockaddr_in __HM_addr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 struct sockaddr_in __HM_addr_real;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 int __HM_set;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 int __Zephyr_server;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 ZLocations_t *__locate_list;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 int __locate_num;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 int __locate_next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 ZSubscription_t *__subscriptions_list;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 int __subscriptions_num;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 int __subscriptions_next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #ifdef ZEPHYR_USES_KERBEROS
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 C_Block __Zephyr_session;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 char __Zephyr_realm[REALM_SZ];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #ifdef Z_DEBUG
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 void (*__Z_debug_print) __P((const char *fmt, va_list args, void *closure));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 void *__Z_debug_print_closure;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #define min(a,b) ((a)<(b)?(a):(b))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 static int Z_AddField __P((char **ptr, char *field, char *end));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 static int find_or_insert_uid __P((ZUnique_Id_t *uid, ZNotice_Kind_t kind));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 /* Find or insert uid in the old uids buffer. The buffer is a sorted
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 * circular queue. We make the assumption that most packets arrive in
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 * order, so we can usually search for a uid or insert it into the buffer
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 * by looking back just a few entries from the end. Since this code is
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 * only executed by the client, the implementation isn't microoptimized. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 static int find_or_insert_uid(uid, kind)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 ZUnique_Id_t *uid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 ZNotice_Kind_t kind;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 static struct _filter {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 ZUnique_Id_t uid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 ZNotice_Kind_t kind;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 time_t t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 } *buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 static long size;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 static long start;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 static long num;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 time_t now;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 struct _filter *new;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 long i, j, new_size;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 int result;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 /* Initialize the uid buffer if it hasn't been done already. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 if (!buffer) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 size = Z_INITFILTERSIZE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 buffer = (struct _filter *) malloc(size * sizeof(*buffer));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 if (!buffer)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 return 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 /* Age the uid buffer, discarding any uids older than the clock skew. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 time(&now);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 while (num && (now - buffer[start % size].t) > CLOCK_SKEW)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 start++, num--;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 start %= size;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 /* Make room for a new uid, since we'll probably have to insert one. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 if (num == size) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 new_size = size * 2 + 2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 new = (struct _filter *) malloc(new_size * sizeof(*new));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 if (!new)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 return 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 for (i = 0; i < num; i++)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 new[i] = buffer[(start + i) % size];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 free(buffer);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 buffer = new;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 size = new_size;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 start = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 /* Search for this uid in the buffer, starting from the end. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 for (i = start + num - 1; i >= start; i--) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 result = memcmp(uid, &buffer[i % size].uid, sizeof(*uid));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 if (result == 0 && buffer[i % size].kind == kind)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 return 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 if (result > 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 /* We didn't find it; insert the uid into the buffer after i. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 for (j = start + num; j > i; j--)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 buffer[j % size] = buffer[(j - 1) % size];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 buffer[i % size].uid = *uid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 buffer[i % size].kind = kind;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 buffer[i % size].t = now;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 num++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 return 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 /* Get the address of the local host and cache it */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 Code_t Z_GetMyAddr()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 register struct hostent *myhost;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 char hostname[MAXHOSTNAMELEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 if (__My_length > 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 if (gethostname(hostname, MAXHOSTNAMELEN) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 return (errno);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 if (!(myhost = gethostbyname(hostname)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 return (errno);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 /* If h_length is 0, that is a serious problem and it doesn't
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 make it worse for malloc(0) to return NULL, so don't worry
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 about that case. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 if (!(__My_addr = (char *)malloc((unsigned)myhost->h_length)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 __My_length = myhost->h_length;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 (void) memcpy(__My_addr, myhost->h_addr, myhost->h_length);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 /* Return 1 if there is a packet waiting, 0 otherwise */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 int Z_PacketWaiting()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 struct timeval tv;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 fd_set read;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 tv.tv_sec = tv.tv_usec = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 FD_ZERO(&read);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 FD_SET(ZGetFD(), &read);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 return (select(ZGetFD() + 1, &read, NULL, NULL, &tv));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 /* Wait for a complete notice to become available */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 Code_t Z_WaitForComplete()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 Code_t retval;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 if (__Q_CompleteLength)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 return (Z_ReadEnqueue());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 while (!__Q_CompleteLength)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 if ((retval = Z_ReadWait()) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 /* Read any available packets and enqueue them */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 Code_t Z_ReadEnqueue()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 Code_t retval;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 if (ZGetFD() < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 return (ZERR_NOPORT);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 while (Z_PacketWaiting())
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 if ((retval = Z_ReadWait()) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 * Search the queue for a notice with the proper multiuid - remove any
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 * notices that haven't been touched in a while
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 struct _Z_InputQ *Z_SearchQueue(uid, kind)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 ZUnique_Id_t *uid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 ZNotice_Kind_t kind;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 register struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 struct _Z_InputQ *next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 struct timeval tv;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 (void) gettimeofday(&tv, (struct timezone *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 qptr = __Q_Head;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 while (qptr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 return (qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 next = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 if (qptr->timep && (qptr->timep+Z_NOTICETIMELIMIT < tv.tv_sec))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 Z_RemQueue(qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 qptr = next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 return (NULL);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 * Now we delve into really convoluted queue handling and
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 * fragmentation reassembly algorithms and other stuff you probably
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 * don't want to look at...
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 * This routine does NOT guarantee a complete packet will be ready when it
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 * returns.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 Code_t Z_ReadWait()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 register struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 ZPacket_t packet;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 struct sockaddr_in olddest, from;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 int from_len, packet_len, part, partof;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 char *slash;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 Code_t retval;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 register int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 if (ZGetFD() < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 return (ZERR_NOPORT);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 from_len = sizeof(struct sockaddr_in);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 packet_len = recvfrom(ZGetFD(), packet, sizeof(packet), 0,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 (struct sockaddr *)&from, &from_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 if (packet_len < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 return (errno);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 if (!packet_len)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 return (ZERR_EOF);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 /* XXX Check for null data (debugging) */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 for (i = packet_len - 1; i >= 0; i--)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 if (packet[i])
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 goto not_all_null;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 #ifdef Z_DEBUG
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 Z_debug ("got null packet from %s", inet_ntoa (from.sin_addr));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 return ZERR_NONE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 not_all_null:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 /* Parse the notice */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 if ((retval = ZParseNotice(packet, packet_len, &notice)) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 * If we're not a server and the notice is of an appropriate kind,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 * send back a CLIENTACK to whoever sent it to say we got it.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 if (!__Zephyr_server) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 if (notice.z_kind != HMACK && notice.z_kind != SERVACK &&
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 notice.z_kind != SERVNAK && notice.z_kind != CLIENTACK) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 ZNotice_t tmpnotice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 ZPacket_t pkt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 tmpnotice = notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 tmpnotice.z_kind = CLIENTACK;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 tmpnotice.z_message_len = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 olddest = __HM_addr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 __HM_addr = from;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 if ((retval = ZFormatSmallRawNotice(&tmpnotice, pkt, &len))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 return(retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 if ((retval = ZSendPacket(pkt, len, 0)) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 __HM_addr = olddest;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 if (find_or_insert_uid(&notice.z_uid, notice.z_kind))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 return(ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 /* Check authentication on the notice. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 notice.z_checked_auth = ZCheckAuthentication(&notice, &from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 * Parse apart the z_multinotice field - if the field is blank for
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 * some reason, assume this packet stands by itself.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 slash = strchr(notice.z_multinotice, '/');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 if (slash) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 part = atoi(notice.z_multinotice);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 partof = atoi(slash+1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 if (part > partof || partof == 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 part = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 partof = notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 part = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 partof = notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 /* Too big a packet...just ignore it! */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 if (partof > Z_MAXNOTICESIZE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 * If we aren't a server and we can find a notice in the queue
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 * with the same multiuid field, insert the current fragment as
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 * appropriate.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 switch (notice.z_kind) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 case SERVACK:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 case SERVNAK:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 /* The SERVACK and SERVNAK replies shouldn't be reassembled
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 (they have no parts). Instead, we should hold on to the reply
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 ONLY if it's the first part of a fragmented message, i.e.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 multi_uid == uid. This allows programs to wait for the uid
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 of the first packet, and get a response when that notice
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 arrives. Acknowledgements of the other fragments are discarded
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 (XXX we assume here that they all carry the same information
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 regarding failure/success)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 if (!__Zephyr_server &&
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 !ZCompareUID(&notice.z_multiuid, &notice.z_uid))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 /* they're not the same... throw away this packet. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 return(ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 /* fall thru & process it */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 /* for HMACK types, we assume no packet loss (local loopback
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 connections). The other types can be fragmented and MUST
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 run through this code. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 if (!__Zephyr_server && (qptr = Z_SearchQueue(&notice.z_multiuid,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 notice.z_kind))) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 * If this is the first fragment, and we haven't already
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 * gotten a first fragment, grab the header from it.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 if (part == 0 && !qptr->header) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 qptr->header_len = packet_len-notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 qptr->header = (char *) malloc((unsigned) qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 if (!qptr->header)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 (void) memcpy(qptr->header, packet, qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 return (Z_AddNoticeToEntry(qptr, &notice, part));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 * We'll have to create a new entry...make sure the queue isn't
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 * going to get too big.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 if (__Q_Size+(__Zephyr_server ? notice.z_message_len : partof) > Z_MAXQUEUESIZE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 * This is a notice we haven't heard of, so create a new queue
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 * entry for it and zero it out.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 qptr = (struct _Z_InputQ *)malloc(sizeof(struct _Z_InputQ));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 if (!qptr)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 (void) memset((char *)qptr, 0, sizeof(struct _Z_InputQ));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 /* Insert the entry at the end of the queue */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 qptr->next = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 qptr->prev = __Q_Tail;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 if (__Q_Tail)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 __Q_Tail->next = qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 __Q_Tail = qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 if (!__Q_Head)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 __Q_Head = qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 /* Copy the from field, multiuid, kind, and checked authentication. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 qptr->from = from;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 qptr->uid = notice.z_multiuid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 qptr->kind = notice.z_kind;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 qptr->auth = notice.z_checked_auth;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 * If this is the first part of the notice, we take the header
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 * from it. We only take it if this is the first fragment so that
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 * the Unique ID's will be predictable.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 * If a Zephyr Server, we always take the header.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 if (__Zephyr_server || part == 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 qptr->header_len = packet_len-notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 qptr->header = (char *) malloc((unsigned) qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 if (!qptr->header)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 return ENOMEM;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 (void) memcpy(qptr->header, packet, qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 * If this is not a fragmented notice, then don't bother with a
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 * hole list.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 * If we are a Zephyr server, all notices are treated as complete.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 if (__Zephyr_server || (part == 0 && notice.z_message_len == partof)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 __Q_CompleteLength++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 qptr->holelist = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 qptr->complete = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 /* allocate a msg buf for this piece */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 if (notice.z_message_len == 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 qptr->msg = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 else if (!(qptr->msg = (char *) malloc((unsigned) notice.z_message_len)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 return(ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 (void) memcpy(qptr->msg, notice.z_message, notice.z_message_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 qptr->msg_len = notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 __Q_Size += notice.z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 qptr->packet_len = qptr->header_len+qptr->msg_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 if (!(qptr->packet = (char *) malloc((unsigned) qptr->packet_len)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 (void) memcpy(qptr->packet, qptr->header, qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 if(qptr->msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 (void) memcpy(qptr->packet+qptr->header_len, qptr->msg,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 qptr->msg_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 * We know how long the message is going to be (this is better
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 * than IP fragmentation...), so go ahead and allocate it all.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 if (!(qptr->msg = (char *) malloc((unsigned) partof)) && partof)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 qptr->msg_len = partof;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 __Q_Size += partof;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 * Well, it's a fragmented notice...allocate a hole list and
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 * initialize it to the full packet size. Then insert the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 * current fragment.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 if (!(qptr->holelist = (struct _Z_Hole *)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 malloc(sizeof(struct _Z_Hole))))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 qptr->holelist->next = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 qptr->holelist->first = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 qptr->holelist->last = partof-1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 return (Z_AddNoticeToEntry(qptr, &notice, part));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 /* Fragment management routines - compliments, more or less, of RFC815 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 Code_t Z_AddNoticeToEntry(qptr, notice, part)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 int part;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 int last, oldfirst, oldlast;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 struct _Z_Hole *hole, *lasthole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 struct timeval tv;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 /* Incorporate this notice's checked authentication. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 if (notice->z_checked_auth == ZAUTH_FAILED)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 qptr->auth = ZAUTH_FAILED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 else if (notice->z_checked_auth == ZAUTH_NO && qptr->auth != ZAUTH_FAILED)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 qptr->auth = ZAUTH_NO;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 (void) gettimeofday(&tv, (struct timezone *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 qptr->timep = tv.tv_sec;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 last = part+notice->z_message_len-1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 lasthole = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 /* copy in the message body */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 (void) memcpy(qptr->msg+part, notice->z_message, notice->z_message_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 /* Search for a hole that overlaps with the current fragment */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 while (hole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 if (part <= hole->last && last >= hole->first)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 lasthole = hole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 hole = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 /* If we found one, delete it and reconstruct a new hole */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 if (hole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 oldfirst = hole->first;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 oldlast = hole->last;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 if (lasthole)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 lasthole->next = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 qptr->holelist = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 free((char *)hole);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 * Now create a new hole that is the original hole without the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 * current fragment.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 if (part > oldfirst) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 /* Search for the end of the hole list */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 lasthole = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 while (hole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 lasthole = hole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 hole = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 if (lasthole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 if (!(lasthole->next = (struct _Z_Hole *)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 malloc(sizeof(struct _Z_InputQ))))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 hole = lasthole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 if (!(qptr->holelist = (struct _Z_Hole *)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 malloc(sizeof(struct _Z_InputQ))))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 hole->next = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 hole->first = oldfirst;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 hole->last = part-1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 if (last < oldlast) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 /* Search for the end of the hole list */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 lasthole = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 while (hole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 lasthole = hole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 hole = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 if (lasthole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 if (!(lasthole->next = (struct _Z_Hole *)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 malloc(sizeof(struct _Z_InputQ))))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 hole = lasthole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 if (!(qptr->holelist = (struct _Z_Hole *)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 malloc(sizeof(struct _Z_InputQ))))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 hole->next = (struct _Z_Hole *) 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 hole->first = last+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 hole->last = oldlast;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 if (!qptr->holelist) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 if (!qptr->complete)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 __Q_CompleteLength++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 qptr->complete = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 qptr->timep = 0; /* don't time out anymore */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 qptr->packet_len = qptr->header_len+qptr->msg_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591 if (!(qptr->packet = (char *) malloc((unsigned) qptr->packet_len)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 return (ENOMEM);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 (void) memcpy(qptr->packet, qptr->header, qptr->header_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594 (void) memcpy(qptr->packet+qptr->header_len, qptr->msg,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
595 qptr->msg_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601 Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 char *buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 int buffer_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 int *len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 Z_AuthProc cert_routine;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 Code_t retval;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 static char version[BUFSIZ]; /* default init should be all \0 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 struct sockaddr_in name;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 int namelen = sizeof(name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
613 if (!notice->z_sender)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 notice->z_sender = ZGetSender();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 if (notice->z_port == 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 if (ZGetFD() < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618 retval = ZOpenPort((u_short *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 if (retval != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 retval = getsockname(ZGetFD(), (struct sockaddr *) &name, &namelen);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 if (retval != 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 notice->z_port = name.sin_port;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 notice->z_multinotice = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 (void) gettimeofday(&notice->z_uid.tv, (struct timezone *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 notice->z_uid.tv.tv_sec = htonl((u_long) notice->z_uid.tv.tv_sec);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 notice->z_uid.tv.tv_usec = htonl((u_long) notice->z_uid.tv.tv_usec);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 if ((retval = Z_GetMyAddr()) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 (void) memcpy((char *)&notice->z_uid.zuid_addr, __My_addr, __My_length);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 notice->z_multiuid = notice->z_uid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 if (!version[0])
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 ZVERSIONMINOR);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 notice->z_version = version;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 char *buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 int buffer_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 int *len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 Z_AuthProc cert_routine;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 if (!cert_routine) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 notice->z_auth = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 notice->z_authent_len = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 notice->z_ascii_authent = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 notice->z_checksum = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 return (Z_FormatRawHeader(notice, buffer, buffer_len,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 len, NULL, NULL));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 return ((*cert_routine)(notice, buffer, buffer_len, len));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 char *buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 int buffer_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 int *len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 char **cstart, **cend;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 char newrecip[BUFSIZ];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676 char *ptr, *end;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 if (!notice->z_class)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 notice->z_class = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 if (!notice->z_class_inst)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 notice->z_class_inst = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685 if (!notice->z_opcode)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 notice->z_opcode = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 if (!notice->z_recipient)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 notice->z_recipient = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 if (!notice->z_default_format)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 notice->z_default_format = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 ptr = buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 end = buffer+buffer_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 if (buffer_len < strlen(notice->z_version)+1)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 (void) strcpy(ptr, notice->z_version);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 if (ZMakeAscii32(ptr, end-ptr, Z_NUMFIELDS + notice->z_num_other_fields)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 if (ZMakeAscii32(ptr, end-ptr, notice->z_kind) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&notice->z_uid,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_port)) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 if (ZMakeAscii32(ptr, end-ptr, notice->z_auth) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 if (ZMakeAscii32(ptr, end-ptr, notice->z_authent_len) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 if (Z_AddField(&ptr, notice->z_ascii_authent, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 if (Z_AddField(&ptr, notice->z_class, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 if (Z_AddField(&ptr, notice->z_class_inst, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 if (Z_AddField(&ptr, notice->z_opcode, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 if (Z_AddField(&ptr, notice->z_sender, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739 if (strchr(notice->z_recipient, '@') || !*notice->z_recipient) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 if (Z_AddField(&ptr, notice->z_recipient, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 if (strlen(notice->z_recipient) + strlen(__Zephyr_realm) + 2 >
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 sizeof(newrecip))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 if (Z_AddField(&ptr, newrecip, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 if (Z_AddField(&ptr, notice->z_default_format, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 /* copy back the end pointer location for crypto checksum */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 if (cstart)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 *cstart = ptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 if (cend)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 *cend = ptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 if (Z_AddField(&ptr, notice->z_multinotice, end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&notice->z_multiuid,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 ptr += strlen(ptr)+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 for (i=0;i<notice->z_num_other_fields;i++)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 if (Z_AddField(&ptr, notice->z_other_fields[i], end))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 return (ZERR_HEADERLEN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775 *len = ptr-buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 static int
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 Z_AddField(ptr, field, end)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 char **ptr, *field, *end;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 register int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 len = field ? strlen (field) + 1 : 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 if (*ptr+len > end)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 return 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 if (field)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 (void) strcpy(*ptr, field);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 **ptr = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794 *ptr += len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796 return 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799 struct _Z_InputQ *Z_GetFirstComplete()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 qptr = __Q_Head;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 while (qptr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 if (qptr->complete)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 return (qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 qptr = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 return ((struct _Z_InputQ *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814 struct _Z_InputQ *Z_GetNextComplete(qptr)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 qptr = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 while (qptr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 if (qptr->complete)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820 return (qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 qptr = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 return ((struct _Z_InputQ *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 void Z_RemQueue(qptr)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 struct _Z_InputQ *qptr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 struct _Z_Hole *hole, *nexthole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 if (qptr->complete)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 __Q_CompleteLength--;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 __Q_Size -= qptr->msg_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 if (qptr->header)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 free(qptr->header);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 if (qptr->msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 free(qptr->msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 if (qptr->packet)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 free(qptr->packet);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 hole = qptr->holelist;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 while (hole) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 nexthole = hole->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 free((char *)hole);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848 hole = nexthole;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 if (qptr == __Q_Head && __Q_Head == __Q_Tail) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 free ((char *)qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853 __Q_Head = (struct _Z_InputQ *)0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854 __Q_Tail = (struct _Z_InputQ *)0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 if (qptr == __Q_Head) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859 __Q_Head = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 __Q_Head->prev = (struct _Z_InputQ *)0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 free ((char *)qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
863 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
864 if (qptr == __Q_Tail) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
865 __Q_Tail = qptr->prev;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866 __Q_Tail->next = (struct _Z_InputQ *)0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 free ((char *)qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 qptr->prev->next = qptr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 qptr->next->prev = qptr->prev;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 free ((char *)qptr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 Z_AuthProc cert_func;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880 Z_SendProc send_func;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 ZNotice_t partnotice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 ZPacket_t buffer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 char multi[64];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 int offset, hdrsize, fragsize, ret_len, message_len, waitforack;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 Code_t retval;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 hdrsize = len-notice->z_message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 fragsize = Z_MAXPKTLEN-hdrsize-Z_FRAGFUDGE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 offset = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 waitforack = ((notice->z_kind == UNACKED || notice->z_kind == ACKED)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 && !__Zephyr_server);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 partnotice = *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 while (offset < notice->z_message_len || !notice->z_message_len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 (void) sprintf(multi, "%d/%d", offset, notice->z_message_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 partnotice.z_multinotice = multi;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 if (offset > 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 (void) gettimeofday(&partnotice.z_uid.tv,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 (struct timezone *)0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 partnotice.z_uid.tv.tv_sec =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 htonl((u_long) partnotice.z_uid.tv.tv_sec);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 partnotice.z_uid.tv.tv_usec =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 htonl((u_long) partnotice.z_uid.tv.tv_usec);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 if ((retval = Z_GetMyAddr()) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 (void) memcpy((char *)&partnotice.z_uid.zuid_addr, __My_addr,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911 __My_length);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913 message_len = min(notice->z_message_len-offset, fragsize);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
914 partnotice.z_message = notice->z_message+offset;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915 partnotice.z_message_len = message_len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
916 if ((retval = Z_FormatAuthHeader(&partnotice, buffer, Z_MAXHEADERLEN,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917 &ret_len, cert_func)) != ZERR_NONE) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
918 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
919 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920 memcpy(buffer + ret_len, partnotice.z_message, message_len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
921 if ((retval = (*send_func)(&partnotice, buffer, ret_len+message_len,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
922 waitforack)) != ZERR_NONE) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 return (retval);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925 offset += fragsize;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 if (!notice->z_message_len)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 return (ZERR_NONE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
931 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 /*ARGSUSED*/
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 Code_t Z_XmitFragment(notice, buf, len, wait)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 ZNotice_t *notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 int wait;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 return(ZSendPacket(buf, len, wait));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
942
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943 #ifdef Z_DEBUG
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
944 /* For debugging printing */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945 const char *const ZNoticeKinds[] = {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
946 "UNSAFE", "UNACKED", "ACKED", "HMACK", "HMCTL", "SERVACK", "SERVNAK",
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 "CLIENTACK", "STAT"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
950
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 #ifdef Z_DEBUG
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 #undef Z_debug
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954 #ifdef HAVE_STDARG_H
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 void Z_debug (const char *format, ...)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 va_list pvar;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
958 if (!__Z_debug_print)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 va_start (pvar, format);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 va_end (pvar);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 #else /* stdarg */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 void Z_debug (va_alist) va_dcl
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 va_list pvar;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 char *format;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 if (!__Z_debug_print)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 va_start (pvar);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 format = va_arg (pvar, char *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 va_end (pvar);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978 void Z_debug_stderr (format, args, closure)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 const char *format;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 va_list args;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 void *closure;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 #ifdef HAVE_VPRINTF
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 vfprintf (stderr, format, args);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 #else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986 _doprnt (format, args, stderr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988 putc ('\n', stderr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 #undef ZGetFD
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 int ZGetFD () { return __Zephyr_fd; }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 #undef ZQLength
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 int ZQLength () { return __Q_CompleteLength; }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 #undef ZGetDestAddr
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 struct sockaddr_in ZGetDestAddr () { return __HM_addr; }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 #undef ZGetRealm
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 Zconst char * ZGetRealm () { return __Zephyr_realm; }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 #undef ZSetDebug
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 void ZSetDebug(proc, arg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 void (*proc) __P((const char *, va_list, void *));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 char *arg;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 __Z_debug_print = proc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 __Z_debug_print_closure = arg;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 #endif /* Z_DEBUG */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012