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