Post 1.0 cleanup:
* Include appropriate header files to bring prototypes into scope. * bcopy -> memcpy * bzero -> memset * bcmp -> memcmp * Tweak yp xdr routines so compiler can do a better job --- saves at least 5 instructions per function call on the i386.
This commit is contained in:
parent
4bb1df3001
commit
fac4c46f81
|
@ -30,13 +30,15 @@
|
|||
*/
|
||||
|
||||
#ifndef LINT
|
||||
static char *rcsid = "$Id: xdryp.c,v 1.6 1994/05/25 09:52:05 deraadt Exp $";
|
||||
static char *rcsid = "$Id: xdryp.c,v 1.7 1994/08/06 23:07:47 jtc Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
@ -58,10 +60,7 @@ xdr_domainname(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
char *objp;
|
||||
{
|
||||
if (!xdr_string(xdrs, &objp, YPMAXDOMAIN)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_string(xdrs, &objp, YPMAXDOMAIN);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -69,10 +68,7 @@ xdr_peername(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
char *objp;
|
||||
{
|
||||
if (!xdr_string(xdrs, &objp, YPMAXPEER)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_string(xdrs, &objp, YPMAXPEER);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -80,10 +76,7 @@ xdr_datum(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
datum *objp;
|
||||
{
|
||||
if (!xdr_bytes(xdrs, (char **)&objp->dptr, (u_int *)&objp->dsize, YPMAXRECORD)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_bytes(xdrs, (char **)&objp->dptr, (u_int *)&objp->dsize, YPMAXRECORD);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -91,10 +84,7 @@ xdr_mapname(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
char *objp;
|
||||
{
|
||||
if (!xdr_string(xdrs, &objp, YPMAXMAP)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_string(xdrs, &objp, YPMAXMAP);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -108,10 +98,7 @@ struct ypreq_key *objp;
|
|||
if (!xdr_mapname(xdrs, objp->map)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_datum(xdrs, &objp->keydat)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_datum(xdrs, &objp->keydat);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -122,10 +109,7 @@ struct ypreq_nokey *objp;
|
|||
if (!xdr_domainname(xdrs, objp->domain)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_mapname(xdrs, objp->map)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_mapname(xdrs, objp->map);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -133,10 +117,7 @@ xdr_yp_inaddr(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
struct in_addr *objp;
|
||||
{
|
||||
if (!xdr_opaque(xdrs, (caddr_t)&objp->s_addr, sizeof objp->s_addr)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_opaque(xdrs, (caddr_t)&objp->s_addr, sizeof objp->s_addr);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -147,11 +128,8 @@ struct ypbind_binding *objp;
|
|||
if (!xdr_yp_inaddr(xdrs, &objp->ypbind_binding_addr)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
|
||||
sizeof objp->ypbind_binding_port)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
|
||||
sizeof objp->ypbind_binding_port);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -159,10 +137,7 @@ xdr_ypbind_resptype(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
enum ypbind_resptype *objp;
|
||||
{
|
||||
if (!xdr_enum(xdrs, (enum_t *)objp)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_enum(xdrs, (enum_t *)objp);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -170,10 +145,7 @@ xdr_ypstat(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
enum ypbind_resptype *objp;
|
||||
{
|
||||
if (!xdr_enum(xdrs, (enum_t *)objp)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_enum(xdrs, (enum_t *)objp);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -186,19 +158,13 @@ struct ypbind_resp *objp;
|
|||
}
|
||||
switch (objp->ypbind_status) {
|
||||
case YPBIND_FAIL_VAL:
|
||||
if (!xdr_u_int(xdrs, (u_int *)&objp->ypbind_respbody.ypbind_error)) {
|
||||
return (FALSE);
|
||||
}
|
||||
break;
|
||||
return xdr_u_int(xdrs, (u_int *)&objp->ypbind_respbody.ypbind_error);
|
||||
case YPBIND_SUCC_VAL:
|
||||
if (!xdr_ypbind_binding(xdrs, &objp->ypbind_respbody.ypbind_bindinfo)) {
|
||||
return (FALSE);
|
||||
}
|
||||
break;
|
||||
return xdr_ypbind_binding(xdrs, &objp->ypbind_respbody.ypbind_bindinfo);
|
||||
default:
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -209,10 +175,7 @@ struct ypresp_val *objp;
|
|||
if (!xdr_ypstat(xdrs, &objp->status)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_datum(xdrs, &objp->valdat)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_datum(xdrs, &objp->valdat);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -226,10 +189,7 @@ struct ypbind_setdom *objp;
|
|||
if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_u_short(xdrs, &objp->ypsetdom_vers)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_u_short(xdrs, &objp->ypsetdom_vers);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -243,10 +203,7 @@ struct ypresp_key_val *objp;
|
|||
if (!xdr_datum(xdrs, &objp->valdat)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_datum(xdrs, &objp->keydat)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_datum(xdrs, &objp->keydat);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -259,16 +216,13 @@ struct ypresp_all *objp;
|
|||
}
|
||||
switch (objp->more) {
|
||||
case TRUE:
|
||||
if (!xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val)) {
|
||||
return (FALSE);
|
||||
}
|
||||
break;
|
||||
return xdr_ypresp_key_val(xdrs, &objp->ypresp_all_u.val);
|
||||
case FALSE:
|
||||
break;
|
||||
return (TRUE);
|
||||
default:
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -281,7 +235,7 @@ u_long *objp;
|
|||
char *key, *val;
|
||||
int r;
|
||||
|
||||
bzero(&out, sizeof out);
|
||||
memset(&out, 0, sizeof out);
|
||||
while(1) {
|
||||
if( !xdr_ypresp_all(xdrs, &out)) {
|
||||
xdr_free(xdr_ypresp_all, (char *)&out);
|
||||
|
@ -296,11 +250,11 @@ u_long *objp;
|
|||
switch(status) {
|
||||
case YP_TRUE:
|
||||
key = (char *)malloc(out.ypresp_all_u.val.keydat.dsize + 1);
|
||||
bcopy(out.ypresp_all_u.val.keydat.dptr, key,
|
||||
memcpy(key, out.ypresp_all_u.val.keydat.dptr,
|
||||
out.ypresp_all_u.val.keydat.dsize);
|
||||
key[out.ypresp_all_u.val.keydat.dsize] = '\0';
|
||||
val = (char *)malloc(out.ypresp_all_u.val.valdat.dsize + 1);
|
||||
bcopy(out.ypresp_all_u.val.valdat.dptr, val,
|
||||
memcpy(val, out.ypresp_all_u.val.valdat.dptr,
|
||||
out.ypresp_all_u.val.valdat.dsize);
|
||||
val[out.ypresp_all_u.val.valdat.dsize] = '\0';
|
||||
xdr_free(xdr_ypresp_all, (char *)&out);
|
||||
|
@ -334,10 +288,7 @@ struct ypresp_master *objp;
|
|||
if (!xdr_ypstat(xdrs, &objp->status)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->master, YPMAXPEER)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_string(xdrs, &objp->master, YPMAXPEER);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -345,10 +296,7 @@ xdr_ypmaplist_str(xdrs, objp)
|
|||
XDR *xdrs;
|
||||
char *objp;
|
||||
{
|
||||
if (!xdr_string(xdrs, &objp, YPMAXMAP+1)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_string(xdrs, &objp, YPMAXMAP+1);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -359,11 +307,8 @@ struct ypmaplist *objp;
|
|||
if (!xdr_ypmaplist_str(xdrs, objp->ypml_name)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_pointer(xdrs, (caddr_t *)&objp->ypml_next,
|
||||
sizeof(struct ypmaplist), xdr_ypmaplist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_pointer(xdrs, (caddr_t *)&objp->ypml_next,
|
||||
sizeof(struct ypmaplist), xdr_ypmaplist);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -374,11 +319,8 @@ struct ypresp_maplist *objp;
|
|||
if (!xdr_ypstat(xdrs, &objp->status)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_pointer(xdrs, (caddr_t *)&objp->list,
|
||||
sizeof(struct ypmaplist), xdr_ypmaplist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_pointer(xdrs, (caddr_t *)&objp->list,
|
||||
sizeof(struct ypmaplist), xdr_ypmaplist);
|
||||
}
|
||||
|
||||
bool_t
|
||||
|
@ -389,8 +331,5 @@ struct ypresp_order *objp;
|
|||
if (!xdr_ypstat(xdrs, &objp->status)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_u_long(xdrs, &objp->ordernum)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return xdr_u_long(xdrs, &objp->ordernum);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#ifndef LINT
|
||||
static char *rcsid = "$Id: yplib.c,v 1.8 1994/05/25 09:52:07 deraadt Exp $";
|
||||
static char *rcsid = "$Id: yplib.c,v 1.9 1994/08/06 23:07:50 jtc Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -40,7 +40,9 @@ static char *rcsid = "$Id: yplib.c,v 1.8 1994/05/25 09:52:07 deraadt Exp $";
|
|||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
|
@ -92,7 +94,7 @@ int vallen;
|
|||
break;
|
||||
if(ep==NULL) {
|
||||
ep = (struct ypmatch_ent *)malloc(sizeof *ep);
|
||||
bzero((char *)ep, sizeof *ep);
|
||||
memset(ep, 0, sizeof *ep);
|
||||
if(ypmc)
|
||||
ep->next = ypmc;
|
||||
ypmc = ep;
|
||||
|
@ -119,8 +121,8 @@ int vallen;
|
|||
ep->keylen = keylen;
|
||||
ep->vallen = vallen;
|
||||
|
||||
bcopy(key, ep->key, ep->keylen);
|
||||
bcopy(val, ep->val, ep->vallen);
|
||||
memcpy(ep->key, key, ep->keylen);
|
||||
memcpy(ep->val, val, ep->vallen);
|
||||
|
||||
if(ep->map) {
|
||||
if( strcmp(ep->map, map) ) {
|
||||
|
@ -155,7 +157,7 @@ int *vallen;
|
|||
continue;
|
||||
if(strcmp(ep->map, map))
|
||||
continue;
|
||||
if(bcmp(ep->key, key, keylen))
|
||||
if(memcmp(ep->key, key, keylen))
|
||||
continue;
|
||||
if(t > ep->expire_t)
|
||||
continue;
|
||||
|
@ -208,7 +210,7 @@ struct dom_binding **ypdb;
|
|||
break;
|
||||
if(ysd==NULL) {
|
||||
ysd = (struct dom_binding *)malloc(sizeof *ysd);
|
||||
bzero((char *)ysd, sizeof *ysd);
|
||||
memset(ysd, 0, sizeof *ysd);
|
||||
ysd->dom_socket = -1;
|
||||
ysd->dom_vers = 0;
|
||||
new = 1;
|
||||
|
@ -240,7 +242,7 @@ again:
|
|||
goto again;
|
||||
}
|
||||
|
||||
bzero(&ysd->dom_server_addr, sizeof ysd->dom_server_addr);
|
||||
memset(&ysd->dom_server_addr, 0, sizeof ysd->dom_server_addr);
|
||||
ysd->dom_server_addr.sin_family = AF_INET;
|
||||
ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
|
||||
ysd->dom_server_addr.sin_addr =
|
||||
|
@ -261,7 +263,7 @@ again:
|
|||
}
|
||||
#endif
|
||||
if(ysd->dom_vers==-1 || ysd->dom_vers==0) {
|
||||
bzero((char *)&clnt_sin, sizeof clnt_sin);
|
||||
memset(&clnt_sin, 0, sizeof clnt_sin);
|
||||
clnt_sin.sin_family = AF_INET;
|
||||
clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
|
||||
|
@ -288,7 +290,7 @@ again:
|
|||
}
|
||||
clnt_destroy(client);
|
||||
|
||||
bzero((char *)&ysd->dom_server_addr, sizeof ysd->dom_server_addr);
|
||||
memset(&ysd->dom_server_addr, 0, sizeof ysd->dom_server_addr);
|
||||
ysd->dom_server_addr.sin_family = AF_INET;
|
||||
ysd->dom_server_addr.sin_port =
|
||||
ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port;
|
||||
|
@ -391,7 +393,7 @@ again:
|
|||
inkeylen, &yprv.valdat.dptr, &yprv.valdat.dsize)) {
|
||||
*outvallen = yprv.valdat.dsize;
|
||||
*outval = (char *)malloc(*outvallen+1);
|
||||
bcopy(yprv.valdat.dptr, *outval, *outvallen);
|
||||
memcpy(*outval, yprv.valdat.dptr, *outvallen);
|
||||
(*outval)[*outvallen] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
@ -405,7 +407,7 @@ again:
|
|||
yprk.keydat.dptr = (char *)inkey;
|
||||
yprk.keydat.dsize = inkeylen;
|
||||
|
||||
bzero((char *)&yprv, sizeof yprv);
|
||||
memset(&yprv, 0, sizeof yprv);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_MATCH,
|
||||
xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
|
||||
|
@ -417,7 +419,7 @@ again:
|
|||
if( !(r=ypprot_err(yprv.status)) ) {
|
||||
*outvallen = yprv.valdat.dsize;
|
||||
*outval = (char *)malloc(*outvallen+1);
|
||||
bcopy(yprv.valdat.dptr, *outval, *outvallen);
|
||||
memcpy(*outval, yprv.valdat.dptr, *outvallen);
|
||||
(*outval)[*outvallen] = '\0';
|
||||
#ifdef YPMATCHCACHE
|
||||
if( strcmp(_yp_domain, indomain)==0 )
|
||||
|
@ -468,7 +470,7 @@ again:
|
|||
|
||||
yprnk.domain = indomain;
|
||||
yprnk.map = inmap;
|
||||
bzero((char *)&yprkv, sizeof yprkv);
|
||||
memset(&yprkv, 0, sizeof yprkv);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_FIRST,
|
||||
xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv);
|
||||
|
@ -480,11 +482,11 @@ again:
|
|||
if( !(r=ypprot_err(yprkv.status)) ) {
|
||||
*outkeylen = yprkv.keydat.dsize;
|
||||
*outkey = (char *)malloc(*outkeylen+1);
|
||||
bcopy(yprkv.keydat.dptr, *outkey, *outkeylen);
|
||||
memcpy (*outkey, yprkv.keydat.dptr, *outkeylen);
|
||||
(*outkey)[*outkeylen] = '\0';
|
||||
*outvallen = yprkv.valdat.dsize;
|
||||
*outval = (char *)malloc(*outvallen+1);
|
||||
bcopy(yprkv.valdat.dptr, *outval, *outvallen);
|
||||
memcpy (*outval, yprkv.valdat.dptr, *outvallen);
|
||||
(*outval)[*outvallen] = '\0';
|
||||
}
|
||||
xdr_free(xdr_ypresp_key_val, (char *)&yprkv);
|
||||
|
@ -523,7 +525,7 @@ again:
|
|||
yprk.map = inmap;
|
||||
yprk.keydat.dptr = inkey;
|
||||
yprk.keydat.dsize = inkeylen;
|
||||
bzero((char *)&yprkv, sizeof yprkv);
|
||||
memset(&yprkv, 0, sizeof yprkv);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_NEXT,
|
||||
xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
|
||||
|
@ -535,11 +537,11 @@ again:
|
|||
if( !(r=ypprot_err(yprkv.status)) ) {
|
||||
*outkeylen = yprkv.keydat.dsize;
|
||||
*outkey = (char *)malloc(*outkeylen+1);
|
||||
bcopy(yprkv.keydat.dptr, *outkey, *outkeylen);
|
||||
memcpy(*outkey, yprkv.keydat.dptr, *outkeylen);
|
||||
(*outkey)[*outkeylen] = '\0';
|
||||
*outvallen = yprkv.valdat.dsize;
|
||||
*outval = (char *)malloc(*outvallen+1);
|
||||
bcopy(yprkv.valdat.dptr, *outval, *outvallen);
|
||||
memcpy(*outval, yprkv.valdat.dptr, *outvallen);
|
||||
(*outval)[*outvallen] = '\0';
|
||||
}
|
||||
xdr_free(xdr_ypresp_key_val, (char *)&yprkv);
|
||||
|
@ -613,7 +615,7 @@ again:
|
|||
yprnk.domain = indomain;
|
||||
yprnk.map = inmap;
|
||||
|
||||
bzero((char *)(char *)&ypro, sizeof ypro);
|
||||
memset(&ypro, 0, sizeof ypro);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_ORDER,
|
||||
xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
|
||||
|
@ -651,7 +653,7 @@ again:
|
|||
yprnk.domain = indomain;
|
||||
yprnk.map = inmap;
|
||||
|
||||
bzero((char *)&yprm, sizeof yprm);
|
||||
memset(&yprm, 0, sizeof yprm);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_MASTER,
|
||||
xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
|
||||
|
@ -684,7 +686,7 @@ again:
|
|||
tv.tv_sec = _yplib_timeout;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
bzero((char *)&ypml, sizeof ypml);
|
||||
memset(&ypml, 0, sizeof ypml);
|
||||
|
||||
r = clnt_call(ysd->dom_client, YPPROC_MAPLIST,
|
||||
xdr_domainname, indomain, xdr_ypresp_maplist, &ypml, tv);
|
||||
|
|
Loading…
Reference in New Issue