Changeset 839697d


Ignore:
Timestamp:
May 7, 2010, 9:40:35 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
4727d31
Parents:
a41c8d1
git-author:
Nelson Elhage <nelhage@mit.edu> (05/07/10 20:31:20)
git-committer:
Nelson Elhage <nelhage@mit.edu> (05/07/10 21:40:35)
Message:
Make owl_message_get_cc_without_recipient return a GList.

Signed-off-by: Nelson Elhage <nelhage@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r91634ec r839697d  
    128128  char filename[MAXPATHLEN], *logpath;
    129129  char *to, *temp;
     130  GList *cc;
    130131
    131132  /* expand ~ in path names */
     
    135136  if (owl_message_is_type_zephyr(m)) {
    136137    /* If this has CC's, do all but the "recipient" which we'll do below */
    137     to = owl_message_get_cc_without_recipient(m);
    138     if (to != NULL) {
    139       temp = strtok(to, " ");
    140       while (temp != NULL) {
    141           temp = short_zuser(temp);
    142           snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    143           owl_log_append(m, filename);
    144           temp = strtok(NULL, " ");
    145       }
    146       owl_free(to);
    147     }
     138    cc = owl_message_get_cc_without_recipient(m);
     139    while (cc != NULL) {
     140      temp = short_zuser(cc->data);
     141      snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     142      owl_log_append(m, filename);
     143
     144      owl_free(cc->data);
     145      cc = g_list_delete_link(cc, cc);
     146    }
     147
    148148    to = short_zuser(owl_message_get_recipient(m));
    149149  } else if (owl_message_is_type_jabber(m)) {
     
    325325     * the sender, as well.
    326326     */
    327     char *cc, *temp;
     327    char *temp;
     328    GList *cc;
    328329    cc = owl_message_get_cc_without_recipient(m);
    329     if (cc != NULL) {
    330       temp = strtok(cc, " ");
    331       while (temp != NULL) {
    332         temp = short_zuser(temp);
    333         if (strcasecmp(temp, frombuff) != 0) {
    334           snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    335           owl_log_append(m, filename);
    336         }
    337         temp = strtok(NULL, " ");
     330    while (cc != NULL) {
     331      temp = short_zuser(cc->data);
     332      if (strcasecmp(temp, frombuff) != 0) {
     333        snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     334        owl_log_append(m, filename);
    338335      }
    339       owl_free(cc);
     336
     337      owl_free(cc->data);
     338      cc = g_list_delete_link(cc, cc);
    340339    }
    341340  }
  • message.c

    r9a7b4f2 r839697d  
    584584
    585585/* caller must free return value */
    586 char *owl_message_get_cc_without_recipient(const owl_message *m)
    587 {
    588   char *cc, *out, *end, *shortuser, *recip;
     586GList *owl_message_get_cc_without_recipient(const owl_message *m)
     587{
     588  char *cc, *shortuser, *recip;
    589589  const char *user;
     590  GList *out = NULL;
    590591
    591592  cc = owl_message_get_cc(m);
     
    594595
    595596  recip = short_zuser(owl_message_get_recipient(m));
    596   out = owl_malloc(strlen(cc) + 2);
    597   end = out;
    598597
    599598  user = strtok(cc, " ");
     
    601600    shortuser = short_zuser(user);
    602601    if (strcasecmp(shortuser, recip) != 0) {
    603       strcpy(end, user);
    604       end[strlen(user)] = ' ';
    605       end += strlen(user) + 1;
     602      out = g_list_prepend(out, owl_strdup(user));
    606603    }
    607604    owl_free(shortuser);
    608605    user = strtok(NULL, " ");
    609606  }
    610   end[0] = '\0';
    611607
    612608  owl_free(recip);
    613609  owl_free(cc);
    614 
    615   if (strlen(out) == 0) {
    616     owl_free(out);
    617     out = NULL;
    618   }
    619610
    620611  return(out);
Note: See TracChangeset for help on using the changeset viewer.