comparison libfaim/faim/aim.h @ 445:e4c34ca88d9b

[gaim-migrate @ 455] Hehehehehe Libfaim got updated, gaim got updated. btw, gaim/faim can't sign in yet, don't ask me why. it's not my fault. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 29 Jun 2000 20:40:28 +0000
parents df984d56efb4
children 6d78b988b479
comparison
equal deleted inserted replaced
444:e7885c54ed2f 445:e4c34ca88d9b
8 8
9 #define FAIM_VERSION_MAJOR 0 9 #define FAIM_VERSION_MAJOR 0
10 #define FAIM_VERSION_MINOR 99 10 #define FAIM_VERSION_MINOR 99
11 #define FAIM_VERSION_MINORMINOR 0 11 #define FAIM_VERSION_MINORMINOR 0
12 12
13 #include <faimconfig.h> 13 #include <faim/faimconfig.h>
14 #include <aim_cbtypes.h> 14 #include <faim/aim_cbtypes.h>
15 15
16 #ifndef FAIM_USEPTHREADS 16 #if !defined(FAIM_USEPTHREADS) && !defined(FAIM_USEFAKELOCKS)
17 #error pthreads are currently required. 17 #error pthreads or fakelocks are currently required.
18 #endif 18 #endif
19 19
20 #include <stdio.h> 20 #include <stdio.h>
21 #include <string.h> 21 #include <string.h>
22 #include <fcntl.h> 22 #include <fcntl.h>
29 #include <pthread.h> 29 #include <pthread.h>
30 #define faim_mutex_t pthread_mutex_t 30 #define faim_mutex_t pthread_mutex_t
31 #define faim_mutex_init pthread_mutex_init 31 #define faim_mutex_init pthread_mutex_init
32 #define faim_mutex_lock pthread_mutex_lock 32 #define faim_mutex_lock pthread_mutex_lock
33 #define faim_mutex_unlock pthread_mutex_unlock 33 #define faim_mutex_unlock pthread_mutex_unlock
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;
34 #endif 46 #endif
35 47
36 #ifdef _WIN32 48 #ifdef _WIN32
37 #include <windows.h> 49 #include <windows.h>
38 #include <time.h> 50 #include <time.h>
54 66
55 #if defined(mach) && defined(__APPLE__) 67 #if defined(mach) && defined(__APPLE__)
56 #define gethostbyname(x) gethostbyname2(x, AF_INET) 68 #define gethostbyname(x) gethostbyname2(x, AF_INET)
57 #endif 69 #endif
58 70
71 #if !defined(MSG_WAITALL)
72 #warning FIX YOUR LIBC! MSG_WAITALL is required!
73 #define MSG_WAITALL 0x100
74 #endif
75
59 /* 76 /*
60 * Current Maximum Length for Screen Names (not including NULL) 77 * Current Maximum Length for Screen Names (not including NULL)
61 */ 78 *
62 #define MAXSNLEN 16 79 * Currently only names up to 16 characters can be registered
80 * however it is aparently legal for them to be larger.
81 */
82 #define MAXSNLEN 32
63 83
64 /* 84 /*
65 * Current Maximum Length for Instant Messages 85 * Current Maximum Length for Instant Messages
66 * 86 *
67 * This was found basically by experiment, but not wholly 87 * This was found basically by experiment, but not wholly
72 * for WinAIM clients (up through the latest (4.0.1957)) to 92 * for WinAIM clients (up through the latest (4.0.1957)) to
73 * send any more than 1kb. Amaze all your windows friends 93 * send any more than 1kb. Amaze all your windows friends
74 * with utterly oversized instant messages! 94 * with utterly oversized instant messages!
75 * 95 *
76 */ 96 */
77 #define MAXMSGLEN 7988 97 #define MAXMSGLEN 7987
78 98
79 /* 99 /*
80 * Current Maximum Length for Chat Room Messages 100 * Current Maximum Length for Chat Room Messages
81 * 101 *
82 * This is actually defined by the protocol to be 102 * This is actually defined by the protocol to be
151 */ 171 */
152 #define AIM_CONN_STATUS_READY 0x0001 172 #define AIM_CONN_STATUS_READY 0x0001
153 #define AIM_CONN_STATUS_INTERNALERR 0x0002 173 #define AIM_CONN_STATUS_INTERNALERR 0x0002
154 #define AIM_CONN_STATUS_RESOLVERR 0x0080 174 #define AIM_CONN_STATUS_RESOLVERR 0x0080
155 #define AIM_CONN_STATUS_CONNERR 0x0040 175 #define AIM_CONN_STATUS_CONNERR 0x0040
176
177 #define AIM_FRAMETYPE_OSCAR 0x0000
178 #define AIM_FRAMETYPE_OFT 0x0001
156 179
157 struct aim_conn_t { 180 struct aim_conn_t {
158 int fd; 181 int fd;
159 int type; 182 int type;
160 int seqnum; 183 int seqnum;
168 struct aim_conn_t *next; 191 struct aim_conn_t *next;
169 }; 192 };
170 193
171 /* struct for incoming commands */ 194 /* struct for incoming commands */
172 struct command_rx_struct { 195 struct command_rx_struct {
173 /* byte 1 assumed to always be 0x2a */ 196 unsigned char hdrtype; /* defines which piece of the union to use */
174 char type; /* type code (byte 2) */ 197 union {
175 u_int seqnum; /* sequence number (bytes 3 and 4) */ 198 struct {
176 u_int commandlen; /* total packet len - 6 (bytes 5 and 6) */ 199 char type;
177 u_char *data; /* packet data (from 7 byte on) */ 200 unsigned short seqnum;
178 u_int lock; /* 0 = open, !0 = locked */ 201 } oscar;
179 u_int handled; /* 0 = new, !0 = been handled */ 202 struct {
180 u_int nofree; /* 0 = free data on purge, 1 = only unlink */ 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 */
181 struct aim_conn_t *conn; /* the connection it came in on... */ 213 struct aim_conn_t *conn; /* the connection it came in on... */
182 struct command_rx_struct *next; /* ptr to next struct in list */ 214 struct command_rx_struct *next; /* ptr to next struct in list */
183 }; 215 };
184 216
185 /* struct for outgoing commands */ 217 /* struct for outgoing commands */
186 struct command_tx_struct { 218 struct command_tx_struct {
187 /* byte 1 assumed to be 0x2a */ 219 unsigned char hdrtype; /* defines which piece of the union to use */
188 char type; /* type/family code */ 220 union {
189 u_int seqnum; /* seqnum dynamically assigned on tx */ 221 struct {
190 u_int commandlen; /* SNAC length */ 222 unsigned char type;
191 u_char *data; /* packet data */ 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;
192 u_int lock; /* 0 = open, !0 = locked */ 233 u_int lock; /* 0 = open, !0 = locked */
193 u_int sent; /* 0 = pending, !0 = has been sent */ 234 u_int sent; /* 0 = pending, !0 = has been sent */
194 struct aim_conn_t *conn; 235 struct aim_conn_t *conn;
195 struct command_tx_struct *next; /* ptr to next struct in list */ 236 struct command_tx_struct *next; /* ptr to next struct in list */
196 }; 237 };
316 * Get command from connections / Dispatch commands 357 * Get command from connections / Dispatch commands
317 * already in queue. 358 * already in queue.
318 */ 359 */
319 int aim_get_command(struct aim_session_t *, struct aim_conn_t *); 360 int aim_get_command(struct aim_session_t *, struct aim_conn_t *);
320 int aim_rxdispatch(struct aim_session_t *); 361 int aim_rxdispatch(struct aim_session_t *);
321 362 u_long aim_debugconn_sendconnect(struct aim_session_t *sess,
363 struct aim_conn_t *conn);
322 int aim_logoff(struct aim_session_t *); 364 int aim_logoff(struct aim_session_t *);
323 365
324 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn); 366 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn);
325 367
326 typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...); 368 typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...);
347 struct aim_conn_t *conn, 389 struct aim_conn_t *conn,
348 unsigned short servid, 390 unsigned short servid,
349 char *ip, 391 char *ip,
350 char *cookie); 392 char *cookie);
351 void aim_purge_rxqueue(struct aim_session_t *); 393 void aim_purge_rxqueue(struct aim_session_t *);
352 394 void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn);
353 395
354 int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...); 396 int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...);
355 int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...); 397 int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...);
356 int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); 398 int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
357 399
358 struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int); 400
401 struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen);
359 int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *); 402 int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *);
360 int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *); 403 int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *);
361 #define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y)) 404 #define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y))
362 int aim_tx_sendframe(struct command_tx_struct *cur); 405 int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx_struct *cur);
363 u_int aim_get_next_txseqnum(struct aim_conn_t *); 406 u_int aim_get_next_txseqnum(struct aim_conn_t *);
364 int aim_tx_flushqueue(struct aim_session_t *); 407 int aim_tx_flushqueue(struct aim_session_t *);
365 int aim_tx_printqueue(struct aim_session_t *); 408 int aim_tx_printqueue(struct aim_session_t *);
366 void aim_tx_purgequeue(struct aim_session_t *); 409 void aim_tx_purgequeue(struct aim_session_t *);
367 410
413 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 456 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05
414 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 457 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
415 #define AIM_VISIBILITYCHANGE_DENYADD 0x07 458 #define AIM_VISIBILITYCHANGE_DENYADD 0x07
416 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 459 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08
417 460
461 u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *);
418 u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); 462 u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long);
419 u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); 463 u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *);
420 u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *); 464 u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *);
421 u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int); 465 u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int);
422 u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long); 466 u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long);
445 #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ 489 #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */
446 #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ 490 #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */
447 491
448 u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *); 492 u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *);
449 int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *); 493 int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *);
494 int aim_parse_outgoing_im_middle(struct aim_session_t *, struct command_rx_struct *);
450 u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn); 495 u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn);
451 int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *); 496 int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *);
452 int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command); 497 int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command);
453 498
454 /* aim_info.c */ 499 /* aim_info.c */
456 #define AIM_CAPS_VOICE 0x02 501 #define AIM_CAPS_VOICE 0x02
457 #define AIM_CAPS_IMIMAGE 0x04 502 #define AIM_CAPS_IMIMAGE 0x04
458 #define AIM_CAPS_CHAT 0x08 503 #define AIM_CAPS_CHAT 0x08
459 #define AIM_CAPS_GETFILE 0x10 504 #define AIM_CAPS_GETFILE 0x10
460 #define AIM_CAPS_SENDFILE 0x20 505 #define AIM_CAPS_SENDFILE 0x20
506
461 extern u_char aim_caps[6][16]; 507 extern u_char aim_caps[6][16];
508 u_short aim_getcap(unsigned char *capblock, int buflen);
509 int aim_putcap(unsigned char *capblock, int buflen, u_short caps);
462 510
463 #define AIM_GETINFO_GENERALINFO 0x00001 511 #define AIM_GETINFO_GENERALINFO 0x00001
464 #define AIM_GETINFO_AWAYMESSAGE 0x00003 512 #define AIM_GETINFO_AWAYMESSAGE 0x00003
465 513
466 #define AIM_RENDEZVOUS_VOICE 0x0000
467 #define AIM_RENDEZVOUS_FILETRANSFER 0x0001
468 #define AIM_RENDEZVOUS_CHAT_EX3 0x0003
469 #define AIM_RENDEZVOUS_CHAT_EX4 0x0004
470 #define AIM_RENDEZVOUS_CHAT_EX5 0x0005
471 #define AIM_RENDEZVOUS_FILETRANSFER_GET 0x0012
472
473 struct aim_msgcookie_t { 514 struct aim_msgcookie_t {
474 unsigned char cookie[8]; 515 unsigned char cookie[8];
475 unsigned char extended[16];
476 int type; 516 int type;
477 void *data; 517 void *data;
478 time_t addtime; 518 time_t addtime;
479 struct aim_msgcookie_t *next; 519 struct aim_msgcookie_t *next;
480 }; 520 };
490 530
491 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 531 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
492 #define AIM_TRANSFER_DENY_DECLINE 0x0001 532 #define AIM_TRANSFER_DENY_DECLINE 0x0001
493 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 533 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
494 u_long aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short code); 534 u_long aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short code);
535 u_long aim_accepttransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short rendid);
495 536
496 u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short); 537 u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
497 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *); 538 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
498 int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *); 539 int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
499 int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *); 540 int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *);