From: mid Date: Wed, 14 Mar 2001 03:15:53 +0000 (+0000) Subject: - Wed Mar 14 03:11:03 UTC 2001 X-Git-Tag: rel_0_99_2~63 X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/commitdiff_plain/d2587300fe3ca6bf664c93b5f6258d275fe75155 - Wed Mar 14 03:11:03 UTC 2001 - Err...I'll commit before I go home. More faimtest crap. --- diff --git a/CHANGES b/CHANGES index b0b18be..c33b1f9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ No release numbers ------------------ + - Wed Mar 14 03:11:03 UTC 2001 + - Err...I'll commit before I go home. More faimtest crap. + - Tue Mar 13 20:23:04 UTC 2001 - Fiddle with faimtest a bit. diff --git a/utils/faimtest/commands.c b/utils/faimtest/commands.c index baab3cb..f27a3df 100644 --- a/utils/faimtest/commands.c +++ b/utils/faimtest/commands.c @@ -8,6 +8,10 @@ static int cmd_quit(char *arg); static int cmd_login(char *arg); static int cmd_logout(char *arg); static int cmd_connlist(char *arg); +static int cmd_goodday(char *arg); +static int cmd_warn(char *arg); +static int cmd_anonwarn(char *arg); +static int cmd_sendmsg(char *arg); struct { char *name; @@ -17,8 +21,12 @@ struct { { "help", cmd_help, "Help"}, { "quit", cmd_quit, "Quit"}, { "login", cmd_login, "Log into AIM"}, - { "logout", cmd_login, "Log out of AIM"}, + { "logout", cmd_logout, "Log out of AIM"}, { "connlist", cmd_connlist, "List open connections"}, + { "goodday", cmd_goodday, "Say goodday to arg"}, + { "warn", cmd_warn, "Warn arg"}, + { "anonwarn", cmd_anonwarn, "Anonymously warn arg"}, + { "sendmsg", cmd_sendmsg, "Send arg[0] bytes to arg[1]"}, { (char *)NULL, (Function *)NULL, (char *)NULL } }; @@ -141,7 +149,7 @@ void cmd_init(void) printf("Welcome to faimtest.\n"); - rl_callback_handler_install("faimtest>", fullline); + rl_callback_handler_install("faimtest> ", fullline); return; } @@ -198,7 +206,6 @@ static int cmd_logout(char *arg) static int cmd_connlist(char *arg) { - extern struct aim_session_t aimsess; struct aim_conn_t *cur; printf("Open connections:\n"); @@ -209,6 +216,63 @@ static int cmd_connlist(char *arg) return 0; } +static int cmd_goodday(char *arg) +{ + if (arg && strlen(arg) && (strlen(arg) < MAXSNLEN)) + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), arg, AIM_IMFLAGS_ACK, "Good day to you too."); + else + printf("no one to say hello to!\n"); + + return 0; +} + +static int cmd_warn(char *arg) +{ + if (arg && strlen(arg) && (strlen(arg) < MAXSNLEN)) + aim_send_warning(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), arg, 0); + else + printf("no one to warn!\n"); + + return 0; +} + +static int cmd_anonwarn(char *arg) +{ + if (arg && strlen(arg) && (strlen(arg) < MAXSNLEN)) + aim_send_warning(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), arg, AIM_WARN_ANON); + else + printf("no one to anonwarn!\n"); + + return 0; +} + +static int cmd_sendmsg(char *arg) +{ + int len = 0, z; + char sn[MAXSNLEN+1], *newbuf = NULL; + + if ((sscanf(arg, "%d %32s", &len, sn) != 2) || + (len >= 10000) || (strlen(sn) > MAXSNLEN)) { + printf("invalid args\n"); + return 0; + } + + printf("sending %d bytes to %s\n", len, sn); + + if (!(newbuf = malloc(len+1))) + return 0; + + for (z = 0; z < len; z++) + newbuf[z] = (z % 10)+0x30; + newbuf[len] = '\0'; + + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), sn, AIM_IMFLAGS_ACK, newbuf); + + free(newbuf); + + return 0; +} + void cmd_uninit(void) { diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index f505747..e10d494 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -252,6 +252,10 @@ int faimtest_init(void) int logout(void) { + + if (ohcaptainmycaptain) + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), ohcaptainmycaptain, 0, "ta ta..."); + aim_logoff(&aimsess); if (faimtest_init() == -1) @@ -911,20 +915,144 @@ int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct return 1; } +static int faimtest_handlecmd(struct aim_session_t *sess, struct command_rx_struct *command, struct aim_userinfo_s *userinfo, char *tmpstr) +{ + + if (!strncmp(tmpstr, "disconnect", 10)) { + + logout(); + + } else if (strstr(tmpstr, "goodday")) { + + aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); + + } else if (strstr(tmpstr, "warnme")) { + + dprintf("faimtest: icbm: sending non-anon warning\n"); + aim_send_warning(sess, command->conn, userinfo->sn, 0); + + } else if (strstr(tmpstr, "anonwarn")) { + + dprintf("faimtest: icbm: sending anon warning\n"); + aim_send_warning(sess, command->conn, userinfo->sn, AIM_WARN_ANON); + + } else if (strstr(tmpstr, "setdirectoryinfo")) { + + dprintf("faimtest: icbm: sending backwards profile data\n"); + aim_setdirectoryinfo(sess, command->conn, "tsrif", "elddim", "tsal", "nediam", "emankcin", "teerts", "ytic", "etats", "piz", 0, 1); + + } else if (strstr(tmpstr, "setinterests")) { + + dprintf("faimtest: icbm: setting fun interests\n"); + aim_setuserinterests(sess, command->conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1); + + } else if (!strncmp(tmpstr, "getfile", 7)) { + + if (!ohcaptainmycaptain) { + + aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!"); + + } else { + struct aim_conn_t *newconn; + + newconn = aim_getfile_initiate(sess, command->conn, (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8); + dvprintf("faimtest: getting file listing from %s\n", (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8); + aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE, faimtest_getfile_initiate,0); + } + + } else if (!strncmp(tmpstr, "open chatnav", 12)) { + + aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); + + } else if (!strncmp(tmpstr, "create", 6)) { + + aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004); + + } else if (!strncmp(tmpstr, "close chatnav", 13)) { + struct aim_conn_t *chatnavconn; + + chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV); + aim_conn_kill(sess, &chatnavconn); + + } else if (!strncmp(tmpstr, "join", 4)) { + + aim_chat_join(sess, command->conn, 0x0004, "worlddomination"); + + } else if (!strncmp(tmpstr, "leave", 5)) { + + aim_chat_leaveroom(sess, "worlddomination"); + + } else if (!strncmp(tmpstr, "getinfo", 7)) { + + aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO); + aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE); + + } else if (!strncmp(tmpstr, "open directim", 13)) { + struct aim_conn_t *newconn; + + printf("faimtest: opening directim to %s\n", (strlen(tmpstr) < 14)?userinfo->sn:tmpstr+14); + newconn = aim_directim_initiate(sess, command->conn, NULL, (strlen(tmpstr) < 14)?userinfo->sn:tmpstr+14); + if(!newconn || newconn->fd == -1) + printf("connection failed!\n"); + aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate,0); + + } else if(!(strncmp(tmpstr, "lookup", 6))) { + + aim_usersearch_address(sess, command->conn, tmpstr+7); + + } else if (!strncmp(tmpstr, "reqsendmsg", 10)) { + + aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "sendmsg 7900"); + + } else if (!strncmp(tmpstr, "reqauth", 7)) { + + aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_AUTH); + + } else if (!strncmp(tmpstr, "reqconfirm", 10)) { + + aim_auth_reqconfirm(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH)); + + } else if (!strncmp(tmpstr, "reqemail", 8)) { + + aim_auth_getinfo(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), 0x0011); + + } else if (!strncmp(tmpstr, "changepass", 8)) { + + aim_auth_changepasswd(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWPASSWORD", "OLDPASSWORD"); + + } else if (!strncmp(tmpstr, "setemail", 8)) { + + aim_auth_setemail(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWEMAILADDRESS"); + + } else if (!strncmp(tmpstr, "sendmsg", 7)) { + int i; + i = atoi(tmpstr+8); + if (i < 10000) { + char *newbuf; + int z; + + newbuf = malloc(i+1); + for (z = 0; z < i; z++) { + newbuf[z] = (z % 10)+0x30; + } + newbuf[i] = '\0'; + aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf); + free(newbuf); + } + + } else { + + dprintf("unknown command.\n"); + aim_add_buddy(sess, command->conn, userinfo->sn); + + } + + return 0; +} + /* * The user-level Incoming ICBM callback. * - * Arguments: - * struct command_rx_struct * command if you feel like doing it yourself - * char * srcsn the source name - * char * msg message - * int warnlevel warning/evil level - * int flags flags - * ulong membersince time_t of date of signup - * ulong onsince time_t of date of singon - * int idletime min (sec?) idle - * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK} - * */ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...) { @@ -993,93 +1121,8 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str } tmpstr = msg+i; - dvprintf("tmpstr = %s\n", tmpstr); - - if ( (strlen(tmpstr) >= 10) && - (!strncmp(tmpstr, "disconnect", 10)) ) { - if (ohcaptainmycaptain) - aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "ta ta..."); - aim_logoff(sess); - } else if (strstr(tmpstr, "goodday")) { - dprintf("faimtest: icbm: sending response\n"); - aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); - } else if (strstr(tmpstr, "warnme")) { - dprintf("faimtest: icbm: sending non-anon warning\n"); - aim_send_warning(sess, command->conn, userinfo->sn, 0); - } else if (strstr(tmpstr, "anonwarn")) { - dprintf("faimtest: icbm: sending anon warning\n"); - aim_send_warning(sess, command->conn, userinfo->sn, AIM_WARN_ANON); - } else if (strstr(tmpstr, "setdirectoryinfo")) { - dprintf("faimtest: icbm: sending backwards profile data\n"); - aim_setdirectoryinfo(sess, command->conn, "tsrif", "elddim", "tsal", "nediam", "emankcin", "teerts", "ytic", "etats", "piz", 0, 1); - } else if (strstr(tmpstr, "setinterests")) { - dprintf("faimtest: icbm: setting fun interests\n"); - aim_setuserinterests(sess, command->conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1); - } else if (!strncmp(tmpstr, "getfile", 7)) { - if (!ohcaptainmycaptain) { - aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!"); - } else { - struct aim_conn_t *newconn; - newconn = aim_getfile_initiate(sess, command->conn, (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8); - dvprintf("faimtest: getting file listing from %s\n", (strlen(tmpstr) < 8)?ohcaptainmycaptain:tmpstr+8); - aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE, faimtest_getfile_initiate,0); - } - } else if (!strncmp(tmpstr, "open chatnav", 12)) { - aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); - } else if (!strncmp(tmpstr, "create", 6)) { - aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004); - } else if (!strncmp(tmpstr, "close chatnav", 13)) { - struct aim_conn_t *chatnavconn; - chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV); - aim_conn_kill(sess, &chatnavconn); - } else if (!strncmp(tmpstr, "join", 4)) { - aim_chat_join(sess, command->conn, 0x0004, "worlddomination"); - } else if (!strncmp(tmpstr, "leave", 5)) - aim_chat_leaveroom(sess, "worlddomination"); - else if (!strncmp(tmpstr, "getinfo", 7)) { - aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO); - aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE); - } else if (!strncmp(tmpstr, "open directim", 13)) { - struct aim_conn_t *newconn; - printf("faimtest: opening directim to %s\n", (strlen(tmpstr) < 14)?userinfo->sn:tmpstr+14); - newconn = aim_directim_initiate(sess, command->conn, NULL, (strlen(tmpstr) < 14)?userinfo->sn:tmpstr+14); - if(!newconn || newconn->fd == -1) - printf("connection failed!\n"); - aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate,0); - } else if(!(strncmp(tmpstr, "lookup", 6))) { - aim_usersearch_address(sess, command->conn, tmpstr+7); - } else if (!strncmp(tmpstr, "reqsendmsg", 10)) { - aim_send_im(sess, command->conn, ohcaptainmycaptain, 0, "sendmsg 7900"); - } else if (!strncmp(tmpstr, "reqauth", 7)) { - aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_AUTH); - } else if (!strncmp(tmpstr, "reqconfirm", 10)) { - aim_auth_reqconfirm(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH)); - } else if (!strncmp(tmpstr, "reqemail", 8)) { - aim_auth_getinfo(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), 0x0011); - } else if (!strncmp(tmpstr, "changepass", 8)) { - aim_auth_changepasswd(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWPASSWORD", "OLDPASSWORD"); - } else if (!strncmp(tmpstr, "setemail", 8)) { - aim_auth_setemail(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWEMAILADDRESS"); - } else if (!strncmp(tmpstr, "sendmsg", 7)) { - int i; - i = atoi(tmpstr+8); - if (i < 10000) { - char *newbuf; - int z; - - newbuf = malloc(i+1); - for (z = 0; z < i; z++) { - newbuf[z] = (z % 10)+0x30; - } - newbuf[i] = '\0'; - aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf); - free(newbuf); - } - } else { - dprintf("unknown command.\n"); - aim_add_buddy(sess, command->conn, userinfo->sn); - } - + faimtest_handlecmd(sess, command, userinfo, tmpstr); + } } /* diff --git a/utils/faimtest/faimtest.h b/utils/faimtest/faimtest.h index 557629c..15fc33c 100644 --- a/utils/faimtest/faimtest.h +++ b/utils/faimtest/faimtest.h @@ -4,6 +4,8 @@ #include extern int keepgoing; +extern struct aim_session_t aimsess; + int login(const char *sn, const char *passwd); int logout(void);