]> jfr.im git - irc/atheme/atheme-contrib-modules.git/commitdiff
ns_mxcheck & ns_mxcheck_async: fix usage of res_query(3)
authorAaron Jones <redacted>
Tue, 9 Mar 2021 08:41:44 +0000 (08:41 +0000)
committerAaron Jones <redacted>
Tue, 9 Mar 2021 08:42:20 +0000 (08:42 +0000)
Most platforms have these as enums, which are converted to int (for use
as arguments) by the compiler automatically. However, some platforms do
not have these as enums, and use macros to define their values instead.

The former platforms also have those macros to define them in terms of
the corresponding enum, so use the macros instead of the enums for
broader compatibility, defining them in terms of their enums when they
don't exist.

glibc2 and musl have enums and compatibility macros, uclibc and
uclibc-ng have enums only, and OpenBSD libc has macros only.

Fixes: 740371b4e2f48fbe8e24 ("Initial commit.")
ns_mxcheck.c
ns_mxcheck_async.c

index 7e665cf68c4bd69002c0f2689f16f553684d81cd..a6e0058b92653634ba98e077a757d8fd37e6bd2e 100644 (file)
@@ -7,6 +7,14 @@
 #include <netinet/in.h>
 #include <resolv.h>
 
+#ifndef C_ANY
+#  define C_ANY ns_c_any
+#endif
+
+#ifndef T_MX
+#  define T_MX ns_t_mx
+#endif
+
 static int
 count_mx(const char *host)
 {
@@ -16,7 +24,7 @@ count_mx(const char *host)
        if (! host || ! *host)
                return 0;
 
-       const int len = res_query(host, ns_c_any, ns_t_mx, nsbuf, sizeof nsbuf);
+       const int len = res_query(host, C_ANY, T_MX, nsbuf, sizeof nsbuf);
 
        if (len < 0)
                return 0;
index 724535c3f1b9bf17f677d37f68025e74eb5b920c..fd1953930adec59409e26a484ccf8afbbd26dc1c 100644 (file)
@@ -7,6 +7,14 @@
 #include <netinet/in.h>
 #include <resolv.h>
 
+#ifndef C_ANY
+#  define C_ANY ns_c_any
+#endif
+
+#ifndef T_MX
+#  define T_MX ns_t_mx
+#endif
+
 #define MAX_CHILDPROCS 10
 
 struct procdata
@@ -27,7 +35,7 @@ count_mx(const char *host)
        if (! host || ! *host)
                return 0;
 
-       const int len = res_query(host, ns_c_any, ns_t_mx, nsbuf, sizeof nsbuf);
+       const int len = res_query(host, C_ANY, T_MX, nsbuf, sizeof nsbuf);
 
        if (len < 0)
                return 0;