glibc getproto*_r()
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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@
|
||||
|
||||
Reference in New Issue
Block a user