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)
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"
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)
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,
/*
* @(#)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_
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));
*/
#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>
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
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
}
/*
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
len += strlen(ne->n_name) + 1;
len += numptr * sizeof(char*);
- if (len > buflen) {
+ if (len > (int)buflen) {
errno = ERANGE;
return (NET_R_BAD);
}
@NET_R_OK@
@NET_R_RETURN@
@NET_R_SET_RESULT@
+@NET_R_SETANSWER@
@NET_R_SET_RETURN@
@GROUP_R_RETURN@