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

index e94a47668c9171e5627a0b1e20819f8df8a39602..5f4244a2aa0825ab68ebe607c09f170382980c8e 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.72 $)
+AC_REVISION($Revision: 1.73 $)
 
 AC_INIT(resolv/herror.c)
 AC_PREREQ(2.13)
@@ -1950,21 +1950,23 @@ SERV_R_BAD="#define SERV_R_BAD NULL"
 SERV_R_COPY="#define SERV_R_COPY buf, buflen"
 SERV_R_COPY_ARGS="#define SERV_R_COPY_ARGS SERV_R_ARGS"
 SERV_R_OK="#define SERV_R_OK sptr"
+SERV_R_SETANSWER="#undef SERV_R_SETANSWER"
 SERV_R_RETURN="#define SERV_R_RETURN struct servent *"
 ]
 ,
 AC_TRY_COMPILE([
 #include <netdb.h>
-struct servent *
-getservent_r __P ((struct servent *, char *, size_t, struct servent **));
+int
+getservent_r (struct servent *, char *, size_t, struct servent **);
 ],[return (0);],
 [
-SERV_R_ARGS="#define SERV_R_ARGS char *buf, int buflen, struct servent **answer"
-SERV_R_BAD="#define SERV_R_BAD (-1)"
+SERV_R_ARGS="#define SERV_R_ARGS char *buf, size_t buflen, struct servent **answerp"
+SERV_R_BAD="#define SERV_R_BAD ERANGE"
 SERV_R_COPY="#define SERV_R_COPY buf, buflen"
-SERV_R_COPY_ARGS="#define SERV_R_COPY_ARGS SERV_R_ARGS"
+SERV_R_COPY_ARGS="#define SERV_R_COPY_ARGS char *buf, size_t buflen"
 SERV_R_OK="#define SERV_R_OK (0)"
-SERV_R_RETURN="#define SERV_R_RETURN 1"
+SERV_R_SETANSWER="#define SERV_R_SETANSWER 1"
+SERV_R_RETURN="#define SERV_R_RETURN int"
 ]
 ,
 )
@@ -1975,6 +1977,7 @@ SERV_R_BAD="#define SERV_R_BAD NULL"
 SERV_R_COPY="#define SERV_R_COPY buf, buflen"
 SERV_R_COPY_ARGS="#define SERV_R_COPY_ARGS SERV_R_ARGS"
 SERV_R_OK="#define SERV_R_OK sptr"
+SERV_R_SETANSWER="#undef SERV_R_SETANSWER"
 SERV_R_RETURN="#define SERV_R_RETURN struct servent *"
 )
 AC_SUBST(SERV_R_ARGS)
@@ -1982,6 +1985,7 @@ AC_SUBST(SERV_R_BAD)
 AC_SUBST(SERV_R_COPY)
 AC_SUBST(SERV_R_COPY_ARGS)
 AC_SUBST(SERV_R_OK)
+AC_SUBST(SERV_R_SETANSWER)
 AC_SUBST(SERV_R_RETURN)
 
 AC_CHECK_FUNC(endservent_r,
index c8e5858edc9243bf22a3b051dd431b3345444c9b..996873e007b330123948927641d43bc2ac367a8d 100644 (file)
@@ -86,7 +86,7 @@
 
 /*
  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
- *     $Id: netdb.h,v 1.9 2001/07/16 08:37:44 marka Exp $
+ *     $Id: netdb.h,v 1.10 2001/07/16 14:43:39 marka Exp $
  */
 
 #ifndef _NETDB_H_
@@ -486,11 +486,19 @@ struct protoent   *getprotoent_r __P((struct protoent *, char *, int));
 void           setprotoent_r __P((int));
 void           endprotoent_r __P((void));
 
+#ifdef __GLIBC__
+int getservbyname_r __P((const char *name, const char *,
+                        struct servent *, char *, size_t, struct servent **));
+int getservbyport_r __P((int port, const char *,
+                        struct servent *, char *, size_t, struct servent **));
+int getservent_r __P((struct servent *, char *, size_t, struct servent **));
+#else
 struct servent *getservbyname_r __P((const char *name, const char *,
                                        struct servent *, char *, int));
 struct servent *getservbyport_r __P((int port, const char *,
                                        struct servent *, char *, int));
 struct servent *getservent_r __P((struct servent *, char *, int));
+#endif
 void           setservent_r __P((int));
 void           endservent_r __P((void));
 
index 89ac50593ef12ae73ec9c57eee2121192d0f4f80..e9984ec35e9ce87a65051692f956516ffa095d35 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: getservent_r.c,v 1.2 2001/07/15 23:29:48 marka Exp $";
+static const char rcsid[] = "$Id: getservent_r.c,v 1.3 2001/07/16 14:43:40 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <port_before.h>
@@ -41,22 +41,42 @@ SERV_R_RETURN
 getservbyname_r(const char *name, const char *proto,
                struct servent *sptr, SERV_R_ARGS) {
        struct servent *se = getservbyname(name, proto);
+#ifdef SERV_R_SETANSWER
+       int n = 0;
+       
+       if (se == NULL || (n = copy_servent(se, sptr, SERV_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = sptr;
 
+       return (n);
+#else
        if (se == NULL)
                return (SERV_R_BAD);
 
        return (copy_servent(se, sptr, SERV_R_COPY));
+#endif
 }
 
 SERV_R_RETURN
 getservbyport_r(int port, const char *proto,
                struct servent *sptr, SERV_R_ARGS) {
        struct servent *se = getservbyport(port, proto);
+#ifdef SERV_R_SETANSWER
+       int n = 0;
+       
+       if (se == NULL || (n = copy_servent(se, sptr, SERV_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = sptr;
 
+       return (n);
+#else
        if (se == NULL)
                return (SERV_R_BAD);
 
        return (copy_servent(se, sptr, SERV_R_COPY));
+#endif
 }
 
 /*
@@ -68,11 +88,21 @@ getservbyport_r(int port, const char *proto,
 SERV_R_RETURN
 getservent_r(struct servent *sptr, SERV_R_ARGS) {
        struct servent *se = getservent();
+#ifdef SERV_R_SETANSWER
+       int n = 0;
+       
+       if (se == NULL || (n = copy_servent(se, sptr, SERV_R_COPY)) != 0)
+               *answerp = NULL;
+       else
+               *answerp = sptr;
 
+       return (n);
+#else
        if (se == NULL)
                return (SERV_R_BAD);
 
        return (copy_servent(se, sptr, SERV_R_COPY));
+#endif
 }
 
 SERV_R_SET_RETURN
@@ -120,7 +150,7 @@ copy_servent(struct servent *se, struct servent *sptr, SERV_R_COPY_ARGS) {
        len += strlen(se->s_proto) + 1;
        len += numptr * sizeof(char*);
        
-       if (len > buflen) {
+       if (len > (int)buflen) {
                errno = ERANGE;
                return (SERV_R_BAD);
        }
index 538d5d52d801ae3bf55014d6c58af6fe62c5cb9b..db8810d64c2baa1cacb1ee3f59ed097f198a9725 100644 (file)
@@ -109,6 +109,7 @@ struct timezone;        /* silence warning */
 @SERV_R_END_RETURN@
 @SERV_R_ENT_ARGS@
 @SERV_R_OK@
+@SERV_R_SETANSWER@
 @SERV_R_RETURN@
 @SERV_R_SET_RESULT@
 @SERV_R_SET_RETURN@