Mercurial > pidgin.yaz
annotate libfaim/aim_buddylist.c @ 1530:0b6e4d52de63
[gaim-migrate @ 1540]
possible segfault?
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 04 Mar 2001 01:00:08 +0000 |
parents | 920c86b753d7 |
children |
rev | line source |
---|---|
2 | 1 |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
2 #include <faim/aim.h> |
2 | 3 |
4 /* | |
5 * aim_add_buddy() | |
6 * | |
7 * Adds a single buddy to your buddy list after login. | |
8 * | |
9 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
10 faim_export unsigned long aim_add_buddy(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
11 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
12 char *sn ) |
2 | 13 { |
237 | 14 struct command_tx_struct *newpacket; |
15 int i; | |
2 | 16 |
237 | 17 if(!sn) |
18 return -1; | |
2 | 19 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
20 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 21 return -1; |
22 | |
23 newpacket->lock = 1; | |
2 | 24 |
237 | 25 i = aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid); |
26 i += aimutil_put8(newpacket->data+i, strlen(sn)); | |
27 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 28 |
237 | 29 aim_tx_enqueue(sess, newpacket ); |
2 | 30 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
31 aim_cachesnac(sess, 0x0003, 0x0004, 0x0000, sn, strlen(sn)+1); |
2 | 32 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
33 return sess->snac_nextid; |
2 | 34 } |
35 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
36 faim_export unsigned long aim_remove_buddy(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
37 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
38 char *sn ) |
2 | 39 { |
237 | 40 struct command_tx_struct *newpacket; |
41 int i; | |
2 | 42 |
237 | 43 if(!sn) |
44 return -1; | |
2 | 45 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
46 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 47 return -1; |
48 | |
49 newpacket->lock = 1; | |
2 | 50 |
237 | 51 i = aim_putsnac(newpacket->data, 0x0003, 0x0005, 0x0000, sess->snac_nextid); |
2 | 52 |
237 | 53 i += aimutil_put8(newpacket->data+i, strlen(sn)); |
54 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 55 |
237 | 56 aim_tx_enqueue(sess, newpacket); |
2 | 57 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
58 aim_cachesnac(sess, 0x0003, 0x0005, 0x0000, sn, strlen(sn)+1); |
2 | 59 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
60 return sess->snac_nextid; |
2 | 61 } |
62 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
63 faim_internal int aim_parse_buddyrights(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
64 struct command_rx_struct *command, ...) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
65 { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
66 rxcallback_t userfunc = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
67 int ret=1; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
68 struct aim_tlvlist_t *tlvlist; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
69 unsigned short maxbuddies = 0, maxwatchers = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
70 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
71 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
72 * TLVs follow |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
73 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
74 if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10))) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
75 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
76 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
77 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
78 * TLV type 0x0001: Maximum number of buddies. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
79 */ |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
80 if (aim_gettlv(tlvlist, 0x0001, 1)) |
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
81 maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1); |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
82 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
83 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
84 * TLV type 0x0002: Maximum number of watchers. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
85 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
86 * XXX: what the hell is a watcher? |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
87 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
88 */ |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
89 if (aim_gettlv(tlvlist, 0x0002, 1)) |
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
90 maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1); |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
91 |
1248
920c86b753d7
[gaim-migrate @ 1258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
92 if ((userfunc = aim_callhandler(command->conn, 0x0003, 0x0003))) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
93 ret = userfunc(sess, command, maxbuddies, maxwatchers); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
94 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
95 aim_freetlvchain(&tlvlist); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
96 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
97 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
98 } |