forked from barnowl/barnowl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zbuddylist.c
58 lines (48 loc) · 1.04 KB
/
zbuddylist.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "owl.h"
void owl_zbuddylist_create(owl_zbuddylist *zb)
{
zb->zusers = g_ptr_array_new();
}
int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name)
{
int i;
char *user;
user=long_zuser(name);
for (i = 0; i < zb->zusers->len; i++) {
if (!strcasecmp(user, zb->zusers->pdata[i])) {
g_free(user);
return(-1);
}
}
g_ptr_array_add(zb->zusers, user);
return(0);
}
int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name)
{
int i;
char *user;
user=long_zuser(name);
for (i = 0; i < zb->zusers->len; i++) {
if (!strcasecmp(user, zb->zusers->pdata[i])) {
g_free(g_ptr_array_remove_index(zb->zusers, i));
g_free(user);
return(0);
}
}
g_free(user);
return(-1);
}
int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name)
{
int i;
char *user;
user=long_zuser(name);
for (i = 0; i < zb->zusers->len; i++) {
if (!strcasecmp(user, zb->zusers->pdata[i])) {
g_free(user);
return(1);
}
}
g_free(user);
return(0);
}