]>
Commit | Line | Data |
---|---|---|
bd71fa88 | 1 | /* |
2 | * Main libfaim header. Must be included in client for prototypes/macros. | |
3 | * | |
4 | */ | |
5 | ||
6 | #ifndef __AIM_H__ | |
7 | #define __AIM_H__ | |
8 | ||
0cc57340 | 9 | #define FAIM_VERSION_MAJOR 0 |
10 | #define FAIM_VERSION_MINOR 99 | |
11 | #define FAIM_VERSION_MINORMINOR 0 | |
12 | ||
bd71fa88 | 13 | #include <faim/faimconfig.h> |
14 | #include <faim/aim_cbtypes.h> | |
15 | ||
81d7797e | 16 | #if !defined(FAIM_USEPTHREADS) || !defined(FAIM_USEFAKELOCKS) |
17 | #error pthreads or fakelocks are currently required. | |
e88ba395 | 18 | #endif |
19 | ||
bd71fa88 | 20 | #include <stdio.h> |
21 | #include <string.h> | |
22 | #include <fcntl.h> | |
23 | #include <sys/types.h> | |
24 | #include <stdlib.h> | |
25 | #include <stdarg.h> | |
26 | #include <errno.h> | |
27 | ||
e88ba395 | 28 | #ifdef FAIM_USEPTHREADS |
29 | #include <pthread.h> | |
30 | #define faim_mutex_t pthread_mutex_t | |
31 | #define faim_mutex_init pthread_mutex_init | |
32 | #define faim_mutex_lock pthread_mutex_lock | |
33 | #define faim_mutex_unlock pthread_mutex_unlock | |
81d7797e | 34 | #elif defined(FAIM_USEFAKELOCKS) |
35 | /* | |
36 | * For platforms without pthreads, we also assume | |
37 | * we're not linking against a threaded app. Which | |
38 | * means we don't have to do real locking. The | |
39 | * macros below do nothing really. They're a joke. | |
40 | * But they get it to compile. | |
41 | */ | |
42 | #define faim_mutex_t char | |
43 | #define faim_mutex_init(x, y) *x = 0 | |
44 | #define faim_mutex_lock(x) *x = 1; | |
45 | #define faim_mutex_unlock(x) *x = 0; | |
e88ba395 | 46 | #endif |
47 | ||
bd71fa88 | 48 | #ifdef _WIN32 |
49 | #include <windows.h> | |
50 | #include <time.h> | |
51 | #include <io.h> | |
52 | #else | |
53 | #include <netdb.h> | |
54 | #include <sys/socket.h> | |
55 | #include <netinet/in.h> | |
56 | #include <sys/time.h> | |
57 | #include <unistd.h> | |
58 | #endif | |
59 | ||
60 | /* Portability stuff (DMP) */ | |
61 | ||
62 | #ifdef _WIN32 | |
63 | #define sleep Sleep | |
64 | #define strlen(x) (int)strlen(x) /* win32 has a unsigned size_t */ | |
65 | #endif | |
66 | ||
040457cc | 67 | #if defined(mach) && defined(__APPLE__) |
68 | #define gethostbyname(x) gethostbyname2(x, AF_INET) | |
69 | #endif | |
bd71fa88 | 70 | |
81d7797e | 71 | #if !defined(MSG_WAITALL) |
72 | #warning FIX YOUR LIBC! MSG_WAITALL is required! | |
73 | #define MSG_WAITALL 0x100 | |
74 | #endif | |
75 | ||
bd71fa88 | 76 | /* |
77 | * Current Maximum Length for Screen Names (not including NULL) | |
68ac63c2 | 78 | * |
79 | * Currently only names up to 16 characters can be registered | |
80 | * however it is aparently legal for them to be larger. | |
bd71fa88 | 81 | */ |
68ac63c2 | 82 | #define MAXSNLEN 32 |
bd71fa88 | 83 | |
91931247 | 84 | /* |
85 | * Current Maximum Length for Instant Messages | |
86 | * | |
87 | * This was found basically by experiment, but not wholly | |
88 | * accurate experiment. It should not be regarded | |
89 | * as completely correct. But its a decent approximation. | |
90 | * | |
91 | * Note that although we can send this much, its impossible | |
92 | * for WinAIM clients (up through the latest (4.0.1957)) to | |
93 | * send any more than 1kb. Amaze all your windows friends | |
5e02cf44 | 94 | * with utterly oversized instant messages! |
91931247 | 95 | * |
96 | */ | |
b69540e3 | 97 | #define MAXMSGLEN 7987 |
91931247 | 98 | |
99 | /* | |
100 | * Current Maximum Length for Chat Room Messages | |
101 | * | |
102 | * This is actually defined by the protocol to be | |
103 | * dynamic, but I have yet to see due cause to | |
104 | * define it dynamically here. Maybe later. | |
105 | * | |
106 | */ | |
107 | #define MAXCHATMSGLEN 512 | |
108 | ||
bd71fa88 | 109 | /* |
110 | * Standard size of an AIM authorization cookie | |
111 | */ | |
112 | #define AIM_COOKIELEN 0x100 | |
113 | ||
b8d0da45 | 114 | #if debug > 0 |
115 | #define faimdprintf(l, x...) {if (l >= debug) printf(x); } | |
116 | #else | |
117 | #define faimdprintf(l, x...) | |
118 | #endif | |
119 | ||
bd71fa88 | 120 | /* |
121 | * Login info. Passes information from the Authorization | |
122 | * stage of login to the service (BOS, etc) connection | |
123 | * phase. | |
124 | * | |
125 | */ | |
126 | struct aim_login_struct { | |
127 | char screen_name[MAXSNLEN+1]; | |
128 | char *BOSIP; | |
129 | char cookie[AIM_COOKIELEN]; | |
130 | char *email; | |
131 | u_short regstatus; | |
01b59e1e | 132 | char *errorurl; |
133 | u_short errorcode; | |
bd71fa88 | 134 | }; |
135 | ||
136 | /* | |
137 | * Client info. Filled in by the client and passed | |
138 | * in to aim_login(). The information ends up | |
139 | * getting passed to OSCAR through the initial | |
140 | * login command. | |
141 | * | |
142 | * XXX: Should this be per-session? -mid | |
143 | * | |
144 | */ | |
145 | struct client_info_s { | |
146 | char clientstring[100]; /* arbitrary size */ | |
147 | int major; | |
148 | int minor; | |
149 | int build; | |
150 | char country[3]; | |
151 | char lang[3]; | |
152 | }; | |
153 | ||
154 | #ifndef TRUE | |
155 | #define TRUE 1 | |
156 | #define FALSE 0 | |
157 | #endif | |
158 | ||
159 | /* | |
160 | * These could be arbitrary, but its easier to use the actual AIM values | |
161 | */ | |
162 | #define AIM_CONN_TYPE_AUTH 0x0007 | |
163 | #define AIM_CONN_TYPE_ADS 0x0005 | |
164 | #define AIM_CONN_TYPE_BOS 0x0002 | |
165 | #define AIM_CONN_TYPE_CHAT 0x000e | |
166 | #define AIM_CONN_TYPE_CHATNAV 0x000d | |
040457cc | 167 | #define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak OSCAR! */ |
bd71fa88 | 168 | |
169 | /* | |
170 | * Status values returned from aim_conn_new(). ORed together. | |
171 | */ | |
172 | #define AIM_CONN_STATUS_READY 0x0001 | |
173 | #define AIM_CONN_STATUS_INTERNALERR 0x0002 | |
174 | #define AIM_CONN_STATUS_RESOLVERR 0x0080 | |
175 | #define AIM_CONN_STATUS_CONNERR 0x0040 | |
176 | ||
b69540e3 | 177 | #define AIM_FRAMETYPE_OSCAR 0x0000 |
178 | #define AIM_FRAMETYPE_OFT 0x0001 | |
179 | ||
bd71fa88 | 180 | struct aim_conn_t { |
181 | int fd; | |
182 | int type; | |
183 | int seqnum; | |
184 | int status; | |
185 | void *priv; /* misc data the client may want to store */ | |
186 | time_t lastactivity; /* time of last transmit */ | |
187 | int forcedlatency; | |
188 | struct aim_rxcblist_t *handlerlist; | |
df5a99fb | 189 | faim_mutex_t active; /* lock around read/writes */ |
190 | faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */ | |
040457cc | 191 | struct aim_conn_t *next; |
bd71fa88 | 192 | }; |
193 | ||
194 | /* struct for incoming commands */ | |
195 | struct command_rx_struct { | |
b69540e3 | 196 | unsigned char hdrtype; /* defines which piece of the union to use */ |
197 | union { | |
198 | struct { | |
199 | char type; | |
200 | unsigned short seqnum; | |
201 | } oscar; | |
202 | struct { | |
203 | unsigned short type; | |
204 | unsigned short hdr2len; | |
205 | unsigned char *hdr2; /* rest of bloated header */ | |
206 | } oft; | |
207 | } hdr; | |
208 | unsigned short commandlen; /* total payload length */ | |
209 | unsigned char *data; /* packet data (from 7 byte on) */ | |
210 | unsigned char lock; /* 0 = open, !0 = locked */ | |
211 | unsigned char handled; /* 0 = new, !0 = been handled */ | |
212 | unsigned char nofree; /* 0 = free data on purge, 1 = only unlink */ | |
bd71fa88 | 213 | struct aim_conn_t *conn; /* the connection it came in on... */ |
214 | struct command_rx_struct *next; /* ptr to next struct in list */ | |
215 | }; | |
216 | ||
217 | /* struct for outgoing commands */ | |
218 | struct command_tx_struct { | |
b69540e3 | 219 | unsigned char hdrtype; /* defines which piece of the union to use */ |
220 | union { | |
221 | struct { | |
222 | unsigned char type; | |
223 | unsigned short seqnum; | |
224 | } oscar; | |
225 | struct { | |
226 | unsigned short type; | |
227 | unsigned short hdr2len; | |
228 | unsigned char *hdr2; | |
229 | } oft; | |
230 | } hdr; | |
231 | u_int commandlen; | |
232 | u_char *data; | |
bd71fa88 | 233 | u_int lock; /* 0 = open, !0 = locked */ |
234 | u_int sent; /* 0 = pending, !0 = has been sent */ | |
235 | struct aim_conn_t *conn; | |
236 | struct command_tx_struct *next; /* ptr to next struct in list */ | |
237 | }; | |
238 | ||
239 | ||
240 | /* | |
241 | * AIM Session: The main client-data interface. | |
242 | * | |
243 | */ | |
244 | struct aim_session_t { | |
245 | ||
246 | /* ---- Client Accessible ------------------------ */ | |
247 | /* | |
248 | * Login information. See definition above. | |
249 | * | |
250 | */ | |
251 | struct aim_login_struct logininfo; | |
252 | ||
253 | /* | |
254 | * Pointer to anything the client wants to | |
255 | * explicitly associate with this session. | |
256 | */ | |
257 | void *aux_data; | |
258 | ||
259 | ||
260 | /* ---- Internal Use Only ------------------------ */ | |
261 | /* | |
262 | * Connection information | |
263 | */ | |
040457cc | 264 | struct aim_conn_t *connlist; |
265 | faim_mutex_t connlistlock; | |
bd71fa88 | 266 | |
267 | /* | |
268 | * TX/RX queues | |
269 | */ | |
e88ba395 | 270 | struct command_tx_struct *queue_outgoing; |
bd71fa88 | 271 | struct command_rx_struct *queue_incoming; |
272 | ||
e88ba395 | 273 | /* |
274 | * Tx Enqueuing function | |
275 | */ | |
276 | int (*tx_enqueue)(struct aim_session_t *, struct command_tx_struct *); | |
277 | ||
0c20631f | 278 | /* |
279 | * This is a dreadful solution to the what-room-are-we-joining | |
280 | * problem. (There's no connection between the service | |
281 | * request and the resulting redirect.) | |
282 | */ | |
283 | char *pendingjoin; | |
284 | ||
bd71fa88 | 285 | /* |
286 | * Outstanding snac handling | |
287 | * | |
288 | * XXX: Should these be per-connection? -mid | |
289 | **/ | |
290 | struct aim_snac_t *outstanding_snacs; | |
291 | u_long snac_nextid; | |
040457cc | 292 | |
293 | struct aim_msgcookie_t *msgcookies; | |
bd71fa88 | 294 | }; |
295 | ||
296 | ||
297 | /* | |
298 | * AIM User Info, Standard Form. | |
299 | */ | |
300 | struct aim_userinfo_s { | |
301 | char sn[MAXSNLEN+1]; | |
302 | u_short warnlevel; | |
303 | u_short idletime; | |
304 | u_short class; | |
305 | u_long membersince; | |
306 | u_long onlinesince; | |
307 | u_long sessionlen; | |
5b79dc93 | 308 | u_short capabilities; |
bd71fa88 | 309 | }; |
310 | ||
0c20631f | 311 | #define AIM_CLASS_TRIAL 0x0001 |
312 | #define AIM_CLASS_UNKNOWN2 0x0002 | |
313 | #define AIM_CLASS_AOL 0x0004 | |
314 | #define AIM_CLASS_UNKNOWN4 0x0008 | |
315 | #define AIM_CLASS_FREE 0x0010 | |
316 | #define AIM_CLASS_AWAY 0x0020 | |
317 | #define AIM_CLASS_UNKNOWN40 0x0040 | |
318 | #define AIM_CLASS_UNKNOWN80 0x0080 | |
319 | ||
bd71fa88 | 320 | /* |
321 | * TLV handling | |
322 | */ | |
323 | ||
324 | /* Generic TLV structure. */ | |
325 | struct aim_tlv_t { | |
326 | u_short type; | |
327 | u_short length; | |
328 | u_char *value; | |
329 | }; | |
330 | ||
331 | /* List of above. */ | |
332 | struct aim_tlvlist_t { | |
333 | struct aim_tlv_t *tlv; | |
334 | struct aim_tlvlist_t *next; | |
335 | }; | |
336 | ||
337 | /* TLV-handling functions */ | |
338 | struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen); | |
339 | void aim_freetlvchain(struct aim_tlvlist_t **list); | |
340 | struct aim_tlv_t *aim_grabtlv(u_char *src); | |
341 | struct aim_tlv_t *aim_grabtlvstr(u_char *src); | |
342 | struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, u_short, int); | |
343 | char *aim_gettlv_str(struct aim_tlvlist_t *, u_short, int); | |
344 | int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv); | |
345 | struct aim_tlv_t *aim_createtlv(void); | |
346 | int aim_freetlv(struct aim_tlv_t **oldtlv); | |
347 | int aim_puttlv_16(u_char *, u_short, u_short); | |
01b59e1e | 348 | int aim_puttlv_32(u_char *, u_short, u_long); |
349 | int aim_puttlv_str(u_char *buf, u_short t, u_short l, u_char *v); | |
0e2be272 | 350 | int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list); |
351 | int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val); | |
e6b05d80 | 352 | int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val); |
353 | int aim_addtlvtochain_str(struct aim_tlvlist_t **list, unsigned short type, char *str, int len); | |
354 | int aim_counttlvchain(struct aim_tlvlist_t **list); | |
bd71fa88 | 355 | |
356 | /* | |
357 | * Get command from connections / Dispatch commands | |
358 | * already in queue. | |
359 | */ | |
f1a5efe0 | 360 | int aim_get_command(struct aim_session_t *, struct aim_conn_t *); |
bd71fa88 | 361 | int aim_rxdispatch(struct aim_session_t *); |
362 | ||
363 | int aim_logoff(struct aim_session_t *); | |
364 | ||
040457cc | 365 | void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn); |
bd71fa88 | 366 | |
367 | typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...); | |
368 | int aim_register_callbacks(rxcallback_t *); | |
369 | ||
370 | u_long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype); | |
371 | u_long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *); | |
372 | u_long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *); | |
373 | ||
374 | /* aim_login.c */ | |
01b59e1e | 375 | int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn); |
376 | int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); | |
bd71fa88 | 377 | int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *); |
378 | int aim_encode_password(const char *, u_char *); | |
5e02cf44 | 379 | int aimicq_encode_password(const char *password, u_char *encoded); |
e6b05d80 | 380 | unsigned long aim_sendauthresp(struct aim_session_t *sess, |
381 | struct aim_conn_t *conn, | |
382 | char *sn, char *bosip, | |
383 | char *cookie, char *email, | |
384 | int regstatus); | |
385 | int aim_gencookie(unsigned char *buf); | |
386 | int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn); | |
387 | unsigned long aim_sendredirect(struct aim_session_t *sess, | |
388 | struct aim_conn_t *conn, | |
389 | unsigned short servid, | |
390 | char *ip, | |
391 | char *cookie); | |
b8d0da45 | 392 | void aim_purge_rxqueue(struct aim_session_t *); |
68ac63c2 | 393 | void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn); |
bd71fa88 | 394 | |
395 | int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...); | |
396 | int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...); | |
397 | int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); | |
398 | ||
b69540e3 | 399 | |
400 | struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen); | |
e88ba395 | 401 | int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *); |
402 | int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *); | |
403 | #define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y)) | |
68ac63c2 | 404 | int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx_struct *cur); |
bd71fa88 | 405 | u_int aim_get_next_txseqnum(struct aim_conn_t *); |
406 | int aim_tx_flushqueue(struct aim_session_t *); | |
407 | int aim_tx_printqueue(struct aim_session_t *); | |
b8d0da45 | 408 | void aim_tx_purgequeue(struct aim_session_t *); |
bd71fa88 | 409 | |
410 | struct aim_rxcblist_t { | |
411 | u_short family; | |
412 | u_short type; | |
413 | rxcallback_t handler; | |
414 | u_short flags; | |
415 | struct aim_rxcblist_t *next; | |
416 | }; | |
417 | ||
418 | int aim_conn_setlatency(struct aim_conn_t *conn, int newval); | |
419 | ||
420 | int aim_conn_addhandler(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short type, rxcallback_t newhandler, u_short flags); | |
421 | rxcallback_t aim_callhandler(struct aim_conn_t *conn, u_short family, u_short type); | |
422 | int aim_clearhandlers(struct aim_conn_t *conn); | |
423 | ||
424 | /* | |
425 | * Generic SNAC structure. Rarely if ever used. | |
426 | */ | |
427 | struct aim_snac_t { | |
428 | u_long id; | |
429 | u_short family; | |
430 | u_short type; | |
431 | u_short flags; | |
432 | void *data; | |
433 | time_t issuetime; | |
434 | struct aim_snac_t *next; | |
435 | }; | |
436 | u_long aim_newsnac(struct aim_session_t *, struct aim_snac_t *newsnac); | |
437 | struct aim_snac_t *aim_remsnac(struct aim_session_t *, u_long id); | |
438 | int aim_cleansnacs(struct aim_session_t *, int maxage); | |
439 | int aim_putsnac(u_char *, int, int, int, u_long); | |
440 | ||
441 | ||
442 | void aim_connrst(struct aim_session_t *); | |
443 | struct aim_conn_t *aim_conn_getnext(struct aim_session_t *); | |
444 | void aim_conn_close(struct aim_conn_t *deadconn); | |
445 | struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type); | |
446 | struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest); | |
447 | int aim_conngetmaxfd(struct aim_session_t *); | |
b8d0da45 | 448 | struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *); |
bd71fa88 | 449 | int aim_conn_isready(struct aim_conn_t *); |
450 | int aim_conn_setstatus(struct aim_conn_t *, int); | |
451 | void aim_session_init(struct aim_session_t *); | |
452 | ||
453 | /* aim_misc.c */ | |
454 | ||
455 | #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 | |
456 | #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 | |
457 | #define AIM_VISIBILITYCHANGE_DENYADD 0x07 | |
458 | #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 | |
459 | ||
f0a7908e | 460 | u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *); |
bd71fa88 | 461 | u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); |
462 | u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); | |
463 | u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *); | |
5b79dc93 | 464 | u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int); |
bd71fa88 | 465 | u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long); |
466 | u_long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *); | |
467 | u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *); | |
468 | u_long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *); | |
469 | u_long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long); | |
470 | u_long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *); | |
471 | u_long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short); | |
472 | u_long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *); | |
473 | u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *); | |
474 | u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *); | |
475 | u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *); | |
0c20631f | 476 | u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); |
bd71fa88 | 477 | |
478 | /* aim_rxhandlers.c */ | |
479 | int aim_rxdispatch(struct aim_session_t *); | |
480 | int aim_authparse(struct aim_session_t *, struct command_rx_struct *); | |
481 | int aim_handleredirect_middle(struct aim_session_t *, struct command_rx_struct *, ...); | |
482 | int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *, ...); | |
483 | int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); | |
484 | int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...); | |
01b59e1e | 485 | int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...); |
bd71fa88 | 486 | |
487 | /* aim_im.c */ | |
488 | #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ | |
489 | #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ | |
490 | ||
491 | u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *); | |
492 | int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *); | |
493 | u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn); | |
494 | int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *); | |
5e02cf44 | 495 | int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command); |
bd71fa88 | 496 | |
497 | /* aim_info.c */ | |
5b79dc93 | 498 | #define AIM_CAPS_BUDDYICON 0x01 |
499 | #define AIM_CAPS_VOICE 0x02 | |
500 | #define AIM_CAPS_IMIMAGE 0x04 | |
501 | #define AIM_CAPS_CHAT 0x08 | |
502 | #define AIM_CAPS_GETFILE 0x10 | |
503 | #define AIM_CAPS_SENDFILE 0x20 | |
b69540e3 | 504 | |
5b79dc93 | 505 | extern u_char aim_caps[6][16]; |
b69540e3 | 506 | u_short aim_getcap(unsigned char *capblock, int buflen); |
507 | int aim_putcap(unsigned char *capblock, int buflen, u_short caps); | |
262272cc | 508 | |
509 | #define AIM_GETINFO_GENERALINFO 0x00001 | |
510 | #define AIM_GETINFO_AWAYMESSAGE 0x00003 | |
511 | ||
040457cc | 512 | struct aim_msgcookie_t { |
513 | unsigned char cookie[8]; | |
040457cc | 514 | int type; |
515 | void *data; | |
516 | time_t addtime; | |
517 | struct aim_msgcookie_t *next; | |
518 | }; | |
519 | ||
520 | struct aim_filetransfer_t { | |
521 | char sender[MAXSNLEN]; | |
522 | char ip[30]; | |
523 | char *filename; | |
524 | }; | |
525 | int aim_cachecookie(struct aim_session_t *sess, struct aim_msgcookie_t *cookie); | |
526 | struct aim_msgcookie_t *aim_uncachecookie(struct aim_session_t *sess, char *cookie); | |
527 | int aim_purgecookies(struct aim_session_t *sess); | |
528 | ||
529 | #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 | |
530 | #define AIM_TRANSFER_DENY_DECLINE 0x0001 | |
531 | #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 | |
532 | u_long aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short code); | |
b69540e3 | 533 | u_long aim_accepttransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short rendid); |
040457cc | 534 | |
262272cc | 535 | u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short); |
bd71fa88 | 536 | int aim_extractuserinfo(u_char *, struct aim_userinfo_s *); |
537 | int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *); | |
538 | int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *); | |
539 | int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *); | |
50443ea0 | 540 | int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info); |
541 | int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info); | |
542 | int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); | |
bd71fa88 | 543 | |
f1a5efe0 | 544 | |
bd71fa88 | 545 | /* aim_auth.c */ |
546 | int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *); | |
547 | u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *); | |
548 | u_long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *); | |
549 | ||
550 | /* aim_buddylist.c */ | |
551 | u_long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *); | |
552 | u_long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *); | |
553 | ||
554 | /* aim_search.c */ | |
555 | u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *); | |
556 | /* u_long aim_usersearch_name(struct aim_session_t *, struct aim_conn_t *, char *); */ | |
557 | ||
0c20631f | 558 | |
559 | struct aim_chat_roominfo { | |
560 | u_short exchange; | |
561 | char *name; | |
562 | u_short instance; | |
563 | }; | |
564 | int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo); | |
565 | int aim_chat_parse_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command); | |
566 | int aim_chat_parse_joined(struct aim_session_t *sess, struct command_rx_struct *command); | |
567 | int aim_chat_parse_leave(struct aim_session_t *sess, struct command_rx_struct *command); | |
568 | int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command); | |
569 | u_long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg); | |
570 | u_long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname); | |
571 | u_long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); | |
572 | int aim_chat_attachname(struct aim_conn_t *conn, char *roomname); | |
573 | char *aim_chat_getname(struct aim_conn_t *conn); | |
574 | struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name); | |
575 | ||
576 | u_long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn); | |
577 | u_long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); | |
578 | ||
579 | u_long aim_chat_invite(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *msg, u_short exchange, char *roomname, u_short instance); | |
580 | ||
581 | struct aim_chat_exchangeinfo { | |
582 | u_short number; | |
583 | char *name; | |
584 | char *charset1; | |
585 | char *lang1; | |
586 | char *charset2; | |
587 | char *lang2; | |
588 | }; | |
589 | int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command); | |
590 | u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange); | |
591 | int aim_chat_leaveroom(struct aim_session_t *sess, char *name); | |
592 | ||
bd71fa88 | 593 | /* aim_util.c */ |
f1a5efe0 | 594 | #ifdef AIMUTIL_USEMACROS |
595 | /* | |
596 | * These are really ugly. You'd think this was LISP. I wish it was. | |
597 | */ | |
598 | #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) | |
599 | #define aimutil_get8(buf) ((*(buf))&0xff) | |
600 | #define aimutil_put16(buf, data) ( \ | |
601 | (*(buf) = (u_char)((data)>>8)&0xff), \ | |
602 | (*((buf)+1) = (u_char)(data)&0xff), \ | |
603 | 2) | |
604 | #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
605 | #define aimutil_put32(buf, data) ( \ | |
606 | (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
607 | (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
608 | (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
609 | (*((buf)+3) = (u_char)(data)&0xff), \ | |
610 | 4) | |
611 | #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
612 | (((*((buf)+1))<<16)&0x00ff0000) + \ | |
613 | (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
614 | (((*((buf)+3) )&0x000000ff))) | |
615 | #else | |
616 | #warning Not using aimutil macros. May have performance problems. | |
bd71fa88 | 617 | int aimutil_put8(u_char *, u_char); |
618 | u_char aimutil_get8(u_char *buf); | |
619 | int aimutil_put16(u_char *, u_short); | |
620 | u_short aimutil_get16(u_char *); | |
621 | int aimutil_put32(u_char *, u_long); | |
622 | u_long aimutil_get32(u_char *); | |
f1a5efe0 | 623 | #endif |
624 | ||
bd71fa88 | 625 | int aimutil_putstr(u_char *, const u_char *, int); |
626 | int aimutil_tokslen(char *toSearch, int index, char dl); | |
627 | int aimutil_itemcnt(char *toSearch, char dl); | |
628 | char *aimutil_itemidx(char *toSearch, int index, char dl); | |
629 | ||
e6b05d80 | 630 | int aim_snlen(const char *sn); |
631 | int aim_sncmp(const char *sn1, const char *sn2); | |
632 | ||
0cc57340 | 633 | /* aim_meta.c */ |
91931247 | 634 | char *aim_getbuilddate(void); |
635 | char *aim_getbuildtime(void); | |
0cc57340 | 636 | char *aim_getbuildstring(void); |
637 | ||
bd71fa88 | 638 | #endif /* __AIM_H__ */ |
639 |