void gtkui_help_open(char *file) { const char *full = "sh -c \"man %s | col -b\""; char *data = NULL, *errors = NULL, *cmd; gboolean ret = FALSE; gint len = 0; len = strlen(file) + strlen(full); cmd = g_malloc(sizeof(char) * len); snprintf(cmd, len, full, file); ret = g_spawn_command_line_sync(cmd, &data, &errors, NULL, NULL); g_free(cmd); /* TODO: use local copy of manpages as backup */ if(ret && errors && strlen(errors) > 0) { ui_error(errors); g_free(errors); } /* print output of command in help window */ if(data && ret) { gtk_text_buffer_set_text(textbuf, "", -1); gtkui_details_print(textbuf, data); g_free(data); } }
/* * details for a connection */ static void gtkui_connection_detail(void) { GtkTreeIter iter; GtkTreeModel *model; GtkTextBuffer *textbuf; char line[200]; struct conn_tail *c = NULL; char tmp[MAX_ASCII_ADDR_LEN]; char *proto = ""; char name[MAX_HOSTNAME_LEN]; DEBUG_MSG("gtk_connection_detail"); model = GTK_TREE_MODEL (ls_conns); if (gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter)) { gtk_tree_model_get (model, &iter, 9, &c, -1); } else return; /* nothing is selected */ if(!c || !c->co) return; textbuf = gtkui_details_window("Connection Details"); snprintf(line, 200, "Source MAC address : %s\n", mac_addr_ntoa(c->co->L2_addr1, tmp)); gtkui_details_print(textbuf, line); snprintf(line, 200, "Destination MAC address : %s\n\n", mac_addr_ntoa(c->co->L2_addr2, tmp)); gtkui_details_print(textbuf, line); snprintf(line, 200, "Source IP address : \t%s\n", ip_addr_ntoa(&(c->co->L3_addr1), tmp)); gtkui_details_print(textbuf, line); if (host_iptoa(&(c->co->L3_addr1), name) == ESUCCESS) { snprintf(line, 200, " %s\n", name); gtkui_details_print(textbuf, line); } snprintf(line, 200, "Destination IP address : \t%s\n", ip_addr_ntoa(&(c->co->L3_addr2), tmp)); gtkui_details_print(textbuf, line); if (host_iptoa(&(c->co->L3_addr2), name) == ESUCCESS) { snprintf(line, 200, " %s\n", name); gtkui_details_print(textbuf, line); } gtkui_details_print(textbuf, "\n"); /* Protocol */ switch (c->co->L4_proto) { case NL_TYPE_UDP: proto = "UDP"; break; case NL_TYPE_TCP: proto = "TCP"; break; } snprintf(line, 200, "Protocol: \t\t\t%s\n", proto); gtkui_details_print(textbuf, line); snprintf(line, 200, "Source port: \t\t%-5d %s\n", ntohs(c->co->L4_addr1), service_search(c->co->L4_addr1, c->co->L4_proto)); gtkui_details_print(textbuf, line); snprintf(line, 200, "Destination port: \t%-5d %s\n\n", ntohs(c->co->L4_addr2), service_search(c->co->L4_addr2, c->co->L4_proto)); gtkui_details_print(textbuf, line); snprintf(line, 200, "Transferred bytes: %d\n\n", c->co->xferred); gtkui_details_print(textbuf, line); /* Login Information */ if (c->co->DISSECTOR.user) { snprintf(line, 200, "Account: \t%s / %s", c->co->DISSECTOR.user, c->co->DISSECTOR.pass); gtkui_details_print(textbuf, line); if (c->co->DISSECTOR.info) { snprintf(line, 200, " Additional Info: %s\n", c->co->DISSECTOR.info); gtkui_details_print(textbuf, line); } } }