From: Guy Harris Date: Fri, 4 Sep 2015 23:06:22 +0000 (-0700) Subject: Declare pcap_wsockinit() in pcap-int.h. X-Git-Tag: libpcap-1.8.0-bp~235 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/f0e7a509e50755e7122219690117f3e15bb102db Declare pcap_wsockinit() in pcap-int.h. We probably shouldn't be exporting something called wsockinit() at all, as it's too likely to collide with routines in code that calls us. I don't know whether Wine implemented it in order to run Windows programs that call it, or if there actually *are* such programs, but we'll leave it around for now. Call pcap_wsockinit() in pcap_compile(), and don't bother declaring it; rely on it being declared in pcap-int.h, so we run less of a risk of the declaration and definition getting out of sync (not that we're likely to change its signature, but...). In the definitions of it and wsockinit(), explicitly note that they take no arguments. --- diff --git a/gencode.c b/gencode.c index 872f70d9..95357b56 100644 --- a/gencode.c +++ b/gencode.c @@ -441,11 +441,10 @@ pcap_compile(pcap_t *p, struct bpf_program *program, * a separate -lpthread, we might not want to do that. */ #ifdef _WIN32 - extern int wsockinit (void); static int done = 0; if (!done) - wsockinit(); + pcap_wsockinit(); done = 1; EnterCriticalSection(&g_PcapCompileCriticalSection); #endif diff --git a/pcap-int.h b/pcap-int.h index d73f902c..6e54141a 100644 --- a/pcap-int.h +++ b/pcap-int.h @@ -468,6 +468,7 @@ void pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *); #ifdef _WIN32 void pcap_win32_err_to_str(DWORD, char *); +void pcap_wsockinit (void); #endif int install_bpf_program(pcap_t *, struct bpf_program *); diff --git a/pcap-win32.c b/pcap-win32.c index 5445d696..bc285aeb 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -99,7 +99,7 @@ BOOL WINAPI DllMain( /* Start winsock */ int -wsockinit() +wsockinit(void) { WORD wVersionRequested; WSADATA wsaData; @@ -120,7 +120,8 @@ wsockinit() return err; } -int pcap_wsockinit() +int +pcap_wsockinit(void) { return wsockinit(); }