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)
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"
]
,
)
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)
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,
/*
* @(#)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_
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));
*/
#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>
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
}
/*
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
len += strlen(se->s_proto) + 1;
len += numptr * sizeof(char*);
- if (len > buflen) {
+ if (len > (int)buflen) {
errno = ERANGE;
return (SERV_R_BAD);
}
@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@