Fossil SCM

Get this branch working with mingw and on Mac

drh 2018-07-12 13:09 UTC smtp-win
Commit f55c0fdc30ffde683a33918c619b65499a1e359fb2b1faf3849dfab265f024a0
2 files changed +9 -5 +1 -2
+9 -5
--- src/smtp.c
+++ src/smtp.c
@@ -19,18 +19,21 @@
1919
** to RFC 5321.
2020
*/
2121
#include "config.h"
2222
#include "smtp.h"
2323
#include <assert.h>
24
-#if !defined(_WIN32)
24
+#if defined(__linux__)
2525
# include <sys/types.h>
2626
# include <netinet/in.h>
2727
# include <arpa/nameser.h>
2828
# include <resolv.h>
29
-#else
29
+# define FOSSIL_UNIX_STYLE_DNS 1
30
+#endif
31
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
3032
# include <windows.h>
3133
# include <windns.h>
34
+# define FOSSIL_WINDOWS_STYLE_DNS 1
3235
#endif
3336
3437
3538
/*
3639
** Find the hostname for receiving email for the domain given
@@ -40,11 +43,11 @@
4043
**
4144
** The returned string is obtained from fossil_malloc()
4245
** and should be released using fossil_free().
4346
*/
4447
char *smtp_mx_host(const char *zDomain){
45
-#if !defined(_WIN32)
48
+#if defined(FOSSIL_UNIX_STYLE_DNS)
4649
int nDns; /* Length of the DNS reply */
4750
int rc; /* Return code from various APIs */
4851
int i; /* Loop counter */
4952
int iBestPriority = 9999999; /* Best priority */
5053
int nRec; /* Number of answers */
@@ -79,11 +82,12 @@
7982
ns_name_uncompress(aDns, aDns+nDns, pBest+2,
8083
zHostname, sizeof(zHostname));
8184
return fossil_strdup(zHostname);
8285
}
8386
return 0;
84
-#else /* !defined(_WIN32) */
87
+#endif /* defined(FOSSIL_UNIX_SYTLE_DNS) */
88
+#if defined(FOSSIL_WINDOWS_STYLE_DNS)
8589
DNS_STATUS status; /* Return status */
8690
PDNS_RECORDA pDnsRecord, p; /* Pointer to DNS_RECORD structure */
8791
int iBestPriority = 9999999; /* Best priority */
8892
char *pBest = 0; /* RDATA for the best answer */
8993
@@ -106,11 +110,11 @@
106110
if( pBest ){
107111
pBest = fossil_strdup(pBest);
108112
}
109113
DnsRecordListFree(pDnsRecord, DnsFreeRecordListDeep);
110114
return pBest;
111
-#endif /* !defined(_WIN32) */
115
+#endif /* defined(FOSSIL_WINDOWS_STYLE_DNS) */
112116
}
113117
114118
/*
115119
** COMMAND: test-find-mx
116120
**
117121
--- src/smtp.c
+++ src/smtp.c
@@ -19,18 +19,21 @@
19 ** to RFC 5321.
20 */
21 #include "config.h"
22 #include "smtp.h"
23 #include <assert.h>
24 #if !defined(_WIN32)
25 # include <sys/types.h>
26 # include <netinet/in.h>
27 # include <arpa/nameser.h>
28 # include <resolv.h>
29 #else
 
 
30 # include <windows.h>
31 # include <windns.h>
 
32 #endif
33
34
35 /*
36 ** Find the hostname for receiving email for the domain given
@@ -40,11 +43,11 @@
40 **
41 ** The returned string is obtained from fossil_malloc()
42 ** and should be released using fossil_free().
43 */
44 char *smtp_mx_host(const char *zDomain){
45 #if !defined(_WIN32)
46 int nDns; /* Length of the DNS reply */
47 int rc; /* Return code from various APIs */
48 int i; /* Loop counter */
49 int iBestPriority = 9999999; /* Best priority */
50 int nRec; /* Number of answers */
@@ -79,11 +82,12 @@
79 ns_name_uncompress(aDns, aDns+nDns, pBest+2,
80 zHostname, sizeof(zHostname));
81 return fossil_strdup(zHostname);
82 }
83 return 0;
84 #else /* !defined(_WIN32) */
 
85 DNS_STATUS status; /* Return status */
86 PDNS_RECORDA pDnsRecord, p; /* Pointer to DNS_RECORD structure */
87 int iBestPriority = 9999999; /* Best priority */
88 char *pBest = 0; /* RDATA for the best answer */
89
@@ -106,11 +110,11 @@
106 if( pBest ){
107 pBest = fossil_strdup(pBest);
108 }
109 DnsRecordListFree(pDnsRecord, DnsFreeRecordListDeep);
110 return pBest;
111 #endif /* !defined(_WIN32) */
112 }
113
114 /*
115 ** COMMAND: test-find-mx
116 **
117
--- src/smtp.c
+++ src/smtp.c
@@ -19,18 +19,21 @@
19 ** to RFC 5321.
20 */
21 #include "config.h"
22 #include "smtp.h"
23 #include <assert.h>
24 #if defined(__linux__)
25 # include <sys/types.h>
26 # include <netinet/in.h>
27 # include <arpa/nameser.h>
28 # include <resolv.h>
29 # define FOSSIL_UNIX_STYLE_DNS 1
30 #endif
31 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
32 # include <windows.h>
33 # include <windns.h>
34 # define FOSSIL_WINDOWS_STYLE_DNS 1
35 #endif
36
37
38 /*
39 ** Find the hostname for receiving email for the domain given
@@ -40,11 +43,11 @@
43 **
44 ** The returned string is obtained from fossil_malloc()
45 ** and should be released using fossil_free().
46 */
47 char *smtp_mx_host(const char *zDomain){
48 #if defined(FOSSIL_UNIX_STYLE_DNS)
49 int nDns; /* Length of the DNS reply */
50 int rc; /* Return code from various APIs */
51 int i; /* Loop counter */
52 int iBestPriority = 9999999; /* Best priority */
53 int nRec; /* Number of answers */
@@ -79,11 +82,12 @@
82 ns_name_uncompress(aDns, aDns+nDns, pBest+2,
83 zHostname, sizeof(zHostname));
84 return fossil_strdup(zHostname);
85 }
86 return 0;
87 #endif /* defined(FOSSIL_UNIX_SYTLE_DNS) */
88 #if defined(FOSSIL_WINDOWS_STYLE_DNS)
89 DNS_STATUS status; /* Return status */
90 PDNS_RECORDA pDnsRecord, p; /* Pointer to DNS_RECORD structure */
91 int iBestPriority = 9999999; /* Best priority */
92 char *pBest = 0; /* RDATA for the best answer */
93
@@ -106,11 +110,11 @@
110 if( pBest ){
111 pBest = fossil_strdup(pBest);
112 }
113 DnsRecordListFree(pDnsRecord, DnsFreeRecordListDeep);
114 return pBest;
115 #endif /* defined(FOSSIL_WINDOWS_STYLE_DNS) */
116 }
117
118 /*
119 ** COMMAND: test-find-mx
120 **
121
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -410,11 +410,11 @@
410410
LIB += -lkernel32 -lws2_32
411411
endif
412412
413413
#### Library required for DNS lookups.
414414
#
415
-LIB += ldnsapi
415
+LIB += -ldnsapi
416416
417417
#### Tcl shell for use in running the fossil test suite. This is only
418418
# used for testing.
419419
#
420420
TCLSH = tclsh
@@ -2420,6 +2420,5 @@
24202420
$(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
24212421
$(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
24222422
24232423
$(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
24242424
$(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
2425
-
24262425
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -410,11 +410,11 @@
410 LIB += -lkernel32 -lws2_32
411 endif
412
413 #### Library required for DNS lookups.
414 #
415 LIB += ldnsapi
416
417 #### Tcl shell for use in running the fossil test suite. This is only
418 # used for testing.
419 #
420 TCLSH = tclsh
@@ -2420,6 +2420,5 @@
2420 $(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
2421 $(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
2422
2423 $(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
2424 $(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
2425
2426
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -410,11 +410,11 @@
410 LIB += -lkernel32 -lws2_32
411 endif
412
413 #### Library required for DNS lookups.
414 #
415 LIB += -ldnsapi
416
417 #### Tcl shell for use in running the fossil test suite. This is only
418 # used for testing.
419 #
420 TCLSH = tclsh
@@ -2420,6 +2420,5 @@
2420 $(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
2421 $(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
2422
2423 $(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
2424 $(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
 
2425

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button