Split yp_all, yp_master, and yp_other out of yplib.c; makes some static

executables a bit smaller.
This commit is contained in:
jtc 1996-05-14 23:37:27 +00:00
parent 2cd534aa06
commit 7808771d84
6 changed files with 267 additions and 141 deletions

View File

@ -1,9 +1,9 @@
# $NetBSD: Makefile.inc,v 1.10 1996/05/14 13:36:49 jtc Exp $ # $NetBSD: Makefile.inc,v 1.11 1996/05/14 23:37:27 jtc Exp $
# yp sources # yp sources
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/yp ${.CURDIR}/yp .PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/yp ${.CURDIR}/yp
SRCS+= xdryp.c yplib.c yperr_string.c SRCS+= xdryp.c yp_all.c yp_master.c yp_order.c yplib.c yperr_string.c
MAN+= ypclnt.3 MAN+= ypclnt.3
MLINKS+=ypclnt.3 yp_all.3 ypclnt.3 yp_bind.3 ypclnt.3 yp_first.3 \ MLINKS+=ypclnt.3 yp_all.3 ypclnt.3 yp_bind.3 ypclnt.3 yp_first.3 \

View File

@ -1,4 +1,4 @@
/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */ /* $NetBSD: xdryp.c,v 1.11 1996/05/14 23:37:29 jtc Exp $ */
/* /*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -32,7 +32,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $"; static char *rcsid = "$NetBSD: xdryp.c,v 1.11 1996/05/14 23:37:29 jtc Exp $";
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -47,8 +47,8 @@ static char *rcsid = "$NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $";
#include <rpcsvc/yp_prot.h> #include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h> #include <rpcsvc/ypclnt.h>
extern int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *)); int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
extern void *ypresp_data; void *ypresp_data;
bool_t bool_t
xdr_domainname(xdrs, objp) xdr_domainname(xdrs, objp)

88
lib/libc/yp/yp_all.c Normal file
View File

@ -0,0 +1,88 @@
/* $NetBSD: yp_all.c,v 1.1 1996/05/14 23:37:30 jtc Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Theo de Raadt.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: yp_all.c,v 1.1 1996/05/14 23:37:30 jtc Exp $";
#endif
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
extern int _yplib_timeout;
extern int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
extern void *ypresp_data;
int
yp_all(indomain, inmap, incallback)
const char *indomain;
const char *inmap;
struct ypall_callback *incallback;
{
struct ypreq_nokey yprnk;
struct dom_binding *ysd;
struct timeval tv;
struct sockaddr_in clnt_sin;
CLIENT *clnt;
u_long status;
int clnt_sock;
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
clnt_sock = RPC_ANYSOCK;
clnt_sin = ysd->dom_server_addr;
clnt_sin.sin_port = 0;
clnt = clnttcp_create(&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0);
if (clnt == NULL) {
printf("clnttcp_create failed\n");
return YPERR_PMAP;
}
yprnk.domain = indomain;
yprnk.map = inmap;
ypresp_allfn = incallback->foreach;
ypresp_data = (void *) incallback->data;
(void) clnt_call(clnt, YPPROC_ALL,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
clnt_destroy(clnt);
/* not really needed... */
xdr_free(xdr_ypresp_all_seq, (char *) &status);
_yp_unbind(ysd);
if (status != YP_FALSE)
return ypprot_err(status);
return 0;
}

83
lib/libc/yp/yp_master.c Normal file
View File

@ -0,0 +1,83 @@
/* $NetBSD: yp_master.c,v 1.1 1996/05/14 23:37:31 jtc Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Theo de Raadt.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: yp_master.c,v 1.1 1996/05/14 23:37:31 jtc Exp $";
#endif
#include <string.h>
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
extern int _yplib_timeout;
int
yp_master(indomain, inmap, outname)
const char *indomain;
const char *inmap;
char **outname;
{
struct dom_binding *ysd;
struct ypresp_master yprm;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
(void)memset(&yprm, 0, sizeof yprm);
r = clnt_call(ysd->dom_client, YPPROC_MASTER,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
ysd->dom_vers = -1;
goto again;
}
if (!(r = ypprot_err(yprm.status))) {
if ((*outname = strdup(yprm.master)) == NULL)
r = RPC_SYSTEMERROR;
}
xdr_free(xdr_ypresp_master, (char *) &yprm);
_yp_unbind(ysd);
return r;
}

86
lib/libc/yp/yp_order.c Normal file
View File

@ -0,0 +1,86 @@
/* $NetBSD: yp_order.c,v 1.1 1996/05/14 23:37:32 jtc Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Theo de Raadt.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: yp_order.c,v 1.1 1996/05/14 23:37:32 jtc Exp $";
#endif
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
extern int _yplib_timeout;
int
yp_order(indomain, inmap, outorder)
const char *indomain;
const char *inmap;
int *outorder;
{
struct dom_binding *ysd;
struct ypresp_order ypro;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
(void)memset(&ypro, 0, sizeof ypro);
r = clnt_call(ysd->dom_client, YPPROC_ORDER,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
if (r == RPC_PROCUNAVAIL) {
/* Case of NIS+ server in NIS compat mode */
r = YPERR_YPERR;
goto bail;
}
ysd->dom_vers = -1;
goto again;
}
*outorder = ypro.ordernum;
xdr_free(xdr_ypresp_order, (char *) &ypro);
r = ypprot_err(ypro.status);
bail:
_yp_unbind(ysd);
return r;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yplib.c,v 1.19 1996/05/14 13:36:51 jtc Exp $ */ /* $NetBSD: yplib.c,v 1.20 1996/05/14 23:37:33 jtc Exp $ */
/* /*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
@ -32,7 +32,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: yplib.c,v 1.19 1996/05/14 13:36:51 jtc Exp $"; static char rcsid[] = "$NetBSD: yplib.c,v 1.20 1996/05/14 23:37:33 jtc Exp $";
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -54,9 +54,6 @@ static char rcsid[] = "$NetBSD: yplib.c,v 1.19 1996/05/14 13:36:51 jtc Exp $";
#define YPBINDLOCK "/var/run/ypbind.lock" #define YPBINDLOCK "/var/run/ypbind.lock"
#define YPMATCHCACHE #define YPMATCHCACHE
int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
void *ypresp_data;
struct dom_binding *_ypbindlist; struct dom_binding *_ypbindlist;
static char _yp_domain[MAXHOSTNAMELEN]; static char _yp_domain[MAXHOSTNAMELEN];
int _yplib_timeout = 10; int _yplib_timeout = 10;
@ -64,7 +61,7 @@ int _yplib_timeout = 10;
static bool_t ypmatch_add __P((const char *, const char *, int, char *, int)); static bool_t ypmatch_add __P((const char *, const char *, int, char *, int));
static bool_t ypmatch_find __P((const char *, const char *, int, const char **, static bool_t ypmatch_find __P((const char *, const char *, int, const char **,
int *)); int *));
static void _yp_unbind __P((struct dom_binding *)); void _yp_unbind __P((struct dom_binding *));
#ifdef YPMATCHCACHE #ifdef YPMATCHCACHE
int _yplib_cache = 5; int _yplib_cache = 5;
@ -357,7 +354,7 @@ gotit:
return 0; return 0;
} }
static void void
_yp_unbind(ypb) _yp_unbind(ypb)
struct dom_binding *ypb; struct dom_binding *ypb;
{ {
@ -594,134 +591,6 @@ again:
return r; return r;
} }
int
yp_all(indomain, inmap, incallback)
const char *indomain;
const char *inmap;
struct ypall_callback *incallback;
{
struct ypreq_nokey yprnk;
struct dom_binding *ysd;
struct timeval tv;
struct sockaddr_in clnt_sin;
CLIENT *clnt;
u_long status;
int clnt_sock;
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
clnt_sock = RPC_ANYSOCK;
clnt_sin = ysd->dom_server_addr;
clnt_sin.sin_port = 0;
clnt = clnttcp_create(&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0);
if (clnt == NULL) {
printf("clnttcp_create failed\n");
return YPERR_PMAP;
}
yprnk.domain = indomain;
yprnk.map = inmap;
ypresp_allfn = incallback->foreach;
ypresp_data = (void *) incallback->data;
(void) clnt_call(clnt, YPPROC_ALL,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
clnt_destroy(clnt);
/* not really needed... */
xdr_free(xdr_ypresp_all_seq, (char *) &status);
_yp_unbind(ysd);
if (status != YP_FALSE)
return ypprot_err(status);
return 0;
}
int
yp_order(indomain, inmap, outorder)
const char *indomain;
const char *inmap;
int *outorder;
{
struct dom_binding *ysd;
struct ypresp_order ypro;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
(void)memset(&ypro, 0, sizeof ypro);
r = clnt_call(ysd->dom_client, YPPROC_ORDER,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
if (r == RPC_PROCUNAVAIL) {
/* Case of NIS+ server in NIS compat mode */
r = YPERR_YPERR;
goto bail;
}
ysd->dom_vers = -1;
goto again;
}
*outorder = ypro.ordernum;
xdr_free(xdr_ypresp_order, (char *) &ypro);
r = ypprot_err(ypro.status);
bail:
_yp_unbind(ysd);
return r;
}
int
yp_master(indomain, inmap, outname)
const char *indomain;
const char *inmap;
char **outname;
{
struct dom_binding *ysd;
struct ypresp_master yprm;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
(void)memset(&yprm, 0, sizeof yprm);
r = clnt_call(ysd->dom_client, YPPROC_MASTER,
xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
ysd->dom_vers = -1;
goto again;
}
if (!(r = ypprot_err(yprm.status))) {
if ((*outname = strdup(yprm.master)) == NULL)
r = RPC_SYSTEMERROR;
}
xdr_free(xdr_ypresp_master, (char *) &yprm);
_yp_unbind(ysd);
return r;
}
int int
yp_maplist(indomain, outmaplist) yp_maplist(indomain, outmaplist)
const char *indomain; const char *indomain;