diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-01-05 22:45:26 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-01-05 22:45:26 +0000 |
commit | d18149374f8dfbac120b56745edd9d5bdc1809aa (patch) | |
tree | 6fa1933042aaf7efdaf7545bffd11ab7f4f265fa | |
parent | 0cc8a3b3ea86b505a7498203a52b4f09eb7d3321 (diff) | |
download | wireshark-d18149374f8dfbac120b56745edd9d5bdc1809aa.tar.gz |
Map the old MGCP preference names to the new ones (including a special
hack to handle the two copies of "mgcp.{tcp,udp}.port" as best we can).
svn path=/trunk/; revision=2832
-rw-r--r-- | prefs.c | 85 |
1 files changed, 80 insertions, 5 deletions
@@ -1,7 +1,7 @@ /* prefs.c * Routines for handling preferences * - * $Id: prefs.c,v 1.46 2001/01/03 07:53:44 guy Exp $ + * $Id: prefs.c,v 1.47 2001/01/05 22:45:26 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -73,6 +73,15 @@ static void free_col_info(e_prefs *); static gboolean init_prefs = TRUE; static gchar *pf_path = NULL; +/* + * XXX - variables to allow us to attempt to interpret the first + * "mgcp.{tcp,udp}.port" in a preferences file as + * "mgcp.{tcp,udp}.gateway_port" and the second as + * "mgcp.{tcp,udp}.callagent_port". + */ +static int mgcp_tcp_port_count; +static int mgcp_udp_port_count; + e_prefs prefs; gchar *gui_ptree_line_style_text[] = @@ -655,6 +664,13 @@ read_prefs_file(const char *pf_path, FILE *pf) gboolean got_val = FALSE; gint var_len = 0, val_len = 0, fline = 1, pline = 1; + /* + * Start out the counters of "mgcp.{tcp,udp}.port" entries we've + * seen. + */ + mgcp_tcp_port_count = 0; + mgcp_udp_port_count = 0; + while ((got_c = getc(pf)) != EOF) { if (got_c == '\n') { state = START; @@ -771,6 +787,16 @@ prefs_set_pref(char *prefarg) u_char *p, *colonp; int ret; + /* + * Set the counters of "mgcp.{tcp,udp}.port" entries we've + * seen to values that keep us from trying to interpret tham + * as "mgcp.{tcp,udp}.gateway_port" or "mgcp.{tcp,udp}.callagent_port", + * as, from the command line, we have no way of guessing which + * the user had in mind. + */ + mgcp_tcp_port_count = -1; + mgcp_udp_port_count = -1; + colonp = strchr(prefarg, ':'); if (colonp == NULL) return PREFS_SET_SYNTAX_ERR; @@ -971,6 +997,55 @@ set_pref(gchar *pref_name, gchar *value) return PREFS_SET_NO_SUCH_PREF; /* no such module */ dotp++; /* skip past separator to preference name */ pref = find_preference(module, dotp); + + /* + * 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 Ethereal; 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 (pref == NULL && strncmp(pref_name, "mgcp.", 5) == 0) { + if (strcmp(dotp, "display raw text toggle") == 0) + pref = find_preference(module, "display_raw_text"); + else if (strcmp(dotp, "display dissect tree") == 0) + pref = 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 = find_preference(module, "tcp.gateway_port"); + } else if (mgcp_tcp_port_count == 2) { + /* It's the second one */ + pref = 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 = find_preference(module, "udp.gateway_port"); + } else if (mgcp_udp_port_count == 2) { + /* It's the second one */ + pref = find_preference(module, "udp.callagent_port"); + } + /* Otherwise it's from the command line, and we don't bother + mapping it. */ + } + } if (pref == NULL) return PREFS_SET_NO_SUCH_PREF; /* no such preference */ @@ -993,8 +1068,8 @@ set_pref(gchar *pref_name, gchar *value) else bval = FALSE; if (*pref->varp.bool != bval) { - module->prefs_changed = TRUE; - *pref->varp.bool = bval; + module->prefs_changed = TRUE; + *pref->varp.bool = bval; } break; @@ -1003,8 +1078,8 @@ set_pref(gchar *pref_name, gchar *value) enum_val = find_val_for_string(value, pref->info.enum_info.enumvals, 1); if (*pref->varp.enump != enum_val) { - module->prefs_changed = TRUE; - *pref->varp.enump = enum_val; + module->prefs_changed = TRUE; + *pref->varp.enump = enum_val; } break; |