- Timestamp:
- Jun 5, 2003, 2:53:47 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 884c272
- Parents:
- 5789230
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
logging.c
rd09e5a1 raac889a 7 7 static const char fileIdent[] = "$Id$"; 8 8 9 void owl_log_outgoing (char *to, char *text) {9 void owl_log_outgoing_zephyr(char *to, char *text) { 10 10 FILE *file; 11 11 char filename[MAXPATHLEN], *logpath; … … 20 20 *ptr='\0'; 21 21 } 22 23 /* expand ~ in path names */ 24 logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 25 owl_global_get_homedir(&g)); 26 27 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff); 28 file=fopen(filename, "a"); 29 if (!file) { 30 owl_function_makemsg("Unable to open file for outgoing logging"); 31 owl_free(logpath); 32 return; 33 } 34 fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); 35 if (text[strlen(text)-1]!='\n') { 36 fprintf(file, "\n"); 37 } 38 fclose(file); 39 40 snprintf(filename, MAXPATHLEN, "%s/all", logpath); 41 owl_free(logpath); 42 file=fopen(filename, "a"); 43 if (!file) { 44 owl_function_makemsg("Unable to open file for outgoing logging"); 45 return; 46 } 47 fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); 48 if (text[strlen(text)-1]!='\n') { 49 fprintf(file, "\n"); 50 } 51 fclose(file); 52 53 owl_free(tobuff); 54 } 55 56 void owl_log_outgoing_aim(char *to, char *text) { 57 FILE *file; 58 char filename[MAXPATHLEN], *logpath; 59 char *tobuff, *ptr; 60 61 tobuff=owl_sprintf("aim:%s", to); 22 62 23 63 /* expand ~ in path names */ … … 59 99 char *frombuff, *ptr, *from, *buff, *tmp; 60 100 int len, ch, i, personal; 61 62 /* we only do zephyrs right now */63 if (!owl_message_is_type_zephyr(m)) return;64 101 65 102 /* check for nolog */ … … 67 104 !strcasecmp(owl_message_get_instance(m), "nolog")) return; 68 105 69 if (owl_message_is_personal(m)) { 70 personal=1; 71 if (!owl_global_is_logging(&g)) return; 106 /* this is kind of a mess */ 107 if (owl_message_is_type_zephyr(m)) { 108 if (owl_message_is_personal(m)) { 109 personal=1; 110 if (!owl_global_is_logging(&g)) return; 111 } else { 112 personal=0; 113 if (!owl_global_is_classlogging(&g)) return; 114 } 72 115 } else { 73 personal=0; 74 if (!owl_global_is_classlogging(&g)) return; 75 } 76 77 if (personal) { 78 from=frombuff=owl_strdup(owl_message_get_sender(m)); 79 /* chop off a local realm */ 80 ptr=strchr(frombuff, '@'); 81 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) { 82 *ptr='\0'; 83 } 84 } else { 85 from=frombuff=owl_strdup(owl_message_get_class(m)); 116 if (owl_message_is_private(m)) { 117 personal=1; 118 if (!owl_global_is_logging(&g)) return; 119 } else { 120 personal=0; 121 if (!owl_global_is_classlogging(&g)) return; 122 } 123 } 124 125 if (owl_message_is_type_zephyr(m)) { 126 /* chop off a local realm for personal zephyr messages */ 127 if (personal) { 128 if (owl_message_is_type_zephyr(m)) { 129 from=frombuff=owl_strdup(owl_message_get_sender(m)); 130 ptr=strchr(frombuff, '@'); 131 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) { 132 *ptr='\0'; 133 } 134 } 135 } else { 136 /* we assume zephyr for now */ 137 from=frombuff=owl_strdup(owl_message_get_class(m)); 138 } 139 } else if (owl_message_is_type_aim(m)) { 140 /* we do not yet handle chat rooms */ 141 from=frombuff=owl_sprintf("aim:%s", owl_message_get_sender(m)); 86 142 } 87 143 … … 134 190 } 135 191 136 tmp=short_zuser(owl_message_get_sender(m)); 137 138 fprintf(file, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); 139 if (strcmp(owl_message_get_opcode(m), "")) fprintf(file, " Opcode: %s", owl_message_get_opcode(m)); 140 fprintf(file, "\n"); 141 fprintf(file, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); 142 ptr=owl_zephyr_get_zsig(owl_message_get_notice(m), &i); 143 buff=owl_malloc(i+10); 144 memcpy(buff, ptr, i); 145 buff[i]='\0'; 146 fprintf(file, "From: %s <%s>\n\n", buff, tmp); 147 fprintf(file, "%s\n", owl_message_get_body(m)); 148 fclose(file); 149 192 /* write to the main file */ 193 if (owl_message_is_type_zephyr(m)) { 194 tmp=short_zuser(owl_message_get_sender(m)); 195 fprintf(file, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); 196 if (strcmp(owl_message_get_opcode(m), "")) fprintf(file, " Opcode: %s", owl_message_get_opcode(m)); 197 fprintf(file, "\n"); 198 fprintf(file, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); 199 ptr=owl_zephyr_get_zsig(owl_message_get_notice(m), &i); 200 buff=owl_malloc(i+10); 201 memcpy(buff, ptr, i); 202 buff[i]='\0'; 203 fprintf(file, "From: %s <%s>\n\n", buff, tmp); 204 fprintf(file, "%s\n", owl_message_get_body(m)); 205 } else if (owl_message_is_type_aim(m)) { 206 fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); 207 fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m)); 208 fprintf(file, "%s\n\n", owl_message_get_body(m)); 209 } 210 fclose(file); 211 212 /* if it's a personal message, also write to the 'all' file */ 150 213 if (personal) { 151 fprintf(allfile, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); 152 if (strcmp(owl_message_get_opcode(m), "")) fprintf(allfile, " Opcode: %s", owl_message_get_opcode(m)); 153 fprintf(allfile, "\n"); 154 fprintf(allfile, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); 155 fprintf(allfile, "From: %s <%s>\n\n", buff, tmp); 156 fprintf(allfile, "%s\n", owl_message_get_body(m)); 157 fclose(allfile); 158 } 159 160 owl_free(tmp); 161 owl_free(buff); 214 if (owl_message_is_type_zephyr(m)) { 215 fprintf(allfile, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); 216 if (strcmp(owl_message_get_opcode(m), "")) fprintf(allfile, " Opcode: %s", owl_message_get_opcode(m)); 217 fprintf(allfile, "\n"); 218 fprintf(allfile, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); 219 fprintf(allfile, "From: %s <%s>\n\n", buff, tmp); 220 fprintf(allfile, "%s\n", owl_message_get_body(m)); 221 fclose(allfile); 222 } else { 223 fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); 224 fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m)); 225 fprintf(file, "%s\n\n", owl_message_get_body(m)); 226 } 227 } 228 229 if (owl_message_is_type_zephyr(m)) { 230 owl_free(tmp); 231 owl_free(buff); 232 } 162 233 owl_free(frombuff); 163 234 }
Note: See TracChangeset
for help on using the changeset viewer.