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