diff options
author | Bill Meier <wmeier@newsguy.com> | 2014-08-05 16:10:44 -0400 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2014-08-05 20:42:21 +0000 |
commit | f3dd7fe1eb5348922b079db2bdede700d4d28fbd (patch) | |
tree | 7382b5da9a3c1de3eba0e91aed54c087fcfea549 /epan | |
parent | dfe331e35e0400942d3ad9e4b5f8c84369546b6d (diff) |
Fix whitespace/indentation to match editor modelines.
Change-Id: I3445ae22f10584582d465bf632942e016f5f70ca
Reviewed-on: https://code.wireshark.org/review/3452
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/address.h | 62 | ||||
-rw-r--r-- | epan/charsets.h | 4 | ||||
-rw-r--r-- | epan/conversation_table.c | 12 | ||||
-rw-r--r-- | epan/frame_data_sequence.c | 22 | ||||
-rw-r--r-- | epan/oids.h | 2 | ||||
-rw-r--r-- | epan/prefs.c | 2310 |
6 files changed, 1206 insertions, 1206 deletions
diff --git a/epan/address.h b/epan/address.h index d64cf93b0a..f3ab362d37 100644 --- a/epan/address.h +++ b/epan/address.h @@ -62,10 +62,10 @@ typedef enum { } address_type; typedef struct _address { - address_type type; /* type of address */ - int hf; /* the specific field that this addr is */ - int len; /* length of address, in bytes */ - const void *data; /* pointer to address data */ + address_type type; /* type of address */ + int hf; /* the specific field that this addr is */ + int len; /* length of address, in bytes */ + const void *data; /* pointer to address data */ } address; /** Initialize an address with the given values. @@ -83,7 +83,7 @@ set_address(address *addr, address_type addr_type, int addr_len, const void * ad addr->hf = -1; addr->len = addr_len; } -#define SET_ADDRESS(addr, addr_type, addr_len, addr_data) \ +#define SET_ADDRESS(addr, addr_type, addr_len, addr_data) \ set_address((addr), (addr_type), (addr_len), (addr_data)) /** Initialize an address from TVB data. @@ -101,7 +101,7 @@ set_address(address *addr, address_type addr_type, int addr_len, const void * ad * @param addr_len [in] The length in bytes of the address data. For example, 4 for * AT_IPv4 or sizeof(struct e_in6_addr) for AT_IPv6. */ -#define TVB_SET_ADDRESS(addr, addr_type, tvb, offset, addr_len) \ +#define TVB_SET_ADDRESS(addr, addr_type, tvb, offset, addr_len) \ do { \ const void *TVB_SET_ADDRESS_data = (const void *)tvb_get_ptr(tvb, offset, addr_len); \ set_address((addr), (addr_type), (addr_len), TVB_SET_ADDRESS_data); \ @@ -123,7 +123,7 @@ set_address_hf(address *addr, address_type addr_type, int addr_len, const void * addr->hf = addr_hf; addr->len = addr_len; } -#define SET_ADDRESS_HF(addr, addr_type, addr_len, addr_data, addr_hf) \ +#define SET_ADDRESS_HF(addr, addr_type, addr_len, addr_data, addr_hf) \ set_address_hf((addr), (addr_type), (addr_len), (addr_data), (addr_hf)) /** Initialize an address from TVB data including an associated field. @@ -142,7 +142,7 @@ set_address_hf(address *addr, address_type addr_type, int addr_len, const void * * AT_IPv4 or sizeof(struct e_in6_addr) for AT_IPv6. * @param addr_hf [in] The header field index to associate with the address. */ -#define TVB_SET_ADDRESS_HF(addr, addr_type, tvb, offset, addr_len, addr_hf) \ +#define TVB_SET_ADDRESS_HF(addr, addr_type, tvb, offset, addr_len, addr_hf) \ do { \ const void *TVB_SET_ADDRESS_data = (const void *) tvb_get_ptr(tvb, offset, addr_len); \ set_address_hf((addr), (addr_type), (addr_len), TVB_SET_ADDRESS_data, (addr_hf)); \ @@ -284,35 +284,35 @@ add_address_to_hash64(guint64 hash_val, const address *addr) { /* Types of port numbers Wireshark knows about. */ typedef enum { - PT_NONE, /* no port number */ - PT_SCTP, /* SCTP */ - PT_TCP, /* TCP */ - PT_UDP, /* UDP */ - PT_DCCP, /* DCCP */ - PT_IPX, /* IPX sockets */ - PT_NCP, /* NCP connection */ - PT_EXCHG, /* Fibre Channel exchange */ - PT_DDP, /* DDP AppleTalk connection */ - PT_SBCCS, /* FICON */ - PT_IDP, /* XNS IDP sockets */ - PT_TIPC, /* TIPC PORT */ - PT_USB, /* USB endpoint 0xffff means the host */ + PT_NONE, /* no port number */ + PT_SCTP, /* SCTP */ + PT_TCP, /* TCP */ + PT_UDP, /* UDP */ + PT_DCCP, /* DCCP */ + PT_IPX, /* IPX sockets */ + PT_NCP, /* NCP connection */ + PT_EXCHG, /* Fibre Channel exchange */ + PT_DDP, /* DDP AppleTalk connection */ + PT_SBCCS, /* FICON */ + PT_IDP, /* XNS IDP sockets */ + PT_TIPC, /* TIPC PORT */ + PT_USB, /* USB endpoint 0xffff means the host */ PT_I2C, - PT_IBQP, /* Infiniband QP number */ + PT_IBQP, /* Infiniband QP number */ PT_BLUETOOTH } port_type; /* Types of circuit IDs Wireshark knows about. */ typedef enum { - CT_NONE, /* no circuit type */ - CT_DLCI, /* Frame Relay DLCI */ - CT_ISDN, /* ISDN channel number */ - CT_X25, /* X.25 logical channel number */ - CT_ISUP, /* ISDN User Part CIC */ - CT_IAX2, /* IAX2 call id */ - CT_H223, /* H.223 logical channel number */ - CT_BICC, /* BICC Circuit identifier */ - CT_DVBCI /* DVB-CI session number|transport connection id */ + CT_NONE, /* no circuit type */ + CT_DLCI, /* Frame Relay DLCI */ + CT_ISDN, /* ISDN channel number */ + CT_X25, /* X.25 logical channel number */ + CT_ISUP, /* ISDN User Part CIC */ + CT_IAX2, /* IAX2 call id */ + CT_H223, /* H.223 logical channel number */ + CT_BICC, /* BICC Circuit identifier */ + CT_DVBCI /* DVB-CI session number|transport connection id */ /* Could also have ATM VPI/VCI pairs */ } circuit_type; diff --git a/epan/charsets.h b/epan/charsets.h index ed0d275a53..07456fdac2 100644 --- a/epan/charsets.h +++ b/epan/charsets.h @@ -88,11 +88,11 @@ get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const WS_DLL_PUBLIC guint8 * get_ts_23_038_7bits_string(wmem_allocator_t *scope, const guint8 *ptr, - const gint bit_offset, gint no_of_chars); + const gint bit_offset, gint no_of_chars); WS_DLL_PUBLIC guint8 * get_ascii_7bits_string(wmem_allocator_t *scope, const guint8 *ptr, - const gint bit_offset, gint no_of_chars); + const gint bit_offset, gint no_of_chars); WS_DLL_PUBLIC guint8 * get_ebcdic_string(wmem_allocator_t *scope, const guint8 *ptr, gint length); diff --git a/epan/conversation_table.c b/epan/conversation_table.c index 57bbb6f9d7..61ec310a19 100644 --- a/epan/conversation_table.c +++ b/epan/conversation_table.c @@ -88,14 +88,14 @@ dissector_conversation_init(const char *opt_arg, void* userdata) */ register_ct_t* get_conversation_by_proto_id(int proto_id) { - GSList *ct; - register_ct_t *table; + GSList *ct; + register_ct_t *table; - for(ct = registered_ct_tables; ct != NULL; ct = g_slist_next(ct)){ - table = (register_ct_t*)ct->data; - if ((table) && (table->proto_id == proto_id)) + for(ct = registered_ct_tables; ct != NULL; ct = g_slist_next(ct)){ + table = (register_ct_t*)ct->data; + if ((table) && (table->proto_id == proto_id)) return table; - } + } return NULL; } diff --git a/epan/frame_data_sequence.c b/epan/frame_data_sequence.c index 8f969dabe3..a2e56006f4 100644 --- a/epan/frame_data_sequence.c +++ b/epan/frame_data_sequence.c @@ -38,8 +38,8 @@ * As frame numbers are 32 bits, and as 1024 is 2^10, that gives us * up to 4 levels of tree. */ -#define LOG2_NODES_PER_LEVEL 10 -#define NODES_PER_LEVEL (1<<LOG2_NODES_PER_LEVEL) +#define LOG2_NODES_PER_LEVEL 10 +#define NODES_PER_LEVEL (1<<LOG2_NODES_PER_LEVEL) struct _frame_data_sequence { guint32 count; /* Total number of frames */ @@ -51,23 +51,23 @@ struct _frame_data_sequence { * node, a level 2 node, a level 1 node, and a leaf node. */ #define LEVEL_3_INDEX(framenum) \ - ((framenum) >> (3*LOG2_NODES_PER_LEVEL)) + ((framenum) >> (3*LOG2_NODES_PER_LEVEL)) #define LEVEL_2_INDEX(framenum) \ - (((framenum) >> (2*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) + (((framenum) >> (2*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) #define LEVEL_1_INDEX(framenum) \ - (((framenum) >> (1*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) + (((framenum) >> (1*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) #define LEAF_INDEX(framenum) \ - (((framenum) >> (0*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) + (((framenum) >> (0*LOG2_NODES_PER_LEVEL)) & (NODES_PER_LEVEL - 1)) frame_data_sequence * new_frame_data_sequence(void) { - frame_data_sequence *fds; + frame_data_sequence *fds; - fds = (frame_data_sequence *)g_malloc(sizeof *fds); - fds->count = 0; - fds->ptree_root = NULL; - return fds; + fds = (frame_data_sequence *)g_malloc(sizeof *fds); + fds->count = 0; + fds->ptree_root = NULL; + return fds; } /* diff --git a/epan/oids.h b/epan/oids.h index 4bbdc4989a..a0668a5272 100644 --- a/epan/oids.h +++ b/epan/oids.h @@ -145,7 +145,7 @@ WS_DLL_PUBLIC guint oid_encoded2subid(const guint8 *oid, gint len, guint32** subids_p); WS_DLL_PUBLIC guint oid_encoded2subid_sub(const guint8 *oid_bytes, gint oid_len, guint32** subids_pi, - gboolean is_first); + gboolean is_first); WS_DLL_PUBLIC guint oid_string2subid(wmem_allocator_t *scope, const gchar *oid_str, guint32** subids_p); diff --git a/epan/prefs.c b/epan/prefs.c index 0f3951982d..f8a889666a 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -2600,91 +2600,91 @@ prefs_register_modules(void) GList * prefs_get_string_list(const gchar *str) { - enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT }; - - gint state = PRE_STRING, i = 0, j = 0; - gboolean backslash = FALSE; - guchar cur_c; - gchar *slstr = NULL; - GList *sl = NULL; - - /* Allocate a buffer for the first string. */ - slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - j = 0; - - for (;;) { - cur_c = str[i]; - if (cur_c == '\0') { - /* It's the end of the input, so it's the end of the string we - were working on, and there's no more input. */ - if (state == IN_QUOT || backslash) { - /* We were in the middle of a quoted string or backslash escape, - and ran out of characters; that's an error. */ - g_free(slstr); - prefs_clear_string_list(sl); - return NULL; - } - slstr[j] = '\0'; - sl = g_list_append(sl, slstr); - break; - } - if (cur_c == '"' && ! backslash) { - switch (state) { - case PRE_STRING: - /* We hadn't yet started processing a string; this starts the - string, and we're now quoting. */ - state = IN_QUOT; - break; - case IN_QUOT: - /* We're in the middle of a quoted string, and we saw a quotation - mark; we're no longer quoting. */ - state = NOT_IN_QUOT; - break; - case NOT_IN_QUOT: - /* We're working on a string, but haven't seen a quote; we're - now quoting. */ - state = IN_QUOT; - break; - default: - break; - } - } else if (cur_c == '\\' && ! backslash) { - /* We saw a backslash, and the previous character wasn't a - backslash; escape the next character. - - This also means we've started a new string. */ - backslash = TRUE; - if (state == PRE_STRING) - state = NOT_IN_QUOT; - } else if (cur_c == ',' && state != IN_QUOT && ! backslash) { - /* We saw a comma, and we're not in the middle of a quoted string - and it wasn't preceded by a backslash; it's the end of - the string we were working on... */ - slstr[j] = '\0'; - sl = g_list_append(sl, slstr); - - /* ...and the beginning of a new string. */ - state = PRE_STRING; - slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - j = 0; - } else if (!isspace(cur_c) || state != PRE_STRING) { - /* Either this isn't a white-space character, or we've started a - string (i.e., already seen a non-white-space character for that - string and put it into the string). - - The character is to be put into the string; do so if there's - room. */ - if (j < COL_MAX_LEN) { - slstr[j] = cur_c; - j++; - } + enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT }; + + gint state = PRE_STRING, i = 0, j = 0; + gboolean backslash = FALSE; + guchar cur_c; + gchar *slstr = NULL; + GList *sl = NULL; + + /* Allocate a buffer for the first string. */ + slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + j = 0; + + for (;;) { + cur_c = str[i]; + if (cur_c == '\0') { + /* It's the end of the input, so it's the end of the string we + were working on, and there's no more input. */ + if (state == IN_QUOT || backslash) { + /* We were in the middle of a quoted string or backslash escape, + and ran out of characters; that's an error. */ + g_free(slstr); + prefs_clear_string_list(sl); + return NULL; + } + slstr[j] = '\0'; + sl = g_list_append(sl, slstr); + break; + } + if (cur_c == '"' && ! backslash) { + switch (state) { + case PRE_STRING: + /* We hadn't yet started processing a string; this starts the + string, and we're now quoting. */ + state = IN_QUOT; + break; + case IN_QUOT: + /* We're in the middle of a quoted string, and we saw a quotation + mark; we're no longer quoting. */ + state = NOT_IN_QUOT; + break; + case NOT_IN_QUOT: + /* We're working on a string, but haven't seen a quote; we're + now quoting. */ + state = IN_QUOT; + break; + default: + break; + } + } else if (cur_c == '\\' && ! backslash) { + /* We saw a backslash, and the previous character wasn't a + backslash; escape the next character. + + This also means we've started a new string. */ + backslash = TRUE; + if (state == PRE_STRING) + state = NOT_IN_QUOT; + } else if (cur_c == ',' && state != IN_QUOT && ! backslash) { + /* We saw a comma, and we're not in the middle of a quoted string + and it wasn't preceded by a backslash; it's the end of + the string we were working on... */ + slstr[j] = '\0'; + sl = g_list_append(sl, slstr); + + /* ...and the beginning of a new string. */ + state = PRE_STRING; + slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + j = 0; + } else if (!isspace(cur_c) || state != PRE_STRING) { + /* Either this isn't a white-space character, or we've started a + string (i.e., already seen a non-white-space character for that + string and put it into the string). + + The character is to be put into the string; do so if there's + room. */ + if (j < COL_MAX_LEN) { + slstr[j] = cur_c; + j++; + } - /* If it was backslash-escaped, we're done with the backslash escape. */ - backslash = FALSE; + /* If it was backslash-escaped, we're done with the backslash escape. */ + backslash = FALSE; + } + i++; } - i++; - } - return(sl); + return(sl); } char *join_string_list(GList *sl) @@ -2721,12 +2721,12 @@ char *join_string_list(GList *sl) void prefs_clear_string_list(GList *sl) { - GList *l = sl; + GList *l = sl; - while (l) { - g_free(l->data); - l = g_list_remove_link(l, l); - } + while (l) { + g_free(l->data); + l = g_list_remove_link(l, l); + } } /* @@ -2789,55 +2789,55 @@ print.file: /a/very/long/path/ static gboolean parse_column_format(fmt_data *cfmt, const char *fmt) { - const gchar *cust_format = col_format_to_string(COL_CUSTOM); - size_t cust_format_len = strlen(cust_format); - gchar **cust_format_info; - char *p; - int col_fmt; - gchar *col_custom_field; - long col_custom_occurrence; - gboolean col_resolved; - - /* - * Is this a custom column? - */ - if ((strlen(fmt) > cust_format_len) && (fmt[cust_format_len] == ':') && - strncmp(fmt, cust_format, cust_format_len) == 0) { - /* Yes. */ - col_fmt = COL_CUSTOM; - cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */ - col_custom_field = g_strdup(cust_format_info[0]); - if (col_custom_field && cust_format_info[1]) { - col_custom_occurrence = strtol(cust_format_info[1], &p, 10); - if (p == cust_format_info[1] || *p != '\0') { - /* Not a valid number. */ - g_free(col_custom_field); + const gchar *cust_format = col_format_to_string(COL_CUSTOM); + size_t cust_format_len = strlen(cust_format); + gchar **cust_format_info; + char *p; + int col_fmt; + gchar *col_custom_field; + long col_custom_occurrence; + gboolean col_resolved; + + /* + * Is this a custom column? + */ + if ((strlen(fmt) > cust_format_len) && (fmt[cust_format_len] == ':') && + strncmp(fmt, cust_format, cust_format_len) == 0) { + /* Yes. */ + col_fmt = COL_CUSTOM; + cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */ + col_custom_field = g_strdup(cust_format_info[0]); + if (col_custom_field && cust_format_info[1]) { + col_custom_occurrence = strtol(cust_format_info[1], &p, 10); + if (p == cust_format_info[1] || *p != '\0') { + /* Not a valid number. */ + g_free(col_custom_field); + g_strfreev(cust_format_info); + return FALSE; + } + } else { + col_custom_occurrence = 0; + } + if (col_custom_field && cust_format_info[1] && cust_format_info[2]) { + col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE; + } else { + col_resolved = TRUE; + } g_strfreev(cust_format_info); - return FALSE; - } - } else { - col_custom_occurrence = 0; - } - if (col_custom_field && cust_format_info[1] && cust_format_info[2]) { - col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE; } else { - col_resolved = TRUE; + col_fmt = get_column_format_from_str(fmt); + if (col_fmt == -1) + return FALSE; + col_custom_field = NULL; + col_custom_occurrence = 0; + col_resolved = TRUE; } - g_strfreev(cust_format_info); - } else { - col_fmt = get_column_format_from_str(fmt); - if (col_fmt == -1) - return FALSE; - col_custom_field = NULL; - col_custom_occurrence = 0; - col_resolved = TRUE; - } - - cfmt->fmt = col_fmt; - cfmt->custom_field = col_custom_field; - cfmt->custom_occurrence = (int)col_custom_occurrence; - cfmt->resolved = col_resolved; - return TRUE; + + cfmt->fmt = col_fmt; + cfmt->custom_field = col_custom_field; + cfmt->custom_occurrence = (int)col_custom_occurrence; + cfmt->resolved = col_resolved; + return TRUE; } /* Initialize non-dissector preferences to wired-in default values. @@ -2849,16 +2849,16 @@ parse_column_format(fmt_data *cfmt, const char *fmt) static void init_prefs(void) { - if (prefs_initialized) - return; + if (prefs_initialized) + return; - uat_load_all(); + uat_load_all(); - prefs_register_modules(); + prefs_register_modules(); - filter_expression_init(TRUE); + filter_expression_init(TRUE); - prefs_initialized = TRUE; + prefs_initialized = TRUE; } /* Initialize non-dissector preferences used by the "register preference" API @@ -2867,168 +2867,168 @@ init_prefs(void) static void pre_init_prefs(void) { - int i; - gchar *col_name; - fmt_data *cfmt; - static const gchar *col_fmt[DEF_NUM_COLS*2] = { - "No.", "%m", "Time", "%t", - "Source", "%s", "Destination", "%d", - "Protocol", "%p", "Length", "%L", - "Info", "%i"}; - - if (prefs_pre_initialized) - return; - - prefs.pr_format = PR_FMT_TEXT; - prefs.pr_dest = PR_DEST_CMD; - prefs.pr_file = "wireshark.out"; - prefs.pr_cmd = "lpr"; - - prefs.gui_altern_colors = FALSE; - prefs.gui_expert_composite_eyecandy = FALSE; - prefs.gui_ptree_line_style = 0; - prefs.gui_ptree_expander_style = 1; - prefs.gui_hex_dump_highlight_style = 1; - prefs.filter_toolbar_show_in_statusbar = FALSE; - prefs.gui_toolbar_main_style = TB_STYLE_ICONS; - prefs.gui_toolbar_filter_style = TB_STYLE_TEXT; - /* These string prefs will be strduped shortly, so we can safely cast away - * their constness in these assignments */ + int i; + gchar *col_name; + fmt_data *cfmt; + static const gchar *col_fmt[DEF_NUM_COLS*2] = { + "No.", "%m", "Time", "%t", + "Source", "%s", "Destination", "%d", + "Protocol", "%p", "Length", "%L", + "Info", "%i"}; + + if (prefs_pre_initialized) + return; + + prefs.pr_format = PR_FMT_TEXT; + prefs.pr_dest = PR_DEST_CMD; + prefs.pr_file = "wireshark.out"; + prefs.pr_cmd = "lpr"; + + prefs.gui_altern_colors = FALSE; + prefs.gui_expert_composite_eyecandy = FALSE; + prefs.gui_ptree_line_style = 0; + prefs.gui_ptree_expander_style = 1; + prefs.gui_hex_dump_highlight_style = 1; + prefs.filter_toolbar_show_in_statusbar = FALSE; + prefs.gui_toolbar_main_style = TB_STYLE_ICONS; + prefs.gui_toolbar_filter_style = TB_STYLE_TEXT; + /* These string prefs will be strduped shortly, so we can safely cast away + * their constness in these assignments */ #ifdef _WIN32 - prefs.gui_gtk2_font_name = (char *) "Lucida Console 10"; + prefs.gui_gtk2_font_name = (char *) "Lucida Console 10"; #else - prefs.gui_gtk2_font_name = (char *) "Monospace 10"; + prefs.gui_gtk2_font_name = (char *) "Monospace 10"; #endif - /* We try to find the best font in the Qt code */ - prefs.gui_qt_font_name = (char *) ""; - prefs.gui_marked_fg.pixel = 65535; - prefs.gui_marked_fg.red = 65535; - prefs.gui_marked_fg.green = 65535; - prefs.gui_marked_fg.blue = 65535; - prefs.gui_marked_bg.pixel = 0; - prefs.gui_marked_bg.red = 0; - prefs.gui_marked_bg.green = 8224; - prefs.gui_marked_bg.blue = 10794; - prefs.gui_ignored_fg.pixel = 32767; - prefs.gui_ignored_fg.red = 32767; - prefs.gui_ignored_fg.green = 32767; - prefs.gui_ignored_fg.blue = 32767; - prefs.gui_ignored_bg.pixel = 65535; - prefs.gui_ignored_bg.red = 65535; - prefs.gui_ignored_bg.green = 65535; - prefs.gui_ignored_bg.blue = 65535; - prefs.gui_colorized_fg = "000000,000000,000000,000000,000000,000000,000000,000000,000000,000000"; - prefs.gui_colorized_bg = "ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0"; - prefs.st_client_fg.pixel = 0; - prefs.st_client_fg.red = 32767; - prefs.st_client_fg.green = 0; - prefs.st_client_fg.blue = 0; - prefs.st_client_bg.pixel = 0; - prefs.st_client_bg.red = 64507; - prefs.st_client_bg.green = 60909; - prefs.st_client_bg.blue = 60909; - prefs.st_server_fg.pixel = 0; - prefs.st_server_fg.red = 0; - prefs.st_server_fg.green = 0; - prefs.st_server_fg.blue = 32767; - prefs.st_server_bg.pixel = 0; - prefs.st_server_bg.red = 60909; - prefs.st_server_bg.green = 60909; - prefs.st_server_bg.blue = 64507; - prefs.gui_text_valid.pixel = 0; /* light green */ - prefs.gui_text_valid.red = 0xAFFF; - prefs.gui_text_valid.green = 0xFFFF; - prefs.gui_text_valid.blue = 0xAFFF; - prefs.gui_text_invalid.pixel = 0; /* light red */ - prefs.gui_text_invalid.red = 0xFFFF; - prefs.gui_text_invalid.green = 0xAFFF; - prefs.gui_text_invalid.blue = 0xAFFF; - prefs.gui_text_deprecated.pixel = 0; /* light yellow */ - prefs.gui_text_deprecated.red = 0xFFFF; - prefs.gui_text_deprecated.green = 0xFFFF; - prefs.gui_text_deprecated.blue = 0xAFFF; - prefs.gui_geometry_save_position = TRUE; - prefs.gui_geometry_save_size = TRUE; - prefs.gui_geometry_save_maximized= TRUE; - prefs.gui_macosx_style = TRUE; - prefs.gui_console_open = console_open_never; - prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED; - prefs.gui_recent_df_entries_max = 10; - prefs.gui_recent_files_count_max = 10; - prefs.gui_fileopen_dir = (char *) get_persdatafile_dir(); - prefs.gui_fileopen_preview = 3; - prefs.gui_ask_unsaved = TRUE; - prefs.gui_find_wrap = TRUE; - prefs.gui_use_pref_save = FALSE; - prefs.gui_update_enabled = TRUE; - prefs.gui_update_channel = UPDATE_CHANNEL_STABLE; - prefs.gui_update_interval = 60*60*24; /* Seconds */ + /* We try to find the best font in the Qt code */ + prefs.gui_qt_font_name = (char *) ""; + prefs.gui_marked_fg.pixel = 65535; + prefs.gui_marked_fg.red = 65535; + prefs.gui_marked_fg.green = 65535; + prefs.gui_marked_fg.blue = 65535; + prefs.gui_marked_bg.pixel = 0; + prefs.gui_marked_bg.red = 0; + prefs.gui_marked_bg.green = 8224; + prefs.gui_marked_bg.blue = 10794; + prefs.gui_ignored_fg.pixel = 32767; + prefs.gui_ignored_fg.red = 32767; + prefs.gui_ignored_fg.green = 32767; + prefs.gui_ignored_fg.blue = 32767; + prefs.gui_ignored_bg.pixel = 65535; + prefs.gui_ignored_bg.red = 65535; + prefs.gui_ignored_bg.green = 65535; + prefs.gui_ignored_bg.blue = 65535; + prefs.gui_colorized_fg = "000000,000000,000000,000000,000000,000000,000000,000000,000000,000000"; + prefs.gui_colorized_bg = "ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0"; + prefs.st_client_fg.pixel = 0; + prefs.st_client_fg.red = 32767; + prefs.st_client_fg.green = 0; + prefs.st_client_fg.blue = 0; + prefs.st_client_bg.pixel = 0; + prefs.st_client_bg.red = 64507; + prefs.st_client_bg.green = 60909; + prefs.st_client_bg.blue = 60909; + prefs.st_server_fg.pixel = 0; + prefs.st_server_fg.red = 0; + prefs.st_server_fg.green = 0; + prefs.st_server_fg.blue = 32767; + prefs.st_server_bg.pixel = 0; + prefs.st_server_bg.red = 60909; + prefs.st_server_bg.green = 60909; + prefs.st_server_bg.blue = 64507; + prefs.gui_text_valid.pixel = 0; /* light green */ + prefs.gui_text_valid.red = 0xAFFF; + prefs.gui_text_valid.green = 0xFFFF; + prefs.gui_text_valid.blue = 0xAFFF; + prefs.gui_text_invalid.pixel = 0; /* light red */ + prefs.gui_text_invalid.red = 0xFFFF; + prefs.gui_text_invalid.green = 0xAFFF; + prefs.gui_text_invalid.blue = 0xAFFF; + prefs.gui_text_deprecated.pixel = 0; /* light yellow */ + prefs.gui_text_deprecated.red = 0xFFFF; + prefs.gui_text_deprecated.green = 0xFFFF; + prefs.gui_text_deprecated.blue = 0xAFFF; + prefs.gui_geometry_save_position = TRUE; + prefs.gui_geometry_save_size = TRUE; + prefs.gui_geometry_save_maximized= TRUE; + prefs.gui_macosx_style = TRUE; + prefs.gui_console_open = console_open_never; + prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED; + prefs.gui_recent_df_entries_max = 10; + prefs.gui_recent_files_count_max = 10; + prefs.gui_fileopen_dir = (char *) get_persdatafile_dir(); + prefs.gui_fileopen_preview = 3; + prefs.gui_ask_unsaved = TRUE; + prefs.gui_find_wrap = TRUE; + prefs.gui_use_pref_save = FALSE; + prefs.gui_update_enabled = TRUE; + prefs.gui_update_channel = UPDATE_CHANNEL_STABLE; + prefs.gui_update_interval = 60*60*24; /* Seconds */ #ifdef HTML_VIEWER - prefs.gui_webbrowser = (char *) HTML_VIEWER " %s"; + prefs.gui_webbrowser = (char *) HTML_VIEWER " %s"; #else - prefs.gui_webbrowser = (char *) ""; + prefs.gui_webbrowser = (char *) ""; #endif - prefs.gui_window_title = (char *) ""; - prefs.gui_start_title = "The World's Most Popular Network Protocol Analyzer"; - prefs.gui_version_placement = version_both; - prefs.gui_auto_scroll_on_expand = FALSE; - prefs.gui_auto_scroll_percentage = 0; - prefs.gui_layout_type = layout_type_5; - prefs.gui_layout_content_1 = layout_pane_content_plist; - prefs.gui_layout_content_2 = layout_pane_content_pdetails; - prefs.gui_layout_content_3 = layout_pane_content_pbytes; - prefs.gui_qt_language = 0; /* (Auto-Detect) */ - prefs.gui_packet_editor = FALSE; - - prefs.col_list = NULL; - for (i = 0; i < DEF_NUM_COLS; i++) { - cfmt = g_new(fmt_data,1); - cfmt->title = g_strdup(col_fmt[i * 2]); - parse_column_format(cfmt, col_fmt[(i * 2) + 1]); - cfmt->visible = TRUE; - cfmt->resolved = TRUE; - cfmt->custom_field = NULL; - cfmt->custom_occurrence = 0; - prefs.col_list = g_list_append(prefs.col_list, cfmt); - } - prefs.num_cols = DEF_NUM_COLS; + prefs.gui_window_title = (char *) ""; + prefs.gui_start_title = "The World's Most Popular Network Protocol Analyzer"; + prefs.gui_version_placement = version_both; + prefs.gui_auto_scroll_on_expand = FALSE; + prefs.gui_auto_scroll_percentage = 0; + prefs.gui_layout_type = layout_type_5; + prefs.gui_layout_content_1 = layout_pane_content_plist; + prefs.gui_layout_content_2 = layout_pane_content_pdetails; + prefs.gui_layout_content_3 = layout_pane_content_pbytes; + prefs.gui_qt_language = 0; /* (Auto-Detect) */ + prefs.gui_packet_editor = FALSE; + + prefs.col_list = NULL; + for (i = 0; i < DEF_NUM_COLS; i++) { + cfmt = g_new(fmt_data,1); + cfmt->title = g_strdup(col_fmt[i * 2]); + parse_column_format(cfmt, col_fmt[(i * 2) + 1]); + cfmt->visible = TRUE; + cfmt->resolved = TRUE; + cfmt->custom_field = NULL; + cfmt->custom_occurrence = 0; + prefs.col_list = g_list_append(prefs.col_list, cfmt); + } + prefs.num_cols = DEF_NUM_COLS; /* set the default values for the capture dialog box */ - prefs.capture_prom_mode = TRUE; + prefs.capture_prom_mode = TRUE; #ifdef PCAP_NG_DEFAULT - prefs.capture_pcap_ng = TRUE; + prefs.capture_pcap_ng = TRUE; #else - prefs.capture_pcap_ng = FALSE; + prefs.capture_pcap_ng = FALSE; #endif - prefs.capture_real_time = TRUE; - prefs.capture_auto_scroll = TRUE; - prefs.capture_show_info = FALSE; - - prefs.capture_columns = NULL; - for (i = 0; i < num_capture_cols; i++) { - col_name = g_strdup(capture_cols[i]); - prefs.capture_columns = g_list_append(prefs.capture_columns, col_name); - } + prefs.capture_real_time = TRUE; + prefs.capture_auto_scroll = TRUE; + prefs.capture_show_info = FALSE; + + prefs.capture_columns = NULL; + for (i = 0; i < num_capture_cols; i++) { + col_name = g_strdup(capture_cols[i]); + prefs.capture_columns = g_list_append(prefs.capture_columns, col_name); + } - prefs.console_log_level = - G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR; + prefs.console_log_level = + G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR; /* set the default values for the tap/statistics dialog box */ - prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL; - prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE; - prefs.st_enable_burstinfo = TRUE; - prefs.st_burst_showcount = FALSE; - prefs.st_burst_resolution = ST_DEF_BURSTRES; - prefs.st_burst_windowlen = ST_DEF_BURSTLEN; - prefs.st_sort_casesensitve = TRUE; - prefs.st_sort_rng_fixorder = TRUE; - prefs.st_sort_rng_nameonly = TRUE; - prefs.st_sort_defcolflag = ST_SORT_COL_COUNT; - prefs.st_sort_defdescending = TRUE; - prefs.st_sort_showfullname = FALSE; - prefs.display_hidden_proto_items = FALSE; - - prefs_pre_initialized = TRUE; + prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL; + prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE; + prefs.st_enable_burstinfo = TRUE; + prefs.st_burst_showcount = FALSE; + prefs.st_burst_resolution = ST_DEF_BURSTRES; + prefs.st_burst_windowlen = ST_DEF_BURSTLEN; + prefs.st_sort_casesensitve = TRUE; + prefs.st_sort_rng_fixorder = TRUE; + prefs.st_sort_rng_nameonly = TRUE; + prefs.st_sort_defcolflag = ST_SORT_COL_COUNT; + prefs.st_sort_defdescending = TRUE; + prefs.st_sort_showfullname = FALSE; + prefs.display_hidden_proto_items = FALSE; + + prefs_pre_initialized = TRUE; } /* @@ -3124,29 +3124,29 @@ reset_module_prefs(void *value, void *data _U_) void prefs_reset(void) { - prefs_initialized = FALSE; - g_free(prefs.saved_at_version); - prefs.saved_at_version = NULL; - - /* - * Unload all UAT preferences. - */ - uat_unload_all(); - - /* - * Unload any loaded MIBs. - */ - oids_cleanup(); - - /* - * Reset the non-dissector preferences. - */ - init_prefs(); - - /* - * Reset the non-UAT dissector preferences. - */ - wmem_tree_foreach(prefs_modules, reset_module_prefs, NULL); + prefs_initialized = FALSE; + g_free(prefs.saved_at_version); + prefs.saved_at_version = NULL; + + /* + * Unload all UAT preferences. + */ + uat_unload_all(); + + /* + * Unload any loaded MIBs. + */ + oids_cleanup(); + + /* + * Reset the non-dissector preferences. + */ + init_prefs(); + + /* + * Reset the non-UAT dissector preferences. + */ + wmem_tree_foreach(prefs_modules, reset_module_prefs, NULL); } /* Read the preferences file, fill in "prefs", and return a pointer to it. @@ -3166,115 +3166,115 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return, char **gpf_path_return, int *pf_errno_return, int *pf_read_errno_return, char **pf_path_return) { - int err; - char *pf_path; - FILE *pf; + int err; + char *pf_path; + FILE *pf; - /* clean up libsmi structures before reading prefs */ - oids_cleanup(); + /* clean up libsmi structures before reading prefs */ + oids_cleanup(); - init_prefs(); + init_prefs(); - /* - * If we don't already have the pathname of the global preferences - * file, construct it. Then, in either case, try to open the file. - */ - if (gpf_path == NULL) { /* - * We don't have the path; try the new path first, and, if that - * file doesn't exist, try the old path. + * If we don't already have the pathname of the global preferences + * file, construct it. Then, in either case, try to open the file. */ - gpf_path = get_datafile_path(PF_NAME); - if ((pf = ws_fopen(gpf_path, "r")) == NULL && errno == ENOENT) { - /* - * It doesn't exist by the new name; try the old name. - */ - g_free(gpf_path); - gpf_path = get_datafile_path(OLD_GPF_NAME); - pf = ws_fopen(gpf_path, "r"); + if (gpf_path == NULL) { + /* + * We don't have the path; try the new path first, and, if that + * file doesn't exist, try the old path. + */ + gpf_path = get_datafile_path(PF_NAME); + if ((pf = ws_fopen(gpf_path, "r")) == NULL && errno == ENOENT) { + /* + * It doesn't exist by the new name; try the old name. + */ + g_free(gpf_path); + gpf_path = get_datafile_path(OLD_GPF_NAME); + pf = ws_fopen(gpf_path, "r"); + } + } else { + /* + * We have the path; try it. + */ + pf = ws_fopen(gpf_path, "r"); } - } else { - /* - * We have the path; try it. - */ - pf = ws_fopen(gpf_path, "r"); - } - - /* - * If we were able to open the file, read it. - * XXX - if it failed for a reason other than "it doesn't exist", - * report the error. - */ - *gpf_path_return = NULL; - if (pf != NULL) { + /* - * Start out the counters of "mgcp.{tcp,udp}.port" entries we've - * seen. + * If we were able to open the file, read it. + * XXX - if it failed for a reason other than "it doesn't exist", + * report the error. */ - mgcp_tcp_port_count = 0; - mgcp_udp_port_count = 0; - - /* We succeeded in opening it; read it. */ - err = read_prefs_file(gpf_path, pf, set_pref, NULL); - if (err != 0) { - /* We had an error reading the file; return the errno and the - pathname, so our caller can report the error. */ - *gpf_errno_return = 0; - *gpf_read_errno_return = err; - *gpf_path_return = gpf_path; + *gpf_path_return = NULL; + if (pf != NULL) { + /* + * Start out the counters of "mgcp.{tcp,udp}.port" entries we've + * seen. + */ + mgcp_tcp_port_count = 0; + mgcp_udp_port_count = 0; + + /* We succeeded in opening it; read it. */ + err = read_prefs_file(gpf_path, pf, set_pref, NULL); + if (err != 0) { + /* We had an error reading the file; return the errno and the + pathname, so our caller can report the error. */ + *gpf_errno_return = 0; + *gpf_read_errno_return = err; + *gpf_path_return = gpf_path; + } + fclose(pf); + } else { + /* We failed to open it. If we failed for some reason other than + "it doesn't exist", return the errno and the pathname, so our + caller can report the error. */ + if (errno != ENOENT) { + *gpf_errno_return = errno; + *gpf_read_errno_return = 0; + *gpf_path_return = gpf_path; + } } - fclose(pf); - } else { - /* We failed to open it. If we failed for some reason other than - "it doesn't exist", return the errno and the pathname, so our - caller can report the error. */ - if (errno != ENOENT) { - *gpf_errno_return = errno; - *gpf_read_errno_return = 0; - *gpf_path_return = gpf_path; + + /* Construct the pathname of the user's preferences file. */ + pf_path = get_persconffile_path(PF_NAME, TRUE); + + /* Read the user's preferences file, if it exists. */ + *pf_path_return = NULL; + if ((pf = ws_fopen(pf_path, "r")) != NULL) { + /* + * Start out the counters of "mgcp.{tcp,udp}.port" entries we've + * seen. + */ + mgcp_tcp_port_count = 0; + mgcp_udp_port_count = 0; + + /* We succeeded in opening it; read it. */ + err = read_prefs_file(pf_path, pf, set_pref, NULL); + if (err != 0) { + /* We had an error reading the file; return the errno and the + pathname, so our caller can report the error. */ + *pf_errno_return = 0; + *pf_read_errno_return = err; + *pf_path_return = pf_path; + } else + g_free(pf_path); + fclose(pf); + } else { + /* We failed to open it. If we failed for some reason other than + "it doesn't exist", return the errno and the pathname, so our + caller can report the error. */ + if (errno != ENOENT) { + *pf_errno_return = errno; + *pf_read_errno_return = 0; + *pf_path_return = pf_path; + } else + g_free(pf_path); } - } - /* Construct the pathname of the user's preferences file. */ - pf_path = get_persconffile_path(PF_NAME, TRUE); + /* load SMI modules if needed */ + oids_init(); - /* Read the user's preferences file, if it exists. */ - *pf_path_return = NULL; - if ((pf = ws_fopen(pf_path, "r")) != NULL) { - /* - * Start out the counters of "mgcp.{tcp,udp}.port" entries we've - * seen. - */ - mgcp_tcp_port_count = 0; - mgcp_udp_port_count = 0; - - /* We succeeded in opening it; read it. */ - err = read_prefs_file(pf_path, pf, set_pref, NULL); - if (err != 0) { - /* We had an error reading the file; return the errno and the - pathname, so our caller can report the error. */ - *pf_errno_return = 0; - *pf_read_errno_return = err; - *pf_path_return = pf_path; - } else - g_free(pf_path); - fclose(pf); - } else { - /* We failed to open it. If we failed for some reason other than - "it doesn't exist", return the errno and the pathname, so our - caller can report the error. */ - if (errno != ENOENT) { - *pf_errno_return = errno; - *pf_read_errno_return = 0; - *pf_path_return = pf_path; - } else - g_free(pf_path); - } - - /* load SMI modules if needed */ - oids_init(); - - return &prefs; + return &prefs; } /* read the preferences file (or similiar) and call the callback @@ -3283,192 +3283,192 @@ int read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data) { - enum { - START, /* beginning of a line */ - IN_VAR, /* processing key name */ - PRE_VAL, /* finished processing key name, skipping white space befor evalue */ - IN_VAL, /* processing value */ - IN_SKIP /* skipping to the end of the line */ - } state = START; - int got_c; - GString *cur_val; - GString *cur_var; - gboolean got_val = FALSE; - gint fline = 1, pline = 1; - gchar hint[] = "(save preferences to remove this warning)"; - gchar ver[128]; - - cur_val = g_string_new(""); - cur_var = g_string_new(""); - - /* Try to read in the profile name in the first line of the preferences file. */ - if (fscanf(pf, "# Configuration file for %127[^\r\n]", ver) == 1) { - /* Assume trailing period and remove it */ - prefs.saved_at_version = g_strndup(ver, strlen(ver) - 1); - } - rewind(pf); - - while ((got_c = getc(pf)) != EOF) { - if (got_c == '\r') { - /* Treat CR-LF at the end of a line like LF, so that if we're reading - * a Windows-format file on UN*X, we handle it the same way we'd handle - * a UN*X-format file. */ - got_c = getc(pf); - if (got_c == EOF) - break; - if (got_c != '\n') { - /* Put back the character after the CR, and process the CR normally. */ - ungetc(got_c, pf); - got_c = '\r'; - } - } - if (got_c == '\n') { - state = START; - fline++; - continue; + enum { + START, /* beginning of a line */ + IN_VAR, /* processing key name */ + PRE_VAL, /* finished processing key name, skipping white space befor evalue */ + IN_VAL, /* processing value */ + IN_SKIP /* skipping to the end of the line */ + } state = START; + int got_c; + GString *cur_val; + GString *cur_var; + gboolean got_val = FALSE; + gint fline = 1, pline = 1; + gchar hint[] = "(save preferences to remove this warning)"; + gchar ver[128]; + + cur_val = g_string_new(""); + cur_var = g_string_new(""); + + /* Try to read in the profile name in the first line of the preferences file. */ + if (fscanf(pf, "# Configuration file for %127[^\r\n]", ver) == 1) { + /* Assume trailing period and remove it */ + prefs.saved_at_version = g_strndup(ver, strlen(ver) - 1); } + rewind(pf); + + while ((got_c = getc(pf)) != EOF) { + if (got_c == '\r') { + /* Treat CR-LF at the end of a line like LF, so that if we're reading + * a Windows-format file on UN*X, we handle it the same way we'd handle + * a UN*X-format file. */ + got_c = getc(pf); + if (got_c == EOF) + break; + if (got_c != '\n') { + /* Put back the character after the CR, and process the CR normally. */ + ungetc(got_c, pf); + got_c = '\r'; + } + } + if (got_c == '\n') { + state = START; + fline++; + continue; + } - switch (state) { - case START: - if (isalnum(got_c)) { - if (cur_var->len > 0) { - if (got_val) { - if (cur_val->len > 0) { - if (cur_val->str[cur_val->len-1] == ',') { - /* - * If the pref has a trailing comma, eliminate it. - */ - cur_val->str[cur_val->len-1] = '\0'; - g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint); + switch (state) { + case START: + if (isalnum(got_c)) { + if (cur_var->len > 0) { + if (got_val) { + if (cur_val->len > 0) { + if (cur_val->str[cur_val->len-1] == ',') { + /* + * If the pref has a trailing comma, eliminate it. + */ + cur_val->str[cur_val->len-1] = '\0'; + g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint); + } + } + /* Call the routine to set the preference; it will parse + the value as appropriate. + + Since we're reading a file, rather than processing + explicit user input, for range preferences, silently + lower values in excess of the range's maximum, rather + than reporting errors and failing. */ + switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) { + + case PREFS_SET_OK: + break; + + case PREFS_SET_SYNTAX_ERR: + g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s", + cur_var->str, pline, pf_path, hint); + break; + + case PREFS_SET_NO_SUCH_PREF: + /* + * If "print.command" silently ignore it because it's valid + * on non-Win32 platforms. + */ + if (strcmp(cur_var->str, "print.command") != 0) + g_warning ("No such preference \"%s\" at line %d of\n%s %s", + cur_var->str, pline, pf_path, hint); + prefs.unknown_prefs = TRUE; + break; + + case PREFS_SET_OBSOLETE: + if (strcmp(cur_var->str, "print.command") != 0) + /* If an attempt is made to save the preferences, a popup warning will be + displayed stating that obsolete prefs have been detected and the user will + be given the opportunity to save these prefs under a different profile name. + The prefs in question need to be listed in the console window so that the + user can make an informed choice. + */ + g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s", + cur_var->str, pline, pf_path, hint); + prefs.unknown_prefs = TRUE; + break; + } + } else { + g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint); + } } - } - /* Call the routine to set the preference; it will parse - the value as appropriate. - - Since we're reading a file, rather than processing - explicit user input, for range preferences, silently - lower values in excess of the range's maximum, rather - than reporting errors and failing. */ - switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) { - - case PREFS_SET_OK: + state = IN_VAR; + got_val = FALSE; + g_string_truncate(cur_var, 0); + g_string_append_c(cur_var, (gchar) got_c); + pline = fline; + } else if (isspace(got_c) && cur_var->len > 0 && got_val) { + state = PRE_VAL; + } else if (got_c == '#') { + state = IN_SKIP; + } else { + g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint); + } + break; + case IN_VAR: + if (got_c != ':') { + g_string_append_c(cur_var, (gchar) got_c); + } else { + /* This is a colon (':') */ + state = PRE_VAL; + g_string_truncate(cur_val, 0); + /* + * Set got_val to TRUE to accommodate prefs such as + * "gui.fileopen.dir" that do not require a value. + */ + got_val = TRUE; + } + break; + case PRE_VAL: + if (!isspace(got_c)) { + state = IN_VAL; + g_string_append_c(cur_val, (gchar) got_c); + } + break; + case IN_VAL: + g_string_append_c(cur_val, (gchar) got_c); + break; + case IN_SKIP: + break; + } + } + if (cur_var->len > 0) { + if (got_val) { + /* Call the routine to set the preference; it will parse + the value as appropriate. + + Since we're reading a file, rather than processing + explicit user input, for range preferences, silently + lower values in excess of the range's maximum, rather + than reporting errors and failing. */ + switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) { + + case PREFS_SET_OK: break; - case PREFS_SET_SYNTAX_ERR: - g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s", - cur_var->str, pline, pf_path, hint); + case PREFS_SET_SYNTAX_ERR: + g_warning ("Syntax error in preference %s at line %d of\n%s %s", + cur_var->str, pline, pf_path, hint); break; - case PREFS_SET_NO_SUCH_PREF: - /* - * If "print.command" silently ignore it because it's valid - * on non-Win32 platforms. - */ - if (strcmp(cur_var->str, "print.command") != 0) - g_warning ("No such preference \"%s\" at line %d of\n%s %s", - cur_var->str, pline, pf_path, hint); + case PREFS_SET_NO_SUCH_PREF: + g_warning ("No such preference \"%s\" at line %d of\n%s %s", + cur_var->str, pline, pf_path, hint); prefs.unknown_prefs = TRUE; break; - case PREFS_SET_OBSOLETE: - if (strcmp(cur_var->str, "print.command") != 0) - /* If an attempt is made to save the preferences, a popup warning will be - displayed stating that obsolete prefs have been detected and the user will - be given the opportunity to save these prefs under a different profile name. - The prefs in question need to be listed in the console window so that the - user can make an informed choice. - */ - g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s", - cur_var->str, pline, pf_path, hint); + case PREFS_SET_OBSOLETE: prefs.unknown_prefs = TRUE; break; - } - } else { - g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint); } - } - state = IN_VAR; - got_val = FALSE; - g_string_truncate(cur_var, 0); - g_string_append_c(cur_var, (gchar) got_c); - pline = fline; - } else if (isspace(got_c) && cur_var->len > 0 && got_val) { - state = PRE_VAL; - } else if (got_c == '#') { - state = IN_SKIP; - } else { - g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint); - } - break; - case IN_VAR: - if (got_c != ':') { - g_string_append_c(cur_var, (gchar) got_c); } else { - /* This is a colon (':') */ - state = PRE_VAL; - g_string_truncate(cur_val, 0); - /* - * Set got_val to TRUE to accommodate prefs such as - * "gui.fileopen.dir" that do not require a value. - */ - got_val = TRUE; - } - break; - case PRE_VAL: - if (!isspace(got_c)) { - state = IN_VAL; - g_string_append_c(cur_val, (gchar) got_c); + g_warning ("Incomplete preference at line %d of\n%s %s", + pline, pf_path, hint); } - break; - case IN_VAL: - g_string_append_c(cur_val, (gchar) got_c); - break; - case IN_SKIP: - break; } - } - if (cur_var->len > 0) { - if (got_val) { - /* Call the routine to set the preference; it will parse - the value as appropriate. - - Since we're reading a file, rather than processing - explicit user input, for range preferences, silently - lower values in excess of the range's maximum, rather - than reporting errors and failing. */ - switch (pref_set_pair_fct(cur_var->str, cur_val->str, private_data, FALSE)) { - - case PREFS_SET_OK: - break; - case PREFS_SET_SYNTAX_ERR: - g_warning ("Syntax error in preference %s at line %d of\n%s %s", - cur_var->str, pline, pf_path, hint); - break; + g_string_free(cur_val, TRUE); + g_string_free(cur_var, TRUE); - case PREFS_SET_NO_SUCH_PREF: - g_warning ("No such preference \"%s\" at line %d of\n%s %s", - cur_var->str, pline, pf_path, hint); - prefs.unknown_prefs = TRUE; - break; - - case PREFS_SET_OBSOLETE: - prefs.unknown_prefs = TRUE; - break; - } - } else { - g_warning ("Incomplete preference at line %d of\n%s %s", - pline, pf_path, hint); - } - } - - g_string_free(cur_val, TRUE); - g_string_free(cur_var, TRUE); - - if (ferror(pf)) - return errno; - else - return 0; + if (ferror(pf)) + return errno; + else + return 0; } /* @@ -3728,34 +3728,34 @@ prefs_capture_options_dialog_column_is_visible(const gchar *column) char string_to_name_resolve(const char *string, e_addr_resolve *name_resolve) { - char c; + char c; - memset(name_resolve, 0, sizeof(e_addr_resolve)); - while ((c = *string++) != '\0') { - switch (c) { - case 'm': - name_resolve->mac_name = TRUE; - break; - case 'n': - name_resolve->network_name = TRUE; - break; - case 'N': - name_resolve->use_external_net_name_resolver = TRUE; - break; - case 't': - name_resolve->transport_name = TRUE; - break; - case 'C': - name_resolve->concurrent_dns = TRUE; - break; - default: - /* - * Unrecognized letter. - */ - return c; - } - } - return '\0'; + memset(name_resolve, 0, sizeof(e_addr_resolve)); + while ((c = *string++) != '\0') { + switch (c) { + case 'm': + name_resolve->mac_name = TRUE; + break; + case 'n': + name_resolve->network_name = TRUE; + break; + case 'N': + name_resolve->use_external_net_name_resolver = TRUE; + break; + case 't': + name_resolve->transport_name = TRUE; + break; + case 'C': + name_resolve->concurrent_dns = TRUE; + break; + default: + /* + * Unrecognized letter. + */ + return c; + } + } + return '\0'; } @@ -3806,509 +3806,509 @@ static prefs_set_pref_e set_pref(gchar *pref_name, const gchar *value, void *private_data _U_, gboolean return_range_errors) { - unsigned long int cval; - guint uval; - gboolean bval; - gint enum_val; - char *p; - gchar *dotp, *last_dotp; - static gchar *filter_label = NULL; - static gboolean filter_enabled = FALSE; - gchar *filter_expr = NULL; - module_t *module; - pref_t *pref; - - if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) { - filter_label = g_strdup(value); - } else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) { - filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE; - } else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) { - filter_expr = g_strdup(value); - filter_expression_new(filter_label, filter_expr, filter_enabled); - g_free(filter_label); - g_free(filter_expr); - } else if (strcmp(pref_name, "gui.version_in_start_page") == 0) { - /* Convert deprecated value to closest current equivalent */ - if (g_ascii_strcasecmp(value, "true") == 0) { - prefs.gui_version_placement = version_both; - } else { - prefs.gui_version_placement = version_neither; - } - } else if (strcmp(pref_name, "name_resolve") == 0 || - strcmp(pref_name, "capture.name_resolve") == 0) { - /* - * Handle the deprecated name resolution options. - * - * "TRUE" and "FALSE", for backwards compatibility, are synonyms for - * RESOLV_ALL and RESOLV_NONE. - * - * Otherwise, we treat it as a list of name types we want to resolve. - */ - if (g_ascii_strcasecmp(value, "true") == 0) { - gbl_resolv_flags.mac_name = TRUE; - gbl_resolv_flags.network_name = TRUE; - gbl_resolv_flags.transport_name = TRUE; - gbl_resolv_flags.concurrent_dns = TRUE; - } - else if (g_ascii_strcasecmp(value, "false") == 0) { - gbl_resolv_flags.mac_name = FALSE; - gbl_resolv_flags.network_name = FALSE; - gbl_resolv_flags.transport_name = FALSE; - gbl_resolv_flags.concurrent_dns = FALSE; - } - else { - /* start out with none set */ - gbl_resolv_flags.mac_name = FALSE; - gbl_resolv_flags.network_name = FALSE; - gbl_resolv_flags.transport_name = FALSE; - gbl_resolv_flags.concurrent_dns = FALSE; - if (string_to_name_resolve(value, &gbl_resolv_flags) != '\0') - return PREFS_SET_SYNTAX_ERR; - } - } else { - /* Handle deprecated "global" options that don't have a module - * associated with them - */ - if ((strcmp(pref_name, "name_resolve_concurrency") == 0) || - (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) || - (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0)) { - module = nameres_module; - dotp = pref_name; - } else { - /* To which module does this preference belong? */ - module = NULL; - last_dotp = pref_name; - while (!module) { - dotp = strchr(last_dotp, '.'); - if (dotp == NULL) { - /* Either there's no such module, or no module was specified. - In either case, that means there's no such preference. */ - return PREFS_SET_NO_SUCH_PREF; + unsigned long int cval; + guint uval; + gboolean bval; + gint enum_val; + char *p; + gchar *dotp, *last_dotp; + static gchar *filter_label = NULL; + static gboolean filter_enabled = FALSE; + gchar *filter_expr = NULL; + module_t *module; + pref_t *pref; + + if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) { + filter_label = g_strdup(value); + } else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) { + filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE; + } else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) { + filter_expr = g_strdup(value); + filter_expression_new(filter_label, filter_expr, filter_enabled); + g_free(filter_label); + g_free(filter_expr); + } else if (strcmp(pref_name, "gui.version_in_start_page") == 0) { + /* Convert deprecated value to closest current equivalent */ + if (g_ascii_strcasecmp(value, "true") == 0) { + prefs.gui_version_placement = version_both; + } else { + prefs.gui_version_placement = version_neither; } - *dotp = '\0'; /* separate module and preference name */ - module = prefs_find_module(pref_name); - + } else if (strcmp(pref_name, "name_resolve") == 0 || + strcmp(pref_name, "capture.name_resolve") == 0) { /* - * XXX - "Diameter" rather than "diameter" was used in earlier - * versions of Wireshark; if we didn't find the module, and its name - * was "Diameter", look for "diameter" instead. - * - * In addition, the BEEP protocol used to be the BXXP protocol, - * so if we didn't find the module, and its name was "bxxp", - * look for "beep" instead. - * - * Also, the preferences for GTP v0 and v1 were combined under - * a single "gtp" heading, and the preferences for SMPP were - * moved to "smpp-gsm-sms" and then moved to "gsm-sms-ud". - * However, SMPP now has its own preferences, so we just map - * "smpp-gsm-sms" to "gsm-sms-ud", and then handle SMPP below. + * Handle the deprecated name resolution options. * - * We also renamed "dcp" to "dccp", "x.25" to "x25", "x411" to "p1" - * and "nsip" to "gprs_ns". - * - * The SynOptics Network Management Protocol (SONMP) is now known by - * its modern name, the Nortel Discovery Protocol (NDP). - */ - if (module == NULL) { - if (strcmp(pref_name, "column") == 0) - module = gui_column_module; - else if (strcmp(pref_name, "Diameter") == 0) - module = prefs_find_module("diameter"); - else if (strcmp(pref_name, "bxxp") == 0) - module = prefs_find_module("beep"); - else if (strcmp(pref_name, "gtpv0") == 0 || - strcmp(pref_name, "gtpv1") == 0) - module = prefs_find_module("gtp"); - else if (strcmp(pref_name, "smpp-gsm-sms") == 0) - module = prefs_find_module("gsm-sms-ud"); - else if (strcmp(pref_name, "dcp") == 0) - module = prefs_find_module("dccp"); - else if (strcmp(pref_name, "x.25") == 0) - module = prefs_find_module("x25"); - else if (strcmp(pref_name, "x411") == 0) - module = prefs_find_module("p1"); - else if (strcmp(pref_name, "nsip") == 0) - module = prefs_find_module("gprs-ns"); - else if (strcmp(pref_name, "sonmp") == 0) - module = prefs_find_module("ndp"); - else if (strcmp(pref_name, "etheric") == 0 || - strcmp(pref_name, "isup_thin") == 0) { - /* This protocol was removed 7. July 2009 */ - return PREFS_SET_OBSOLETE; - } - if (module) { - g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n" - "Save your preferences to make this change permanent.", - pref_name, dotp+1, module->parent->name, pref_name, dotp+1); - prefs.unknown_prefs = TRUE; - } - } - *dotp = '.'; /* put the preference string back */ - dotp++; /* skip past separator to preference name */ - last_dotp = dotp; - } - } - - pref = prefs_find_preference(module, dotp); - - if (pref == NULL) { - prefs.unknown_prefs = TRUE; - - /* "gui" prefix was added to column preferences for better organization - * within the preferences file - */ - if ((strcmp(pref_name, PRS_COL_HIDDEN) == 0) || - (strcmp(pref_name, PRS_COL_FMT) == 0)) { - pref = prefs_find_preference(module, pref_name); - } - else if (strcmp(module->name, "mgcp") == 0) { - /* - * XXX - "mgcp.display raw text toggle" and "mgcp.display dissect tree" - * rather than "mgcp.display_raw_text" and "mgcp.display_dissect_tree" - * were used in earlier versions of Wireshark; if we didn't find the - * preference, it was an MGCP preference, and its name was - * "display raw text toggle" or "display dissect tree", look for - * "display_raw_text" or "display_dissect_tree" instead. + * "TRUE" and "FALSE", for backwards compatibility, are synonyms for + * RESOLV_ALL and RESOLV_NONE. * - * "mgcp.tcp.port" and "mgcp.udp.port" are harder to handle, as both - * the gateway and callagent ports were given those names; we interpret - * the first as "mgcp.{tcp,udp}.gateway_port" and the second as - * "mgcp.{tcp,udp}.callagent_port", as that's the order in which - * they were registered by the MCCP dissector and thus that's the - * order in which they were written to the preferences file. (If - * we're not reading the preferences file, but are handling stuff - * from a "-o" command-line option, we have no clue which the user - * had in mind - they should have used "mgcp.{tcp,udp}.gateway_port" - * or "mgcp.{tcp,udp}.callagent_port" instead.) + * Otherwise, we treat it as a list of name types we want to resolve. */ - if (strcmp(dotp, "display raw text toggle") == 0) - pref = prefs_find_preference(module, "display_raw_text"); - else if (strcmp(dotp, "display dissect tree") == 0) - pref = prefs_find_preference(module, "display_dissect_tree"); - else if (strcmp(dotp, "tcp.port") == 0) { - mgcp_tcp_port_count++; - if (mgcp_tcp_port_count == 1) { - /* It's the first one */ - pref = prefs_find_preference(module, "tcp.gateway_port"); - } else if (mgcp_tcp_port_count == 2) { - /* It's the second one */ - pref = prefs_find_preference(module, "tcp.callagent_port"); - } - /* Otherwise it's from the command line, and we don't bother - mapping it. */ - } else if (strcmp(dotp, "udp.port") == 0) { - mgcp_udp_port_count++; - if (mgcp_udp_port_count == 1) { - /* It's the first one */ - pref = prefs_find_preference(module, "udp.gateway_port"); - } else if (mgcp_udp_port_count == 2) { - /* It's the second one */ - pref = prefs_find_preference(module, "udp.callagent_port"); - } - /* Otherwise it's from the command line, and we don't bother - mapping it. */ + if (g_ascii_strcasecmp(value, "true") == 0) { + gbl_resolv_flags.mac_name = TRUE; + gbl_resolv_flags.network_name = TRUE; + gbl_resolv_flags.transport_name = TRUE; + gbl_resolv_flags.concurrent_dns = TRUE; } - } else if (strcmp(module->name, "smb") == 0) { - /* Handle old names for SMB preferences. */ - if (strcmp(dotp, "smb.trans.reassembly") == 0) - pref = prefs_find_preference(module, "trans_reassembly"); - else if (strcmp(dotp, "smb.dcerpc.reassembly") == 0) - pref = prefs_find_preference(module, "dcerpc_reassembly"); - } else if (strcmp(module->name, "ndmp") == 0) { - /* Handle old names for NDMP preferences. */ - if (strcmp(dotp, "ndmp.desegment") == 0) - pref = prefs_find_preference(module, "desegment"); - } else if (strcmp(module->name, "diameter") == 0) { - /* Handle old names for Diameter preferences. */ - if (strcmp(dotp, "diameter.desegment") == 0) - pref = prefs_find_preference(module, "desegment"); - } else if (strcmp(module->name, "pcli") == 0) { - /* Handle old names for PCLI preferences. */ - if (strcmp(dotp, "pcli.udp_port") == 0) - pref = prefs_find_preference(module, "udp_port"); - } else if (strcmp(module->name, "artnet") == 0) { - /* Handle old names for ARTNET preferences. */ - if (strcmp(dotp, "artnet.udp_port") == 0) - pref = prefs_find_preference(module, "udp_port"); - } else if (strcmp(module->name, "mapi") == 0) { - /* Handle old names for MAPI preferences. */ - if (strcmp(dotp, "mapi_decrypt") == 0) - pref = prefs_find_preference(module, "decrypt"); - } else if (strcmp(module->name, "fc") == 0) { - /* Handle old names for Fibre Channel preferences. */ - if (strcmp(dotp, "reassemble_fc") == 0) - pref = prefs_find_preference(module, "reassemble"); - else if (strcmp(dotp, "fc_max_frame_size") == 0) - pref = prefs_find_preference(module, "max_frame_size"); - } else if (strcmp(module->name, "fcip") == 0) { - /* Handle old names for Fibre Channel-over-IP preferences. */ - if (strcmp(dotp, "desegment_fcip_messages") == 0) - pref = prefs_find_preference(module, "desegment"); - else if (strcmp(dotp, "fcip_port") == 0) - pref = prefs_find_preference(module, "target_port"); - } else if (strcmp(module->name, "gtp") == 0) { - /* Handle old names for GTP preferences. */ - if (strcmp(dotp, "gtpv0_port") == 0) - pref = prefs_find_preference(module, "v0_port"); - else if (strcmp(dotp, "gtpv1c_port") == 0) - pref = prefs_find_preference(module, "v1c_port"); - else if (strcmp(dotp, "gtpv1u_port") == 0) - pref = prefs_find_preference(module, "v1u_port"); - else if (strcmp(dotp, "gtp_dissect_tpdu") == 0) - pref = prefs_find_preference(module, "dissect_tpdu"); - else if (strcmp(dotp, "gtpv0_dissect_cdr_as") == 0) - pref = prefs_find_preference(module, "v0_dissect_cdr_as"); - else if (strcmp(dotp, "gtpv0_check_etsi") == 0) - pref = prefs_find_preference(module, "v0_check_etsi"); - else if (strcmp(dotp, "gtpv1_check_etsi") == 0) - pref = prefs_find_preference(module, "v1_check_etsi"); - } else if (strcmp(module->name, "ip") == 0) { - /* Handle old names for IP preferences. */ - if (strcmp(dotp, "ip_summary_in_tree") == 0) - pref = prefs_find_preference(module, "summary_in_tree"); - } else if (strcmp(module->name, "iscsi") == 0) { - /* Handle old names for iSCSI preferences. */ - if (strcmp(dotp, "iscsi_port") == 0) - pref = prefs_find_preference(module, "target_port"); - } else if (strcmp(module->name, "lmp") == 0) { - /* Handle old names for LMP preferences. */ - if (strcmp(dotp, "lmp_version") == 0) - pref = prefs_find_preference(module, "version"); - } else if (strcmp(module->name, "mtp3") == 0) { - /* Handle old names for MTP3 preferences. */ - if (strcmp(dotp, "mtp3_standard") == 0) - pref = prefs_find_preference(module, "standard"); - else if (strcmp(dotp, "net_addr_format") == 0) - pref = prefs_find_preference(module, "addr_format"); - } else if (strcmp(module->name, "nlm") == 0) { - /* Handle old names for NLM preferences. */ - if (strcmp(dotp, "nlm_msg_res_matching") == 0) - pref = prefs_find_preference(module, "msg_res_matching"); - } else if (strcmp(module->name, "ppp") == 0) { - /* Handle old names for PPP preferences. */ - if (strcmp(dotp, "ppp_fcs") == 0) - pref = prefs_find_preference(module, "fcs_type"); - else if (strcmp(dotp, "ppp_vj") == 0) - pref = prefs_find_preference(module, "decompress_vj"); - } else if (strcmp(module->name, "rsvp") == 0) { - /* Handle old names for RSVP preferences. */ - if (strcmp(dotp, "rsvp_process_bundle") == 0) - pref = prefs_find_preference(module, "process_bundle"); - } else if (strcmp(module->name, "tcp") == 0) { - /* Handle old names for TCP preferences. */ - if (strcmp(dotp, "tcp_summary_in_tree") == 0) - pref = prefs_find_preference(module, "summary_in_tree"); - else if (strcmp(dotp, "tcp_analyze_sequence_numbers") == 0) - pref = prefs_find_preference(module, "analyze_sequence_numbers"); - else if (strcmp(dotp, "tcp_relative_sequence_numbers") == 0) - pref = prefs_find_preference(module, "relative_sequence_numbers"); - } else if (strcmp(module->name, "udp") == 0) { - /* Handle old names for UDP preferences. */ - if (strcmp(dotp, "udp_summary_in_tree") == 0) - pref = prefs_find_preference(module, "summary_in_tree"); - } else if (strcmp(module->name, "ndps") == 0) { - /* Handle old names for NDPS preferences. */ - if (strcmp(dotp, "desegment_ndps") == 0) - pref = prefs_find_preference(module, "desegment_tcp"); - } else if (strcmp(module->name, "http") == 0) { - /* Handle old names for HTTP preferences. */ - if (strcmp(dotp, "desegment_http_headers") == 0) - pref = prefs_find_preference(module, "desegment_headers"); - else if (strcmp(dotp, "desegment_http_body") == 0) - pref = prefs_find_preference(module, "desegment_body"); - } else if (strcmp(module->name, "smpp") == 0) { - /* Handle preferences that moved from SMPP. */ - module_t *new_module = prefs_find_module("gsm-sms-ud"); - if (new_module){ - if (strcmp(dotp, "port_number_udh_means_wsp") == 0) - pref = prefs_find_preference(new_module, "port_number_udh_means_wsp"); - else if (strcmp(dotp, "try_dissect_1st_fragment") == 0) - pref = prefs_find_preference(new_module, "try_dissect_1st_fragment"); + else if (g_ascii_strcasecmp(value, "false") == 0) { + gbl_resolv_flags.mac_name = FALSE; + gbl_resolv_flags.network_name = FALSE; + gbl_resolv_flags.transport_name = FALSE; + gbl_resolv_flags.concurrent_dns = FALSE; } - } else if (strcmp(module->name, "asn1") == 0) { - /* Handle old generic ASN.1 preferences (it's not really a - rename, as the new preferences support multiple ports, - but we might as well copy them over). */ - if (strcmp(dotp, "tcp_port") == 0) - pref = prefs_find_preference(module, "tcp_ports"); - else if (strcmp(dotp, "udp_port") == 0) - pref = prefs_find_preference(module, "udp_ports"); - else if (strcmp(dotp, "sctp_port") == 0) - pref = prefs_find_preference(module, "sctp_ports"); - } else if (strcmp(module->name, "llcgprs") == 0) { - if (strcmp(dotp, "ignore_cipher_bit") == 0) - pref = prefs_find_preference(module, "autodetect_cipher_bit"); - } else if (strcmp(module->name, "erf") == 0) { - if (strcmp(dotp, "erfeth") == 0) { - /* Handle the old "erfeth" preference; map it to the new - "ethfcs" preference, and map the values to those for - the new preference. */ - pref = prefs_find_preference(module, "ethfcs"); - if (strcmp(value, "ethfcs") == 0 || strcmp(value, "Ethernet with FCS") == 0) - value = "TRUE"; - else if (strcmp(value, "eth") == 0 || strcmp(value, "Ethernet") == 0) - value = "FALSE"; - else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) - value = "TRUE"; - } else if (strcmp(dotp, "erfatm") == 0) { - /* Handle the old "erfatm" preference; map it to the new - "aal5_type" preference, and map the values to those for - the new preference. */ - pref = prefs_find_preference(module, "aal5_type"); - if (strcmp(value, "atm") == 0 || strcmp(value, "ATM") == 0) - value = "guess"; - else if (strcmp(value, "llc") == 0 || strcmp(value, "LLC") == 0) - value = "llc"; - else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) - value = "guess"; - } else if (strcmp(dotp, "erfhdlc") == 0) { - /* Handle the old "erfhdlc" preference; map it to the new - "hdlc_type" preference, and map the values to those for - the new preference. */ - pref = prefs_find_preference(module, "hdlc_type"); - if (strcmp(value, "chdlc") == 0 || strcmp(value, "Cisco HDLC") == 0) - value = "chdlc"; - else if (strcmp(value, "ppp") == 0 || strcmp(value, "PPP serial") == 0) - value = "ppp"; - else if (strcmp(value, "fr") == 0 || strcmp(value, "Frame Relay") == 0) - value = "frelay"; - else if (strcmp(value, "mtp2") == 0 || strcmp(value, "SS7 MTP2") == 0) - value = "mtp2"; - else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) - value = "guess"; + else { + /* start out with none set */ + gbl_resolv_flags.mac_name = FALSE; + gbl_resolv_flags.network_name = FALSE; + gbl_resolv_flags.transport_name = FALSE; + gbl_resolv_flags.concurrent_dns = FALSE; + if (string_to_name_resolve(value, &gbl_resolv_flags) != '\0') + return PREFS_SET_SYNTAX_ERR; } - } else if (strcmp(module->name, "eth") == 0) { - /* "eth.qinq_ethertype" has been changed(restored) to "vlan.qinq.ethertype" */ - if (strcmp(dotp, "qinq_ethertype") == 0) { - module_t *new_module = prefs_find_module("vlan"); - if (new_module) { - pref = prefs_find_preference(new_module, "qinq_ethertype"); - module = new_module; - } + } else { + /* Handle deprecated "global" options that don't have a module + * associated with them + */ + if ((strcmp(pref_name, "name_resolve_concurrency") == 0) || + (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) || + (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0)) { + module = nameres_module; + dotp = pref_name; + } else { + /* To which module does this preference belong? */ + module = NULL; + last_dotp = pref_name; + while (!module) { + dotp = strchr(last_dotp, '.'); + if (dotp == NULL) { + /* Either there's no such module, or no module was specified. + In either case, that means there's no such preference. */ + return PREFS_SET_NO_SUCH_PREF; + } + *dotp = '\0'; /* separate module and preference name */ + module = prefs_find_module(pref_name); + + /* + * XXX - "Diameter" rather than "diameter" was used in earlier + * versions of Wireshark; if we didn't find the module, and its name + * was "Diameter", look for "diameter" instead. + * + * In addition, the BEEP protocol used to be the BXXP protocol, + * so if we didn't find the module, and its name was "bxxp", + * look for "beep" instead. + * + * Also, the preferences for GTP v0 and v1 were combined under + * a single "gtp" heading, and the preferences for SMPP were + * moved to "smpp-gsm-sms" and then moved to "gsm-sms-ud". + * However, SMPP now has its own preferences, so we just map + * "smpp-gsm-sms" to "gsm-sms-ud", and then handle SMPP below. + * + * We also renamed "dcp" to "dccp", "x.25" to "x25", "x411" to "p1" + * and "nsip" to "gprs_ns". + * + * The SynOptics Network Management Protocol (SONMP) is now known by + * its modern name, the Nortel Discovery Protocol (NDP). + */ + if (module == NULL) { + if (strcmp(pref_name, "column") == 0) + module = gui_column_module; + else if (strcmp(pref_name, "Diameter") == 0) + module = prefs_find_module("diameter"); + else if (strcmp(pref_name, "bxxp") == 0) + module = prefs_find_module("beep"); + else if (strcmp(pref_name, "gtpv0") == 0 || + strcmp(pref_name, "gtpv1") == 0) + module = prefs_find_module("gtp"); + else if (strcmp(pref_name, "smpp-gsm-sms") == 0) + module = prefs_find_module("gsm-sms-ud"); + else if (strcmp(pref_name, "dcp") == 0) + module = prefs_find_module("dccp"); + else if (strcmp(pref_name, "x.25") == 0) + module = prefs_find_module("x25"); + else if (strcmp(pref_name, "x411") == 0) + module = prefs_find_module("p1"); + else if (strcmp(pref_name, "nsip") == 0) + module = prefs_find_module("gprs-ns"); + else if (strcmp(pref_name, "sonmp") == 0) + module = prefs_find_module("ndp"); + else if (strcmp(pref_name, "etheric") == 0 || + strcmp(pref_name, "isup_thin") == 0) { + /* This protocol was removed 7. July 2009 */ + return PREFS_SET_OBSOLETE; + } + if (module) { + g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n" + "Save your preferences to make this change permanent.", + pref_name, dotp+1, module->parent->name, pref_name, dotp+1); + prefs.unknown_prefs = TRUE; + } + } + *dotp = '.'; /* put the preference string back */ + dotp++; /* skip past separator to preference name */ + last_dotp = dotp; + } } - } else if (strcmp(module->name, "taps") == 0) { - /* taps preferences moved to "statistics" module */ - if (strcmp(dotp, "update_interval") == 0 || - strcmp(dotp, "rtp_player_max_visible") == 0) - pref = prefs_find_preference(stats_module, dotp); - } else if (strcmp(module->name, "packet_list") == 0) { - /* packet_list preferences moved to protocol module */ - if (strcmp(dotp, "display_hidden_proto_items") == 0) - pref = prefs_find_preference(protocols_module, dotp); - } else if (strcmp(module->name, "stream") == 0) { - /* stream preferences moved to gui color module */ - if ((strcmp(dotp, "client.fg") == 0) || - (strcmp(dotp, "client.bg") == 0) || - (strcmp(dotp, "server.fg") == 0) || - (strcmp(dotp, "server.bg") == 0)) - pref = prefs_find_preference(gui_color_module, pref_name); - } else if (strcmp(module->name, "nameres") == 0) { - if (strcmp(pref_name, "name_resolve_concurrency") == 0) { - pref = prefs_find_preference(nameres_module, pref_name); - } else if (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) { - pref = prefs_find_preference(nameres_module, "load_smi_modules"); - } else if (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0) { - pref = prefs_find_preference(nameres_module, "suppress_smi_errors"); - } - } - } - if (pref == NULL) - return PREFS_SET_NO_SUCH_PREF; /* no such preference */ - switch (pref->type) { + pref = prefs_find_preference(module, dotp); - case PREF_UINT: - /* XXX - give an error if it doesn't fit in a guint? */ - uval = (guint)strtoul(value, &p, pref->info.base); - if (p == value || *p != '\0') - return PREFS_SET_SYNTAX_ERR; /* number was bad */ - if (*pref->varp.uint != uval) { - module->prefs_changed = TRUE; - *pref->varp.uint = uval; - } - break; + if (pref == NULL) { + prefs.unknown_prefs = TRUE; - case PREF_BOOL: - /* XXX - give an error if it's neither "true" nor "false"? */ - if (g_ascii_strcasecmp(value, "true") == 0) - bval = TRUE; - else - bval = FALSE; - if (*pref->varp.boolp != bval) { - module->prefs_changed = TRUE; - *pref->varp.boolp = bval; - } - break; + /* "gui" prefix was added to column preferences for better organization + * within the preferences file + */ + if ((strcmp(pref_name, PRS_COL_HIDDEN) == 0) || + (strcmp(pref_name, PRS_COL_FMT) == 0)) { + pref = prefs_find_preference(module, pref_name); + } + else if (strcmp(module->name, "mgcp") == 0) { + /* + * XXX - "mgcp.display raw text toggle" and "mgcp.display dissect tree" + * rather than "mgcp.display_raw_text" and "mgcp.display_dissect_tree" + * were used in earlier versions of Wireshark; if we didn't find the + * preference, it was an MGCP preference, and its name was + * "display raw text toggle" or "display dissect tree", look for + * "display_raw_text" or "display_dissect_tree" instead. + * + * "mgcp.tcp.port" and "mgcp.udp.port" are harder to handle, as both + * the gateway and callagent ports were given those names; we interpret + * the first as "mgcp.{tcp,udp}.gateway_port" and the second as + * "mgcp.{tcp,udp}.callagent_port", as that's the order in which + * they were registered by the MCCP dissector and thus that's the + * order in which they were written to the preferences file. (If + * we're not reading the preferences file, but are handling stuff + * from a "-o" command-line option, we have no clue which the user + * had in mind - they should have used "mgcp.{tcp,udp}.gateway_port" + * or "mgcp.{tcp,udp}.callagent_port" instead.) + */ + if (strcmp(dotp, "display raw text toggle") == 0) + pref = prefs_find_preference(module, "display_raw_text"); + else if (strcmp(dotp, "display dissect tree") == 0) + pref = prefs_find_preference(module, "display_dissect_tree"); + else if (strcmp(dotp, "tcp.port") == 0) { + mgcp_tcp_port_count++; + if (mgcp_tcp_port_count == 1) { + /* It's the first one */ + pref = prefs_find_preference(module, "tcp.gateway_port"); + } else if (mgcp_tcp_port_count == 2) { + /* It's the second one */ + pref = prefs_find_preference(module, "tcp.callagent_port"); + } + /* Otherwise it's from the command line, and we don't bother + mapping it. */ + } else if (strcmp(dotp, "udp.port") == 0) { + mgcp_udp_port_count++; + if (mgcp_udp_port_count == 1) { + /* It's the first one */ + pref = prefs_find_preference(module, "udp.gateway_port"); + } else if (mgcp_udp_port_count == 2) { + /* It's the second one */ + pref = prefs_find_preference(module, "udp.callagent_port"); + } + /* Otherwise it's from the command line, and we don't bother + mapping it. */ + } + } else if (strcmp(module->name, "smb") == 0) { + /* Handle old names for SMB preferences. */ + if (strcmp(dotp, "smb.trans.reassembly") == 0) + pref = prefs_find_preference(module, "trans_reassembly"); + else if (strcmp(dotp, "smb.dcerpc.reassembly") == 0) + pref = prefs_find_preference(module, "dcerpc_reassembly"); + } else if (strcmp(module->name, "ndmp") == 0) { + /* Handle old names for NDMP preferences. */ + if (strcmp(dotp, "ndmp.desegment") == 0) + pref = prefs_find_preference(module, "desegment"); + } else if (strcmp(module->name, "diameter") == 0) { + /* Handle old names for Diameter preferences. */ + if (strcmp(dotp, "diameter.desegment") == 0) + pref = prefs_find_preference(module, "desegment"); + } else if (strcmp(module->name, "pcli") == 0) { + /* Handle old names for PCLI preferences. */ + if (strcmp(dotp, "pcli.udp_port") == 0) + pref = prefs_find_preference(module, "udp_port"); + } else if (strcmp(module->name, "artnet") == 0) { + /* Handle old names for ARTNET preferences. */ + if (strcmp(dotp, "artnet.udp_port") == 0) + pref = prefs_find_preference(module, "udp_port"); + } else if (strcmp(module->name, "mapi") == 0) { + /* Handle old names for MAPI preferences. */ + if (strcmp(dotp, "mapi_decrypt") == 0) + pref = prefs_find_preference(module, "decrypt"); + } else if (strcmp(module->name, "fc") == 0) { + /* Handle old names for Fibre Channel preferences. */ + if (strcmp(dotp, "reassemble_fc") == 0) + pref = prefs_find_preference(module, "reassemble"); + else if (strcmp(dotp, "fc_max_frame_size") == 0) + pref = prefs_find_preference(module, "max_frame_size"); + } else if (strcmp(module->name, "fcip") == 0) { + /* Handle old names for Fibre Channel-over-IP preferences. */ + if (strcmp(dotp, "desegment_fcip_messages") == 0) + pref = prefs_find_preference(module, "desegment"); + else if (strcmp(dotp, "fcip_port") == 0) + pref = prefs_find_preference(module, "target_port"); + } else if (strcmp(module->name, "gtp") == 0) { + /* Handle old names for GTP preferences. */ + if (strcmp(dotp, "gtpv0_port") == 0) + pref = prefs_find_preference(module, "v0_port"); + else if (strcmp(dotp, "gtpv1c_port") == 0) + pref = prefs_find_preference(module, "v1c_port"); + else if (strcmp(dotp, "gtpv1u_port") == 0) + pref = prefs_find_preference(module, "v1u_port"); + else if (strcmp(dotp, "gtp_dissect_tpdu") == 0) + pref = prefs_find_preference(module, "dissect_tpdu"); + else if (strcmp(dotp, "gtpv0_dissect_cdr_as") == 0) + pref = prefs_find_preference(module, "v0_dissect_cdr_as"); + else if (strcmp(dotp, "gtpv0_check_etsi") == 0) + pref = prefs_find_preference(module, "v0_check_etsi"); + else if (strcmp(dotp, "gtpv1_check_etsi") == 0) + pref = prefs_find_preference(module, "v1_check_etsi"); + } else if (strcmp(module->name, "ip") == 0) { + /* Handle old names for IP preferences. */ + if (strcmp(dotp, "ip_summary_in_tree") == 0) + pref = prefs_find_preference(module, "summary_in_tree"); + } else if (strcmp(module->name, "iscsi") == 0) { + /* Handle old names for iSCSI preferences. */ + if (strcmp(dotp, "iscsi_port") == 0) + pref = prefs_find_preference(module, "target_port"); + } else if (strcmp(module->name, "lmp") == 0) { + /* Handle old names for LMP preferences. */ + if (strcmp(dotp, "lmp_version") == 0) + pref = prefs_find_preference(module, "version"); + } else if (strcmp(module->name, "mtp3") == 0) { + /* Handle old names for MTP3 preferences. */ + if (strcmp(dotp, "mtp3_standard") == 0) + pref = prefs_find_preference(module, "standard"); + else if (strcmp(dotp, "net_addr_format") == 0) + pref = prefs_find_preference(module, "addr_format"); + } else if (strcmp(module->name, "nlm") == 0) { + /* Handle old names for NLM preferences. */ + if (strcmp(dotp, "nlm_msg_res_matching") == 0) + pref = prefs_find_preference(module, "msg_res_matching"); + } else if (strcmp(module->name, "ppp") == 0) { + /* Handle old names for PPP preferences. */ + if (strcmp(dotp, "ppp_fcs") == 0) + pref = prefs_find_preference(module, "fcs_type"); + else if (strcmp(dotp, "ppp_vj") == 0) + pref = prefs_find_preference(module, "decompress_vj"); + } else if (strcmp(module->name, "rsvp") == 0) { + /* Handle old names for RSVP preferences. */ + if (strcmp(dotp, "rsvp_process_bundle") == 0) + pref = prefs_find_preference(module, "process_bundle"); + } else if (strcmp(module->name, "tcp") == 0) { + /* Handle old names for TCP preferences. */ + if (strcmp(dotp, "tcp_summary_in_tree") == 0) + pref = prefs_find_preference(module, "summary_in_tree"); + else if (strcmp(dotp, "tcp_analyze_sequence_numbers") == 0) + pref = prefs_find_preference(module, "analyze_sequence_numbers"); + else if (strcmp(dotp, "tcp_relative_sequence_numbers") == 0) + pref = prefs_find_preference(module, "relative_sequence_numbers"); + } else if (strcmp(module->name, "udp") == 0) { + /* Handle old names for UDP preferences. */ + if (strcmp(dotp, "udp_summary_in_tree") == 0) + pref = prefs_find_preference(module, "summary_in_tree"); + } else if (strcmp(module->name, "ndps") == 0) { + /* Handle old names for NDPS preferences. */ + if (strcmp(dotp, "desegment_ndps") == 0) + pref = prefs_find_preference(module, "desegment_tcp"); + } else if (strcmp(module->name, "http") == 0) { + /* Handle old names for HTTP preferences. */ + if (strcmp(dotp, "desegment_http_headers") == 0) + pref = prefs_find_preference(module, "desegment_headers"); + else if (strcmp(dotp, "desegment_http_body") == 0) + pref = prefs_find_preference(module, "desegment_body"); + } else if (strcmp(module->name, "smpp") == 0) { + /* Handle preferences that moved from SMPP. */ + module_t *new_module = prefs_find_module("gsm-sms-ud"); + if (new_module){ + if (strcmp(dotp, "port_number_udh_means_wsp") == 0) + pref = prefs_find_preference(new_module, "port_number_udh_means_wsp"); + else if (strcmp(dotp, "try_dissect_1st_fragment") == 0) + pref = prefs_find_preference(new_module, "try_dissect_1st_fragment"); + } + } else if (strcmp(module->name, "asn1") == 0) { + /* Handle old generic ASN.1 preferences (it's not really a + rename, as the new preferences support multiple ports, + but we might as well copy them over). */ + if (strcmp(dotp, "tcp_port") == 0) + pref = prefs_find_preference(module, "tcp_ports"); + else if (strcmp(dotp, "udp_port") == 0) + pref = prefs_find_preference(module, "udp_ports"); + else if (strcmp(dotp, "sctp_port") == 0) + pref = prefs_find_preference(module, "sctp_ports"); + } else if (strcmp(module->name, "llcgprs") == 0) { + if (strcmp(dotp, "ignore_cipher_bit") == 0) + pref = prefs_find_preference(module, "autodetect_cipher_bit"); + } else if (strcmp(module->name, "erf") == 0) { + if (strcmp(dotp, "erfeth") == 0) { + /* Handle the old "erfeth" preference; map it to the new + "ethfcs" preference, and map the values to those for + the new preference. */ + pref = prefs_find_preference(module, "ethfcs"); + if (strcmp(value, "ethfcs") == 0 || strcmp(value, "Ethernet with FCS") == 0) + value = "TRUE"; + else if (strcmp(value, "eth") == 0 || strcmp(value, "Ethernet") == 0) + value = "FALSE"; + else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) + value = "TRUE"; + } else if (strcmp(dotp, "erfatm") == 0) { + /* Handle the old "erfatm" preference; map it to the new + "aal5_type" preference, and map the values to those for + the new preference. */ + pref = prefs_find_preference(module, "aal5_type"); + if (strcmp(value, "atm") == 0 || strcmp(value, "ATM") == 0) + value = "guess"; + else if (strcmp(value, "llc") == 0 || strcmp(value, "LLC") == 0) + value = "llc"; + else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) + value = "guess"; + } else if (strcmp(dotp, "erfhdlc") == 0) { + /* Handle the old "erfhdlc" preference; map it to the new + "hdlc_type" preference, and map the values to those for + the new preference. */ + pref = prefs_find_preference(module, "hdlc_type"); + if (strcmp(value, "chdlc") == 0 || strcmp(value, "Cisco HDLC") == 0) + value = "chdlc"; + else if (strcmp(value, "ppp") == 0 || strcmp(value, "PPP serial") == 0) + value = "ppp"; + else if (strcmp(value, "fr") == 0 || strcmp(value, "Frame Relay") == 0) + value = "frelay"; + else if (strcmp(value, "mtp2") == 0 || strcmp(value, "SS7 MTP2") == 0) + value = "mtp2"; + else if (strcmp(value, "raw") == 0 || strcmp(value, "Raw data") == 0) + value = "guess"; + } + } else if (strcmp(module->name, "eth") == 0) { + /* "eth.qinq_ethertype" has been changed(restored) to "vlan.qinq.ethertype" */ + if (strcmp(dotp, "qinq_ethertype") == 0) { + module_t *new_module = prefs_find_module("vlan"); + if (new_module) { + pref = prefs_find_preference(new_module, "qinq_ethertype"); + module = new_module; + } + } + } else if (strcmp(module->name, "taps") == 0) { + /* taps preferences moved to "statistics" module */ + if (strcmp(dotp, "update_interval") == 0 || + strcmp(dotp, "rtp_player_max_visible") == 0) + pref = prefs_find_preference(stats_module, dotp); + } else if (strcmp(module->name, "packet_list") == 0) { + /* packet_list preferences moved to protocol module */ + if (strcmp(dotp, "display_hidden_proto_items") == 0) + pref = prefs_find_preference(protocols_module, dotp); + } else if (strcmp(module->name, "stream") == 0) { + /* stream preferences moved to gui color module */ + if ((strcmp(dotp, "client.fg") == 0) || + (strcmp(dotp, "client.bg") == 0) || + (strcmp(dotp, "server.fg") == 0) || + (strcmp(dotp, "server.bg") == 0)) + pref = prefs_find_preference(gui_color_module, pref_name); + } else if (strcmp(module->name, "nameres") == 0) { + if (strcmp(pref_name, "name_resolve_concurrency") == 0) { + pref = prefs_find_preference(nameres_module, pref_name); + } else if (strcmp(pref_name, "name_resolve_load_smi_modules") == 0) { + pref = prefs_find_preference(nameres_module, "load_smi_modules"); + } else if (strcmp(pref_name, "name_resolve_suppress_smi_errors") == 0) { + pref = prefs_find_preference(nameres_module, "suppress_smi_errors"); + } + } + } + if (pref == NULL) + return PREFS_SET_NO_SUCH_PREF; /* no such preference */ + + switch (pref->type) { + + case PREF_UINT: + /* XXX - give an error if it doesn't fit in a guint? */ + uval = (guint)strtoul(value, &p, pref->info.base); + if (p == value || *p != '\0') + return PREFS_SET_SYNTAX_ERR; /* number was bad */ + if (*pref->varp.uint != uval) { + module->prefs_changed = TRUE; + *pref->varp.uint = uval; + } + break; - case PREF_ENUM: - /* XXX - give an error if it doesn't match? */ - enum_val = find_val_for_string(value, pref->info.enum_info.enumvals, - *pref->varp.enump); - if (*pref->varp.enump != enum_val) { - module->prefs_changed = TRUE; - *pref->varp.enump = enum_val; - } - break; + case PREF_BOOL: + /* XXX - give an error if it's neither "true" nor "false"? */ + if (g_ascii_strcasecmp(value, "true") == 0) + bval = TRUE; + else + bval = FALSE; + if (*pref->varp.boolp != bval) { + module->prefs_changed = TRUE; + *pref->varp.boolp = bval; + } + break; - case PREF_STRING: - case PREF_FILENAME: - case PREF_DIRNAME: - if (strcmp(*pref->varp.string, value) != 0) { - module->prefs_changed = TRUE; - g_free((void *)*pref->varp.string); - *pref->varp.string = g_strdup(value); - } - break; + case PREF_ENUM: + /* XXX - give an error if it doesn't match? */ + enum_val = find_val_for_string(value, pref->info.enum_info.enumvals, + *pref->varp.enump); + if (*pref->varp.enump != enum_val) { + module->prefs_changed = TRUE; + *pref->varp.enump = enum_val; + } + break; - case PREF_RANGE: - { - range_t *newrange; + case PREF_STRING: + case PREF_FILENAME: + case PREF_DIRNAME: + if (strcmp(*pref->varp.string, value) != 0) { + module->prefs_changed = TRUE; + g_free((void *)*pref->varp.string); + *pref->varp.string = g_strdup(value); + } + break; - if (range_convert_str_work(&newrange, value, pref->info.max_value, - return_range_errors) != CVT_NO_ERROR) { - return PREFS_SET_SYNTAX_ERR; /* number was bad */ - } + case PREF_RANGE: + { + range_t *newrange; - if (!ranges_are_equal(*pref->varp.range, newrange)) { - module->prefs_changed = TRUE; - g_free(*pref->varp.range); - *pref->varp.range = newrange; - } else { - g_free (newrange); - } - break; - } + if (range_convert_str_work(&newrange, value, pref->info.max_value, + return_range_errors) != CVT_NO_ERROR) { + return PREFS_SET_SYNTAX_ERR; /* number was bad */ + } - case PREF_COLOR: - { - cval = strtoul(value, NULL, 16); - pref->varp.colorp->pixel = 0; - if ((pref->varp.colorp->red != RED_COMPONENT(cval)) || - (pref->varp.colorp->green != GREEN_COMPONENT(cval)) || - (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) { - module->prefs_changed = TRUE; - pref->varp.colorp->red = RED_COMPONENT(cval); - pref->varp.colorp->green = GREEN_COMPONENT(cval); - pref->varp.colorp->blue = BLUE_COMPONENT(cval); - } - break; - } + if (!ranges_are_equal(*pref->varp.range, newrange)) { + module->prefs_changed = TRUE; + g_free(*pref->varp.range); + *pref->varp.range = newrange; + } else { + g_free (newrange); + } + break; + } - case PREF_CUSTOM: - return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed); + case PREF_COLOR: + { + cval = strtoul(value, NULL, 16); + pref->varp.colorp->pixel = 0; + if ((pref->varp.colorp->red != RED_COMPONENT(cval)) || + (pref->varp.colorp->green != GREEN_COMPONENT(cval)) || + (pref->varp.colorp->blue != BLUE_COMPONENT(cval))) { + module->prefs_changed = TRUE; + pref->varp.colorp->red = RED_COMPONENT(cval); + pref->varp.colorp->green = GREEN_COMPONENT(cval); + pref->varp.colorp->blue = BLUE_COMPONENT(cval); + } + break; + } - case PREF_STATIC_TEXT: - case PREF_UAT: - { - break; - } + case PREF_CUSTOM: + return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed); - case PREF_OBSOLETE: - return PREFS_SET_OBSOLETE; /* no such preference any more */ + case PREF_STATIC_TEXT: + case PREF_UAT: + { + break; + } + + case PREF_OBSOLETE: + return PREFS_SET_OBSOLETE; /* no such preference any more */ + } } - } - return PREFS_SET_OK; + return PREFS_SET_OK; } typedef struct { @@ -4782,74 +4782,74 @@ write_module_prefs(module_t *module, gpointer user_data) int write_prefs(char **pf_path_return) { - char *pf_path; - FILE *pf; - write_gui_pref_arg_t write_gui_pref_info; + char *pf_path; + FILE *pf; + write_gui_pref_arg_t write_gui_pref_info; - /* Needed for "-G defaultprefs" */ - init_prefs(); + /* Needed for "-G defaultprefs" */ + init_prefs(); - /* To do: - * - Split output lines longer than MAX_VAL_LEN - * - Create a function for the preference directory check/creation - * so that duplication can be avoided with filter.c - */ + /* To do: + * - Split output lines longer than MAX_VAL_LEN + * - Create a function for the preference directory check/creation + * so that duplication can be avoided with filter.c + */ - if (pf_path_return != NULL) { - pf_path = get_persconffile_path(PF_NAME, TRUE); - if ((pf = ws_fopen(pf_path, "w")) == NULL) { - *pf_path_return = pf_path; - return errno; + if (pf_path_return != NULL) { + pf_path = get_persconffile_path(PF_NAME, TRUE); + if ((pf = ws_fopen(pf_path, "w")) == NULL) { + *pf_path_return = pf_path; + return errno; + } + } else { + pf = stdout; } - } else { - pf = stdout; - } - - fputs("# Configuration file for Wireshark " VERSION ".\n" - "#\n" - "# This file is regenerated each time preferences are saved within\n" - "# Wireshark. Making manual changes should be safe, however.\n" - "# Preferences that have been commented out have not been\n" - "# changed from their default value.\n", pf); - - /* - * For "backwards compatibility" the GUI module is written first as it's - * at the top of the file. This is followed by all modules that can't - * fit into the preferences read/write API. Finally the remaining modules - * are written in alphabetical order (including of course the protocol preferences) - */ - write_gui_pref_info.pf = pf; - write_gui_pref_info.is_gui_module = TRUE; - - write_module_prefs(gui_module, &write_gui_pref_info); - - { - struct filter_expression *fe = *(struct filter_expression **)prefs.filter_expressions; - - if (fe != NULL) - fprintf(pf, "\n####### Filter Expressions ########\n"); - - while (fe != NULL) { - if (fe->deleted == FALSE) { - fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_LABEL, fe->label); - fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_ENABLED, - fe->enabled == TRUE ? "TRUE" : "FALSE"); - fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_EXPR, fe->expression); - } - fe = fe->next; + + fputs("# Configuration file for Wireshark " VERSION ".\n" + "#\n" + "# This file is regenerated each time preferences are saved within\n" + "# Wireshark. Making manual changes should be safe, however.\n" + "# Preferences that have been commented out have not been\n" + "# changed from their default value.\n", pf); + + /* + * For "backwards compatibility" the GUI module is written first as it's + * at the top of the file. This is followed by all modules that can't + * fit into the preferences read/write API. Finally the remaining modules + * are written in alphabetical order (including of course the protocol preferences) + */ + write_gui_pref_info.pf = pf; + write_gui_pref_info.is_gui_module = TRUE; + + write_module_prefs(gui_module, &write_gui_pref_info); + + { + struct filter_expression *fe = *(struct filter_expression **)prefs.filter_expressions; + + if (fe != NULL) + fprintf(pf, "\n####### Filter Expressions ########\n"); + + while (fe != NULL) { + if (fe->deleted == FALSE) { + fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_LABEL, fe->label); + fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_ENABLED, + fe->enabled == TRUE ? "TRUE" : "FALSE"); + fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_EXPR, fe->expression); + } + fe = fe->next; + } } - } - write_gui_pref_info.is_gui_module = FALSE; - prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info); + write_gui_pref_info.is_gui_module = FALSE; + prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info); - fclose(pf); + fclose(pf); - /* XXX - catch I/O errors (e.g. "ran out of disk space") and return - an error indication, or maybe write to a new preferences file and - rename that file on top of the old one only if there are not I/O - errors. */ - return 0; + /* XXX - catch I/O errors (e.g. "ran out of disk space") and return + an error indication, or maybe write to a new preferences file and + rename that file on top of the old one only if there are not I/O + errors. */ + return 0; } /** The col_list is only partly managed by the custom preference API @@ -4859,18 +4859,18 @@ write_prefs(char **pf_path_return) static void free_col_info(GList * list) { - fmt_data *cfmt; - - while (list != NULL) { - cfmt = (fmt_data *)list->data; - - g_free(cfmt->title); - g_free(cfmt->custom_field); - g_free(cfmt); - list = g_list_remove_link(list, list); - } - g_list_free(list); - list = NULL; + fmt_data *cfmt; + + while (list != NULL) { + cfmt = (fmt_data *)list->data; + + g_free(cfmt->title); + g_free(cfmt->custom_field); + g_free(cfmt); + list = g_list_remove_link(list, list); + } + g_list_free(list); + list = NULL; } /* |