From: Piotr S. <ps...@us...> - 2009-09-17 12:05:39
|
Update of /cvsroot/ayttm/ayttm/modules/icq/libicq In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12682/modules/icq/libicq Modified Files: config.c icq.h icqconfig.h icqfile.c libicq.c libicq.h receive.c receive.h send.c send.h tcp.c tcp.h util.c util.h Log Message: reformatted source code Index: config.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/config.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- config.c 1 Apr 2003 07:24:28 -0000 1.1.1.1 +++ config.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,7 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -39,230 +38,219 @@ int Get_Config_Info() { - char path[300]; + char path[300]; #if 0 #warning "Crashes" - ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Get_Config_Info"); + ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Get_Config_Info"); #endif #if defined( _WIN32 ) - strcpy( path, "C:" ); + strcpy(path, "C:"); #else - strcpy(path, getenv("HOME")); + strcpy(path, getenv("HOME")); #endif - strcat(path, "/.icq"); - mkdir(path, S_IRWXU); + strcat(path, "/.icq"); + mkdir(path, S_IRWXU); - strcpy(icq_rc, path); - strcat(icq_rc, "/icq.rc"); - if(Verbose & ICQ_VERB_INFO) - printf("ICQ.RC: %s\n", icq_rc); - - strcpy(contacts_rc, path); - strcat(contacts_rc, "/contacts.rc"); - if(Verbose & ICQ_VERB_INFO) - printf("CONTACTS.RC: %s\n", contacts_rc); - - if(!Read_ICQ_RC(icq_rc)) return 0; - Read_Contacts_RC(contacts_rc); - - return 1; -} + strcpy(icq_rc, path); + strcat(icq_rc, "/icq.rc"); + if (Verbose & ICQ_VERB_INFO) + printf("ICQ.RC: %s\n", icq_rc); + + strcpy(contacts_rc, path); + strcat(contacts_rc, "/contacts.rc"); + if (Verbose & ICQ_VERB_INFO) + printf("CONTACTS.RC: %s\n", contacts_rc); + + if (!Read_ICQ_RC(icq_rc)) + return 0; + Read_Contacts_RC(contacts_rc); + return 1; +} -int Read_ICQ_RC(char* filename) +int Read_ICQ_RC(char *filename) { - /* CfgVersion doesn't exist in older configuration files, but they should - still be read fine. It will add "Version 1" to them when saving them as - Version 1 is considered the version with a version tag. Enough of that. */ - - int CfgVersion = 0; - FILE* fp; - char buf[100], c; + /* CfgVersion doesn't exist in older configuration files, but they should + still be read fine. It will add "Version 1" to them when saving them as + Version 1 is considered the version with a version tag. Enough of that. */ + + int CfgVersion = 0; + FILE *fp; + char buf[100], c; #if 0 #warning "Crashes!" - ICQ_Debug(ICQ_VERB_INFO, "\nLIBICQ> Get_ICQ_RC"); + ICQ_Debug(ICQ_VERB_INFO, "\nLIBICQ> Get_ICQ_RC"); #endif - if(!(fp = fopen(filename, "rt"))) - { - if(UIN == 0) return 0; - - set_status = STATUS_ONLINE; - strcpy(server, "icq.mirabilis.com"); - remote_port = 4000; - - Write_ICQ_RC(filename); - return 1; - } - - while(!feof(fp)) - { - c = fgetc(fp); - if(c == '#') /* Comment */ - { - while(!feof(fp) && fgetc(fp) != '\n'); - continue; - } - else if(c == '\n') /* Blank line */ - { - continue; - } - else - { - ungetc(c, fp); - } - - fscanf(fp, "%s ", buf); - - if(CfgVersion >= 0) - { - /* In all cases, check for the following: */ - if (!strcmp(buf, "Version")) fscanf(fp, "%d\n", &CfgVersion); - else if(!strcmp(buf, "UIN")) fscanf(fp, "%d\n", &UIN); - else if(!strcmp(buf, "Password")) fscanf(fp, "%s\n", passwd); - else if(!strcmp(buf, "Status")) fscanf(fp, "%d\n", &set_status); - else if(!strcmp(buf, "Server")) fscanf(fp, "%s\n", server); - else if(!strcmp(buf, "Port")) fscanf(fp, "%d\n", &remote_port); - } - - if(CfgVersion > 0) - { - /* VER 1 This is the first version with the "Version" number */ - /* No features added with version 1 */ - } - - if(CfgVersion > 1) - { - /* Put new config information for version 2 in here */ - /* if (!strcmp(buf, "Whatever")) ... */ - } - } - - if(fclose(fp) != 0) - { - if(Verbose & ICQ_VERB_ERR) - printf("\nfclose (%s) failed.\n", filename); - return 0; - } + if (!(fp = fopen(filename, "rt"))) { + if (UIN == 0) + return 0; + + set_status = STATUS_ONLINE; + strcpy(server, "icq.mirabilis.com"); + remote_port = 4000; + + Write_ICQ_RC(filename); + return 1; + } + + while (!feof(fp)) { + c = fgetc(fp); + if (c == '#') { /* Comment */ + while (!feof(fp) && fgetc(fp) != '\n') ; + continue; + } else if (c == '\n') { /* Blank line */ + continue; + } else { + ungetc(c, fp); + } + + fscanf(fp, "%s ", buf); + + if (CfgVersion >= 0) { + /* In all cases, check for the following: */ + if (!strcmp(buf, "Version")) + fscanf(fp, "%d\n", &CfgVersion); + else if (!strcmp(buf, "UIN")) + fscanf(fp, "%d\n", &UIN); + else if (!strcmp(buf, "Password")) + fscanf(fp, "%s\n", passwd); + else if (!strcmp(buf, "Status")) + fscanf(fp, "%d\n", &set_status); + else if (!strcmp(buf, "Server")) + fscanf(fp, "%s\n", server); + else if (!strcmp(buf, "Port")) + fscanf(fp, "%d\n", &remote_port); + } + + if (CfgVersion > 0) { + /* VER 1 This is the first version with the "Version" number */ + /* No features added with version 1 */ + } + + if (CfgVersion > 1) { + /* Put new config information for version 2 in here */ + /* if (!strcmp(buf, "Whatever")) ... */ + } + } + + if (fclose(fp) != 0) { + if (Verbose & ICQ_VERB_ERR) + printf("\nfclose (%s) failed.\n", filename); + return 0; + } - return 1; + return 1; } - -void Write_ICQ_RC(char* filename) +void Write_ICQ_RC(char *filename) { - int CfgVersion = 1; // Current version - FILE* fp; + int CfgVersion = 1; // Current version + FILE *fp; - ICQ_Debug(ICQ_VERB_INFO, "\nLIBICQ> Write_ICQ_RC"); + ICQ_Debug(ICQ_VERB_INFO, "\nLIBICQ> Write_ICQ_RC"); - if(!(fp = fopen(filename, "wt"))) - { - ICQ_Debug(ICQ_VERB_ERR, "LIBICQ> failed to open file."); + if (!(fp = fopen(filename, "wt"))) { + ICQ_Debug(ICQ_VERB_ERR, "LIBICQ> failed to open file."); /*win32--#warning "FIXME: ... but we should return a value to know if we failed."*/ - return; - } + return; + } - fprintf(fp, "# ICQ connection settings\n\n"); - fprintf(fp, "Version %d\n", CfgVersion); - fprintf(fp, "UIN %d\n", UIN); - fprintf(fp, "Password %s\n", passwd); - fprintf(fp, "Status %d\n", set_status); - fprintf(fp, "Server %s\n", server); - fprintf(fp, "Port %d\n", remote_port); - - if (fclose (fp) != 0) - { - if(Verbose & ICQ_VERB_ERR) - printf("\nfclose (%s) failed.\n", filename); + fprintf(fp, "# ICQ connection settings\n\n"); + fprintf(fp, "Version %d\n", CfgVersion); + fprintf(fp, "UIN %d\n", UIN); + fprintf(fp, "Password %s\n", passwd); + fprintf(fp, "Status %d\n", set_status); + fprintf(fp, "Server %s\n", server); + fprintf(fp, "Port %d\n", remote_port); + + if (fclose(fp) != 0) { + if (Verbose & ICQ_VERB_ERR) + printf("\nfclose (%s) failed.\n", filename); /* Void Function ... but we should return a value to know if we failed. return PROBLEM!; */ - } + } } - -int Read_Contacts_RC(char* filename) +int Read_Contacts_RC(char *filename) { - FILE* fp; - char buf[100], c; + FILE *fp; + char buf[100], c; - Num_Contacts = 0; + Num_Contacts = 0; #if 0 #warning "Crashes!" - ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Read_Contacts_RC"); + ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Read_Contacts_RC"); #endif - if(!(fp = fopen(filename, "rt"))) return 0; + if (!(fp = fopen(filename, "rt"))) + return 0; - while(!feof(fp)) - { - c = fgetc(fp); - if(c == '#') - { - fgets(buf, 100, fp); - continue; - } - else if(feof(fp)) - break; - else if(c == '\n') - continue; - else - ungetc(c, fp); - - fscanf(fp, "%d ", &Contacts[Num_Contacts].uin); - fgets(buf, 100, fp); - buf[strlen(buf) - 1] = '\0'; - strncpy(Contacts[Num_Contacts].nick, buf, 20); - Contacts[Num_Contacts].status = STATUS_OFFLINE; - Contacts[Num_Contacts].last_time = -1L; - Contacts[Num_Contacts].current_ip = -1L; - Contacts[Num_Contacts].tcp_sok = -1L; - Contacts[Num_Contacts].tcp_port = 0; - Contacts[Num_Contacts].tcp_status = TCP_NOT_CONNECTED; - Contacts[Num_Contacts].chat_sok = -1L; - Contacts[Num_Contacts].chat_port = 0; - Contacts[Num_Contacts].chat_status = TCP_NOT_CONNECTED; - Contacts[Num_Contacts].chat_active = FALSE; - Contacts[Num_Contacts].chat_active2 = FALSE; - Num_Contacts++; - } - - if(fclose(fp) != 0) - { - if(Verbose & ICQ_VERB_ERR) - printf("\nfclose (%s) failed.\n", filename); - return 0; - } - - return 1; -} + while (!feof(fp)) { + c = fgetc(fp); + if (c == '#') { + fgets(buf, 100, fp); + continue; + } else if (feof(fp)) + break; + else if (c == '\n') + continue; + else + ungetc(c, fp); + + fscanf(fp, "%d ", &Contacts[Num_Contacts].uin); + fgets(buf, 100, fp); + buf[strlen(buf) - 1] = '\0'; + strncpy(Contacts[Num_Contacts].nick, buf, 20); + Contacts[Num_Contacts].status = STATUS_OFFLINE; + Contacts[Num_Contacts].last_time = -1L; + Contacts[Num_Contacts].current_ip = -1L; + Contacts[Num_Contacts].tcp_sok = -1L; + Contacts[Num_Contacts].tcp_port = 0; + Contacts[Num_Contacts].tcp_status = TCP_NOT_CONNECTED; + Contacts[Num_Contacts].chat_sok = -1L; + Contacts[Num_Contacts].chat_port = 0; + Contacts[Num_Contacts].chat_status = TCP_NOT_CONNECTED; + Contacts[Num_Contacts].chat_active = FALSE; + Contacts[Num_Contacts].chat_active2 = FALSE; + Num_Contacts++; + } + + if (fclose(fp) != 0) { + if (Verbose & ICQ_VERB_ERR) + printf("\nfclose (%s) failed.\n", filename); + return 0; + } + return 1; +} -void Write_Contacts_RC(char* filename) +void Write_Contacts_RC(char *filename) { - FILE* fp; - int x; - - ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Write_Contacts_RC"); - - if(!(fp = fopen(filename, "wt"))) return; - - fprintf(fp, "# ICQ contact list\n\n"); - - for(x = 0; x < Num_Contacts; x++) - if((Contacts[x].uin > 0) && (strlen(Contacts[x].nick) > 0) - && (Contacts[x].status != STATUS_NOT_IN_LIST)) - fprintf(fp, "%d %s\n", Contacts[x].uin, Contacts[x].nick); - - if(fclose (fp) != 0) - { - if(Verbose & ICQ_VERB_ERR) - printf("\nfclose (%s) failed.\n", filename); + FILE *fp; + int x; + + ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Write_Contacts_RC"); + + if (!(fp = fopen(filename, "wt"))) + return; + + fprintf(fp, "# ICQ contact list\n\n"); + + for (x = 0; x < Num_Contacts; x++) + if ((Contacts[x].uin > 0) && (strlen(Contacts[x].nick) > 0) + && (Contacts[x].status != STATUS_NOT_IN_LIST)) + fprintf(fp, "%d %s\n", Contacts[x].uin, + Contacts[x].nick); + + if (fclose(fp) != 0) { + if (Verbose & ICQ_VERB_ERR) + printf("\nfclose (%s) failed.\n", filename); // Void function ... but we should return a value to know if we failed // return 0; - } + } } Index: icq.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/icq.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- icq.h 1 Apr 2003 07:24:28 -0000 1.1.1.1 +++ icq.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __ICQ_H__ #define __ICQ_H__ @@ -37,50 +36,44 @@ #define PACKET_DIRECTION_SEND 4 #define PACKET_DIRECTION_RECEIVE 8 - -typedef struct -{ - guint8 dummy[2]; /* to fix alignment problem */ - guint8 ver[2]; - guint8 rand[2]; - guint8 zero[2]; - guint8 cmd[2]; - guint8 seq[2]; - guint8 seq2[2]; - guint8 UIN[4]; - guint8 checkcode[4]; +typedef struct { + guint8 dummy[2]; /* to fix alignment problem */ + guint8 ver[2]; + guint8 rand[2]; + guint8 zero[2]; + guint8 cmd[2]; + guint8 seq[2]; + guint8 seq2[2]; + guint8 UIN[4]; + guint8 checkcode[4]; } ICQ_pak, *ICQ_PAK_PTR; -typedef struct -{ - guint16 dummy; /* to fix alignment problem */ - guint8 ver[2]; - guint8 cmd[2]; - guint8 seq[2]; - guint8 seq2[2]; - guint8 UIN[4]; - guint8 check[4]; +typedef struct { + guint16 dummy; /* to fix alignment problem */ + guint8 ver[2]; + guint8 cmd[2]; + guint8 seq[2]; + guint8 seq2[2]; + guint8 UIN[4]; + guint8 check[4]; } SRV_ICQ_pak, *SRV_ICQ_PAK_PTR; - -typedef struct -{ - ICQ_pak head; - unsigned char data[1024]; +typedef struct { + ICQ_pak head; + unsigned char data[1024]; } net_icq_pak, *NET_ICQ_PTR; -typedef struct -{ - SRV_ICQ_pak head; - unsigned char data[1024]; +typedef struct { + SRV_ICQ_pak head; + unsigned char data[1024]; } srv_net_icq_pak, *SRV_NET_ICQ_PTR; -#define CMD_ACK 0x000A /* Just an acknowledgement */ +#define CMD_ACK 0x000A /* Just an acknowledgement */ #define CMD_SENDM 0x010E #define CMD_LOGIN 0x03E8 /* Send password and port to server */ #define CMD_REG_NEW_USER 0x03FC /* Send password (after 04EC) for new */ #define CMD_NEW_USER_REG 0x03FC -#define CMD_CONT_LIST 0x0406 /* Send list of users for status check*/ +#define CMD_CONT_LIST 0x0406 /* Send list of users for status check */ #define CMD_SEARCH_UIN 0x041a #define CMD_SEARCH_USER 0x0424 #define CMD_KEEP_ALIVE 0x042e /* Keep alive */ @@ -93,7 +86,7 @@ #define CMD_CHANGE_PW 0x049c #define CMD_ACK_MESSAGES 0x0442 #define CMD_NEW_USER_INFO 0x04A6 /* Request info on a new user */ -#define CMD_UPDATE_EXT_INFO 0x04B0 /* Rest of info (new user) after 00B4*/ +#define CMD_UPDATE_EXT_INFO 0x04B0 /* Rest of info (new user) after 00B4 */ #define CMD_QUERY_SERVERS 0x04BA /* Send after 04C4 when creating new */ #define CMD_QUERY_ADDONS 0x04C4 /* Send after 044C when creating new */ #define CMD_STATUS_CHANGE 0x04D8 @@ -128,27 +121,25 @@ #define SRV_STATUS_UPDATE 0x01A4 #define SRV_SYSTEM_MESSAGE 0x01C2 #define SRV_UPDATE 0x01E0 -#define SRV_X1 0x021C /* Received after 0212 when create ID*/ +#define SRV_X1 0x021C /* Received after 0212 when create ID */ #define SRV_MULTI_PACKET 0x0212 /* Full / user / app info receive */ #define SRV_RND_USER_INFO 0x024E /* Receive info on random user */ #define SRV_BAD_PASS 0x6400 -typedef struct -{ - guint8 time[4]; - guint8 port[4]; - guint8 len[2]; +typedef struct { + guint8 time[4]; + guint8 port[4]; + guint8 len[2]; } login_1, *LOGIN_1_PTR; -typedef struct -{ - guint8 X1[4]; - guint8 ip[4]; - guint8 X2[1]; - guint8 status[4]; - guint8 X3[4]; - guint8 X4[4]; - guint8 X5[4]; +typedef struct { + guint8 X1[4]; + guint8 ip[4]; + guint8 X2[1]; + guint8 status[4]; + guint8 X3[4]; + guint8 X4[4]; + guint8 X5[4]; } login_2, *LOGIN_2_PTR; #define LOGIN_X1_DEF 0x00000098 @@ -158,24 +149,21 @@ //#define LOGIN_X5_DEF 0x00980000 #define LOGIN_X5_DEF 0x00980010 - -typedef struct -{ - guint8 uin[4]; - guint8 year[2]; - guint8 month; - guint8 day; - guint8 hour; - guint8 minute; - guint8 type[2]; - guint8 len[2]; +typedef struct { + guint8 uin[4]; + guint8 year[2]; + guint8 month; + guint8 day; + guint8 hour; + guint8 minute; + guint8 type[2]; + guint8 len[2]; } RECV_MESSAGE, *RECV_MESSAGE_PTR; -typedef struct -{ - guint8 uin[4]; - guint8 type[2]; - guint8 len[2]; +typedef struct { + guint8 uin[4]; + guint8 type[2]; + guint8 len[2]; } SIMPLE_MESSAGE, *SIMPLE_MESSAGE_PTR; -#endif /* __ICQ_H__ */ +#endif /* __ICQ_H__ */ Index: icqconfig.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/icqconfig.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- icqconfig.h 1 Apr 2003 07:24:30 -0000 1.1.1.1 +++ icqconfig.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,14 +14,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __FILE_IO_H__ #define __FILE_IO_H__ int Get_Config_Info(); -int Read_ICQ_RC(char* filename); -void Write_ICQ_RC(char* filename); -int Read_Contacts_RC(char* filename); -void Write_Contacts_RC(char* filename); +int Read_ICQ_RC(char *filename); +void Write_ICQ_RC(char *filename); +int Read_Contacts_RC(char *filename); +void Write_Contacts_RC(char *filename); -#endif /* __FILE_IO_H__ */ +#endif /* __FILE_IO_H__ */ Index: icqfile.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/icqfile.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- icqfile.c 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ icqfile.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -55,10 +55,9 @@ #define ICQ_FILE_VERSION htons(0x0300) #define COMMAND_SENDFILE htons(0xee07) -typedef struct _ICQPacket -{ +typedef struct _ICQPacket { /* Packet 2 Header */ - unsigned long SourceUIN; + unsigned long SourceUIN; unsigned short ICQVersion; unsigned long Command; unsigned short CommentLength; @@ -67,55 +66,56 @@ unsigned long Unknown1b; unsigned long Unknown2b; unsigned long FileNameLength; - unsigned char Unknown4b; + unsigned char Unknown4b; unsigned long FileSize; unsigned long Unknown1c; - unsigned long Unknown2c; /* Sender status ?*/ + unsigned long Unknown2c; /* Sender status ? */ short FirstHeaderSize; unsigned short SecondHeaderSize; unsigned short DestinationPort; - - char header[8]; + + char header[8]; char header2[3]; char intPad[4]; char shortPad[2]; char charPad[1]; - + char fileName[1024]; char comment[1024]; } ICQPacket; - - void exchangeName(ICQPacket * this, int sock ); - void writePacket( ICQPacket * this, int sock ); - void readResponse( ICQPacket * this, int sock, ICQPacket* pPkt ); - void readNameExchange( ICQPacket * this, int sock, ICQPacket* pPkt ); - void sendFilePreamble( ICQPacket * this, int sock ); - void readFilePreamble (ICQPacket * this, int sock); - void sendFile( ICQPacket * this, int sock ); -void initilizePKT(ICQPacket * pkt ) +void exchangeName(ICQPacket *this, int sock); +void writePacket(ICQPacket *this, int sock); +void readResponse(ICQPacket *this, int sock, ICQPacket *pPkt); +void readNameExchange(ICQPacket *this, int sock, ICQPacket *pPkt); +void sendFilePreamble(ICQPacket *this, int sock); +void readFilePreamble(ICQPacket *this, int sock); +void sendFile(ICQPacket *this, int sock); + +void initilizePKT(ICQPacket *pkt) { pkt->FirstHeaderSize = 0x1a; pkt->header[0] = 0xff; pkt->header[1] = 0x03; pkt->header[2] = 0x00; - pkt->header[3] = pkt->header[4] = pkt->header[5] - = pkt->header[6] = pkt->header[7] - = pkt->header[8] = 0x00; + pkt->header[3] = pkt->header[4] = pkt->header[5] + = pkt->header[6] = pkt->header[7] + = pkt->header[8] = 0x00; pkt->header2[0] = 0x04; pkt->header2[1] = pkt->header2[2] = 0x00; - pkt->intPad[0] = pkt->intPad[1] = pkt->intPad[2] = pkt->intPad[3] = 0x00; + pkt->intPad[0] = pkt->intPad[1] = pkt->intPad[2] = pkt->intPad[3] = + 0x00; pkt->shortPad[0] = pkt->shortPad[1] = 0x00; pkt->charPad[0] = 0x00; } -void writePacket(ICQPacket * this, int sock) +void writePacket(ICQPacket *this, int sock) { char buffer[65537]; int offset = 0; - + memcpy(buffer, this->header, 9); offset += 9; memcpy(buffer + offset, &(this->SourceUIN), sizeof(unsigned long)); @@ -128,9 +128,9 @@ offset += sizeof(unsigned short); memcpy(buffer + offset, &(this->header2), 3); offset += 3; - + offset += sizeof(unsigned short); - + memcpy(buffer + offset, &(this->SourceUIN), sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->ICQVersion), sizeof(unsigned short)); @@ -143,11 +143,11 @@ offset += sizeof(unsigned short); memcpy(buffer + offset, &(this->CommentLength), sizeof(unsigned short)); offset += sizeof(unsigned short); - + memcpy(buffer + offset, this->comment, strlen(this->comment)); offset += strlen(this->comment); - buffer[offset++] = 0x0; - + buffer[offset++] = 0x0; + memcpy(buffer + offset, &(this->SenderIP), sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->SenderIP), sizeof(unsigned long)); @@ -162,53 +162,56 @@ offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->Unknown4b), sizeof(unsigned char)); offset += sizeof(unsigned char); - + memcpy(buffer + offset, this->fileName, strlen(this->fileName)); offset += strlen(this->fileName); - buffer[offset++] = 0x0; - + buffer[offset++] = 0x0; + memcpy(buffer + offset, &(this->FileSize), sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->Unknown1c), sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->Unknown2c), sizeof(unsigned long)); offset += sizeof(unsigned long); - + this->SecondHeaderSize = offset - this->FirstHeaderSize - 2; - memcpy(buffer + 0x1a, &(this->SecondHeaderSize), sizeof(unsigned short)); - - write(sock, (void const *)&(this->FirstHeaderSize), sizeof(unsigned short)); + memcpy(buffer + 0x1a, &(this->SecondHeaderSize), + sizeof(unsigned short)); + + write(sock, (void const *)&(this->FirstHeaderSize), + sizeof(unsigned short)); write(sock, (void const *)buffer, offset); - + } -void exchangeName( ICQPacket * this, int sock ) +void exchangeName(ICQPacket *this, int sock) { - char local_header[] = {0xff, 0x03, 0x00, 0x00, 0x00}; - char local_header2[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}; - char local_header3[] = {0x64, 0x00, 0x00, 0x00}; + char local_header[] = { 0xff, 0x03, 0x00, 0x00, 0x00 }; + char local_header2[] = + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; + char local_header3[] = { 0x64, 0x00, 0x00, 0x00 }; // local_this->header3 is the speed in percent (0 - 100) // bytes 6 thru 9 of local_this->header2 is the number of files to send. - + char buffer[65537]; int offset = 0; - + // make username equal to UIN char userName[1024]; unsigned short userNameLength; this->FirstHeaderSize = 0x1a; - + memcpy(buffer, &local_header, 5); offset += 5; - this->SenderPort --; + this->SenderPort--; memcpy(buffer + offset, &(this->SenderPort), sizeof(unsigned short)); offset += sizeof(unsigned short); - offset += 2; // skip over 0x00, 0x00 - + offset += 2; // skip over 0x00, 0x00 + memcpy(buffer + offset, &(this->SourceUIN), sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(buffer + offset, &(this->SenderIP), sizeof(unsigned long)); @@ -220,10 +223,10 @@ memcpy(buffer + offset, &(this->header2), 3); offset += 3; - this->SenderPort ++; // set senderport back to actual port + this->SenderPort++; // set senderport back to actual port + + offset += 2; // skip over rest of file length. - offset += 2; // skip over rest of file length. - memcpy(buffer + offset, &local_header2, 9); offset += 9; memcpy(buffer + offset, &(this->FileSize), sizeof(unsigned long)); @@ -231,19 +234,21 @@ memcpy(buffer + offset, &local_header3, 4); offset += 4; - sprintf(userName, "%ld", this->SourceUIN); + sprintf(userName, "%ld", this->SourceUIN); userNameLength = strlen(userName); - + memcpy(buffer + offset, &userNameLength, sizeof(unsigned short)); offset += sizeof(unsigned short); memcpy(buffer + offset, &userName, userNameLength); offset += userNameLength; buffer[offset++] = 0x0; - + this->SecondHeaderSize = offset - this->FirstHeaderSize - 2; - memcpy(buffer + 0x1a, &(this->SecondHeaderSize), sizeof(unsigned short)); - - write(sock, (void const *)&(this->FirstHeaderSize), sizeof(unsigned short)); + memcpy(buffer + 0x1a, &(this->SecondHeaderSize), + sizeof(unsigned short)); + + write(sock, (void const *)&(this->FirstHeaderSize), + sizeof(unsigned short)); write(sock, (void const *)buffer, offset); @@ -252,12 +257,13 @@ /* Set up this->fileName, fileSize, * */ -void sendFilePreamble( ICQPacket * this, int sock ) +void sendFilePreamble(ICQPacket *this, int sock) { - char local_header[] = {0x02, 0x00}; - char local_header2[] = {0x01, 0x00, 0x00}; // file number? + char local_header[] = { 0x02, 0x00 }; + char local_header2[] = { 0x01, 0x00, 0x00 }; // file number? char buffer[65537]; - unsigned long offset = 0, speed = 100, fileNameLength = strlen(this->fileName) + 1; + unsigned long offset = 0, speed = 100, fileNameLength = + strlen(this->fileName) + 1; unsigned long Unknown1 = 0x0; unsigned short nextPacketSize; @@ -268,7 +274,7 @@ memcpy(buffer + offset, &(this->fileName), fileNameLength - 1); offset += fileNameLength - 1; buffer[offset++] = 0x0; - memcpy (buffer+offset, local_header2, 3); + memcpy(buffer + offset, local_header2, 3); offset += 3; memcpy(buffer + offset, &(this->FileSize), sizeof(unsigned long)); offset += sizeof(unsigned long); @@ -276,350 +282,338 @@ offset += sizeof(unsigned long); memcpy(buffer + offset, &speed, sizeof(unsigned long)); offset += sizeof(unsigned long); - - nextPacketSize = (unsigned short)offset; - write(sock, (void*)&nextPacketSize, sizeof(unsigned short)); - write(sock, (void*)buffer, nextPacketSize); - + + nextPacketSize = (unsigned short)offset; + write(sock, (void *)&nextPacketSize, sizeof(unsigned short)); + write(sock, (void *)buffer, nextPacketSize); + } -void readNameExchange( ICQPacket * this, int sock, ICQPacket* pPkt ) +void readNameExchange(ICQPacket *this, int sock, ICQPacket *pPkt) { unsigned short nextPacketSize; int offset = 0; int connectionSpeed = 0; char constant; - char *buffer; - read(sock, (void*)&nextPacketSize, sizeof(unsigned short)); + char *buffer; + read(sock, (void *)&nextPacketSize, sizeof(unsigned short)); buffer = malloc(nextPacketSize); - if(buffer){ - read(sock, (void*)buffer, nextPacketSize); - + if (buffer) { + read(sock, (void *)buffer, nextPacketSize); + memcpy(&constant, buffer + offset, 1); offset += 1; - - memcpy(&connectionSpeed, buffer + offset, sizeof(unsigned long)); + + memcpy(&connectionSpeed, buffer + offset, + sizeof(unsigned long)); offset += sizeof(unsigned long); - memcpy(&pPkt->CommentLength, buffer + offset, sizeof(unsigned short)); + memcpy(&pPkt->CommentLength, buffer + offset, + sizeof(unsigned short)); offset += sizeof(unsigned short); memcpy(&pPkt->comment, buffer + offset, pPkt->CommentLength); offset += pPkt->CommentLength; pPkt->comment[pPkt->CommentLength] = 0x0; - + printf("Sending file to %s:", pPkt->comment); fflush(stdout); - + free(buffer); + } else { + printf("Error allocating buffer in readNameExchange.\n"); } - else - { - printf("Error allocating buffer in readNameExchange.\n"); - } } -void readFilePreamble (ICQPacket * this, int sock) +void readFilePreamble(ICQPacket *this, int sock) { unsigned short nextPacketSize; unsigned long unknown1, unknown2; int offset = 0; int connectionSpeed = 0; char constant; - char *buffer; - read(sock, (void*)&nextPacketSize, sizeof(unsigned short)); + char *buffer; + read(sock, (void *)&nextPacketSize, sizeof(unsigned short)); buffer = malloc(nextPacketSize); - if(buffer){ - read(sock, (void*)buffer, nextPacketSize); - + if (buffer) { + read(sock, (void *)buffer, nextPacketSize); + memcpy(&constant, buffer + offset, 1); offset += 1; - + memcpy(&unknown1, buffer + offset, sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(&unknown2, buffer + offset, sizeof(unsigned long)); offset += sizeof(unsigned short); - memcpy(&connectionSpeed, buffer + offset, sizeof(unsigned long)); + memcpy(&connectionSpeed, buffer + offset, + sizeof(unsigned long)); offset += sizeof(unsigned long); - + free(buffer); - } - else{ + } else { printf("Error allocating buffer in readNameExchange.\n"); } - - + } -void sendFile(ICQPacket * this, int sock ) +void sendFile(ICQPacket *this, int sock) { char *fileBuffer = malloc(this->FileSize); unsigned char constant = 0x06; int remainingBytes = this->FileSize, offset = 0; unsigned short nextPacketSize; - - if( fileBuffer ) - { - int fd = open( this->fileName, O_RDONLY); - if ( fd == -1 ) - { + + if (fileBuffer) { + int fd = open(this->fileName, O_RDONLY); + if (fd == -1) { perror("open in sendFile"); - } - else - { - int status = read( fd, fileBuffer, this->FileSize ); - if( status == -1 ) - { + } else { + int status = read(fd, fileBuffer, this->FileSize); + if (status == -1) { perror("read in sendfile"); - } - else - { + } else { int firstPacket = 1; fflush(stdout); - do - { + do { char b[2051]; unsigned short temp; - - if(remainingBytes < 2048) + + if (remainingBytes < 2048) nextPacketSize = remainingBytes; else nextPacketSize = 2048; - if( firstPacket ) - { + if (firstPacket) { firstPacket = 0; temp = nextPacketSize + 1; - write(sock, &temp, sizeof(unsigned short)); + write(sock, &temp, + sizeof(unsigned short)); b[0] = constant; - memcpy(&b[1], fileBuffer + offset, nextPacketSize); + memcpy(&b[1], + fileBuffer + offset, + nextPacketSize); offset += nextPacketSize; - remainingBytes -= nextPacketSize; - write(sock, b, nextPacketSize + 1); - } - else - { + remainingBytes -= + nextPacketSize; + write(sock, b, + nextPacketSize + 1); + } else { temp = nextPacketSize + 1; - memcpy(b, &temp, sizeof(unsigned short)); + memcpy(b, &temp, + sizeof(unsigned short)); b[2] = constant; - memcpy(&b[3], fileBuffer + offset, nextPacketSize); + memcpy(&b[3], + fileBuffer + offset, + nextPacketSize); offset += nextPacketSize; - remainingBytes -= nextPacketSize; - write(sock, b, nextPacketSize + 3); + remainingBytes -= + nextPacketSize; + write(sock, b, + nextPacketSize + 3); } printf("."); fflush(stdout); - } while ( remainingBytes ); + } while (remainingBytes); printf("\nFile sent.\n"); - + } - free(fileBuffer); + free(fileBuffer); } - } - else - { + } else { printf("Error allocating memory for fileBuffer in sendFile.\n"); } } -void readResponse( ICQPacket * this, int sock, ICQPacket* pPkt ) +void readResponse(ICQPacket *this, int sock, ICQPacket *pPkt) { unsigned short nextPacketSize; int offset = 0; - char *buf; + char *buf; unsigned short FileLength; read(sock, (void *)&nextPacketSize, sizeof(unsigned short)); - + buf = malloc(nextPacketSize); - if(buf) { + if (buf) { unsigned long reject; - + read(sock, (void *)buf, nextPacketSize); - + memcpy(&pPkt->SourceUIN, &buf[offset], sizeof(unsigned long)); offset += sizeof(unsigned long); memcpy(&pPkt->ICQVersion, &buf[offset], sizeof(unsigned short)); offset += sizeof(unsigned short); - if(pPkt->ICQVersion != ICQ_FILE_VERSION) + if (pPkt->ICQVersion != ICQ_FILE_VERSION) printf("Version differences: target 0x%x, actual 0x%x.\n", ICQ_FILE_VERSION, pPkt->ICQVersion); memcpy(&pPkt->Command, &buf[offset], sizeof(unsigned long)); offset += sizeof(unsigned long); - offset += sizeof(unsigned long); // skip over the 2nd UIN - offset += sizeof(unsigned short); // skip over the 2nd version - memcpy(&pPkt->CommentLength, &buf[offset], sizeof(unsigned short)); + offset += sizeof(unsigned long); // skip over the 2nd UIN + offset += sizeof(unsigned short); // skip over the 2nd version + memcpy(&pPkt->CommentLength, &buf[offset], + sizeof(unsigned short)); offset += sizeof(unsigned short); memcpy(&pPkt->comment, &buf[offset], pPkt->CommentLength); offset += pPkt->CommentLength; - - + memcpy(&pPkt->SenderIP, &buf[offset], sizeof(unsigned long)); offset += sizeof(unsigned long); - offset += sizeof(unsigned long); // skip over 2nd IP + offset += sizeof(unsigned long); // skip over 2nd IP memcpy(&pPkt->SenderPort, &buf[offset], sizeof(unsigned short)); offset += sizeof(unsigned short); - offset += 3; // skip junk 0x00, 0x00, 0x04 + offset += 3; // skip junk 0x00, 0x00, 0x04 memcpy(&reject, &buf[offset], sizeof(unsigned long)); offset += sizeof(unsigned long); - - if(!reject) + + if (!reject) printf("Connection accepted.\n"); - else - { + else { printf("Connection REJECTED.\n"); printf("Comment: %s\n", pPkt->comment); } - offset += sizeof(unsigned short); // skip over dest port - - offset += sizeof(unsigned short); // skip 2 bytes 0x00, 0x00 - + offset += sizeof(unsigned short); // skip over dest port + + offset += sizeof(unsigned short); // skip 2 bytes 0x00, 0x00 + //memcpy(&pPkt->FileNameLength, &buf[offset], sizeof(unsigned short)); memcpy(&FileLength, &buf[offset], sizeof(unsigned short)); pPkt->FileNameLength = FileLength; offset += sizeof(unsigned short); - fprintf(stderr, "Copying %ld bytes to copy %s\n", pPkt->FileNameLength, - &buf[offset] ); - + fprintf(stderr, "Copying %ld bytes to copy %s\n", + pPkt->FileNameLength, &buf[offset]); + memcpy(&pPkt->fileName, &buf[offset], pPkt->FileNameLength); offset += pPkt->FileNameLength; - - offset += sizeof(unsigned long); // skip 4 bytes 0x00, 0x00, 0x00, 0x00 - - memcpy(&pPkt->DestinationPort, &buf[offset], sizeof(unsigned short)); + + offset += sizeof(unsigned long); // skip 4 bytes 0x00, 0x00, 0x00, 0x00 + + memcpy(&pPkt->DestinationPort, &buf[offset], + sizeof(unsigned short)); offset += sizeof(unsigned short); - + free(buf); - - } - else { + + } else { printf("Error allocating memory.\n"); - } + } } - -int ICQSendFile(const char * ip, const char * port, const char * uin, const char * fileName, const char * comment) +int ICQSendFile(const char *ip, const char *port, const char *uin, + const char *fileName, const char *comment) { - struct sockaddr_in sin, sout, sin2, sout2; + struct sockaddr_in sin, sout, sin2, sout2; struct stat st; - - + int sock, x; int nameSize; - int fileSize=0; + int fileSize = 0; int sock2; ICQPacket pkt, pkt2, pkt3; initilizePKT(&pkt); initilizePKT(&pkt2); initilizePKT(&pkt3); - fprintf( stderr, "ip = %s port = %s\n", ip, port ); + fprintf(stderr, "ip = %s port = %s\n", ip, port); //comment[0] = 0; -// { -// printf(" ICQ File Spoofer\n"); -// printf("usage: %s ip port SpoofedUIN file \"comment\"\n", argv[0]); +// { +// printf(" ICQ File Spoofer\n"); +// printf("usage: %s ip port SpoofedUIN file \"comment\"\n", argv[0]); // } - - if( stat(fileName, &st) != -1) - { - fileSize = st.st_size; - } - else - { - perror("stat"); - /* exit(1); */ - } - + + if (stat(fileName, &st) != -1) { + fileSize = st.st_size; + } else { + perror("stat"); + /* exit(1); */ + } + /* make a socket */ if (!(sock = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket"); return (0); } - + /* set some stuff up */ sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(ip); sin.sin_port = htons(atol(port)); - + /* connect to the victim */ - if (connect(sock, (struct sockaddr*)&sin,sizeof(sin))==-1) { + if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1) { perror("connect"); return (0); } nameSize = sizeof(struct sockaddr); - getsockname(sock, (struct sockaddr*)&sout, &nameSize); - + getsockname(sock, (struct sockaddr *)&sout, &nameSize); + /* make our payload */ x = -1; - - - pkt.SourceUIN = atoi(uin); + + pkt.SourceUIN = atoi(uin); pkt.ICQVersion = ICQ_FILE_VERSION; pkt.Command = COMMAND_SENDFILE; pkt.CommentLength = strlen(comment) + 1; - pkt.Unknown1b = 0x00040000; pkt.Unknown2b = 0x00001000; pkt.FileNameLength = htonl(strlen(fileName) + 1); pkt.Unknown4b = 0x00; - + pkt.FileSize = fileSize; pkt.Unknown1c = 0x0000; pkt.Unknown2c = 0xFFFFFFA0; strcpy(pkt.fileName, fileName); strcpy(pkt.comment, comment); - + writePacket(&pkt, sock); printf("Waiting for acceptance.\n"); readResponse(&pkt, sock, &pkt2); - - /* make a socket */ + /* make a socket */ if (!(sock2 = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket2"); return (0); } - + /* set some stuff up */ sin2.sin_family = AF_INET; sin2.sin_addr.s_addr = inet_addr(ip); sin2.sin_port = htons(pkt2.DestinationPort); - + /* connect to the victim */ - if (connect(sock2, (struct sockaddr*)&sin2,sizeof(sin2))==-1) { + if (connect(sock2, (struct sockaddr *)&sin2, sizeof(sin2)) == -1) { perror("connect"); return (0); } nameSize = sizeof(struct sockaddr); - getsockname(sock2, (struct sockaddr*)&sout2, &nameSize); + getsockname(sock2, (struct sockaddr *)&sout2, &nameSize); pkt3.SenderIP = sout2.sin_addr.s_addr; - pkt3.SenderPort = ntohs( sout2.sin_port ); + pkt3.SenderPort = ntohs(sout2.sin_port); pkt3.SourceUIN = atoi(uin); pkt3.FileSize = fileSize; - exchangeName(&pkt3, sock2 ); + exchangeName(&pkt3, sock2); - readNameExchange(&pkt3, sock2, &pkt2 ); + readNameExchange(&pkt3, sock2, &pkt2); pkt3.FileSize = fileSize; strcpy(pkt3.fileName, fileName); - sendFilePreamble(&pkt3, sock2 ); + sendFilePreamble(&pkt3, sock2); - readFilePreamble(&pkt3, sock2 ); + readFilePreamble(&pkt3, sock2); + + sendFile(&pkt3, sock2); - sendFile (&pkt3, sock2 ); - close(sock2); - - close(sock); - return (0); + + close(sock); + return (0); } Index: libicq.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/libicq.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- libicq.c 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ libicq.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -18,7 +18,7 @@ #include "config.h" #endif -#include <errno.h> +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -31,7 +31,7 @@ #include <io.h> #include <time.h> [...1184 lines suppressed...] + if (curr_msg->type == MSG_MESS) + Send_Message(c->uin, curr_msg->text); + else if (curr_msg->type == URL_MESS) + Send_URL(c->uin, curr_msg->url, curr_msg->text); - g_free(curr_msg->text); - g_free(curr_msg->url); - g_free(curr_msg); + g_free(curr_msg->text); + g_free(curr_msg->url); + g_free(curr_msg); - c->messages = g_list_remove_link(c->messages, g_list_first(c->messages)); - } + c->messages = + g_list_remove_link(c->messages, + g_list_first(c->messages)); + } } - Index: libicq.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/libicq.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- libicq.h 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ libicq.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,11 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __LIBICQ_H__ #define __LIBICQ_H__ -#define STATUS_NOT_IN_LIST (guint32)(-3L) /* This is a made-up number */ +#define STATUS_NOT_IN_LIST (guint32)(-3L) /* This is a made-up number */ #define STATUS_OFFLINE (guint32)(-1L) #define STATUS_ONLINE 0x0000 #define STATUS_INVISIBLE 0x0100 @@ -35,12 +34,10 @@ #define USER_ADDED_MESS 0x000C #define CONTACT_MESS 0x0013 - -#define AWAY_MESS 0x1001 /* These are made-up numbers */ +#define AWAY_MESS 0x1001 /* These are made-up numbers */ #define CHAT_MESS 0x1002 #define FILE_MESS 0x1003 - /* to go with the new int version of Verbose */ #define ICQ_VERB_NONE 0 // show no messages #define ICQ_VERB_ERR (1<<0) // show only errors @@ -62,99 +59,91 @@ #define ICQ_MAX_CONTACTS 255 // maximum contacts -typedef struct -{ - guint32 uin; - gint year; - gint month; - gint day; - gint hour; - gint minute; - gint type; - gint32 len; - gchar* msg; - gchar* url; - gchar* filename; - guint32 file_size; - guint32 seq; +typedef struct { + guint32 uin; + gint year; + gint month; + gint day; + gint hour; + gint minute; + gint type; + gint32 len; + gchar *msg; + gchar *url; + gchar *filename; + guint32 file_size; + guint32 seq; } CLIENT_MESSAGE, *CLIENT_MESSAGE_PTR; -typedef struct -{ - guint32 uin; - gchar nick[20]; - guint32 status; +typedef struct { + guint32 uin; + gchar nick[20]; + guint32 status; } USER_UPDATE, *USER_UPDATE_PTR; -typedef struct -{ - guint32 uin; - gchar nick[20]; - gchar first[50]; - gchar last[50]; - gchar email[50]; - gint auth_required; +typedef struct { + guint32 uin; + gchar nick[20]; + gchar first[50]; + gchar last[50]; + gchar email[50]; + gint auth_required; } USER_INFO, *USER_INFO_PTR; -typedef struct -{ - guint32 uin; - gchar city[50]; - gchar country[50]; - gint country_code; - gint country_status; - gchar state[50]; - gchar age[15]; - gchar sex[15]; - gchar phone[15]; - gchar url[150]; - gchar about[1000]; +typedef struct { + guint32 uin; + gchar city[50]; + gchar country[50]; + gint country_code; + gint country_status; + gchar state[50]; + gchar age[15]; + gchar sex[15]; + gchar phone[15]; + gchar url[150]; + gchar about[1000]; } USER_EXT_INFO, *USER_EXT_INFO_PTR; -typedef struct -{ - guint32 uin; - guint32 status; - guint32 last_time; /* last time online or when came online */ - guint32 current_ip; - gint tcp_sok; - guint32 tcp_port; - gint tcp_status; /* can we get some stats on this one */ - gint chat_sok; - guint32 chat_port; - gint chat_status; - gint chat_active; - gint chat_active2; - guint32 chat_seq; - guint32 file_gdk_input; - gchar nick[20]; - GList* messages; +typedef struct { + guint32 uin; + guint32 status; + guint32 last_time; /* last time online or when came online */ + guint32 current_ip; + gint tcp_sok; + guint32 tcp_port; + gint tcp_status; /* can we get some stats on this one */ + gint chat_sok; + guint32 chat_port; + gint chat_status; + gint chat_active; + gint chat_active2; + guint32 chat_seq; + guint32 file_gdk_input; + gchar nick[20]; + GList *messages; } Contact_Member, *CONTACT_PTR; -typedef struct -{ - guint32 uin; - gchar nick[20]; - gchar first[50]; - gchar last[50]; - gchar email[50]; - gint auth_required; +typedef struct { + guint32 uin; + gchar nick[20]; + gchar first[50]; + gchar last[50]; + gchar email[50]; + gint auth_required; } SEARCH_RESULT, *SEARCH_RESULT_PTR; -typedef struct -{ - gint type; - gchar* text; - gchar* url; +typedef struct { + gint type; + gchar *text; + gchar *url; } MESSAGE_DATA, *MESSAGE_DATA_PTR; -typedef struct -{ - guint32 uin; - gchar c; +typedef struct { + guint32 uin; + gchar c; } CHAT_DATA, *CHAT_DATA_PTR; -extern Contact_Member Contacts[ ICQ_MAX_CONTACTS ]; +extern Contact_Member Contacts[ICQ_MAX_CONTACTS]; extern gint Num_Contacts; extern guint32 UIN; @@ -166,16 +155,17 @@ /* To make dealing with function pointers a LOT easier... */ /* CALLBACK is a reserved word in Win32 code for FAR PASCAL functions * instead lets use FUNC_CALLBACK */ -typedef void (*FUNC_CALLBACK)( void * ); +typedef void (*FUNC_CALLBACK) (void *); /* Types of server messages */ -enum { EVENT_LOGIN, EVENT_MESSAGE, EVENT_INFO, EVENT_EXT_INFO, +enum { EVENT_LOGIN, EVENT_MESSAGE, EVENT_INFO, EVENT_EXT_INFO, EVENT_OFFLINE, EVENT_ONLINE, EVENT_STATUS_UPDATE, EVENT_SEARCH_RESULTS, EVENT_DISCONNECT, EVENT_CHAT_CONNECT, - EVENT_CHAT_DISCONNECT, EVENT_CHAT_READ, EVENT_RTNSTATUS, NUM_EVENTS }; + EVENT_CHAT_DISCONNECT, EVENT_CHAT_READ, EVENT_RTNSTATUS, NUM_EVENTS +}; /* An array of function pointers to store the callbacks */ -void (*event[NUM_EVENTS])(void* data); +void (*event[NUM_EVENTS]) (void *data); /* Assigns "func" to the appropriate "event" pointer */ void ICQ_Register_Callback(gint event_type, FUNC_CALLBACK func); @@ -192,21 +182,20 @@ gint ICQ_Connect(); void ICQ_Disconnect(); void ICQ_Change_Status(guint32 new_status); -void ICQ_Send_Message(guint32 uin, gchar* text); -void ICQ_Send_URL(guint32 uin, gchar* url, gchar* text); -void ICQ_Request_Chat(guint32 uin, gchar* text); +void ICQ_Send_Message(guint32 uin, gchar *text); +void ICQ_Send_URL(guint32 uin, gchar *url, gchar *text); +void ICQ_Request_Chat(guint32 uin, gchar *text); void ICQ_Accept_Chat(guint32 uin); void ICQ_Refuse_Chat(guint32 uin); -void ICQ_Send_Chat(guint32 uin, gchar* text); -void ICQ_Search(gchar *email, gchar *nick, gchar* first, gchar* last); +void ICQ_Send_Chat(guint32 uin, gchar *text); +void ICQ_Search(gchar *email, gchar *nick, gchar *first, gchar *last); void ICQ_Get_Info(guint32 uin); void ICQ_Get_Ext_Info(guint32 uin); void ICQ_Get_Away_Message(guint32 uin); void ICQ_Add_User(guint32 uin, gchar *name); void ICQ_Rename_User(guint32 uin, gchar *name); void ICQ_Delete_User(guint32 uin); -int ICQSendFile(char * ip, char * port, char * uin, char * fileName, char * comment); - +int ICQSendFile(char *ip, char *port, char *uin, char *fileName, char *comment); void ICQ_SetLogging(gint logging); void ICQ_Debug(gint level, const gchar *debug_message); @@ -215,5 +204,4 @@ void DW_2_Chars(unsigned char *buf, guint32 num); void Word_2_Chars(unsigned char *buf, guint16 num); -#endif /* __LIBICQ_H__ */ - +#endif /* __LIBICQ_H__ */ Index: receive.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/receive.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- receive.c 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ receive.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -29,7 +29,7 @@ #if defined( _WIN32 ) && !defined(__MINGW32__) #include <windows.h> #include <io.h> -#else /* !_WIN32 */ +#else /* !_WIN32 */ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -49,7 +49,6 @@ #include "util.h" #include "tcp.h" [...1165 lines suppressed...] + current_search_result->auth_required = *tmp; + + Search_Results = + g_list_append(Search_Results, (gpointer) current_search_result); +} void Rec_EndOfSearch(srv_net_icq_pak pak) { - ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Rec_EndOfSearch"); + ICQ_Debug(ICQ_VERB_INFO, "LIBICQ> Rec_EndOfSearch"); - Send_Ack(Chars_2_Word( pak.head.seq ) ); + Send_Ack(Chars_2_Word(pak.head.seq)); - if(event[EVENT_SEARCH_RESULTS] != NULL) - (*event[EVENT_SEARCH_RESULTS])((void*)Search_Results); + if (event[EVENT_SEARCH_RESULTS] != NULL) + (*event[EVENT_SEARCH_RESULTS]) ((void *)Search_Results); } - Index: receive.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/receive.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- receive.h 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ receive.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,14 +14,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __RECEIVE_H__ #define __RECEIVE_H__ void Rec_Packet(); -void Process_Packet(srv_net_icq_pak pak, guint32 len, guint16 cmd, guint16 ver, guint16 seq, guint32 uin); +void Process_Packet(srv_net_icq_pak pak, guint32 len, guint16 cmd, guint16 ver, + guint16 seq, guint32 uin); -void Rec_Multi_Packet(guint8* pdata); +void Rec_Multi_Packet(guint8 *pdata); void Rec_Login(srv_net_icq_pak pak); void Rec_X1(srv_net_icq_pak pak); void Rec_X2(srv_net_icq_pak pak); @@ -36,6 +36,6 @@ void Rec_GoAway(srv_net_icq_pak pak); void Rec_UserFound(srv_net_icq_pak pak); void Rec_EndOfSearch(srv_net_icq_pak pak); -void Rec_AwayMessage(guint32 uin, char* msg); +void Rec_AwayMessage(guint32 uin, char *msg); -#endif /* __RECEIVE_H__ */ +#endif /* __RECEIVE_H__ */ Index: send.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/send.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- send.c 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ send.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,8 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -24,7 +22,7 @@ #include <winbase.h> #define sleep( x ) Sleep( x ) [...1212 lines suppressed...] + (gpointer) Contacts[cindex].tcp_sok); + close(Contacts[cindex].tcp_sok); + } + + if (Contacts[cindex].chat_sok > 0) { + open_sockets = g_list_remove(open_sockets, + (gpointer) Contacts[cindex].chat_sok); + close(Contacts[cindex].chat_sok); + } + + Contacts[cindex].status = STATUS_OFFLINE; + Contacts[cindex].current_ip = -1L; + Contacts[cindex].tcp_sok = 0; + Contacts[cindex].tcp_port = -1L; + Contacts[cindex].tcp_status = TCP_NOT_CONNECTED; + Contacts[cindex].chat_sok = 0; + Contacts[cindex].chat_port = -1L; + Contacts[cindex].chat_status = TCP_NOT_CONNECTED; + } +} Index: send.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/send.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- send.h 1 Apr 2003 07:24:29 -0000 1.1.1.1 +++ send.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,14 +14,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __SEND_H__ #define __SEND_H__ -int Connect_Remote(char* hostname, guint32 port); +int Connect_Remote(char *hostname, guint32 port); void Send_Ack(gint seq); -void Send_BeginLogin(guint32 UIN, char* pass, guint32 ip, guint32 port); +void Send_BeginLogin(guint32 UIN, char *pass, guint32 ip, guint32 port); void Send_FinishLogin(); void Send_KeepAlive(); void Send_GotMessages(); @@ -31,8 +30,8 @@ void Send_ChangeStatus(guint32 status); void Send_InfoRequest(guint32 uin); void Send_ExtInfoRequest(guint32 uin); -void Send_SearchRequest(char* email, char* nick, char* first, char* last); -void Send_RegisterNewUser(char* pass); +void Send_SearchRequest(char *email, char *nick, char *first, char *last); +void Send_RegisterNewUser(char *pass); void Send_Disconnect(); -void Send_URL(guint32 uin, char* url, char *text); -#endif /* __SEND_H__ */ +void Send_URL(guint32 uin, char *url, char *text); +#endif /* __SEND_H__ */ Index: tcp.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/tcp.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- tcp.c 1 Apr 2003 07:24:30 -0000 1.1.1.1 +++ tcp.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -30,7 +30,7 @@ #if defined( _WIN32 ) && !defined(__MINGW32__) #include <winsock2.h> #include <io.h> -#else /* !_WIN32 */ +#else /* !_WIN32 */ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -49,7 +49,6 @@ #include "libproxy.h" #include "plugin_api.h" [...3507 lines suppressed...] - DW_2_Chars( pack_tail.seq, seq ); - if( sock != -1 ) - { - intsize = sizeof( tcp_head ) + sizeof( tcp_tail ) + 1; - buffer = (guint8*)g_malloc( intsize + 2 ); - - Word_2_Chars (buffer, intsize); - memcpy( buffer+2, &pack_head, sizeof( pack_head ) ); - buffer[2 + sizeof( pack_head )] = 0x00; - memcpy( buffer+2 + sizeof( pack_head ) + 1, - &pack_tail, sizeof( pack_tail ) ); - write( sock, buffer, intsize + 2 ); - } - else - return -1; + return 1; - return 1; - } Index: tcp.h =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/tcp.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- tcp.h 1 Apr 2003 07:24:30 -0000 1.1.1.1 +++ tcp.h 17 Sep 2009 12:04:58 -0000 1.2 @@ -14,7 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #ifndef __TCP_H__ #define __TCP_H__ @@ -62,25 +61,23 @@ gint TCP_Ack(gint sock, guint16 cmd, gint seq); void TCP_SendHelloPacket(gint sock); -void TCP_ProcessPacket(guint8* packet, gint packet_length, gint sock); +void TCP_ProcessPacket(guint8 *packet, gint packet_length, gint sock); gint TCP_ReadPacket(gint sock); gint TCP_Connect(guint32 ip, guint32 port); -gint TCP_SendMessage(guint32 uin, char* msg); -gint TCP_SendURL(guint32 uin, char* url, char *text); +gint TCP_SendMessage(guint32 uin, char *msg); +gint TCP_SendURL(guint32 uin, char *url, char *text); gint TCP_GetAwayMessage(guint32 uin); gint TCP_ChatServerHandshake(gint sock); gint TCP_ChatClientHandshake(gint sock); gint TCP_ChatReadClient(gint sock); gint TCP_ChatReadServer(gint sock); -gint TCP_SendChatRequest(guint32 uin, gchar* text); +gint TCP_SendChatRequest(guint32 uin, gchar *text); gint TCP_AcceptChat(guint32 uin); gint TCP_RefuseChat(guint32 uin); -gint TCP_ChatSend(guint32 uin, gchar* text); +gint TCP_ChatSend(guint32 uin, gchar *text); gint TCP_ConnectChat(guint32 port, guint32 uin); gint TCP_TerminateChat(guint32 uin); -gint TCP_AcceptFile( int sock, int uin, guint32 seq); - - -#endif /* __TCP_H__ */ +gint TCP_AcceptFile(int sock, int uin, guint32 seq); +#endif /* __TCP_H__ */ Index: util.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/icq/libicq/util.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- util.c 1 Apr 2003 07:24:30 -0000 1.1.1.1 +++ util.c 17 Sep 2009 12:04:58 -0000 1.2 @@ -41,7 +41,6 @@ #include "icq.h" #include "libicq.h" - extern Contact_Member Contacts[]; extern int Num_Contacts; @@ -51,188 +50,178 @@ The following data constitutes fair use for compatibility. *********************************************************/ unsigned char icq_check_data[257] = { - 0x0a, 0x5b, 0x31, 0x5d, 0x20, 0x59, 0x6f, 0x75, - 0x20, 0x63, 0x61, 0x6e, 0x20, 0x6d, 0x6f, 0x64, - 0x69, 0x66, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x73, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x20, 0x49, - 0x43, 0x51, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, - 0x2e, 0x20, 0x4a, 0x75, 0x73, 0x74, 0x20, 0x73, - 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x22, 0x53, - 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x20, 0x66, - 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x22, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, - 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x69, 0x73, - 0x63, 0x22, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x43, - 0x51, 0x20, 0x6f, 0x72, 0x20, 0x66, 0x72, 0x6f, - 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x22, 0x53, - 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x20, 0x69, - 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20, 0x70, 0x61, - 0x6e, 0x65, 0x6c, 0x2e, 0x20, 0x43, 0x72, 0x65, - 0x64, 0x69, 0x74, 0x3a, 0x20, 0x45, 0x72, 0x61, - 0x6e, 0x0a, 0x5b, 0x32, 0x5d, 0x20, 0x43, 0x61, - 0x6e, 0x27, 0x74, 0x20, 0x72, 0x65, 0x6d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x20, 0x77, 0x68, 0x61, - 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x73, 0x61, - 0x69, 0x64, 0x3f, 0x20, 0x20, 0x44, 0x6f, 0x75, - 0x62, 0x6c, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x63, - 0x6b, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x20, 0x75, - 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x67, - 0x65, 0x74, 0x20, 0x61, 0x20, 0x64, 0x69, 0x61, - 0x6c, 0x6f, 0x67, 0x20, 0x6f, 0x66, 0x20, 0x61, - 0x6c, 0x6c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, - 0x20, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0 + 0x0a, 0x5b, 0x31, 0x5d, 0x20, 0x59, 0x6f, 0x75, + 0x20, 0x63, 0x61, 0x6e, 0x20, 0x6d, 0x6f, 0x64, + 0x69, 0x66, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x73, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x20, 0x49, + 0x43, 0x51, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, + 0x2e, 0x20, 0x4a, 0x75, 0x73, 0x74, 0x20, 0x73, + 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x22, 0x53, + 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x20, 0x66, + 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x22, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x69, 0x73, + 0x63, 0x22, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x43, + 0x51, 0x20, 0x6f, 0x72, 0x20, 0x66, 0x72, 0x6f, + 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x22, 0x53, + 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x20, 0x69, + 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20, 0x70, 0x61, + 0x6e, 0x65, 0x6c, 0x2e, 0x20, 0x43, 0x72, 0x65, + 0x64, 0x69, 0x74, 0x3a, 0x20, 0x45, 0x72, 0x61, + 0x6e, 0x0a, 0x5b, 0x32, 0x5d, 0x20, 0x43, 0x61, + 0x6e, 0x27, 0x74, 0x20, 0x72, 0x65, 0x6d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x20, 0x77, 0x68, 0x61, + 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x73, 0x61, + 0x69, 0x64, 0x3f, 0x20, 0x20, 0x44, 0x6f, 0x75, + 0x62, 0x6c, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x63, + 0x6b, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x20, 0x75, + 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x67, + 0x65, 0x74, 0x20, 0x61, 0x20, 0x64, 0x69, 0x61, + 0x6c, 0x6f, 0x67, 0x20, 0x6f, 0x66, 0x20, 0x61, + 0x6c, 0x6c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, + 0x20, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0 }; - -Contact_Member* contact(guint32 uin) +Contact_Member *contact(guint32 uin) { - int cindex; + int cindex; - for(cindex = 0; cindex < Num_Contacts; cindex++) - if(Contacts[cindex].uin == uin) break; + for (cindex = 0; cindex < Num_Contacts; cindex++) + if (Contacts[cindex].uin == uin) + break; - if(cindex == Num_Contacts) - return NULL; + if (cindex == Num_Contacts) + return NULL; - return &Contacts[cindex]; + return &Contacts[cindex]; } - -Contact_Member* contact_from_socket(gint sock) +Contact_Member *contact_from_socket(gint sock) { - int cindex; + int cindex; - for(cindex = 0; cindex < Num_Contacts; cindex++) - { - if(Contacts[cindex].tcp_sok == sock) break; - if(Contacts[cindex].chat_sok == sock) break; - } + for (cindex = 0; cindex < Num_Contacts; cindex++) { + if (Contacts[cindex].tcp_sok == sock) + break; + if (Contacts[cindex].chat_sok == sock) + break; + } - if(cindex == Num_Contacts) - return NULL; + if (cindex == Num_Contacts) + return NULL; - return &Contacts[cindex]; + return &Contacts[cindex]; } - guint32 Chars_2_DW(unsigned char *buf) { - return (guint32)((buf[3] << 24) + (buf[2] << 16) + (buf[1] << 8) + buf[0]); + return (guint32) ((buf[3] << 24) + (buf[2] << 16) + (buf[1] << 8) + + buf[0]); } - guint16 Chars_2_Word(unsigned char *buf) { - return (guint16)((buf[1] << 8) + buf[0]); + return (guint16) ((buf[1] << 8) + buf[0]); } - void DW_2_Chars(unsigned char *buf, guint32 num) { - buf[3] = (guchar)((num >> 24) & 0x000000FF); - buf[2] = (guchar)((num >> 16) & 0x000000FF); - buf[1] = (guchar)((num >> 8) & 0x000000FF); - buf[0] = (guchar)(num & 0x000000FF); + buf[3] = (guchar) ((num >> 24) & 0x000000FF); + buf[2] = (guchar) ((num >> 16) & 0x000000FF); + buf[1] = (guchar) ((num >> 8) & 0x000000FF); + buf[0] = (guchar) (num & 0x000000FF); } - void Word_2_Chars(unsigned char *buf, guint16 num) { - buf[1] = (guchar)((num >> 8) & 0x00FF); - buf[0] = (guchar)(num & 0x00FF); + buf[1] = (guchar) ((num >> 8) & 0x00FF); + buf[0] = (guchar) (num & 0x00FF); } - -void wrinkle_packet(void* ptr, size_t len) +void wrinkle_packet(void *ptr, size_t len) { - guint8 *buf; - guint32 chksum; - guint32 key; - guint32 tkey, temp; - guint8 r1, r2; - gint n, pos; - guint32 chk1, chk2; - - buf = ptr; - - buf[2] = rand() & 0xff; - buf[3] = 0; - buf[4] = 0; - buf[5] = 0; - - r1 = rand() % ( len - 4 ); - r2 = rand() & 0xff; - - chk1 = (guint8) buf[8]; - chk1 <<= 8; - chk1 += (guint8) buf[4]; - chk1 <<= 8; - chk1 += (guint8) buf[2]; - chk1 <<= 8; - chk1 += (guint8) buf[6]; - chk2 = r1; - chk2 <<= 8; - chk2 += (guint8) ( buf[ r1 ] ); - chk2 <<= 8; - chk2 += r2; - chk2 <<= 8; - chk2 += (guint8) ( icq_check_data[ r2 ] ); - chk2 ^= 0x00ff00ff; - - chksum = chk2 ^ chk1; - - DW_2_Chars( &buf[ 0x10 ], chksum ); - key = len; - key *= 0x66756B65; - key += chksum; - n = ( len + 3 ) / 4; - pos = 0; - while( pos < n ) - { - if( pos != 0x10 ) - { - tkey = key + icq_check_data[ pos & 0xff ]; - temp = Chars_2_DW( &buf[ pos ] ); - temp ^= tkey; - DW_2_Chars( &buf[ pos ], temp ); - } - pos += 4; - } - Word_2_Chars( &buf[ 0 ], ICQ_VER ); + guint8 *buf; + guint32 chksum; + guint32 key; + guint32 tkey, temp; + guint8 r1, r2; + gint n, pos; + guint32 chk1, chk2; + + buf = ptr; + + buf[2] = rand() & 0xff; + buf[3] = 0; + buf[4] = 0; + buf[5] = 0; + + r1... [truncated message content] |