regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / epan / dfilter / drange.h
blob8162afd55758544278e86ce773943b0deaa5cc3e
1 /** @file
3 * Routines for providing general range support to the dfilter library
5 * Copyright (c) 2000 by Ed Warnicke <hagbard@physics.rutgers.edu>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs
9 * Copyright 1999 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __DRANGE_H__
14 #define __DRANGE_H__
16 #include <wireshark.h>
18 /* Please don't directly manipulate these structs. Please use
19 * the methods provided. If you REALLY can't do what you need to
20 * do with the methods provided please write new methods that do
21 * what you need, put them into the drange object here, and limit
22 * your direct manipulation of the drange and drange_node structs to
23 * here.
26 typedef enum {
27 DRANGE_NODE_END_T_UNINITIALIZED,
28 DRANGE_NODE_END_T_LENGTH,
29 DRANGE_NODE_END_T_OFFSET,
30 DRANGE_NODE_END_T_TO_THE_END
31 } drange_node_end_t;
33 typedef struct _drange_node {
34 int start_offset;
35 int length;
36 int end_offset;
37 drange_node_end_t ending;
38 } drange_node;
40 typedef struct _drange {
41 GSList* range_list;
42 bool has_total_length;
43 int total_length;
44 int min_start_offset;
45 int max_start_offset;
46 } drange_t;
48 /* drange_node constructor */
49 drange_node* drange_node_new(void);
51 /* drange_node constructor */
52 drange_node* drange_node_from_str(const char *range_str, char **err_ptr);
54 /* drange_node destructor */
55 void drange_node_free(drange_node* drnode);
57 /* Call drange_node destructor on all list items */
58 void drange_node_free_list(GSList* list);
60 /* drange_node accessors */
61 int drange_node_get_start_offset(drange_node* drnode);
62 int drange_node_get_length(drange_node* drnode);
63 int drange_node_get_end_offset(drange_node* drnode);
64 drange_node_end_t drange_node_get_ending(drange_node* drnode);
66 /* drange_node mutators */
67 void drange_node_set_start_offset(drange_node* drnode, int offset);
68 void drange_node_set_length(drange_node* drnode, int length);
69 void drange_node_set_end_offset(drange_node* drnode, int offset);
70 void drange_node_set_to_the_end(drange_node* drnode);
72 /* drange constructor */
73 drange_t * drange_new(drange_node* drnode);
74 drange_t * drange_new_from_list(GSList *list);
75 drange_t * drange_dup(drange_t *org);
77 /* drange destructor, only use this if you used drange_new() to creat
78 * the drange
80 void drange_free(drange_t* dr);
82 /* drange accessors */
83 bool drange_has_total_length(drange_t* dr);
84 int drange_get_total_length(drange_t* dr);
85 int drange_get_min_start_offset(drange_t* dr);
86 int drange_get_max_start_offset(drange_t* dr);
88 /* drange mutators */
89 void drange_append_drange_node(drange_t* dr, drange_node* drnode);
90 void drange_prepend_drange_node(drange_t* dr, drange_node* drnode);
91 void drange_foreach_drange_node(drange_t* dr, GFunc func, void *funcdata);
93 char *drange_node_tostr(const drange_node *rn);
95 char *drange_tostr(const drange_t *dr);
97 #endif /* ! __DRANGE_H__ */