[b7d3cc34] | 1 | /* |
---|
| 2 | * Main libfaim header. Must be included in client for prototypes/macros. |
---|
| 3 | * |
---|
| 4 | * "come on, i turned a chick lesbian; i think this is the hackish equivalent" |
---|
| 5 | * -- Josh Meyer |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #ifndef __AIM_H__ |
---|
| 10 | #define __AIM_H__ |
---|
| 11 | |
---|
| 12 | #include <stdio.h> |
---|
| 13 | #include <string.h> |
---|
| 14 | #include <fcntl.h> |
---|
| 15 | #include <sys/types.h> |
---|
| 16 | #include <stdlib.h> |
---|
| 17 | #include <stdarg.h> |
---|
| 18 | #include <errno.h> |
---|
| 19 | #include <time.h> |
---|
| 20 | #include <gmodule.h> |
---|
| 21 | |
---|
| 22 | #include "bitlbee.h" |
---|
| 23 | |
---|
| 24 | /* XXX adjust these based on autoconf-detected platform */ |
---|
| 25 | typedef guint32 aim_snacid_t; |
---|
| 26 | typedef guint16 flap_seqnum_t; |
---|
| 27 | |
---|
| 28 | /* Portability stuff (DMP) */ |
---|
| 29 | |
---|
| 30 | #if defined(mach) && defined(__APPLE__) |
---|
| 31 | #define gethostbyname(x) gethostbyname2(x, AF_INET) |
---|
| 32 | #endif |
---|
| 33 | |
---|
| 34 | /* |
---|
| 35 | * Current Maximum Length for Screen Names (not including NULL) |
---|
| 36 | * |
---|
| 37 | * Currently only names up to 16 characters can be registered |
---|
| 38 | * however it is aparently legal for them to be larger. |
---|
| 39 | */ |
---|
| 40 | #define MAXSNLEN 32 |
---|
| 41 | |
---|
| 42 | /* |
---|
| 43 | * Current Maximum Length for Instant Messages |
---|
| 44 | * |
---|
| 45 | * This was found basically by experiment, but not wholly |
---|
| 46 | * accurate experiment. It should not be regarded |
---|
| 47 | * as completely correct. But its a decent approximation. |
---|
| 48 | * |
---|
| 49 | * Note that although we can send this much, its impossible |
---|
| 50 | * for WinAIM clients (up through the latest (4.0.1957)) to |
---|
| 51 | * send any more than 1kb. Amaze all your windows friends |
---|
| 52 | * with utterly oversized instant messages! |
---|
| 53 | * |
---|
| 54 | * XXX: the real limit is the total SNAC size at 8192. Fix this. |
---|
| 55 | * |
---|
| 56 | */ |
---|
| 57 | #define MAXMSGLEN 7987 |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * Maximum size of a Buddy Icon. |
---|
| 61 | */ |
---|
| 62 | #define MAXICONLEN 7168 |
---|
| 63 | #define AIM_ICONIDENT "AVT1picture.id" |
---|
| 64 | |
---|
| 65 | /* |
---|
| 66 | * Current Maximum Length for Chat Room Messages |
---|
| 67 | * |
---|
| 68 | * This is actually defined by the protocol to be |
---|
| 69 | * dynamic, but I have yet to see due cause to |
---|
| 70 | * define it dynamically here. Maybe later. |
---|
| 71 | * |
---|
| 72 | */ |
---|
| 73 | #define MAXCHATMSGLEN 512 |
---|
| 74 | |
---|
| 75 | /* |
---|
| 76 | * Standard size of an AIM authorization cookie |
---|
| 77 | */ |
---|
| 78 | #define AIM_COOKIELEN 0x100 |
---|
| 79 | |
---|
| 80 | #define AIM_MD5_STRING "AOL Instant Messenger (SM)" |
---|
| 81 | |
---|
| 82 | /* |
---|
| 83 | * Default Authorizer server name and TCP port for the OSCAR farm. |
---|
| 84 | * |
---|
| 85 | * You shouldn't need to change this unless you're writing |
---|
| 86 | * your own server. |
---|
| 87 | * |
---|
| 88 | * Note that only one server is needed to start the whole |
---|
| 89 | * AIM process. The later server addresses come from |
---|
| 90 | * the authorizer service. |
---|
| 91 | * |
---|
| 92 | * This is only here for convenience. Its still up to |
---|
| 93 | * the client to connect to it. |
---|
| 94 | * |
---|
| 95 | */ |
---|
| 96 | #define AIM_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" |
---|
| 97 | #define AIM_LOGIN_PORT 5190 |
---|
| 98 | |
---|
| 99 | /* |
---|
| 100 | * Size of the SNAC caching hash. |
---|
| 101 | * |
---|
| 102 | * Default: 16 |
---|
| 103 | * |
---|
| 104 | */ |
---|
| 105 | #define AIM_SNAC_HASH_SIZE 16 |
---|
| 106 | |
---|
| 107 | /* |
---|
| 108 | * Client info. Filled in by the client and passed in to |
---|
| 109 | * aim_send_login(). The information ends up getting passed to OSCAR |
---|
| 110 | * through the initial login command. |
---|
| 111 | * |
---|
| 112 | */ |
---|
| 113 | struct client_info_s { |
---|
| 114 | const char *clientstring; |
---|
| 115 | guint16 clientid; |
---|
| 116 | int major; |
---|
| 117 | int minor; |
---|
| 118 | int point; |
---|
| 119 | int build; |
---|
| 120 | const char *country; /* two-letter abbrev */ |
---|
| 121 | const char *lang; /* two-letter abbrev */ |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | #define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \ |
---|
| 125 | "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \ |
---|
| 126 | 0x0004, \ |
---|
| 127 | 0x0003, \ |
---|
| 128 | 0x0005, \ |
---|
| 129 | 0x0000, \ |
---|
| 130 | 0x0686, \ |
---|
| 131 | "us", \ |
---|
| 132 | "en", \ |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | #define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \ |
---|
| 136 | "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \ |
---|
| 137 | 0x0004, \ |
---|
| 138 | 0x0004, \ |
---|
| 139 | 0x0001, \ |
---|
| 140 | 0x0000, \ |
---|
| 141 | 0x07da, \ |
---|
| 142 | "us", \ |
---|
| 143 | "en", \ |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | /* |
---|
| 147 | * I would make 4.1.2010 the default, but they seem to have found |
---|
| 148 | * an alternate way of breaking that one. |
---|
| 149 | * |
---|
| 150 | * 3.5.1670 should work fine, however, you will be subjected to the |
---|
| 151 | * memory test, which may require you to have a WinAIM binary laying |
---|
| 152 | * around. (see login.c::memrequest()) |
---|
| 153 | */ |
---|
| 154 | #define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 |
---|
| 155 | |
---|
| 156 | #ifndef TRUE |
---|
| 157 | #define TRUE 1 |
---|
| 158 | #define FALSE 0 |
---|
| 159 | #endif |
---|
| 160 | |
---|
| 161 | /* |
---|
| 162 | * These could be arbitrary, but its easier to use the actual AIM values |
---|
| 163 | */ |
---|
| 164 | #define AIM_CONN_TYPE_AUTH 0x0007 |
---|
| 165 | #define AIM_CONN_TYPE_ADS 0x0005 |
---|
| 166 | #define AIM_CONN_TYPE_BOS 0x0002 |
---|
| 167 | #define AIM_CONN_TYPE_CHAT 0x000e |
---|
| 168 | #define AIM_CONN_TYPE_CHATNAV 0x000d |
---|
| 169 | |
---|
| 170 | /* |
---|
| 171 | * Status values returned from aim_conn_new(). ORed together. |
---|
| 172 | */ |
---|
| 173 | #define AIM_CONN_STATUS_READY 0x0001 |
---|
| 174 | #define AIM_CONN_STATUS_INTERNALERR 0x0002 |
---|
| 175 | #define AIM_CONN_STATUS_RESOLVERR 0x0040 |
---|
| 176 | #define AIM_CONN_STATUS_CONNERR 0x0080 |
---|
| 177 | #define AIM_CONN_STATUS_INPROGRESS 0x0100 |
---|
| 178 | |
---|
| 179 | #define AIM_FRAMETYPE_FLAP 0x0000 |
---|
| 180 | |
---|
| 181 | /* |
---|
| 182 | * message type flags |
---|
| 183 | */ |
---|
| 184 | #define AIM_MTYPE_PLAIN 0x01 |
---|
| 185 | #define AIM_MTYPE_CHAT 0x02 |
---|
| 186 | #define AIM_MTYPE_FILEREQ 0x03 |
---|
| 187 | #define AIM_MTYPE_URL 0x04 |
---|
| 188 | #define AIM_MTYPE_AUTHREQ 0x06 |
---|
| 189 | #define AIM_MTYPE_AUTHDENY 0x07 |
---|
| 190 | #define AIM_MTYPE_AUTHOK 0x08 |
---|
| 191 | #define AIM_MTYPE_SERVER 0x09 |
---|
| 192 | #define AIM_MTYPE_ADDED 0x0C |
---|
| 193 | #define AIM_MTYPE_WWP 0x0D |
---|
| 194 | #define AIM_MTYPE_EEXPRESS 0x0E |
---|
| 195 | #define AIM_MTYPE_CONTACTS 0x13 |
---|
| 196 | #define AIM_MTYPE_PLUGIN 0x1A |
---|
| 197 | #define AIM_MTYPE_AUTOAWAY 0xE8 |
---|
| 198 | #define AIM_MTYPE_AUTOBUSY 0xE9 |
---|
| 199 | #define AIM_MTYPE_AUTONA 0xEA |
---|
| 200 | #define AIM_MTYPE_AUTODND 0xEB |
---|
| 201 | #define AIM_MTYPE_AUTOFFC 0xEC |
---|
| 202 | |
---|
| 203 | typedef struct aim_conn_s { |
---|
| 204 | int fd; |
---|
| 205 | guint16 type; |
---|
| 206 | guint16 subtype; |
---|
| 207 | flap_seqnum_t seqnum; |
---|
| 208 | guint32 status; |
---|
| 209 | void *priv; /* misc data the client may want to store */ |
---|
| 210 | void *internal; /* internal conn-specific libfaim data */ |
---|
| 211 | time_t lastactivity; /* time of last transmit */ |
---|
| 212 | int forcedlatency; |
---|
| 213 | void *handlerlist; |
---|
| 214 | void *sessv; /* pointer to parent session */ |
---|
| 215 | void *inside; /* only accessible from inside libfaim */ |
---|
| 216 | struct aim_conn_s *next; |
---|
| 217 | } aim_conn_t; |
---|
| 218 | |
---|
| 219 | /* |
---|
| 220 | * Byte Stream type. Sort of. |
---|
| 221 | * |
---|
| 222 | * Use of this type serves a couple purposes: |
---|
| 223 | * - Buffer/buflen pairs are passed all around everywhere. This turns |
---|
| 224 | * that into one value, as well as abstracting it slightly. |
---|
| 225 | * - Through the abstraction, it is possible to enable bounds checking |
---|
| 226 | * for robustness at the cost of performance. But a clean failure on |
---|
| 227 | * weird packets is much better than a segfault. |
---|
| 228 | * - I like having variables named "bs". |
---|
| 229 | * |
---|
| 230 | * Don't touch the insides of this struct. Or I'll have to kill you. |
---|
| 231 | * |
---|
| 232 | */ |
---|
| 233 | typedef struct aim_bstream_s { |
---|
| 234 | guint8 *data; |
---|
| 235 | guint32 len; |
---|
| 236 | guint32 offset; |
---|
| 237 | } aim_bstream_t; |
---|
| 238 | |
---|
| 239 | typedef struct aim_frame_s { |
---|
| 240 | guint8 hdrtype; /* defines which piece of the union to use */ |
---|
| 241 | union { |
---|
| 242 | struct { |
---|
| 243 | guint8 type; |
---|
| 244 | flap_seqnum_t seqnum; |
---|
| 245 | } flap; |
---|
| 246 | } hdr; |
---|
| 247 | aim_bstream_t data; /* payload stream */ |
---|
| 248 | guint8 handled; /* 0 = new, !0 = been handled */ |
---|
| 249 | guint8 nofree; /* 0 = free data on purge, 1 = only unlink */ |
---|
| 250 | aim_conn_t *conn; /* the connection it came in on... */ |
---|
| 251 | struct aim_frame_s *next; |
---|
| 252 | } aim_frame_t; |
---|
| 253 | |
---|
| 254 | typedef struct aim_msgcookie_s { |
---|
| 255 | unsigned char cookie[8]; |
---|
| 256 | int type; |
---|
| 257 | void *data; |
---|
| 258 | time_t addtime; |
---|
| 259 | struct aim_msgcookie_s *next; |
---|
| 260 | } aim_msgcookie_t; |
---|
| 261 | |
---|
| 262 | /* |
---|
| 263 | * AIM Session: The main client-data interface. |
---|
| 264 | * |
---|
| 265 | */ |
---|
| 266 | typedef struct aim_session_s { |
---|
| 267 | |
---|
| 268 | /* ---- Client Accessible ------------------------ */ |
---|
| 269 | |
---|
| 270 | /* Our screen name. */ |
---|
| 271 | char sn[MAXSNLEN+1]; |
---|
| 272 | |
---|
| 273 | /* |
---|
| 274 | * Pointer to anything the client wants to |
---|
| 275 | * explicitly associate with this session. |
---|
| 276 | * |
---|
| 277 | * This is for use in the callbacks mainly. In any |
---|
| 278 | * callback, you can access this with sess->aux_data. |
---|
| 279 | * |
---|
| 280 | */ |
---|
| 281 | void *aux_data; |
---|
| 282 | |
---|
| 283 | /* ---- Internal Use Only ------------------------ */ |
---|
| 284 | |
---|
| 285 | /* Server-stored information (ssi) */ |
---|
| 286 | struct { |
---|
| 287 | int received_data; |
---|
| 288 | guint16 revision; |
---|
| 289 | struct aim_ssi_item *items; |
---|
| 290 | time_t timestamp; |
---|
| 291 | int waiting_for_ack; |
---|
| 292 | aim_frame_t *holding_queue; |
---|
| 293 | } ssi; |
---|
| 294 | |
---|
| 295 | /* Connection information */ |
---|
| 296 | aim_conn_t *connlist; |
---|
| 297 | |
---|
| 298 | /* |
---|
| 299 | * Transmit/receive queues. |
---|
| 300 | * |
---|
| 301 | * These are only used when you don't use your own lowlevel |
---|
| 302 | * I/O. I don't suggest that you use libfaim's internal I/O. |
---|
| 303 | * Its really bad and the API/event model is quirky at best. |
---|
| 304 | * |
---|
| 305 | */ |
---|
| 306 | aim_frame_t *queue_outgoing; |
---|
| 307 | aim_frame_t *queue_incoming; |
---|
| 308 | |
---|
| 309 | /* |
---|
| 310 | * Tx Enqueuing function. |
---|
| 311 | * |
---|
| 312 | * This is how you override the transmit direction of libfaim's |
---|
| 313 | * internal I/O. This function will be called whenever it needs |
---|
| 314 | * to send something. |
---|
| 315 | * |
---|
| 316 | */ |
---|
| 317 | int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *); |
---|
| 318 | |
---|
| 319 | /* |
---|
| 320 | * Outstanding snac handling |
---|
| 321 | * |
---|
| 322 | * XXX: Should these be per-connection? -mid |
---|
| 323 | */ |
---|
| 324 | void *snac_hash[AIM_SNAC_HASH_SIZE]; |
---|
| 325 | aim_snacid_t snacid_next; |
---|
| 326 | |
---|
| 327 | struct aim_icq_info *icq_info; |
---|
| 328 | struct aim_oft_info *oft_info; |
---|
| 329 | struct aim_authresp_info *authinfo; |
---|
| 330 | struct aim_emailinfo *emailinfo; |
---|
| 331 | |
---|
| 332 | struct { |
---|
| 333 | struct aim_userinfo_s *userinfo; |
---|
| 334 | struct userinfo_node *torequest; |
---|
| 335 | struct userinfo_node *requested; |
---|
| 336 | int waiting_for_response; |
---|
| 337 | } locate; |
---|
| 338 | |
---|
| 339 | guint32 flags; /* AIM_SESS_FLAGS_ */ |
---|
| 340 | |
---|
| 341 | aim_msgcookie_t *msgcookies; |
---|
| 342 | |
---|
| 343 | void *modlistv; |
---|
| 344 | |
---|
| 345 | guint8 aim_icq_state; /* ICQ representation of away state */ |
---|
| 346 | } aim_session_t; |
---|
| 347 | |
---|
| 348 | /* Values for sess->flags */ |
---|
| 349 | #define AIM_SESS_FLAGS_SNACLOGIN 0x00000001 |
---|
| 350 | #define AIM_SESS_FLAGS_XORLOGIN 0x00000002 |
---|
| 351 | #define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004 |
---|
| 352 | #define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008 |
---|
| 353 | |
---|
| 354 | /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */ |
---|
| 355 | #define AIM_ICQ_STATE_NORMAL 0x00000000 |
---|
| 356 | #define AIM_ICQ_STATE_AWAY 0x00000001 |
---|
| 357 | #define AIM_ICQ_STATE_DND 0x00000002 |
---|
| 358 | #define AIM_ICQ_STATE_OUT 0x00000004 |
---|
| 359 | #define AIM_ICQ_STATE_BUSY 0x00000010 |
---|
| 360 | #define AIM_ICQ_STATE_CHAT 0x00000020 |
---|
| 361 | #define AIM_ICQ_STATE_INVISIBLE 0x00000100 |
---|
| 362 | #define AIM_ICQ_STATE_WEBAWARE 0x00010000 |
---|
| 363 | #define AIM_ICQ_STATE_HIDEIP 0x00020000 |
---|
| 364 | #define AIM_ICQ_STATE_BIRTHDAY 0x00080000 |
---|
| 365 | #define AIM_ICQ_STATE_DIRECTDISABLED 0x00100000 |
---|
| 366 | #define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000 |
---|
| 367 | #define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000 |
---|
| 368 | #define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000 |
---|
| 369 | |
---|
| 370 | /* |
---|
| 371 | * AIM User Info, Standard Form. |
---|
| 372 | */ |
---|
| 373 | typedef struct { |
---|
| 374 | char sn[MAXSNLEN+1]; |
---|
| 375 | guint16 warnlevel; |
---|
| 376 | guint16 idletime; |
---|
| 377 | guint16 flags; |
---|
| 378 | guint32 membersince; |
---|
| 379 | guint32 onlinesince; |
---|
| 380 | guint32 sessionlen; |
---|
| 381 | guint32 capabilities; |
---|
| 382 | struct { |
---|
| 383 | guint32 status; |
---|
| 384 | guint32 ipaddr; |
---|
| 385 | guint8 crap[0x25]; /* until we figure it out... */ |
---|
| 386 | } icqinfo; |
---|
| 387 | guint32 present; |
---|
| 388 | } aim_userinfo_t; |
---|
| 389 | |
---|
| 390 | #define AIM_USERINFO_PRESENT_FLAGS 0x00000001 |
---|
| 391 | #define AIM_USERINFO_PRESENT_MEMBERSINCE 0x00000002 |
---|
| 392 | #define AIM_USERINFO_PRESENT_ONLINESINCE 0x00000004 |
---|
| 393 | #define AIM_USERINFO_PRESENT_IDLE 0x00000008 |
---|
| 394 | #define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010 |
---|
| 395 | #define AIM_USERINFO_PRESENT_ICQIPADDR 0x00000020 |
---|
| 396 | #define AIM_USERINFO_PRESENT_ICQDATA 0x00000040 |
---|
| 397 | #define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080 |
---|
| 398 | #define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100 |
---|
| 399 | |
---|
| 400 | const char *aim_userinfo_sn(aim_userinfo_t *ui); |
---|
| 401 | guint16 aim_userinfo_flags(aim_userinfo_t *ui); |
---|
| 402 | guint16 aim_userinfo_idle(aim_userinfo_t *ui); |
---|
| 403 | float aim_userinfo_warnlevel(aim_userinfo_t *ui); |
---|
| 404 | time_t aim_userinfo_membersince(aim_userinfo_t *ui); |
---|
| 405 | time_t aim_userinfo_onlinesince(aim_userinfo_t *ui); |
---|
| 406 | guint32 aim_userinfo_sessionlen(aim_userinfo_t *ui); |
---|
| 407 | int aim_userinfo_hascap(aim_userinfo_t *ui, guint32 cap); |
---|
| 408 | |
---|
| 409 | #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */ |
---|
| 410 | #define AIM_FLAG_ADMINISTRATOR 0x0002 |
---|
| 411 | #define AIM_FLAG_AOL 0x0004 |
---|
| 412 | #define AIM_FLAG_OSCAR_PAY 0x0008 |
---|
| 413 | #define AIM_FLAG_FREE 0x0010 |
---|
| 414 | #define AIM_FLAG_AWAY 0x0020 |
---|
| 415 | #define AIM_FLAG_ICQ 0x0040 |
---|
| 416 | #define AIM_FLAG_WIRELESS 0x0080 |
---|
| 417 | #define AIM_FLAG_UNKNOWN100 0x0100 |
---|
| 418 | #define AIM_FLAG_UNKNOWN200 0x0200 |
---|
| 419 | #define AIM_FLAG_ACTIVEBUDDY 0x0400 |
---|
| 420 | #define AIM_FLAG_UNKNOWN800 0x0800 |
---|
| 421 | #define AIM_FLAG_ABINTERNAL 0x1000 |
---|
| 422 | |
---|
| 423 | #define AIM_FLAG_ALLUSERS 0x001f |
---|
| 424 | |
---|
| 425 | /* |
---|
| 426 | * TLV handling |
---|
| 427 | */ |
---|
| 428 | |
---|
| 429 | /* Generic TLV structure. */ |
---|
| 430 | typedef struct aim_tlv_s { |
---|
| 431 | guint16 type; |
---|
| 432 | guint16 length; |
---|
| 433 | guint8 *value; |
---|
| 434 | } aim_tlv_t; |
---|
| 435 | |
---|
| 436 | /* List of above. */ |
---|
| 437 | typedef struct aim_tlvlist_s { |
---|
| 438 | aim_tlv_t *tlv; |
---|
| 439 | struct aim_tlvlist_s *next; |
---|
| 440 | } aim_tlvlist_t; |
---|
| 441 | |
---|
| 442 | /* TLV-handling functions */ |
---|
| 443 | |
---|
| 444 | #if 0 |
---|
| 445 | /* Very, very raw TLV handling. */ |
---|
| 446 | int aim_puttlv_8(guint8 *buf, const guint16 t, const guint8 v); |
---|
| 447 | int aim_puttlv_16(guint8 *buf, const guint16 t, const guint16 v); |
---|
| 448 | int aim_puttlv_32(guint8 *buf, const guint16 t, const guint32 v); |
---|
| 449 | int aim_puttlv_raw(guint8 *buf, const guint16 t, const guint16 l, const guint8 *v); |
---|
| 450 | #endif |
---|
| 451 | |
---|
| 452 | /* TLV list handling. */ |
---|
| 453 | aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs); |
---|
| 454 | void aim_freetlvchain(aim_tlvlist_t **list); |
---|
| 455 | aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, guint16 t, const int n); |
---|
| 456 | char *aim_gettlv_str(aim_tlvlist_t *list, const guint16 t, const int n); |
---|
| 457 | guint8 aim_gettlv8(aim_tlvlist_t *list, const guint16 type, const int num); |
---|
| 458 | guint16 aim_gettlv16(aim_tlvlist_t *list, const guint16 t, const int n); |
---|
| 459 | guint32 aim_gettlv32(aim_tlvlist_t *list, const guint16 t, const int n); |
---|
| 460 | int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list); |
---|
| 461 | int aim_addtlvtochain8(aim_tlvlist_t **list, const guint16 t, const guint8 v); |
---|
| 462 | int aim_addtlvtochain16(aim_tlvlist_t **list, const guint16 t, const guint16 v); |
---|
| 463 | int aim_addtlvtochain32(aim_tlvlist_t **list, const guint16 type, const guint32 v); |
---|
| 464 | int aim_addtlvtochain_availmsg(aim_tlvlist_t **list, const guint16 type, const char *msg); |
---|
| 465 | int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l, const guint8 *v); |
---|
| 466 | int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps); |
---|
| 467 | int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type); |
---|
[b8ef1b1] | 468 | int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance); |
---|
[b7d3cc34] | 469 | int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui); |
---|
| 470 | int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl); |
---|
| 471 | int aim_counttlvchain(aim_tlvlist_t **list); |
---|
| 472 | int aim_sizetlvchain(aim_tlvlist_t **list); |
---|
| 473 | |
---|
| 474 | |
---|
| 475 | /* |
---|
| 476 | * Get command from connections |
---|
| 477 | * |
---|
| 478 | * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction. |
---|
| 479 | * XXX Make this easily overridable. |
---|
| 480 | * |
---|
| 481 | */ |
---|
| 482 | int aim_get_command(aim_session_t *, aim_conn_t *); |
---|
| 483 | |
---|
| 484 | /* |
---|
| 485 | * Dispatch commands that are in the rx queue. |
---|
| 486 | */ |
---|
| 487 | void aim_rxdispatch(aim_session_t *); |
---|
| 488 | |
---|
| 489 | int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
| 490 | |
---|
| 491 | typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...); |
---|
| 492 | |
---|
| 493 | struct aim_clientrelease { |
---|
| 494 | char *name; |
---|
| 495 | guint32 build; |
---|
| 496 | char *url; |
---|
| 497 | char *info; |
---|
| 498 | }; |
---|
| 499 | |
---|
| 500 | struct aim_authresp_info { |
---|
| 501 | char *sn; |
---|
| 502 | guint16 errorcode; |
---|
| 503 | char *errorurl; |
---|
| 504 | guint16 regstatus; |
---|
| 505 | char *email; |
---|
| 506 | char *bosip; |
---|
| 507 | guint8 *cookie; |
---|
| 508 | struct aim_clientrelease latestrelease; |
---|
| 509 | struct aim_clientrelease latestbeta; |
---|
| 510 | }; |
---|
| 511 | |
---|
| 512 | /* Callback data for redirect. */ |
---|
| 513 | struct aim_redirect_data { |
---|
| 514 | guint16 group; |
---|
| 515 | const char *ip; |
---|
| 516 | const guint8 *cookie; |
---|
| 517 | struct { /* group == AIM_CONN_TYPE_CHAT */ |
---|
| 518 | guint16 exchange; |
---|
| 519 | const char *room; |
---|
| 520 | guint16 instance; |
---|
| 521 | } chat; |
---|
| 522 | }; |
---|
| 523 | |
---|
| 524 | int aim_clientready(aim_session_t *sess, aim_conn_t *conn); |
---|
| 525 | int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn); |
---|
| 526 | int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
| 527 | int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key); |
---|
| 528 | int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest); |
---|
| 529 | void aim_purge_rxqueue(aim_session_t *); |
---|
| 530 | |
---|
| 531 | #define AIM_TX_QUEUED 0 /* default */ |
---|
| 532 | #define AIM_TX_IMMEDIATE 1 |
---|
| 533 | #define AIM_TX_USER 2 |
---|
| 534 | int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)); |
---|
| 535 | |
---|
| 536 | int aim_tx_flushqueue(aim_session_t *); |
---|
| 537 | void aim_tx_purgequeue(aim_session_t *); |
---|
| 538 | |
---|
| 539 | int aim_conn_setlatency(aim_conn_t *conn, int newval); |
---|
| 540 | |
---|
| 541 | void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn); |
---|
| 542 | |
---|
| 543 | int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags); |
---|
| 544 | int aim_clearhandlers(aim_conn_t *conn); |
---|
| 545 | |
---|
| 546 | aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, guint16 group); |
---|
| 547 | aim_session_t *aim_conn_getsess(aim_conn_t *conn); |
---|
| 548 | void aim_conn_close(aim_conn_t *deadconn); |
---|
| 549 | aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest); |
---|
| 550 | int aim_conngetmaxfd(aim_session_t *); |
---|
| 551 | aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *); |
---|
| 552 | int aim_conn_isready(aim_conn_t *); |
---|
| 553 | int aim_conn_setstatus(aim_conn_t *, int); |
---|
| 554 | int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
| 555 | int aim_conn_isconnecting(aim_conn_t *conn); |
---|
| 556 | |
---|
| 557 | typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va); |
---|
| 558 | int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t); |
---|
| 559 | void aim_session_init(aim_session_t *, guint32 flags, int debuglevel); |
---|
| 560 | void aim_session_kill(aim_session_t *); |
---|
| 561 | void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password); |
---|
| 562 | aim_conn_t *aim_getconn_type(aim_session_t *, int type); |
---|
| 563 | aim_conn_t *aim_getconn_type_all(aim_session_t *, int type); |
---|
| 564 | aim_conn_t *aim_getconn_fd(aim_session_t *, int fd); |
---|
| 565 | |
---|
| 566 | /* aim_misc.c */ |
---|
| 567 | |
---|
| 568 | |
---|
| 569 | struct aim_chat_roominfo { |
---|
| 570 | unsigned short exchange; |
---|
| 571 | char *name; |
---|
| 572 | unsigned short instance; |
---|
| 573 | }; |
---|
| 574 | |
---|
[b8ef1b1] | 575 | struct aim_chat_invitation { |
---|
[0da65d5] | 576 | struct im_connection * ic; |
---|
[b8ef1b1] | 577 | char * name; |
---|
| 578 | guint8 exchange; |
---|
| 579 | }; |
---|
[b7d3cc34] | 580 | |
---|
| 581 | #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 |
---|
| 582 | #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 |
---|
| 583 | #define AIM_VISIBILITYCHANGE_DENYADD 0x07 |
---|
| 584 | #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 |
---|
| 585 | |
---|
| 586 | #define AIM_PRIVFLAGS_ALLOWIDLE 0x01 |
---|
| 587 | #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02 |
---|
| 588 | |
---|
| 589 | #define AIM_WARN_ANON 0x01 |
---|
| 590 | |
---|
| 591 | int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn); |
---|
| 592 | int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, guint32 flags); |
---|
| 593 | int aim_nop(aim_session_t *, aim_conn_t *); |
---|
| 594 | int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn); |
---|
| 595 | int aim_bos_setidle(aim_session_t *, aim_conn_t *, guint32); |
---|
| 596 | int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *); |
---|
| 597 | int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *); |
---|
| 598 | int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, guint32 caps); |
---|
| 599 | int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, guint32 mask); |
---|
| 600 | int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, guint32); |
---|
| 601 | int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *); |
---|
| 602 | int aim_reqservice(aim_session_t *, aim_conn_t *, guint16); |
---|
| 603 | int aim_bos_reqrights(aim_session_t *, aim_conn_t *); |
---|
| 604 | int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *); |
---|
| 605 | int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *); |
---|
| 606 | int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy); |
---|
| 607 | int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy); |
---|
| 608 | int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status); |
---|
| 609 | |
---|
| 610 | struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *); |
---|
| 611 | |
---|
| 612 | #define AIM_CLIENTTYPE_UNKNOWN 0x0000 |
---|
| 613 | #define AIM_CLIENTTYPE_MC 0x0001 |
---|
| 614 | #define AIM_CLIENTTYPE_WINAIM 0x0002 |
---|
| 615 | #define AIM_CLIENTTYPE_WINAIM41 0x0003 |
---|
| 616 | #define AIM_CLIENTTYPE_AOL_TOC 0x0004 |
---|
| 617 | unsigned short aim_fingerprintclient(unsigned char *msghdr, int len); |
---|
| 618 | |
---|
| 619 | #define AIM_RATE_CODE_CHANGE 0x0001 |
---|
| 620 | #define AIM_RATE_CODE_WARNING 0x0002 |
---|
| 621 | #define AIM_RATE_CODE_LIMIT 0x0003 |
---|
| 622 | #define AIM_RATE_CODE_CLEARLIMIT 0x0004 |
---|
| 623 | int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn); |
---|
| 624 | |
---|
| 625 | /* aim_im.c */ |
---|
| 626 | |
---|
| 627 | aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, guint16 numfiles, guint32 totsize); |
---|
| 628 | |
---|
| 629 | aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn); |
---|
| 630 | int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size); |
---|
| 631 | int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn); |
---|
| 632 | int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn); |
---|
| 633 | |
---|
| 634 | #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0 |
---|
| 635 | #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1 |
---|
| 636 | |
---|
| 637 | int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag); |
---|
| 638 | |
---|
| 639 | #define AIM_GETINFO_GENERALINFO 0x00001 |
---|
| 640 | #define AIM_GETINFO_AWAYMESSAGE 0x00003 |
---|
| 641 | #define AIM_GETINFO_CAPABILITIES 0x0004 |
---|
| 642 | |
---|
| 643 | struct aim_invite_priv { |
---|
| 644 | char *sn; |
---|
| 645 | char *roomname; |
---|
| 646 | guint16 exchange; |
---|
| 647 | guint16 instance; |
---|
| 648 | }; |
---|
| 649 | |
---|
| 650 | #define AIM_COOKIETYPE_UNKNOWN 0x00 |
---|
| 651 | #define AIM_COOKIETYPE_ICBM 0x01 |
---|
| 652 | #define AIM_COOKIETYPE_ADS 0x02 |
---|
| 653 | #define AIM_COOKIETYPE_BOS 0x03 |
---|
| 654 | #define AIM_COOKIETYPE_IM 0x04 |
---|
| 655 | #define AIM_COOKIETYPE_CHAT 0x05 |
---|
| 656 | #define AIM_COOKIETYPE_CHATNAV 0x06 |
---|
| 657 | #define AIM_COOKIETYPE_INVITE 0x07 |
---|
| 658 | |
---|
| 659 | int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur); |
---|
| 660 | |
---|
| 661 | #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 |
---|
| 662 | #define AIM_TRANSFER_DENY_DECLINE 0x0001 |
---|
| 663 | #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 |
---|
| 664 | int aim_denytransfer(aim_session_t *sess, const char *sender, const guint8 *cookie, unsigned short code); |
---|
| 665 | aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const guint8 *cookie, const guint8 *ip, guint16 listingfiles, guint16 listingtotsize, guint16 listingsize, guint32 listingchecksum, guint16 rendid); |
---|
| 666 | |
---|
| 667 | int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short); |
---|
| 668 | int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info); |
---|
| 669 | int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
| 670 | |
---|
| 671 | #define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001 |
---|
| 672 | #define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002 |
---|
| 673 | |
---|
| 674 | /* This is what the server will give you if you don't set them yourself. */ |
---|
| 675 | #define AIM_IMPARAM_DEFAULTS { \ |
---|
| 676 | 0, \ |
---|
| 677 | AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ |
---|
| 678 | 512, /* !! Note how small this is. */ \ |
---|
| 679 | (99.9)*10, (99.9)*10, \ |
---|
| 680 | 1000 /* !! And how large this is. */ \ |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | /* This is what most AIM versions use. */ |
---|
| 684 | #define AIM_IMPARAM_REASONABLE { \ |
---|
| 685 | 0, \ |
---|
| 686 | AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ |
---|
| 687 | 8000, \ |
---|
| 688 | (99.9)*10, (99.9)*10, \ |
---|
| 689 | 0 \ |
---|
| 690 | } |
---|
| 691 | |
---|
| 692 | |
---|
| 693 | struct aim_icbmparameters { |
---|
| 694 | guint16 maxchan; |
---|
| 695 | guint32 flags; /* AIM_IMPARAM_FLAG_ */ |
---|
| 696 | guint16 maxmsglen; /* message size that you will accept */ |
---|
| 697 | guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */ |
---|
| 698 | guint16 maxrecverwarn; |
---|
| 699 | guint32 minmsginterval; /* in milliseconds? */ |
---|
| 700 | }; |
---|
| 701 | |
---|
| 702 | int aim_reqicbmparams(aim_session_t *sess); |
---|
| 703 | int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params); |
---|
| 704 | |
---|
| 705 | /* auth.c */ |
---|
| 706 | int aim_sendcookie(aim_session_t *, aim_conn_t *, const guint8 *); |
---|
| 707 | |
---|
| 708 | int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw); |
---|
| 709 | int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn); |
---|
| 710 | int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, guint16 info); |
---|
| 711 | int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail); |
---|
| 712 | int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick); |
---|
| 713 | |
---|
| 714 | /* These apply to exchanges as well. */ |
---|
| 715 | #define AIM_CHATROOM_FLAG_EVILABLE 0x0001 |
---|
| 716 | #define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002 |
---|
| 717 | #define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004 |
---|
| 718 | #define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008 |
---|
| 719 | |
---|
| 720 | struct aim_chat_exchangeinfo { |
---|
| 721 | guint16 number; |
---|
| 722 | guint16 flags; |
---|
| 723 | char *name; |
---|
| 724 | char *charset1; |
---|
| 725 | char *lang1; |
---|
| 726 | char *charset2; |
---|
| 727 | char *lang2; |
---|
| 728 | }; |
---|
| 729 | |
---|
[73cf7fd] | 730 | #define AIM_CHATFLAGS_NOREFLECT 0x0001 |
---|
| 731 | #define AIM_CHATFLAGS_AWAY 0x0002 |
---|
| 732 | #define AIM_CHATFLAGS_UNICODE 0x0004 |
---|
| 733 | #define AIM_CHATFLAGS_ISO_8859_1 0x0008 |
---|
| 734 | |
---|
[b7d3cc34] | 735 | int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen); |
---|
| 736 | int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance); |
---|
| 737 | int aim_chat_attachname(aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance); |
---|
| 738 | char *aim_chat_getname(aim_conn_t *conn); |
---|
| 739 | aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name); |
---|
| 740 | |
---|
| 741 | int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn); |
---|
| 742 | |
---|
| 743 | int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance); |
---|
| 744 | |
---|
| 745 | int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange); |
---|
| 746 | int aim_chat_leaveroom(aim_session_t *sess, const char *name); |
---|
| 747 | |
---|
| 748 | /* aim_util.c */ |
---|
| 749 | /* |
---|
| 750 | * These are really ugly. You'd think this was LISP. I wish it was. |
---|
| 751 | * |
---|
| 752 | * XXX With the advent of bstream's, these should be removed to enforce |
---|
| 753 | * their use. |
---|
| 754 | * |
---|
| 755 | */ |
---|
| 756 | #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) |
---|
| 757 | #define aimutil_get8(buf) ((*(buf))&0xff) |
---|
| 758 | #define aimutil_put16(buf, data) ( \ |
---|
| 759 | (*(buf) = (u_char)((data)>>8)&0xff), \ |
---|
| 760 | (*((buf)+1) = (u_char)(data)&0xff), \ |
---|
| 761 | 2) |
---|
| 762 | #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
---|
| 763 | #define aimutil_put32(buf, data) ( \ |
---|
| 764 | (*((buf)) = (u_char)((data)>>24)&0xff), \ |
---|
| 765 | (*((buf)+1) = (u_char)((data)>>16)&0xff), \ |
---|
| 766 | (*((buf)+2) = (u_char)((data)>>8)&0xff), \ |
---|
| 767 | (*((buf)+3) = (u_char)(data)&0xff), \ |
---|
| 768 | 4) |
---|
| 769 | #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ |
---|
| 770 | (((*((buf)+1))<<16)&0x00ff0000) + \ |
---|
| 771 | (((*((buf)+2))<< 8)&0x0000ff00) + \ |
---|
| 772 | (((*((buf)+3) )&0x000000ff))) |
---|
| 773 | |
---|
| 774 | /* Little-endian versions (damn ICQ) */ |
---|
| 775 | #define aimutil_putle8(buf, data) ( \ |
---|
| 776 | (*(buf) = (unsigned char)(data) & 0xff), \ |
---|
| 777 | 1) |
---|
| 778 | #define aimutil_getle8(buf) ( \ |
---|
| 779 | (*(buf)) & 0xff \ |
---|
| 780 | ) |
---|
| 781 | #define aimutil_putle16(buf, data) ( \ |
---|
| 782 | (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \ |
---|
| 783 | (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \ |
---|
| 784 | 2) |
---|
| 785 | #define aimutil_getle16(buf) ( \ |
---|
| 786 | (((*((buf)+0)) << 0) & 0x00ff) + \ |
---|
| 787 | (((*((buf)+1)) << 8) & 0xff00) \ |
---|
| 788 | ) |
---|
| 789 | #define aimutil_putle32(buf, data) ( \ |
---|
| 790 | (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \ |
---|
| 791 | (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \ |
---|
| 792 | (*((buf)+2) = (unsigned char)((data) >> 16) & 0xff), \ |
---|
| 793 | (*((buf)+3) = (unsigned char)((data) >> 24) & 0xff), \ |
---|
| 794 | 4) |
---|
| 795 | #define aimutil_getle32(buf) ( \ |
---|
| 796 | (((*((buf)+0)) << 0) & 0x000000ff) + \ |
---|
| 797 | (((*((buf)+1)) << 8) & 0x0000ff00) + \ |
---|
| 798 | (((*((buf)+2)) << 16) & 0x00ff0000) + \ |
---|
| 799 | (((*((buf)+3)) << 24) & 0xff000000)) |
---|
| 800 | |
---|
| 801 | |
---|
| 802 | int aimutil_putstr(u_char *, const char *, int); |
---|
| 803 | int aimutil_tokslen(char *toSearch, int index, char dl); |
---|
| 804 | int aimutil_itemcnt(char *toSearch, char dl); |
---|
| 805 | char *aimutil_itemidx(char *toSearch, int index, char dl); |
---|
| 806 | int aim_sncmp(const char *a, const char *b); |
---|
| 807 | |
---|
| 808 | #include <aim_internal.h> |
---|
| 809 | |
---|
| 810 | /* |
---|
| 811 | * SNAC Families. |
---|
| 812 | */ |
---|
| 813 | #define AIM_CB_FAM_ACK 0x0000 |
---|
| 814 | #define AIM_CB_FAM_GEN 0x0001 |
---|
| 815 | #define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */ |
---|
| 816 | |
---|
| 817 | /* |
---|
| 818 | * SNAC Family: Ack. |
---|
| 819 | * |
---|
| 820 | * Not really a family, but treating it as one really |
---|
| 821 | * helps it fit into the libfaim callback structure better. |
---|
| 822 | * |
---|
| 823 | */ |
---|
| 824 | #define AIM_CB_ACK_ACK 0x0001 |
---|
| 825 | |
---|
| 826 | /* |
---|
| 827 | * SNAC Family: General. |
---|
| 828 | */ |
---|
| 829 | #define AIM_CB_GEN_ERROR 0x0001 |
---|
| 830 | #define AIM_CB_GEN_CLIENTREADY 0x0002 |
---|
| 831 | #define AIM_CB_GEN_SERVERREADY 0x0003 |
---|
| 832 | #define AIM_CB_GEN_SERVICEREQ 0x0004 |
---|
| 833 | #define AIM_CB_GEN_REDIRECT 0x0005 |
---|
| 834 | #define AIM_CB_GEN_RATEINFOREQ 0x0006 |
---|
| 835 | #define AIM_CB_GEN_RATEINFO 0x0007 |
---|
| 836 | #define AIM_CB_GEN_RATEINFOACK 0x0008 |
---|
| 837 | #define AIM_CB_GEN_RATECHANGE 0x000a |
---|
| 838 | #define AIM_CB_GEN_SERVERPAUSE 0x000b |
---|
| 839 | #define AIM_CB_GEN_SERVERRESUME 0x000d |
---|
| 840 | #define AIM_CB_GEN_REQSELFINFO 0x000e |
---|
| 841 | #define AIM_CB_GEN_SELFINFO 0x000f |
---|
| 842 | #define AIM_CB_GEN_EVIL 0x0010 |
---|
| 843 | #define AIM_CB_GEN_SETIDLE 0x0011 |
---|
| 844 | #define AIM_CB_GEN_MIGRATIONREQ 0x0012 |
---|
| 845 | #define AIM_CB_GEN_MOTD 0x0013 |
---|
| 846 | #define AIM_CB_GEN_SETPRIVFLAGS 0x0014 |
---|
| 847 | #define AIM_CB_GEN_WELLKNOWNURL 0x0015 |
---|
| 848 | #define AIM_CB_GEN_NOP 0x0016 |
---|
| 849 | #define AIM_CB_GEN_DEFAULT 0xffff |
---|
| 850 | |
---|
| 851 | /* |
---|
| 852 | * SNAC Family: Advertisement Services |
---|
| 853 | */ |
---|
| 854 | #define AIM_CB_ADS_ERROR 0x0001 |
---|
| 855 | #define AIM_CB_ADS_DEFAULT 0xffff |
---|
| 856 | |
---|
| 857 | /* |
---|
| 858 | * OFT Services |
---|
| 859 | * |
---|
| 860 | * See non-SNAC note below. |
---|
| 861 | */ |
---|
| 862 | #define AIM_CB_OFT_DIRECTIMCONNECTREQ 0x0001/* connect request -- actually an OSCAR CAP*/ |
---|
| 863 | #define AIM_CB_OFT_DIRECTIMINCOMING 0x0002 |
---|
| 864 | #define AIM_CB_OFT_DIRECTIMDISCONNECT 0x0003 |
---|
| 865 | #define AIM_CB_OFT_DIRECTIMTYPING 0x0004 |
---|
| 866 | #define AIM_CB_OFT_DIRECTIMINITIATE 0x0005 |
---|
| 867 | |
---|
| 868 | #define AIM_CB_OFT_GETFILECONNECTREQ 0x0006 /* connect request -- actually an OSCAR CAP*/ |
---|
| 869 | #define AIM_CB_OFT_GETFILELISTINGREQ 0x0007 /* OFT listing.txt request */ |
---|
| 870 | #define AIM_CB_OFT_GETFILEFILEREQ 0x0008 /* received file request */ |
---|
| 871 | #define AIM_CB_OFT_GETFILEFILESEND 0x0009 /* received file request confirm -- send data */ |
---|
| 872 | #define AIM_CB_OFT_GETFILECOMPLETE 0x000a /* received file send complete*/ |
---|
| 873 | #define AIM_CB_OFT_GETFILEINITIATE 0x000b /* request for file get acknowledge */ |
---|
| 874 | #define AIM_CB_OFT_GETFILEDISCONNECT 0x000c /* OFT connection disconnected.*/ |
---|
| 875 | #define AIM_CB_OFT_GETFILELISTING 0x000d /* OFT listing.txt received.*/ |
---|
| 876 | #define AIM_CB_OFT_GETFILERECEIVE 0x000e /* OFT file incoming.*/ |
---|
| 877 | #define AIM_CB_OFT_GETFILELISTINGRXCONFIRM 0x000f |
---|
| 878 | #define AIM_CB_OFT_GETFILESTATE4 0x0010 |
---|
| 879 | |
---|
| 880 | #define AIM_CB_OFT_SENDFILEDISCONNECT 0x0020 /* OFT connection disconnected.*/ |
---|
| 881 | |
---|
| 882 | |
---|
| 883 | |
---|
| 884 | /* |
---|
| 885 | * SNAC Family: Internal Messages |
---|
| 886 | * |
---|
| 887 | * This isn't truely a SNAC family either, but using |
---|
| 888 | * these, we can integrated non-SNAC services into |
---|
| 889 | * the SNAC-centered libfaim callback structure. |
---|
| 890 | * |
---|
| 891 | */ |
---|
| 892 | #define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001 |
---|
| 893 | #define AIM_CB_SPECIAL_AUTHOTHER 0x0002 |
---|
| 894 | #define AIM_CB_SPECIAL_CONNERR 0x0003 |
---|
| 895 | #define AIM_CB_SPECIAL_CONNCOMPLETE 0x0004 |
---|
| 896 | #define AIM_CB_SPECIAL_FLAPVER 0x0005 |
---|
| 897 | #define AIM_CB_SPECIAL_CONNINITDONE 0x0006 |
---|
| 898 | #define AIM_CB_SPECIAL_IMAGETRANSFER 0x007 |
---|
| 899 | #define AIM_CB_SPECIAL_UNKNOWN 0xffff |
---|
| 900 | #define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN |
---|
| 901 | |
---|
| 902 | #endif /* __AIM_H__ */ |
---|