]> andersk Git - libfaim.git/blame - aim_buddylist.c
Big ICBM handling cleanup, including fix for the last of the IM crashes.
[libfaim.git] / aim_buddylist.c
CommitLineData
9de3ca7e 1
2#include <aim.h>
3
4/*
5 * aim_add_buddy()
6 *
7 * Adds a single buddy to your buddy list after login.
8 *
9 */
10u_long aim_add_buddy(struct aim_conn_t *conn, char *sn )
11{
12 struct command_tx_struct newpacket;
13
14 if( !sn )
15 return -1;
16
17 if (conn)
18 newpacket.conn = conn;
19 else
20 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS);
21
22 newpacket.lock = 1;
23 newpacket.type = 0x0002;
24 newpacket.commandlen = 11 + strlen( sn );
25 newpacket.data = (char *)malloc( newpacket.commandlen );
26
27 aim_putsnac(newpacket.data, 0x0003, 0x0004, 0x0000, aim_snac_nextid);
28
29 /* length of screenname */
30 newpacket.data[10] = strlen( sn );
31
32 memcpy( &(newpacket.data[11]), sn, strlen( sn ) );
33
34 aim_tx_enqueue( &newpacket );
35
36 {
37 struct aim_snac_t snac;
38
39 snac.id = aim_snac_nextid;
40 snac.family = 0x0003;
41 snac.type = 0x0004;
42 snac.flags = 0x0000;
43
44 snac.data = malloc( strlen( sn ) + 1 );
45 memcpy( snac.data, sn, strlen( sn ) + 1 );
46
47 aim_newsnac( &snac );
48 }
49
50 return( aim_snac_nextid++ );
51}
52
53u_long aim_remove_buddy(struct aim_conn_t *conn, char *sn )
54{
55 struct command_tx_struct newpacket;
56
57 if( !sn )
58 return -1;
59
60 if (conn)
61 newpacket.conn = conn;
62 else
63 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS);
64
65 newpacket.lock = 1;
66 newpacket.type = 0x0002;
67 newpacket.commandlen = 11 + strlen(sn);
68 newpacket.data = (char *)malloc( newpacket.commandlen );
69
70 aim_putsnac(newpacket.data, 0x0003, 0x0005, 0x0000, aim_snac_nextid);
71
72 /* length of screenname */
73 newpacket.data[10] = strlen( sn );
74
75 memcpy( &(newpacket.data[11]), sn, strlen( sn ) );
76
77 aim_tx_enqueue( &newpacket );
78
79 {
80 struct aim_snac_t snac;
81
82 snac.id = aim_snac_nextid;
83 snac.family = 0x0003;
84 snac.type = 0x0005;
85 snac.flags = 0x0000;
86
87 snac.data = malloc( strlen( sn ) + 1 );
88 memcpy( snac.data, sn, strlen( sn ) + 1 );
89
90 aim_newsnac( &snac );
91 }
92
93 return( aim_snac_nextid++ );
94}
95
This page took 0.062506 seconds and 5 git commands to generate.