Report syntax errors in UAT prefs parsing
[metze/wireshark/wip.git] / epan / prefs.h
index 220de860ead3fed7523020530f11fe5b13c256ec..e757a25533213ae54294af800b3715216100ee8f 100644 (file)
@@ -193,6 +193,9 @@ typedef struct _e_prefs {
   layout_pane_content_e gui_layout_content_3;
   gchar       *gui_interfaces_hide_types;
   gboolean     gui_interfaces_show_hidden;
+#ifdef HAVE_PCAP_REMOTE
+  gboolean     gui_interfaces_remote_display;
+#endif
   gint         console_log_level;
   gchar       *capture_device;
   gchar       *capture_devices_linktypes;
@@ -266,33 +269,6 @@ WS_DLL_PUBLIC void prefs_reset(void);
 /** Frees memory used by proto routines. Called at program shutdown */
 void prefs_cleanup(void);
 
-/*
- * Register a module that will have preferences.
- * Specify the module under which to register it or NULL to register it
- * at the top level, the name used for the module in the preferences file,
- * the title used in the tab for it in a preferences dialog box, a
- * routine to call back when we apply the preferences, and if it should
- * use the GUI controls provided by the preferences or it has its own.
- *
- * This should not be used for dissector preferences;
- * "prefs_register_protocol()" should be used for that, so that the
- * preferences go under the "Protocols" subtree, and so that the
- * name is the protocol name specified at the "proto_register_protocol()"
- * call so that the "Protocol Properties..." menu item works.
- */
-WS_DLL_PUBLIC module_t *prefs_register_module(module_t *parent, const char *name,
-    const char *title, const char *description, void (*apply_cb)(void),
-    const gboolean use_gui);
-
-/*
- * Register a subtree that will have modules under it.
- * Specify the module under which to register it or NULL to register it
- * at the top level and the title used in the tab for it in a preferences
- * dialog box.
- */
-WS_DLL_PUBLIC module_t *prefs_register_subtree(module_t *parent, const char *title,
-    const char *description, void (*apply_cb)(void));
-
 /*
  * Register that a protocol has preferences.
  */
@@ -420,9 +396,17 @@ WS_DLL_PUBLIC pref_t *prefs_find_preference(module_t * module, const char *pref)
 WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char *name,
     const char *title, const char *description, guint base, guint *var);
 
+/*
+ * prefs_register_ callers must conform to the following:
+ *
+ * Names must be in lowercase letters only (underscore allowed).
+ * Titles and descriptions must be valid UTF-8 or NULL.
+ * Titles must be short (less than 80 characters)
+ * Titles must not contain newlines.
+ */
+
 /*
  * Register a preference with an Boolean value.
- * Note that the name must be in lowercase letters only (underscore allowed).
  */
 WS_DLL_PUBLIC void prefs_register_bool_preference(module_t *module, const char *name,
     const char *title, const char *description, gboolean *var);
@@ -447,7 +431,7 @@ WS_DLL_PUBLIC void prefs_register_string_preference(module_t *module, const char
  * file.
  */
 WS_DLL_PUBLIC void prefs_register_filename_preference(module_t *module, const char *name,
-    const char *title, const char *description, const char **var);
+    const char *title, const char *description, const char **var, gboolean for_writing);
 
 /*
  * Register a preference with a directory name (string) value.
@@ -578,18 +562,12 @@ char *prefs_pref_to_str(pref_t *pref, pref_source_t source);
 
 /* Read the preferences file, fill in "prefs", and return a pointer to it.
 
-   If we got an error (other than "it doesn't exist") trying to read
-   the global preferences file, stuff the errno into "*gpf_errno_return"
-   on an open error and into "*gpf_read_errno_return" on a read error,
-   stuff a pointer to the path of the file into "*gpf_path_return", and
-   return NULL.
+   If we got an error (other than "it doesn't exist") we report it through
+   the UI.
 
-   If we got an error (other than "it doesn't exist") trying to read
-   the user's preferences file, stuff the errno into "*pf_errno_return"
-   on an open error and into "*pf_read_errno_return" on a read error,
-   stuff a pointer to the path of the file into "*pf_path_return", and
-   return NULL. */
-WS_DLL_PUBLIC e_prefs *read_prefs(int *, int *, char **, int *, int *, char **);
+   This is called by epan_load_settings(); programs should call that
+   rather than individually calling the routines it calls. */
+extern e_prefs *read_prefs(void);
 
 /* Write out "prefs" to the user's preferences file, and return 0.
 
@@ -597,14 +575,8 @@ WS_DLL_PUBLIC e_prefs *read_prefs(int *, int *, char **, int *, int *, char **);
    into "*pf_path_return", and return the errno. */
 WS_DLL_PUBLIC int write_prefs(char **);
 
-/*
- * Given a string of the form "<pref name>:<pref value>", as might appear
- * as an argument to a "-o" option, parse it and set the preference in
- * question.  Return an indication of whether it succeeded or failed
- * in some fashion.
- *
- * XXX - should supply, for syntax errors, a detailed explanation of
- * the syntax error.
+/**
+ * Result of setting a preference.
  */
 typedef enum {
     PREFS_SET_OK,               /* succeeded */
@@ -613,7 +585,16 @@ typedef enum {
     PREFS_SET_OBSOLETE          /* preference used to exist but no longer does */
 } prefs_set_pref_e;
 
-WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg);
+/*
+ * Given a string of the form "<pref name>:<pref value>", as might appear
+ * as an argument to a "-o" option, parse it and set the preference in
+ * question.  Return an indication of whether it succeeded or failed
+ * in some fashion.
+ *
+ * For syntax errors (return value PREFS_SET_SYNTAX_ERR), details (when
+ * available) are written into "errmsg" which must be freed with g_free.
+ */
+WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg, char **errmsg);
 
 /*
  * Get or set a preference's obsolete status. These can be used to make a
@@ -623,6 +604,17 @@ WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg);
 gboolean prefs_get_preference_obsolete(pref_t *pref);
 prefs_set_pref_e prefs_set_preference_obsolete(pref_t *pref);
 
+/*
+ * Get current  preference uint value. This allows the preference structure
+ * to remain hidden from those that doesn't really need it
+ */
+WS_DLL_PUBLIC guint prefs_get_uint_value(const char *module_name, const char* pref_name);
+
+/*
+ * Get the current range preference value (maintained by pref, so it doesn't need to be freed). This allows the
+ * preference structure to remain hidden from those that doesn't really need it.
+ */
+WS_DLL_PUBLIC range_t* prefs_get_range_value(const char *module_name, const char* pref_name);
 
 /*
  * Returns TRUE if the given device is hidden
@@ -636,6 +628,11 @@ WS_DLL_PUBLIC gboolean prefs_capture_device_monitor_mode(const char *name);
 
 WS_DLL_PUBLIC gboolean prefs_capture_options_dialog_column_is_visible(const gchar *column);
 
+/*
+ * Returns TRUE if the layout pane content is enabled
+ */
+WS_DLL_PUBLIC gboolean prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */