]> andersk Git - libfaim.git/blobdiff - utils/faimtest/faimtest.c
this gets faimtest to compile on my work box. stupid gcc 2.96
[libfaim.git] / utils / faimtest / faimtest.c
index f9ee277e1dfae5f0cf69c957d6ed6f514447e33b..f5b8e2751167b9a02e6c9de467de1e062ee0c7cc 100644 (file)
@@ -461,8 +461,8 @@ static int faimtest_infochange(aim_session_t *sess, aim_frame_t *fr, ...)
 
        va_start(ap, fr);
        change = va_arg(ap, int);
-       perms = va_arg(ap, fu16_t);
-       type = va_arg(ap, fu16_t);
+       perms = (fu16_t)va_arg(ap, unsigned int);
+       type = (fu16_t)va_arg(ap, unsigned int);
        length = va_arg(ap, int);
        val = va_arg(ap, char *);
        str = va_arg(ap, int);
@@ -944,7 +944,7 @@ static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...)
        userinfo = va_arg(ap, struct aim_userinfo_s *);
        prof_encoding = va_arg(ap, char *);
        prof = va_arg(ap, char *);
-       inforeq = va_arg(ap, fu16_t);
+       inforeq = (fu16_t)va_arg(ap, unsigned int);
        va_end(ap);
 
        dvprintf("faimtest: userinfo: sn: %s\n", userinfo->sn);
@@ -995,6 +995,107 @@ static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, struct aim_
 
                aim_send_im_ext(sess, conn, &args);
 
+       } else if (strstr(tmpstr, "sendbin")) {
+               struct aim_sendimext_args args;
+               static const unsigned char data[] = {
+                       0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+                       0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+                       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+               };
+
+               /*
+                * I put this here as a demonstration of how to send 
+                * arbitrary binary data via OSCAR ICBM's without the need
+                * for escape or baseN encoding of any sort.  
+                *
+                * Apparently if you set the charset to something WinAIM
+                * doesn't recognize, it will completly ignore the message.
+                * That is, it will not display anything in the conversation
+                * window for the user that recieved it.
+                *
+                * HOWEVER, if they do not have a conversation window open
+                * for you, a new one will be created, but it will not have
+                * any messages in it.  Therefore sending these things could
+                * be a great way to seemingly subliminally convince people
+                * to talk to you...
+                *
+                */
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_CUSTOMCHARSET;
+               args.charset = args.charsubset = 0x4242;
+               args.msg = data;
+               args.msglen = sizeof(data);
+
+               aim_send_im_ext(sess, conn, &args);
+
+       } else if (strstr(tmpstr, "sendmulti")) {
+               struct aim_sendimext_args args;
+               aim_mpmsg_t mpm;
+               static const fu16_t unidata[] = { /* "UNICODE." */
+                       0x0055, 0x004e, 0x0049, 0x0043,
+                       0x004f, 0x0044, 0x0045, 0x002e,
+               };
+               static const int unidatalen = 8;
+
+               /*
+                * This is how multipart messages should be sent.
+                *
+                * This should render as:
+                *        "Part 1, ASCII.  UNICODE.Part 3, ASCII.  "
+                */
+
+               aim_mpmsg_init(sess, &mpm);
+
+               aim_mpmsg_addascii(sess, &mpm, "Part 1, ASCII.  ");
+               aim_mpmsg_addunicode(sess, &mpm, unidata, unidatalen);
+               aim_mpmsg_addascii(sess, &mpm, "Part 3, ASCII.  ");
+
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_MULTIPART;
+               args.mpmsg = &mpm;
+
+               aim_send_im_ext(sess, conn, &args);
+
+               aim_mpmsg_free(sess, &mpm);
+
+       } else if (strstr(tmpstr, "sendprebin")) {
+               static const unsigned char data[] = {
+                       0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+                       0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+                       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+               };
+               struct aim_sendimext_args args;
+               aim_mpmsg_t mpm;
+
+               /*
+                * This demonstrates sending a human-readable preamble,
+                * and then arbitrary binary data.
+                *
+                * This means that you can very inconspicuously send binary
+                * attachments to other users.  In WinAIM, this appears as
+                * though it only had the ASCII portion.
+                *
+                */
+
+               aim_mpmsg_init(sess, &mpm);
+
+               aim_mpmsg_addascii(sess, &mpm, "This message has binary data.");
+               aim_mpmsg_addraw(sess, &mpm, 0x4242, 0x4242, data, sizeof(data));
+
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_MULTIPART;
+               args.mpmsg = &mpm;
+
+               aim_send_im_ext(sess, conn, &args);
+
+               aim_mpmsg_free(sess, &mpm);
+
        } else if (strstr(tmpstr, "havefeat")) {
                struct aim_sendimext_args args;
                static const char featmsg[] = {"I have nifty features."};
@@ -1132,17 +1233,12 @@ static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, struct aim_
 /*
  * Channel 1: Standard Message
  */
-static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, va_list ap)
+static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, struct aim_incomingim_ch1_args *args)
 {
        struct faimtest_priv *priv = (struct faimtest_priv *)sess->aux_data;
        char *tmpstr;
-       struct aim_incomingim_ch1_args *args;
        int clienttype = AIM_CLIENTTYPE_UNKNOWN;
        char realmsg[8192+1] = {""};
-
-       args = va_arg(ap, struct aim_incomingim_ch1_args *);
-       va_end(ap);
-
        clienttype = aim_fingerprintclient(args->features, args->featureslen);
 
        dvprintf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
@@ -1168,7 +1264,8 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
                dinlineprintf("hasicon ");
        dinlineprintf("\n");
 
-       dvprintf("faimtest: icbm: encoding flags = {%04x, %04x}\n", args->flag1, args->flag2);
+       if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET)
+               dvprintf("faimtest: icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset);
 
        /*
         * Quickly convert it to eight bit format, replacing non-ASCII UNICODE 
@@ -1220,6 +1317,21 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
 
        dvprintf("faimtest: icbm: message: %s\n", realmsg);
 
+       if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
+               aim_mpmsg_section_t *sec;
+               int z;
+
+               dvprintf("faimtest: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
+
+               for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
+                       if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
+                               dvprintf("faimtest: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data);
+                       } else {
+                               dvprintf("faimtest: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset);
+                       }
+               }
+       }
+
        if (args->icbmflags & AIM_IMFLAGS_HASICON)
                aim_send_im(sess, conn, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon");
 
@@ -1248,12 +1360,8 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
 /*
  * Channel 2: Rendevous Request
  */
-static int faimtest_parse_incoming_im_chan2(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, va_list ap)
+static int faimtest_parse_incoming_im_chan2(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, struct aim_incomingim_ch2_args *args)
 {
-       struct aim_incomingim_ch2_args *args;
-
-       args = va_arg(ap, struct aim_incomingim_ch2_args *);
-       va_end(ap);
 
        if (args->reqclass == AIM_CAPS_VOICE) {
 
@@ -1323,16 +1431,27 @@ static int faimtest_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...)
        int ret = 0;
 
        va_start(ap, fr);
-       channel = va_arg(ap, fu16_t);
+       channel = (fu16_t)va_arg(ap, unsigned int);
        userinfo = va_arg(ap, struct aim_userinfo_s *);
 
-       if (channel == 1)
-               ret = faimtest_parse_incoming_im_chan1(sess, fr->conn, userinfo, ap);
-       else if (channel == 2)
-               ret = faimtest_parse_incoming_im_chan2(sess, fr->conn, userinfo, ap);
-       else
+       if (channel == 1) {
+               struct aim_incomingim_ch1_args *args;
+
+               args = va_arg(ap, struct aim_incomingim_ch1_args *);
+
+               ret = faimtest_parse_incoming_im_chan1(sess, fr->conn, userinfo, args);
+
+       } else if (channel == 2) {
+               struct aim_incomingim_ch2_args *args;
+
+               args = va_arg(ap, struct aim_incomingim_ch2_args *);
+
+               ret = faimtest_parse_incoming_im_chan2(sess, fr->conn, userinfo, args);
+       } else
                dvprintf("unsupported channel 0x%04x\n", channel);
 
+       va_end(ap);
+
        dvprintf("faimtest: icbm: done with ICBM handling (ret = %d)\n", ret);
 
        return 1;
@@ -1393,7 +1512,7 @@ static int faimtest_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...)
        fu16_t reason;
 
        va_start(ap, fr);
-       reason = va_arg(ap, fu16_t);
+       reason = (fu16_t)va_arg(ap, unsigned int);
        va_end(ap);
 
        dvprintf("faimtest: snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
@@ -1408,7 +1527,7 @@ static int faimtest_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...)
        fu16_t reason;
 
        va_start(ap, fr);
-       reason = va_arg(ap, fu16_t);
+       reason = (fu16_t)va_arg(ap, unsigned int);
        destsn = va_arg(ap, char *);
        va_end(ap);
 
@@ -1424,7 +1543,7 @@ static int faimtest_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...)
        fu16_t reason;
 
        va_start(ap, fr);
-       reason = va_arg(ap, fu16_t);
+       reason = (fu16_t)va_arg(ap, unsigned int);
        destsn = va_arg(ap, char *);
        va_end(ap);
 
@@ -1449,10 +1568,10 @@ static int faimtest_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...)
        struct aim_userinfo_s *userinfo;
 
        va_start(ap, fr);
-       chan = va_arg(ap, fu16_t);
+       chan = (fu16_t)va_arg(ap, unsigned int);
        userinfo = va_arg(ap, struct aim_userinfo_s *);
-       nummissed = va_arg(ap, fu16_t);
-       reason = va_arg(ap, fu16_t);
+       nummissed = (fu16_t)va_arg(ap, unsigned int);
+       reason = (fu16_t)va_arg(ap, unsigned int);
        va_end(ap);
 
        dvprintf("faimtest: missed %d messages from %s on channel %d (reason %d: %s)\n", nummissed, userinfo->sn, chan, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown");
@@ -1470,7 +1589,7 @@ static int faimtest_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...)
        char *sn = NULL;
 
        va_start(ap, fr);
-       type = va_arg(ap, fu16_t);
+       type = (fu16_t)va_arg(ap, unsigned int);
        sn = va_arg(ap, char *);
        va_end(ap);
 
@@ -1496,12 +1615,12 @@ static int faimtest_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...)
        va_start(ap, fr); 
 
        /* See code explanations below */
-       code = va_arg(ap, fu16_t);
+       code = (fu16_t)va_arg(ap, unsigned int);
 
        /*
         * See comments above aim_parse_ratechange_middle() in aim_rxhandlers.c.
         */
-       rateclass = va_arg(ap, fu16_t);
+       rateclass = (fu16_t)va_arg(ap, unsigned int);
 
        /*
         * Not sure what this is exactly.  I think its the temporal 
@@ -1571,7 +1690,7 @@ static int faimtest_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...)
        struct aim_userinfo_s *userinfo;
 
        va_start(ap, fr);
-       newevil = va_arg(ap, fu16_t);
+       newevil = (fu16_t)va_arg(ap, unsigned int);
        userinfo = va_arg(ap, struct aim_userinfo_s *);
        va_end(ap);
 
This page took 0.086748 seconds and 4 git commands to generate.