Fossil SCM
Merged branch libbind-ns-alternative: I haven't found any platform where this won't build. It doesn't enable libbind or use libresolv better on every platform where it might possibly work, but at the very least it avoids build errors everywhere I've tried it.
Commit
71c298f3ea42391638a6c96b9ab1c62bf9754881fefebed79f96fd71efa0e448
Parent
a937c69e1d46e38…
2 files changed
+19
-1
+16
-5
M
auto.def
+19
-1
| --- auto.def | ||
| +++ auto.def | ||
| @@ -513,11 +513,29 @@ | ||
| 513 | 513 | # Last resort, may be Windows |
| 514 | 514 | if {[is_mingw]} { |
| 515 | 515 | define-append LIBS -lwsock32 |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | -cc-check-function-in-lib ns_name_uncompress resolv | |
| 518 | + | |
| 519 | +# The SMTP module requires special libraries and headers for MX DNS | |
| 520 | +# record lookups and such. | |
| 521 | +cc-check-includes arpa/nameser.h | |
| 522 | +cc-include-needs bind/resolv.h netinet/in.h | |
| 523 | +cc-check-includes bind/resolv.h | |
| 524 | +cc-check-includes resolv.h | |
| 525 | +if { !(([cc-check-function-in-lib dn_expand resolv] || | |
| 526 | + [cc-check-function-in-lib ns_name_uncompress {bind resolv}] || | |
| 527 | + [cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) && | |
| 528 | + ([cc-check-function-in-lib ns_parserr {bind resolv}] || | |
| 529 | + [cc-check-function-in-lib __ns_parserr {bind resolv}]) && | |
| 530 | + ([cc-check-function-in-lib res_query {bind resolv}] || | |
| 531 | + [cc-check-function-in-lib __res_query {bind resolv}]))} { | |
| 532 | + msg-result "WARNING: SMTP feature will not be able to look up local MX." | |
| 533 | +} | |
| 534 | +cc-check-function-in-lib res_9_ns_initparse resolv | |
| 535 | + | |
| 536 | +# Other nonstandard function checks | |
| 519 | 537 | cc-check-functions utime |
| 520 | 538 | cc-check-functions usleep |
| 521 | 539 | cc-check-functions strchrnul |
| 522 | 540 | cc-check-functions pledge |
| 523 | 541 | cc-check-functions backtrace |
| 524 | 542 |
| --- auto.def | |
| +++ auto.def | |
| @@ -513,11 +513,29 @@ | |
| 513 | # Last resort, may be Windows |
| 514 | if {[is_mingw]} { |
| 515 | define-append LIBS -lwsock32 |
| 516 | } |
| 517 | } |
| 518 | cc-check-function-in-lib ns_name_uncompress resolv |
| 519 | cc-check-functions utime |
| 520 | cc-check-functions usleep |
| 521 | cc-check-functions strchrnul |
| 522 | cc-check-functions pledge |
| 523 | cc-check-functions backtrace |
| 524 |
| --- auto.def | |
| +++ auto.def | |
| @@ -513,11 +513,29 @@ | |
| 513 | # Last resort, may be Windows |
| 514 | if {[is_mingw]} { |
| 515 | define-append LIBS -lwsock32 |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | # The SMTP module requires special libraries and headers for MX DNS |
| 520 | # record lookups and such. |
| 521 | cc-check-includes arpa/nameser.h |
| 522 | cc-include-needs bind/resolv.h netinet/in.h |
| 523 | cc-check-includes bind/resolv.h |
| 524 | cc-check-includes resolv.h |
| 525 | if { !(([cc-check-function-in-lib dn_expand resolv] || |
| 526 | [cc-check-function-in-lib ns_name_uncompress {bind resolv}] || |
| 527 | [cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) && |
| 528 | ([cc-check-function-in-lib ns_parserr {bind resolv}] || |
| 529 | [cc-check-function-in-lib __ns_parserr {bind resolv}]) && |
| 530 | ([cc-check-function-in-lib res_query {bind resolv}] || |
| 531 | [cc-check-function-in-lib __res_query {bind resolv}]))} { |
| 532 | msg-result "WARNING: SMTP feature will not be able to look up local MX." |
| 533 | } |
| 534 | cc-check-function-in-lib res_9_ns_initparse resolv |
| 535 | |
| 536 | # Other nonstandard function checks |
| 537 | cc-check-functions utime |
| 538 | cc-check-functions usleep |
| 539 | cc-check-functions strchrnul |
| 540 | cc-check-functions pledge |
| 541 | cc-check-functions backtrace |
| 542 |
+16
-5
| --- src/smtp.c | ||
| +++ src/smtp.c | ||
| @@ -19,15 +19,27 @@ | ||
| 19 | 19 | ** to RFC 5321. |
| 20 | 20 | */ |
| 21 | 21 | #include "config.h" |
| 22 | 22 | #include "smtp.h" |
| 23 | 23 | #include <assert.h> |
| 24 | -#if defined(__linux__) && !defined(FOSSIL_OMIT_DNS) | |
| 24 | +#if (HAVE_DN_EXPAND || HAVE___NS_NAME_UNCOMPRESS || HAVE_NS_NAME_UNCOMPRESS) && \ | |
| 25 | + (HAVE_NS_PARSERR || HAVE___NS_PARSERR) && !defined(FOSSIL_OMIT_DNS) | |
| 25 | 26 | # include <sys/types.h> |
| 26 | 27 | # include <netinet/in.h> |
| 27 | -# include <arpa/nameser.h> | |
| 28 | -# include <resolv.h> | |
| 28 | +# if defined(HAVE_BIND_RESOLV_H) | |
| 29 | +# include <bind/resolv.h> | |
| 30 | +# include <bind/arpa/nameser_compat.h> | |
| 31 | +# else | |
| 32 | +# include <arpa/nameser.h> | |
| 33 | +# include <resolv.h> | |
| 34 | +# endif | |
| 35 | +# if defined(HAVENS_NAME_UNCOMPRESS) && !defined(dn_expand) | |
| 36 | +# define dn_expand ns_name_uncompress | |
| 37 | +# endif | |
| 38 | +# if defined(HAVE__NS_NAME_UNCOMPRESS) && !defined(dn_expand) | |
| 39 | +# define dn_expand __ns_name_uncompress | |
| 40 | +# endif | |
| 29 | 41 | # define FOSSIL_UNIX_STYLE_DNS 1 |
| 30 | 42 | #endif |
| 31 | 43 | #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__) |
| 32 | 44 | # include <windows.h> |
| 33 | 45 | # include <windns.h> |
| @@ -77,12 +89,11 @@ | ||
| 77 | 89 | iBestPriority = priority; |
| 78 | 90 | } |
| 79 | 91 | } |
| 80 | 92 | } |
| 81 | 93 | if( pBest ){ |
| 82 | - ns_name_uncompress(aDns, aDns+nDns, pBest+2, | |
| 83 | - zHostname, sizeof(zHostname)); | |
| 94 | + dn_expand(aDns, aDns+nDns, pBest+2, zHostname, sizeof(zHostname)); | |
| 84 | 95 | return fossil_strdup(zHostname); |
| 85 | 96 | } |
| 86 | 97 | return 0; |
| 87 | 98 | #elif defined(FOSSIL_WINDOWS_STYLE_DNS) |
| 88 | 99 | DNS_STATUS status; /* Return status */ |
| 89 | 100 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -19,15 +19,27 @@ | |
| 19 | ** to RFC 5321. |
| 20 | */ |
| 21 | #include "config.h" |
| 22 | #include "smtp.h" |
| 23 | #include <assert.h> |
| 24 | #if defined(__linux__) && !defined(FOSSIL_OMIT_DNS) |
| 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> |
| @@ -77,12 +89,11 @@ | |
| 77 | iBestPriority = priority; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | if( pBest ){ |
| 82 | ns_name_uncompress(aDns, aDns+nDns, pBest+2, |
| 83 | zHostname, sizeof(zHostname)); |
| 84 | return fossil_strdup(zHostname); |
| 85 | } |
| 86 | return 0; |
| 87 | #elif defined(FOSSIL_WINDOWS_STYLE_DNS) |
| 88 | DNS_STATUS status; /* Return status */ |
| 89 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -19,15 +19,27 @@ | |
| 19 | ** to RFC 5321. |
| 20 | */ |
| 21 | #include "config.h" |
| 22 | #include "smtp.h" |
| 23 | #include <assert.h> |
| 24 | #if (HAVE_DN_EXPAND || HAVE___NS_NAME_UNCOMPRESS || HAVE_NS_NAME_UNCOMPRESS) && \ |
| 25 | (HAVE_NS_PARSERR || HAVE___NS_PARSERR) && !defined(FOSSIL_OMIT_DNS) |
| 26 | # include <sys/types.h> |
| 27 | # include <netinet/in.h> |
| 28 | # if defined(HAVE_BIND_RESOLV_H) |
| 29 | # include <bind/resolv.h> |
| 30 | # include <bind/arpa/nameser_compat.h> |
| 31 | # else |
| 32 | # include <arpa/nameser.h> |
| 33 | # include <resolv.h> |
| 34 | # endif |
| 35 | # if defined(HAVENS_NAME_UNCOMPRESS) && !defined(dn_expand) |
| 36 | # define dn_expand ns_name_uncompress |
| 37 | # endif |
| 38 | # if defined(HAVE__NS_NAME_UNCOMPRESS) && !defined(dn_expand) |
| 39 | # define dn_expand __ns_name_uncompress |
| 40 | # endif |
| 41 | # define FOSSIL_UNIX_STYLE_DNS 1 |
| 42 | #endif |
| 43 | #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__) |
| 44 | # include <windows.h> |
| 45 | # include <windns.h> |
| @@ -77,12 +89,11 @@ | |
| 89 | iBestPriority = priority; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | if( pBest ){ |
| 94 | dn_expand(aDns, aDns+nDns, pBest+2, zHostname, sizeof(zHostname)); |
| 95 | return fossil_strdup(zHostname); |
| 96 | } |
| 97 | return 0; |
| 98 | #elif defined(FOSSIL_WINDOWS_STYLE_DNS) |
| 99 | DNS_STATUS status; /* Return status */ |
| 100 |