Changeset 37eab7f for logging.c


Ignore:
Timestamp:
Oct 25, 2003, 11:53:43 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
eec69e1
Parents:
8c92848
Message:
Added the loopback message type
Added the loopwrite command
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r15283bb r37eab7f  
    5555}
    5656
    57 void owl_log_outgoing_aim(char *to, char *text) {
     57void owl_log_outgoing_aim(char *to, char *text)
     58{
    5859  FILE *file;
    5960  char filename[MAXPATHLEN], *logpath;
     
    6162
    6263  tobuff=owl_sprintf("aim:%s", to);
     64
     65  /* expand ~ in path names */
     66  logpath = owl_util_substitute(owl_global_get_logpath(&g), "~",
     67                                owl_global_get_homedir(&g));
     68
     69  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     70  file=fopen(filename, "a");
     71  if (!file) {
     72    owl_function_error("Unable to open file for outgoing logging");
     73    owl_free(logpath);
     74    return;
     75  }
     76  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     77  if (text[strlen(text)-1]!='\n') {
     78    fprintf(file, "\n");
     79  }
     80  fclose(file);
     81
     82  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
     83  owl_free(logpath);
     84  file=fopen(filename, "a");
     85  if (!file) {
     86    owl_function_error("Unable to open file for outgoing logging");
     87    return;
     88  }
     89  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     90  if (text[strlen(text)-1]!='\n') {
     91    fprintf(file, "\n");
     92  }
     93  fclose(file);
     94
     95  owl_free(tobuff);
     96}
     97
     98void owl_log_outgoing_loopback(char *text)
     99{
     100  FILE *file;
     101  char filename[MAXPATHLEN], *logpath;
     102  char *tobuff;
     103
     104  tobuff=owl_sprintf("loopback:%s", "loppback");
    63105
    64106  /* expand ~ in path names */
     
    142184    /* we do not yet handle chat rooms */
    143185    from=frombuff=owl_sprintf("aim:%s", owl_message_get_sender(m));
     186  } else if (owl_message_is_type_loopback(m)) {
     187    from=frombuff=owl_strdup("loopback");
    144188  } else {
    145189    from=frombuff=owl_strdup("unknown");
     
    220264    if (owl_message_is_login(m)) fprintf(file, "LOGIN\n\n");
    221265    if (owl_message_is_logout(m)) fprintf(file, "LOGOUT\n\n");
    222   }
     266  } else {
     267    fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
     268    fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
     269    fprintf(file, "%s\n\n", owl_message_get_body(m));
     270  }
     271
    223272  fclose(file);
    224273
     
    245294      if (owl_message_is_login(m)) fprintf(allfile, "LOGIN\n\n");
    246295      if (owl_message_is_logout(m)) fprintf(allfile, "LOGOUT\n\n");
     296    } else {
     297      fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
     298      fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
     299      fprintf(file, "%s\n\n", owl_message_get_body(m));
    247300    }
    248301    fclose(allfile);
Note: See TracChangeset for help on using the changeset viewer.