| | 271 | | static void cmd_window_log(const char *data) |
| | 272 | | { |
| | 273 | | LOG_REC *log; |
| | 274 | | char *set, *fname, window[MAX_INT_STRLEN];
|
| | 275 | | void *free_arg; |
| | 276 | | int open_log, close_log; |
| | 277 | | |
| | 278 | | if (!cmd_get_params(data, &free_arg, 2, &set, &fname)) |
| | 279 | | return; |
| | 280 | | |
| | 281 | | ltoa(window, active_win->refnum);
|
| | 282 | | log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, window, NULL, NULL);
|
| | 283 | | |
| | 284 | | open_log = close_log = FALSE;
|
| | 285 | | if (g_ascii_strcasecmp(set, "ON") == 0) |
| | 286 | | open_log = TRUE;
|
| | 287 | | else if (g_ascii_strcasecmp(set, "OFF") == 0) { |
| | 288 | | close_log = TRUE;
|
| | 289 | | } else if (g_ascii_strcasecmp(set, "TOGGLE") == 0) { |
| | 290 | | open_log = log == NULL;
|
| | 291 | | close_log = log != NULL;
|
| | 292 | | } else { |
| | 293 | | printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE);
|
| | 294 | | cmd_params_free(free_arg); |
| | 295 | | return; |
| | 296 | | } |
| | 297 | | |
| | 298 | | if (open_log && log == NULL) {
|
| | 299 | | |
| | 300 | | fname = *fname != '\0' ? g_strdup(fname) : |
| | 301 | | g_strdup_printf("~/irc.log.%s%s", |
| | 302 | | active_win->name != NULL ? active_win->name : "Window",
|
| | 303 | | active_win->name != NULL ? "" : window);
|