aboutsummaryrefslogtreecommitdiffstats
path: root/ui/preference_utils.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-11-28 16:03:11 -0800
committerMichael Mann <mmann78@netscape.net>2017-11-30 00:14:16 +0000
commit3ed5b4fb67edc6829ece7adf542f44e9a75185af (patch)
tree24ad6cc6525ca7af094d8c6d04dccf26d272227d /ui/preference_utils.c
parentb59dc97dfef3bcce71cd393f4d2493e7ba1a8f82 (diff)
Reformat some top-level ui files.
Make sure each ui/*.[ch] file uses identical (4-space) indentation. Remove ui/.editorconfig. Fix up other formatting where needed. SPDX-abbreviate the license blurb in the files we modify. Change-Id: I5faa1c1eae9a4b6220422ad8e4ba7a341c7deb1f Reviewed-on: https://code.wireshark.org/review/24632 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/preference_utils.c')
-rw-r--r--ui/preference_utils.c162
1 files changed, 75 insertions, 87 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c
index 95be0c692c..b532060e94 100644
--- a/ui/preference_utils.c
+++ b/ui/preference_utils.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -46,8 +34,8 @@ void
prefs_to_capture_opts(void)
{
#ifdef HAVE_LIBPCAP
- /* Set promiscuous mode from the preferences setting. */
- /* the same applies to other preferences settings as well. */
+ /* Set promiscuous mode from the preferences setting. */
+ /* the same applies to other preferences settings as well. */
global_capture_opts.default_options.promisc_mode = prefs.capture_prom_mode;
global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
global_capture_opts.show_info = prefs.capture_show_info; /* GTK+ only */
@@ -59,106 +47,106 @@ prefs_to_capture_opts(void)
void
prefs_main_write(void)
{
- int err;
- char *pf_dir_path;
- char *pf_path;
-
- /* Create the directory that holds personal configuration files, if
- necessary. */
- if (create_persconffile_dir(&pf_dir_path) == -1) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
- g_strerror(errno));
- g_free(pf_dir_path);
- } else {
- /* Write the preferencs out. */
- err = write_prefs(&pf_path);
- if (err != 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ int err;
+ char *pf_dir_path;
+ char *pf_path;
+
+ /* Create the directory that holds personal configuration files, if
+ necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
+ g_strerror(errno));
+ g_free(pf_dir_path);
+ } else {
+ /* Write the preferencs out. */
+ err = write_prefs(&pf_path);
+ if (err != 0) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open preferences file\n\"%s\": %s.", pf_path,
g_strerror(err));
- g_free(pf_path);
+ g_free(pf_path);
+ }
}
- }
}
static gboolean
prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
- module_t * module = NULL;
- pref_t * pref = NULL;
- gboolean pref_changed = TRUE;
+ module_t * module = NULL;
+ pref_t * pref = NULL;
+ gboolean pref_changed = TRUE;
- if ( ! prefs_is_registered_protocol(module_name))
- return FALSE;
+ if ( ! prefs_is_registered_protocol(module_name))
+ return FALSE;
- module = prefs_find_module(module_name);
- if ( ! module )
- return FALSE;
+ module = prefs_find_module(module_name);
+ if ( ! module )
+ return FALSE;
- pref = prefs_find_preference(module, pref_name);
+ pref = prefs_find_preference(module, pref_name);
- if (!pref)
- return FALSE;
+ if (!pref)
+ return FALSE;
- if (prefs_get_type(pref) == PREF_STRING )
- {
- pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
- if ( ! pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
- pref_changed = prefs_set_string_value(pref, pref_value, pref_current);
- }
+ if (prefs_get_type(pref) == PREF_STRING )
+ {
+ pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
+ if ( ! pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
+ pref_changed = prefs_set_string_value(pref, pref_value, pref_current);
+ }
- return pref_changed;
+ return pref_changed;
}
gboolean
prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
{
- if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
- {
- prefs_main_write();
- prefs_apply_all();
- prefs_to_capture_opts();
- return TRUE;
- }
+ if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
+ {
+ prefs_main_write();
+ prefs_apply_all();
+ prefs_to_capture_opts();
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
gboolean
prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
{
- gboolean pref_changed = FALSE;
- GList * keys = NULL;
+ gboolean pref_changed = FALSE;
+ GList * keys = NULL;
- if ( ! prefs_is_registered_protocol(module))
- return pref_changed;
-
- keys = g_hash_table_get_keys(pref_values);
- if ( ! keys )
- return pref_changed;
+ if ( ! prefs_is_registered_protocol(module))
+ return pref_changed;
- while ( keys != NULL )
- {
- gchar * pref_name = (gchar *)keys->data;
- gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);
+ keys = g_hash_table_get_keys(pref_values);
+ if ( ! keys )
+ return pref_changed;
- if ( pref_name && pref_value )
+ while ( keys != NULL )
{
- if ( prefs_store_ext_helper(module, pref_name, pref_value) )
- pref_changed = TRUE;
+ gchar * pref_name = (gchar *)keys->data;
+ gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);
+
+ if ( pref_name && pref_value )
+ {
+ if ( prefs_store_ext_helper(module, pref_name, pref_value) )
+ pref_changed = TRUE;
+ }
+ keys = g_list_next(keys);
}
- keys = g_list_next(keys);
- }
- if ( pref_changed )
- {
- prefs_main_write();
- prefs_apply_all();
- prefs_to_capture_opts();
- }
+ if ( pref_changed )
+ {
+ prefs_main_write();
+ prefs_apply_all();
+ prefs_to_capture_opts();
+ }
- return TRUE;
+ return TRUE;
}
gint
@@ -223,14 +211,14 @@ column_prefs_remove_nth(gint col)
}
/*
- * Editor modelines
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/