source: zbuddylist.c @ 6329cd5

release-1.10release-1.8release-1.9
Last change on this file since 6329cd5 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
RevLine 
[dad943e]1#include "owl.h"
2
3void owl_zbuddylist_create(owl_zbuddylist *zb)
4{
[7ed9bc6]5  zb->zusers = g_ptr_array_new();
[dad943e]6}
7
[e19eb97]8int 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]25int 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]43int 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.