Use pref_t rather than struct preference.

Consistently use it (except in some of the C++ code, where, for some
unknown reason, some headers, such as epan/prefs.h, are not being
included).

While we're at it, don't call prefs_find_module("extcap") twice, just
call it once and save the result.
This commit is contained in:
Guy Harris 2024-11-22 11:50:12 -08:00
parent b0001fab8e
commit 1101efa898
7 changed files with 13 additions and 12 deletions

View File

@ -1152,7 +1152,7 @@ module_find_pref_cb(const void *key _U_, void *value, void *data)
/* Tries to find a preference, setting containing_module to the (sub)module
* holding this preference. */
static struct preference *
static pref_t *
prefs_find_preference_with_submodule(module_t *module, const char *name,
module_t **containing_module)
{
@ -1184,10 +1184,10 @@ prefs_find_preference_with_submodule(module_t *module, const char *name,
if (containing_module)
*containing_module = arg.submodule ? arg.submodule : module;
return (struct preference *) list_entry->data;
return (pref_t *) list_entry->data;
}
struct preference *
pref_t *
prefs_find_preference(module_t *module, const char *name)
{
return prefs_find_preference_with_submodule(module, name, NULL);

View File

@ -829,10 +829,10 @@ void extcap_free_if_configuration(GList *list, bool free_args)
g_list_free(list);
}
struct preference *
pref_t *
extcap_pref_for_argument(const char *ifname, struct _extcap_arg *arg)
{
struct preference *pref = NULL;
pref_t *pref = NULL;
extcap_ensure_all_interfaces_loaded();
@ -840,14 +840,15 @@ extcap_pref_for_argument(const char *ifname, struct _extcap_arg *arg)
GRegex *regex_ifname = g_regex_new("(?![a-zA-Z0-9_]).", G_REGEX_RAW, (GRegexMatchFlags) 0, NULL);
if (regex_name && regex_ifname)
{
if (prefs_find_module("extcap"))
module_t *extcap_module = prefs_find_module("extcap");
if (extcap_module)
{
char *pref_name = g_regex_replace(regex_name, arg->call, strlen(arg->call), 0, "", (GRegexMatchFlags) 0, NULL);
char *ifname_underscore = g_regex_replace(regex_ifname, ifname, strlen(ifname), 0, "_", (GRegexMatchFlags) 0, NULL);
char *ifname_lowercase = g_ascii_strdown(ifname_underscore, -1);
char *pref_ifname = g_strconcat(ifname_lowercase, ".", pref_name, NULL);
pref = prefs_find_preference(prefs_find_module("extcap"), pref_ifname);
pref = prefs_find_preference(extcap_module, pref_ifname);
g_free(pref_name);
g_free(ifname_underscore);

View File

@ -248,7 +248,7 @@ extcap_request_stop(capture_session *cap_session);
* @param arg The command line argument to check.
* @return The associated preference on success, NULL on failure.
*/
struct preference *
pref_t *
extcap_pref_for_argument(const char *ifname, struct _extcap_arg * arg);
/**

View File

@ -936,7 +936,7 @@ int ExtcapArgument::argNr() const
QString ExtcapArgument::prefKey(const QString & device_name)
{
struct preference * pref = NULL;
pref_t * pref = NULL;
if (_argument == 0 || ! _argument->save)
return QString();

View File

@ -38,7 +38,7 @@ protected:
signals:
void showProtocolPreferences(const QString module_name);
void editProtocolPreference(struct preference *pref, struct pref_module *module);
void editProtocolPreference(pref_t *pref, struct pref_module *module);
private slots:
void on_buttonBox_helpRequested();

View File

@ -179,7 +179,7 @@ signals:
void editColumn(int column);
void packetListScrolled(bool at_end);
void showProtocolPreferences(const QString module_name);
void editProtocolPreference(struct preference *pref, struct pref_module *module);
void editProtocolPreference(pref_t *pref, struct pref_module *module);
void framesSelected(QList<int>);
void fieldSelected(FieldInformation *);

View File

@ -76,7 +76,7 @@ signals:
void goToPacket(int);
void relatedFrame(int, ft_framenum_type_t);
void showProtocolPreferences(const QString module_name);
void editProtocolPreference(struct preference *pref, struct pref_module *module);
void editProtocolPreference(pref_t *pref, struct pref_module *module);
public slots: