release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since a06334e was
b258c51,
checked in by Anders Kaseorg <andersk@mit.edu>, 15 years ago
|
Add const qualifiers for owl_zbuddylist *.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[dad943e] | 1 | #include "owl.h" |
---|
| 2 | |
---|
| 3 | void owl_zbuddylist_create(owl_zbuddylist *zb) |
---|
| 4 | { |
---|
| 5 | owl_list_create(&(zb->zusers)); |
---|
| 6 | } |
---|
| 7 | |
---|
[e19eb97] | 8 | int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name) |
---|
[dad943e] | 9 | { |
---|
| 10 | int i, j; |
---|
| 11 | char *user; |
---|
| 12 | |
---|
| 13 | user=long_zuser(name); |
---|
| 14 | |
---|
| 15 | j=owl_list_get_size(&(zb->zusers)); |
---|
| 16 | for (i=0; i<j; i++) { |
---|
| 17 | if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) { |
---|
| 18 | owl_free(user); |
---|
| 19 | return(-1); |
---|
| 20 | } |
---|
| 21 | } |
---|
| 22 | owl_list_append_element(&(zb->zusers), user); |
---|
| 23 | return(0); |
---|
| 24 | } |
---|
| 25 | |
---|
[e19eb97] | 26 | int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name) |
---|
[dad943e] | 27 | { |
---|
| 28 | int i, j; |
---|
| 29 | char *user, *ptr; |
---|
| 30 | |
---|
| 31 | user=long_zuser(name); |
---|
| 32 | |
---|
| 33 | j=owl_list_get_size(&(zb->zusers)); |
---|
| 34 | for (i=0; i<j; i++) { |
---|
| 35 | ptr=owl_list_get_element(&(zb->zusers), i); |
---|
| 36 | if (!strcasecmp(user, ptr)) { |
---|
| 37 | owl_list_remove_element(&(zb->zusers), i); |
---|
| 38 | owl_free(ptr); |
---|
| 39 | owl_free(user); |
---|
| 40 | return(0); |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | owl_free(user); |
---|
| 44 | return(-1); |
---|
| 45 | } |
---|
| 46 | |
---|
[b258c51] | 47 | int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name) |
---|
[dad943e] | 48 | { |
---|
| 49 | int i, j; |
---|
| 50 | char *user; |
---|
| 51 | |
---|
| 52 | user=long_zuser(name); |
---|
| 53 | |
---|
| 54 | j=owl_list_get_size(&(zb->zusers)); |
---|
| 55 | for (i=0; i<j; i++) { |
---|
| 56 | if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) { |
---|
| 57 | owl_free(user); |
---|
| 58 | return(1); |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | owl_free(user); |
---|
| 62 | return(0); |
---|
| 63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.