static char *ignore_get_levels(int level, int xlevel) { GString *str; char *levelstr, *p, *ret; str = g_string_new(NULL); if (level != 0) { levelstr = bits2level(level); g_string_append(str, levelstr); g_free(levelstr); } if (xlevel != 0) { if (str->len > 0) g_string_append_c(str, ' '); levelstr = bits2level(xlevel); for (p = levelstr; *p != '\0'; p++) { if (!isspace(*p) && (p == levelstr || isspace(p[-1]))) g_string_append_c(str, '^'); g_string_append_c(str, *p); } g_free(levelstr); } ret = str->str; g_string_free(str, FALSE); return ret; }
static void ignore_set_config(IGNORE_REC *rec) { CONFIG_NODE *node; char *levelstr; if (rec->level == 0 && rec->except_level == 0) return; if (rec->time > 0) return; node = iconfig_node_traverse("(ignores", TRUE); node = config_node_section(node, NULL, NODE_TYPE_BLOCK); if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask); if (rec->level) { levelstr = bits2level(rec->level); iconfig_node_set_str(node, "level", levelstr); g_free(levelstr); } if (rec->except_level) { levelstr = bits2level(rec->except_level); iconfig_node_set_str(node, "except_level", levelstr); g_free(levelstr); } iconfig_node_set_str(node, "pattern", rec->pattern); if (rec->regexp) config_node_set_bool(node, "regexp", TRUE); if (rec->fullword) config_node_set_bool(node, "fullword", TRUE); if (rec->replies) config_node_set_bool(node, "replies", TRUE); if (rec->channels != NULL && *rec->channels != NULL) { node = config_node_section(node, "channels", NODE_TYPE_LIST); config_node_add_list(node, rec->channels); } }
static void log_update_config(LOG_REC *log) { CONFIG_NODE *node; char *levelstr; if (log->temp) return; node = iconfig_node_traverse("logs", TRUE); node = config_node_section(node, log->fname, NODE_TYPE_BLOCK); if (log->autoopen) iconfig_node_set_bool(node, "auto_open", TRUE); else iconfig_node_set_str(node, "auto_open", NULL); levelstr = bits2level(log->level); iconfig_node_set_str(node, "level", levelstr); g_free(levelstr); iconfig_node_set_str(node, "items", NULL); if (log->items != NULL) log_items_update_config(log, node); signal_emit("log config save", 2, log, node); }
static void window_save(WINDOW_REC *window, CONFIG_NODE *node) { char refnum[MAX_INT_STRLEN]; ltoa(refnum, window->refnum); node = config_node_section(node, refnum, NODE_TYPE_BLOCK); if (window->sticky_refnum) iconfig_node_set_bool(node, "sticky_refnum", TRUE); if (window->immortal) iconfig_node_set_bool(node, "immortal", TRUE); if (window->name != NULL) iconfig_node_set_str(node, "name", window->name); if (window->history_name != NULL) iconfig_node_set_str(node, "history_name", window->history_name); if (window->servertag != NULL) iconfig_node_set_str(node, "servertag", window->servertag); if (window->level != 0) { char *level = bits2level(window->level); iconfig_node_set_str(node, "level", level); g_free(level); } if (window->theme_name != NULL) iconfig_node_set_str(node, "theme", window->theme_name); if (window->items != NULL) window_save_items(window, node); signal_emit("layout save window", 2, window, node); }
static void cmd_log_list(void) { GSList *tmp; char *levelstr, *items, *rotate; int index; printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_LOG_LIST_HEADER); for (tmp = logs, index = 1; tmp != NULL; tmp = tmp->next, index++) { LOG_REC *rec = tmp->data; levelstr = bits2level(rec->level); items = rec->items == NULL ? NULL : g_strjoinv(",", rec->items); rotate = rec->rotate == 0 ? NULL : g_strdup_printf(" -rotate %s", log_rotate2str(rec->rotate)); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_LOG_LIST, index, rec->fname, items != NULL ? items : "", levelstr, rotate != NULL ? rotate : "", rec->autoopen ? " -autoopen" : ""); g_free_not_null(rotate); g_free_not_null(items); g_free(levelstr); } printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_LOG_LIST_FOOTER); }
/* SYNTAX: WINDOW LEVEL [<level>] */ static void cmd_window_level(const char *data) { char *level; g_return_if_fail(data != NULL); window_set_level(active_win, combine_level(active_win->level, data)); level = active_win->level == 0 ? g_strdup("NONE") : bits2level(active_win->level); printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_WINDOW_LEVEL, level); g_free(level); }
/* SYNTAX: WINDOW LEVEL [<level>] */ static void cmd_window_level(const char *data) { char *level; g_return_if_fail(data != NULL); window_set_level(active_win, combine_level(active_win->level, data)); level = active_win->level == 0 ? g_strdup("NONE") : bits2level(active_win->level); printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE, "Window level is now %s", level); g_free(level); }
static void hilight_print(int index, HILIGHT_REC *rec) { char *chans, *levelstr; GString *options; options = g_string_new(NULL); if (rec->nick && rec->word) { /* default case, no option */ } else if (rec->nick) g_string_append(options, "-nick "); else if (rec->word) g_string_append(options, "-word "); else g_string_append(options, "-line "); if (rec->nickmask) g_string_append(options, "-mask "); if (rec->fullword) g_string_append(options, "-full "); if (rec->case_sensitive) g_string_append(options, "-matchcase "); if (rec->regexp) { g_string_append(options, "-regexp "); #ifdef HAVE_REGEX_H if (!rec->regexp_compiled) g_string_append(options, "[INVALID!] "); #endif } if (rec->priority != 0) g_string_append_printf(options, "-priority %d ", rec->priority); if (rec->servertag != NULL) g_string_append_printf(options, "-network %s ", rec->servertag); if (rec->color != NULL) g_string_append_printf(options, "-color %s ", rec->color); if (rec->act_color != NULL) g_string_append_printf(options, "-actcolor %s ", rec->act_color); chans = rec->channels == NULL ? NULL : g_strjoinv(",", rec->channels); levelstr = rec->level == 0 ? NULL : bits2level(rec->level); if (levelstr != NULL) levelstr = g_strconcat(levelstr, " ", NULL); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_LINE, index, rec->text, chans != NULL ? chans : "", levelstr != NULL ? levelstr : "", options->str); g_free_not_null(chans); g_free_not_null(levelstr); g_string_free(options, TRUE); }
static void hilight_print(int index, HILIGHT_REC *rec) { char *chans, *levelstr; chans = rec->channels == NULL ? NULL : g_strjoinv(",", rec->channels); levelstr = rec->level == 0 ? NULL : bits2level(rec->level); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_HILIGHT_LINE, index, rec->text, chans != NULL ? chans : "", levelstr != NULL ? levelstr : "", rec->nickmask ? " -nick" : "", rec->fullword ? " -word" : "", rec->regexp ? " -regexp" : ""); g_free_not_null(chans); g_free_not_null(levelstr); }
static void ignore_print(int index, IGNORE_REC *rec) { GString *options; char *key, *levels; key = ignore_get_key(rec); levels = bits2level(rec->level); options = g_string_new(NULL); if (rec->exception) g_string_append(options, "-except "); if (rec->regexp) { g_string_append(options, "-regexp "); if (rec->pattern == NULL) g_string_append(options, "[INVALID! -pattern missing] "); #ifdef HAVE_REGEX_H else if (!rec->regexp_compiled) g_string_append(options, "[INVALID!] "); #endif } if (rec->fullword) g_string_append(options, "-full "); if (rec->replies) g_string_append(options, "-replies "); if (rec->servertag != NULL) g_string_append_printf(options, "-network %s ", rec->servertag); if (rec->pattern != NULL) g_string_append_printf(options, "-pattern %s ", rec->pattern); if (options->len > 1) g_string_truncate(options, options->len-1); if (index >= 0) { printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_IGNORE_LINE, index, key != NULL ? key : "", levels != NULL ? levels : "", options->str); } else { printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, options->len > 0 ? TXT_IGNORED_OPTIONS : TXT_IGNORED, key != NULL ? key : "", levels != NULL ? levels : "", options->str); } g_string_free(options, TRUE); g_free(key); g_free(levels); }
static void hilight_print(int index, HILIGHT_REC *rec) { char *chans, *levelstr; GString *options; options = g_string_new(NULL); if (!rec->nick || !rec->word) { if (rec->nick) g_string_append(options, "-nick "); if (rec->word) g_string_append(options, "-word "); } if (rec->nickmask) g_string_append(options, "-nickmask "); if (rec->fullword) g_string_append(options, "-fullword "); if (rec->regexp) { g_string_append(options, "-regexp "); #ifdef HAVE_REGEX_H if (!rec->regexp_compiled) g_string_append(options, "[INVALID!] "); #endif } if (rec->priority != 0) g_string_sprintfa(options, "-priority %d ", rec->priority); if (rec->color != NULL) g_string_sprintfa(options, "-color %s ", rec->color); if (rec->act_color != NULL) g_string_sprintfa(options, "-actcolor %s ", rec->act_color); chans = rec->channels == NULL ? NULL : g_strjoinv(",", rec->channels); levelstr = rec->level == 0 ? NULL : bits2level(rec->level); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_LINE, index, rec->text, chans != NULL ? chans : "", levelstr != NULL ? levelstr : "", options->str); g_free_not_null(chans); g_free_not_null(levelstr); g_string_free(options, TRUE); }
/* SYNTAX: WINDOW LIST */ static void cmd_window_list(void) { GSList *tmp, *sorted; char *levelstr; sorted = windows_get_sorted(); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_WINDOWLIST_HEADER); for (tmp = sorted; tmp != NULL; tmp = tmp->next) { WINDOW_REC *rec = tmp->data; levelstr = bits2level(rec->level); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_WINDOWLIST_LINE, rec->refnum, rec->name == NULL ? "" : rec->name, rec->active == NULL ? "" : rec->active->visible_name, rec->active_server == NULL ? "" : ((SERVER_REC *) rec->active_server)->tag, levelstr); g_free(levelstr); } g_slist_free(sorted); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_WINDOWLIST_FOOTER); }
static void cmd_log_list(void) { GSList *tmp; char *levelstr, *items; int index; printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_LOG_LIST_HEADER); for (tmp = logs, index = 1; tmp != NULL; tmp = tmp->next, index++) { LOG_REC *rec = tmp->data; levelstr = bits2level(rec->level); items = rec->items == NULL ? NULL : log_items_get_list(rec); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_LOG_LIST, index, rec->fname, items != NULL ? items : "", levelstr, rec->autoopen ? " -autoopen" : ""); g_free_not_null(items); g_free(levelstr); } printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_LOG_LIST_FOOTER); }
static void cmd_window_info(WINDOW_REC *win) { char *levelstr; printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_HEADER); /* Window reference number + sticky status */ if (!win->sticky_refnum) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_REFNUM, win->refnum); } else { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_REFNUM_STICKY, win->refnum); } /* Window name */ if (win->name != NULL) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_NAME, win->name); } /* Window width / height */ printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SIZE, win->width, win->height); /* Window immortality */ if (win->immortal) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_IMMORTAL); } /* Window history name */ if (win->history_name != NULL) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_HISTORY, win->history_name); } /* Window level */ levelstr = win->level == 0 ? g_strdup("NONE") : bits2level(win->level); printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_LEVEL, levelstr); g_free(levelstr); /* Active window server + sticky status */ if (win->servertag == NULL) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SERVER, win->active_server != NULL ? win->active_server->tag : "NONE"); } else { if (win->active_server != NULL && strcmp(win->active_server->tag, win->servertag) != 0) g_warning("Active server isn't the sticky server!"); printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SERVER_STICKY, win->servertag); } /* Window theme + error status */ if (win->theme_name != NULL) { printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_THEME, win->theme_name, win->theme != NULL ? "" : "(not loaded)"); } /* Bound items in window */ if (win->bound_items != NULL) window_print_binds(win); /* Item */ if (win->items != NULL) window_print_items(win); signal_emit("window print info", 1, win); printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_FOOTER); }