home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Online / StrICQ / Src / include / libraries / icq.h
C/C++ Source or Header  |  2000-02-02  |  31KB  |  841 lines

  1. #ifndef LIBRARIES_ICQ_H
  2. #define LIBRARIES_ICQ_H
  3.  
  4. /* icq.library - Use to create and parse packets sent to/from an ICQ server.
  5. ** Will eventually support multiple versions and TCP.
  6. ** Written by Douglas F. McLaughlin <mclaughd@kda.attmil.ne.jp>
  7. ** Placed in the public domain.
  8. **
  9. ** The ICQ protocol is (C) Copyright 1996, Mirabilis Ltd.
  10. */
  11.  
  12. #ifndef EXEC_TYPES_H
  13. #include <exec/types.h>
  14. #endif
  15.  
  16.  
  17. extern void  MSG_ParseMessage(UWORD Type, UBYTE *Message, APTR DataStruct);
  18.  
  19. extern UWORD TCP_CreateMsgPacket(struct TCP_Message *TCPMsg, UBYTE **Buffer, ULONG *Sequence, UWORD *RevLen);
  20. extern void  TCP_ParseMsgPacket(struct TCP_Message *TCPMsg, UBYTE *Buffer, ULONG *Sequence);
  21. extern UWORD TCP_CreateFilePacket(UBYTE Command, APTR DataStruct, UBYTE *Buffer, UWORD *RevLen);
  22. extern UWORD TCP_CreateChatPacket(UBYTE Command, APTR DataStruct, UBYTE *Buffer, UWORD *RevLen);
  23. extern UBYTE TCP_ParseChatPacket(void **DataStruct, UBYTE *Buffer);
  24. extern UWORD TCP_CreateChatCmd(UBYTE Command, APTR DataStruct, UBYTE *Buffer);
  25. extern void  TCP_FreeMsgPacket(UBYTE *Buf);
  26. extern UWORD TCP_ParseTCPInit(struct TCP_Init *, UBYTE *);
  27.  
  28. extern char *ICQ_CmdToText(UWORD);
  29.  
  30. extern UWORD UDP_CreatePacket(struct UDP_Header *Header, APTR DataStruct, UBYTE *Buffer);
  31. extern BOOL  UDP_EncryptPacket(UBYTE *Buffer, UBYTE *OldBuf, UWORD Len);
  32. extern void  UDP_ParseHeader(UBYTE *Buffer, struct UDP_Header *Header);
  33. extern void  UDP_ParsePacket(APTR DataStruct, UBYTE *Buffer, UWORD PktLen, struct UDP_Header *Header);
  34. extern void  UDP_ParseMeta(APTR DataStruct, struct S_Meta *Meta);
  35.  
  36. extern void  UDP_NextMulti(struct S_Multi *Multi);
  37.  
  38.  
  39. extern void  PrintHex(UBYTE Type, char *Title, UBYTE *Buffer, UWORD Len);
  40.  
  41. /*
  42. ** These will convert between Big-Endian and Little-Endian, LONG and WORD values.
  43. */
  44.  
  45. #define BREV_L(a) (((a)>>24)|(((a)&0x00FF0000)>>8)|(((a)&0x0000FF00)<<8)|((a)<<24))
  46. #define BREV_W(a) (((a)>>8)|((a)<<8))
  47.  
  48. /*
  49. ** Various values.
  50. */
  51.  
  52. #ifndef LINE
  53. #define LINE                 "\0"        /* Empty line for sending empty messages */
  54. #endif
  55.  
  56. #define MAX_CONTACTS_PKT     0x64        /*  100 is as large as this can go */
  57. #define FILE_PKT_SIZE        0x0800      /* 2048 bytes per filedirect packet */
  58.  
  59. /*
  60. ** Status codes used by ICQ.
  61. */
  62.  
  63. /*
  64. ** -Old Method.
  65. */
  66.  
  67. #define STAT_ONLINE          0x00000000  /* Online */
  68. #define STAT_AWAY            0x00000001  /* Away */
  69. #define STAT_DND_2           0x00000003  /* Do Not Disturb */
  70. #define STAT_NA              0x00000005  /* Not Available */
  71. #define STAT_DND_3           0x00000010  /* Do Not Disturb */
  72. #define STAT_OCCUPIED        0x00000011  /* Occupied */
  73. #define STAT_DND             0x00000013  /* Do Not Disturb */
  74. #define STAT_FREE_CHAT       0x00000020  /* Free For Chat */
  75. #define STAT_INVISIBLE       0x00000100  /* Invisible */
  76. #define STAT_ONLINE_99       0x00000200  /* First Online */
  77. #define STAT_AWAY_99         0x00000201  /* First Away */
  78. #define STAT_NA_99           0x00000204  /* First Not Available */
  79. #define STAT_OCCUPIED_99     0x00000210  /* First Occupied */
  80. #define STAT_FREE_CHAT_99    0x00000220  /* First Free For Chat */
  81. #define STAT_NEWUIN          0x000000FE  /* New UIN in Contact List (STRICQ) */
  82. #define STAT_OFFLINE         0x0000FFFF  /* Offline */
  83.  
  84. #define STAT_HIDEIP          0x00020000
  85. #define STAT_WEBPRESENCE     0x00010000
  86.  
  87. /*
  88. ** +New Method.
  89. */
  90.  
  91. #define STATUS_ONLINE        0x00000000  /* Online */
  92. #define STATUS_AWAY          0x00000001  /* Away */
  93. #define STATUS_DND           0x00000003  /* Do Not Disturb */
  94. #define STATUS_NA            0x00000005  /* Not Available */
  95.  
  96. #define STATUS_NEWUIN        0x000000FE  /* Not in my contact list (STRICQ) */
  97. #define STATUS_OFFLINE       0x0000FFFF  /* Offline */
  98.  
  99. #define STATUSF_HIGH         0x00000010  /* & Online = Occupied */
  100. #define STATUSF_CHAT         0x00000020  /* & Online = Free For Chat */
  101. #define STATUSF_INVISIBLE    0x00000100  /* & Any mode = Invisible, but you can see me */
  102. #define STATUSF_FIRST        0x00000200  /* & Any mode = My first login this session (ICQ99a Betas) */
  103.  
  104. #define STATUSF_WEBPRESENCE  0x00010000  /* Turn on my web page status indicator */
  105. #define STATUSF_HIDEIP       0x00020000  /* Don't show my IP address */
  106. #define STATUSF_BIRTHDAY     0x00080000  /* Today is my birthday */
  107. #define STATUSF_UNK_1        0x00200000  /* Unknown */
  108.  
  109. /*
  110. ** UDP Protocol Commands sent to server.
  111. */
  112.  
  113. #define C_ACK                0x000A      /* 0010 acknowledgement */
  114. #define C_SEND_MESSAGE       0x010E      /* 0270 send message through server */
  115. #define C_LOGIN              0x03E8      /* 1000 login on to server */
  116. #define C_NEW_USER_REG       0x03FC      /* 1020 Register a new user */
  117. #define C_CONTACT_LIST       0x0406      /* 1030 Inform the server of contact list, addatively */
  118. #define C_SEARCH_USER        0x0424      /* 1060 Search for user by nick/name/email */
  119. #define C_KEEP_ALIVE         0x042E      /* 1070 keep alive */
  120. #define C_SEND_TEXT_CODE     0x0438      /* 1080 send special message to server */
  121. #define C_ACK_MSG            0x0442         /* 1090 Ack all messages (delete from server) */
  122. #define C_LOGIN_1            0x044C      /* 1100 Sent during login */
  123. #define C_INFO_REQ           0x0460      /* 1120 Request a UINs Basic Information */
  124. #define C_EXT_INFO_REQ       0x046A      /* 1130 Request a UINs Extended Information */
  125. #define C_CHANGE_PASSWORD    0x049C      /* 1180 Change the user's password */
  126. #define C_NEW_USER_INFO      0x04A6      /* 1190 Send new user's basic information */
  127. #define C_UPDATE_EXT_INFO    0x04B0      /* 1200 Update my extended information */
  128. #define C_QUERY_STATUS       0x04BA      /* 1210 Query about other servers */
  129. #define C_LOGIN_3            0x04CE      /* 1230 Sent during login */
  130. #define C_STATUS_CHANGE      0x04D8      /* 1240 Change status of user (Away etc.) */
  131. #define C_NEW_USER_1         0x04EC      /* 1260 Ask for permission to add new user */
  132. #define C_SEND_URL_MESSAGE   0x04F6      /* 1270 Request server advertisement */
  133. #define C_UPDATE_INFO        0x050A      /* 1290 Update my basic information */
  134. #define C_UPDATE_AUTH        0x0514      /* 1300 Update my authorization status */
  135. #define C_LOGIN_2            0x0528      /* 1320 Sent during Login */
  136. #define C_META               0x064A      /* 1610 Meta command that supports sub-commands (v5) */
  137. #define C_INVIS_LIST         0x06A4      /* 1700 Sends the 'Invisible To User' contact list */
  138. #define C_VIS_LIST           0x06AE      /* 1710 Sends the 'Visible To User' contact list */
  139.  
  140. /*
  141. ** UDP Protocol Commands sent by server.
  142. */
  143.  
  144. #define S_ACK                0x000A      /* 0010 Ack */
  145. #define S_UNKNOWN_ERROR      0x001E      /* 0030 Unknown error message */
  146. #define S_GO_AWAY            0x0028         /* 0040 Been idle, logging you out */
  147. #define S_NEW_USER_UIN       0x0046      /* 0070 Confirmation of new user with UIN */
  148. #define S_LOGIN_REPLY        0x005A      /* 0090 Login reply */
  149. #define S_BAD_PASSWORD       0x0064      /* 0100 Bad password sent during login */
  150. #define S_USER_ONLINE        0x006E      /* 0110 user in clist changed status */
  151. #define S_USER_OFFLINE       0x0078      /* 0120 user in clist has gone offline */
  152. #define S_QUERY_REPLY        0x0082      /* 0130 Response to QUERY_SERVERS or QUERY_ADDONS */
  153. #define S_USER_FOUND         0x008C      /* 0140 user record found matching query */
  154. #define S_END_OF_SEARCH      0x00A0      /* 0160 No more USER_FOUND will be sent */
  155. #define S_NEW_USER_REPLY     0x00B4      /* 0180 Confirmation of new user info */
  156. #define S_UPDATE_EXT_REPLY   0x00C8      /* 0200 Confirmation of extended update */
  157. #define S_RECEIVE_MESSAGE    0x00DC      /* 0220 message sent while offline */
  158. #define S_END_OFFLINE_MSGS   0x00E6      /* 0230 The last offline message has been sent */
  159. #define S_LOGGED_OFF         0x00F0      /* 0240 The server has logged you off */
  160. #define S_TOO_BUSY           0x00FA      /* 0250 Server is busy try again later */
  161. #define S_GET_MESSAGE        0x0104         /* 0260 message from user (sent through server) */
  162. #define S_INFO_REPLY         0x0118      /* 0280 Return basic information */
  163. #define S_EXT_INFO_REPLY     0x0122      /* 0290 Return extended information */
  164. #define S_INFO_NOT_FOUND     0x012C      /* 0300 User's basic information not found */
  165. #define S_EXT_INFO_NOT_FOUND 0x0136      /* 0310 User's extended information not found */
  166. #define S_TCP_REQUEST        0x015E      /* 0350 TCP connection request sent through server */
  167. #define S_STATUS_UPDATE      0x01A4      /* 0420 User on contact list changed stat */
  168. #define S_SYSTEM_MESSAGE     0x01C2      /* 0450 System message with URL button */
  169. #define S_UPDATE_REPLY       0x01E0      /* 0480 Confirmation of basic update */
  170. #define S_UPDATE_FAIL        0x01EA      /* 0490 Basic info update has failed */
  171. #define S_UPDATE_AUTH_REPLY  0x01F4      /* 0500 Confirmation of Authorization update */
  172. #define S_MULTI              0x0212      /* 0530 Multi-packet containing other packets encapsulated */
  173. #define S_REPLY_X1           0x021C      /* 0540 Unknown, reply to C_LOGIN_1 */
  174. #define S_META               0x03DE      /* 0990 Meta command reply that supports sub-commands (v5) */
  175.  
  176. /*
  177. ** Meta command sub-commands.
  178. */
  179.  
  180. #define META_RPLY_HOME         0x0064      /* 0100 Indicates the home information update succeeded/failed */
  181. #define META_RPLY_WORK         0x006E      /* 0110 Indicates the work information update succeeded/failed */
  182. #define META_RPLY_MORE         0x0078      /* 0120 Indicates the more information update succeeded/failed */
  183. #define META_RPLY_ABOUT        0x0082      /* 0130 Indicates the about text update succeeded/failed */
  184. #define META_RPLY_INTERESTS    0x008C      /* 0140 Indicates the interests update succeeded/failed */
  185. #define META_RPLY_AFFILIATIONS 0x0096      /* 0150 Indicates the affiliations update succeeded/failed */
  186. #define META_RPLY_FLAGS        0x00A0      /* 0160 Indicates the authorize, webaware and hideip update succeeded/failed */
  187. #define META_RPLY_PASSWORD     0x00AA      /* 0170 Indicates the password change succeeded/failed */
  188. #define META_RPLY_URLCATEGORY  0x00BE      /* 0190 Indicates the homepage URL category change succeeded/failed */
  189.  
  190. #define META_INFO_HOME         0x00C8      /* 0200 Returns personal contact information, including EMail, Address, Phone */
  191. #define META_INFO_WORK         0x00D2      /* 0210 Returns work/business contact related information */
  192. #define META_INFO_MORE         0x00DC      /* 0220 Returns more information not in META_INFO_HOME */
  193. #define META_INFO_ABOUT        0x00E6      /* 0230 Returns only the about text */
  194. #define META_INFO_INTERESTS    0x00F0      /* 0240 Returns interests */
  195. #define META_INFO_AFFILIATIONS 0x00FA      /* 0250 Returns affiliations */
  196. #define META_INFO_URLCATEGORY  0x010E      /* 0270 Returns the homepage URL category */
  197.  
  198. #define META_INFO_BASIC        0x019A      /* 0410 Returns basic information, same as S_INFO_REPLY */
  199.  
  200. #define META_UPD_HOME          0x03E8      /* 1000 Updates personal contact information */
  201. #define META_UPD_HOME_1        0x03E9      /* 1001 Updates personal contact information (99b client) */
  202. #define META_UPD_WORK          0x03F2      /* 1010 Updates work/business contact related information */
  203. #define META_UPD_WORK_1        0x03F3      /* 1011 Updates work/business contact related information (99b client) */
  204. #define META_UPD_MORE          0x03FC      /* 1020 Updates the more information */
  205. #define META_UPD_MORE_1        0x03FD      /* 1021 Updates the more information (99b client) */
  206. #define META_UPD_ABOUT         0x0406      /* 1030 Updates about text */
  207. #define META_UPD_INTERESTS     0x0410      /* 1040 Updates interests */
  208. #define META_UPD_AFFILIATIONS  0x041A      /* 1050 Updates affiliations */
  209. #define META_UPD_FLAGS         0x0424      /* 1060 Updates authorize, webaware and hideip status' */
  210. #define META_UPD_PASSWORD      0x042E      /* 1070 Updates the login password */
  211. #define META_UPD_URLCATEGORY   0x0442      /* 1090 Updates the homepage URL category */
  212.  
  213. #define META_REQ_INFO          0x04B0      /* 1200 Requests META_INFO_HOME, _WORK, _MORE, _ABOUT, _INTERESTS, _AFFILIATIONS and _URLCATEGORY */
  214. #define META_REQ_INFO_1        0x04B1      /* 1201 Requests same as META_REQ_INFO (99b client) */
  215. #define META_REQ_GRABME        0x04CE      /* 1230 Requests all MY userinfo to synchronize with ICQ server */
  216. #define META_REQ_GRABME_1      0x04CF      /* 1231 Requests all MY userinfo to synchronize with ICQ server (99b client) */
  217.  
  218. #define META_UNK_1             0x07D0      /* 2000 Unknown, sent during login and throughout a session by 99b clients with 0x0000 data */
  219.  
  220. #define META_SUCCESS           0x0A        /* 0010 META_REQ_* subcommand was successful and returned valid data */
  221.  
  222. /*
  223. ** TCP/UDP Message related codes.
  224. **
  225. ** Message types.
  226. */
  227.  
  228. #define MSG_MSG          0x0001      /* 0001 Used to send a normal message, same for UDP and TCP  */
  229. #define MSG_CHAT         0x0002      /* 0002 Used to initiate a Chat session */
  230. #define MSG_FILE         0x0003      /* 0003 Used to initiate a FileDirect session */
  231. #define MSG_URL          0x0004      /* 0004 Used to send a URL message, same for UDP and TCP */
  232. #define MSG_REQ_AUTH     0x0006      /* 0006 Used to request authorization to add to contact list */
  233. #define MSG_DENY_AUTH    0x0007      /* 0007 Used to deny authorization to add to contact list */
  234. #define MSG_GIVE_AUTH    0x0008      /* 0008 Used to grant authorization to add to contact list */
  235. #define MSG_ADDED        0x000C      /* 0012 Used to notify that your UIN was added to a contact list */
  236. #define MSG_WEB_PAGER    0x000D      /* 0013 Used to receive a web pager message from the white page */
  237. #define MSG_EMAIL_PAGER  0x000E      /* 0014 Used to receive an EMail message from UIN@pager.mirabilis.com */
  238. #define MSG_ADDUIN       0x0013      /* 0019 Used to send UINs from one client to another */
  239. #define MSG_GREETING     0x001A      /* 0026 Used to send a greeting card */
  240.  
  241. #define MSG_READAWAY     0x03E8      /* 1000 */
  242. #define MSG_READOCCUPIED 0x03E9      /* 1001 */
  243. #define MSG_READNA       0x03EA      /* 1002 */
  244. #define MSG_READDND      0x03EB      /* 1003 */
  245. #define MSG_READFFC      0x03EC      /* 1004 */
  246.  
  247. #define MSGF_MASS        0x0800      /* 2048 This message was sent to more than one UIN */
  248.  
  249. /*
  250. ** TCP Packet Constants.
  251. */
  252.  
  253. #define TCP_INIT_IDENT       0xFF    /* 0255 First byte is always 0xFF */
  254.  
  255. #define TCP_VERSION_CURRENT  0x0002  /* 0002 Version currently in use (STRICQ) */
  256. #define TCP_VERSION_MAX      0x0006  /* 0006 Highest version of TCP known so far */
  257.  
  258. #define TCP_REVISION_CURRENT 0x0000  /* 0000 Revision in use */
  259.  
  260. #define TCP_FLAG_CAPABLE     0x04    /* 0004 Client is TCP capable */
  261. #define TCP_FLAG_NOTCP       0x06    /* 0006 Client is not TCP capable */
  262.  
  263. /*
  264. ** TCP Message Commands.
  265. */
  266.  
  267. #define TCP_CANCEL           0x07D0  /* 2000 TCP cancel previous file/chat request */
  268. #define TCP_ACK              0x07DA  /* 2010 TCP acknowledge message packet */
  269. #define TCP_MESSAGE          0x07EE  /* 2030 TCP message */
  270.  
  271. /*
  272. ** TCP Message Command Types.
  273. */
  274.  
  275. #define TCP_MSG_AUTO         0x0000  /* TCP message ACK and Auto-Reply */
  276. #define TCP_MSG_REAL         0x0010  /* TCP message */
  277. #define TCP_MSG_LIST         0x0020  /* TCP message sent to the contact list */
  278. #define TCP_MSG_URGENT       0x0040  /* TCP message sent urgently */
  279.  
  280. #define TCP_MSGF_S_INVISIBLE 0x0080  /* The message sender is Invisible */
  281. #define TCP_MSGF_S_AWAY      0x0100  /* The message sender is Away */
  282. #define TCP_MSGF_S_OCCUPIED  0x0200  /* The message sender is Occupied */
  283. #define TCP_MSGF_S_NA        0x0800  /* The message sender is Not Available */
  284. #define TCP_MSGF_S_DND       0x1000  /* The message sender is Do Not Disturb */
  285.  
  286. /*
  287. ** TCP Message Status'
  288. */
  289.  
  290. #define TCP_STATUS_ONLINE    0x0000
  291. #define TCP_STATUS_REFUSE    0x0001
  292. #define TCP_STATUS_AWAY      0x0004
  293. #define TCP_STATUS_OCCUPIED  0x0009
  294. #define TCP_STATUS_DND       0x000A
  295. #define TCP_STATUS_NA        0x000E
  296.  
  297. /*
  298. ** TCP FileDirect related codes.
  299. */
  300.  
  301. #define TCP_FILE_BEGIN       0x00        /*   00 Start the file send process */
  302. #define TCP_FILE_READY       0x02        /*   02 Ready to start the file transfer */
  303. #define TCP_FILE_SPEED       0x05        /*   05 Change the sender's rate of transfer */
  304. #define TCP_FILE_DATA        0x06        /*   06 Up to 2048 bytes of the file being sent */
  305.  
  306. /*
  307. ** TCP Chat related codes.
  308. */
  309.  
  310. #define TCP_CHAT_HANDSHAKE   0x00000064  /*  100 Chat initialization handshake code */
  311. #define TCP_CHAT_HANDSHAKE2  0x00000065  /*  101 Chat initialization used in ICQ 99b */
  312. #define TCP_CHAT_VER_CURRENT 0xFFFFFFFC  /*  -04 Current used chat version */
  313. #define TCP_CHAT_VERSION     0xFFFFFFFA  /*  -06 Chat TCP version */
  314.  
  315. #define TCP_CHAT_1           0x00        /*   00 First chat packet sent */
  316. #define TCP_CHAT_2           0x01        /*   01 Second chat packet sent as reply to first */
  317. #define TCP_CHAT_3           0x02        /*   02 Third chat packet sent as reply to second */
  318. #define TCP_CHAT_ERROR       0x80        /*  128 An error occured allocating RAM (STRICQ) */
  319.  
  320. #define TCP_CHAT_CMD_FCOLOR  0x00        /*    0 Changes the text color */
  321. #define TCP_CHAT_CMD_STYLE   0x11        /*   17 Changes the text style Bold, Italic, Underline */
  322.  
  323. #define TCP_CHATF_NONE       0x00        /*    0 set text to normal */
  324. #define TCP_CHATF_BOLD       0x01        /*    1 Set text style to Bold */
  325. #define TCP_CHATF_ITALIC     0x02        /*    2 Set text style to Italic */
  326. #define TCP_CHATF_UNDERLINE  0x04        /*    4 Set text style to Underline */
  327.  
  328. /*
  329. ** Structures used to send UDP packets to the server.
  330. */
  331.  
  332. struct C_SendMessage {
  333.   ULONG ToUIN;       /* UIN of person to message to. */
  334.   UWORD Type;        /* Message type.  See defines. */
  335.   char *Message;     /* Actual message text. */
  336. };
  337.  
  338. struct C_LogOn {
  339.   ULONG Time;        /* time(NULL) (v5) */
  340.   ULONG TCP_MsgPort; /* Port your client will accept TCP connections on. */
  341.   char  Password[8]; /* Password, max 8 characters, case sensitive. */
  342.   ULONG X1;          /* Unknown.  Use 0x00000000 for v2. (0x000000D5 v5) */
  343.   ULONG TCP_MsgIP;   /* IP Address your client will accept TCP connections on. */
  344.   UBYTE TCP_Flag;    /* Is your client TCP capable?  0x04 = Yes, 0x06 = No. */
  345.   ULONG Status;      /* Your client's status at login.  See defines. */
  346.   ULONG X3;          /* TCP Version.  Use 0x00000002 for v2. (0x00000006 v5) */
  347.   UWORD Seq_Login;   /* One up for each login packet sent. (v2) */
  348.   ULONG X4;          /* Unknown.  Use 0x00000000 for v2/5. */
  349.   ULONG X5;          /* Unknown.  Use 0x007300D9 for v2. (0x00D60000 v5) */
  350.   ULONG X6;          /* Unknown.  Use 0x00000050 for v5. */
  351.   ULONG X7;          /* Unknown.  Use 0x00000003 for v5. */
  352.   ULONG X8;          /* Unknown.  Random? (v5) */
  353. };
  354.  
  355. struct C_NewUser {
  356.   UWORD X1;          /* Unknown.  Use 0x000c for v2. */
  357.   char  Password[8]; /* Password, max 8 characters, case sensitive. */
  358.   ULONG X2;          /* Unknown.  Use 0x00000073 for v2. (0x000000A0 v5) */
  359.   UWORD Random;      /* Unknown.  Seemingly random. */
  360.   UWORD Pad;         /* Unknown.  Use 0x0000 for v2/5. */
  361.   ULONG X3;          /* Unknown.  Use 0x00A00000 for v5. */
  362.   ULONG X4;          /* Unknown.  Use 0x00000000 for v5. */
  363. };
  364.   
  365. struct C_ContactList {
  366.   UBYTE UIN_Count;             /* Count of UINs in this packet. */
  367.   ULONG UIN[MAX_CONTACTS_PKT]; /* Each UIN one after the other. */
  368. };
  369.  
  370. struct C_Search_User {
  371.   UWORD Sequence;    /* Search sequence. (v2) */
  372.   char  Nick[21];    /* Nick. */
  373.   char  First[21];   /* First name. */
  374.   char  Last[21];    /* Last name. */
  375.   char  EMail[61];   /* EMail address. */
  376. };
  377.  
  378. struct C_LogOff {
  379.   char *Text;        /* Text code to send to the server.  Use "B_USER_DISCONNECTED" for v2. */
  380.   UWORD X1;          /* Unknown.  Use 0x0005 for logoff. */
  381. };
  382.  
  383. struct C_ServerStat {
  384.   ULONG Index;       /* Index number of last Server Status message received. */
  385. };
  386.  
  387. struct C_LogOn_3 {
  388.   ULONG X1;          /* Unknown.  Use 0x00000000 for v2. */
  389. };
  390.  
  391. struct C_SendURLMsg {
  392.   ULONG Index;       /* Index number of last URL message received. */
  393. };
  394.  
  395. struct C_LogOn_2 {
  396.   UBYTE X1;          /* Unknown.  User 0x00 for v2. */
  397. };
  398.  
  399. struct C_Update_Basic_Info {
  400.   UWORD Sequence;    /* One up count for each packet sent. (v2) */
  401.   char  Nick[21];    /* Nick. */
  402.   char  First[21];   /* First name. */
  403.   char  Last[21];    /* Last name. */
  404.   char  EMail[61];   /* EMail address. */
  405.   UBYTE Authorize;   /* Authorize flag.  NOT UPDATED WITH THIS PACKET. */
  406. };
  407.  
  408. struct C_Update_Ext_Info {
  409.   UWORD Sequence;    /* One up count for each packet sent. (v2) */
  410.   char  City[51];    /* City. */
  411.   UWORD Country;     /* Country code. */
  412.   UBYTE Timezone;    /* Timezone +\- 24. */
  413.   char  State[4];    /* State. */
  414.   UWORD Age;         /* Age. */
  415.   UBYTE Sex;         /* Sex. */
  416.   char  Phone[21];   /* Phone number. */
  417.   char  URL[101];    /* Homepage. */
  418.   char  About[256];  /* About. */
  419. };
  420.  
  421. struct C_Info_Req {
  422.   UWORD Sequence;    /* Search sequence. (v2) */
  423.   ULONG UIN;         /* UIN to search for. */
  424. };
  425.  
  426. struct C_ChangePassword {
  427.   UWORD Sequence;    /* Change password sequence. (v2) */
  428.   char  Password[8]; /* New password. */
  429. };
  430.  
  431. struct C_StatusChange {
  432.   ULONG Status;      /* Change status code. */
  433. };
  434.  
  435. struct C_UpdateAuth {
  436.   UWORD Sequence;    /* Change authorization sequence. (v2) */
  437.   UBYTE Authorize;   /* Authorization code. */
  438. };
  439.  
  440. struct C_Meta {
  441.   UWORD Subcommand;  /* Meta command subcommand. */
  442.   ULONG UIN;         /* UIN requesting info about. */
  443. };
  444.  
  445. /*
  446. ** Structures used for UDP receiving packets from the server.
  447. */
  448.  
  449. struct UDP_Header {
  450.   UWORD Version;      /* v2/5 */
  451.   ULONG UIN;          /* v5   */
  452.   ULONG SessionID;    /* v5   */
  453.   UWORD Command;      /* v2/5 */
  454.   UWORD Sequence;     /* v2/5 */
  455.   UWORD Sequence2;    /* v5   */
  456.   ULONG CheckCode;    /* v5   */
  457.   ULONG TCP_Sequence; /* STRICQ */
  458. };
  459.  
  460. struct S_New_User_UIN {
  461.   UWORD X1;
  462.   ULONG UIN;
  463.   ULONG Random;
  464. };
  465.  
  466. struct S_Login_Reply {
  467.   ULONG IP;
  468.   UWORD X1, X2, X3;               /* (v2, v2, v2) */
  469.   ULONG X4, X5;                   /* (v2, v2/5) */
  470.   UWORD X6, X7, X8, X9, X10, X11; /* (v2/5, v2/5, v2/5, v2/5, v2) */
  471.   ULONG X12;                      /* (v2/5) */
  472. };
  473.  
  474. struct S_User_Online {
  475.   ULONG UIN;
  476.   ULONG IP;
  477.   ULONG TCP_MsgPort;
  478.   ULONG RealIP;
  479.   UBYTE TCP_Flag;
  480.   ULONG Status;
  481.   UWORD TCP_Version;
  482.   UWORD TCP_Revision;
  483. //ULONG X1, X2, X3, X4, X5, X6, X7;
  484. };
  485.  
  486. struct S_User_Offline {
  487.   ULONG UIN;
  488. };
  489.  
  490. struct S_End_Of_Search {
  491.   UWORD Sequence;     /* v2   */
  492.   UBYTE TooMany;      /* v2/5 */
  493. };
  494.  
  495. struct S_Receive_Message {
  496.   ULONG UIN;
  497.   UWORD Year;
  498.   UBYTE Month;
  499.   UBYTE Day;
  500.   UBYTE Hour;
  501.   UBYTE Minute;
  502.   UWORD Type;
  503.   UWORD Length;
  504.   char *MessageBuf;
  505. };
  506.  
  507. struct S_Get_Message {
  508.   ULONG UIN;
  509.   UWORD Type;
  510.   UWORD Length;
  511.   char *MessageBuf;
  512. };
  513.  
  514. struct S_Basic_Info { /* Also used for S_USER_FOUND. */
  515.   UWORD Sequence;     /* Matches the sequence used in the info request. (v2) */
  516.   ULONG UIN;          /* UIN. */
  517.   char  Nick[21];     /* Nick. */
  518.   char  First[21];    /* First name. */
  519.   char  Last[21];     /* Last name. */
  520.   char  EMail[61];    /* EMail address. */
  521.   UBYTE Authorize;    /* Authorize flag. */
  522. };
  523.  
  524. struct S_Ext_Info {
  525.   UWORD Sequence;    /* One up count for each packet sent. (v2) */
  526.   ULONG UIN;         /* UIN. */
  527.   char  City[51];    /* City. */
  528.   UWORD Country;     /* Country code. */
  529.   BYTE  Timezone;    /* Timezone +\- 24. */
  530.   char  State[4];    /* State. */
  531.   UWORD Age;         /* Age. */
  532.   UBYTE Sex;         /* Sex. */
  533.   char  Phone[21];   /* Phone number. */
  534.   char  URL[101];    /* Homepage. */
  535.   char  About[256];  /* About. */
  536. };
  537.  
  538. struct S_TCP_Request {
  539.   ULONG Local_UIN;   /* Your UIN. (v2) */
  540.   ULONG Remote_UIN;  /* Remote requester's UIN. */
  541.   ULONG IP;          /* The IP to connect with. */
  542.   ULONG Port;        /* The port to connect with. */
  543.   UBYTE TCP_Flag;    /* TCP Flag of the requester. */
  544.   ULONG Port2;       /* Another UI port. */
  545.   ULONG Port3;       /* The UI port again. */
  546.   UWORD TCP_Version; /* The TCP version of the requester. */
  547. //ULONG X1;          /* Unknown.  Not sent.  Received as 0x00000000. */
  548. //ULONG X2;          /* Unknown.  Not sent.  Received as 0x00000000. */
  549. };
  550.  
  551. struct S_Status_Update {
  552.   ULONG UIN;
  553.   ULONG Status;
  554. };
  555.  
  556. struct S_System_Message {
  557.   ULONG Index;
  558.   char  Ad[256];
  559.   char  URL[256];
  560.   char  Button[256];
  561. };
  562.  
  563. struct S_Meta {
  564.   UWORD Subcommand;
  565.   UBYTE Success;
  566.   UBYTE *Packet;
  567. };
  568.  
  569. struct S_Multi {
  570.   UBYTE Count;
  571.   UWORD Size;
  572.   UBYTE *Packet;
  573. };
  574.  
  575. /*
  576. ** Structures used to create/parse META packets.
  577. */
  578.  
  579. struct Meta_Info_Home {
  580.   char  Nick[21];
  581.   char  First[21];
  582.   char  Last[21];
  583.   char  EMail_Primary[61];
  584.   char  EMail_Secondary[61];
  585.   char  EMail_Old[61];
  586.   char  City[31];
  587.   char  State[4];
  588.   char  Phone[31];
  589.   char  FAX[31];
  590.   char  Street[51];
  591.   char  Cellular[31];
  592.   char  ZipCode[6];
  593.   UWORD Country;
  594.   BYTE  Timezone;
  595.   UBYTE Flag1;         /* (Update: 0x00 = Open EMail, 0x01 = Don't publish Email) (Request/GrabMe: 0x00 = Authorize, 0x01 = Open */
  596.   UBYTE Flag2;         /* (Update: Not sent) (Request: Unknown, usually 0x02) (GrabMe: 0x00 = WebAware off, 0x01 = On */
  597.   UBYTE Flag3;         /* (Update: Not sent) (Request: Unknown, usually 0x00) (GrabMe: 0x00 = Open EMail, 0x01 = Don't publish EMail) */
  598.   UBYTE Flag4;         /* (Update: Not sent) (Request: Not Sent) (GrabMe: Unknown, usually 0x00) */
  599. };
  600.  
  601. struct Meta_Info_Work {
  602.   char  City[31];
  603.   char  State[4];
  604.   char  Phone[31];
  605.   char  FAX[31];
  606.   char  Address[31];
  607.   char  ZipCode[6];
  608.   UWORD Country;
  609.   char  Company[31];
  610.   char  Department[41];
  611.   char  Position[41];
  612.   UWORD Occupation;
  613.   char  URL[101];
  614. };
  615.  
  616. struct Meta_Info_More {
  617.   UWORD Age;
  618.   UBYTE Sex;
  619.   char  URL[101];
  620.   UWORD BDay_Year;
  621.   UBYTE BDay_Month;
  622.   UBYTE BDay_Day;
  623.   UBYTE Language1;      /* 0xFF = Undefined (i.e. blank) */
  624.   UBYTE Language2;
  625.   UBYTE Language3;
  626. };
  627.  
  628. struct Meta_Info_About {
  629.   char  About[512];
  630. };
  631.  
  632. struct Meta_Info_Interests {
  633.   UBYTE Total_Categories;   /* Total categories in the packet (always 0x04 for update) */
  634.   UWORD Topic;              /* Topic index (+100?) */
  635.   char *TopicText;          /* Text of all topics, comma seperated */
  636.   UBYTE *Next_Category;     /* Remaining portion of packet.  Used by UDP_NextInterest() to parse the next category */
  637. };
  638.  
  639. struct Meta_Info_Affiliations {
  640.   UBYTE Total_Backgrounds;  /* Total categories of 'Past Background' in the packet (always 0x03 for update) */
  641.   UWORD Background;         /* Background index */
  642.   char *BackgroundText;     /* Text of entered names or keywords */
  643.   UBYTE *Next_Background;   /* Remaining portion of packet.  Used by UDP_NextAffiliation() to parse the next item */
  644.   UBYTE Total_Affiliations; /* Total categories of 'Affiliations' in the packet (always 0x03 for update) */
  645.   UWORD Affiliation;        /* Affiliation index */
  646.   char *AffiliationText;    /* Text of entered names or keywords */
  647.   UBYTE *Next_Affiliation;  /* Remaining portion of packet.  Used by UDP_NextAffiliation() to parse the next item */
  648. };
  649.  
  650. struct Meta_Info_URLCategory {
  651.   UBYTE Total_Categories;   /* Total categories of 'Homepage URL' in the packet (always 0x01 for update) */
  652.   UWORD Category;           /* Category index */
  653.   char *AboutText;          /* About description of URL */
  654.   UBYTE *Next_Category;     /* Remaining portion of packet.  Used by UDP_NextURLCategory() to parse the next item */
  655. };
  656.  
  657. struct Meta_Update_Flags {
  658.   UBYTE Authorize;      /* 0x00 = Authorize, 0x01 = Open */
  659.   UBYTE Webaware;       /* 0x00 = Off, 0x01 = On */
  660.   UBYTE HideIP;         /* 0x00 = HideIP, 0x01 = Open */
  661. };
  662.  
  663. struct Meta_Update_Password {
  664.   char  Password[8];
  665. };
  666.  
  667. /*
  668. ** Structures used to send TCP packets to other clients.
  669. */
  670.  
  671. struct TCP_Init {
  672.   UWORD Version;
  673.   UWORD X1;
  674.   ULONG TCP_Chat_File_Port;
  675.   ULONG UIN;
  676.   ULONG TCP_MsgIP;
  677.   ULONG TCP_RealIP;
  678.   UBYTE TCP_Flag;
  679.   ULONG TCP_MsgPort;
  680. };
  681.  
  682. struct TCP_Message {
  683.   ULONG UIN;
  684.   UWORD Command;
  685.   UWORD X1;
  686.   UWORD Type;
  687.   char *Message;
  688.   ULONG TCP_MsgIP;
  689.   ULONG TCP_RealIP;
  690.   ULONG TCP_MsgPort;
  691.   UWORD TCP_Status;
  692.   UWORD MsgCommand;
  693.   char *Chat_Session;
  694.   UWORD Chat_RevPort;
  695.   UWORD Chat_X2;
  696.   ULONG Chat_Port;
  697.   UWORD File_RevPort;
  698.   UWORD File_X3;
  699.   char *File_Name;
  700.   ULONG File_Size;
  701.   ULONG File_Port;
  702. };
  703.  
  704. /*
  705. ** Structures used during TCP File Direct.
  706. */
  707.  
  708. struct TCP_FileBegin { /* FileDirect packet 0x00 */
  709.   ULONG X1;
  710.   ULONG TotalFiles;
  711.   ULONG TotalSize;
  712.   ULONG Speed;
  713.   char  Nick[21];
  714. };
  715.  
  716. struct TCP_FileReady { /* FileDirect packet 0x02 */
  717.   UBYTE X1;
  718.   char *Filename;
  719.   char *Text;
  720.   ULONG Filesize;
  721.   ULONG X2;
  722.   ULONG Speed;
  723. };
  724.  
  725. struct TCP_FileSpeed { /* FileDirect packet 0x05 */
  726.  ULONG Speed;
  727. };
  728.  
  729. struct TCP_FileData {  /* FileDirect packet 0x06 */
  730.   char  Data[FILE_PKT_SIZE+3];
  731.   UWORD DataLen;
  732. };
  733.  
  734. /*
  735. ** Structures used during TCP Chat initialization.
  736. */
  737.  
  738. struct TCP_ChatInit {
  739.   ULONG HandShake;
  740.   ULONG HiVersion;
  741.   ULONG UIN;
  742.   char  Nick[21];
  743.   UWORD RevPort;
  744.   ULONG TextColor;
  745.   ULONG BackColor;
  746.   UBYTE X1;
  747. };
  748.  
  749. struct TCP_ChatTwo_Ext {
  750.   UWORD Version;
  751.   UWORD X1;
  752.   ULONG Port;
  753.   ULONG UIN;
  754.   ULONG IP;
  755.   ULONG RealIP;
  756.   UWORD RevPort;
  757.   UBYTE TCP_Flag;
  758.   UWORD X2;
  759.   ULONG HandShake;
  760.   struct TCP_ChatTwo_Ext *Next;
  761. };
  762.  
  763. struct TCP_ChatTwo {
  764.   ULONG HandShake;
  765.   ULONG UIN;
  766.   char  Nick[21];
  767.   ULONG TextColor;
  768.   ULONG BackColor;
  769.   UWORD Version;
  770.   UWORD X1;
  771.   ULONG Port;
  772.   ULONG IP;
  773.   ULONG RealIP;
  774.   UBYTE TCP_Flag;
  775.   UWORD X2;
  776.   ULONG FontSize;
  777.   ULONG FontFamily;
  778.   char  FontName[128];
  779.   UBYTE X3;
  780.   UBYTE X4;
  781.   UBYTE Count;
  782.   struct TCP_ChatTwo_Ext Ext;
  783. };
  784.  
  785. struct TCP_ChatThree {
  786.   UWORD Version;
  787.   UWORD X1;
  788.   ULONG Port;
  789.   ULONG IP;
  790.   ULONG RealIP;
  791.   UBYTE TCP_Flag;
  792.   UWORD X2;
  793.   ULONG FontSize;
  794.   ULONG FontFamily;
  795.   char  FontName[128];
  796.   UWORD X3;
  797. };
  798.  
  799. struct TCP_ChatColor {
  800.   UBYTE Red;
  801.   UBYTE Green;
  802.   UBYTE Blue;
  803. };
  804.  
  805. struct TCP_ChatCmdStyle {
  806.   BOOL Bold;
  807.   BOOL Italic;
  808.   BOOL Underline;
  809. };
  810.  
  811. /*
  812. ** Structures used for parsing/creating the various message formats.
  813. */
  814.  
  815. struct MSG_Message { /* Just a plain simple message. */
  816.   char *Message;     /*   MSG_MSG, MSG_CHAT, MSG_FILE, MSG_DENY_AUTH, MSG_GIVE_AUTH */
  817. };
  818.  
  819. struct MSG_URLDesc { /* URL message. */
  820.   char *Desc;        /*   MSG_URL */
  821.   char *URL;
  822. };
  823.  
  824. struct MSG_Common {  /* Common format used by several UDP message types.          */
  825.   char *Nick;        /*   MSG_REQ_AUTH, MSG_ADDED, MSG_WEB_PAGER, MSG_EMAIL_PAGER */
  826.   char *First;
  827.   char *Last;
  828.   char *EMail;
  829.   UBYTE Authorize;
  830.   char *Message;
  831. };
  832.  
  833. struct MSG_AddUIN {  /* Used in TCP messaging to swap UINs. */
  834.   ULONG Total;
  835.   ULONG UIN;
  836.   char *Nick;
  837.   UBYTE *Next;
  838. };
  839.  
  840. #endif  /* LIBRARIES_ICQ_H */
  841.