Skip to content

Commit

Permalink
Use pref_t rather than struct preference.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guyharris committed Nov 22, 2024
1 parent b0001fa commit 1101efa
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions epan/prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions extcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,25 +829,26 @@ 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();

GRegex *regex_name = g_regex_new("[-]+", G_REGEX_RAW, (GRegexMatchFlags) 0, NULL);
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);
Expand Down
2 changes: 1 addition & 1 deletion extcap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
2 changes: 1 addition & 1 deletion ui/qt/extcap_argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ui/qt/packet_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PacketDialog : public WiresharkDialog

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();
Expand Down
2 changes: 1 addition & 1 deletion ui/qt/packet_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected slots:
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 *);
Expand Down
2 changes: 1 addition & 1 deletion ui/qt/proto_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProtoTree : public QTreeView
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:

Expand Down

0 comments on commit 1101efa

Please sign in to comment.