comparison libpurple/protocols/zephyr/zephyr_internal.h @ 23172:047c56435f1e

When compiling against an external libzephyr, we need to use its zephyr.h, not our zephyr.h. This came from Debian, but I simplified it: http://bugs.debian.org/451165
author Richard Laager <rlaager@wiktel.com>
date Sun, 25 May 2008 00:40:15 +0000
parents
children
comparison
equal deleted inserted replaced
23171:c767bcb40b36 23172:047c56435f1e
1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains global definitions
3 *
4 * Created by: Robert French
5 *
6 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of
7 * Technology. For copying and distribution information, see the
8 * file "mit-copyright.h".
9 */
10
11 #ifndef __ZEPHYR_H__
12 #define __ZEPHYR_H__
13
14 #include <config.h>
15
16 #include <glib.h>
17
18 #include <sys/types.h>
19 #include <sys/time.h>
20
21 #include <zephyr_err.h>
22
23 #ifndef IPPROTO_MAX /* Make sure not already included */
24 #ifndef WIN32
25 #include <netinet/in.h>
26 #endif
27 #endif
28
29 /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const.
30 * This is a public header file, so autoconf can't help us here. */
31 #ifdef __STDC__
32 # include <stdarg.h>
33 # define ZP(x) x
34 # define ZCONST const
35 #else
36 # define ZP(x) ()
37 # define ZCONST
38 #endif
39
40 #ifdef WIN32
41 /* this really should be uint32_t */
42 /*typedef unsigned int in_addr_t;
43 struct in_addr
44 {
45 in_addr_t s_addr;
46 }; */
47 #include <winsock2.h>
48 #endif
49
50 /* Service names */
51 #define HM_SVCNAME "zephyr-hm"
52 #define HM_SRV_SVCNAME "zephyr-hm-srv"
53 #define SERVER_SVCNAME "zephyr-clt"
54 #define SERVER_SERVICE "zephyr"
55 #define SERVER_INSTANCE "zephyr"
56
57 #define ZVERSIONHDR "ZEPH"
58 #define ZVERSIONMAJOR 0
59 #define ZVERSIONMINOR 2
60
61 #define Z_MAXPKTLEN 1024
62 #define Z_MAXHEADERLEN 800
63 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
64 #define Z_NUMFIELDS 17
65
66 /* Authentication levels returned by ZCheckAuthentication */
67 #define ZAUTH_FAILED (-1)
68 #define ZAUTH_YES 1
69 #define ZAUTH_NO 0
70
71 typedef char ZPacket_t[Z_MAXPKTLEN];
72
73 /* Packet type */
74 typedef enum {
75 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
76 } ZNotice_Kind_t;
77 extern ZCONST char *ZNoticeKinds[9];
78
79 /* Unique ID format */
80 typedef struct _ZUnique_Id_t {
81 struct in_addr zuid_addr;
82 struct timeval tv;
83 } ZUnique_Id_t;
84
85 /* Checksum */
86 typedef unsigned long ZChecksum_t;
87
88 /* Notice definition */
89 typedef struct _ZNotice_t {
90 char *z_packet;
91 char *z_version;
92 ZNotice_Kind_t z_kind;
93 ZUnique_Id_t z_uid;
94 #define z_sender_addr z_uid.zuid_addr
95 struct timeval z_time;
96 unsigned short z_port;
97 int z_auth;
98 int z_checked_auth;
99 int z_authent_len;
100 char *z_ascii_authent;
101 char *z_class;
102 const char *z_class_inst;
103 char *z_opcode;
104 char *z_sender;
105 const char *z_recipient;
106 char *z_default_format;
107 char *z_multinotice;
108 ZUnique_Id_t z_multiuid;
109 ZChecksum_t z_checksum;
110 int z_num_other_fields;
111 char *z_other_fields[Z_MAXOTHERFIELDS];
112 caddr_t z_message;
113 int z_message_len;
114 } ZNotice_t;
115
116 /* Subscription structure */
117 typedef struct _ZSubscriptions_t {
118 char *zsub_recipient;
119 char *zsub_class;
120 char *zsub_classinst;
121 } ZSubscription_t;
122
123 /* Function return code */
124 typedef int Code_t;
125
126 /* Locations structure */
127 typedef struct _ZLocations_t {
128 char *host;
129 char *time;
130 char *tty;
131 } ZLocations_t;
132
133 typedef struct _ZAsyncLocateData_t {
134 char *user;
135 ZUnique_Id_t uid;
136 char *version;
137 } ZAsyncLocateData_t;
138
139 /* for ZSetDebug */
140 #ifdef Z_DEBUG
141 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
142 void *__Z_debug_print_closure;
143 #endif
144
145 int ZCompareUIDPred ZP((ZNotice_t *, void *));
146 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
147
148 /* Defines for ZFormatNotice, et al. */
149 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *));
150 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*));
151
152 char *ZGetSender ZP((void));
153 char *ZGetVariable ZP((char *));
154 Code_t ZSetVariable ZP((char *var, char *value));
155 Code_t ZUnsetVariable ZP((char *var));
156 int ZGetWGPort ZP((void));
157 Code_t ZSetDestAddr ZP((struct sockaddr_in *));
158 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
159 char **, int*, Z_AuthProc));
160 Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
161 Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
162 Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
163 Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
164 Code_t ZSendPacket ZP((char*, int, int));
165 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
166 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
167 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
168 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
169 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
170 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
171 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
172 char **buffer, int *ret_len));
173 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
174 Code_t ZRequestLocations ZP((const char *, ZAsyncLocateData_t *,
175 ZNotice_Kind_t, Z_AuthProc));
176 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
177 Code_t ZInitialize ZP((void));
178 Code_t ZSetServerState ZP((int));
179 Code_t ZSetFD ZP((int));
180 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
181 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
182 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
183 Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
184 Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
185 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
186 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
187 Code_t ZSetLocation ZP((char *exposure));
188 Code_t ZUnsetLocation ZP((void));
189 Code_t ZFlushMyLocations ZP((void));
190 Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *));
191 Code_t ZRetrieveSubscriptions ZP((unsigned short, int*));
192 Code_t ZOpenPort ZP((unsigned short *port));
193 Code_t ZClosePort ZP((void));
194 Code_t ZFlushLocations ZP((void));
195 Code_t ZFlushSubscriptions ZP((void));
196 Code_t ZFreeNotice ZP((ZNotice_t *notice));
197 Code_t ZParseLocations ZP((register ZNotice_t *notice,
198 register ZAsyncLocateData_t *zald, int *nlocs,
199 char **user));
200 int ZCompareALDPred ZP((ZNotice_t *notice, void *zald));
201 void ZFreeALD ZP((register ZAsyncLocateData_t *zald));
202 Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
203 register int (*predicate) ZP((ZNotice_t *,void *)),
204 void *args));
205 Code_t ZPeekPacket ZP((char **buffer, int *ret_len,
206 struct sockaddr_in *from));
207 Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
208 Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
209 int (*predicate) ZP((ZNotice_t *, void *)), void *args));
210 Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems,
211 unsigned int port));
212 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
213 unsigned int port));
214 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
215 unsigned int port));
216 Code_t ZCancelSubscriptions ZP((unsigned int port));
217 int ZPending ZP((void));
218 Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
219 #ifdef Z_DEBUG
220 void Z_debug ZP((ZCONST char *, ...));
221 #endif
222
223 #undef ZP
224
225 /* Compatibility */
226 #define ZNewLocateUser ZLocateUser
227
228 /* Macros to retrieve Zephyr library values. */
229 extern int __Zephyr_fd;
230 extern int __Q_CompleteLength;
231 extern struct sockaddr_in __HM_addr;
232 extern char __Zephyr_realm[];
233 #define ZGetFD() __Zephyr_fd
234 #define ZQLength() __Q_CompleteLength
235 #define ZGetDestAddr() __HM_addr
236 #define ZGetRealm() __Zephyr_realm
237
238 #ifdef Z_DEBUG
239 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
240 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
241 __Z_debug_print_closure=(closure), \
242 (void) 0)
243 #else
244 #define ZSetDebug(proc,closure)
245 #endif
246
247 /* Maximum queue length */
248 #define Z_MAXQLEN 30
249
250 /* Successful function return */
251 #define ZERR_NONE 0
252
253 /* Hostmanager wait time (in secs) */
254 #define HM_TIMEOUT 1
255
256 /* Server wait time (in secs) */
257 #define SRV_TIMEOUT 30
258
259 #define ZAUTH (ZMakeAuthentication)
260 #define ZNOAUTH ((Z_AuthProc)0)
261
262 /* Packet strings */
263 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
264 #define ZSRVACK_NOTSENT "LOST"
265 #define ZSRVACK_FAIL "FAIL"
266
267 /* Server internal class */
268 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
269
270 /* Control codes sent to a server */
271 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
272
273 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
274 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
275 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
276 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
277 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
278 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
279 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
280 * subscriptions */
281
282 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
283 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
284 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
285 #define HM_DETACH "DETACH" /* Opcode: Detach me */
286 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
287
288 /* Control codes send to a HostManager */
289 #define HM_CTL_CLASS "HM_CTL" /* Class */
290
291 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
292 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
293 #define SERVER_PING "PING" /* Opcode: PING */
294
295 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
296 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
297 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
298
299 /* HM Statistics */
300 #define HM_STAT_CLASS "HM_STAT" /* Class */
301
302 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
303 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
304
305 /* Login class messages */
306 #define LOGIN_CLASS "LOGIN" /* Class */
307
308 /* Class Instance is principal of user who is logging in or logging out */
309
310 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
311 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
312 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
313 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
314 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
315 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
316 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
317 (from server) */
318 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
319 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
320
321 /* Locate class messages */
322 #define LOCATE_CLASS "USER_LOCATE" /* Class */
323
324 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
325 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
326
327 /* Class Instance is principal of user to locate */
328 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
329
330 /* WG_CTL class messages */
331 #define WG_CTL_CLASS "WG_CTL" /* Class */
332
333 #define WG_CTL_USER "USER" /* Inst: User request */
334 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
335 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
336 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
337 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
338
339 #endif /* __ZEPHYR_H__ */