/* Convert an FT_STRING using a callback function */ static gboolean string_walk(GList* arg1list, GList **retval, gchar(*conv_func)(gchar)) { GList *arg1; fvalue_t *arg_fvalue; fvalue_t *new_ft_string; char *s, *c; arg1 = arg1list; while (arg1) { arg_fvalue = (fvalue_t *)arg1->data; /* XXX - it would be nice to handle FT_TVBUFF, too */ if (IS_FT_STRING(fvalue_type_ftenum(arg_fvalue))) { s = (char *)ep_strdup((gchar *)fvalue_get(arg_fvalue)); for (c = s; *c; c++) { /**c = string_ascii_to_lower(*c);*/ *c = conv_func(*c); } new_ft_string = fvalue_new(FT_STRING); fvalue_set_string(new_ft_string, s); *retval = g_list_append(*retval, new_ft_string); } arg1 = arg1->next; } return TRUE; }
void fvalue_set_string(fvalue_t *fv, const gchar *value) { g_assert(IS_FT_STRING(fv->ftype->ftype) || fv->ftype->ftype == FT_UINT_STRING || fv->ftype->ftype == FT_PCRE); g_assert(fv->ftype->set_value.set_value_string); fv->ftype->set_value.set_value_string(fv, value); }
bool FieldInformation::isLink() const { if (fi_ && fi_->hfinfo) { if((fi_->hfinfo->type == FT_FRAMENUM) || (FI_GET_FLAG(fi_, FI_URL) && IS_FT_STRING(fi_->hfinfo->type))) { return true; } } return false; }
QString FieldInformation::url() { QString url; if (flag(FI_URL) && headerInfo().isValid && IS_FT_STRING(fi_->hfinfo->type)) { gchar *url_str; url_str = fvalue_to_string_repr(NULL, &fi_->value, FTREPR_DISPLAY, fi_->hfinfo->display); if (url_str) { url = url_str; } wmem_free(NULL, url_str); } return url; }
void ProtoTree::itemDoubleClick(QTreeWidgetItem *item, int column) { Q_UNUSED(column); field_info *fi; fi = item->data(0, Qt::UserRole).value<field_info *>(); if(fi->hfinfo->type == FT_FRAMENUM) { emit goToFrame(fi->value.value.uinteger); } if(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type)) { gchar *url; url = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, NULL); if(url){ // browser_open_url(url); QDesktopServices::openUrl(QUrl(url)); g_free(url); } } }
gpointer fvalue_get(fvalue_t *fv) { g_assert(fv->ftype->ftype == FT_BYTES || fv->ftype->ftype == FT_UINT_BYTES || fv->ftype->ftype == FT_AX25 || fv->ftype->ftype == FT_VINES || fv->ftype->ftype == FT_ETHER || fv->ftype->ftype == FT_OID || fv->ftype->ftype == FT_REL_OID || fv->ftype->ftype == FT_SYSTEM_ID || fv->ftype->ftype == FT_FCWWN || fv->ftype->ftype == FT_GUID || fv->ftype->ftype == FT_IPv6 || fv->ftype->ftype == FT_PCRE || fv->ftype->ftype == FT_PROTOCOL || IS_FT_STRING(fv->ftype->ftype) || fv->ftype->ftype == FT_UINT_STRING || IS_FT_TIME(fv->ftype->ftype)); g_assert(fv->ftype->get_value.get_value_ptr); return fv->ftype->get_value.get_value_ptr(fv); }
/* Fill a single protocol tree item with its string value and set its color. */ static void proto_tree_draw_node(proto_node *node, gpointer data) { field_info *fi = PNODE_FINFO(node); gchar label_str[ITEM_LABEL_LENGTH]; gchar *label_ptr; gboolean is_branch; /* dissection with an invisible proto tree? */ g_assert(fi); if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items) return; // Fill in our label /* was a free format label produced? */ if (fi->rep) { label_ptr = fi->rep->representation; } else { /* no, make a generic label */ label_ptr = label_str; proto_item_fill_label(fi, label_str); } if (node->first_child != NULL) { is_branch = TRUE; g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types); } else { is_branch = FALSE; } if (PROTO_ITEM_IS_GENERATED(node)) { if (PROTO_ITEM_IS_HIDDEN(node)) { label_ptr = g_strdup_printf("<[%s]>", label_ptr); } else { label_ptr = g_strdup_printf("[%s]", label_ptr); } } else if (PROTO_ITEM_IS_HIDDEN(node)) { label_ptr = g_strdup_printf("<%s>", label_ptr); } QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data; QTreeWidgetItem *item; ProtoTree *proto_tree = qobject_cast<ProtoTree *>(parentItem->treeWidget()); item = new QTreeWidgetItem(parentItem, 0); // Set our colors. QPalette pal = QApplication::palette(); if (fi && fi->hfinfo) { if(fi->hfinfo->type == FT_PROTOCOL) { item->setData(0, Qt::BackgroundRole, pal.alternateBase()); } if((fi->hfinfo->type == FT_FRAMENUM) || (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) { QFont font = item->font(0); item->setData(0, Qt::ForegroundRole, pal.link()); font.setUnderline(true); item->setData(0, Qt::FontRole, font); if (fi->hfinfo->type == FT_FRAMENUM) { proto_tree->emitRelatedFrame(fi->value.value.uinteger); } } } // XXX - Add routines to get our severity colors. if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { case(PI_COMMENT): item->setData(0, Qt::BackgroundRole, expert_color_comment); break; case(PI_CHAT): item->setData(0, Qt::BackgroundRole, expert_color_chat); break; case(PI_NOTE): item->setData(0, Qt::BackgroundRole, expert_color_note); break; case(PI_WARN): item->setData(0, Qt::BackgroundRole, expert_color_warn); break; case(PI_ERROR): item->setData(0, Qt::BackgroundRole, expert_color_error); break; default: g_assert_not_reached(); } item->setData(0, Qt::ForegroundRole, expert_color_foreground); } item->setText(0, label_ptr); item->setData(0, Qt::UserRole, qVariantFromValue(fi)); if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) { g_free(label_ptr); } if (is_branch) { if (tree_expanded(fi->tree_type)) { item->setExpanded(true); } else { item->setExpanded(false); } proto_tree_children_foreach(node, proto_tree_draw_node, item); } }