diff options
author | Guy Harris <gharris@sonic.net> | 2021-03-17 21:59:55 +0000 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-03-17 23:15:57 +0000 |
commit | fcefe78a672f806b7f24288d1e134d40cfc2c05c (patch) | |
tree | ae39197a5aa584bf18a1dd36214a34448a8d43a9 /caputils | |
parent | 2974b301503b208e79f1c97e2fe6fca4b1b82e21 (diff) |
caputils: get rid of the extern "C" { idiom.
Instead, declare each function with EXTERN_C, #defined as extern "C" in
C++ and just extern in C.
This avoids all the thrashing to try to keep headers outside extern "C"
{ by the simple expedient of not *having* extern "C" {.
(cherry picked from commit 4584b9d1d396920468e0b8a71f1681c7cfda382b)
Diffstat (limited to 'caputils')
-rw-r--r-- | caputils/capture-pcap-util.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/caputils/capture-pcap-util.h b/caputils/capture-pcap-util.h index b6ceb8c8d3..a82deb0b09 100644 --- a/caputils/capture-pcap-util.h +++ b/caputils/capture-pcap-util.h @@ -12,7 +12,9 @@ #define __CAPTURE_PCAP_UTIL_H__ #ifdef __cplusplus -extern "C" { +#define EXTERN_C extern "C" +#else /* __cplusplus */ +#define EXTERN_C extern #endif /* __cplusplus */ #ifdef HAVE_LIBPCAP @@ -30,19 +32,21 @@ extern "C" { */ #define MIN_PACKET_SIZE 1 /* minimum amount of packet data we can read */ -GList *get_interface_list(int *err, char **err_str); +EXTERN_C GList *get_interface_list(int *err, char **err_str); #ifdef HAVE_PCAP_REMOTE -GList *get_remote_interface_list(const char *hostname, const char *port, - int auth_type, const char *username, - const char *passwd, int *err, char **err_str); +EXTERN_C GList *get_remote_interface_list(const char *hostname, + const char *port, int auth_type, + const char *username, + const char *passwd, + int *err, char **err_str); #endif /* HAVE_PCAP_REMOTE */ -const char *linktype_val_to_name(int dlt); -int linktype_name_to_val(const char *linktype); +EXTERN_C const char *linktype_val_to_name(int dlt); +EXTERN_C int linktype_name_to_val(const char *linktype); -int get_pcap_datalink(pcap_t *pch, const char *devicename); +EXTERN_C int get_pcap_datalink(pcap_t *pch, const char *devicename); -gboolean set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name, +EXTERN_C gboolean set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name, char *errmsg, size_t errmsg_len, char *secondary_errmsg, size_t secondary_errmsg_len); @@ -51,7 +55,7 @@ gboolean set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name, * Return TRUE if the pcap_t in question is set up for high-precision * time stamps, FALSE otherwise. */ -gboolean have_high_resolution_timestamp(pcap_t *pcap_h); +EXTERN_C gboolean have_high_resolution_timestamp(pcap_t *pcap_h); #endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */ /* @@ -63,16 +67,16 @@ typedef enum { CAP_DEVICE_OPEN_ERR_NOT_PERMISSIONS, /* Error is known not to be a permissions error */ CAP_DEVICE_OPEN_ERR_GENERIC /* Error is not known to be one or the other */ } cap_device_open_err; -extern if_capabilities_t *get_if_capabilities(interface_options *interface_opts, +EXTERN_C if_capabilities_t *get_if_capabilities(interface_options *interface_opts, cap_device_open_err *err, char **err_str); -extern pcap_t *open_capture_device(capture_options *capture_opts, +EXTERN_C pcap_t *open_capture_device(capture_options *capture_opts, interface_options *interface_opts, int timeout, cap_device_open_err *open_err, char (*open_err_str)[PCAP_ERRBUF_SIZE]); #endif /* HAVE_LIBPCAP */ -extern void get_compiled_caplibs_version(GString *str); +EXTERN_C void get_compiled_caplibs_version(GString *str); /* * Append to a GString an indication of the version of capture libraries @@ -81,10 +85,6 @@ extern void get_compiled_caplibs_version(GString *str); * WinPcap/Npcap wasn't loaded, or nothing, if we weren't compiled with * libpcap/WinPcap/Npcap. */ -extern void get_runtime_caplibs_version(GString *str); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ +EXTERN_C void get_runtime_caplibs_version(GString *str); #endif /* __CAPTURE_PCAP_UTIL_H__ */ |