Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 63 lines (53 sloc) 1.226 kb
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 59 60 61 62 63
#include "owl.h"

void owl_zbuddylist_create(owl_zbuddylist *zb)
{
  owl_list_create(&(zb->zusers));
}

int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name)
{
  int i, j;
  char *user;

  user=long_zuser(name);

  j=owl_list_get_size(&(zb->zusers));
  for (i=0; i<j; i++) {
    if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
      g_free(user);
      return(-1);
    }
  }
  owl_list_append_element(&(zb->zusers), user);
  return(0);
}

int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name)
{
  int i, j;
  char *user, *ptr;

  user=long_zuser(name);

  j=owl_list_get_size(&(zb->zusers));
  for (i=0; i<j; i++) {
    ptr=owl_list_get_element(&(zb->zusers), i);
    if (!strcasecmp(user, ptr)) {
      owl_list_remove_element(&(zb->zusers), i);
      g_free(ptr);
      g_free(user);
      return(0);
    }
  }
  g_free(user);
  return(-1);
}

int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name)
{
  int i, j;
  char *user;

  user=long_zuser(name);

  j=owl_list_get_size(&(zb->zusers));
  for (i=0; i<j; i++) {
    if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
      g_free(user);
      return(1);
    }
  }
  g_free(user);
  return(0);
}
Something went wrong with that request. Please try again.