/* 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;
}
Beispiel #2
0
static gboolean
diam_tree_to_csv(proto_node* node, gpointer data)
{
	char* val_str=NULL;
	char* val_tmp=NULL;
	ftenum_t ftype;
	field_info* fi;
	header_field_info	*hfi;
	if(!node) {
		fprintf(stderr,"traverse end: empty node. node='%p' data='%p'\n",(void *)node,(void *)data);
		return FALSE;
	}
	fi=node->finfo;
	hfi=fi ? fi->hfinfo : NULL;
	if(!hfi) {
		fprintf(stderr,"traverse end: hfi not found. node='%p'\n",(void *)node);
		return FALSE;
	}
	ftype=fvalue_type_ftenum(&fi->value);
	if (ftype!=FT_NONE&&ftype!=FT_PROTOCOL) {
		/* convert value to string */
		val_tmp=fvalue_to_string_repr(&fi->value,FTREPR_DISPLAY,NULL);
		if(val_tmp)
		{
			val_str=ep_strdup(val_tmp);
			g_free(val_tmp);
		} else
			val_str=ep_strdup_printf("unsupported type: %s",ftype_name(ftype));

		/*printf("traverse: name='%s', abbrev='%s',desc='%s', val='%s'\n",hfi->name,hfi->abbrev,ftype_name(hfi->type),val_str);*/
		printf("%s='%s' ",hfi->name,val_str);
	}
	return FALSE;
}