Changeset 12294d2


Ignore:
Timestamp:
Jun 25, 2011, 3:26:15 AM (6 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
fc8a87a
Parents:
6829afc
git-author:
David Benjamin <davidben@mit.edu> (03/10/11 12:12:21)
git-committer:
David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
Message:
Remove owl_list from owl_zwrite

Use a GPtrArray directly.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    r6829afc r12294d2  
    342342  char *zsig;
    343343  char *message;
    344   owl_list recips;
     344  GPtrArray *recips;
    345345  int cc;
    346346  int noping;
  • zephyr.c

    r6829afc r12294d2  
    838838      zw.opcode = g_strdup(retnotice->z_opcode);
    839839      zw.zsig   = g_strdup("");
    840       owl_list_create(&(zw.recips));
    841       owl_list_append_element(&(zw.recips), g_strdup(retnotice->z_recipient));
     840      zw.recips = g_ptr_array_new();
     841      g_ptr_array_add(zw.recips, g_strdup(retnotice->z_recipient));
    842842
    843843      owl_log_outgoing_zephyr_error(&zw, buff);
  • zwrite.c

    r6829afc r12294d2  
    3434  z->cc=0;
    3535  z->noping=0;
    36   owl_list_create(&(z->recips));
     36  z->recips = g_ptr_array_new();
    3737  z->zwriteline = g_strdup(line);
    3838
     
    9797      }
    9898      /* we must already have users or a class or an instance */
    99       if (owl_list_get_size(&(z->recips))<1 && (!z->class) && (!z->inst)) {
     99      if (z->recips->len < 1 && (!z->class) && (!z->inst)) {
    100100        badargs=1;
    101101        break;
     
    117117    } else {
    118118      /* anything unattached is a recipient */
    119       owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0]));
     119      g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));
    120120      myargv++;
    121121      myargc--;
     
    131131  if (z->class == NULL &&
    132132      z->inst == NULL &&
    133       owl_list_get_size(&(z->recips))==0) {
     133      z->recips->len == 0) {
    134134    owl_function_error("You must specify a recipient for zwrite");
    135135    return(-1);
     
    162162void owl_zwrite_send_ping(const owl_zwrite *z)
    163163{
    164   int i, j;
     164  int i;
    165165  char *to;
    166166
     
    173173  /* if there are no recipients we won't send a ping, which
    174174     is what we want */
    175   j=owl_list_get_size(&(z->recips));
    176   for (i=0; i<j; i++) {
     175  for (i = 0; i < z->recips->len; i++) {
    177176    to = owl_zwrite_get_recip_n_with_realm(z, i);
    178177    send_ping(to, z->class, z->inst);
     
    191190void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    192191{
    193   int i, j;
     192  int i;
    194193  GString *message;
    195194  char *tmp = NULL, *tmp2;
     
    197196  g_free(z->message);
    198197
    199   j=owl_list_get_size(&(z->recips));
    200   if (j>0 && z->cc) {
     198  if (z->recips->len > 0 && z->cc) {
    201199    message = g_string_new("CC: ");
    202     for (i=0; i<j; i++) {
     200    for (i = 0; i < z->recips->len; i++) {
    203201      tmp = owl_zwrite_get_recip_n_with_realm(z, i);
    204202      g_string_append_printf(message, "%s ", tmp);
     
    233231int owl_zwrite_send_message(const owl_zwrite *z)
    234232{
    235   int i, j, ret = 0;
     233  int i, ret = 0;
    236234  char *to = NULL;
    237235
    238236  if (z->message==NULL) return(-1);
    239237
    240   j=owl_list_get_size(&(z->recips));
    241   if (j>0) {
    242     for (i=0; i<j; i++) {
     238  if (z->recips->len > 0) {
     239    for (i = 0; i < z->recips->len; i++) {
    243240      to = owl_zwrite_get_recip_n_with_realm(z, i);
    244241      ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
     
    312309int owl_zwrite_get_numrecips(const owl_zwrite *z)
    313310{
    314   return(owl_list_get_size(&(z->recips)));
     311  return z->recips->len;
    315312}
    316313
    317314const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n)
    318315{
    319   return(owl_list_get_element(&(z->recips), n));
     316  return z->recips->pdata[n];
    320317}
    321318
     
    333330{
    334331  /* return true if at least one of the recipients is personal */
    335   int i, j;
    336   char *foo;
    337 
    338   j=owl_list_get_size(&(z->recips));
    339   for (i=0; i<j; i++) {
    340     foo=owl_list_get_element(&(z->recips), i);
    341     if (foo[0]!='@') return(1);
     332  int i;
     333  char *recip;
     334
     335  for (i = 0; i < z->recips->len; i++) {
     336    recip = z->recips->pdata[i];
     337    if (recip[0] != '@') return 1;
    342338  }
    343339  return(0);
     
    352348void owl_zwrite_cleanup(owl_zwrite *z)
    353349{
    354   owl_list_cleanup(&(z->recips), &g_free);
     350  g_ptr_array_foreach(z->recips, (GFunc)g_free, NULL);
     351  g_ptr_array_free(z->recips, true);
    355352  g_free(z->cmd);
    356353  g_free(z->zwriteline);
     
    403400  }
    404401  if (z->cc) {
    405     for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
     402    for (i = 0; i < z->recips->len; i++) {
    406403      g_string_append_c(buf, ' ');
    407       owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
     404      owl_string_append_quoted_arg(buf, z->recips->pdata[i]);
    408405    }
    409   } else if (recip_index < owl_list_get_size(&(z->recips))) {
     406  } else if (recip_index < z->recips->len) {
    410407    g_string_append_c(buf, ' ');
    411     owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index));
     408    owl_string_append_quoted_arg(buf, z->recips->pdata[recip_index]);
    412409  }
    413410
Note: See TracChangeset for help on using the changeset viewer.