2 * -----------------------------------------------------------
3 * ProtoFAIM: v1.xx.xxplxx
4 * -----------------------------------------------------------
6 * This is ProtoFAIM v1.xx.xxplxx!!! Its nearly completely
7 * different than that ugly thing called v0. This app is
8 * compatible with the latest version of the libfaim library.
11 * ProtoFAIM should only be used for two things...
12 * 1) Testing the libfaim backend.
13 * 2) For reference on the libfaim API when developing clients.
15 * Its very ugly. Probably always will be. Nothing is more
16 * ugly than the backend itself, however.
18 * -----------------------------------------------------------
20 * I'm releasing this code and all it's associated linkage
21 * under the GNU General Public License. For more information,
22 * please refer to http://www.fsf.org. For any questions,
23 * please contact me at the address below.
26 * (c) 1998 Adam Fritzler, PST, afritz@iname.com
28 * The password algorithms
29 * (c) 1998 Brock Wilcox, awwaiid@iname.com
31 * THERE IS NO CODE FROM AOL'S AIM IN THIS CODE, NOR
32 * WAS THERE ANY DISASSEMBLAGE TO DEFINE PROTOCOL. All
33 * information was gained through painstakingly comparing
34 * TCP dumps while the AIM Java client was running. Nothing
35 * more than that, except for a lot of experimenting.
37 * -----------------------------------------------------------
48 static char *dprintf_ctime(void)
50 static char retbuf[64];
55 gettimeofday(&tv, &tz);
56 lt = localtime((time_t *)&tv.tv_sec);
57 strftime(retbuf, 64, "%a %b %e %H:%M:%S %Z %Y", lt);
61 #define dprintf(x) { \
62 printf("%s %s: " x, dprintf_ctime(), "faimtest"); \
65 #define dvprintf(x, y...) { \
66 printf("%s %s: " x, dprintf_ctime(), "faimtest", y); \
69 #define dinlineprintf(x) { \
73 #define dvinlineprintf(x, y...) { \
77 #define dperror(x) dvprintf("%s: %s\n", x, strerror(errno));
79 int faimtest_parse_oncoming(struct aim_session_t *, struct command_rx_struct *, ...);
80 int faimtest_parse_offgoing(struct aim_session_t *, struct command_rx_struct *, ...);
81 int faimtest_parse_login_phase3d_f(struct aim_session_t *, struct command_rx_struct *, ...);
82 int faimtest_parse_authresp(struct aim_session_t *, struct command_rx_struct *, ...);
83 int faimtest_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *command, ...);
84 int faimtest_parse_userinfo(struct aim_session_t *, struct command_rx_struct *command, ...);
85 int faimtest_handleredirect(struct aim_session_t *, struct command_rx_struct *command, ...);
86 int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *command, ...);
87 int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...);
88 int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...);
89 int faimtest_hostversions(struct aim_session_t *sess, struct command_rx_struct *command, ...);
90 int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...);
91 int faimtest_parse_msgack(struct aim_session_t *, struct command_rx_struct *command, ...);
92 int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...);
93 int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...);
94 int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...);
95 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...);
96 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
97 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...);
98 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...);
99 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
100 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
102 int faimtest_directim_request(struct aim_session_t *sess, struct command_rx_struct *command, ...);
103 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
104 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
105 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...);
106 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
107 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...);
110 int faimtest_getfile_filereq(struct aim_session_t *sess, struct command_rx_struct *command, ...);
111 int faimtest_getfile_filesend(struct aim_session_t *sess, struct command_rx_struct *command, ...);
112 int faimtest_getfile_complete(struct aim_session_t *sess, struct command_rx_struct *command, ...);
113 int faimtest_getfile_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
114 int faimtest_getfile_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
115 int faimtest_getfile_listing(struct aim_session_t *sess, struct command_rx_struct *command, ...);
116 int faimtest_getfile_listingreq(struct aim_session_t *sess, struct command_rx_struct *command, ...);
117 int faimtest_getfile_recieve(struct aim_session_t *sess, struct command_rx_struct *command, ...);
120 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...);
121 int faimtest_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...);
122 int faimtest_parse_searcherror(struct aim_session_t *sess, struct command_rx_struct *command, ...);
123 int faimtest_parse_searchreply(struct aim_session_t *sess, struct command_rx_struct *command, ...);
124 int faimtest_parse_msgerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
125 int faimtest_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...);
126 int faimtest_parse_locerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
127 int faimtest_parse_genericerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
129 static char *msgerrreasons[] = {
135 "Service unavailable",
136 "Service not defined",
138 "Not supported by host",
139 "Not supported by client",
144 "Busted SNAC payload",
145 "Insufficient rights",
146 "In local permit/deny",
148 "Too evil (receiver)",
149 "User temporarily unavailable",
155 static int msgerrreasonslen = 25;
157 static char *screenname,*password,*server=NULL;
158 static char *ohcaptainmycaptain = NULL;
159 static int connected = 0;
166 int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...)
169 dvprintf("aim: minimum report interval: %d (seconds?)\n", aimutil_get16(command->data+10));
171 dprintf("aim: NULL minimum report interval!\n");
175 int faimtest_flapversion(struct aim_session_t *sess, struct command_rx_struct *command, ...)
178 dvprintf("faimtest: using FLAP version %u\n", aimutil_get32(command->data));
182 * This is an alternate location for starting the login process.
184 /* XXX should do more checking to make sure its really the right AUTH conn */
185 if (command->conn->type == AIM_CONN_TYPE_AUTH) {
186 /* do NOT send a connack/flapversion, request_login will send it if needed */
187 aim_request_login(sess, command->conn, screenname);
188 dprintf("faimtest: login request sent\n");
196 * This is a frivilous callback. You don't need it. I only used it for
197 * debugging non-blocking connects.
199 * If packets are sent to a conn before its fully connected, they
200 * will be queued and then transmitted when the connection completes.
203 int faimtest_conncomplete(struct aim_session_t *sess, struct command_rx_struct *command, ...)
206 struct aim_conn_t *conn;
208 va_start(ap, command);
209 conn = va_arg(ap, struct aim_conn_t *);
213 dvprintf("faimtest: connection on %d completed\n", conn->fd);
220 * This is really all thats needed to link against libfaim on win32.
222 * Note that this particular version of faimtest has never been tested
223 * on win32, but I'm fairly sure it should.
227 WORD wVersionRequested;
230 wVersionRequested = MAKEWORD(2,2);
231 return WSAStartup(wVersionRequested, &wsaData);
235 int main(int argc, char **argv)
237 struct aim_session_t aimsess;
238 struct aim_conn_t *authconn = NULL, *waitingconn = NULL;
240 char *proxy, *proxyusername, *proxypass;
244 screenname = getenv("SCREENNAME");
245 password = getenv("PASSWORD");
246 server = getenv("AUTHSERVER");
247 proxy = getenv("SOCKSPROXY");
248 proxyusername = getenv("SOCKSNAME");
249 proxypass = getenv("SOCKSPASS");
252 listingpath = getenv("LISTINGPATH");
255 while ((i = getopt(argc, argv, "u:p:a:U:P:A:l:c:h")) != EOF) {
257 case 'u': screenname = optarg; break;
258 case 'p': password = optarg; break;
259 case 'a': server = optarg; break;
260 case 'U': proxyusername = optarg; break;
261 case 'P': proxypass = optarg; break;
262 case 'A': proxy = optarg; break;
263 case 'l': listingpath = optarg; break;
264 case 'c': ohcaptainmycaptain = optarg; break;
268 printf("faimtest\n");
269 printf(" Options: \n");
270 printf(" -u name Screen name ($SCREENNAME)\n");
271 printf(" -p passwd Password ($PASSWORD)\n");
272 printf(" -a host:port Authorizer ($AUTHSERVER)\n");
273 printf(" -U name Proxy user name ($SOCKSPROXY)\n");
274 printf(" -P passwd Proxy password ($SOCKSNAME)\n");
275 printf(" -A host:port Proxy host ($SOCKSPASS)\n");
276 printf(" -l path Path to listing file ($LISTINGPATH)\n");
277 printf(" -c name Screen name of owner\n");
282 if (!screenname || !password)
286 if (initwsa() != 0) {
287 dprintf("faimtest: could not initialize windows sockets\n");
292 /* Pass zero as flags if you want blocking connects */
293 aim_session_init(&aimsess, AIM_SESS_FLAGS_NONBLOCKCONNECT);
298 if(!(listingname = (char *)calloc(1, strlen(listingpath)+strlen("/listing.txt")))) {
299 dperror("listingname calloc");
302 sprintf(listingname, "%s/listing.txt", listingpath);
303 if( (listingfile = fopen(listingname, "r")) == NULL) {
304 dvprintf("Couldn't open %s... bombing.\n", listingname);
313 aim_setupproxy(&aimsess, proxy, proxyusername, proxypass);
315 authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER);
317 if (authconn == NULL) {
318 dprintf("faimtest: internal connection error while in aim_login. bailing out.\n");
320 } else if (authconn->fd == -1) {
321 if (authconn->status & AIM_CONN_STATUS_RESOLVERR) {
322 dprintf("faimtest: could not resolve authorizer name\n");
323 } else if (authconn->status & AIM_CONN_STATUS_CONNERR) {
324 dprintf("faimtest: could not connect to authorizer\n");
326 aim_conn_kill(&aimsess, &authconn);
330 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
331 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
332 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
333 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
335 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT, faimtest_debugconn_connect, 0);
337 /* If the connection is in progress, this will just be queued */
338 aim_request_login(&aimsess, authconn, screenname);
339 dprintf("faimtest: login request sent\n");
342 waitingconn = aim_select(&aimsess, NULL, &selstat);
346 keepgoing = 0; /* fall through and hit the aim_logoff() */
349 case 0: /* no events pending */
352 case 1: /* outgoing data pending */
353 aim_tx_flushqueue(&aimsess);
356 case 2: /* incoming data pending */
357 if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
358 if (aim_handlerendconnect(&aimsess, waitingconn) < 0) {
359 dprintf("connection error (rend out)\n");
360 aim_conn_kill(&aimsess, &waitingconn);
365 if (aim_get_command(&aimsess, waitingconn) >= 0) {
366 aim_rxdispatch(&aimsess);
368 dvprintf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype);
369 /* we should have callbacks for all these, else the library will do the conn_kill for us. */
370 if(waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) {
371 dprintf("connection error: rendezvous connection. you forgot register a disconnect callback, right?\n");
372 aim_conn_kill(&aimsess, &waitingconn);
374 aim_conn_kill(&aimsess, &waitingconn);
375 if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) {
376 dprintf("major connection error\n");
389 dprintf("AIM just decided we didn't need to be here anymore, closing up...\n");
391 /* close up all connections, dead or no */
392 aim_logoff(&aimsess);
398 int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
401 switch(command->conn->type) {
402 case AIM_CONN_TYPE_BOS: {
403 /* this is the new buddy list */
405 /* this is the new profile */
408 /* Caution: Buddy1 and Buddy2 are real people! (who I don't know) */
409 snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&%s&", ohcaptainmycaptain?ohcaptainmycaptain:"blah");
410 snprintf(profile, sizeof(profile), "Hello.<br>My captain is %s. They were dumb enough to leave this message in their client, or they are using faimtest. Shame on them.", ohcaptainmycaptain);
412 aim_bos_ackrateresp(sess, command->conn); /* ack rate info response */
413 aim_bos_reqpersonalinfo(sess, command->conn);
414 aim_bos_reqlocaterights(sess, command->conn);
415 aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS);
416 aim_bos_reqbuddyrights(sess, command->conn);
418 /* send the buddy list and profile (required, even if empty) */
419 aim_bos_setbuddylist(sess, command->conn, buddies);
421 /* dont really know what this does */
422 aim_addicbmparam(sess, command->conn);
423 aim_bos_reqicbmparaminfo(sess, command->conn);
425 aim_bos_reqrights(sess, command->conn);
426 /* set group permissions -- all user classes */
427 aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS);
428 aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE|AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
434 dvprintf("faimtest: got rate response for unhandled connection type %04x\n", command->conn->type);
441 int faimtest_hostversions(struct aim_session_t *sess, struct command_rx_struct *command, ...)
444 unsigned char *versions;
447 va_start(ap, command);
448 vercount = va_arg(ap, int); /* number of family/version pairs */
449 versions = va_arg(ap, unsigned char *);
452 dprintf("faimtest: SNAC versions supported by this host: ");
453 for (i = 0; i < vercount*4; i += 4)
454 dvinlineprintf("0x%04x:0x%04x ",
455 aimutil_get16(versions+i), /* SNAC family */
456 aimutil_get16(versions+i+2) /* Version number */);
462 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
465 unsigned short *families;
468 va_start(ap, command);
469 famcount = va_arg(ap, int);
470 families = va_arg(ap, unsigned short *);
473 dvprintf("faimtest: SNAC families supported by this host (type %d): ", command->conn->type);
474 for (i = 0; i < famcount; i++)
475 dvinlineprintf("0x%04x ", families[i]);
478 switch (command->conn->type) {
479 case AIM_CONN_TYPE_BOS:
481 aim_setversions(sess, command->conn);
482 aim_bos_reqrate(sess, command->conn); /* request rate info */
484 dprintf("faimtest: done with BOS ServerReady\n");
487 case AIM_CONN_TYPE_CHATNAV:
488 dprintf("faimtest: chatnav: got server ready\n");
489 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
490 aim_bos_reqrate(sess, command->conn);
491 aim_bos_ackrateresp(sess, command->conn);
492 aim_chatnav_clientready(sess, command->conn);
493 aim_chatnav_reqrights(sess, command->conn);
497 case AIM_CONN_TYPE_CHAT:
498 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
499 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
500 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
501 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
502 aim_bos_reqrate(sess, command->conn);
503 aim_bos_ackrateresp(sess, command->conn);
504 aim_chat_clientready(sess, command->conn);
507 case AIM_CONN_TYPE_RENDEZVOUS: /* empty */
511 dprintf("faimtest: unknown connection type on Server Ready\n");
517 int faimtest_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...)
520 unsigned short maxbuddies, maxwatchers;
522 va_start(ap, command);
523 maxbuddies = va_arg(ap, int);
524 maxwatchers = va_arg(ap, int);
527 dvprintf("faimtest: buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers);
532 int faimtest_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...)
534 unsigned short maxpermits, maxdenies;
537 va_start(ap, command);
538 maxpermits = va_arg(ap, int);
539 maxdenies = va_arg(ap, int);
542 dvprintf("faimtest: BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies);
544 aim_bos_clientready(sess, command->conn);
546 dprintf("faimtest: officially connected to BOS.\n");
551 int faimtest_parse_unknown(struct aim_session_t *sess, struct command_rx_struct *command, ...)
555 if (!sess || !command)
558 dprintf("\nRecieved unknown packet:");
559 for (i = 0; i < command->commandlen; i++) {
561 dinlineprintf("\n\t");
562 dvinlineprintf("0x%2x ", command->data[i]);
564 dinlineprintf("\n\n");
572 This, of course, handles Service Redirects from OSCAR.
574 Should get passed in the following:
575 struct command_rx_struct *command
578 the destination service ID
580 the IP address of the service's server
584 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
589 unsigned char *cookie;
591 va_start(ap, command);
592 serviceid = va_arg(ap, int);
593 ip = va_arg(ap, char *);
594 cookie = va_arg(ap, unsigned char *);
598 case 0x0007: /* Authorizer */
600 struct aim_conn_t *tstconn;
601 /* Open a connection to the Auth */
602 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
603 if ((tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) {
604 dprintf("faimtest: unable to reconnect with authorizer\n");
606 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
607 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
608 /* Send the cookie to the Auth */
609 aim_auth_sendcookie(sess, tstconn, cookie);
614 case 0x000d: /* ChatNav */
616 struct aim_conn_t *tstconn = NULL;
617 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
618 if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) {
619 dprintf("faimtest: unable to connect to chatnav server\n");
620 if (tstconn) aim_conn_kill(sess, &tstconn);
624 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, faimtest_parse_unknown, 0);
625 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, faimtest_parse_unknown, 0);
627 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
628 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
629 aim_auth_sendcookie(sess, tstconn, cookie);
630 dprintf("\achatnav: connected\n");
633 case 0x000e: /* Chat */
635 char *roomname = NULL;
637 struct aim_conn_t *tstconn = NULL;
639 roomname = va_arg(ap, char *);
640 exchange = va_arg(ap, int);
642 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
643 if ( (tstconn==NULL) || (tstconn->status & AIM_CONN_STATUS_RESOLVERR))
645 dprintf("faimtest: unable to connect to chat server\n");
646 if (tstconn) aim_conn_kill(sess, &tstconn);
649 dvprintf("faimtest: chat: connected to %s on exchange %d\n", roomname, exchange);
652 * We must do this to attach the stored name to the connection!
654 aim_chat_attachname(tstconn, roomname);
656 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
657 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
658 aim_auth_sendcookie(sess, tstconn, cookie);
662 dvprintf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
671 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
674 struct aim_conn_t *bosconn = NULL;
675 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL;
676 unsigned char *cookie = NULL;
677 int errorcode = 0, regstatus = 0;
678 int latestbuild = 0, latestbetabuild = 0;
679 char *latestrelease = NULL, *latestbeta = NULL;
680 char *latestreleaseurl = NULL, *latestbetaurl = NULL;
681 char *latestreleaseinfo = NULL, *latestbetainfo = NULL;
683 va_start(ap, command);
684 sn = va_arg(ap, char *);
685 errorcode = va_arg(ap, int);
686 errurl = va_arg(ap, char *);
687 regstatus = va_arg(ap, int);
688 email = va_arg(ap, char *);
689 bosip = va_arg(ap, char *);
690 cookie = va_arg(ap, unsigned char *);
692 latestrelease = va_arg(ap, char *);
693 latestbuild = va_arg(ap, int);
694 latestreleaseurl = va_arg(ap, char *);
695 latestreleaseinfo = va_arg(ap, char *);
697 latestbeta = va_arg(ap, char *);
698 latestbetabuild = va_arg(ap, int);
699 latestbetaurl = va_arg(ap, char *);
700 latestbetainfo = va_arg(ap, char *);
704 dvprintf("Screen name: %s\n", sn);
709 if (errorcode || !bosip || !cookie) {
710 dvprintf("Login Error Code 0x%04x\n", errorcode);
711 dvprintf("Error URL: %s\n", errurl);
712 aim_conn_kill(sess, &command->conn);
716 dvprintf("Reg status: %2d\n", regstatus);
717 dvprintf("Email: %s\n", email);
718 dvprintf("BOS IP: %s\n", bosip);
721 dvprintf("Latest beta version: %s, build %d, at %s (more info at %s)\n", latestbeta, latestbetabuild, latestbetaurl, latestbetainfo);
724 dvprintf("Latest released version: %s, build %d, at %s (more info at %s)\n", latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo);
726 dprintf("Closing auth connection...\n");
727 aim_conn_kill(sess, &command->conn);
728 if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip))) {
729 dprintf("faimtest: could not connect to BOS: internal error\n");
731 } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) {
732 dprintf("faimtest: could not connect to BOS\n");
733 aim_conn_kill(sess, &bosconn);
737 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
738 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, faimtest_bosrights, 0);
739 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */
740 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
741 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0);
742 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
743 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
744 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
745 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, faimtest_reportinterval, 0);
746 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, faimtest_parse_buddyrights, 0);
747 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
748 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
749 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
750 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_locerr, 0);
751 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
752 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0);
753 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, faimtest_parse_evilnotify, 0);
754 aim_conn_addhandler(sess, bosconn, 0x000a, 0x0001, faimtest_parse_searcherror, 0);
755 aim_conn_addhandler(sess, bosconn, 0x000a, 0x0003, faimtest_parse_searchreply, 0);
756 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_msgerr, 0);
757 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
758 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0);
760 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, faimtest_parse_unknown, 0);
761 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, faimtest_parse_unknown, 0);
762 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
764 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, faimtest_parse_genericerr, 0);
765 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, faimtest_parse_genericerr, 0);
766 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, faimtest_parse_genericerr, 0);
768 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0);
771 aim_auth_sendcookie(sess, bosconn, cookie);
776 static void printuserflags(unsigned short flags)
778 if (flags & AIM_FLAG_UNCONFIRMED)
779 dinlineprintf("UNCONFIRMED ");
780 if (flags & AIM_FLAG_ADMINISTRATOR)
781 dinlineprintf("ADMINISTRATOR ");
782 if (flags & AIM_FLAG_AOL)
783 dinlineprintf("AOL ");
784 if (flags & AIM_FLAG_OSCAR_PAY)
785 dinlineprintf("OSCAR_PAY ");
786 if (flags & AIM_FLAG_FREE)
787 dinlineprintf("FREE ");
788 if (flags & AIM_FLAG_AWAY)
789 dinlineprintf("AWAY ");
790 if (flags & AIM_FLAG_UNKNOWN40)
791 dinlineprintf("ICQ? ");
792 if (flags & AIM_FLAG_UNKNOWN80)
793 dinlineprintf("UNKNOWN80 ");
797 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
799 struct aim_userinfo_s *userinfo;
800 char *prof_encoding = NULL;
802 unsigned short inforeq = 0;
805 va_start(ap, command);
806 userinfo = va_arg(ap, struct aim_userinfo_s *);
807 prof_encoding = va_arg(ap, char *);
808 prof = va_arg(ap, char *);
809 inforeq = va_arg(ap, int);
812 dvprintf("faimtest: userinfo: sn: %s\n", userinfo->sn);
813 dvprintf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
814 dvprintf("faimtest: userinfo: flags: 0x%04x = ", userinfo->flags);
815 printuserflags(userinfo->flags);
818 dvprintf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
819 dvprintf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
820 dvprintf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
822 if (inforeq == AIM_GETINFO_GENERALINFO) {
823 dvprintf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
824 dvprintf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
825 } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) {
826 dvprintf("faimtest: userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
827 dvprintf("faimtest: userinfo: awaymsg: %s\n", prof ? prof : "[none]");
829 dprintf("faimtest: userinfo: unknown info request\n");
835 * The user-level Incoming ICBM callback.
838 * struct command_rx_struct * command if you feel like doing it yourself
839 * char * srcsn the source name
841 * int warnlevel warning/evil level
843 * ulong membersince time_t of date of signup
844 * ulong onsince time_t of date of singon
845 * int idletime min (sec?) idle
846 * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK}
849 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
854 va_start(ap, command);
855 channel = va_arg(ap, int);
858 * Channel 1: Standard Message
861 struct aim_userinfo_s *userinfo;
865 unsigned short flag1, flag2;
867 userinfo = va_arg(ap, struct aim_userinfo_s *);
868 msg = va_arg(ap, char *);
869 icbmflags = va_arg(ap, u_int);
870 flag1 = va_arg(ap, int);
871 flag2 = va_arg(ap, int);
874 dvprintf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
875 dvprintf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
876 dvprintf("faimtest: icbm: flags = 0x%04x = ", userinfo->flags);
877 printuserflags(userinfo->flags);
880 dvprintf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
881 dvprintf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
882 dvprintf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
883 dvprintf("faimtest: icbm: capabilities = 0x%04x\n", userinfo->capabilities);
885 dprintf("faimtest: icbm: icbmflags = ");
886 if (icbmflags & AIM_IMFLAGS_AWAY)
887 dinlineprintf("away ");
888 if (icbmflags & AIM_IMFLAGS_ACK)
889 dinlineprintf("ackrequest ");
892 dvprintf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
894 dvprintf("faimtest: icbm: message: %s\n", msg);
899 while (msg[i] == '<') {
901 while (msg[i] != '>')
908 dvprintf("tmpstr = %s\n", tmpstr);
910 if ( (strlen(tmpstr) >= 10) &&
911 (!strncmp(tmpstr, "disconnect", 10)) ) {
912 if (ohcaptainmycaptain)
913 aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "ta ta...");
915 } else if (strstr(tmpstr, "goodday")) {
916 dprintf("faimtest: icbm: sending response\n");
917 aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");
918 } else if (strstr(tmpstr, "warnme")) {
919 dprintf("faimtest: icbm: sending non-anon warning\n");
920 aim_send_warning(sess, command->conn, userinfo->sn, 0);
921 } else if (strstr(tmpstr, "anonwarn")) {
922 dprintf("faimtest: icbm: sending anon warning\n");
923 aim_send_warning(sess, command->conn, userinfo->sn, AIM_WARN_ANON);
924 } else if (strstr(tmpstr, "setdirectoryinfo")) {
925 dprintf("faimtest: icbm: sending backwards profile data\n");
926 aim_setdirectoryinfo(sess, command->conn, "tsrif", "elddim", "tsal", "nediam", "emankcin", "teerts", "ytic", "etats", "piz", 0, 1);
927 } else if (strstr(tmpstr, "setinterests")) {
928 dprintf("faimtest: icbm: setting fun interests\n");
929 aim_setuserinterests(sess, command->conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1);
930 } else if (!strncmp(tmpstr, "getfile", 7)) {
931 if (!ohcaptainmycaptain) {
932 aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!");
934 struct aim_conn_t *newconn;
935 newconn = aim_getfile_initiate(sess, command->conn, (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8);
936 dvprintf("faimtest: getting file listing from %s\n", (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8);
937 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE, faimtest_getfile_initiate,0);
939 } else if (!strncmp(tmpstr, "open chatnav", 12)) {
940 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
941 } else if (!strncmp(tmpstr, "create", 6)) {
942 aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004);
943 } else if (!strncmp(tmpstr, "close chatnav", 13)) {
944 struct aim_conn_t *chatnavconn;
945 chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
946 aim_conn_kill(sess, &chatnavconn);
947 } else if (!strncmp(tmpstr, "join", 4)) {
948 aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
949 } else if (!strncmp(tmpstr, "leave", 5))
950 aim_chat_leaveroom(sess, "worlddomination");
951 else if (!strncmp(tmpstr, "getinfo", 7)) {
952 aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO);
953 aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE);
954 } else if (!strncmp(tmpstr, "open directim", 13)) {
955 struct aim_conn_t *newconn;
956 newconn = aim_directim_initiate(sess, command->conn, NULL, userinfo->sn);
957 } else if(!(strncmp(tmpstr, "lookup", 6))) {
958 aim_usersearch_address(sess, command->conn, tmpstr+7);
959 } else if (!strncmp(tmpstr, "reqsendmsg", 10)) {
960 aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "sendmsg 7900");
961 } else if (!strncmp(tmpstr, "sendmsg", 7)) {
968 newbuf = malloc(i+1);
969 for (z = 0; z < i; z++) {
970 newbuf[z] = (z % 10)+0x30;
973 aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf);
977 dprintf("unknown command.\n");
978 aim_add_buddy(sess, command->conn, userinfo->sn);
984 * Channel 2: Rendevous Request
986 else if (channel == 2) {
987 struct aim_userinfo_s *userinfo;
988 unsigned short reqclass;
990 reqclass = va_arg(ap, int);
992 case AIM_CAPS_VOICE: {
993 userinfo = va_arg(ap, struct aim_userinfo_s *);
996 dvprintf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
997 dvprintf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
998 dvprintf("faimtest: voice invitation: \tclass = 0x%04x = ", userinfo->flags);
999 printuserflags(userinfo->flags);
1000 dinlineprintf("\n");
1002 /* we dont get membersince on chat invites! */
1003 dvprintf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
1004 dvprintf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
1008 case AIM_CAPS_GETFILE: {
1011 struct aim_conn_t *newconn;
1012 struct aim_fileheader_t *fh;
1014 userinfo = va_arg(ap, struct aim_userinfo_s *);
1015 ip = va_arg(ap, char *);
1016 cookie = va_arg(ap, char *);
1019 dvprintf("faimtest: get file request from %s (at %s)\n", userinfo->sn, ip);
1021 fh = aim_getlisting(listingfile);
1023 if( (newconn = aim_accepttransfer(sess, command->conn, userinfo->sn, cookie, ip, fh->totfiles, fh->totsize, fh->size, fh->checksum, reqclass)) == NULL ) {
1024 dprintf("faimtest: getfile: requestconn: apparent error in accepttransfer\n");
1030 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);
1031 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ, faimtest_getfile_filereq, 0);
1032 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);
1033 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);
1035 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);
1037 dprintf("faimtest: getfile connect succeeded, handlers added.\n");
1042 case AIM_CAPS_SENDFILE: {
1043 dprintf("faimtest: send file!\n");
1046 case AIM_CAPS_CHAT: {
1047 char *msg,*encoding,*lang;
1048 struct aim_chat_roominfo *roominfo;
1050 userinfo = va_arg(ap, struct aim_userinfo_s *);
1051 roominfo = va_arg(ap, struct aim_chat_roominfo *);
1052 msg = va_arg(ap, char *);
1053 encoding = va_arg(ap, char *);
1054 lang = va_arg(ap, char *);
1057 dvprintf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
1058 dvprintf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
1059 dvprintf("faimtest: chat invitation: \tclass = 0x%04x = ", userinfo->flags);
1060 printuserflags(userinfo->flags);
1061 dinlineprintf("\n");
1063 /* we dont get membersince on chat invites! */
1064 dvprintf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
1065 dvprintf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
1067 dvprintf("faimtest: chat invitation: message = %s\n", msg);
1068 dvprintf("faimtest: chat invitation: room name = %s\n", roominfo->name);
1069 dvprintf("faimtest: chat invitation: encoding = %s\n", encoding);
1070 dvprintf("faimtest: chat invitation: language = %s\n", lang);
1071 dvprintf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
1072 dvprintf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
1073 dvprintf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
1075 * Automatically join room...
1077 aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
1080 case AIM_CAPS_IMIMAGE: {
1081 struct aim_directim_priv *priv;
1082 struct aim_conn_t *newconn;
1084 dprintf("faimtest: icbm: rendezvous imimage\n");
1086 userinfo = va_arg(ap, struct aim_userinfo_s *);
1087 priv = va_arg(ap, struct aim_directim_priv *);
1090 dvprintf("faimtest: OFT: DirectIM: request from %s (%s)\n", userinfo->sn, priv->ip);
1092 if (!(newconn = aim_directim_connect(sess, command->conn, priv))) {
1093 dprintf("faimtest: icbm: imimage: could not connect\n");
1096 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
1097 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
1098 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
1100 dvprintf("faimtest: OFT: DirectIM: connected to %s\n", userinfo->sn);
1102 aim_send_im_direct(sess, newconn, "goodday");
1107 dvprintf("faimtest: icbm: unknown reqclass (%d)\n", reqclass);
1110 dvprintf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
1111 dprintf("faimtest: icbm: done with ICBM handling\n");
1116 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1119 struct aim_directim_priv *priv;
1120 struct aim_conn_t *newconn;
1122 va_start(ap, command);
1123 newconn = va_arg(ap, struct aim_conn_t *);
1126 priv = (struct aim_directim_priv *)newconn->priv;
1128 dvprintf("faimtest: OFT: DirectIM: intitiate success to %s\n", priv->ip);
1130 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
1131 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
1132 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
1134 aim_send_im_direct(sess, newconn, "goodday");
1136 dvprintf("faimtest: OFT: DirectIM: connected to %s\n", priv->sn);
1141 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1144 struct aim_directim_priv *priv;
1146 va_start(ap, command);
1147 priv = va_arg(ap, struct aim_directim_priv *);
1151 dprintf("faimtest: directim_connect\n");
1156 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1159 char *sn = NULL, *msg = NULL;
1160 struct aim_conn_t *conn;
1162 va_start(ap, command);
1163 conn = va_arg(ap, struct aim_conn_t *);
1164 sn = va_arg(ap, char *);
1165 msg = va_arg(ap, char *);
1168 dvprintf("faimtest: Directim from %s: %s\n", sn, msg);
1169 if (!strncmp(msg, "sendmsg", 7)) {
1176 newbuf = malloc(i+1);
1177 for (z = 0; z < i; z++) {
1178 newbuf[z] = (z % 10)+0x30;
1181 aim_send_im_direct(sess, conn, newbuf);
1184 } else if (!strncmp(msg, "goodday", 7)) {
1185 aim_send_im_direct(sess, conn, "Good day to you, too");
1188 snprintf(newmsg, sizeof(newmsg), "unknown (%s)\n", msg);
1189 aim_send_im_direct(sess, conn, newmsg);
1194 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1197 struct aim_conn_t *conn;
1200 va_start(ap, command);
1201 conn = va_arg(ap, struct aim_conn_t *);
1202 sn = va_arg(ap, char *);
1205 dvprintf("faimtest: directim: disconnected from %s\n", sn);
1207 aim_conn_kill(sess, &conn);
1211 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1216 va_start(ap, command);
1217 sn = va_arg(ap, char *);
1220 dvprintf("faimtest: ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn);
1224 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1226 dvprintf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
1228 /* should just be able to tell it we're ready too... */
1229 aim_auth_clientready(sess, command->conn);
1233 * This is where you'd really begin changing your password.
1234 * However, this callback may get called for reasons other
1235 * than you wanting to change your password. You should
1236 * probably check that before actually doing it.
1238 aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
1244 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1246 dprintf("PASSWORD CHANGE SUCCESSFUL!!!\n");
1250 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1252 struct aim_userinfo_s *userinfo;
1255 va_start(ap, command);
1256 userinfo = va_arg(ap, struct aim_userinfo_s *);
1259 dvprintf("%ld %s is now online (flags: %04x = %s%s%s%s%s%s%s%s) (caps = 0x%04x)\n",
1261 userinfo->sn, userinfo->flags,
1262 (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"",
1263 (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"",
1264 (userinfo->flags&AIM_FLAG_AOL)?" AOL":"",
1265 (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"",
1266 (userinfo->flags&AIM_FLAG_FREE)?" FREE":"",
1267 (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"",
1268 (userinfo->flags&AIM_FLAG_UNKNOWN40)?" UNKNOWN40":"",
1269 (userinfo->flags&AIM_FLAG_UNKNOWN80)?" UNKNOWN80":"",
1270 userinfo->capabilities);
1274 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1279 va_start(ap, command);
1280 sn = va_arg(ap, char *);
1283 dvprintf("\n%s has left\n", sn);
1288 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1290 static char *codes[] = {
1292 "Mandatory upgrade",
1295 "Top o' the world!"};
1296 static int codeslen = 5;
1302 va_start(ap, command);
1303 id = va_arg(ap, int);
1304 msg = va_arg(ap, char *);
1307 dvprintf("faimtest: motd: %s (%d / %s)\n", msg, id,
1308 (id < codeslen)?codes[id]:"unknown");
1316 int faimtest_parse_genericerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1319 unsigned short reason;
1321 va_start(ap, command);
1322 reason = va_arg(ap, int);
1325 dvprintf("faimtest: snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
1330 int faimtest_parse_msgerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1334 unsigned short reason;
1336 va_start(ap, command);
1337 destsn = va_arg(ap, char *);
1338 reason = va_arg(ap, int);
1341 dvprintf("faimtest: message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
1346 int faimtest_parse_locerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1350 unsigned short reason;
1352 va_start(ap, command);
1353 destsn = va_arg(ap, char *);
1354 reason = va_arg(ap, int);
1357 dvprintf("faimtest: user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
1363 * Handles callbacks for AIM_CB_MISSED_CALL.
1365 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1367 static char *missedreasons[] = {
1369 "Message too large"};
1370 static int missedreasonslen = 2;
1373 unsigned short chan, nummissed, reason;
1374 struct aim_userinfo_s *userinfo;
1376 va_start(ap, command);
1377 chan = va_arg(ap, int);
1378 userinfo = va_arg(ap, struct aim_userinfo_s *);
1379 nummissed = va_arg(ap, int);
1380 reason = va_arg(ap, int);
1383 dvprintf("faimtest: missed %d messages from %s (reason %d: %s)\n", nummissed, userinfo->sn, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown");
1388 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1390 struct client_info_s info = {"faimtest (with SNAC login)", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x0000004b}; /* 4.1.2010 */
1394 va_start(ap, command);
1395 key = va_arg(ap, char *);
1398 aim_send_login(sess, command->conn, screenname, password, &info, key);
1403 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1406 struct aim_userinfo_s *userinfo;
1407 int count = 0, i = 0;
1409 va_start(ap, command);
1410 count = va_arg(ap, int);
1411 userinfo = va_arg(ap, struct aim_userinfo_s *);
1414 dvprintf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv);
1416 dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1421 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1424 struct aim_userinfo_s *userinfo;
1425 int count = 0, i = 0;
1427 va_start(ap, command);
1428 count = va_arg(ap, int);
1429 userinfo = va_arg(ap, struct aim_userinfo_s *);
1432 dvprintf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv);
1434 for (i = 0; i < count; )
1435 dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1440 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1443 struct aim_userinfo_s *userinfo;
1444 struct aim_chat_roominfo *roominfo;
1448 unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen;
1449 unsigned long creationtime;
1451 va_start(ap, command);
1452 roominfo = va_arg(ap, struct aim_chat_roominfo *);
1453 roomname = va_arg(ap, char *);
1454 usercount= va_arg(ap, int);
1455 userinfo = va_arg(ap, struct aim_userinfo_s *);
1456 roomdesc = va_arg(ap, char *);
1457 unknown_c9 = va_arg(ap, int);
1458 creationtime = va_arg(ap, unsigned long);
1459 maxmsglen = va_arg(ap, int);
1460 unknown_d2 = va_arg(ap, int);
1461 unknown_d5 = va_arg(ap, int);
1464 dvprintf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv);
1465 dvprintf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n",
1466 (char *)command->conn->priv,
1469 roominfo->instance);
1470 dvprintf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname);
1471 dvprintf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
1472 dvprintf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
1474 for (i = 0; i < usercount; )
1475 dvprintf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1477 dvprintf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9);
1478 dvprintf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime);
1479 dvprintf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen);
1480 dvprintf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2);
1481 dvprintf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5);
1486 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1489 struct aim_userinfo_s *userinfo;
1493 va_start(ap, command);
1494 userinfo = va_arg(ap, struct aim_userinfo_s *);
1495 msg = va_arg(ap, char *);
1498 dvprintf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
1501 * Do an echo for testing purposes. But not for ourselves ("oops!")
1503 if (strcmp(userinfo->sn, sess->sn) != 0)
1505 sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
1506 aim_chat_send_im(sess, command->conn, tmpbuf);
1512 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1514 unsigned short type;
1517 va_start(ap, command);
1518 type = va_arg(ap, int);
1523 struct aim_chat_exchangeinfo *exchanges;
1524 int exchangecount,i = 0;
1526 maxrooms = va_arg(ap, int);
1527 exchangecount = va_arg(ap, int);
1528 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
1531 dprintf("faimtest: chat info: Chat Rights:\n");
1532 dvprintf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
1534 dvprintf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
1535 for (i = 0; i < exchangecount; i++) {
1536 dvprintf("faimtest: chat info: \t\t%x: %s (%s/%s)\n",
1537 exchanges[i].number,
1539 exchanges[i].charset1,
1540 exchanges[i].lang1);
1546 char *fqcn, *name, *ck;
1547 unsigned short instance, flags, maxmsglen, maxoccupancy, unknown, exchange;
1548 unsigned char createperms;
1549 unsigned long createtime;
1551 fqcn = va_arg(ap, char *);
1552 instance = va_arg(ap, int);
1553 exchange = va_arg(ap, int);
1554 flags = va_arg(ap, int);
1555 createtime = va_arg(ap, unsigned long);
1556 maxmsglen = va_arg(ap, int);
1557 maxoccupancy = va_arg(ap, int);
1558 createperms = va_arg(ap, int);
1559 unknown = va_arg(ap, int);
1560 name = va_arg(ap, char *);
1561 ck = va_arg(ap, char *);
1564 dvprintf("faimtest: recieved room create reply for %s/0x%04x\n", fqcn, exchange);
1569 dvprintf("faimtest: chatnav info: unknown type (%04x)\n", type);
1574 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1577 unsigned short code;
1580 va_start(ap, command);
1581 code = va_arg(ap, int);
1582 msg = va_arg(ap, char *);
1585 dvprintf("faimtest: connerr: Code 0x%04x: %s\n", code, msg);
1586 aim_conn_kill(sess, &command->conn); /* this will break the main loop */
1591 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1593 dprintf("faimtest: connecting to an aimdebugd!\n");
1595 /* convert the authorizer connection to a BOS connection */
1596 command->conn->type = AIM_CONN_TYPE_BOS;
1598 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
1600 /* tell the aimddebugd we're ready */
1601 aim_debugconn_sendconnect(sess, command->conn);
1603 /* go right into main loop (don't open a BOS connection, etc) */
1608 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
1610 int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1613 unsigned short type;
1616 va_start(ap, command);
1617 type = va_arg(ap, int);
1618 sn = va_arg(ap, char *);
1621 dvprintf("faimtest: msgack: 0x%04x / %s\n", type, sn);
1627 int faimtest_getfile_filereq(struct aim_session_t *ses, struct command_rx_struct *command, ...)
1630 struct aim_conn_t *oftconn;
1631 struct aim_fileheader_t *fh;
1634 va_start(ap, command);
1635 oftconn = va_arg(ap, struct aim_conn_t *);
1636 fh = va_arg(ap, struct aim_fileheader_t *);
1637 cookie = va_arg(ap, char *);
1640 dvprintf("faimtest: request for file %s.\n", fh->name);
1646 int faimtest_getfile_filesend(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1649 struct aim_conn_t *oftconn;
1650 struct aim_fileheader_t *fh;
1651 char *path, *cookie;
1652 int pos, bufpos, bufsize = 2048, i;
1657 va_start(ap, command);
1658 oftconn = va_arg(ap, struct aim_conn_t *);
1659 fh = va_arg(ap, struct aim_fileheader_t *);
1660 cookie = va_arg(ap, char *);
1663 dvprintf("faimtest: sending file %s(%ld).\n", fh->name, fh->size);
1665 if( (path = (char *)calloc(1, strlen(listingpath) +strlen(fh->name)+2)) == NULL) {
1667 dprintf("faimtest: error in calloc of path\n");
1668 return 0; /* XXX: no idea what winaim expects here =) */
1671 snprintf(path, strlen(listingpath)+strlen(fh->name)+2, "%s/%s", listingpath, fh->name);
1674 if( (file = fopen(path, "r")) == NULL) {
1675 dvprintf("faimtest: getfile_send fopen failed for %s. damn.\n", path);
1679 for(pos = 0; pos < fh->size; pos++) {
1680 bufpos = pos % bufsize;
1682 if(bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */
1683 if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {
1684 dperror("faim: getfile_send: write1");
1685 dprintf("faim: getfile_send: whoopsy, didn't write it all...\n");
1690 if( (buf[bufpos] = fgetc(file)) == EOF) {
1691 if(pos != fh->size) {
1692 dvprintf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size);
1697 dvprintf("%c(0x%02x) ", buf[pos], buf[pos]);
1700 if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {
1701 dperror("faim: getfile_send: write2");
1702 dprintf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n");
1712 int faimtest_getfile_complete(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1715 struct aim_conn_t *conn;
1716 struct aim_fileheader_t *fh;
1718 va_start(ap, command);
1719 conn = va_arg(ap, struct aim_conn_t *);
1720 fh = va_arg(ap, struct aim_fileheader_t *);
1723 dvprintf("faimtest: completed file transfer for %s.\n", fh->name);
1725 aim_conn_close(conn);
1726 aim_conn_kill(sess, &conn);
1730 int faimtest_getfile_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1733 struct aim_conn_t *conn;
1736 va_start(ap, command);
1737 conn = va_arg(ap, struct aim_conn_t *);
1738 sn = va_arg(ap, char *);
1741 aim_conn_kill(sess, &conn);
1743 dvprintf("faimtest: getfile: disconnected from %s\n", sn);
1746 int faimtest_getfile_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1749 struct aim_conn_t *conn;
1751 struct aim_filetransfer_priv *priv;
1753 va_start(ap, command);
1754 conn = va_arg(ap, struct aim_conn_t *);
1755 sn = va_arg(ap, char *);
1758 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ, faimtest_getfile_filereq, 0);
1759 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);
1760 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);
1761 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);
1762 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTING, faimtest_getfile_listing, 0);
1763 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);
1764 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILERECIEVE, faimtest_getfile_recieve, 0);
1766 priv = (struct aim_filetransfer_priv *)conn->priv;
1768 dvprintf("faimtest: getfile: %s (%s) connected to us on %d\n", sn, priv->ip, conn->fd);
1772 int faimtest_getfile_listing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1775 struct aim_conn_t *conn;
1777 struct aim_filetransfer_priv *ft;
1778 char *filename, *nameend, *sizec;
1779 int filesize, namelen;
1781 va_start(ap, command);
1782 conn = va_arg(ap, struct aim_conn_t *);
1783 ft = va_arg(ap, struct aim_filetransfer_priv *);
1784 listing = va_arg(ap, char *);
1787 dvprintf("listing on %d==================\n%s\n===========\n", conn->fd, listing);
1789 nameend = strstr(listing+0x1a, "\r");
1791 namelen = nameend - (listing + 0x1a);
1793 filename = malloc(namelen + 1);
1794 strncpy(filename, listing+0x1a, namelen);
1795 filename[namelen] = 0x00;
1797 sizec = malloc(8+1);
1798 memcpy(sizec, listing + 0x11, 8);
1801 filesize = strtol(sizec, (char **)NULL, 10);
1803 dvprintf("faimtest: requesting %d %s(%d long)\n", namelen, filename, filesize);
1805 aim_oft_getfile_request(sess, conn, filename, filesize);
1813 int faimtest_getfile_listingreq(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1816 struct aim_conn_t *oftconn;
1817 struct aim_fileheader_t *fh;
1818 int pos, bufpos, bufsize = 2048, i;
1822 va_start(ap, command);
1823 oftconn = va_arg(ap, struct aim_conn_t *);
1824 fh = va_arg(ap, struct aim_fileheader_t *);
1827 dvprintf("faimtest: sending listing of size %ld\n", fh->size);
1829 for(pos = 0; pos < fh->size; pos++) {
1830 bufpos = pos % bufsize;
1832 if(bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */
1833 if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {
1834 dperror("faim: getfile_send: write1");
1835 dprintf("faim: getfile_send: whoopsy, didn't write it all...\n");
1840 if( (buf[bufpos] = fgetc(listingfile)) == EOF) {
1841 if(pos != fh->size) {
1842 dvprintf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size);
1849 if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {
1850 dperror("faim: getfile_send: write2");
1851 dprintf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n");
1856 dprintf("faimtest: sent listing\n");
1860 int faimtest_getfile_recieve(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1863 struct aim_conn_t *conn;
1864 struct aim_filetransfer_priv *ft;
1868 va_start(ap, command);
1869 conn = va_arg(ap, struct aim_conn_t *);
1870 ft = va_arg(ap, struct aim_filetransfer_priv *);
1873 dvprintf("faimtest: receiving %ld bytes of file data for %s:\n\t", ft->fh.size, ft->fh.name);
1875 for(pos = 0; pos < ft->fh.size; pos++) {
1876 read(conn->fd, &data, 1);
1877 dvprintf("%c(%02x) ", data, data);
1882 aim_oft_getfile_ack(sess, conn);
1883 aim_oft_getfile_end(sess, conn);
1888 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1890 static char *codes[5] = {"invalid",
1897 unsigned long rateclass, windowsize, clear, alert, limit, disconnect;
1898 unsigned long currentavg, maxavg;
1900 va_start(ap, command);
1902 /* See code explanations below */
1903 code = va_arg(ap, int);
1906 * See comments above aim_parse_ratechange_middle() in aim_rxhandlers.c.
1908 rateclass = va_arg(ap, unsigned long);
1911 * Not sure what this is exactly. I think its the temporal
1912 * relation factor (ie, how to make the rest of the numbers
1913 * make sense in the real world).
1915 windowsize = va_arg(ap, unsigned long);
1917 /* Explained below */
1918 clear = va_arg(ap, unsigned long);
1919 alert = va_arg(ap, unsigned long);
1920 limit = va_arg(ap, unsigned long);
1921 disconnect = va_arg(ap, unsigned long);
1922 currentavg = va_arg(ap, unsigned long);
1923 maxavg = va_arg(ap, unsigned long);
1928 dvprintf("faimtest: rate %s (rate class 0x%04lx): curavg = %ld, maxavg = %ld, alert at %ld, clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n",
1929 (code < 5)?codes[code]:"invalid",
1936 if (code == AIM_RATE_CODE_CHANGE) {
1938 * Not real sure when these get sent.
1940 if (currentavg >= clear)
1941 aim_conn_setlatency(command->conn, 0);
1943 } else if (code == AIM_RATE_CODE_WARNING) {
1945 * We start getting WARNINGs the first time we go below the 'alert'
1946 * limit (currentavg < alert) and they stop when either we pause
1947 * long enough for currentavg to go above 'clear', or until we
1948 * flood it bad enough to go below 'limit' (and start getting
1949 * LIMITs instead) or even further and go below 'disconnect' and
1950 * get disconnected completely (and won't be able to login right
1953 aim_conn_setlatency(command->conn, windowsize/4); /* XXX this is bogus! */
1955 } else if (code == AIM_RATE_CODE_LIMIT) {
1957 * When we hit LIMIT, messages will start getting dropped.
1959 aim_conn_setlatency(command->conn, windowsize/2); /* XXX this is bogus! */
1961 } else if (code == AIM_RATE_CODE_CLEARLIMIT) {
1963 * The limit is cleared when curavg goes above 'clear'.
1965 aim_conn_setlatency(command->conn, 0);
1971 int faimtest_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1975 struct aim_userinfo_s *userinfo;
1977 va_start(ap, command);
1978 newevil = va_arg(ap, int);
1979 userinfo = va_arg(ap, struct aim_userinfo_s *);
1983 * Evil Notifications that are lacking userinfo->sn are anon-warns
1984 * if they are an evil increases, but are not warnings at all if its
1985 * a decrease (its the natural backoff happening).
1987 * newevil is passed as an int representing the new evil value times
1990 dvprintf("faimtest: evil level change: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous");
1995 int faimtest_parse_searchreply(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1998 char *address, *SNs;
2001 va_start(ap, command);
2002 address = va_arg(ap, char *);
2003 num = va_arg(ap, int);
2004 SNs = va_arg(ap, char *);
2007 dvprintf("faimtest: E-Mail Search Results for %s: ", address);
2009 for(i = 0; i < num; i++)
2010 dvinlineprintf("%s, ", &SNs[i*(MAXSNLEN+1)]);
2011 dinlineprintf("\n");
2016 int faimtest_parse_searcherror(struct aim_session_t *sess, struct command_rx_struct *command, ...)
2021 va_start(ap, command);
2022 address = va_arg(ap, char *);
2025 dvprintf("faimtest: E-Mail Search Results for %s: No Results or Invalid Email\n", address);