From df3d502c26689ffde76c2763aa3e33d3db917ff6 Mon Sep 17 00:00:00 2001 From: roland Date: Tue, 25 Jun 1996 06:49:54 +0000 Subject: [PATCH] Mon Jun 24 19:57:01 1996 Roland McGrath * inet/Makefile (routines): Add getrpcent, getrpcbyname, getrpcbynumber, getrpcent_r, getrpcbyname_r, getrpcbynumber_r. * inet/getrpcbynumber_r.c: New file. * inet/getrpcbynumber.c: New file. * inet/getrpcbyname.c: New file. * inet/getrpcbyname_r.c: New file. * inet/getrpcent_r.c: New file. * inet/getrpcent.c: New file. * nss/rpc-lookup.c: New file. * nss/nss_files/files-rpc.c: New file. * nss/Makefile (routines): Add rpc-lookup. (libnss_files-routines): Add files-rpc. * sunrpc/Makefile (routines): Remove getrpcent. * sunrpc/getrpcent.c: File removed. --- inet/Makefile | 15 +++- inet/getrpcbyname.c | 30 +++++++ inet/getrpcbyname_r.c | 29 +++++++ inet/getrpcbynumber.c | 29 +++++++ inet/getrpcbynumber_r.c | 29 +++++++ inet/getrpcent.c | 26 ++++++ inet/getrpcent_r.c | 26 ++++++ nss/nss_files/files-rpc.c | 48 ++++++++++ nss/rpc-lookup.c | 22 +++++ sunrpc/Makefile | 4 +- sunrpc/getrpcent.c | 217 ---------------------------------------------- 11 files changed, 252 insertions(+), 223 deletions(-) create mode 100644 inet/getrpcbyname.c create mode 100644 inet/getrpcbyname_r.c create mode 100644 inet/getrpcbynumber.c create mode 100644 inet/getrpcbynumber_r.c create mode 100644 inet/getrpcent.c create mode 100644 inet/getrpcent_r.c create mode 100644 nss/nss_files/files-rpc.c create mode 100644 nss/rpc-lookup.c delete mode 100644 sunrpc/getrpcent.c diff --git a/inet/Makefile b/inet/Makefile index 9389a22338..da300c7376 100644 --- a/inet/Makefile +++ b/inet/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -25,9 +25,16 @@ headers := netinet/in.h $(wildcard arpa/*.h protocols/*.h) routines := ntohl ntohs htonl htons \ inet_lnaof inet_mkadr \ - inet_netof inet_ntoa inet_net \ - getproto getprtent getprtname \ - getsrvbynm getsrvbypt getservent \ + inet_netof inet_ntoa inet_net herrno \ + gethstbyad gethstbyad_r gethstbynm gethstbynm2 gethstbynm2_r \ + gethstbynm_r gethstent gethstent_r \ + getnetbypt getnetbypt_r getnetbynm getnetent getnetent_r \ + getnetbynm_r \ + getproto getproto_r getprtent getprtent_r getprtname getprtname_r \ + getsrvbynm getsrvbynm_r getsrvbypt getsrvbypt_r getservent \ + getservent_r \ + getrpcent getrpcbyname getrpcbynumber \ + getrpcent_r getrpcbyname_r getrpcbynumber_r \ rcmd rexec ruserpass # No warnings about losing BSD code. diff --git a/inet/getrpcbyname.c b/inet/getrpcbyname.c new file mode 100644 index 0000000000..be14f71fed --- /dev/null +++ b/inet/getrpcbyname.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define FUNCTION_NAME getrpcbyname +#define DATABASE_NAME rpc +#define ADD_PARAMS const char *name +#define ADD_VARIABLES name +#define BUFLEN 1024 + +#include "../nss/getXXbyYY.c" diff --git a/inet/getrpcbyname_r.c b/inet/getrpcbyname_r.c new file mode 100644 index 0000000000..c8b5eba23a --- /dev/null +++ b/inet/getrpcbyname_r.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define FUNCTION_NAME getrpcbyname +#define DATABASE_NAME rpc +#define ADD_PARAMS const char *name +#define ADD_VARIABLES name + +#include "../nss/getXXbyYY_r.c" diff --git a/inet/getrpcbynumber.c b/inet/getrpcbynumber.c new file mode 100644 index 0000000000..4b0215610f --- /dev/null +++ b/inet/getrpcbynumber.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define FUNCTION_NAME getrpcbynumber +#define DATABASE_NAME rpc +#define ADD_PARAMS int number +#define ADD_VARIABLES number + +#include "../nss/getXXbyYY_r.c" diff --git a/inet/getrpcbynumber_r.c b/inet/getrpcbynumber_r.c new file mode 100644 index 0000000000..4b0215610f --- /dev/null +++ b/inet/getrpcbynumber_r.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define FUNCTION_NAME getrpcbynumber +#define DATABASE_NAME rpc +#define ADD_PARAMS int number +#define ADD_VARIABLES number + +#include "../nss/getXXbyYY_r.c" diff --git a/inet/getrpcent.c b/inet/getrpcent.c new file mode 100644 index 0000000000..5b2274af45 --- /dev/null +++ b/inet/getrpcent.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define GETFUNC_NAME rpcent +#define BUFLEN 1024 + +#include "../nss/getXXent.c" diff --git a/inet/getrpcent_r.c b/inet/getrpcent_r.c new file mode 100644 index 0000000000..4c9639f3a1 --- /dev/null +++ b/inet/getrpcent_r.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + + +#define LOOKUP_TYPE struct rpcent +#define GETFUNC_NAME rpcent +#define BUFLEN 1024 + +#include "../nss/getXXent_r.c" diff --git a/nss/nss_files/files-rpc.c b/nss/nss_files/files-rpc.c new file mode 100644 index 0000000000..fef0ff88b1 --- /dev/null +++ b/nss/nss_files/files-rpc.c @@ -0,0 +1,48 @@ +/* SunRPC program number file parser in nss_files module. +Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + + +#define ENTNAME rpcent +#define DATAFILE "/etc/rpc" + +struct rpcent_data {}; + +#define TRAILING_LIST_MEMBER r_aliases +#define TRAILING_LIST_SEPARATOR_P isspace +#include "files-parse.c" +LINE_PARSER +( + MIDLINE_COMMENTS; + STRING_FIELD (result->r_name, isspace, 1); + INT_FIELD (result->r_number, isspace, 1, 10,); + ) + +#include "files-XXX.c" + +DB_LOOKUP (rpcbyname, + LOOKUP_NAME (r_name, r_aliases), + const char *name) + +DB_LOOKUP (rpcbynumber, + { + if (result->r_number == number) + break; + }, int number) diff --git a/nss/rpc-lookup.c b/nss/rpc-lookup.c new file mode 100644 index 0000000000..f49359ad2b --- /dev/null +++ b/nss/rpc-lookup.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define DATABASE_NAME rpc + +#include "XXX-lookup.c" diff --git a/sunrpc/Makefile b/sunrpc/Makefile index 27c85cfe4c..d7101fe666 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -57,7 +57,7 @@ generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) routines := auth_none auth_unix authuxprot bindrsvprt \ clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \ - clnt_udp rpc_dtable get_myaddr getrpcent getrpcport \ + clnt_udp rpc_dtable get_myaddr getrpcport \ pmap_clnt pm_getmaps pm_getport pmap_prot \ pmap_prot2 pmap_rmt rpc_prot rpc_common rpc_cmsg \ svc svc_auth svc_authux svc_raw svc_run svc_simple \ diff --git a/sunrpc/getrpcent.c b/sunrpc/getrpcent.c deleted file mode 100644 index 0fc7affdf9..0000000000 --- a/sunrpc/getrpcent.c +++ /dev/null @@ -1,217 +0,0 @@ -/* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -/* - * Internet version. - */ -struct rpcdata { - FILE *rpcf; - char *current; - int currentlen; - int stayopen; -#define MAXALIASES 35 - char *rpc_aliases[MAXALIASES]; - struct rpcent rpc; - char line[BUFSIZ+1]; - char *domain; -} *rpcdata, *_rpcdata(); - -static struct rpcent *interpret(); -struct hostent *gethostent(); -char *inet_ntoa(); -extern char *index(); /* Changed from static by roland@gnu */ - -static char RPCDB[] = _PATH_RPC; /* Changed from "/etc/rpc" by roland@gnu */ - -static struct rpcdata * -_rpcdata() -{ - register struct rpcdata *d = rpcdata; - - if (d == 0) { - d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); - rpcdata = d; - } - return (d); -} - -struct rpcent * -getrpcbynumber(number) - register int number; -{ - register struct rpcdata *d = _rpcdata(); - register struct rpcent *p; - int reason; - char adrstr[16], *val = NULL; - int vallen; - - if (d == 0) - return (0); - setrpcent(0); - while (p = getrpcent()) { - if (p->r_number == number) - break; - } - endrpcent(); - return (p); -} - -struct rpcent * -getrpcbyname(name) - const char *name; /* const added by roland@gnu */ -{ - struct rpcent *rpc; - char **rp; - - setrpcent(0); - while(rpc = getrpcent()) { - if (strcmp(rpc->r_name, name) == 0) - return (rpc); - for (rp = rpc->r_aliases; *rp != NULL; rp++) { - if (strcmp(*rp, name) == 0) - return (rpc); - } - } - endrpcent(); - return (NULL); -} - -setrpcent(f) - int f; -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; - if (d->rpcf == NULL) - d->rpcf = fopen(RPCDB, "r"); - else - rewind(d->rpcf); - if (d->current) - free(d->current); - d->current = NULL; - d->stayopen |= f; -} - -endrpcent() -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; - if (d->current && !d->stayopen) { - free(d->current); - d->current = NULL; - } - if (d->rpcf && !d->stayopen) { - fclose(d->rpcf); - d->rpcf = NULL; - } -} - -struct rpcent * -getrpcent() -{ - struct rpcent *hp; - int reason; - char *key = NULL, *val = NULL; - int keylen, vallen; - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return(NULL); - if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) - return (NULL); - if (fgets(d->line, BUFSIZ, d->rpcf) == NULL) - return (NULL); - return interpret(d->line, strlen(d->line)); -} - -static struct rpcent * -interpret(val, len) - char * val; - size_t len; -{ - register struct rpcdata *d = _rpcdata(); - char *p; - register char *cp, **q; - - if (d == 0) - return; - strncpy(d->line, val, len); - p = d->line; - d->line[len] = '\n'; - if (*p == '#') - return (getrpcent()); - cp = strpbrk(p, "#\n"); - if (cp == NULL) - return (getrpcent()); - *cp = '\0'; - cp = strpbrk(p, " \t"); - if (cp == NULL) - return (getrpcent()); - *cp++ = '\0'; - /* THIS STUFF IS INTERNET SPECIFIC */ - d->rpc.r_name = d->line; - while (*cp == ' ' || *cp == '\t') - cp++; - d->rpc.r_number = atoi(cp); - q = d->rpc.r_aliases = d->rpc_aliases; - cp = strpbrk(p, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &(d->rpc_aliases[MAXALIASES - 1])) - *q++ = cp; - cp = strpbrk(p, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&d->rpc); -} -- 2.11.0