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

index 8607cb9c93ef098cfd871e7820fe6553c33d5519..e94a47668c9171e5627a0b1e20819f8df8a39602 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.71 $)
+AC_REVISION($Revision: 1.72 $)
 
 AC_INIT(resolv/herror.c)
 AC_PREREQ(2.13)
@@ -1792,9 +1792,30 @@ PROTO_R_BAD="#define PROTO_R_BAD NULL"
 PROTO_R_COPY="#define PROTO_R_COPY buf, buflen"
 PROTO_R_COPY_ARGS="#define PROTO_R_COPY_ARGS PROTO_R_ARGS"
 PROTO_R_OK="#define PROTO_R_OK pptr"
+PROTO_R_SETANSWER="#undef PROTO_R_SETANSWER"
 PROTO_R_RETURN="#define PROTO_R_RETURN struct protoent *"
 ]
 ,
+AC_TRY_COMPILE(
+[
+#include <netdb.h>
+int getprotoent_r (struct protoent *, char *, size_t, struct protoent **);
+
+]
+,
+[return (0);]
+,
+[
+PROTO_R_ARGS="#define PROTO_R_ARGS char *buf, size_t buflen, struct protoent **answerp"
+PROTO_R_BAD="#define PROTO_R_BAD ERANGE"
+PROTO_R_COPY="#define PROTO_R_COPY buf, buflen"
+PROTO_R_COPY_ARGS="#define PROTO_R_COPY_ARGS char *buf, size_t buflen"
+PROTO_R_OK="#define PROTO_R_OK 0"
+PROTO_R_SETANSWER="#define PROTO_R_SETANSWER 1"
+PROTO_R_RETURN="#define PROTO_R_RETURN int"
+]
+,
+)
 )
 ,
 PROTO_R_ARGS="#define PROTO_R_ARGS char *buf, int buflen"
@@ -1802,6 +1823,7 @@ PROTO_R_BAD="#define PROTO_R_BAD NULL"
 PROTO_R_COPY="#define PROTO_R_COPY buf, buflen"
 PROTO_R_COPY_ARGS="#define PROTO_R_COPY_ARGS PROTO_R_ARGS"
 PROTO_R_OK="#define PROTO_R_OK pptr"
+PROTO_R_SETANSWER="#undef PROTO_R_SETANSWER"
 PROTO_R_RETURN="#define PROTO_R_RETURN struct protoent *"
 )
 AC_SUBST(PROTO_R_ARGS)
@@ -1809,6 +1831,7 @@ AC_SUBST(PROTO_R_BAD)
 AC_SUBST(PROTO_R_COPY)
 AC_SUBST(PROTO_R_COPY_ARGS)
 AC_SUBST(PROTO_R_OK)
+AC_SUBST(PROTO_R_SETANSWER)
 AC_SUBST(PROTO_R_RETURN)
 
 AC_CHECK_FUNC(endprotoent_r,
index fafd2b640d8c5e2afc57c242bc76f96dbbf54af4..c8e5858edc9243bf22a3b051dd431b3345444c9b 100644 (file)
@@ -86,7 +86,7 @@
 
 /*
  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
- *     $Id: netdb.h,v 1.8 2001/07/16 08:05:19 marka Exp $
+ *     $Id: netdb.h,v 1.9 2001/07/16 08:37:44 marka Exp $
  */
 
 #ifndef _NETDB_H_
@@ -470,11 +470,19 @@ struct netent     *getnetent_r __P((struct netent *, char *, int));
 void           setnetent_r __P((int));
 void           endnetent_r __P((void));
 
+#ifdef __GLIBC__
+int getprotobyname_r __P((const char *, struct protoent *, char *,
+                         size_t, struct protoent **));
+int getprotobynumber_r __P((int, struct protoent *, char *, size_t,
+                           struct protoent **));
+int getprotoent_r __P((struct protoent *, char *, size_t, struct protoent **));
+#else
 struct protoent        *getprotobyname_r __P((const char *,
                                struct protoent *, char *, int));
 struct protoent        *getprotobynumber_r __P((int,
                                struct protoent *, char *, int));
 struct protoent        *getprotoent_r __P((struct protoent *, char *, int));
+#endif
 void           setprotoent_r __P((int));
 void           endprotoent_r __P((void));
 
index b6d80eb2d1a7f2120408b8b52ccc6367b085e794..78b93f80075b1927a0cd494d0179c0c95ac6689e 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: getprotoent_r.c,v 1.2 2001/07/15 23:29:46 marka Exp $";
+static const char rcsid[] = "$Id: getprotoent_r.c,v 1.3 2001/07/16 08:37:45 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <port_before.h>
@@ -39,21 +39,41 @@ copy_protoent(struct protoent *, struct protoent *, PROTO_R_COPY_ARGS);
 PROTO_R_RETURN
 getprotobyname_r(const char *name, struct protoent *pptr, PROTO_R_ARGS) {
        struct protoent *pe = getprotobyname(name);
+#ifdef PROTO_R_SETANSWER
+       int n = 0;
 
+       if (pe == NULL || (n = copy_protoent(pe, pptr, PROTO_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = pptr;
+       
+       return (n);
+#else
        if (pe == NULL)
                return (PROTO_R_BAD);
 
        return (copy_protoent(pe, pptr, PROTO_R_COPY));
+#endif
 }
 
 PROTO_R_RETURN
 getprotobynumber_r(int proto, struct protoent *pptr, PROTO_R_ARGS) {
        struct protoent *pe = getprotobynumber(proto);
+#ifdef PROTO_R_SETANSWER
+       int n = 0;
 
+       if (pe == NULL || (n = copy_protoent(pe, pptr, PROTO_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = pptr;
+       
+       return (n);
+#else
        if (pe == NULL)
                return (PROTO_R_BAD);
 
        return (copy_protoent(pe, pptr, PROTO_R_COPY));
+#endif
 }
 
 /*
@@ -65,11 +85,21 @@ getprotobynumber_r(int proto, struct protoent *pptr, PROTO_R_ARGS) {
 PROTO_R_RETURN
 getprotoent_r(struct protoent *pptr, PROTO_R_ARGS) {
        struct protoent *pe = getprotoent();
+#ifdef PROTO_R_SETANSWER
+       int n = 0;
 
+       if (pe == NULL || (n = copy_protoent(pe, pptr, PROTO_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = pptr;
+       
+       return (n);
+#else
        if (pe == NULL)
                return (PROTO_R_BAD);
 
        return (copy_protoent(pe, pptr, PROTO_R_COPY));
+#endif
 }
 
 PROTO_R_SET_RETURN
@@ -114,7 +144,7 @@ copy_protoent(struct protoent *pe, struct protoent *pptr, PROTO_R_COPY_ARGS) {
        len += strlen(pe->p_name) + 1;
        len += numptr * sizeof(char*);
        
-       if (len > buflen) {
+       if (len > (int)buflen) {
                errno = ERANGE;
                return (PROTO_R_BAD);
        }
index 7d89ceb0e4b8c7a507072be671485a3034607cdd..538d5d52d801ae3bf55014d6c58af6fe62c5cb9b 100644 (file)
@@ -84,6 +84,7 @@ struct timezone;        /* silence warning */
 @PROTO_R_END_RETURN@
 @PROTO_R_ENT_ARGS@
 @PROTO_R_OK@
+@PROTO_R_SETANSWER@
 @PROTO_R_RETURN@
 @PROTO_R_SET_RESULT@
 @PROTO_R_SET_RETURN@