| 23 * chan = channel for OSCAR, hdrtype for OFT |
23 * chan = channel for OSCAR, hdrtype for OFT |
| 24 * |
24 * |
| 25 */ |
25 */ |
| 26 faim_internal struct command_tx_struct *aim_tx_new(unsigned char framing, int chan, struct aim_conn_t *conn, int datalen) |
26 faim_internal struct command_tx_struct *aim_tx_new(unsigned char framing, int chan, struct aim_conn_t *conn, int datalen) |
| 27 { |
27 { |
| 28 struct command_tx_struct *new; |
28 struct command_tx_struct *newtx; |
| 29 |
29 |
| 30 if (!conn) { |
30 if (!conn) { |
| 31 printf("aim_tx_new: ERROR: no connection specified\n"); |
31 printf("aim_tx_new: ERROR: no connection specified\n"); |
| 32 return NULL; |
32 return NULL; |
| 33 } |
33 } |
| 34 |
34 |
| 35 new = (struct command_tx_struct *)malloc(sizeof(struct command_tx_struct)); |
35 newtx = (struct command_tx_struct *)malloc(sizeof(struct command_tx_struct)); |
| 36 if (!new) |
36 if (!newtx) |
| 37 return NULL; |
37 return NULL; |
| 38 memset(new, 0, sizeof(struct command_tx_struct)); |
38 memset(newtx, 0, sizeof(struct command_tx_struct)); |
| 39 |
39 |
| 40 new->conn = conn; |
40 newtx->conn = conn; |
| 41 |
41 |
| 42 if(datalen) { |
42 if(datalen) { |
| 43 new->data = (u_char *)malloc(datalen); |
43 newtx->data = (unsigned char *)malloc(datalen); |
| 44 new->commandlen = datalen; |
44 newtx->commandlen = datalen; |
| 45 } else |
45 } else |
| 46 new->data = NULL; |
46 newtx->data = NULL; |
| 47 |
47 |
| 48 new->hdrtype = framing; |
48 newtx->hdrtype = framing; |
| 49 if (new->hdrtype == AIM_FRAMETYPE_OSCAR) { |
49 if (newtx->hdrtype == AIM_FRAMETYPE_OSCAR) { |
| 50 new->hdr.oscar.type = chan; |
50 newtx->hdr.oscar.type = chan; |
| 51 } else if (new->hdrtype == AIM_FRAMETYPE_OFT) { |
51 } else if (newtx->hdrtype == AIM_FRAMETYPE_OFT) { |
| 52 new->hdr.oft.type = chan; |
52 newtx->hdr.oft.type = chan; |
| 53 new->hdr.oft.hdr2len = 0; /* this will get setup by caller */ |
53 newtx->hdr.oft.hdr2len = 0; /* this will get setup by caller */ |
| 54 } else { |
54 } else { |
| 55 printf("tx_new: unknown framing\n"); |
55 printf("tx_new: unknown framing\n"); |
| 56 } |
56 } |
| 57 |
57 |
| 58 return new; |
58 return newtx; |
| 59 } |
59 } |
| 60 |
60 |
| 61 /* |
61 /* |
| 62 * aim_tx_enqeue__queuebased() |
62 * aim_tx_enqeue__queuebased() |
| 63 * |
63 * |