[7d4fbcd] | 1 | #include "owl.h" |
---|
| 2 | #include <stdlib.h> |
---|
| 3 | #include <string.h> |
---|
| 4 | #include <ctype.h> |
---|
| 5 | #include <sys/param.h> |
---|
| 6 | |
---|
[1aee7d9] | 7 | static const char fileIdent[] = "$Id$"; |
---|
| 8 | |
---|
[15b34fd] | 9 | /* This is now the one function that should be called to log a |
---|
| 10 | * message. It will do all the work necessary by calling the other |
---|
| 11 | * functions in this file as necessary. |
---|
| 12 | */ |
---|
| 13 | void owl_log_message(owl_message *m) { |
---|
| 14 | owl_function_debugmsg("owl_log_message: entering"); |
---|
| 15 | |
---|
| 16 | /* should we be logging this message? */ |
---|
| 17 | if (!owl_log_shouldlog_message(m)) { |
---|
| 18 | owl_function_debugmsg("owl_log_message: not logging message"); |
---|
| 19 | return; |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | /* handle incmoing messages */ |
---|
| 23 | if (owl_message_is_direction_in(m)) { |
---|
| 24 | owl_log_incoming(m); |
---|
| 25 | owl_function_debugmsg("owl_log_message: leaving"); |
---|
| 26 | return; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | /* handle outgoing messages */ |
---|
| 30 | if (owl_message_is_type_aim(m)) { |
---|
| 31 | owl_log_outgoing_aim(m); |
---|
| 32 | } else if (owl_message_is_type_zephyr(m)) { |
---|
| 33 | owl_log_outgoing_zephyr(m); |
---|
| 34 | } else if (owl_message_is_type_loopback(m)) { |
---|
| 35 | owl_log_outgoing_loopback(m); |
---|
| 36 | } else { |
---|
| 37 | owl_function_error("Unknown message type for logging"); |
---|
| 38 | } |
---|
| 39 | owl_function_debugmsg("owl_log_message: leaving"); |
---|
| 40 | } |
---|
[7d4fbcd] | 41 | |
---|
[15b34fd] | 42 | /* Return 1 if we should log the given message, otherwise return 0 */ |
---|
| 43 | int owl_log_shouldlog_message(owl_message *m) { |
---|
| 44 | owl_filter *f; |
---|
[12c35df] | 45 | |
---|
[15b34fd] | 46 | /* If there's a logfilter and this message matches it, log */ |
---|
| 47 | f=owl_global_get_filter(&g, owl_global_get_logfilter(&g)); |
---|
| 48 | if (f && owl_filter_message_match(f, m)) return(1); |
---|
[7d4fbcd] | 49 | |
---|
[15b34fd] | 50 | /* otherwise we do things based on the logging variables */ |
---|
| 51 | |
---|
| 52 | /* skip login/logout messages if appropriate */ |
---|
| 53 | if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return(0); |
---|
| 54 | |
---|
| 55 | /* check for nolog */ |
---|
| 56 | if (!strcasecmp(owl_message_get_opcode(m), "nolog") || !strcasecmp(owl_message_get_instance(m), "nolog")) return(0); |
---|
| 57 | |
---|
| 58 | /* check direction */ |
---|
| 59 | if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) && owl_message_is_direction_out(m)) { |
---|
| 60 | return(0); |
---|
| 61 | } |
---|
| 62 | if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_OUT) && owl_message_is_direction_in(m)) { |
---|
| 63 | return(0); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | if (owl_message_is_type_zephyr(m)) { |
---|
| 67 | if (owl_message_is_personal(m) && !owl_global_is_logging(&g)) return(0); |
---|
| 68 | if (!owl_message_is_personal(m) && !owl_global_is_classlogging(&g)) return(0); |
---|
| 69 | } else { |
---|
| 70 | if (owl_message_is_private(m) || owl_message_is_loginout(m)) { |
---|
| 71 | if (!owl_global_is_logging(&g)) return(0); |
---|
| 72 | } else { |
---|
| 73 | if (!owl_global_is_classlogging(&g)) return(0); |
---|
| 74 | } |
---|
[7d4fbcd] | 75 | } |
---|
[15b34fd] | 76 | return(1); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | void owl_log_outgoing_zephyr(owl_message *m) |
---|
| 80 | { |
---|
| 81 | FILE *file; |
---|
| 82 | char filename[MAXPATHLEN], *logpath; |
---|
| 83 | char *to, *text; |
---|
| 84 | |
---|
| 85 | /* strip local realm */ |
---|
| 86 | to=short_zuser(owl_message_get_recipient(m)); |
---|
[7d4fbcd] | 87 | |
---|
[e1c4636] | 88 | /* expand ~ in path names */ |
---|
[15b34fd] | 89 | logpath=owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g)); |
---|
[e1c4636] | 90 | |
---|
[15b34fd] | 91 | text=owl_message_get_body(m); |
---|
| 92 | |
---|
| 93 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, to); |
---|
[7d4fbcd] | 94 | file=fopen(filename, "a"); |
---|
| 95 | if (!file) { |
---|
[836ea3a3] | 96 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[e1c4636] | 97 | owl_free(logpath); |
---|
[15b34fd] | 98 | owl_free(to); |
---|
[7d4fbcd] | 99 | return; |
---|
| 100 | } |
---|
[15b34fd] | 101 | fprintf(file, "OUTGOING (owl): %s\n%s\n", to, text); |
---|
[7d4fbcd] | 102 | if (text[strlen(text)-1]!='\n') { |
---|
| 103 | fprintf(file, "\n"); |
---|
| 104 | } |
---|
| 105 | fclose(file); |
---|
| 106 | |
---|
[e1c4636] | 107 | snprintf(filename, MAXPATHLEN, "%s/all", logpath); |
---|
| 108 | owl_free(logpath); |
---|
[7d4fbcd] | 109 | file=fopen(filename, "a"); |
---|
| 110 | if (!file) { |
---|
[836ea3a3] | 111 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[15b34fd] | 112 | owl_free(to); |
---|
[7d4fbcd] | 113 | return; |
---|
| 114 | } |
---|
[15b34fd] | 115 | fprintf(file, "OUTGOING (owl): %s\n%s\n", to, text); |
---|
[7d4fbcd] | 116 | if (text[strlen(text)-1]!='\n') { |
---|
| 117 | fprintf(file, "\n"); |
---|
| 118 | } |
---|
| 119 | fclose(file); |
---|
| 120 | |
---|
[15b34fd] | 121 | owl_free(to); |
---|
[7d4fbcd] | 122 | } |
---|
| 123 | |
---|
[2b86d14] | 124 | void owl_log_outgoing_zephyr_error(char *to, char *text) |
---|
| 125 | { |
---|
| 126 | FILE *file; |
---|
| 127 | char filename[MAXPATHLEN], *logpath; |
---|
[180cd15] | 128 | char *tobuff, *zwriteline; |
---|
| 129 | owl_message *m; |
---|
| 130 | |
---|
| 131 | /* create a present message so we can pass it to |
---|
| 132 | * owl_log_shouldlog_message() |
---|
| 133 | */ |
---|
| 134 | zwriteline=owl_sprintf("zwrite %s", to); |
---|
| 135 | m=owl_function_make_outgoing_zephyr(text, zwriteline, ""); |
---|
| 136 | owl_free(zwriteline); |
---|
| 137 | if (!owl_log_shouldlog_message(m)) { |
---|
| 138 | owl_message_free(m); |
---|
| 139 | return; |
---|
| 140 | } |
---|
| 141 | owl_message_free(m); |
---|
[2b86d14] | 142 | |
---|
[180cd15] | 143 | /* chop off a local realm */ |
---|
[15b34fd] | 144 | tobuff=short_zuser(to); |
---|
[2b86d14] | 145 | |
---|
| 146 | /* expand ~ in path names */ |
---|
[15b34fd] | 147 | logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g)); |
---|
[2b86d14] | 148 | |
---|
| 149 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff); |
---|
| 150 | file=fopen(filename, "a"); |
---|
| 151 | if (!file) { |
---|
| 152 | owl_function_error("Unable to open file for outgoing logging"); |
---|
| 153 | owl_free(logpath); |
---|
[15b34fd] | 154 | owl_free(tobuff); |
---|
[2b86d14] | 155 | return; |
---|
| 156 | } |
---|
| 157 | fprintf(file, "ERROR (owl): %s\n%s\n", tobuff, text); |
---|
| 158 | if (text[strlen(text)-1]!='\n') { |
---|
| 159 | fprintf(file, "\n"); |
---|
| 160 | } |
---|
| 161 | fclose(file); |
---|
| 162 | |
---|
| 163 | snprintf(filename, MAXPATHLEN, "%s/all", logpath); |
---|
| 164 | owl_free(logpath); |
---|
| 165 | file=fopen(filename, "a"); |
---|
| 166 | if (!file) { |
---|
| 167 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[15b34fd] | 168 | owl_free(tobuff); |
---|
[2b86d14] | 169 | return; |
---|
| 170 | } |
---|
| 171 | fprintf(file, "ERROR (owl): %s\n%s\n", tobuff, text); |
---|
| 172 | if (text[strlen(text)-1]!='\n') { |
---|
| 173 | fprintf(file, "\n"); |
---|
| 174 | } |
---|
| 175 | fclose(file); |
---|
| 176 | |
---|
| 177 | owl_free(tobuff); |
---|
| 178 | } |
---|
| 179 | |
---|
[15b34fd] | 180 | void owl_log_outgoing_aim(owl_message *m) |
---|
[37eab7f] | 181 | { |
---|
[aac889a] | 182 | FILE *file; |
---|
| 183 | char filename[MAXPATHLEN], *logpath; |
---|
[15b34fd] | 184 | char *tobuff, *normalto, *text; |
---|
[aac889a] | 185 | |
---|
[15b34fd] | 186 | owl_function_debugmsg("owl_log_outgoing_aim: entering"); |
---|
[12c35df] | 187 | |
---|
[15b34fd] | 188 | /* normalize and downcase the screenname */ |
---|
| 189 | normalto=owl_aim_normalize_screenname(owl_message_get_recipient(m)); |
---|
[421c286f] | 190 | downstr(normalto); |
---|
| 191 | tobuff=owl_sprintf("aim:%s", normalto); |
---|
| 192 | owl_free(normalto); |
---|
[aac889a] | 193 | |
---|
| 194 | /* expand ~ in path names */ |
---|
[15b34fd] | 195 | logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g)); |
---|
[aac889a] | 196 | |
---|
[15b34fd] | 197 | text=owl_message_get_body(m); |
---|
| 198 | |
---|
[aac889a] | 199 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff); |
---|
| 200 | file=fopen(filename, "a"); |
---|
| 201 | if (!file) { |
---|
[836ea3a3] | 202 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[aac889a] | 203 | owl_free(logpath); |
---|
[15b34fd] | 204 | owl_free(tobuff); |
---|
[aac889a] | 205 | return; |
---|
| 206 | } |
---|
| 207 | fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); |
---|
| 208 | if (text[strlen(text)-1]!='\n') { |
---|
| 209 | fprintf(file, "\n"); |
---|
| 210 | } |
---|
| 211 | fclose(file); |
---|
| 212 | |
---|
| 213 | snprintf(filename, MAXPATHLEN, "%s/all", logpath); |
---|
| 214 | owl_free(logpath); |
---|
| 215 | file=fopen(filename, "a"); |
---|
| 216 | if (!file) { |
---|
[836ea3a3] | 217 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[15b34fd] | 218 | owl_free(tobuff); |
---|
[aac889a] | 219 | return; |
---|
| 220 | } |
---|
| 221 | fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); |
---|
| 222 | if (text[strlen(text)-1]!='\n') { |
---|
| 223 | fprintf(file, "\n"); |
---|
| 224 | } |
---|
| 225 | fclose(file); |
---|
| 226 | |
---|
| 227 | owl_free(tobuff); |
---|
| 228 | } |
---|
| 229 | |
---|
[15b34fd] | 230 | void owl_log_outgoing_loopback(owl_message *m) |
---|
[37eab7f] | 231 | { |
---|
| 232 | FILE *file; |
---|
| 233 | char filename[MAXPATHLEN], *logpath; |
---|
[15b34fd] | 234 | char *tobuff, *text; |
---|
[12c35df] | 235 | |
---|
| 236 | tobuff=owl_sprintf("loopback"); |
---|
[37eab7f] | 237 | |
---|
| 238 | /* expand ~ in path names */ |
---|
[15b34fd] | 239 | logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g)); |
---|
| 240 | |
---|
| 241 | text=owl_message_get_body(m); |
---|
[37eab7f] | 242 | |
---|
| 243 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff); |
---|
| 244 | file=fopen(filename, "a"); |
---|
| 245 | if (!file) { |
---|
| 246 | owl_function_error("Unable to open file for outgoing logging"); |
---|
| 247 | owl_free(logpath); |
---|
[15b34fd] | 248 | owl_free(tobuff); |
---|
[37eab7f] | 249 | return; |
---|
| 250 | } |
---|
| 251 | fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); |
---|
| 252 | if (text[strlen(text)-1]!='\n') { |
---|
| 253 | fprintf(file, "\n"); |
---|
| 254 | } |
---|
| 255 | fclose(file); |
---|
| 256 | |
---|
| 257 | snprintf(filename, MAXPATHLEN, "%s/all", logpath); |
---|
| 258 | owl_free(logpath); |
---|
| 259 | file=fopen(filename, "a"); |
---|
| 260 | if (!file) { |
---|
| 261 | owl_function_error("Unable to open file for outgoing logging"); |
---|
[15b34fd] | 262 | owl_free(tobuff); |
---|
[37eab7f] | 263 | return; |
---|
| 264 | } |
---|
| 265 | fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text); |
---|
| 266 | if (text[strlen(text)-1]!='\n') { |
---|
| 267 | fprintf(file, "\n"); |
---|
| 268 | } |
---|
| 269 | fclose(file); |
---|
| 270 | |
---|
| 271 | owl_free(tobuff); |
---|
| 272 | } |
---|
| 273 | |
---|
[15283bb] | 274 | void owl_log_incoming(owl_message *m) |
---|
| 275 | { |
---|
[7d4fbcd] | 276 | FILE *file, *allfile; |
---|
[e1c4636] | 277 | char filename[MAXPATHLEN], allfilename[MAXPATHLEN], *logpath; |
---|
[e6449bc] | 278 | char *frombuff=NULL, *from=NULL, *buff=NULL, *ptr; |
---|
[7d4fbcd] | 279 | int len, ch, i, personal; |
---|
[12c35df] | 280 | |
---|
[15b34fd] | 281 | /* figure out if it's a "personal" message or not */ |
---|
[aac889a] | 282 | if (owl_message_is_type_zephyr(m)) { |
---|
| 283 | if (owl_message_is_personal(m)) { |
---|
| 284 | personal=1; |
---|
| 285 | } else { |
---|
| 286 | personal=0; |
---|
| 287 | } |
---|
[7d4fbcd] | 288 | } else { |
---|
[79a0e82] | 289 | if (owl_message_is_private(m) || owl_message_is_loginout(m)) { |
---|
[aac889a] | 290 | personal=1; |
---|
| 291 | } else { |
---|
| 292 | personal=0; |
---|
| 293 | } |
---|
[7d4fbcd] | 294 | } |
---|
| 295 | |
---|
[aac889a] | 296 | if (owl_message_is_type_zephyr(m)) { |
---|
| 297 | if (personal) { |
---|
| 298 | if (owl_message_is_type_zephyr(m)) { |
---|
[15b34fd] | 299 | from=frombuff=short_zuser(owl_message_get_sender(m)); |
---|
[aac889a] | 300 | } |
---|
| 301 | } else { |
---|
| 302 | from=frombuff=owl_strdup(owl_message_get_class(m)); |
---|
[7d4fbcd] | 303 | } |
---|
[aac889a] | 304 | } else if (owl_message_is_type_aim(m)) { |
---|
| 305 | /* we do not yet handle chat rooms */ |
---|
[421c286f] | 306 | char *normalto; |
---|
| 307 | normalto=owl_aim_normalize_screenname(owl_message_get_sender(m)); |
---|
| 308 | downstr(normalto); |
---|
| 309 | from=frombuff=owl_sprintf("aim:%s", normalto); |
---|
| 310 | owl_free(normalto); |
---|
[37eab7f] | 311 | } else if (owl_message_is_type_loopback(m)) { |
---|
| 312 | from=frombuff=owl_strdup("loopback"); |
---|
[e6449bc] | 313 | } else { |
---|
| 314 | from=frombuff=owl_strdup("unknown"); |
---|
[7d4fbcd] | 315 | } |
---|
| 316 | |
---|
| 317 | /* check for malicious sender formats */ |
---|
| 318 | len=strlen(frombuff); |
---|
| 319 | if (len<1 || len>35) from="weird"; |
---|
| 320 | if (strchr(frombuff, '/')) from="weird"; |
---|
| 321 | |
---|
| 322 | ch=frombuff[0]; |
---|
| 323 | if (!isalnum(ch)) from="weird"; |
---|
| 324 | |
---|
| 325 | for (i=0; i<len; i++) { |
---|
[e1c4636] | 326 | if (frombuff[i]<'!' || frombuff[i]>='~') from="weird"; |
---|
[7d4fbcd] | 327 | } |
---|
| 328 | |
---|
| 329 | if (!strcmp(frombuff, ".") || !strcasecmp(frombuff, "..")) from="weird"; |
---|
| 330 | |
---|
| 331 | if (!personal) { |
---|
| 332 | if (strcmp(from, "weird")) downstr(from); |
---|
| 333 | } |
---|
| 334 | |
---|
[e1c4636] | 335 | /* create the filename (expanding ~ in path names) */ |
---|
[7d4fbcd] | 336 | if (personal) { |
---|
[15b34fd] | 337 | logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g)); |
---|
[e1c4636] | 338 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from); |
---|
| 339 | snprintf(allfilename, MAXPATHLEN, "%s/all", logpath); |
---|
| 340 | |
---|
[7d4fbcd] | 341 | } else { |
---|
[15b34fd] | 342 | logpath = owl_text_substitute(owl_global_get_classlogpath(&g), "~", owl_global_get_homedir(&g)); |
---|
[e1c4636] | 343 | snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from); |
---|
[7d4fbcd] | 344 | } |
---|
[e1c4636] | 345 | owl_free(logpath); |
---|
[7d4fbcd] | 346 | |
---|
| 347 | file=fopen(filename, "a"); |
---|
| 348 | if (!file) { |
---|
[836ea3a3] | 349 | owl_function_error("Unable to open file for incoming logging"); |
---|
[15b34fd] | 350 | owl_free(frombuff); |
---|
[7d4fbcd] | 351 | return; |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | allfile=NULL; |
---|
| 355 | if (personal) { |
---|
| 356 | allfile=fopen(allfilename, "a"); |
---|
| 357 | if (!allfile) { |
---|
[836ea3a3] | 358 | owl_function_error("Unable to open file for incoming logging"); |
---|
[15b34fd] | 359 | owl_free(frombuff); |
---|
[79a0e82] | 360 | fclose(file); |
---|
[7d4fbcd] | 361 | return; |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | |
---|
[aac889a] | 365 | /* write to the main file */ |
---|
| 366 | if (owl_message_is_type_zephyr(m)) { |
---|
[e6449bc] | 367 | char *tmp; |
---|
| 368 | |
---|
[aac889a] | 369 | tmp=short_zuser(owl_message_get_sender(m)); |
---|
| 370 | fprintf(file, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); |
---|
| 371 | if (strcmp(owl_message_get_opcode(m), "")) fprintf(file, " Opcode: %s", owl_message_get_opcode(m)); |
---|
| 372 | fprintf(file, "\n"); |
---|
| 373 | fprintf(file, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); |
---|
| 374 | ptr=owl_zephyr_get_zsig(owl_message_get_notice(m), &i); |
---|
| 375 | buff=owl_malloc(i+10); |
---|
| 376 | memcpy(buff, ptr, i); |
---|
| 377 | buff[i]='\0'; |
---|
| 378 | fprintf(file, "From: %s <%s>\n\n", buff, tmp); |
---|
[269ed34] | 379 | fprintf(file, "%s\n\n", owl_message_get_body(m)); |
---|
[e6449bc] | 380 | owl_free(tmp); |
---|
[79a0e82] | 381 | } else if (owl_message_is_type_aim(m) && !owl_message_is_loginout(m)) { |
---|
[aac889a] | 382 | fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 383 | fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 384 | fprintf(file, "%s\n\n", owl_message_get_body(m)); |
---|
[79a0e82] | 385 | } else if (owl_message_is_type_aim(m) && owl_message_is_loginout(m)) { |
---|
| 386 | fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 387 | fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 388 | if (owl_message_is_login(m)) fprintf(file, "LOGIN\n\n"); |
---|
| 389 | if (owl_message_is_logout(m)) fprintf(file, "LOGOUT\n\n"); |
---|
[37eab7f] | 390 | } else { |
---|
| 391 | fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 392 | fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 393 | fprintf(file, "%s\n\n", owl_message_get_body(m)); |
---|
[aac889a] | 394 | } |
---|
[37eab7f] | 395 | |
---|
[7d4fbcd] | 396 | fclose(file); |
---|
| 397 | |
---|
[aac889a] | 398 | /* if it's a personal message, also write to the 'all' file */ |
---|
[7d4fbcd] | 399 | if (personal) { |
---|
[aac889a] | 400 | if (owl_message_is_type_zephyr(m)) { |
---|
[e6449bc] | 401 | char *tmp; |
---|
| 402 | |
---|
| 403 | tmp=short_zuser(owl_message_get_sender(m)); |
---|
[aac889a] | 404 | fprintf(allfile, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m)); |
---|
| 405 | if (strcmp(owl_message_get_opcode(m), "")) fprintf(allfile, " Opcode: %s", owl_message_get_opcode(m)); |
---|
| 406 | fprintf(allfile, "\n"); |
---|
| 407 | fprintf(allfile, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m)); |
---|
| 408 | fprintf(allfile, "From: %s <%s>\n\n", buff, tmp); |
---|
[269ed34] | 409 | fprintf(allfile, "%s\n\n", owl_message_get_body(m)); |
---|
[e6449bc] | 410 | owl_free(tmp); |
---|
[79a0e82] | 411 | } else if (owl_message_is_type_aim(m) && !owl_message_is_loginout(m)) { |
---|
| 412 | fprintf(allfile, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 413 | fprintf(allfile, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 414 | fprintf(allfile, "%s\n\n", owl_message_get_body(m)); |
---|
| 415 | } else if (owl_message_is_type_aim(m) && owl_message_is_loginout(m)) { |
---|
| 416 | fprintf(allfile, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 417 | fprintf(allfile, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 418 | if (owl_message_is_login(m)) fprintf(allfile, "LOGIN\n\n"); |
---|
| 419 | if (owl_message_is_logout(m)) fprintf(allfile, "LOGOUT\n\n"); |
---|
[37eab7f] | 420 | } else { |
---|
[eec69e1] | 421 | fprintf(allfile, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m)); |
---|
| 422 | fprintf(allfile, "Time: %s\n\n", owl_message_get_timestr(m)); |
---|
| 423 | fprintf(allfile, "%s\n\n", owl_message_get_body(m)); |
---|
[aac889a] | 424 | } |
---|
[723c427] | 425 | fclose(allfile); |
---|
[7d4fbcd] | 426 | } |
---|
| 427 | |
---|
[aac889a] | 428 | if (owl_message_is_type_zephyr(m)) { |
---|
| 429 | owl_free(buff); |
---|
| 430 | } |
---|
[7d4fbcd] | 431 | owl_free(frombuff); |
---|
| 432 | } |
---|