Changeset 5ebff60 for protocols/oscar/snac.c
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/snac.c
raf359b4 r5ebff60 1 1 /* 2 2 * 3 * Various SNAC-related dodads... 3 * Various SNAC-related dodads... 4 4 * 5 5 * outstanding_snacs is a list of aim_snac_t structs. A SNAC should be added 6 6 * whenever a new SNAC is sent and it should remain in the list until the 7 * response for it has been receieved. 7 * response for it has been receieved. 8 8 * 9 9 * cleansnacs() should be called periodically by the client in order … … 24 24 int i; 25 25 26 for (i = 0; i < AIM_SNAC_HASH_SIZE; i++) 26 for (i = 0; i < AIM_SNAC_HASH_SIZE; i++) { 27 27 sess->snac_hash[i] = NULL; 28 } 28 29 29 30 return; 30 31 } 31 32 32 aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen) 33 aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags, 34 const void *data, const int datalen) 33 35 { 34 36 aim_snac_t snac; … … 40 42 41 43 if (datalen) { 42 if (!(snac.data = g_malloc(datalen))) 44 if (!(snac.data = g_malloc(datalen))) { 43 45 return 0; /* er... */ 46 } 44 47 memcpy(snac.data, data, datalen); 45 } else 48 } else { 46 49 snac.data = NULL; 50 } 47 51 48 52 return aim_newsnac(sess, &snac); … … 58 62 int index; 59 63 60 if (!newsnac) 64 if (!newsnac) { 61 65 return 0; 66 } 62 67 63 if (!(snac = g_malloc(sizeof(aim_snac_t)))) 68 if (!(snac = g_malloc(sizeof(aim_snac_t)))) { 64 69 return 0; 70 } 65 71 memcpy(snac, newsnac, sizeof(aim_snac_t)); 66 72 snac->issuetime = time(NULL); … … 68 74 index = snac->id % AIM_SNAC_HASH_SIZE; 69 75 70 snac->next = (aim_snac_t *) sess->snac_hash[index];71 sess->snac_hash[index] = (void *) snac;76 snac->next = (aim_snac_t *) sess->snac_hash[index]; 77 sess->snac_hash[index] = (void *) snac; 72 78 73 79 return snac->id; … … 75 81 76 82 /* 77 * Finds a snac structure with the passed SNAC ID, 83 * Finds a snac structure with the passed SNAC ID, 78 84 * removes it from the list/hash, and returns a pointer to it. 79 85 * … … 81 87 * 82 88 */ 83 aim_snac_t *aim_remsnac(aim_session_t *sess, aim_snacid_t id) 89 aim_snac_t *aim_remsnac(aim_session_t *sess, aim_snacid_t id) 84 90 { 85 91 aim_snac_t *cur, **prev; … … 88 94 index = id % AIM_SNAC_HASH_SIZE; 89 95 90 for (prev = (aim_snac_t **) &sess->snac_hash[index]; (cur = *prev); ) {96 for (prev = (aim_snac_t **) &sess->snac_hash[index]; (cur = *prev); ) { 91 97 if (cur->id == id) { 92 98 *prev = cur->next; 93 99 return cur; 94 } else 100 } else { 95 101 prev = &cur->next; 102 } 96 103 } 97 104 … … 114 121 time_t curtime; 115 122 116 if (!sess->snac_hash[i]) 123 if (!sess->snac_hash[i]) { 117 124 continue; 125 } 118 126 119 127 curtime = time(NULL); /* done here in case we waited for the lock */ 120 128 121 for (prev = (aim_snac_t **) &sess->snac_hash[i]; (cur = *prev); ) {129 for (prev = (aim_snac_t **) &sess->snac_hash[i]; (cur = *prev); ) { 122 130 if ((curtime - cur->issuetime) > maxage) { 123 131 … … 128 136 g_free(cur); 129 137 130 } else 138 } else { 131 139 prev = &cur->next; 140 } 132 141 } 133 142 }
Note: See TracChangeset
for help on using the changeset viewer.