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" {.
This commit is contained in:
Guy Harris 2021-03-17 14:59:55 -07:00
parent 9ca121bcf8
commit 4584b9d1d3
1 changed files with 18 additions and 18 deletions

View File

@ -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__ */