- int iserror = 0;
- struct aim_tlv_t *tlv = NULL;
- char *errorurl = NULL;
- short errorcode = 0x00;
- u_int z = 0;
-
- if ( (command->data[0] == 0x00) &&
- (command->data[1] == 0x01) &&
- (command->data[2] == 0x00) &&
- (command->data[3] == 0x03) )
- {
- /* "server ready" -- can be ignored */
- userfunc = aim_callhandler(command->conn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY);
- }
- else if ( (command->data[0] == 0x00) &&
- (command->data[1] == 0x07) &&
- (command->data[2] == 0x00) &&
- (command->data[3] == 0x05) )
- {
- /* "information change reply" */
- userfunc = aim_callhandler(command->conn, AIM_CB_FAM_ADM, AIM_CB_ADM_INFOCHANGE_REPLY);
- }
- else
- {
- /* anything else -- usually used for login; just parse as pure TLVs */
-
- /*
- * Free up the loginstruct first.
- */
- if (aim_logininfo.screen_name)
- {
- free(aim_logininfo.screen_name);
- aim_logininfo.screen_name = NULL;
- }
- if (aim_logininfo.BOSIP)
- {
- free(aim_logininfo.BOSIP);
- aim_logininfo.BOSIP = NULL;
- }
- if (aim_logininfo.cookie)
- {
- free(aim_logininfo.cookie);
- aim_logininfo.cookie = NULL;
- }
- if (aim_logininfo.email)
- {
- free(aim_logininfo.email);
- aim_logininfo.email = NULL;
- }
- aim_logininfo.regstatus = 0;
-
- /* all this block does is figure out if it's an
- error or a success, nothing more */
- while (z < command->commandlen)
- {
- tlv = aim_grabtlvstr(&(command->data[z]));
- switch(tlv->type)
- {
- case 0x0001: /* screen name */
- aim_logininfo.screen_name = tlv->value;
- z += 2 + 2 + tlv->length;
- free(tlv);
- tlv = NULL;
- break;
- case 0x0004: /* error URL */
- errorurl = tlv->value;
- z += 2 + 2 + tlv->length;
- free(tlv);
- tlv = NULL;
- break;
- case 0x0005: /* BOS IP */
- aim_logininfo.BOSIP = tlv->value;
- z += 2 + 2 + tlv->length;
- free(tlv);
- tlv = NULL;
- break;
- case 0x0006: /* auth cookie */
- aim_logininfo.cookie = tlv->value;
- z += 2 + 2 + tlv->length;
- free(tlv);
- tlv=NULL;
- break;
- case 0x0011: /* email addy */
- aim_logininfo.email = tlv->value;
- z += 2 + 2 + tlv->length;
- free(tlv);
- tlv = NULL;
- break;
- case 0x0013: /* registration status */
- aim_logininfo.regstatus = *(tlv->value);
- z += 2 + 2 + tlv->length;
- aim_freetlv(&tlv);
- break;
- case 0x0008: /* error code */
- errorcode = *(tlv->value);
- z += 2 + 2 + tlv->length;
- aim_freetlv(&tlv);
- iserror = 1;
- break;
- default:
- z += 2 + 2 + tlv->length;
- aim_freetlv(&tlv);
- /* dunno */
- }
- }
+ char *msg;
+ int ret=1;
+ struct aim_tlvlist_t *tlvlist;
+ u_short id;
+
+ /*
+ * Dunno.
+ */
+ id = aimutil_get16(command->data+10);
+
+ /*
+ * TLVs follow
+ */
+ tlvlist = aim_readtlvchain(command->data+12, command->commandlen-12);
+
+ msg = aim_gettlv_str(tlvlist, 0x000b, 1);
+
+ userfunc = aim_callhandler(command->conn, 0x0001, 0x0013);
+ if (userfunc)
+ ret = userfunc(sess, command, id, msg);