annotate libfaim/aim_msgcookie.c @ 1382:0ccf91652dac

[gaim-migrate @ 1392] Feel the sting of my bononononono committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 05 Jan 2001 01:52:57 +0000
parents c00fc3adfd66
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
1 /*
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
2 * Cookie Caching stuff. Adam wrote this, apparently just some
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
3 * derivatives of n's SNAC work. I cleaned it up, added comments.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
4 *
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
5 * I'm going to rewrite this stuff eventually, honest. -jbm
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
6 *
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
7 */
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 /*
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
10 * I'm assuming that cookies are type-specific. that is, we can have
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
11 * "1234578" for type 1 and type 2 concurrently. if i'm wrong, then we
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
12 * lose some error checking. if we assume cookies are not type-specific and are
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
13 * wrong, we get quirky behavior when cookies step on each others' toes.
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 */
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #include <faim/aim.h>
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
18 /*
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
19 * aim_cachecookie:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
20 * appends a cookie to the cookie list for sess.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
21 * - if cookie->cookie for type cookie->type is found, addtime is updated.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
22 * - copies cookie struct; you need to free() it afterwards;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
23 * - cookie->data is not copied, but passed along. don't free it.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
24 * - newcook->addtime is updated accordingly;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
25 * - cookie->type is just passed across.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
26 *
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
27 * returns -1 on error, 0 on success.
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
28 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
29 faim_internal int aim_cachecookie(struct aim_session_t *sess,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
30 struct aim_msgcookie_t *cookie)
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 {
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
32 struct aim_msgcookie_t *newcook;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
33
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 if (!cookie)
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 return -1;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
37 if( (newcook = aim_checkcookie(sess, cookie->cookie, cookie->type)) ) {
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
38 newcook->addtime = time(NULL);
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
39 if(cookie->data != newcook->data) {
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
40
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
41 printf("faim: cachecookie: matching cookie/type pair "
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
42 "%x%x%x%x%x%x%x%x/%x has different *data. free()ing cookie copy..\n",
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
43 cookie->cookie[0], cookie->cookie[1], cookie->cookie[2],
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
44 cookie->cookie[3], cookie->cookie[4], cookie->cookie[5],
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
45 cookie->cookie[6], cookie->cookie[7], cookie->type);
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
46
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
47 free(cookie->data);
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
48 }
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
49
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
50 return 0;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
51 }
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
52
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 if (!(newcook = malloc(sizeof(struct aim_msgcookie_t))))
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 return -1;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 memcpy(newcook, cookie, sizeof(struct aim_msgcookie_t));
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 newcook->addtime = time(NULL);
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
57
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
58 newcook->next = sess->msgcookies;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
59 sess->msgcookies = newcook;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
60
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 return 0;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
64 /*
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
65 * aim_uncachecookie:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
66 * takes a cookie string and grabs the cookie struct associated with
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
67 * it. removes struct from chain. returns the struct if found, or
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
68 * NULL on not found.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
69 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
70 faim_internal struct aim_msgcookie_t *aim_uncachecookie(struct aim_session_t *sess, unsigned char *cookie, int type)
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 {
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 struct aim_msgcookie_t *cur;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
74 if (!cookie || !sess->msgcookies)
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 return NULL;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
77 if ((sess->msgcookies->type == type) &&
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
78 (memcmp(sess->msgcookies->cookie, cookie, 8) == 0)) {
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
79 struct aim_msgcookie_t *tmp;
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
81 tmp = sess->msgcookies;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
82 sess->msgcookies = sess->msgcookies->next;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
83
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
84 return tmp;
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
87 for (cur = sess->msgcookies; cur->next; cur = cur->next) {
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
88 if ((cur->next->type == type) &&
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
89 (memcmp(cur->next->cookie, cookie, 8) == 0)) {
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 struct aim_msgcookie_t *tmp;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 tmp = cur->next;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 cur->next = cur->next->next;
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
94
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 return tmp;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 }
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
98
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 return NULL;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 /*
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
103 * aim_purgecookies:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
104 * purge out old cookies
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
105 *
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
106 * finds old cookies, calls uncache on them.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
107 *
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
108 * this is highly inefficient, but It Works. and i don't feel like
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
109 * totally rewriting this. it might have some concurrency issues as
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
110 * well, if i rewrite it.
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
111 *
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
112 * i'll avoid the puns.
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 */
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
114
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
115 faim_export int aim_purgecookies(struct aim_session_t *sess, int maxage)
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 {
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 struct aim_msgcookie_t *cur;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 time_t curtime;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
120 curtime = time(NULL);
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
121
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
122 for (cur = sess->msgcookies; cur; cur = cur->next) {
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
123 if (cur->addtime > (time(NULL) - maxage)) {
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
124 struct aim_msgcookie_t *remed = NULL;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
125
1186
c00fc3adfd66 [gaim-migrate @ 1196]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1184
diff changeset
126 #if 1
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 printf("aimmsgcookie: WARNING purged obsolete message cookie %x%x%x%x %x%x%x%x\n",
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 cur->cookie[0], cur->cookie[1], cur->cookie[2], cur->cookie[3],
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 cur->cookie[4], cur->cookie[5], cur->cookie[6], cur->cookie[7]);
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 #endif
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
131
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
132 remed = aim_uncachecookie(sess, cur->cookie, cur->type);
338
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 if (remed) {
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 if (remed->data)
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 free(remed->data);
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 free(remed);
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 return 0;
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 }
9d258a0aa560 [gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
144 faim_internal struct aim_msgcookie_t *aim_mkcookie(unsigned char *c, int type, void *data)
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
145 {
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
146 struct aim_msgcookie_t *cookie;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
147
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
148 if (!c)
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
149 return NULL;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
150
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
151 if (!(cookie = calloc(1, sizeof(struct aim_msgcookie_t))))
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
152 return NULL;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
153
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
154 cookie->data = data;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
155 cookie->type = type;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
156 memcpy(cookie->cookie, c, 8);
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
157
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
158 return cookie;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
159 }
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
160
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
161 faim_internal struct aim_msgcookie_t *aim_checkcookie(struct aim_session_t *sess, unsigned char *cookie, int type)
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
162 {
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
163 struct aim_msgcookie_t *cur;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
164
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
165 for (cur = sess->msgcookies; cur; cur = cur->next) {
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
166 if ((cur->type == type) &&
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
167 (memcmp(cur->cookie, cookie, 8) == 0))
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
168 return cur;
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
169 }
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
170
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
171 return NULL;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
172 }
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
173
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
174 static int aim_freecookie(struct aim_msgcookie_t *cookie) {
1184
ed8855ae6632 [gaim-migrate @ 1194]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
175 return 0;
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
176 }
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
177
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 503
diff changeset
178 faim_internal int aim_msgcookie_gettype(int reqclass) {
503
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
179 /* XXX: hokey-assed. needs fixed. */
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
180 switch(reqclass) {
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
181 case AIM_CAPS_BUDDYICON:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
182 return AIM_COOKIETYPE_OFTICON;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
183 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
184 case AIM_CAPS_VOICE:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
185 return AIM_COOKIETYPE_OFTVOICE;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
186 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
187 case AIM_CAPS_IMIMAGE:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
188 return AIM_COOKIETYPE_OFTIMAGE;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
189 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
190 case AIM_CAPS_CHAT:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
191 return AIM_COOKIETYPE_CHAT;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
192 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
193 case AIM_CAPS_GETFILE:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
194 return AIM_COOKIETYPE_OFTGET;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
195 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
196 case AIM_CAPS_SENDFILE:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
197 return AIM_COOKIETYPE_OFTSEND;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
198 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
199 default:
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
200 return AIM_COOKIETYPE_UNKNOWN;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
201 break;
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
202 }
6e318907bcce [gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
203 }