]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
glibc getnet*_r()
authorMark Andrews <marka@isc.org>
Mon, 16 Jul 2001 08:05:20 +0000 (08:05 +0000)
committerMark Andrews <marka@isc.org>
Mon, 16 Jul 2001 08:05:20 +0000 (08:05 +0000)
lib/bind/configure.in
lib/bind/include/netdb.h
lib/bind/irs/getnetent_r.c
lib/bind/port_before.h.in

index a329cbcf1152b840925cf45a55d4e65d84a58003..8607cb9c93ef098cfd871e7820fe6553c33d5519 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.70 $)
+AC_REVISION($Revision: 1.71 $)
 
 AC_INIT(resolv/herror.c)
 AC_PREREQ(2.13)
@@ -1414,8 +1414,25 @@ NET_R_BAD="#define NET_R_BAD NULL"
 NET_R_COPY="#define NET_R_COPY buf, buflen"
 NET_R_COPY_ARGS="#define NET_R_COPY_ARGS NET_R_ARGS"
 NET_R_OK="#define NET_R_OK nptr"
+NET_R_SETANSWER="#undef NET_R_SETANSWER"
 NET_R_RETURN="#define NET_R_RETURN struct netent *"
 ],
+AC_TRY_COMPILE(
+[#include <netdb.h>
+int getnetbyaddr_r (unsigned long int, int, struct netent *,
+                    char *, size_t, struct netent **, int *);
+],
+[return (0)],
+[
+NET_R_ARGS="#define NET_R_ARGS char *buf, size_t buflen, struct netent **answerp, int *h_errnop"
+NET_R_BAD="#define NET_R_BAD ERANGE"
+NET_R_COPY="#define NET_R_COPY buf, buflen"
+NET_R_COPY_ARGS="#define NET_R_COPY_ARGS char *buf, size_t buflen"
+NET_R_OK="#define NET_R_OK 0"
+NET_R_SETANSWER="#define NET_R_SETANSWER 1"
+NET_R_RETURN="#define NET_R_RETURN int"
+],
+)
 )
 ,
 NET_R_ARGS="#define NET_R_ARGS char *buf, int buflen"
@@ -1423,6 +1440,7 @@ NET_R_BAD="#define NET_R_BAD NULL"
 NET_R_COPY="#define NET_R_COPY buf, buflen"
 NET_R_COPY_ARGS="#define NET_R_COPY_ARGS NET_R_ARGS"
 NET_R_OK="#define NET_R_OK nptr"
+NET_R_SETANSWER="#undef NET_R_SETANSWER"
 NET_R_RETURN="#define NET_R_RETURN struct netent *"
 )
 AC_SUBST(NET_R_ARGS)
@@ -1430,6 +1448,7 @@ AC_SUBST(NET_R_BAD)
 AC_SUBST(NET_R_COPY)
 AC_SUBST(NET_R_COPY_ARGS)
 AC_SUBST(NET_R_OK)
+AC_SUBST(NET_R_SETANSWER)
 AC_SUBST(NET_R_RETURN)
 
 AC_CHECK_FUNC(setnetent_r,
index 3915f69c548a99543474432dcd90882ebf96e1a4..fafd2b640d8c5e2afc57c242bc76f96dbbf54af4 100644 (file)
@@ -86,7 +86,7 @@
 
 /*
  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
- *     $Id: netdb.h,v 1.7 2001/07/16 05:23:28 marka Exp $
+ *     $Id: netdb.h,v 1.8 2001/07/16 08:05:19 marka Exp $
  */
 
 #ifndef _NETDB_H_
@@ -454,11 +454,19 @@ struct hostent    *gethostent_r __P((struct hostent *, char *, int, int *));
 void           sethostent_r __P((int));
 void           endhostent_r __P((void));
 
+#ifdef __GLIBC__
+int getnetbyname_r __P((const char *, struct netent *,
+                       char *, size_t, struct netent **, int*));
+int getnetbyaddr_r __P((long, int, struct netent *,
+                       char *, size_t, struct netent **, int*));
+int getnetent_r __P((struct netent *, char *, size_t, struct netent **, int*));
+#else
 struct netent  *getnetbyname_r __P((const char *, struct netent *,
                                        char *, int));
 struct netent  *getnetbyaddr_r __P((long, int, struct netent *,
                                        char *, int));
 struct netent  *getnetent_r __P((struct netent *, char *, int));
+#endif
 void           setnetent_r __P((int));
 void           endnetent_r __P((void));
 
index 859c1958eae0f0bbdc8fce2d9334e026989f83af..3d953d14e5a9ec218a309a526bc2fab2d59f401c 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: getnetent_r.c,v 1.2 2001/07/15 23:29:45 marka Exp $";
+static const char rcsid[] = "$Id: getnetent_r.c,v 1.3 2001/07/16 08:05:20 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <port_before.h>
@@ -40,11 +40,22 @@ copy_netent(struct netent *, struct netent *, NET_R_COPY_ARGS);
 NET_R_RETURN
 getnetbyname_r(const char *name,  struct netent *nptr, NET_R_ARGS) {
        struct netent *ne = getnetbyname(name);
+#ifdef NET_R_SETANSWER
+       int n = 0;
 
+       if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = ne;
+       if (ne == NULL)
+               *h_errnop = h_errno;
+       return (n);
+#else
        if (ne == NULL)
                return (NET_R_BAD);
 
        return (copy_netent(ne, nptr, NET_R_COPY));
+#endif
 }
 
 #ifndef GETNETBYADDR_ADDR_T
@@ -53,11 +64,23 @@ getnetbyname_r(const char *name,  struct netent *nptr, NET_R_ARGS) {
 NET_R_RETURN
 getnetbyaddr_r(GETNETBYADDR_ADDR_T addr, int type, struct netent *nptr, NET_R_ARGS) {
        struct netent *ne = getnetbyaddr(addr, type);
+#ifdef NET_R_SETANSWER
+       int n = 0;
+
+       if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = ne;
+       if (ne == NULL)
+               *h_errnop = h_errno;
+       return (n);
+#else
 
        if (ne == NULL)
                return (NET_R_BAD);
 
        return (copy_netent(ne, nptr, NET_R_COPY));
+#endif
 }
 
 /*
@@ -69,11 +92,23 @@ getnetbyaddr_r(GETNETBYADDR_ADDR_T addr, int type, struct netent *nptr, NET_R_AR
 NET_R_RETURN
 getnetent_r(struct netent *nptr, NET_R_ARGS) {
        struct netent *ne = getnetent();
+#ifdef NET_R_SETANSWER
+       int n = 0;
+
+       if (ne == NULL || (n = copy_netent(ne, nptr, NET_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = ne;
+       if (ne == NULL)
+               *h_errnop = h_errno;
+       return (n);
+#else
 
        if (ne == NULL)
                return (NET_R_BAD);
 
        return (copy_netent(ne, nptr, NET_R_COPY));
+#endif
 }
 
 NET_R_SET_RETURN
@@ -118,7 +153,7 @@ copy_netent(struct netent *ne, struct netent *nptr, NET_R_COPY_ARGS) {
        len += strlen(ne->n_name) + 1;
        len += numptr * sizeof(char*);
        
-       if (len > buflen) {
+       if (len > (int)buflen) {
                errno = ERANGE;
                return (NET_R_BAD);
        }
index 6ebaed0487a81cf3859ebee8e69cdadb2c20880c..7d89ceb0e4b8c7a507072be671485a3034607cdd 100644 (file)
@@ -35,6 +35,7 @@ struct timezone;        /* silence warning */
 @NET_R_OK@
 @NET_R_RETURN@
 @NET_R_SET_RESULT@
+@NET_R_SETANSWER@
 @NET_R_SET_RETURN@
 
 @GROUP_R_RETURN@