Mercurial > pidgin.yaz
comparison src/protocols/oscar/chat.c @ 11074:ba630d7a7365
[gaim-migrate @ 13083]
sf patch #1233671, from Ryan McCabe
eliminate the usage of ->priv in libfaim
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 09 Jul 2005 19:26:49 +0000 |
parents | b45613311dab |
children | bd8ac1d4b2f2 |
comparison
equal
deleted
inserted
replaced
11073:634fec5ed0f2 | 11074:ba630d7a7365 |
---|---|
6 #define FAIM_INTERNAL | 6 #define FAIM_INTERNAL |
7 #include <aim.h> | 7 #include <aim.h> |
8 | 8 |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 /* Stored in the ->priv of chat connections */ | 11 /* Stored in the ->internal of chat connections */ |
12 struct chatconnpriv { | 12 struct chatconnpriv { |
13 fu16_t exchange; | 13 fu16_t exchange; |
14 char *name; | 14 char *name; |
15 fu16_t instance; | 15 fu16_t instance; |
16 }; | 16 }; |
17 | 17 |
18 faim_internal void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn) | 18 faim_internal void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn) |
19 { | 19 { |
20 struct chatconnpriv *ccp = (struct chatconnpriv *)conn->priv; | 20 struct chatconnpriv *ccp = (struct chatconnpriv *)conn->internal; |
21 | 21 |
22 if (ccp) | 22 if (ccp) |
23 free(ccp->name); | 23 free(ccp->name); |
24 free(ccp); | 24 free(ccp); |
25 | 25 |
34 return NULL; | 34 return NULL; |
35 | 35 |
36 if (conn->type != AIM_CONN_TYPE_CHAT) | 36 if (conn->type != AIM_CONN_TYPE_CHAT) |
37 return NULL; | 37 return NULL; |
38 | 38 |
39 ccp = (struct chatconnpriv *)conn->priv; | 39 ccp = (struct chatconnpriv *)conn->internal; |
40 | 40 |
41 return ccp->name; | 41 return ccp->name; |
42 } | 42 } |
43 | 43 |
44 /* XXX get this into conn.c -- evil!! */ | 44 /* XXX get this into conn.c -- evil!! */ |
45 faim_export aim_conn_t *aim_chat_getconn(aim_session_t *sess, const char *name) | 45 faim_export aim_conn_t *aim_chat_getconn(aim_session_t *sess, const char *name) |
46 { | 46 { |
47 aim_conn_t *cur; | 47 aim_conn_t *cur; |
48 | 48 |
49 for (cur = sess->connlist; cur; cur = cur->next) { | 49 for (cur = sess->connlist; cur; cur = cur->next) { |
50 struct chatconnpriv *ccp = (struct chatconnpriv *)cur->priv; | 50 struct chatconnpriv *ccp = (struct chatconnpriv *)cur->internal; |
51 | 51 |
52 if (cur->type != AIM_CONN_TYPE_CHAT) | 52 if (cur->type != AIM_CONN_TYPE_CHAT) |
53 continue; | 53 continue; |
54 if (!cur->priv) { | 54 if (!cur->internal) { |
55 faimdprintf(sess, 0, "faim: chat: chat connection with no name! (fd = %d)\n", cur->fd); | 55 faimdprintf(sess, 0, "faim: chat: chat connection with no name! (fd = %d)\n", cur->fd); |
56 continue; | 56 continue; |
57 } | 57 } |
58 | 58 |
59 if (strcmp(ccp->name, name) == 0) | 59 if (strcmp(ccp->name, name) == 0) |
68 struct chatconnpriv *ccp; | 68 struct chatconnpriv *ccp; |
69 | 69 |
70 if (!conn || !roomname) | 70 if (!conn || !roomname) |
71 return -EINVAL; | 71 return -EINVAL; |
72 | 72 |
73 if (conn->priv) | 73 if (conn->internal) |
74 free(conn->priv); | 74 free(conn->internal); |
75 | 75 |
76 if (!(ccp = malloc(sizeof(struct chatconnpriv)))) | 76 if (!(ccp = malloc(sizeof(struct chatconnpriv)))) |
77 return -ENOMEM; | 77 return -ENOMEM; |
78 | 78 |
79 ccp->exchange = exchange; | 79 ccp->exchange = exchange; |
80 ccp->name = strdup(roomname); | 80 ccp->name = strdup(roomname); |
81 ccp->instance = instance; | 81 ccp->instance = instance; |
82 | 82 |
83 conn->priv = (void *)ccp; | 83 conn->internal = (void *)ccp; |
84 | 84 |
85 return 0; | 85 return 0; |
86 } | 86 } |
87 | 87 |
88 faim_internal int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo) | 88 faim_internal int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo) |