Changeset ecffae6


Ignore:
Timestamp:
Jun 25, 2011, 3:26:15 AM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
e4524da
Parents:
e6d7e4e
git-author:
David Benjamin <davidben@mit.edu> (03/11/11 16:21:42)
git-committer:
David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
Message:
Make owl_zephyr_get_anyone_list return a GPtrArray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    re6d7e4e recffae6  
    29942994#ifdef HAVE_LIBZEPHYR
    29952995  int x;
    2996   owl_list anyone;
     2996  GPtrArray *anyone;
    29972997  const char *user;
    29982998  char *tmp;
     
    30293029    } else {
    30303030      owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3031       owl_list_create(&anyone);
    3032       ret=owl_zephyr_get_anyone_list(&anyone, filename);
    3033       if (ret) {
     3031      anyone = owl_zephyr_get_anyone_list(filename);
     3032      if (anyone == NULL) {
    30343033        if (errno == ENOENT) {
    30353034          owl_fmtext_append_normal(&fm, " You have not added any zephyr buddies.  Use the\n");
     
    30413040        }
    30423041      } else {
    3043         j=owl_list_get_size(&anyone);
    3044         for (i=0; i<j; i++) {
    3045           user=owl_list_get_element(&anyone, i);
     3042        for (i = 0; i < anyone->len; i++) {
     3043          user = anyone->pdata[i];
    30463044          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30473045
     
    30753073        }
    30763074      }
    3077       owl_list_cleanup(&anyone, g_free);
     3075      g_ptr_array_foreach(anyone, (GFunc)g_free, NULL);
     3076      g_ptr_array_free(anyone, true);
    30783077    }
    30793078  }
     
    33873386{
    33883387#ifdef HAVE_LIBZEPHYR
    3389   int i, j;
    3390   owl_list anyone;
     3388  int i;
     3389  GPtrArray *anyone;
    33913390  GList **zaldlist;
    33923391  GList *zaldptr;
     
    34083407  *zaldlist = NULL;
    34093408
    3410   owl_list_create(&anyone);
    3411   owl_zephyr_get_anyone_list(&anyone, NULL);
    3412   j = owl_list_get_size(&anyone);
    3413   for (i = 0; i < j; i++) {
    3414     user = owl_list_get_element(&anyone, i);
     3409  anyone = owl_zephyr_get_anyone_list(NULL);
     3410  for (i = 0; i < anyone->len; i++) {
     3411    user = anyone->pdata[i];
    34153412    zald = g_new(ZAsyncLocateData_t, 1);
    34163413    if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
     
    34213418  }
    34223419
    3423   owl_list_cleanup(&anyone, g_free);
     3420  g_ptr_array_foreach(anyone, (GFunc)g_free, NULL);
     3421  g_ptr_array_free(anyone, true);
    34243422#endif
    34253423}
  • zephyr.c

    r12294d2 recffae6  
    13241324}
    13251325
    1326 /* read the list of users in 'filename' as a .anyone file, and put the
    1327  * names of the zephyr users in the list 'in'.  If 'filename' is NULL,
    1328  * use the default .anyone file in the users home directory.  Returns
    1329  * -1 on failure, 0 on success.
     1326/* Read the list of users in 'filename' as a .anyone file, and return as a
     1327 * GPtrArray of strings.  If 'filename' is NULL, use the default .anyone file
     1328 * in the users home directory.  Returns NULL on failure.
    13301329 */
    1331 int owl_zephyr_get_anyone_list(owl_list *in, const char *filename)
     1330GPtrArray *owl_zephyr_get_anyone_list(const char *filename)
    13321331{
    13331332#ifdef HAVE_LIBZEPHYR
    13341333  char *ourfile, *tmp, *s = NULL;
    13351334  FILE *f;
     1335  GPtrArray *list;
    13361336
    13371337  ourfile = owl_zephyr_dotfile(".anyone", filename);
     
    13411341    owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
    13421342    g_free(ourfile);
    1343     return -1;
     1343    return NULL;
    13441344  }
    13451345  g_free(ourfile);
    13461346
     1347  list = g_ptr_array_new();
    13471348  while (owl_getline_chomp(&s, f)) {
    13481349    /* ignore comments, blank lines etc. */
     
    13601361      tmp[0] = '\0';
    13611362
    1362     owl_list_append_element(in, long_zuser(s));
     1363    g_ptr_array_add(list, long_zuser(s));
    13631364  }
    13641365  g_free(s);
    13651366  fclose(f);
    1366   return 0;
    1367 #else
    1368   return -1;
     1367  return list;
     1368#else
     1369  return NULL;
    13691370#endif
    13701371}
Note: See TracChangeset for help on using the changeset viewer.