source:
zbuddylist.c
@
6329cd5
Last change on this file since 6329cd5 was 7ed9bc6, checked in by David Benjamin <davidben@mit.edu>, 13 years ago | |
---|---|
|
|
File size: 1.0 KB |
Rev | Line | |
---|---|---|
[dad943e] | 1 | #include "owl.h" |
2 | ||
3 | void owl_zbuddylist_create(owl_zbuddylist *zb) | |
4 | { | |
[7ed9bc6] | 5 | zb->zusers = g_ptr_array_new(); |
[dad943e] | 6 | } |
7 | ||
[e19eb97] | 8 | int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name) |
[dad943e] | 9 | { |
[7ed9bc6] | 10 | int i; |
[dad943e] | 11 | char *user; |
12 | ||
13 | user=long_zuser(name); | |
14 | ||
[7ed9bc6] | 15 | for (i = 0; i < zb->zusers->len; i++) { |
16 | if (!strcasecmp(user, zb->zusers->pdata[i])) { | |
[ddbbcffa] | 17 | g_free(user); |
[dad943e] | 18 | return(-1); |
19 | } | |
20 | } | |
[7ed9bc6] | 21 | g_ptr_array_add(zb->zusers, user); |
[dad943e] | 22 | return(0); |
23 | } | |
24 | ||
[e19eb97] | 25 | int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name) |
[dad943e] | 26 | { |
[7ed9bc6] | 27 | int i; |
28 | char *user; | |
[dad943e] | 29 | |
30 | user=long_zuser(name); | |
31 | ||
[7ed9bc6] | 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)); | |
[ddbbcffa] | 35 | g_free(user); |
[dad943e] | 36 | return(0); |
37 | } | |
38 | } | |
[ddbbcffa] | 39 | g_free(user); |
[dad943e] | 40 | return(-1); |
41 | } | |
42 | ||
[b258c51] | 43 | int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name) |
[dad943e] | 44 | { |
[7ed9bc6] | 45 | int i; |
[dad943e] | 46 | char *user; |
47 | ||
48 | user=long_zuser(name); | |
49 | ||
[7ed9bc6] | 50 | for (i = 0; i < zb->zusers->len; i++) { |
51 | if (!strcasecmp(user, zb->zusers->pdata[i])) { | |
[ddbbcffa] | 52 | g_free(user); |
[dad943e] | 53 | return(1); |
54 | } | |
55 | } | |
[ddbbcffa] | 56 | g_free(user); |
[dad943e] | 57 | return(0); |
58 | } |
Note: See TracBrowser
for help on using the repository browser.