/* Set default format keys for a session. */ void format_session(struct format_tree *ft, struct session *s) { struct session_group *sg; char *tim; time_t t; format_add(ft, "session_name", "%s", s->name); format_add(ft, "session_windows", "%u", winlink_count(&s->windows)); format_add(ft, "session_width", "%u", s->sx); format_add(ft, "session_height", "%u", s->sy); sg = session_group_find(s); format_add(ft, "session_grouped", "%d", sg != NULL); if (sg != NULL) format_add(ft, "session_group", "%u", session_group_index(sg)); t = s->creation_time.tv_sec; format_add(ft, "session_created", "%ld", (long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "session_created_string", "%s", tim); if (s->flags & SESSION_UNATTACHED) format_add(ft, "session_attached", "%d", 0); else format_add(ft, "session_attached", "%d", 1); }
/* Set default format keys for paste buffer. */ void format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb) { char *pb_print = paste_print(pb, 50); format_add(ft, "buffer_size", "%zu", pb->size); format_add(ft, "buffer_sample", "%s", pb_print); free(pb_print); }
static int xmsg_theme_init(void) { #ifndef NO_DEFAULT_THEME format_add("xmsg_addwatch_failed", _("Unable to add inotify watch (wrong path?)"), 1); format_add("xmsg_nosendcmd", _("%> (%1) You need to set %csend_cmd%n to be able to send msgs"), 1); format_add("xmsg_toobig", _("%> (%2) File %T%1%n is larger than %cmax_filesize%n, skipping"), 1); format_add("xmsg_toobigrm", _("%> (%2) File %T%1%n was larger than %cmax_filesize%n, removed"), 1); format_add("xmsg_umount", _("volume containing watched directory was unmounted"), 1); #endif return 0; }
/* Set default format keys for a winlink. */ void format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) { struct window *w = wl->window; char *flags; flags = window_printable_flags(s, wl); format_window(ft, w); format_add(ft, "window_index", "%d", wl->idx); format_add(ft, "window_flags", "%s", flags); format_add(ft, "window_active", "%d", wl == s->curw); format_add(ft, "window_bell_flag", "%u", !!(wl->flags & WINLINK_BELL)); format_add(ft, "window_content_flag", "%u", !!(wl->flags & WINLINK_CONTENT)); format_add(ft, "window_activity_flag", "%u", !!(wl->flags & WINLINK_ACTIVITY)); format_add(ft, "window_silence_flag", "%u", !!(wl->flags & WINLINK_SILENCE)); free(flags); }
/* Create a new tree. */ struct format_tree * format_create(void) { struct format_tree *ft; char host[MAXHOSTNAMELEN], *ptr; ft = xmalloc(sizeof *ft); RB_INIT(ft); if (gethostname(host, sizeof host) == 0) { format_add(ft, "host", "%s", host); if ((ptr = strchr(host, '.')) != NULL) *ptr = '\0'; format_add(ft, "host_short", "%s", host); } return (ft); }
/* Create a new tree. */ struct format_tree * format_create(void) { struct format_tree *ft; char host[MAXHOSTNAMELEN]; ft = xmalloc(sizeof *ft); RB_INIT(ft); if (gethostname(host, sizeof host) == 0) format_add(ft, "host", "%s", host); return (ft); }
/* Set default format keys for a winlink. */ void format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) { struct window *w = wl->window; char *layout, *flags; layout = layout_dump(w); flags = window_printable_flags(s, wl); format_add(ft, "window_id", "@%u", w->id); format_add(ft, "window_index", "%d", wl->idx); format_add(ft, "window_name", "%s", w->name); format_add(ft, "window_width", "%u", w->sx); format_add(ft, "window_height", "%u", w->sy); format_add(ft, "window_flags", "%s", flags); format_add(ft, "window_layout", "%s", layout); format_add(ft, "window_active", "%d", wl == s->curw); format_add(ft, "window_panes", "%u", window_count_panes(w)); xfree(flags); xfree(layout); }
/* Add window pane tabs. */ void format_window_pane_tabs(struct format_tree *ft, struct window_pane *wp) { struct evbuffer *buffer; u_int i; buffer = evbuffer_new(); for (i = 0; i < wp->base.grid->sx; i++) { if (!bit_test(wp->base.tabs, i)) continue; if (EVBUFFER_LENGTH(buffer) > 0) evbuffer_add(buffer, ",", 1); evbuffer_add_printf(buffer, "%d", i); } format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer), EVBUFFER_DATA(buffer)); evbuffer_free(buffer); }
/* Set default format keys for a window. */ void format_window(struct format_tree *ft, struct window *w) { char *layout; layout = layout_dump(w); format_add(ft, "window_id", "@%u", w->id); format_add(ft, "window_name", "%s", w->name); format_add(ft, "window_width", "%u", w->sx); format_add(ft, "window_height", "%u", w->sy); format_add(ft, "window_layout", "%s", layout); format_add(ft, "window_panes", "%u", window_count_panes(w)); free(layout); }
static VALUE ruby_format_add(int argc, VALUE *argv, VALUE self) { int replace = 1; char *name; if (argc != 2 && argc != 3) rb_raise(rb_eArgError, "format_add() accepts 2 or 3 params, but %d given", argc); Check_Type(argv[0], T_STRING); Check_Type(argv[1], T_STRING); name = RSTRING(argv[0])->ptr; if (argc == 3) { Check_Type(argv[2], T_FIXNUM); replace = FIX2INT(argv[2]); } format_add(name, RSTRING(argv[1])->ptr, replace); rb_iv_set(self, "@name", rb_str_new2(name)); return ekg2_ruby_theme; }
/* Set default format keys for a window pane. */ void format_window_pane(struct format_tree *ft, struct window_pane *wp) { struct grid *gd = wp->base.grid; struct grid_line *gl; unsigned long long size; u_int i, idx; char *cmd, *cwd; size = 0; for (i = 0; i < gd->hsize; i++) { gl = &gd->linedata[i]; size += gl->cellsize * sizeof *gl->celldata; } size += gd->hsize * sizeof *gd->linedata; format_add(ft, "history_size", "%u", gd->hsize); format_add(ft, "history_limit", "%u", gd->hlimit); format_add(ft, "history_bytes", "%llu", size); if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); format_add(ft, "pane_index", "%u", idx); format_add(ft, "pane_width", "%u", wp->sx); format_add(ft, "pane_height", "%u", wp->sy); format_add(ft, "pane_title", "%s", wp->base.title); format_add(ft, "pane_id", "%%%u", wp->id); format_add(ft, "pane_active", "%d", wp == wp->window->active); format_add(ft, "pane_dead", "%d", wp->fd == -1); format_add(ft, "pane_in_mode", "%d", wp->screen != &wp->base); format_add(ft, "pane_synchronized", "%d", !!options_get_number(&wp->window->options, "synchronize-panes")); if (wp->tty != NULL) format_add(ft, "pane_tty", "%s", wp->tty); format_add(ft, "pane_pid", "%ld", (long) wp->pid); if (wp->cmd != NULL) format_add(ft, "pane_start_command", "%s", wp->cmd); if ((cwd = osdep_get_cwd(wp->fd)) != NULL) format_add(ft, "pane_current_path", "%s", cwd); if ((cmd = format_get_command(wp)) != NULL) { format_add(ft, "pane_current_command", "%s", cmd); free(cmd); } format_add(ft, "cursor_x", "%d", wp->base.cx); format_add(ft, "cursor_y", "%d", wp->base.cy); format_add(ft, "scroll_region_upper", "%d", wp->base.rupper); format_add(ft, "scroll_region_lower", "%d", wp->base.rlower); format_add(ft, "saved_cursor_x", "%d", wp->ictx.old_cx); format_add(ft, "saved_cursor_y", "%d", wp->ictx.old_cy); format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0); format_add(ft, "alternate_saved_x", "%d", wp->saved_cx); format_add(ft, "alternate_saved_y", "%d", wp->saved_cy); format_add(ft, "cursor_flag", "%d", !!(wp->base.mode & MODE_CURSOR)); format_add(ft, "insert_flag", "%d", !!(wp->base.mode & MODE_INSERT)); format_add(ft, "keypad_cursor_flag", "%d", !!(wp->base.mode & MODE_KCURSOR)); format_add(ft, "keypad_flag", "%d", !!(wp->base.mode & MODE_KKEYPAD)); format_add(ft, "wrap_flag", "%d", !!(wp->base.mode & MODE_WRAP)); format_add(ft, "mouse_standard_flag", "%d", !!(wp->base.mode & MODE_MOUSE_STANDARD)); format_add(ft, "mouse_button_flag", "%d", !!(wp->base.mode & MODE_MOUSE_BUTTON)); format_add(ft, "mouse_any_flag", "%d", !!(wp->base.mode & MODE_MOUSE_ANY)); format_add(ft, "mouse_utf8_flag", "%d", !!(wp->base.mode & MODE_MOUSE_UTF8)); format_window_pane_tabs(ft, wp); }
/* Set default format keys for a client. */ void format_client(struct format_tree *ft, struct client *c) { char *tim; time_t t; struct session *s; format_add(ft, "client_height", "%u", c->tty.sy); format_add(ft, "client_width", "%u", c->tty.sx); if (c->tty.path != NULL) format_add(ft, "client_tty", "%s", c->tty.path); if (c->tty.termname != NULL) format_add(ft, "client_termname", "%s", c->tty.termname); t = c->creation_time.tv_sec; format_add(ft, "client_created", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_created_string", "%s", tim); t = c->activity_time.tv_sec; format_add(ft, "client_activity", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_activity_string", "%s", tim); format_add(ft, "client_prefix", "%d", !!(c->flags & CLIENT_PREFIX)); if (c->tty.flags & TTY_UTF8) format_add(ft, "client_utf8", "%d", 1); else format_add(ft, "client_utf8", "%d", 0); if (c->flags & CLIENT_READONLY) format_add(ft, "client_readonly", "%d", 1); else format_add(ft, "client_readonly", "%d", 0); s = c->session; if (s != NULL) format_add(ft, "client_session", "%s", s->name); s = c->last_session; if (s != NULL && session_alive(s)) format_add(ft, "client_last_session", "%s", s->name); }
/* Set default format keys for a window pane. */ void format_window_pane(struct format_tree *ft, struct window_pane *wp) { struct grid *gd = wp->base.grid; struct grid_line *gl; unsigned long long size; u_int i; u_int idx; size = 0; for (i = 0; i < gd->hsize; i++) { gl = &gd->linedata[i]; size += gl->cellsize * sizeof *gl->celldata; size += gl->utf8size * sizeof *gl->utf8data; } size += gd->hsize * sizeof *gd->linedata; if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); format_add(ft, "pane_width", "%u", wp->sx); format_add(ft, "pane_height", "%u", wp->sy); format_add(ft, "pane_title", "%s", wp->base.title); format_add(ft, "pane_index", "%u", idx); format_add(ft, "history_size", "%u", gd->hsize); format_add(ft, "history_limit", "%u", gd->hlimit); format_add(ft, "history_bytes", "%llu", size); format_add(ft, "pane_id", "%%%u", wp->id); format_add(ft, "pane_active", "%d", wp == wp->window->active); format_add(ft, "pane_dead", "%d", wp->fd == -1); if (wp->cmd != NULL) format_add(ft, "pane_start_command", "%s", wp->cmd); if (wp->cwd != NULL) format_add(ft, "pane_start_path", "%s", wp->cwd); format_add(ft, "pane_current_path", "%s", get_proc_cwd(wp->pid)); format_add(ft, "pane_pid", "%ld", (long) wp->pid); format_add(ft, "pane_tty", "%s", wp->tty); }
/* Set default format keys for a client. */ void format_client(struct format_tree *ft, struct client *c) { char *tim; time_t t; format_add(ft, "client_cwd", "%s", c->cwd); format_add(ft, "client_height", "%u", c->tty.sy); format_add(ft, "client_width", "%u", c->tty.sx); format_add(ft, "client_tty", "%s", c->tty.path); format_add(ft, "client_termname", "%s", c->tty.termname); t = c->creation_time.tv_sec; format_add(ft, "client_created", "%ld", (long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_created_string", "%s", tim); t = c->activity_time.tv_sec; format_add(ft, "client_activity", "%ld", (long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_activity_string", "%s", tim); if (c->tty.flags & TTY_UTF8) format_add(ft, "client_utf8", "%d", 1); else format_add(ft, "client_utf8", "%d", 0); if (c->flags & CLIENT_READONLY) format_add(ft, "client_readonly", "%d", 1); else format_add(ft, "client_readonly", "%d", 0); }
static int sniff_theme_init() { /* sniff gg */ format_add("sniff_gg_welcome", ("%) %b[GG_WELCOME] %gSEED: %W%1"), 1); format_add("sniff_gg_login60", ("%) %b[GG_LOGIN60] %gUIN: %W%1 %gPROTOCOL: %W%3 %gHASH: %W%2"), 1); format_add("sniff_gg_login70_sha1", ("%) %b[GG_LOGIN70] %gUIN: %W%1 %gPROTOCOL: %W%3 %gSHA1: %W%2"), 1); format_add("sniff_gg_login70_hash", ("%) %b[GG_LOGIN70] %gUIN: %W%1 %gPROTOCOL: %W%3 %gHASH: %W%2"), 1); format_add("sniff_gg_login70_unknown", ("%) %b[GG_LOGIN70] %gUIN: %W%1 %gPROTOCOL: %W%3 %gTYPE: %W%2"), 1); format_add("sniff_gg_userlist_req", ("%) %b[GG_USERLIST_REQUEST] %gTYPE: %W%1 (%2)"), 1); format_add("sniff_gg_userlist_reply", ("%) %b[GG_USERLIST_REPLY] %gTYPE: %W%1 (%2)"), 1); format_add("sniff_gg_userlist_data", ("%) %b[%1] %gENTRY: %W%2"), 1); format_add("sniff_gg_list", ("%) %b[%1] %gLEN: %W%2"), 1); format_add("sniff_gg_list_data", ("%) %b[%1] %gENTRY: %W%2 %gTYPE: %W%3"), 1); format_add("sniff_gg_pubdir50_req", ("%) %b[GG_PUBDIR50_REQUEST] %gTYPE: %W%1 (%2) %gSEQ: %W%3"), 1); format_add("sniff_gg_pubdir50_req_data", ("%) %gTYPE: %W%1 %gENTRY: %W%2"), 1); format_add("sniff_gg_pubdir50_reply", ("%) %b[GG_PUBDIR50_REPLY] %gTYPE: %W%1 (%2) %gSEQ: %W%3"), 1); format_add("sniff_gg_pubdir50_reply_data", ("%) %gTYPE: %W%1 %gENTRY: %W%2"), 1); format_add("sniff_gg_pubdir50_reply_data_sep", ("%) %b-"), 1); format_add("sniff_gg_disconnecting", ("%) %b[GG_DISCONNECTING]"), 1); format_add("sniff_gg_status60", ("%) %b[GG_STATUS60] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_notify60", ("%) %b[GG_NOTIFY60] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_status77", ("%) %b[GG_STATUS77] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_notify77", ("%) %b[GG_NOTIFY77] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_login80_sha1", ("%) %b[GG_LOGIN80] %gUIN: %W%1 %gPROTOCOL: %W%3 %gSHA1: %W%2"), 1); format_add("sniff_gg_login80_hash", ("%) %b[GG_LOGIN80] %gUIN: %W%1 %gPROTOCOL: %W%3 %gHASH: %W%2"), 1); /* untested */ format_add("sniff_gg_login80_unknown", ("%) %b[GG_LOGIN80] %gUIN: %W%1 %gPROTOCOL: %W%3 %gTYPE: %W%2"), 1); format_add("sniff_gg_login80_real_sha1", ("%) %b[GG_LOGIN80_REAL] %gUIN: %W%1 %gPROTOCOL: %W%3 %gSHA1: %W%2"), 1); format_add("sniff_gg_login80_real_hash", ("%) %b[GG_LOGIN80_REAL] %gUIN: %W%1 %gPROTOCOL: %W%3 %gHASH: %W%2"), 1); /* untested */ format_add("sniff_gg_login80_real_unknown", ("%) %b[GG_LOGIN80_REAL] %gUIN: %W%1 %gPROTOCOL: %W%3 %gTYPE: %W%2"), 1); format_add("sniff_gg_status80", ("%) %b[GG_STATUS80] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_notify80", ("%) %b[GG_NOTIFY80] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_status80_real", ("%) %b[GG_STATUS80_REAL] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_notify80_real", ("%) %b[GG_NOTIFY80_REAL] %gDCC: %W%1:%2 %gVERSION: %W#%3 (%4) %gIMGSIZE: %W%5KiB"), 1); format_add("sniff_gg_addnotify", ("%) %b[GG_ADD_NOTIFY] %gUIN: %W%1 %gDATA: %W%2"), 1); format_add("sniff_gg_delnotify", ("%) %b[GG_REMOVE_NOTIFY] %gUIN: %W%1 %gDATA: %W%2"), 1); /* sniff dns */ format_add("sniff_dns_reply", ("%) %b[SNIFF_DNS, %r%1%b] %gDOMAIN: %W%2"), 1); format_add("sniff_dns_entry_a", ("%) %b[IN_A] %gDOMAIN: %W%1 %gIP: %W%2"), 1); format_add("sniff_dns_entry_aaaa", ("%) %b[IN_AAAA] %gDOMAIN: %W%1 %gIP6: %W%2"), 1); format_add("sniff_dns_entry_cname", ("%) %b[IN_CNAME] %gDOMAIN: %W%1 %gCNAME: %W%2"), 1); format_add("sniff_dns_entry_ptr", ("%) %b[IN_PTR] %gIP_PTR: %W%1 %gDOMAIN: %W%2"), 1); format_add("sniff_dns_entry_mx", ("%) %b[IN_MX] %gDOMAIN: %W%1 %gENTRY: %W%2 %gPREF: %W%3"), 1); format_add("sniff_dns_entry_ns", ("%) %b[IN_NS] %gDOMAIN: %W%1 %gIP: %W%2"), 1); format_add("sniff_dns_entry_srv", ("%) %b[IN_SRV] %gDOMAIN: %W%1 %gENTRY: %W%2 %gPORT: %W%3 %gPRIO: %W%4 %gWEIGHT: %W%5"), 1); format_add("sniff_dns_entry_?", ("%) %b[IN_?] %gDOMAIN: %W%1 %gTYPE: %W%2 %gLEN: %W%3"), 1); format_add("sniff_dns_entry_ndisplay", ("%) %rZADEN REKORD NIE WYSWIETLONY DLA ZAPYTANIE POWYZEJ ;), OBEJRZYJ DEBUG"), 1); /* sniff rivchat */ format_add("sniff_rivchat_init", ("%) %b[RIVCHAT_INIT, %r%1%b]"), 1); format_add("sniff_rivchat_me", ("%) %b[RIVCHAT_ME, %r%1%b] %W* %2 %3"), 1); format_add("sniff_rivchat_away", ("%) %b[RIVCHAT_AWAY, %r%1%b] %gREASON: %W%2"), 1); format_add("sniff_rivchat_quit", ("%) %b[RIVCHAT_QUIT, %r%1%b]"), 1); format_add("sniff_rivchat_pingaway", ("%) %b[RIVCHAT_PINGAWAY, %r%1%b] %gREASON: %W%2"), 1); format_add("sniff_rivchat_message", ("%) %b[RIVCHAT_MESSAGE, %r%1%b] <%2> %W%3"), 1); format_add("sniff_rivchat_rcinfo", ("%) %b[RIVCHAT_INFO, %r%1%b] %gFINGER: %W%2@%3 %gOS: %W%4 %gPROGRAM: %W%5 %6"), 1); /* stats */ format_add("sniff_pkt_rcv", ("%) %2 packets captured"), 1); format_add("sniff_pkt_drop", ("%) %2 packets dropped"), 1); format_add("sniff_conn_db", ("%) %2 connections founded"), 1); format_add("sniff_tcp_connection", "TCP %1:%2 <==> %3:%4", 1); return 0; }