}
+void
+proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move)
+{
+ proto_item *curr_item;
+
+
+ /*** cut item_to_move out ***/
+
+ /* is item_to_move the first? */
+ if(tree->first_child == item_to_move) {
+ /* simply change first child to next */
+ tree->first_child = item_to_move->next;
+ } else {
+ /* find previous and change it's next */
+ for(curr_item = tree->first_child; curr_item != NULL; curr_item = curr_item->next) {
+ if(curr_item->next == item_to_move) {
+ break;
+ }
+ }
+
+ DISSECTOR_ASSERT(curr_item);
+
+ curr_item->next = item_to_move->next;
+
+ /* fix last_child if required */
+ if(tree->last_child == item_to_move) {
+ tree->last_child = curr_item;
+ }
+ }
+
+ /*** insert to_move after fixed ***/
+ item_to_move->next = fixed_item->next;
+ fixed_item->next = item_to_move;
+ if(tree->last_child == fixed_item) {
+ tree->last_child = item_to_move;
+ }
+}
+
+
int
proto_register_protocol(char *name, char *short_name, char *filter_name)
{
/** is this protocol field hidden from the protocol tree display (used for filtering only)? */
#define PROTO_ITEM_IS_HIDDEN(proto_item) \
- ((proto_item) ? FI_GET_FLAG(proto_item->finfo, FI_HIDDEN) : 0)
+ ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
/** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
#define PROTO_ITEM_SET_HIDDEN(proto_item) \
- ((proto_item) ? FI_SET_FLAG(proto_item->finfo, FI_HIDDEN) : 0)
+ ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
/** is this protocol field generated by Ethereal (and not read from the packet data)? */
#define PROTO_ITEM_IS_GENERATED(proto_item) \
- ((proto_item) ? FI_GET_FLAG(proto_item->finfo, FI_GENERATED) : 0)
+ ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
/** mark this protocol field as generated by Ethereal (and not read from the packet data) */
#define PROTO_ITEM_SET_GENERATED(proto_item) \
- ((proto_item) ? FI_SET_FLAG(proto_item->finfo, FI_GENERATED) : 0)
+ ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
@return parent item */
extern proto_item* proto_tree_get_parent(proto_tree *tree);
+/** Move an existing item behind another existing item.
+ @param tree the tree to which both items belong
+ @param item the item which keeps it's position
+ @param item_to_move the item which will be moved */
+extern void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
+
/** Add an item to a proto_tree, using the text label registered to that item.