release-1.10release-1.8release-1.9
Last change
on this file since 731e921 was
7ed9bc6,
checked in by David Benjamin <davidben@mit.edu>, 13 years ago
|
Replace owl_zbuddlist's owl_list with GPtrArray
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #include "owl.h" |
---|
2 | |
---|
3 | void owl_zbuddylist_create(owl_zbuddylist *zb) |
---|
4 | { |
---|
5 | zb->zusers = g_ptr_array_new(); |
---|
6 | } |
---|
7 | |
---|
8 | int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name) |
---|
9 | { |
---|
10 | int i; |
---|
11 | char *user; |
---|
12 | |
---|
13 | user=long_zuser(name); |
---|
14 | |
---|
15 | for (i = 0; i < zb->zusers->len; i++) { |
---|
16 | if (!strcasecmp(user, zb->zusers->pdata[i])) { |
---|
17 | g_free(user); |
---|
18 | return(-1); |
---|
19 | } |
---|
20 | } |
---|
21 | g_ptr_array_add(zb->zusers, user); |
---|
22 | return(0); |
---|
23 | } |
---|
24 | |
---|
25 | int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name) |
---|
26 | { |
---|
27 | int i; |
---|
28 | char *user; |
---|
29 | |
---|
30 | user=long_zuser(name); |
---|
31 | |
---|
32 | for (i = 0; i < zb->zusers->len; i++) { |
---|
33 | if (!strcasecmp(user, zb->zusers->pdata[i])) { |
---|
34 | g_free(g_ptr_array_remove_index(zb->zusers, i)); |
---|
35 | g_free(user); |
---|
36 | return(0); |
---|
37 | } |
---|
38 | } |
---|
39 | g_free(user); |
---|
40 | return(-1); |
---|
41 | } |
---|
42 | |
---|
43 | int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name) |
---|
44 | { |
---|
45 | int i; |
---|
46 | char *user; |
---|
47 | |
---|
48 | user=long_zuser(name); |
---|
49 | |
---|
50 | for (i = 0; i < zb->zusers->len; i++) { |
---|
51 | if (!strcasecmp(user, zb->zusers->pdata[i])) { |
---|
52 | g_free(user); |
---|
53 | return(1); |
---|
54 | } |
---|
55 | } |
---|
56 | g_free(user); |
---|
57 | return(0); |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.