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