commit:     23f0219c99ca322665c6bacc3850de06084c802e
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Sat Apr  6 12:39:42 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Mar 14 21:01:19 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23f0219c

dev-libs/libdnsres: Port to C99, musl

Inlude some musl libraries for transient dependency fix.
Port a function from glibc as a replacement for missing on musl.
Fixed some of the badness hidden in autotools, legacy types.
Fold seds.

Closes: https://bugs.gentoo.org/880341
Closes: https://bugs.gentoo.org/713630
Closes: https://bugs.gentoo.org/729906
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Closes: https://github.com/gentoo/gentoo/pull/36138
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/libdnsres/files/libdnsres-0.1a-C99.patch  | 317 +++++++++++
 .../files/libdnsres-0.1a-autotools-fix-path.patch  |  39 ++
 .../files/libdnsres-0.1a-modern-types.patch        | 619 +++++++++++++++++++++
 dev-libs/libdnsres/files/libdnsres-0.1a-musl.patch |  80 +++
 dev-libs/libdnsres/libdnsres-0.1a-r5.ebuild        |  41 ++
 5 files changed, 1096 insertions(+)

diff --git a/dev-libs/libdnsres/files/libdnsres-0.1a-C99.patch 
b/dev-libs/libdnsres/files/libdnsres-0.1a-C99.patch
new file mode 100644
index 000000000000..a2def1a58478
--- /dev/null
+++ b/dev-libs/libdnsres/files/libdnsres-0.1a-C99.patch
@@ -0,0 +1,317 @@
+Port to C99, fix glibc-specific defines, missing or bad includes
+https://bugs.gentoo.org/880341
+--- a/arc4random.c
++++ b/arc4random.c
+@@ -1,5 +1,6 @@
+ #include <sys/types.h>
+ #include <stdlib.h>
++#include <time.h>
+ 
+ #include "config.h"
+ 
+@@ -9,8 +10,8 @@
+  * application anyway.  Screw you, hippy!
+  */
+ 
+-u_int32_t
+-arc4random(void)
++u_int32_t arc4random(void);
++u_int32_t arc4random(void)
+ {
+       static int init;
+ 
+--- a/dnsres.h
++++ b/dnsres.h
+@@ -118,10 +118,7 @@
+ #define _DNSRES_H_
+ 
+ #include <sys/param.h>
+-#if (!defined(BSD)) || (BSD < 199306)
+-# include <sys/bitypes.h>
+-#endif
+-#include <sys/cdefs.h>
++#include <sys/types.h>
+ 
+ /*
+  * Type values for resources and queries
+@@ -373,7 +370,10 @@
+ };
+ #endif
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
++
+ struct addrinfo;
+ struct dnsres;
+ struct dnsres_cbstate;
+@@ -431,7 +431,10 @@
+ int           dnsres_net_addrcmp(struct sockaddr *, struct sockaddr *);
+ int           dnsres_getrrsetbyname(const char *, unsigned int, unsigned int, 
unsigned int, struct dnsres_rrsetinfo **);
+ void          dnsres_freerrset(struct dnsres_rrsetinfo *);
+-__END_DECLS
++
++#ifdef __cplusplus
++}
++#endif
+ 
+ /*
+  * Global defines and variables for resolver stub.
+--- a/resolv.h
++++ b/resolv.h
+@@ -119,12 +119,7 @@
+ #define       _RESOLV_H_
+ 
+ #include <sys/param.h>
+-#if (!defined(BSD)) || (BSD < 199306)
+-# include <sys/bitypes.h>
+-#else
+ # include <sys/types.h>
+-#endif
+-#include <sys/cdefs.h>
+ #include <sys/socket.h>
+ #include <stdio.h>
+ 
+@@ -275,7 +270,10 @@
+ struct dnsres_target;
+ struct res_search_state;
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
++
+ int                   res_hnok(const char *);
+ int                   res_ownok(const char *);
+ int                   res_mailok(const char *);
+@@ -353,7 +351,10 @@
+ void                  res_close(struct dnsres_socket *);
+ unsigned short                getshort(const unsigned char *);
+ unsigned int          getlong(const unsigned char *);
+-__END_DECLS
++
++#ifdef __cplusplus
++}
++#endif
+ 
+ #ifndef HAVE_FGETLN
+ char                  *fgetln(FILE *, size_t *);
+--- a/res_debug.c
++++ b/res_debug.c
+@@ -109,8 +109,7 @@
+ 
+ /* XXX: we should use getservbyport() instead. */
+ static const char *
+-dewks(wks)
+-      int wks;
++dewks(int wks)
+ {
+       static char nbuf[20];
+ 
+@@ -169,8 +168,7 @@
+ 
+ /* XXX: we should use getprotobynumber() instead. */
+ static const char *
+-deproto(protonum)
+-      int protonum;
++deproto(int protonum)
+ {
+       static char nbuf[20];
+ 
+@@ -390,10 +388,7 @@
+ }
+ 
+ const u_char *
+-__dnsres_p_cdnname(cp, msg, len, file)
+-      const u_char *cp, *msg;
+-      int len;
+-      FILE *file;
++__dnsres_p_cdnname(const u_char *cp, const u_char *msg, int len, FILE *file)
+ {
+       char name[DNSRES_MAXDNAME];
+       int n;
+@@ -420,11 +415,7 @@
+    length supplied).  */
+ 
+ const u_char *
+-__dnsres_p_fqnname(cp, msg, msglen, name, namelen)
+-      const u_char *cp, *msg;
+-      int msglen;
+-      char *name;
+-      int namelen;
++__dnsres_p_fqnname(const u_char *cp, const u_char *msg, int msglen, char 
*name, int namelen)
+ {
+       int n, newlen;
+ 
+@@ -444,9 +435,7 @@
+  */
+ 
+ const u_char *
+-__dnsres_p_fqname(cp, msg, file)
+-      const u_char *cp, *msg;
+-      FILE *file;
++__dnsres_p_fqname(const u_char *cp, const u_char *msg, FILE *file)
+ {
+       char name[DNSRES_MAXDNAME];
+       const u_char *n;
+@@ -918,10 +907,7 @@
+ };
+ 
+ int
+-__dnsres_sym_ston(syms, name, success)
+-      const struct res_sym *syms;
+-      char *name;
+-      int *success;
++__dnsres_sym_ston(const struct res_sym *syms, char *name, int *success)
+ {
+       for (; syms->name != 0; syms++) {
+               if (strcasecmp (name, syms->name) == 0) {
+@@ -936,10 +922,7 @@
+ }
+ 
+ const char *
+-__dnsres_sym_ntos(syms, number, success)
+-      const struct res_sym *syms;
+-      int number;
+-      int *success;
++__dnsres_sym_ntos(const struct res_sym *syms, int number, int *success)
+ {
+       static char unname[20];
+ 
+@@ -959,10 +942,7 @@
+ 
+ 
+ const char *
+-__dnsres_sym_ntop(syms, number, success)
+-      const struct res_sym *syms;
+-      int number;
+-      int *success;
++__dnsres_sym_ntop(const struct res_sym *syms, int number, int *success)
+ {
+       static char unname[20];
+ 
+@@ -983,8 +963,7 @@
+  * Return a string for the type
+  */
+ const char *
+-__dnsres_p_type(type)
+-      int type;
++__dnsres_p_type(int type)
+ {
+       return (__dnsres_sym_ntos (__dnsres_p_type_syms, type, (int *)0));
+ }
+@@ -993,8 +972,7 @@
+  * Return a mnemonic for class
+  */
+ const char *
+-__dnsres_p_class(class)
+-      int class;
++__dnsres_p_class(int class)
+ {
+       return (__dnsres_sym_ntos (__dnsres_p_class_syms, class, (int *)0));
+ }
+@@ -1003,8 +981,7 @@
+  * Return a mnemonic for an option
+  */
+ const char *
+-__dnsres_p_option(option)
+-      u_long option;
++__dnsres_p_option(u_long option)
+ {
+       static char nbuf[40];
+ 
+@@ -1033,8 +1010,7 @@
+  * Return a mnemonic for a time to live
+  */
+ const char *
+-p_time(value)
+-      u_int32_t value;
++p_time(u_int32_t value)
+ {
+       static char nbuf[40];
+       char *ebuf;
+@@ -1115,8 +1091,7 @@
+ 
+ /* takes an XeY precision/size value, returns a string representation. */
+ static const char *
+-precsize_ntoa(prec)
+-      u_int8_t prec;
++precsize_ntoa(u_int8_t prec)
+ {
+       static char retbuf[sizeof "90000000.00"];
+       unsigned long val;
+@@ -1133,8 +1108,7 @@
+ 
+ /* converts ascii size/precision X * 10**Y(cm) to 0xXY.  moves pointer. */
+ static u_int8_t
+-precsize_aton(strptr)
+-      char **strptr;
++precsize_aton(unsigned char **strptr)
+ {
+       unsigned int mval = 0, cmval = 0;
+       u_int8_t retval = 0;
+@@ -1175,9 +1149,7 @@
+ 
+ /* converts ascii lat/lon to unsigned encoded 32-bit number.  moves pointer. 
*/
+ static u_int32_t
+-latlon2ul(latlonstrptr,which)
+-      char **latlonstrptr;
+-      int *which;
++latlon2ul(unsigned char **latlonstrptr, int *which)
+ {
+       unsigned char *cp;
+       u_int32_t retval;
+@@ -1274,9 +1246,7 @@
+ /* converts a zone file representation in a string to an RDATA on-the-wire
+  * representation. */
+ int
+-loc_aton(ascii, binary)
+-      const char *ascii;
+-      u_char *binary;
++loc_aton(const char *ascii, u_char *binary)
+ {
+       const unsigned char *maxcp;
+       u_char *bcp;
+@@ -1385,19 +1355,14 @@
+ }
+ 
+ const char *
+-loc_ntoa(binary, ascii)
+-      const u_char *binary;
+-      char *ascii;
++loc_ntoa(const u_char *binary, char *ascii)
+ {
+       return loc_ntoal(binary, ascii, 255);
+ }
+ 
+ /* takes an on-the-wire LOC RR and formats it in a human readable format. */
+ static const char *
+-loc_ntoal(binary, ascii, ascii_len)
+-      const u_char *binary;
+-      char *ascii;
+-      int ascii_len;
++loc_ntoal(const u_char *binary, char *ascii, int ascii_len)
+ {
+       static char *error = "?";
+       register const u_char *cp = binary;
+@@ -1499,8 +1464,7 @@
+ 
+ /* Return the number of DNS hierarchy levels in the name. */
+ int
+-__dnsres_dn_count_labels(name)
+-      char *name;
++__dnsres_dn_count_labels(char *name)
+ {
+       int i, len, count;
+ 
+@@ -1530,8 +1494,7 @@
+  * SIG records are required to be printed like this, by the Secure DNS RFC.
+  */
+ char *
+-__dnsres_p_secstodate (secs)
+-      unsigned long secs;
++__dnsres_p_secstodate (unsigned long secs)
+ {
+       static char output[15];         /* YYYYMMDDHHMMSS and null */
+       time_t clock = secs;

diff --git a/dev-libs/libdnsres/files/libdnsres-0.1a-autotools-fix-path.patch 
b/dev-libs/libdnsres/files/libdnsres-0.1a-autotools-fix-path.patch
new file mode 100644
index 000000000000..af14727edee9
--- /dev/null
+++ b/dev-libs/libdnsres/files/libdnsres-0.1a-autotools-fix-path.patch
@@ -0,0 +1,39 @@
+To fix hardcoded library path so stuff works both on 64 and 32 bit systems
+https://bugs.gentoo.org/713630
+--- a/configure.in
++++ b/configure.in
+@@ -43,11 +43,11 @@
+         if cd $withval; then withval=`pwd`; cd $owd; fi
+         EVENTINC="-I$withval"
+         EVENTLIB="-L$withval -levent"
+-     elif test -f $withval/include/event.h -a -f $withval/lib/libevent.a; then
++     elif test -f $withval/include/event.h -a -f ${libdir}/libevent.a; then
+         owd=`pwd`
+         if cd $withval; then withval=`pwd`; cd $owd; fi
+       EVENTINC="-I$withval/include"
+-      EVENTLIB="-L$withval/lib -levent"
++      EVENTLIB="-L${libdir} -levent"
+      else
+         AC_ERROR(event.h or libevent.a not found in $withval)
+      fi
+@@ -55,7 +55,7 @@
+   esac ],
+ [ if test -f ${prefix}/include/event.h; then
+      EVENTINC="-I${prefix}/include"
+-     EVENTLIB="-L${prefix}/lib -levent"
++     EVENTLIB="-L${libdir} -levent"
+   elif test -f /usr/include/event/event.h; then
+      EVENTINC="-I/usr/include/event"
+      EVENTLIB="-levent"
+was sed -i configure.in -e 's|AM_CONFIG_HEADER|AC_CONFIG_HEADERS|g' || die
+--- a/configure.in
++++ b/configure.in
+@@ -2,7 +2,7 @@
+ AC_INIT(res_init.c)
+ 
+ AM_INIT_AUTOMAKE(libdnsres,0.1a)
+-AM_CONFIG_HEADER(config.h)
++AC_CONFIG_HEADERS([config.h])
+ AM_MAINTAINER_MODE
+ 
+ dnl Initialize prefix.

diff --git a/dev-libs/libdnsres/files/libdnsres-0.1a-modern-types.patch 
b/dev-libs/libdnsres/files/libdnsres-0.1a-modern-types.patch
new file mode 100644
index 000000000000..503602d507fb
--- /dev/null
+++ b/dev-libs/libdnsres/files/libdnsres-0.1a-modern-types.patch
@@ -0,0 +1,619 @@
+Per discussion in 
https://github.com/gentoo/gentoo/pull/36138#discussion_r1594836910
+transformed u_intX_t to uintX_t, changed relevant includes and trimmed
+really redundant checks, includes, undefines
+https://bugs.gentoo.org/880341
+--- a/acconfig.h
++++ b/acconfig.h
+@@ -1,18 +1,6 @@
+ /* Define if kqueue works correctly with pipes */
+ #undef HAVE_WORKING_KQUEUE
+ 
+-/* Define to `unsigned long long' if <sys/types.h> doesn't define.  */
+-#undef u_int64_t
+-
+-/* Define to `unsigned int' if <sys/types.h> doesn't define.  */
+-#undef u_int32_t
+-
+-/* Define to `unsigned short' if <sys/types.h> doesn't define.  */
+-#undef u_int16_t
+-
+-/* Define to `unsigned char' if <sys/types.h> doesn't define.  */
+-#undef u_int8_t
+-
+ /* Define if timeradd is defined in <sys/time.h> */
+ #undef HAVE_TIMERADD
+ #ifndef HAVE_TIMERADD
+--- a/arc4random.c
++++ b/arc4random.c
+@@ -1,4 +1,4 @@
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <time.h>
+ 
+@@ -10,8 +10,8 @@
+  * application anyway.  Screw you, hippy!
+  */
+ 
+-u_int32_t arc4random(void);
+-u_int32_t arc4random(void)
++uint32_t arc4random(void);
++uint32_t arc4random(void)
+ {
+       static int init;
+ 
+--- a/base64.c
++++ b/base64.c
+@@ -42,7 +42,6 @@
+  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+  */
+ 
+-#include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+@@ -52,6 +51,7 @@
+ #include <ctype.h>
+ #include <stdio.h>
+ 
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+--- a/config.h.in
++++ b/config.h.in
+@@ -2,18 +2,6 @@
+ /* Define if kqueue works correctly with pipes */
+ #undef HAVE_WORKING_KQUEUE
+ 
+-/* Define to `unsigned long long' if <sys/types.h> doesn't define.  */
+-#undef u_int64_t
+-
+-/* Define to `unsigned int' if <sys/types.h> doesn't define.  */
+-#undef u_int32_t
+-
+-/* Define to `unsigned short' if <sys/types.h> doesn't define.  */
+-#undef u_int16_t
+-
+-/* Define to `unsigned char' if <sys/types.h> doesn't define.  */
+-#undef u_int8_t
+-
+ /* Define if timeradd is defined in <sys/time.h> */
+ #undef HAVE_TIMERADD
+ #ifndef HAVE_TIMERADD
+@@ -250,14 +238,3 @@
+ /* Define to unsigned int if you dont have it */
+ #undef socklen_t
+ 
+-/* Define to `unsigned short' if <sys/types.h> does not define. */
+-#undef u_int16_t
+-
+-/* Define to `unsigned int' if <sys/types.h> does not define. */
+-#undef u_int32_t
+-
+-/* Define to `unsigned long long' if <sys/types.h> does not define. */
+-#undef u_int64_t
+-
+-/* Define to `unsigned char' if <sys/types.h> does not define. */
+-#undef u_int8_t
+--- a/configure.in
++++ b/configure.in
+@@ -167,10 +167,6 @@
+ 
+ AC_TYPE_PID_T
+ AC_TYPE_SIZE_T
+-AC_CHECK_TYPE(u_int64_t, unsigned long long)
+-AC_CHECK_TYPE(u_int32_t, unsigned int)
+-AC_CHECK_TYPE(u_int16_t, unsigned short)
+-AC_CHECK_TYPE(u_int8_t, unsigned char)
+ 
+ AC_MSG_CHECKING([for sin_len])
+ AC_TRY_COMPILE([
+--- a/dnsres-internal.h
++++ b/dnsres-internal.h
+@@ -101,6 +101,9 @@
+  * --Copyright--
+  */
+ 
++
++#include <stdint.h>
++
+ #ifndef _DNSRES_INTERNAL_H_
+ #define _DNSRES_INTERNAL_H_
+ 
+@@ -305,24 +308,24 @@
+  */
+ #define DNSRES_GETSHORT(s, cp) { \
+       unsigned char *t_cp = (unsigned char *)(cp); \
+-      (s) = ((u_int16_t)t_cp[0] << 8) \
+-          | ((u_int16_t)t_cp[1]) \
++      (s) = ((uint16_t)t_cp[0] << 8) \
++          | ((uint16_t)t_cp[1]) \
+           ; \
+       (cp) += INT16SZ; \
+ }
+ 
+ #define DNSRES_GETLONG(l, cp) { \
+       unsigned char *t_cp = (unsigned char *)(cp); \
+-      (l) = ((u_int32_t)t_cp[0] << 24) \
+-          | ((u_int32_t)t_cp[1] << 16) \
+-          | ((u_int32_t)t_cp[2] << 8) \
+-          | ((u_int32_t)t_cp[3]) \
++      (l) = ((uint32_t)t_cp[0] << 24) \
++          | ((uint32_t)t_cp[1] << 16) \
++          | ((uint32_t)t_cp[2] << 8) \
++          | ((uint32_t)t_cp[3]) \
+           ; \
+       (cp) += INT32SZ; \
+ }
+ 
+ #define DNSRES_PUTSHORT(s, cp) { \
+-      u_int16_t t_s = (u_int16_t)(s); \
++      uint16_t t_s = (uint16_t)(s); \
+       unsigned char *t_cp = (unsigned char *)(cp); \
+       *t_cp++ = t_s >> 8; \
+       *t_cp   = t_s; \
+@@ -330,7 +333,7 @@
+ }
+ 
+ #define DNSRES_PUTLONG(l, cp) { \
+-      u_int32_t t_l = (u_int32_t)(l); \
++      uint32_t t_l = (uint32_t)(l); \
+       unsigned char *t_cp = (unsigned char *)(cp); \
+       *t_cp++ = t_l >> 24; \
+       *t_cp++ = t_l >> 16; \
+--- a/dnsres.h
++++ b/dnsres.h
+@@ -118,7 +118,7 @@
+ #define _DNSRES_H_
+ 
+ #include <sys/param.h>
+-#include <sys/types.h>
++#include <stdint.h>
+ 
+ /*
+  * Type values for resources and queries
+@@ -482,7 +482,7 @@
+       char    unused[3];
+       struct {
+               struct in_addr  addr;
+-              u_int32_t       mask;
++              uint32_t        mask;
+       } sort_list[MAXRESOLVSORT];
+       char    lookups[MAXDNSLUS];
+ 
+--- a/getaddrinfo.c
++++ b/getaddrinfo.c
+@@ -110,7 +110,7 @@
+ #include "config.h"
+ #endif
+ 
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+@@ -221,7 +221,7 @@
+ static int get_port(struct dnsres_servent_state *,
+         struct addrinfo *, const char *, int);
+ static const struct afd *find_afd(int);
+-static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *);
++static int ip6_str2scopeid(char *, struct sockaddr_in6 *, uint32_t *);
+ 
+ static void _sethtent(struct dnsres_hostent_state *);
+ static void _endhtent(struct dnsres_hostent_state *);
+@@ -969,7 +969,7 @@
+ 
+       error = explore_numeric(state, pai, addr, servname, res, hostname);
+       if (error == 0) {
+-              u_int32_t scopeid;
++              uint32_t scopeid;
+ 
+               for (cur = *res; cur; cur = cur->ai_next) {
+                       if (cur->ai_family != AF_INET6)
+@@ -1148,10 +1148,7 @@
+ 
+ /* convert a string to a scope identifier. XXX: IPv6 specific */
+ static int
+-ip6_str2scopeid(scope, sin6, scopeid)
+-      char *scope;
+-      struct sockaddr_in6 *sin6;
+-      u_int32_t *scopeid;
++ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, uint32_t *scopeid)
+ {
+       u_long lscopeid;
+       struct in6_addr *a6 = &sin6->sin6_addr;
+@@ -1185,7 +1182,7 @@
+   trynumeric:
+       errno = 0;
+       lscopeid = strtoul(scope, &ep, 10);
+-      *scopeid = (u_int32_t)(lscopeid & 0xffffffffUL);
++      *scopeid = (uint32_t)(lscopeid & 0xffffffffUL);
+       if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid)
+               return 0;
+       else
+--- a/res_comp.c
++++ b/res_comp.c
+@@ -64,6 +64,7 @@
+ #include <stdio.h>
+ #include <ctype.h>
+ 
++#include <stdint.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <event.h>
+@@ -81,10 +82,7 @@
+  * Return size of compressed name or -1 if there was an error.
+  */
+ int
+-dn_expand(msg, eomorig, comp_dn, exp_dn, length)
+-      const u_char *msg, *eomorig, *comp_dn;
+-      char *exp_dn;
+-      int length;
++dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, 
char *exp_dn, int length)
+ {
+       const u_char *cp;
+       char *dn;
+@@ -165,10 +163,7 @@
+  * is NULL, we don't update the list.
+  */
+ int
+-dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
+-      const char *exp_dn;
+-      u_char *comp_dn, **dnptrs, **lastdnptr;
+-      int length;
++dn_comp(const char *exp_dn, u_char *comp_dn, int length, u_char **dnptrs, 
u_char **lastdnptr)
+ {
+       register u_char *cp, *dn;
+       register int c, l;
+@@ -245,8 +240,7 @@
+  * Skip over a compressed domain name. Return the size or -1.
+  */
+ int
+-__dnsres_dn_skipname(comp_dn, eom)
+-      const u_char *comp_dn, *eom;
++__dnsres_dn_skipname(const u_char *comp_dn, const u_char *eom)
+ {
+       register const u_char *cp;
+       register int n;
+@@ -289,9 +283,7 @@
+  * not the pointer to the start of the message.
+  */
+ static int
+-dn_find(exp_dn, msg, dnptrs, lastdnptr)
+-      u_char *exp_dn, *msg;
+-      u_char **dnptrs, **lastdnptr;
++dn_find(u_char *exp_dn, u_char *msg, u_char **dnptrs, u_char **lastdnptr)
+ {
+       register u_char *dn, *cp, **cpp;
+       register int n;
+@@ -389,8 +381,7 @@
+  * but must otherwise be as a host name.
+  */
+ int
+-res_ownok(dn)
+-      const char *dn;
++res_ownok(const char *dn)
+ {
+       if (asterchar(dn[0])) {
+               if (periodchar(dn[1]))
+@@ -406,8 +397,7 @@
+  * label, but the rest of the name has to look like a host name.
+  */
+ int
+-res_mailok(dn)
+-      const char *dn;
++res_mailok(const char *dn)
+ {
+       int ch, escaped = 0;
+ 
+@@ -436,8 +426,7 @@
+  * recommendations.
+  */
+ int
+-res_dnok(dn)
+-      const char *dn;
++res_dnok(const char *dn)
+ {
+       int ch;
+ 
+@@ -451,36 +440,32 @@
+  * Routines to insert/extract short/long's.
+  */
+ 
+-u_int16_t
+-__dnsres_getshort(msgp)
+-      register const u_char *msgp;
++uint16_t
++__dnsres_getshort(register const u_char *msgp)
+ {
+-      register u_int16_t u;
++      register uint16_t u;
+ 
+       DNSRES_GETSHORT(u, msgp);
+       return (u);
+ }
+ 
+-u_int32_t
+-__dnsres_getlong(msgp)
+-      register const u_char *msgp;
++uint32_t
++__dnsres_getlong(register const u_char *msgp)
+ {
+-      register u_int32_t u;
++      register uint32_t u;
+ 
+       DNSRES_GETLONG(u, msgp);
+       return (u);
+ }
+ 
+ void
+-__dnsres_putshort(register u_int16_t s, register u_char *msgp)
++__dnsres_putshort(register uint16_t s, register u_char *msgp)
+ {
+       DNSRES_PUTSHORT(s, msgp);
+ }
+ 
+ void
+-__dnsres_putlong(l, msgp)
+-      register u_int32_t l;
+-      register u_char *msgp;
++__dnsres_putlong(register uint32_t l, register u_char *msgp)
+ {
+       DNSRES_PUTLONG(l, msgp);
+ }
+--- a/res_debug.c
++++ b/res_debug.c
+@@ -73,8 +73,9 @@
+  * --Copyright--
+  */
+ 
++#include <stdint.h>
+ #include <sys/param.h>
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+@@ -457,9 +458,9 @@
+       int type, class, dlen, n, c;
+       struct in_addr inaddr;
+       const u_char *cp1, *cp2;
+-      u_int32_t tmpttl, t;
++      uint32_t tmpttl, t;
+       int lcnt;
+-      u_int16_t keyflags;
++      uint16_t keyflags;
+       char rrname[DNSRES_MAXDNAME];           /* The fqdn of this RR */
+       char base64_key[MAX_KEY_BASE64];
+ 
+@@ -1010,7 +1011,7 @@
+  * Return a mnemonic for a time to live
+  */
+ const char *
+-p_time(u_int32_t value)
++p_time(uint32_t value)
+ {
+       static char nbuf[40];
+       char *ebuf;
+@@ -1091,7 +1092,7 @@
+ 
+ /* takes an XeY precision/size value, returns a string representation. */
+ static const char *
+-precsize_ntoa(u_int8_t prec)
++precsize_ntoa(uint8_t prec)
+ {
+       static char retbuf[sizeof "90000000.00"];
+       unsigned long val;
+@@ -1107,11 +1108,11 @@
+ }
+ 
+ /* converts ascii size/precision X * 10**Y(cm) to 0xXY.  moves pointer. */
+-static u_int8_t
++static uint8_t
+ precsize_aton(unsigned char **strptr)
+ {
+       unsigned int mval = 0, cmval = 0;
+-      u_int8_t retval = 0;
++      uint8_t retval = 0;
+       unsigned char *cp;
+       int exponent;
+       int mantissa;
+@@ -1148,11 +1149,11 @@
+ }
+ 
+ /* converts ascii lat/lon to unsigned encoded 32-bit number.  moves pointer. 
*/
+-static u_int32_t
++static uint32_t
+ latlon2ul(unsigned char **latlonstrptr, int *which)
+ {
+       unsigned char *cp;
+-      u_int32_t retval;
++      uint32_t retval;
+       int deg = 0, min = 0, secs = 0, secsfrac = 0;
+ 
+       cp = *latlonstrptr;
+@@ -1252,12 +1253,12 @@
+       u_char *bcp;
+       unsigned char *cp;
+ 
+-      u_int32_t latit = 0, longit = 0, alt = 0;
+-      u_int32_t lltemp1 = 0, lltemp2 = 0;
++      uint32_t latit = 0, longit = 0, alt = 0;
++      uint32_t lltemp1 = 0, lltemp2 = 0;
+       int altmeters = 0, altfrac = 0, altsign = 1;
+-      u_int8_t hp = 0x16;     /* default = 1e6 cm = 10000.00m = 10km */
+-      u_int8_t vp = 0x13;     /* default = 1e3 cm = 10.00m */
+-      u_int8_t siz = 0x12;    /* default = 1e2 cm = 1.00m */
++      uint8_t hp = 0x16;      /* default = 1e6 cm = 10000.00m = 10km */
++      uint8_t vp = 0x13;      /* default = 1e3 cm = 10.00m */
++      uint8_t siz = 0x12;     /* default = 1e2 cm = 1.00m */
+       int which1 = 0, which2 = 0;
+ 
+       cp = (unsigned char *)ascii;
+@@ -1343,7 +1344,7 @@
+  defaults:
+ 
+       bcp = binary;
+-      *bcp++ = (u_int8_t) 0;  /* version byte */
++      *bcp++ = (uint8_t) 0;   /* version byte */
+       *bcp++ = siz;
+       *bcp++ = hp;
+       *bcp++ = vp;
+@@ -1375,8 +1376,8 @@
+       const int referencealt = 100000 * 100;
+ 
+       int32_t latval, longval, altval;
+-      u_int32_t templ;
+-      u_int8_t sizeval, hpval, vpval, versionval;
++      uint32_t templ;
++      uint8_t sizeval, hpval, vpval, versionval;
+     
+       char *sizestr, *hpstr, *vpstr;
+ 
+--- a/res_init.c
++++ b/res_init.c
+@@ -85,7 +85,7 @@
+ #include "config.h"
+ #endif
+ 
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <sys/time.h>
+@@ -137,7 +137,7 @@
+ #ifdef RESOLVSORT
+ static const char sort_mask[] = "/&";
+ #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
+-static u_int32_t net_mask(struct in_addr);
++static uint32_t net_mask(struct in_addr);
+ #endif
+ 
+ /*
+@@ -603,11 +603,10 @@
+ 
+ #ifdef RESOLVSORT
+ /* XXX - should really support CIDR which means explicit masks always. */
+-static u_int32_t
+-net_mask(in)          /* XXX - should really use system's version of this */
+-      struct in_addr in;
++static uint32_t
++net_mask(struct in_addr in)           /* XXX - should really use system's 
version of this */
+ {
+-      register u_int32_t i = ntohl(in.s_addr);
++      register uint32_t i = ntohl(in.s_addr);
+ 
+       if (IN_CLASSA(i))
+               return (htonl(IN_CLASSA_NET));
+--- a/res_random.c
++++ b/res_random.c
+@@ -54,7 +54,7 @@
+  * so that an attacker will not get sequential ids.
+  */
+ 
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <netinet/in.h>
+ #include <sys/time.h>
+ 
+@@ -72,23 +72,23 @@
+ #define RU_M  31104           /* RU_M = 2^7*3^5 - don't change */
+ 
+ #define PFAC_N 3
+-const static u_int16_t pfacts[PFAC_N] = {
++const static uint16_t pfacts[PFAC_N] = {
+       2, 
+       3,
+       2729
+ };
+ 
+-static u_int16_t ru_x;
+-static u_int16_t ru_seed, ru_seed2;
+-static u_int16_t ru_a, ru_b;
+-static u_int16_t ru_g;
+-static u_int16_t ru_counter = 0;
+-static u_int16_t ru_msb = 0;
++static uint16_t ru_x;
++static uint16_t ru_seed, ru_seed2;
++static uint16_t ru_a, ru_b;
++static uint16_t ru_g;
++static uint16_t ru_counter = 0;
++static uint16_t ru_msb = 0;
+ static long ru_reseed;
+-static u_int32_t tmp;                /* Storage for unused random */
++static uint32_t tmp;                /* Storage for unused random */
+ static struct timeval tv;
+ 
+-static u_int16_t pmod(u_int16_t, u_int16_t, u_int16_t);
++static uint16_t pmod(uint16_t, uint16_t, uint16_t);
+ static void res_initid(void);
+ 
+ /*
+@@ -96,10 +96,10 @@
+  * of 0 - (mod-1)
+  */
+ 
+-static u_int16_t
+-pmod(u_int16_t gen, u_int16_t exp, u_int16_t mod)
++static uint16_t
++pmod(uint16_t gen, uint16_t exp, uint16_t mod)
+ {
+-      u_int16_t s, t, u;
++      uint16_t s, t, u;
+ 
+       s = 1;
+       t = gen;
+@@ -125,7 +125,7 @@
+ static void 
+ res_initid()
+ {
+-      u_int16_t j, i;
++      uint16_t j, i;
+       int noprime = 1;
+ 
+       tmp = arc4random();
+@@ -208,7 +208,7 @@
+ main(int argc, char **argv)
+ {
+       int i, n;
+-      u_int16_t wert;
++      uint16_t wert;
+ 
+       res_initid();
+ 
+--- a/resolv.h
++++ b/resolv.h
+@@ -119,7 +119,8 @@
+ #define       _RESOLV_H_
+ 
+ #include <sys/param.h>
+-# include <sys/types.h>
++#include <sys/types.h>
++#include <stdint.h>
+ #include <sys/socket.h>
+ #include <stdio.h>
+ 
+@@ -293,10 +294,10 @@
+ void                  fp_nquery(struct dnsres *,
+                           const unsigned char *msg, int len, FILE *file);
+ const char *          hostalias(struct dnsres *, const char *);
+-void                  putlong(u_int32_t, unsigned char *);
+-void                  putshort(u_int16_t, unsigned char *);
++void                  putlong(uint32_t, unsigned char *);
++void                  putshort(uint16_t, unsigned char *);
+ const char *          p_class(int);
+-const char *          p_time(u_int32_t);
++const char *          p_time(uint32_t);
+ const char *          p_type(int);
+ void                  p_query(struct dnsres *,
+                           const unsigned char *);
+@@ -365,7 +366,7 @@
+ #endif
+ 
+ #ifndef ARC4RANDOM
+-u_int32_t             arc4random(void);
++uint32_t              arc4random(void);
+ #endif
+ 
+ #endif /* !_RESOLV_H_ */

diff --git a/dev-libs/libdnsres/files/libdnsres-0.1a-musl.patch 
b/dev-libs/libdnsres/files/libdnsres-0.1a-musl.patch
new file mode 100644
index 000000000000..2a1ed0b78679
--- /dev/null
+++ b/dev-libs/libdnsres/files/libdnsres-0.1a-musl.patch
@@ -0,0 +1,80 @@
+Add a function that's missing from musl, use autotools machinery to
+use it when needed
+https://bugs.gentoo.org/880341
+--- a/configure.in
++++ b/configure.in
+@@ -191,6 +191,8 @@
+       [Define to unsigned int if you dont have it])]
+ )
+ 
++AC_REPLACE_FUNCS([inet_nsap_ntoa])
++
+ AC_MSG_CHECKING([whether our compiler supports __func__])
+ AC_TRY_COMPILE([],
+  [void foo() { const char *cp = __func__; }],
+--- a/inet_nsap_ntoa.c
++++ b/inet_nsap_ntoa.c
+@@ -0,0 +1,50 @@
++/* taken from glibc source */
++/*
++ * Copyright (c) 1996-1999 by Internet Software Consortium.
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
++ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 
WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
++ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
++ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
++ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
++ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
++ * SOFTWARE.
++ */
++
++#if !defined(HAVE_INET_NSAP_NTOA)
++#include <sys/types.h>
++
++char *
++inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
++      int nib;
++      int i;
++      static char tmpbuf[255*2 + 128];
++      char *start;
++
++      if (ascii)
++              start = ascii;
++      else {
++              ascii = tmpbuf;
++              start = tmpbuf;
++      }
++
++      if (binlen > 255)
++              binlen = 255;
++
++      for (i = 0; i < binlen; i++) {
++              nib = *binary >> 4;
++              *ascii++ = nib + (nib < 10 ? '0' : '7');
++              nib = *binary++ & 0x0f;
++              *ascii++ = nib + (nib < 10 ? '0' : '7');
++              if (((i % 2) == 0 && (i + 1) < binlen))
++                      *ascii++ = '.';
++      }
++      *ascii = '\0';
++      return (start);
++}
++#endif
+--- a/res_debug.c
++++ b/res_debug.c
+@@ -94,6 +94,10 @@
+ #include "dnsres-internal.h"
+ #include "resolv.h"
+ 
++#if !defined(HAVE_INET_NSAP_NTOA)
++char *inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii);
++#endif
++
+ /* Signatures */
+                                         /* Size of a mod or exp in bits */
+ #define MIN_MD5RSA_KEY_PART_BITS         512

diff --git a/dev-libs/libdnsres/libdnsres-0.1a-r5.ebuild 
b/dev-libs/libdnsres/libdnsres-0.1a-r5.ebuild
new file mode 100644
index 000000000000..8b4bc01ab207
--- /dev/null
+++ b/dev-libs/libdnsres/libdnsres-0.1a-r5.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools edo
+
+DESCRIPTION="A non-blocking DNS resolver library"
+HOMEPAGE="https://www.monkey.org/~provos/libdnsres/";
+SRC_URI="https://www.monkey.org/~provos/${P}.tar.gz";
+
+LICENSE="BSD-4"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~sparc ~x86"
+IUSE="static-libs"
+
+DEPEND="dev-libs/libevent"
+RDEPEND="${DEPEND}"
+
+DOCS=( README )
+PATCHES=(
+       "${FILESDIR}"/${P}-autotools.patch
+       "${FILESDIR}"/${P}-autotools-fix-path.patch
+       "${FILESDIR}"/${P}-C99.patch
+       "${FILESDIR}"/${P}-modern-types.patch
+       "${FILESDIR}"/${P}-musl.patch
+)
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_configure() {
+       econf $(use_enable static-libs static)
+}
+
+src_install() {
+       default
+       find "${ED}" -name '*.la' -delete || die
+}

Reply via email to