glibc/sunrpc/svc_simple.c

144 lines
4.0 KiB
C
Raw Normal View History

1995-02-18 02:27:10 +01:00
/* @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC */
/*
* 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.
*
1995-02-18 02:27:10 +01:00
* 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.
*
1995-02-18 02:27:10 +01:00
* 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.
*
1995-02-18 02:27:10 +01:00
* 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.
*
1995-02-18 02:27:10 +01:00
* 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.
*
1995-02-18 02:27:10 +01:00
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
1995-02-18 02:27:10 +01:00
* svc_simple.c
* Simplified front end to rpc.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <netdb.h>
static struct proglst {
char *(*p_progname)();
int p_prognum;
int p_procnum;
xdrproc_t p_inproc, p_outproc;
struct proglst *p_nxt;
} *proglst;
static void universal();
static SVCXPRT *transp;
registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
char *(*progname)();
xdrproc_t inproc, outproc;
{
Fri May 3 13:32:08 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * intl/Makefile (CPPFLAGS): Change $(nlsdir) to $(i18ndir) in LOCALE_ALIAS_PATH. Fri May 3 03:14:02 1996 Ulrich Drepper <drepper@cygnus.com> * intl/Makefile (routines): Add l10nflist and explodename. (distribute): Add loadinfo.h and locale.alias. (install-others): New variable to install locale.alias. * intl/dcgettext.c, intl/finddomain.c, intl/gettextP.h, intl/loadmsgcat.c: Adapt for upcoming gettext-0.10.13. Some code is now shared with the locale implementation. * intl/explodename.c, intl/l10nflist.c, intl/loadinfo.h: New file. Extracted from finddomain.c. This is also used in the locale implementation. * intl/locale.alias: New file. Locale alias database compatible with X Window System's locale alias file. Can now be used in locale and gettext code. * libio/stdio.h: Add prototypes for asprint and vasprintf. * locale/C-collate.c, locale/C-ctype.c, locale/C-messages.c, locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c: Add new field in structure with name of locale ("C" in this case). * locale/Makefile (routines): Add findlocale. * locale/findlocale.c: New file. Instead of trying to load the directly described file we now try to be much smarter when this fails. Use the same code as gettext does. * locale/loadlocale.c, locale/setlocale.c: Rewrite to know about new loading scheme. * locale/localeinfo.h: Adapt prototypes and declarations for new setlocale implementation. Remove definition of u32_t type. We now use u_int32_t from <sys/types.h>. * locale/programs/charset.h (ILLEGAL_CHAR_VALUE): Provide type with constant. * locale/programs/config.h, locale/lc-collate.c, locale/localeinfo.h, locale/programs/ld-collate.c, locale/programs/ld-ctype.c, locale/programs/ld-messages.c, locale/programs/ld-monetary.c, locale/programs/ld-numeric.c, locale/programs/ld-time.c, locale/weight.h, string/strcoll.c: Change to use u_int32_t and u_int16_t. * locale/programs/localedef.c (construct_output_path): Change name of output locale to contain normalized form of the character set portion. * string/Makefile (routines): Add agrz-ctsep and argz-next. (tests): Add tst-strlen. * string/argz-ctsep.c: New file. Implement reverse operation from argz-stringify. * string/argz-next.c: Non-inline version of function from argz.h. * string/argz.h, string/envz.h: Make usable as global header file. * string/envz.c: Fix declarations to use size_t where prototypes say so. * string/tst-strlen.c: New file. Another test for critical situation in strlen implementations. * sysdeps/i386/i586/strlen.S: Fix bug with highest byte in word being zero. * wctype/test_wctype.c: Fix controlling comparison after change to 32 bit character class array. Fri May 3 12:53:12 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * sysdeps/unix/sysv/linux/sys/socket.h: Remove spurious doubled line. Thu May 2 22:50:52 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/getpriority.c: New file. * sysdeps/unix/sysv/linux/syscalls.list: Add s_getpriority. Thu May 2 22:41:31 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/fpu_control.h (_FPU_DEFAULT): Disable all exceptions. Thu May 2 22:33:14 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/fpu/e_acos.c, sysdeps/m68k/fpu/e_acosf.c, sysdeps/m68k/fpu/e_fmod.c, sysdeps/m68k/fpu/e_fmodf.c, sysdeps/m68k/fpu/isinfl.c, sysdeps/m68k/fpu/isnanl.c, sysdeps/m68k/fpu/s_atan.c, sysdeps/m68k/fpu/s_atanf.c, sysdeps/m68k/fpu/s_frexp.c, sysdeps/m68k/fpu/s_frexpf.c, sysdeps/m68k/fpu/s_ilogb.c, sysdeps/m68k/fpu/s_ilogbf.c, sysdeps/m68k/fpu/s_isinf.c, sysdeps/m68k/fpu/s_isinff.c, sysdeps/m68k/fpu/s_ldexp.c, sysdeps/m68k/fpu/s_ldexpf.c, sysdeps/m68k/fpu/s_modf.c, sysdeps/m68k/fpu/s_modff.c: Don't define __NO_MATH_INLINES, which is already defined on command line. Thu May 2 22:18:28 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/libm-ieee754/e_j0f.c (__ieee754_j0f, __ieee754_y0f): Replace 0x80000000 by 0x48000000. * sysdeps/libm-ieee754/e_j1f.c (__ieee754_j1f): Likewise. Thu May 2 21:30:33 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sunrpc/svc_simple.c: Make global variable pl local to registerrpc. Thu May 2 00:24:04 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * time/Makefile (tz-cflags): New variable. (CFLAGS-tzfile.c): New variable. (CFLAGS-zic.c): Add $(tz-cflags). (tz-cc): Remove variable. ($(objpfx)tzfile.o, $(objpfx)zic.o): Remove targets. * sysdeps/mach/hurd/getcwd.c: Jump out of both loops when we find a name, instead of checking for reaching end of buffer, which happens when the match is the last entry in the buffer.
1996-05-03 19:44:31 +02:00
struct proglst *pl;
1995-02-18 02:27:10 +01:00
if (procnum == NULLPROC) {
(void) fprintf(stderr,
_("can't reassign procedure number %d\n"), NULLPROC);
1995-02-18 02:27:10 +01:00
return (-1);
}
if (transp == 0) {
transp = svcudp_create(RPC_ANYSOCK);
if (transp == NULL) {
(void) fprintf(stderr, _("couldn't create an rpc server\n"));
1995-02-18 02:27:10 +01:00
return (-1);
}
}
(void) pmap_unset((u_long)prognum, (u_long)versnum);
if (!svc_register(transp, (u_long)prognum, (u_long)versnum,
1995-02-18 02:27:10 +01:00
universal, IPPROTO_UDP)) {
(void) fprintf(stderr, _("couldn't register prog %d vers %d\n"),
1995-02-18 02:27:10 +01:00
prognum, versnum);
return (-1);
}
pl = (struct proglst *)malloc(sizeof(struct proglst));
if (pl == NULL) {
(void) fprintf(stderr, _("registerrpc: out of memory\n"));
1995-02-18 02:27:10 +01:00
return (-1);
}
pl->p_progname = progname;
pl->p_prognum = prognum;
pl->p_procnum = procnum;
pl->p_inproc = inproc;
pl->p_outproc = outproc;
pl->p_nxt = proglst;
proglst = pl;
return (0);
}
static void
universal(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
int prog, proc;
char *outdata;
char xdrbuf[UDPMSGSIZE];
struct proglst *pl;
/*
1995-02-18 02:27:10 +01:00
* enforce "procnum 0 is echo" convention
*/
if (rqstp->rq_proc == NULLPROC) {
if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) {
(void) fprintf(stderr, "xxx\n");
exit(1);
}
return;
}
prog = rqstp->rq_prog;
proc = rqstp->rq_proc;
for (pl = proglst; pl != NULL; pl = pl->p_nxt)
if (pl->p_prognum == prog && pl->p_procnum == proc) {
/* decode arguments into a CLEAN buffer */
bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */
if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) {
svcerr_decode(transp);
return;
}
outdata = (*(pl->p_progname))(xdrbuf);
if (outdata == NULL && pl->p_outproc != xdr_void)
/* there was an error */
return;
if (!svc_sendreply(transp, pl->p_outproc, outdata)) {
(void) fprintf(stderr,
_("trouble replying to prog %d\n"),
1995-02-18 02:27:10 +01:00
pl->p_prognum);
exit(1);
}
/* free the decoded arguments */
(void)svc_freeargs(transp, pl->p_inproc, xdrbuf);
return;
}
(void) fprintf(stderr, _("never registered prog %d\n"), prog);
1995-02-18 02:27:10 +01:00
exit(1);
}