mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Update.
1997-03-27 02:28 Ulrich Drepper <drepper@cygnus.com> * gmon/gmon.c (monstartup): Mark all messages. (write_call_graph): Rewrite to use larger I/O vector for writev call to reduce syscall overhead. (write_bb_counts): Simplify writev handling. * inet/rexec.c: Make string parameters `const'. * resolv/netdb.h: Add prototypes for rcmd, rexec, ruserok, and rresvport. * math/Makefile: Don't define CFLAGS-* macros to prevent inlining in libm-test. * math/libm-test.c (this_does_nothing): Remove functions. It's notuseful on any platform but ix86. (inverse_func_pair_test): Don't use this_does_nothing. Use memory reference. (identities1_test): Likewise. (identities2_test): Likewise. (identities3_test): Likewise. (basic_test): Likewise. Patch by Andreas Schwab. (BUILD_COMPLEX): New macro. Create complex number from real and imaginary parts. This works around bugs/inefficiencies in current gcc. (cexp_test): Use BUILD_COMPLEX. Add more tests. * nss/nsswitch.c: Fix typo. * posix/glob.h: Add declaration for glob_pattern_p. * posix/glob.c: Rename glob_pattern_p to __glob_pattern_p and make glob_pattern_p a weak alias. This function is used in other packages (e.g. bash). * signal/Makefile (routines): Add sigisempty, sigandset, and sigorset. * signal/signal.h: Add prototypes for sigisempty, sigandset, and sigorset. * signal/sigisempty.c: New file. * signal/sigandset.c: New file. * signal/sigorset.c: New file. * sysdeps/generic/sigset.h: Define __sigisemptyset, __sigandset, and __sigorset. * sysdeps/unix/sysv/linux/sigset.h: Likewise. * stdlib/strtod.c: Handle `n-char-sequence' in NaN parsing. It determines the bits in the mantissa part of the NaN. * stdlib/strtof.c: Define SET_MANTISSA for float type. * wcsmbs/wcstof.c: Define SET_MANTISSA for float type. * stdlib/strtold.c: Define SET_MANTISSA for long double type. * wcsmbs/wcstold.c: Define SET_MANTISSA for long double type. * sysdeps/libm-ieee754/s_cexp.c: Use explicit assignment to complex number components. Some more corrects for special cases. * sysdeps/libm-ieee754/s_cexpf.c: Likewise. * sysdeps/libm-ieee754/s_cexpl.c: Likewise. * sysdeps/sparc/elf/start.S: Remove as per request of Miguel de Icaza. * sysdeps/unix/sysv/linux/netinet/icmp.h: Remove since we have ip_icmp.h. Reported by HJ Lu. 1997-03-25 03:50 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/Makefile (CFLAGS-rtld.c): Add -Wno-unused. * sysdeps/m68k/dl-machine.h (elf_machine_rela): Rewritten as for i386. (elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p, ELF_MACHINE_RELOC_NOPLT): Define. 1997-03-25 03:48 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * grp/grp.h: Include <stddef.h> only once. 1997-03-25 09:38 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/termbits.h (OXTABS): Don't define. * sysdeps/unix/sysv/linux/alpha/termbits.h (OXTABS): Likewise. * termios/sys/ttydefaults.h (TTYDEF_OFLAG): Use either OXTABS or TAB3, if one of them is defined. 1997-03-26 04:53 Ulrich Drepper <drepper@cygnus.com> * posix/glob.c (next_brace_sub): Decrement depth counter when '}' is found. Patch by Dennis Henriksen <opus@flamingo.osrl.dk>. 1997-03-25 16:25 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * sunrpc/Makefile: Comment gccwarn out. * sunrpc/auth_none.c: Fix prototypes and parameters for compiling with enabled warnings. * sunrpc/auth_unix.c: Likewise. * sunrpc/authuxprot.c: Likewise. * sunrpc/bindrsvprt.c: Likewise. * sunrpc/clnt_gen.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_raw.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/get_myaddr.c: Likewise. * sunrpc/getrpcport.c: Likewise. * sunrpc/pm_getmaps.c: Likewise. * sunrpc/pm_getport.c: Likewise. * sunrpc/pmap_clnt.c: Likewise. * sunrpc/pmap_prot.c: Likewise. * sunrpc/pmap_prot2.c: Likewise. * sunrpc/pmap_rmt.c: Likewise. * sunrpc/rpc/auth.h: Likewise. * sunrpc/rpc/clnt.h: Likewise. * sunrpc/rpc/pmap_clnt.h: Likewise. * sunrpc/rpc/svc.h: Likewise. * sunrpc/rpc/svc_auth.h: Likewise. * sunrpc/rpc/types.h: Likewise. * sunrpc/rpc/xdr.h: Likewise. * sunrpc/rpc_clntout.c: Likewise. * sunrpc/rpc_cmsg.c: Likewise. * sunrpc/rpc_dtable.c: Likewise. * sunrpc/rpc_prot.c: Likewise. * sunrpc/svc.c: Likewise. * sunrpc/svc_auth.c: Likewise. * sunrpc/svc_authux.c: Likewise. * sunrpc/svc_raw.c: Likewise. * sunrpc/svc_run.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_mem.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sunrpc/xdr_stdio.c: Likewise. 1997-03-25 13:39 Ulrich Drepper <drepper@cygnus.com> * math/libm-test.c (log2_test): Compile this function and call it. (exp2_test): Likewise, but check whether function really exists before testing. * math/Makefile (libm-calls): Add s_log2 and s_exp2. 1997-03-25 04:50 Ulrich Drepper <drepper@cygnus.com> Implement exp2 function. * sysdeps/libm-i387/s_exp2.S: New file. * sysdeps/libm-i387/s_exp2f.S: New file. * sysdeps/libm-i387/s_exp2l.S: New file. Implement log2 function. * sysdeps/libm-i387/s_log2.S: New file. * sysdeps/libm-i387/s_log2f.S: New file. * sysdeps/libm-i387/s_log2l.S: New file. * sysdeps/libm-ieee754/s_log2.c: New file. * sysdeps/libm-ieee754/s_log2f.c: New file. * sysdeps/stub/s_log2.c: New file. Stub version.
This commit is contained in:
160
ChangeLog
160
ChangeLog
@ -1,3 +1,163 @@
|
||||
1997-03-27 02:28 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* gmon/gmon.c (monstartup): Mark all messages.
|
||||
(write_call_graph): Rewrite to use larger I/O vector for writev
|
||||
call to reduce syscall overhead.
|
||||
(write_bb_counts): Simplify writev handling.
|
||||
|
||||
* inet/rexec.c: Make string parameters `const'.
|
||||
* resolv/netdb.h: Add prototypes for rcmd, rexec, ruserok, and
|
||||
rresvport.
|
||||
|
||||
* math/Makefile: Don't define CFLAGS-* macros to prevent inlining
|
||||
in libm-test.
|
||||
* math/libm-test.c (this_does_nothing): Remove functions. It's
|
||||
notuseful on any platform but ix86.
|
||||
(inverse_func_pair_test): Don't use this_does_nothing. Use
|
||||
memory reference.
|
||||
(identities1_test): Likewise.
|
||||
(identities2_test): Likewise.
|
||||
(identities3_test): Likewise.
|
||||
(basic_test): Likewise.
|
||||
Patch by Andreas Schwab.
|
||||
(BUILD_COMPLEX): New macro. Create complex number from real and
|
||||
imaginary parts. This works around bugs/inefficiencies in current
|
||||
gcc.
|
||||
(cexp_test): Use BUILD_COMPLEX. Add more tests.
|
||||
|
||||
* nss/nsswitch.c: Fix typo.
|
||||
|
||||
* posix/glob.h: Add declaration for glob_pattern_p.
|
||||
* posix/glob.c: Rename glob_pattern_p to __glob_pattern_p and
|
||||
make glob_pattern_p a weak alias. This function is used in other
|
||||
packages (e.g. bash).
|
||||
|
||||
* signal/Makefile (routines): Add sigisempty, sigandset, and
|
||||
sigorset.
|
||||
* signal/signal.h: Add prototypes for sigisempty, sigandset, and
|
||||
sigorset.
|
||||
* signal/sigisempty.c: New file.
|
||||
* signal/sigandset.c: New file.
|
||||
* signal/sigorset.c: New file.
|
||||
* sysdeps/generic/sigset.h: Define __sigisemptyset, __sigandset,
|
||||
and __sigorset.
|
||||
* sysdeps/unix/sysv/linux/sigset.h: Likewise.
|
||||
|
||||
* stdlib/strtod.c: Handle `n-char-sequence' in NaN parsing. It
|
||||
determines the bits in the mantissa part of the NaN.
|
||||
* stdlib/strtof.c: Define SET_MANTISSA for float type.
|
||||
* wcsmbs/wcstof.c: Define SET_MANTISSA for float type.
|
||||
* stdlib/strtold.c: Define SET_MANTISSA for long double type.
|
||||
* wcsmbs/wcstold.c: Define SET_MANTISSA for long double type.
|
||||
|
||||
* sysdeps/libm-ieee754/s_cexp.c: Use explicit assignment to
|
||||
complex number components. Some more corrects for special cases.
|
||||
* sysdeps/libm-ieee754/s_cexpf.c: Likewise.
|
||||
* sysdeps/libm-ieee754/s_cexpl.c: Likewise.
|
||||
|
||||
* sysdeps/sparc/elf/start.S: Remove as per request of Miguel de Icaza.
|
||||
|
||||
* sysdeps/unix/sysv/linux/netinet/icmp.h: Remove since we have
|
||||
ip_icmp.h. Reported by HJ Lu.
|
||||
|
||||
1997-03-25 03:50 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* sysdeps/m68k/Makefile (CFLAGS-rtld.c): Add -Wno-unused.
|
||||
|
||||
* sysdeps/m68k/dl-machine.h (elf_machine_rela): Rewritten as for
|
||||
i386.
|
||||
(elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p,
|
||||
ELF_MACHINE_RELOC_NOPLT): Define.
|
||||
|
||||
1997-03-25 03:48 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* grp/grp.h: Include <stddef.h> only once.
|
||||
|
||||
1997-03-25 09:38 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* sysdeps/unix/sysv/linux/termbits.h (OXTABS): Don't define.
|
||||
* sysdeps/unix/sysv/linux/alpha/termbits.h (OXTABS): Likewise.
|
||||
|
||||
* termios/sys/ttydefaults.h (TTYDEF_OFLAG): Use either OXTABS or
|
||||
TAB3, if one of them is defined.
|
||||
|
||||
1997-03-26 04:53 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* posix/glob.c (next_brace_sub): Decrement depth counter when '}'
|
||||
is found.
|
||||
Patch by Dennis Henriksen <opus@flamingo.osrl.dk>.
|
||||
|
||||
1997-03-25 16:25 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
|
||||
* sunrpc/Makefile: Comment gccwarn out.
|
||||
* sunrpc/auth_none.c: Fix prototypes and parameters for compiling
|
||||
with enabled warnings.
|
||||
* sunrpc/auth_unix.c: Likewise.
|
||||
* sunrpc/authuxprot.c: Likewise.
|
||||
* sunrpc/bindrsvprt.c: Likewise.
|
||||
* sunrpc/clnt_gen.c: Likewise.
|
||||
* sunrpc/clnt_perr.c: Likewise.
|
||||
* sunrpc/clnt_raw.c: Likewise.
|
||||
* sunrpc/clnt_simp.c: Likewise.
|
||||
* sunrpc/clnt_tcp.c: Likewise.
|
||||
* sunrpc/clnt_udp.c: Likewise.
|
||||
* sunrpc/get_myaddr.c: Likewise.
|
||||
* sunrpc/getrpcport.c: Likewise.
|
||||
* sunrpc/pm_getmaps.c: Likewise.
|
||||
* sunrpc/pm_getport.c: Likewise.
|
||||
* sunrpc/pmap_clnt.c: Likewise.
|
||||
* sunrpc/pmap_prot.c: Likewise.
|
||||
* sunrpc/pmap_prot2.c: Likewise.
|
||||
* sunrpc/pmap_rmt.c: Likewise.
|
||||
* sunrpc/rpc/auth.h: Likewise.
|
||||
* sunrpc/rpc/clnt.h: Likewise.
|
||||
* sunrpc/rpc/pmap_clnt.h: Likewise.
|
||||
* sunrpc/rpc/svc.h: Likewise.
|
||||
* sunrpc/rpc/svc_auth.h: Likewise.
|
||||
* sunrpc/rpc/types.h: Likewise.
|
||||
* sunrpc/rpc/xdr.h: Likewise.
|
||||
* sunrpc/rpc_clntout.c: Likewise.
|
||||
* sunrpc/rpc_cmsg.c: Likewise.
|
||||
* sunrpc/rpc_dtable.c: Likewise.
|
||||
* sunrpc/rpc_prot.c: Likewise.
|
||||
* sunrpc/svc.c: Likewise.
|
||||
* sunrpc/svc_auth.c: Likewise.
|
||||
* sunrpc/svc_authux.c: Likewise.
|
||||
* sunrpc/svc_raw.c: Likewise.
|
||||
* sunrpc/svc_run.c: Likewise.
|
||||
* sunrpc/svc_simple.c: Likewise.
|
||||
* sunrpc/svc_tcp.c: Likewise.
|
||||
* sunrpc/svc_udp.c: Likewise.
|
||||
* sunrpc/xdr.c: Likewise.
|
||||
* sunrpc/xdr_array.c: Likewise.
|
||||
* sunrpc/xdr_mem.c: Likewise.
|
||||
* sunrpc/xdr_rec.c: Likewise.
|
||||
* sunrpc/xdr_ref.c: Likewise.
|
||||
* sunrpc/xdr_stdio.c: Likewise.
|
||||
|
||||
1997-03-25 13:39 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* math/libm-test.c (log2_test): Compile this function and call it.
|
||||
(exp2_test): Likewise, but check whether function really exists
|
||||
before testing.
|
||||
|
||||
* math/Makefile (libm-calls): Add s_log2 and s_exp2.
|
||||
|
||||
1997-03-25 04:50 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
Implement exp2 function.
|
||||
* sysdeps/libm-i387/s_exp2.S: New file.
|
||||
* sysdeps/libm-i387/s_exp2f.S: New file.
|
||||
* sysdeps/libm-i387/s_exp2l.S: New file.
|
||||
|
||||
Implement log2 function.
|
||||
* sysdeps/libm-i387/s_log2.S: New file.
|
||||
* sysdeps/libm-i387/s_log2f.S: New file.
|
||||
* sysdeps/libm-i387/s_log2l.S: New file.
|
||||
* sysdeps/libm-ieee754/s_log2.c: New file.
|
||||
* sysdeps/libm-ieee754/s_log2f.c: New file.
|
||||
* sysdeps/stub/s_log2.c: New file. Stub version.
|
||||
|
||||
1997-03-24 19:58 Richard Henderson <rth@tamu.edu>
|
||||
|
||||
* stdlib/tst-strtol.c (tests): Correct 64-bit entry.
|
||||
|
2
PROJECTS
2
PROJECTS
@ -1,6 +1,6 @@
|
||||
Open jobs for finishing GNU libc:
|
||||
---------------------------------
|
||||
Status: January 1997
|
||||
Status: March 1997
|
||||
|
||||
If you have time and talent to take over any of the jobs below please
|
||||
contact <bug-glibc@prep.ai.mit.edu>
|
||||
|
49
gmon/gmon.c
49
gmon/gmon.c
@ -125,7 +125,7 @@ monstartup (lowpc, highpc)
|
||||
cp = malloc (p->kcountsize + p->fromssize + p->tossize);
|
||||
if (! cp)
|
||||
{
|
||||
ERR("monstartup: out of memory\n");
|
||||
ERR(_("monstartup: out of memory\n"));
|
||||
return;
|
||||
}
|
||||
bzero(cp, p->kcountsize + p->fromssize + p->tossize);
|
||||
@ -194,25 +194,25 @@ static void
|
||||
write_call_graph (fd)
|
||||
int fd;
|
||||
{
|
||||
#define NARCS_PER_WRITEV 32
|
||||
u_char tag = GMON_TAG_CG_ARC;
|
||||
struct gmon_cg_arc_record raw_arc[4]
|
||||
struct gmon_cg_arc_record raw_arc[NARCS_PER_WRITEV]
|
||||
__attribute__ ((aligned (__alignof__ (char*))));
|
||||
int from_index, to_index, from_len;
|
||||
u_long frompc;
|
||||
struct iovec iov[2 * NARCS_PER_WRITEV];
|
||||
int nfilled;
|
||||
|
||||
struct iovec iov[8] =
|
||||
for (nfilled = 0; nfilled < NARCS_PER_WRITEV; ++nfilled)
|
||||
{
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[0], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[1], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[2], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[3], sizeof (struct gmon_cg_arc_record) },
|
||||
};
|
||||
int nfilled = 0;
|
||||
iov[2 * nfilled].iov_base = &tag;
|
||||
iov[2 * nfilled].iov_len = sizeof (tag);
|
||||
|
||||
iov[2 * nfilled + 1].iov_base = &raw_arc[nfilled];
|
||||
iov[2 * nfilled + 1].iov_len = sizeof (struct gmon_cg_arc_record);
|
||||
}
|
||||
|
||||
nfilled = 0;
|
||||
from_len = _gmonparam.fromssize / sizeof (*_gmonparam.froms);
|
||||
for (from_index = 0; from_index < from_len; ++from_index)
|
||||
{
|
||||
@ -226,18 +226,19 @@ write_call_graph (fd)
|
||||
to_index != 0;
|
||||
to_index = _gmonparam.tos[to_index].link)
|
||||
{
|
||||
if (nfilled > 3)
|
||||
{
|
||||
__writev (fd, iov, 2 * nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
*(char **) raw_arc[nfilled].from_pc = (char *) frompc;
|
||||
*(char **) raw_arc[nfilled].self_pc =
|
||||
(char *)_gmonparam.tos[to_index].selfpc;
|
||||
*(int *) raw_arc[nfilled].count = _gmonparam.tos[to_index].count;
|
||||
++nfilled;
|
||||
|
||||
if (++nfilled == NARCS_PER_WRITEV)
|
||||
{
|
||||
__writev (fd, iov, 2 * nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nfilled > 0)
|
||||
__writev (fd, iov, 2 * nfilled);
|
||||
}
|
||||
|
||||
@ -268,17 +269,11 @@ write_bb_counts (fd)
|
||||
/* Write each group of basic-block info (all basic-blocks in a
|
||||
compilation unit form a single group). */
|
||||
|
||||
nfilled = 0;
|
||||
for (grp = __bb_head; grp; grp = grp->next)
|
||||
{
|
||||
ncounts = grp->ncounts;
|
||||
if (nfilled > 0)
|
||||
{
|
||||
__writev (fd, bbbody, nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
__writev (fd, bbhead, 2);
|
||||
for (i = 0; i < ncounts; ++i)
|
||||
for (nfilled = i = 0; i < ncounts; ++i)
|
||||
{
|
||||
if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2)
|
||||
{
|
||||
@ -289,10 +284,10 @@ write_bb_counts (fd)
|
||||
bbbody[nfilled++].iov_base = (char *) &grp->addresses[i];
|
||||
bbbody[nfilled++].iov_base = &grp->counts[i];
|
||||
}
|
||||
}
|
||||
if (nfilled > 0)
|
||||
__writev (fd, bbbody, nfilled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
@ -32,9 +32,6 @@ __BEGIN_DECLS
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* The group structure. */
|
||||
struct group
|
||||
|
@ -53,7 +53,7 @@ int
|
||||
rexec(ahost, rport, name, pass, cmd, fd2p)
|
||||
char **ahost;
|
||||
int rport;
|
||||
char *name, *pass, *cmd;
|
||||
const char *name, *pass, *cmd;
|
||||
int *fd2p;
|
||||
{
|
||||
struct sockaddr_in sin, sin2, from;
|
||||
|
@ -48,7 +48,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
|
||||
w_gamma_r w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
|
||||
w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
|
||||
s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
|
||||
s_remquo \
|
||||
s_remquo s_log2 s_exp2 \
|
||||
conj cimag creal cabs s_cexp
|
||||
libm-routines = $(libm-support) $(libm-calls) \
|
||||
$(patsubst %_rf,%f_r,$(libm-calls:=f)) \
|
||||
@ -73,9 +73,6 @@ tests = test-float test-double $(test-longdouble-$(long-double-fcts))
|
||||
# XXX This test is disabled for now since the functions are too buggy.
|
||||
#test-longdouble-yes = test-longdouble
|
||||
|
||||
CFLAGS-test-float.c = -fno-inline
|
||||
CFLAGS-test-double.c = -fno-inline
|
||||
CFLAGS-test-longdouble.c = -fno-inline
|
||||
LDLIBS-test-float = libm
|
||||
LDLIBS-test-double = libm
|
||||
LDLIBS-test-longdouble = libm
|
||||
|
147
math/libm-test.c
147
math/libm-test.c
@ -63,10 +63,6 @@
|
||||
-s,--silent outputs only the error count (equals --verbose=0)
|
||||
*/
|
||||
|
||||
/* Define if the following ISO C 9X functions are implemented: exp2,
|
||||
log2. */
|
||||
#undef ISO_9X_IMPLEMENTED
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
@ -103,6 +99,12 @@ static MATHTYPE plus_infty, minus_infty, nan_value;
|
||||
|
||||
typedef MATHTYPE (*mathfunc) (MATHTYPE);
|
||||
|
||||
#define BUILD_COMPLEX(real, imag) \
|
||||
({ __complex__ MATHTYPE __retval; \
|
||||
__real__ __retval = (real); \
|
||||
__imag__ __retval = (imag); \
|
||||
__retval; })
|
||||
|
||||
|
||||
#define ISINF(x) \
|
||||
(sizeof (x) == sizeof (float) ? \
|
||||
@ -135,18 +137,6 @@ asm ("fnstsw":"=a" (sw));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Call to an external function so that floating point registers
|
||||
get moved to memory
|
||||
*/
|
||||
static void
|
||||
this_does_nothing (void)
|
||||
{
|
||||
clock_t dummy;
|
||||
|
||||
dummy = clock ();
|
||||
}
|
||||
|
||||
/*
|
||||
Get a random value x with min_value < x < max_value
|
||||
and min_value, max_value finite,
|
||||
@ -644,10 +634,15 @@ exp_test (void)
|
||||
}
|
||||
|
||||
|
||||
#ifdef ISO_9X_IMPLEMENTED
|
||||
static void
|
||||
exp2_test (void)
|
||||
{
|
||||
errno = 0;
|
||||
exp2(0);
|
||||
if (errno == ENOSYS)
|
||||
/* Function not implemented. */
|
||||
return;
|
||||
|
||||
check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
|
||||
check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
|
||||
|
||||
@ -655,7 +650,6 @@ exp2_test (void)
|
||||
check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
|
||||
check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
@ -892,7 +886,6 @@ log1p_test (void)
|
||||
}
|
||||
|
||||
|
||||
#ifdef ISO_9X_IMPLEMENTED
|
||||
static void
|
||||
log2_test (void)
|
||||
{
|
||||
@ -914,7 +907,6 @@ log2_test (void)
|
||||
check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
@ -1540,32 +1532,92 @@ cexp_test (void)
|
||||
{
|
||||
__complex__ MATHTYPE result;
|
||||
|
||||
result = FUNC(cexp) (plus_zero + 1.0i * plus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
|
||||
check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_zero + 1.0i * plus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
|
||||
check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (plus_zero + 1.0i * minus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
|
||||
check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(0 - 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_zero + 1.0i * minus_zero);
|
||||
check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
|
||||
check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(-0 - 0i)) = 0", __imag__ result, 0);
|
||||
check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
|
||||
|
||||
result = FUNC(cexp) (plus_infty + 1.0i * plus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
|
||||
check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
|
||||
check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (plus_infty + 1.0i * minus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
|
||||
check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
|
||||
check ("imag(cexp(+inf - 0i)) = 0", __imag__ result, 0);
|
||||
|
||||
result = FUNC(cexp) (minus_infty + 1.0i * plus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
|
||||
check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_infty + 1.0i * minus_zero);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
|
||||
check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf - 0i)) = 0", __imag__ result, 0);
|
||||
check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
|
||||
check_isnan ("real(cexp(x + i inf)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(x + i inf)) = NaN", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
|
||||
check_isnan ("real(cexp(x - i inf)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(x - i inf)) = NaN", __imag__ result);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
|
||||
check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
|
||||
check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
|
||||
check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
|
||||
check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
|
||||
check_isinfn ("real(cexp(+inf + 2.0i)) = -0", __real__ result);
|
||||
check_isinfp ("imag(cexp(+inf + 2.0i)) = 0", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
|
||||
check_isinfn ("real(cexp(+inf + 4.0i)) = -0", __real__ result);
|
||||
check_isinfn ("imag(cexp(+inf + 4.0i)) = -0", __imag__ result);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
|
||||
check_isinfp ("real(cexp(+inf + i inf)) = +inf", __real__ result);
|
||||
check_isnan ("imag(cexp(+inf + i inf)) = NaN", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
|
||||
check_isinfp ("real(cexp(+inf - i inf)) = +inf", __real__ result);
|
||||
check_isnan ("imag(cexp(+inf - i inf)) = NaN", __imag__ result);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
|
||||
check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
|
||||
check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf - i inf)) = 0", __imag__ result, 0);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
|
||||
check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
|
||||
check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
|
||||
check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
|
||||
check_isnan ("real(cexp(NaN + 1i)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(NaN + 1i)) = NaN", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
|
||||
check_isnan ("real(cexp(NaN + i inf)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(NaN + i inf)) = NaN", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
|
||||
check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
|
||||
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
|
||||
check_isnan ("real(cexp(0 + i NaN)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(0 + i NaN)) = NaN", __imag__ result);
|
||||
result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
|
||||
check_isnan ("real(cexp(1 + i NaN)) = NaN", __real__ result);
|
||||
check_isnan ("imag(cexp(1 + i NaN)) = NaN", __imag__ result);
|
||||
}
|
||||
|
||||
|
||||
@ -1578,9 +1630,9 @@ inverse_func_pair_test (const char *test_name,
|
||||
int result;
|
||||
|
||||
a = f1 (x);
|
||||
this_does_nothing ();
|
||||
(void) &a;
|
||||
b = inverse (a);
|
||||
this_does_nothing ();
|
||||
(void) &b;
|
||||
|
||||
result = check_equal (b, x, epsilon, &difference);
|
||||
output_result (test_name, result,
|
||||
@ -1630,11 +1682,11 @@ identities1_test (MATHTYPE x, MATHTYPE epsilon)
|
||||
int result;
|
||||
|
||||
res1 = FUNC(sin) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res1;
|
||||
res2 = FUNC(cos) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res2;
|
||||
res3 = res1 * res1 + res2 * res2;
|
||||
this_does_nothing ();
|
||||
(void) &res3;
|
||||
|
||||
result = check_equal (res3, 1.0, epsilon, &diff);
|
||||
output_result_ext ("sin^2 + cos^2 == 1", result,
|
||||
@ -1650,13 +1702,13 @@ identities2_test (MATHTYPE x, MATHTYPE epsilon)
|
||||
int result;
|
||||
|
||||
res1 = FUNC(sin) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res1;
|
||||
res2 = FUNC(cos) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res2;
|
||||
res3 = FUNC(tan) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res3;
|
||||
res4 = res1 / res2;
|
||||
this_does_nothing ();
|
||||
(void) &res4;
|
||||
|
||||
result = check_equal (res4, res3, epsilon, &diff);
|
||||
output_result_ext ("sin/cos == tan", result,
|
||||
@ -1672,11 +1724,11 @@ identities3_test (MATHTYPE x, MATHTYPE epsilon)
|
||||
int result;
|
||||
|
||||
res1 = FUNC(sinh) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res1;
|
||||
res2 = FUNC(cosh) (x);
|
||||
this_does_nothing ();
|
||||
(void) &res2;
|
||||
res3 = res2 * res2 - res1 * res1;
|
||||
this_does_nothing ();
|
||||
(void) &res3;
|
||||
|
||||
result = check_equal (res3, 1.0, epsilon, &diff);
|
||||
output_result_ext ("cosh^2 - sinh^2 == 1", result,
|
||||
@ -1721,7 +1773,10 @@ basic_tests (void)
|
||||
NaN_var = nan_value;
|
||||
Inf_var = one_var / zero_var;
|
||||
|
||||
this_does_nothing ();
|
||||
(void) &zero_var;
|
||||
(void) &one_var;
|
||||
(void) &NaN_var;
|
||||
(void) &Inf_var;
|
||||
|
||||
check_isinfp ("isinf (inf) == +1", Inf_var);
|
||||
check_isinfn ("isinf (-inf) == -1", -Inf_var);
|
||||
@ -1854,9 +1909,7 @@ main (int argc, char *argv[])
|
||||
cos_test ();
|
||||
cosh_test ();
|
||||
exp_test ();
|
||||
#ifdef ISO_9X_IMPLEMENTED
|
||||
exp2_test ();
|
||||
#endif
|
||||
expm1_test ();
|
||||
frexp_test ();
|
||||
ilogb_test ();
|
||||
@ -1864,9 +1917,7 @@ main (int argc, char *argv[])
|
||||
log_test ();
|
||||
log10_test ();
|
||||
log1p_test ();
|
||||
#ifdef ISO_9X_IMPLEMENTED
|
||||
log2_test ();
|
||||
#endif
|
||||
logb_test ();
|
||||
modf_test ();
|
||||
scalb_test ();
|
||||
|
@ -106,8 +106,8 @@ __nss_database_lookup (const char *database, const char *alternate_name,
|
||||
*ni = entry->service;
|
||||
|
||||
if (*ni == NULL && alternate_name != NULL)
|
||||
/* We haven't found a an entry so far. Try to find it with
|
||||
the alternative name. */
|
||||
/* We haven't found an entry so far. Try to find it with the
|
||||
alternative name. */
|
||||
for (entry = service_table->entry; entry != NULL; entry = entry->next)
|
||||
if (strcmp (alternate_name, entry->name) == 0)
|
||||
*ni = entry->service;
|
||||
|
16
posix/glob.c
16
posix/glob.c
@ -250,7 +250,6 @@ extern char *alloca ();
|
||||
#undef GLOB_PERIOD
|
||||
#include <glob.h>
|
||||
|
||||
static int glob_pattern_p __P ((const char *pattern, int quote));
|
||||
static int glob_in_dir __P ((const char *pattern, const char *directory,
|
||||
int flags,
|
||||
int (*errfunc) __P ((const char *, int)),
|
||||
@ -288,7 +287,7 @@ next_brace_sub (const char *begin)
|
||||
while (*cp != '\0' && (*cp != '}' || depth > 0))
|
||||
{
|
||||
if (*cp == '}')
|
||||
++depth;
|
||||
--depth;
|
||||
++cp;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
@ -617,7 +616,7 @@ glob (pattern, flags, errfunc, pglob)
|
||||
}
|
||||
#endif /* Not VMS. */
|
||||
|
||||
if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
|
||||
if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
|
||||
{
|
||||
/* The directory name contains metacharacters, so we
|
||||
have to glob for the directory, and then glob for
|
||||
@ -844,8 +843,8 @@ prefix_array (dirname, array, n)
|
||||
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
|
||||
static int
|
||||
glob_pattern_p (pattern, quote)
|
||||
int
|
||||
__glob_pattern_p (pattern, quote)
|
||||
const char *pattern;
|
||||
int quote;
|
||||
{
|
||||
@ -876,6 +875,9 @@ glob_pattern_p (pattern, quote)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__glob_pattern_p, glob_pattern_p)
|
||||
#endif
|
||||
|
||||
|
||||
/* Like `glob', but PATTERN is a final pathname component,
|
||||
@ -900,7 +902,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
struct globlink *names = NULL;
|
||||
size_t nfound = 0;
|
||||
|
||||
if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
|
||||
if (!__glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
|
||||
{
|
||||
stream = NULL;
|
||||
flags |= GLOB_NOCHECK;
|
||||
@ -958,7 +960,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
}
|
||||
|
||||
if (nfound == 0 && (flags & GLOB_NOMAGIC) &&
|
||||
! glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
|
||||
! __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
|
||||
flags |= GLOB_NOCHECK;
|
||||
|
||||
if (nfound == 0 && (flags & GLOB_NOCHECK))
|
||||
|
12
posix/glob.h
12
posix/glob.h
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@ -104,6 +104,16 @@ extern int glob __P ((const char *__pattern, int __flags,
|
||||
extern void globfree __P ((glob_t *__pglob));
|
||||
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero.
|
||||
|
||||
This function is not part of the interface specified by POSIX.2
|
||||
but several programs want to use it. */
|
||||
extern int __glob_pattern_p __P ((__const char *__pattern, int __quote));
|
||||
extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -364,6 +364,39 @@ extern int getnetgrent_r __P ((char **__hostp, char **__userp,
|
||||
#endif /* misc */
|
||||
|
||||
|
||||
#ifdef __USE_BSD
|
||||
/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
|
||||
The local user is LOCUSER, on the remote machine the command is
|
||||
executed as REMUSER. In *FD2P the descriptor to the socket for the
|
||||
connection is returned. The caller must have the right to use a
|
||||
reserved port. When the function returns *AHOST contains the
|
||||
official host name. */
|
||||
extern int rcmd __P ((char **__ahost, unsigned short int __rport,
|
||||
__const char *__locuser, __const char *__remuser,
|
||||
__const char *__cmd, int *__fd2p));
|
||||
|
||||
/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
|
||||
CMD. The process runs at the remote machine using the ID of user
|
||||
NAME whose cleartext password is PASSWD. In *FD2P the descriptor
|
||||
to the socket for the connection is returned. When the function
|
||||
returns *AHOST contains the official host name. */
|
||||
extern int rexec __P ((char **__ahost, int __rport, __const char *__name,
|
||||
__const char *__pass, __const char *__cmd,
|
||||
int *__fd2p));
|
||||
|
||||
/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
|
||||
If SUSER is not zero the user tries to become superuser. Return 0 if
|
||||
it is possible. */
|
||||
extern int ruserok __P ((__const char *__rhost, int __suser,
|
||||
__const char *__remuser, __const char *__locuser));
|
||||
|
||||
/* Try to allocate reserved port, returning a descriptor for a socket opened
|
||||
at this port or -1 if unsuccessful. The search for an available port
|
||||
will start at ALPORT and continues with lower numbers. */
|
||||
extern int rresvport __P ((int *__alport));
|
||||
#endif
|
||||
|
||||
|
||||
/* Extension from POSIX.1g. */
|
||||
#ifdef __USE_POSIX
|
||||
/* Structure to contain information about address of a service provider. */
|
||||
|
@ -30,7 +30,8 @@ routines := signal raise killpg \
|
||||
sigstack sigaltstack sigintr \
|
||||
sigsetops sigempty sigfillset sigaddset sigdelset sigismem \
|
||||
sigreturn \
|
||||
siggetmask sysv_signal
|
||||
siggetmask sysv_signal \
|
||||
sigisempty sigandset sigorset
|
||||
|
||||
tests := tst-signal
|
||||
|
||||
|
36
signal/sigandset.c
Normal file
36
signal/sigandset.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 1991, 1996, 1997 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 <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Combine sets LEFT and RIGHT by logical AND and place result in DEST. */
|
||||
int
|
||||
sigandset (dest, left, right)
|
||||
sigset_t *dest;
|
||||
const sigset_t *left;
|
||||
const sigset_t *right;
|
||||
{
|
||||
if (dest == NULL || left == NULL || right == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return __sigandset (dest, left, right);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1996, 1997 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
|
||||
@ -16,10 +16,19 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _NETINET_ICMP_H
|
||||
#define _NETINET_ICMP_H 1
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <linux/icmp.h>
|
||||
/* Test whether SET is empty. */
|
||||
int
|
||||
sigisemptyset (set)
|
||||
const sigset_t *set;
|
||||
{
|
||||
if (set == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* netinet/icmp.h */
|
||||
return __sigisemptyset (set);
|
||||
}
|
@ -183,6 +183,19 @@ extern int sigdelset __P ((sigset_t *__set, int __signo));
|
||||
/* Return 1 if SIGNO is in SET, 0 if not. */
|
||||
extern int sigismember __P ((__const sigset_t *__set, int __signo));
|
||||
|
||||
#ifdef __USE_GNU
|
||||
/* Return non-empty value is SET is not empty. */
|
||||
extern int sigisemptyset __P ((__const sigset_t *__set));
|
||||
|
||||
/* Build new signal set by combining the two inputs set using logical AND. */
|
||||
extern int sigandset __P ((sigset_t *__set, __const sigset_t *__left,
|
||||
__const sigset_t *__right));
|
||||
|
||||
/* Build new signal set by combining the two inputs set using logical OR. */
|
||||
extern int sigorset __P ((sigset_t *__set, __const sigset_t *__left,
|
||||
__const sigset_t *__right));
|
||||
#endif /* GNU */
|
||||
|
||||
/* Get the system-specific definitions of `struct sigaction'
|
||||
and the `SA_*' and `SIG_*'. constants. */
|
||||
#include <sigaction.h>
|
||||
|
36
signal/sigorset.c
Normal file
36
signal/sigorset.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 1991, 1996, 1997 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 <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Combine sets LEFT and RIGHT by logical OR and place result in DEST. */
|
||||
int
|
||||
sigorset (dest, left, right)
|
||||
sigset_t *dest;
|
||||
const sigset_t *left;
|
||||
const sigset_t *right;
|
||||
{
|
||||
if (dest == NULL || left == NULL || right == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return __sigorset (dest, left, right);
|
||||
}
|
@ -31,6 +31,12 @@
|
||||
# endif
|
||||
# define MPN2FLOAT __mpn_construct_double
|
||||
# define FLOAT_HUGE_VAL HUGE_VAL
|
||||
# define SET_MANTISSA(flt, mant) \
|
||||
do { union ieee754_double u; \
|
||||
u.d = (flt); \
|
||||
u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff; \
|
||||
u.ieee.mantissa1 = (mant) & 0xffffffff; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIDE_CHAR
|
||||
@ -44,6 +50,7 @@
|
||||
# define ISXDIGIT(Ch) iswxdigit (Ch)
|
||||
# define TOLOWER(Ch) towlower (Ch)
|
||||
# define STRNCASECMP(S1, S2, N) __wcsncasecmp ((S1), (S2), (N))
|
||||
# define STRTOULL(S, E, B) wcstoull ((S), (E), (B))
|
||||
#else
|
||||
# define STRING_TYPE char
|
||||
# define CHAR_TYPE char
|
||||
@ -53,6 +60,7 @@
|
||||
# define ISXDIGIT(Ch) isxdigit (Ch)
|
||||
# define TOLOWER(Ch) tolower (Ch)
|
||||
# define STRNCASECMP(S1, S2, N) __strncasecmp ((S1), (S2), (N))
|
||||
# define STRTOULL(S, E, B) strtoull ((S), (E), (B))
|
||||
#endif
|
||||
/* End of configuration part. */
|
||||
|
||||
@ -461,6 +469,8 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
|
||||
if (TOLOWER (c) == L_('n') && STRNCASECMP (cp, L_("an"), 2) == 0)
|
||||
{
|
||||
FLOAT retval = NAN;
|
||||
|
||||
/* Return NaN. */
|
||||
if (endptr != NULL)
|
||||
{
|
||||
@ -480,12 +490,25 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
/* The closing brace is missing. Only match the NAN
|
||||
part. */
|
||||
cp = startp;
|
||||
else
|
||||
{
|
||||
/* This is a system-dependent way to specify the
|
||||
bitmask used for the NaN. We expect it to be
|
||||
a number which is put in the mantissa of the
|
||||
number. */
|
||||
STRING_TYPE *endp;
|
||||
unsigned long long int mant;
|
||||
|
||||
mant = STRTOULL (startp, &endp, 0);
|
||||
if (endp == cp)
|
||||
SET_MANTISSA (retval, mant);
|
||||
}
|
||||
}
|
||||
|
||||
*endptr = (STRING_TYPE *) cp;
|
||||
}
|
||||
|
||||
return NAN;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* It is really a text we do not recognize. */
|
||||
|
@ -6,5 +6,11 @@
|
||||
#define STRTOF strtof
|
||||
#define MPN2FLOAT __mpn_construct_float
|
||||
#define FLOAT_HUGE_VAL HUGE_VALF
|
||||
#define SET_MANTISSA(flt, mant) \
|
||||
do { union ieee754_float u; \
|
||||
u.f = (flt); \
|
||||
u.ieee.mantissa = (mant) & 0x7fffff; \
|
||||
(flt) = u.f; \
|
||||
} while (0)
|
||||
|
||||
#include "strtod.c"
|
||||
|
@ -6,5 +6,12 @@
|
||||
#define STRTOF strtold
|
||||
#define MPN2FLOAT __mpn_construct_long_double
|
||||
#define FLOAT_HUGE_VAL HUGE_VALL
|
||||
#define SET_MANTISSA(flt, mant) \
|
||||
do { union ieee854_long_double u; \
|
||||
u.d = (flt); \
|
||||
u.ieee.mantissa0 = ((mant) >> 32) & 0x7fffffff; \
|
||||
u.ieee.mantissa1 = (mant) & 0xffffffff; \
|
||||
(flt) = u.d; \
|
||||
} while (0)
|
||||
|
||||
#include "strtod.c"
|
||||
|
@ -80,9 +80,6 @@ extra-objs = $(rpcgen-objs)
|
||||
|
||||
all: # Make this the default target; it will be defined in Rules.
|
||||
|
||||
# Sun's code is not too clean.
|
||||
override +gccwarn := -w
|
||||
|
||||
include ../Makeconfig
|
||||
|
||||
ifeq (no,$(cross-compiling))
|
||||
@ -96,6 +93,19 @@ librpcsvc-inhibit-o = .so # Build no shared rpcsvc library.
|
||||
omit-deps = $(librpcsvc-routines)
|
||||
endif
|
||||
|
||||
CFLAGS-xbootparam.c = -Wno-unused
|
||||
CFLAGS-xnlm_prot.c = -Wno-unused
|
||||
CFLAGS-xrstat.c = -Wno-unused
|
||||
CFLAGS-xyppasswd.c = -Wno-unused
|
||||
CFLAGS-xklm_prot.c = -Wno-unused
|
||||
CFLAGS-xrex.c = -Wno-unused
|
||||
CFLAGS-xsm_inter.c = -Wno-unused
|
||||
CFLAGS-xmount.c = -Wno-unused
|
||||
CFLAGS-xrusers.c = -Wno-unused
|
||||
CFLAGS-xspray.c = -Wno-unused
|
||||
CFLAGS-xnfs_prot.c = -Wno-unused
|
||||
CFLAGS-xrquote.c = -Wno-unused
|
||||
|
||||
include ../Rules
|
||||
|
||||
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) $(common-objpfx)libc.a
|
||||
|
@ -40,20 +40,23 @@ static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpc/auth.h>
|
||||
|
||||
#define MAX_MARSHEL_SIZE 20
|
||||
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
/*
|
||||
* Authenticator operations routines
|
||||
*/
|
||||
static void authnone_verf();
|
||||
static void authnone_destroy();
|
||||
static bool_t authnone_marshal();
|
||||
static bool_t authnone_validate();
|
||||
static bool_t authnone_refresh();
|
||||
static void authnone_verf (AUTH *);
|
||||
static void authnone_destroy (AUTH *);
|
||||
static bool_t authnone_marshal (AUTH *, XDR *);
|
||||
static bool_t authnone_validate (AUTH *, struct opaque_auth *);
|
||||
static bool_t authnone_refresh (AUTH *);
|
||||
|
||||
static struct auth_ops ops = {
|
||||
static struct auth_ops ops =
|
||||
{
|
||||
authnone_verf,
|
||||
authnone_marshal,
|
||||
authnone_validate,
|
||||
@ -61,26 +64,30 @@ static struct auth_ops ops = {
|
||||
authnone_destroy
|
||||
};
|
||||
|
||||
static struct authnone_private {
|
||||
static struct authnone_private
|
||||
{
|
||||
AUTH no_client;
|
||||
char marshalled_client[MAX_MARSHEL_SIZE];
|
||||
u_int mcnt;
|
||||
} *authnone_private;
|
||||
}
|
||||
*authnone_private;
|
||||
|
||||
AUTH *
|
||||
authnone_create()
|
||||
authnone_create (void)
|
||||
{
|
||||
register struct authnone_private *ap = authnone_private;
|
||||
struct authnone_private *ap = authnone_private;
|
||||
XDR xdr_stream;
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
|
||||
if (ap == 0) {
|
||||
if (ap == 0)
|
||||
{
|
||||
ap = (struct authnone_private *) calloc (1, sizeof (*ap));
|
||||
if (ap == 0)
|
||||
return (0);
|
||||
return NULL;
|
||||
authnone_private = ap;
|
||||
}
|
||||
if (!ap->mcnt) {
|
||||
if (!ap->mcnt)
|
||||
{
|
||||
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
|
||||
ap->no_client.ah_ops = &ops;
|
||||
xdrs = &xdr_stream;
|
||||
@ -96,11 +103,9 @@ authnone_create()
|
||||
|
||||
/*ARGSUSED */
|
||||
static bool_t
|
||||
authnone_marshal(client, xdrs)
|
||||
AUTH *client;
|
||||
XDR *xdrs;
|
||||
authnone_marshal (AUTH *client, XDR *xdrs)
|
||||
{
|
||||
register struct authnone_private *ap = authnone_private;
|
||||
struct authnone_private *ap = authnone_private;
|
||||
|
||||
if (ap == 0)
|
||||
return (0);
|
||||
@ -109,25 +114,23 @@ authnone_marshal(client, xdrs)
|
||||
}
|
||||
|
||||
static void
|
||||
authnone_verf()
|
||||
authnone_verf (AUTH *auth)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t
|
||||
authnone_validate()
|
||||
authnone_validate (AUTH *auth, struct opaque_auth *oa)
|
||||
{
|
||||
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
authnone_refresh()
|
||||
authnone_refresh (AUTH *auth)
|
||||
{
|
||||
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
authnone_destroy()
|
||||
authnone_destroy (AUTH *auth)
|
||||
{
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -53,16 +54,19 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <rpc/auth.h>
|
||||
#include <rpc/auth_unix.h>
|
||||
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
/*
|
||||
* Unix authenticator operations vector
|
||||
*/
|
||||
static void authunix_nextverf();
|
||||
static bool_t authunix_marshal();
|
||||
static bool_t authunix_validate();
|
||||
static bool_t authunix_refresh();
|
||||
static void authunix_destroy();
|
||||
static void authunix_nextverf (AUTH *);
|
||||
static bool_t authunix_marshal (AUTH *, XDR *);
|
||||
static bool_t authunix_validate (AUTH *, struct opaque_auth *);
|
||||
static bool_t authunix_refresh (AUTH *);
|
||||
static void authunix_destroy (AUTH *);
|
||||
|
||||
static struct auth_ops auth_unix_ops = {
|
||||
static struct auth_ops auth_unix_ops =
|
||||
{
|
||||
authunix_nextverf,
|
||||
authunix_marshal,
|
||||
authunix_validate,
|
||||
@ -73,7 +77,8 @@ static struct auth_ops auth_unix_ops = {
|
||||
/*
|
||||
* This struct is pointed to by the ah_private field of an auth_handle.
|
||||
*/
|
||||
struct audata {
|
||||
struct audata
|
||||
{
|
||||
struct opaque_auth au_origcred; /* original credentials */
|
||||
struct opaque_auth au_shcred; /* short hand cred */
|
||||
u_long au_shfaults; /* short hand cache faults */
|
||||
@ -82,7 +87,7 @@ struct audata {
|
||||
};
|
||||
#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private)
|
||||
|
||||
static bool_t marshal_new_auth();
|
||||
static bool_t marshal_new_auth (AUTH *);
|
||||
|
||||
|
||||
/*
|
||||
@ -94,33 +99,31 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
char *machname;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
register int len;
|
||||
int len;
|
||||
gid_t *aup_gids;
|
||||
{
|
||||
struct authunix_parms aup;
|
||||
char mymem[MAX_AUTH_BYTES];
|
||||
struct timeval now;
|
||||
XDR xdrs;
|
||||
register AUTH *auth;
|
||||
register struct audata *au;
|
||||
AUTH *auth;
|
||||
struct audata *au;
|
||||
|
||||
/*
|
||||
* Allocate and set up auth handle
|
||||
*/
|
||||
auth = (AUTH *) mem_alloc (sizeof (*auth));
|
||||
#ifndef KERNEL
|
||||
if (auth == NULL) {
|
||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
||||
return (NULL);
|
||||
if (auth == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("authunix_create: out of memory\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
au = (struct audata *) mem_alloc (sizeof (*au));
|
||||
#ifndef KERNEL
|
||||
if (au == NULL) {
|
||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
||||
return (NULL);
|
||||
if (au == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("authunix_create: out of memory\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
auth->ah_ops = &auth_unix_ops;
|
||||
auth->ah_private = (caddr_t) au;
|
||||
auth->ah_verf = au->au_shcred = _null_auth;
|
||||
@ -145,14 +148,11 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
abort ();
|
||||
au->au_origcred.oa_length = len = XDR_GETPOS (&xdrs);
|
||||
au->au_origcred.oa_flavor = AUTH_UNIX;
|
||||
#ifdef KERNEL
|
||||
au->au_origcred.oa_base = mem_alloc((u_int) len);
|
||||
#else
|
||||
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
|
||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
||||
return (NULL);
|
||||
if ((au->au_origcred.oa_base = mem_alloc ((u_int) len)) == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("authunix_create: out of memory\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
bcopy (mymem, au->au_origcred.oa_base, (u_int) len);
|
||||
|
||||
/*
|
||||
@ -160,7 +160,7 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
*/
|
||||
auth->ah_cred = au->au_origcred;
|
||||
marshal_new_auth (auth);
|
||||
return (auth);
|
||||
return auth;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -168,12 +168,12 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
* syscalls.
|
||||
*/
|
||||
AUTH *
|
||||
authunix_create_default()
|
||||
authunix_create_default (void)
|
||||
{
|
||||
register int len;
|
||||
int len;
|
||||
char machname[MAX_MACHINE_NAME + 1];
|
||||
register uid_t uid;
|
||||
register gid_t gid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
int max_nr_groups = sysconf (_SC_NGROUPS_MAX);
|
||||
gid_t gids[max_nr_groups];
|
||||
|
||||
@ -188,7 +188,7 @@ authunix_create_default()
|
||||
/* This braindamaged Sun code forces us here to truncate the
|
||||
list of groups to NGRPS members since the code in
|
||||
authuxprot.c transforms a fixed array. Grrr. */
|
||||
return (authunix_create(machname, uid, gid, MIN (NGRPS, len), gids));
|
||||
return authunix_create (machname, uid, gid, MIN (NGRPS, len), gids);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -196,43 +196,43 @@ authunix_create_default()
|
||||
*/
|
||||
|
||||
static void
|
||||
authunix_nextverf(auth)
|
||||
AUTH *auth;
|
||||
authunix_nextverf (AUTH *auth)
|
||||
{
|
||||
/* no action necessary */
|
||||
}
|
||||
|
||||
static bool_t
|
||||
authunix_marshal(auth, xdrs)
|
||||
AUTH *auth;
|
||||
XDR *xdrs;
|
||||
authunix_marshal (AUTH *auth, XDR *xdrs)
|
||||
{
|
||||
register struct audata *au = AUTH_PRIVATE(auth);
|
||||
struct audata *au = AUTH_PRIVATE (auth);
|
||||
|
||||
return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos));
|
||||
return XDR_PUTBYTES (xdrs, au->au_marshed, au->au_mpos);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
authunix_validate(auth, verf)
|
||||
register AUTH *auth;
|
||||
struct opaque_auth *verf;
|
||||
authunix_validate (AUTH *auth, struct opaque_auth *verf)
|
||||
{
|
||||
register struct audata *au;
|
||||
struct audata *au;
|
||||
XDR xdrs;
|
||||
|
||||
if (verf->oa_flavor == AUTH_SHORT) {
|
||||
if (verf->oa_flavor == AUTH_SHORT)
|
||||
{
|
||||
au = AUTH_PRIVATE (auth);
|
||||
xdrmem_create (&xdrs, verf->oa_base, verf->oa_length,
|
||||
XDR_DECODE);
|
||||
|
||||
if (au->au_shcred.oa_base != NULL) {
|
||||
if (au->au_shcred.oa_base != NULL)
|
||||
{
|
||||
mem_free (au->au_shcred.oa_base,
|
||||
au->au_shcred.oa_length);
|
||||
au->au_shcred.oa_base = NULL;
|
||||
}
|
||||
if (xdr_opaque_auth(&xdrs, &au->au_shcred)) {
|
||||
if (xdr_opaque_auth (&xdrs, &au->au_shcred))
|
||||
{
|
||||
auth->ah_cred = au->au_shcred;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
xdrs.x_op = XDR_FREE;
|
||||
(void) xdr_opaque_auth (&xdrs, &au->au_shcred);
|
||||
au->au_shcred.oa_base = NULL;
|
||||
@ -240,22 +240,22 @@ authunix_validate(auth, verf)
|
||||
}
|
||||
marshal_new_auth (auth);
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
authunix_refresh(auth)
|
||||
register AUTH *auth;
|
||||
authunix_refresh (AUTH *auth)
|
||||
{
|
||||
register struct audata *au = AUTH_PRIVATE(auth);
|
||||
struct audata *au = AUTH_PRIVATE (auth);
|
||||
struct authunix_parms aup;
|
||||
struct timeval now;
|
||||
XDR xdrs;
|
||||
register int stat;
|
||||
int stat;
|
||||
|
||||
if (auth->ah_cred.oa_base == au->au_origcred.oa_base) {
|
||||
if (auth->ah_cred.oa_base == au->au_origcred.oa_base)
|
||||
{
|
||||
/* there is no hope. Punt */
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
au->au_shfaults++;
|
||||
|
||||
@ -283,14 +283,13 @@ done:
|
||||
xdrs.x_op = XDR_FREE;
|
||||
(void) xdr_authunix_parms (&xdrs, &aup);
|
||||
XDR_DESTROY (&xdrs);
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
static void
|
||||
authunix_destroy(auth)
|
||||
register AUTH *auth;
|
||||
authunix_destroy (AUTH *auth)
|
||||
{
|
||||
register struct audata *au = AUTH_PRIVATE(auth);
|
||||
struct audata *au = AUTH_PRIVATE (auth);
|
||||
|
||||
mem_free (au->au_origcred.oa_base, au->au_origcred.oa_length);
|
||||
|
||||
@ -310,19 +309,23 @@ authunix_destroy(auth)
|
||||
* sets private data, au_marshed and au_mpos
|
||||
*/
|
||||
static bool_t
|
||||
marshal_new_auth(auth)
|
||||
register AUTH *auth;
|
||||
marshal_new_auth (AUTH *auth)
|
||||
{
|
||||
XDR xdr_stream;
|
||||
register XDR *xdrs = &xdr_stream;
|
||||
register struct audata *au = AUTH_PRIVATE(auth);
|
||||
XDR *xdrs = &xdr_stream;
|
||||
struct audata *au = AUTH_PRIVATE (auth);
|
||||
|
||||
xdrmem_create (xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
|
||||
if ((!xdr_opaque_auth (xdrs, &(auth->ah_cred))) ||
|
||||
(! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) {
|
||||
(!xdr_opaque_auth (xdrs, &(auth->ah_verf))))
|
||||
{
|
||||
perror (_("auth_none.c - Fatal marshalling problem"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
au->au_mpos = XDR_GETPOS (xdrs);
|
||||
}
|
||||
XDR_DESTROY (xdrs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -48,11 +48,8 @@ static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
|
||||
* XDR for unix authentication parameters.
|
||||
*/
|
||||
bool_t
|
||||
xdr_authunix_parms(xdrs, p)
|
||||
register XDR *xdrs;
|
||||
register struct authunix_parms *p;
|
||||
xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p)
|
||||
{
|
||||
|
||||
if (xdr_u_long (xdrs, &(p->aup_time))
|
||||
&& xdr_string (xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
|
||||
&& (sizeof (uid_t) == sizeof (short int)
|
||||
@ -64,8 +61,9 @@ xdr_authunix_parms(xdrs, p)
|
||||
&& xdr_array (xdrs, (caddr_t *) & (p->aup_gids),
|
||||
& (p->aup_len), NGRPS, sizeof (gid_t),
|
||||
(sizeof (gid_t) == sizeof (short int)
|
||||
? xdr_u_short : xdr_u_int)) ) {
|
||||
return (TRUE);
|
||||
? (xdrproc_t) xdr_u_short : (xdrproc_t) xdr_u_int)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI";
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
@ -27,11 +26,15 @@ static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI";
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/socket.h>
|
||||
@ -40,9 +43,8 @@ static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08
|
||||
/*
|
||||
* Bind a socket to a privileged IP port
|
||||
*/
|
||||
bindresvport(sd, sin)
|
||||
int sd;
|
||||
struct sockaddr_in *sin;
|
||||
int
|
||||
bindresvport (int sd, struct sockaddr_in *sin)
|
||||
{
|
||||
int res;
|
||||
static short port;
|
||||
@ -56,25 +58,31 @@ bindresvport(sd, sin)
|
||||
#define ENDPORT (IPPORT_RESERVED - 1)
|
||||
#define NPORTS (ENDPORT - STARTPORT + 1)
|
||||
|
||||
if (sin == (struct sockaddr_in *)0) {
|
||||
if (sin == (struct sockaddr_in *) 0)
|
||||
{
|
||||
sin = &myaddr;
|
||||
bzero (sin, sizeof (*sin));
|
||||
sin->sin_family = AF_INET;
|
||||
} else if (sin->sin_family != AF_INET) {
|
||||
__set_errno (EPFNOSUPPORT);
|
||||
return (-1);
|
||||
}
|
||||
if (port == 0) {
|
||||
else if (sin->sin_family != AF_INET)
|
||||
{
|
||||
__set_errno (EPFNOSUPPORT);
|
||||
return -1;
|
||||
}
|
||||
if (port == 0)
|
||||
{
|
||||
port = (getpid () % NPORTS) + STARTPORT;
|
||||
}
|
||||
res = -1;
|
||||
__set_errno (EADDRINUSE);
|
||||
for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) {
|
||||
for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++)
|
||||
{
|
||||
sin->sin_port = htons (port++);
|
||||
if (port > ENDPORT) {
|
||||
if (port > ENDPORT)
|
||||
{
|
||||
port = STARTPORT;
|
||||
}
|
||||
res = bind (sd, sin, sizeof (struct sockaddr_in));
|
||||
}
|
||||
return (res);
|
||||
return res;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
|
||||
*/
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/errno.h>
|
||||
@ -46,11 +47,8 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
|
||||
* change using the rpc equivalent of ioctl()'s.
|
||||
*/
|
||||
CLIENT *
|
||||
clnt_create(hostname, prog, vers, proto)
|
||||
char *hostname;
|
||||
unsigned prog;
|
||||
unsigned vers;
|
||||
char *proto;
|
||||
clnt_create (const char *hostname, u_long prog, u_long vers,
|
||||
const char *proto)
|
||||
{
|
||||
struct hostent hostbuf, *h;
|
||||
size_t hstbuflen;
|
||||
@ -80,13 +78,14 @@ clnt_create(hostname, prog, vers, proto)
|
||||
hsttmpbuf = __alloca (hstbuflen);
|
||||
}
|
||||
|
||||
if (h->h_addrtype != AF_INET) {
|
||||
if (h->h_addrtype != AF_INET)
|
||||
{
|
||||
/*
|
||||
* Only support INET for now
|
||||
*/
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
sin.sin_family = h->h_addrtype;
|
||||
sin.sin_port = 0;
|
||||
@ -111,30 +110,33 @@ clnt_create(hostname, prog, vers, proto)
|
||||
}
|
||||
|
||||
sock = RPC_ANYSOCK;
|
||||
switch (p->p_proto) {
|
||||
switch (p->p_proto)
|
||||
{
|
||||
case IPPROTO_UDP:
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
client = clntudp_create (&sin, prog, vers, tv, &sock);
|
||||
if (client == NULL) {
|
||||
return (NULL);
|
||||
if (client == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
tv.tv_sec = 25;
|
||||
clnt_control(client, CLSET_TIMEOUT, &tv);
|
||||
clnt_control (client, CLSET_TIMEOUT, (char *)&tv);
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
client = clnttcp_create (&sin, prog, vers, &sock, 0, 0);
|
||||
if (client == NULL) {
|
||||
return (NULL);
|
||||
if (client == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
tv.tv_sec = 25;
|
||||
tv.tv_usec = 0;
|
||||
clnt_control(client, CLSET_TIMEOUT, &tv);
|
||||
clnt_control (client, CLSET_TIMEOUT, (char *)&tv);
|
||||
break;
|
||||
default:
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
|
||||
return (NULL);
|
||||
}
|
||||
return (client);
|
||||
return client;
|
||||
}
|
||||
|
@ -38,53 +38,47 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/auth.h>
|
||||
#include <rpc/clnt.h>
|
||||
|
||||
/* extern char *sys_errlist[]; --drepper@gnu */
|
||||
/* extern char *sprintf(); --roland@gnu */
|
||||
static char *auth_errmsg();
|
||||
|
||||
extern char *strcpy();
|
||||
static char *auth_errmsg (enum auth_stat stat);
|
||||
|
||||
static char *buf;
|
||||
|
||||
static char *
|
||||
_buf()
|
||||
_buf (void)
|
||||
{
|
||||
|
||||
if (buf == 0)
|
||||
if (buf == NULL)
|
||||
buf = (char *) malloc (256);
|
||||
return (buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print reply error info
|
||||
*/
|
||||
char *
|
||||
clnt_sperror(rpch, s)
|
||||
CLIENT *rpch;
|
||||
char *s;
|
||||
clnt_sperror (CLIENT * rpch, const char *msg)
|
||||
{
|
||||
char buf[1024];
|
||||
struct rpc_err e;
|
||||
void clnt_perrno();
|
||||
char *err;
|
||||
char *str = _buf ();
|
||||
char *strstart = str;
|
||||
int len;
|
||||
|
||||
if (str == 0)
|
||||
return (0);
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
CLNT_GETERR (rpch, &e);
|
||||
|
||||
(void) sprintf(str, "%s: ", s);
|
||||
str += strlen(str);
|
||||
len = sprintf (str, "%s: ", msg);
|
||||
str += len;
|
||||
|
||||
(void) strcpy(str, clnt_sperrno(e.re_status));
|
||||
str += strlen(str);
|
||||
str = stpcpy (str, clnt_sperrno (e.re_status));
|
||||
|
||||
switch (e.re_status) {
|
||||
switch (e.re_status)
|
||||
{
|
||||
case RPC_SUCCESS:
|
||||
case RPC_CANTENCODEARGS:
|
||||
case RPC_CANTDECODERES:
|
||||
@ -102,65 +96,62 @@ clnt_sperror(rpch, s)
|
||||
|
||||
case RPC_CANTSEND:
|
||||
case RPC_CANTRECV:
|
||||
(void) sprintf(str, "; errno = %s",
|
||||
sys_errlist[e.re_errno]);
|
||||
str += strlen(str);
|
||||
len = sprintf (str, "; errno = %s", strerror_r (e.re_errno,
|
||||
buf, sizeof buf));
|
||||
str += len;
|
||||
break;
|
||||
|
||||
case RPC_VERSMISMATCH:
|
||||
(void) sprintf(str,
|
||||
_("; low version = %lu, high version = %lu"),
|
||||
len= sprintf (str, _("; low version = %lu, high version = %lu"),
|
||||
e.re_vers.low, e.re_vers.high);
|
||||
str += strlen(str);
|
||||
str += len;
|
||||
break;
|
||||
|
||||
case RPC_AUTHERROR:
|
||||
err = auth_errmsg (e.re_why);
|
||||
(void) sprintf(str,_("; why = "));
|
||||
str += strlen(str);
|
||||
if (err != NULL) {
|
||||
(void) sprintf(str, "%s",err);
|
||||
} else {
|
||||
(void) sprintf(str,
|
||||
_("(unknown authentication error - %d)"),
|
||||
(int) e.re_why);
|
||||
str = stpcpy (str, _ ("; why = "));
|
||||
if (err != NULL)
|
||||
{
|
||||
str = stpcpy (str, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = sprintf (str, _("(unknown authentication error - %d)"),
|
||||
(int) e.re_why);
|
||||
str += len;
|
||||
}
|
||||
str += strlen(str);
|
||||
break;
|
||||
|
||||
case RPC_PROGVERSMISMATCH:
|
||||
(void) sprintf(str,
|
||||
_("; low version = %lu, high version = %lu"),
|
||||
len = sprintf (str, _("; low version = %lu, high version = %lu"),
|
||||
e.re_vers.low, e.re_vers.high);
|
||||
str += strlen(str);
|
||||
str += len;
|
||||
break;
|
||||
|
||||
default: /* unknown */
|
||||
(void) sprintf(str,
|
||||
"; s1 = %lu, s2 = %lu",
|
||||
e.re_lb.s1, e.re_lb.s2);
|
||||
str += strlen(str);
|
||||
len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
|
||||
str += len;
|
||||
break;
|
||||
}
|
||||
(void) sprintf(str, "\n");
|
||||
*str = '\n';
|
||||
return (strstart);
|
||||
}
|
||||
|
||||
void
|
||||
clnt_perror(rpch, s)
|
||||
CLIENT *rpch;
|
||||
char *s;
|
||||
clnt_perror (CLIENT * rpch, const char *msg)
|
||||
{
|
||||
(void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
|
||||
(void) fputs (clnt_sperror (rpch, msg), stderr);
|
||||
}
|
||||
|
||||
|
||||
struct rpc_errtab {
|
||||
struct rpc_errtab
|
||||
{
|
||||
enum clnt_stat status;
|
||||
char *message;
|
||||
const char *message;
|
||||
};
|
||||
|
||||
static struct rpc_errtab rpc_errlist[] = {
|
||||
static const struct rpc_errtab rpc_errlist[] =
|
||||
{
|
||||
{RPC_SUCCESS,
|
||||
N_("RPC: Success")},
|
||||
{RPC_CANTENCODEARGS,
|
||||
@ -204,13 +195,14 @@ static struct rpc_errtab rpc_errlist[] = {
|
||||
* This interface for use by clntrpc
|
||||
*/
|
||||
char *
|
||||
clnt_sperrno(stat)
|
||||
enum clnt_stat stat;
|
||||
clnt_sperrno (enum clnt_stat stat)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
|
||||
if (rpc_errlist[i].status == stat) {
|
||||
for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++)
|
||||
{
|
||||
if (rpc_errlist[i].status == stat)
|
||||
{
|
||||
return _(rpc_errlist[i].message);
|
||||
}
|
||||
}
|
||||
@ -218,60 +210,65 @@ clnt_sperrno(stat)
|
||||
}
|
||||
|
||||
void
|
||||
clnt_perrno(num)
|
||||
enum clnt_stat num;
|
||||
clnt_perrno (enum clnt_stat num)
|
||||
{
|
||||
(void) fprintf(stderr,"%s",clnt_sperrno(num));
|
||||
(void) fputs (clnt_sperrno (num), stderr);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
clnt_spcreateerror(s)
|
||||
char *s;
|
||||
clnt_spcreateerror (const char *msg)
|
||||
{
|
||||
extern int sys_nerr;
|
||||
/* extern char *sys_errlist[]; --drepper@gnu */
|
||||
char buf[1024];
|
||||
char *str = _buf ();
|
||||
char *cp;
|
||||
int len;
|
||||
|
||||
if (str == 0)
|
||||
return(0);
|
||||
(void) sprintf(str, "%s: ", s);
|
||||
(void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
|
||||
switch (rpc_createerr.cf_stat) {
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
len = sprintf (str, "%s: ", msg);
|
||||
cp = str + len;
|
||||
cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_stat));
|
||||
switch (rpc_createerr.cf_stat)
|
||||
{
|
||||
case RPC_PMAPFAILURE:
|
||||
(void) strcat(str, " - ");
|
||||
(void) strcat(str,
|
||||
clnt_sperrno(rpc_createerr.cf_error.re_status));
|
||||
cp = stpcpy (cp, " - ");
|
||||
cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_error.re_status));
|
||||
break;
|
||||
|
||||
case RPC_SYSTEMERROR:
|
||||
(void) strcat(str, " - ");
|
||||
cp = stpcpy (str, " - ");
|
||||
if (rpc_createerr.cf_error.re_errno > 0
|
||||
&& rpc_createerr.cf_error.re_errno < sys_nerr)
|
||||
(void) strcat(str,
|
||||
sys_errlist[rpc_createerr.cf_error.re_errno]);
|
||||
cp = stpcpy (str, strerror_r (rpc_createerr.cf_error.re_errno,
|
||||
buf, sizeof buf));
|
||||
else
|
||||
(void) sprintf(&str[strlen(str)], _("Error %d"),
|
||||
rpc_createerr.cf_error.re_errno);
|
||||
{
|
||||
len = sprintf (cp, _("Error %d"), rpc_createerr.cf_error.re_errno);
|
||||
cp += len;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
(void) strcat(str, "\n");
|
||||
return (str);
|
||||
*cp = '\n';
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
clnt_pcreateerror(s)
|
||||
char *s;
|
||||
clnt_pcreateerror (const char *msg)
|
||||
{
|
||||
(void) fprintf(stderr,"%s",clnt_spcreateerror(s));
|
||||
(void) fputs (clnt_spcreateerror (msg), stderr);
|
||||
}
|
||||
|
||||
struct auth_errtab {
|
||||
struct auth_errtab
|
||||
{
|
||||
enum auth_stat status;
|
||||
char *message;
|
||||
const char *message;
|
||||
};
|
||||
|
||||
static struct auth_errtab auth_errlist[] = {
|
||||
static const struct auth_errtab auth_errlist[] =
|
||||
{
|
||||
{AUTH_OK,
|
||||
N_("Authentication OK")},
|
||||
{AUTH_BADCRED,
|
||||
@ -291,15 +288,16 @@ static struct auth_errtab auth_errlist[] = {
|
||||
};
|
||||
|
||||
static char *
|
||||
auth_errmsg(stat)
|
||||
enum auth_stat stat;
|
||||
auth_errmsg (enum auth_stat stat)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
|
||||
if (auth_errlist[i].status == stat) {
|
||||
for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++)
|
||||
{
|
||||
if (auth_errlist[i].status == stat)
|
||||
{
|
||||
return _(auth_errlist[i].message);
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -43,28 +43,36 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/svc.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
#define MCALL_MSG_SIZE 24
|
||||
|
||||
/*
|
||||
* This is the "network" we will be moving stuff over.
|
||||
*/
|
||||
static struct clntraw_private {
|
||||
static struct clntraw_private
|
||||
{
|
||||
CLIENT client_object;
|
||||
XDR xdr_stream;
|
||||
char _raw_buf[UDPMSGSIZE];
|
||||
char mashl_callmsg[MCALL_MSG_SIZE];
|
||||
u_int mcnt;
|
||||
} *clntraw_private;
|
||||
}
|
||||
*clntraw_private;
|
||||
|
||||
static enum clnt_stat clntraw_call();
|
||||
static void clntraw_abort();
|
||||
static void clntraw_geterr();
|
||||
static bool_t clntraw_freeres();
|
||||
static bool_t clntraw_control();
|
||||
static void clntraw_destroy();
|
||||
static enum clnt_stat clntraw_call (CLIENT *, u_long, xdrproc_t, caddr_t,
|
||||
xdrproc_t, caddr_t, struct timeval);
|
||||
static void clntraw_abort (void);
|
||||
static void clntraw_geterr (CLIENT *, struct rpc_err *);
|
||||
static bool_t clntraw_freeres (CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clntraw_control (CLIENT *, int, char *);
|
||||
static void clntraw_destroy (CLIENT *);
|
||||
|
||||
static struct clnt_ops client_ops = {
|
||||
static struct clnt_ops client_ops =
|
||||
{
|
||||
clntraw_call,
|
||||
clntraw_abort,
|
||||
clntraw_geterr,
|
||||
@ -73,22 +81,19 @@ static struct clnt_ops client_ops = {
|
||||
clntraw_control
|
||||
};
|
||||
|
||||
void svc_getreq();
|
||||
|
||||
/*
|
||||
* Create a client handle for memory based rpc.
|
||||
*/
|
||||
CLIENT *
|
||||
clntraw_create(prog, vers)
|
||||
u_long prog;
|
||||
u_long vers;
|
||||
clntraw_create (u_long prog, u_long vers)
|
||||
{
|
||||
register struct clntraw_private *clp = clntraw_private;
|
||||
struct clntraw_private *clp = clntraw_private;
|
||||
struct rpc_msg call_msg;
|
||||
XDR *xdrs = &clp->xdr_stream;
|
||||
CLIENT *client = &clp->client_object;
|
||||
|
||||
if (clp == 0) {
|
||||
if (clp == 0)
|
||||
{
|
||||
clp = (struct clntraw_private *) calloc (1, sizeof (*clp));
|
||||
if (clp == 0)
|
||||
return (0);
|
||||
@ -102,7 +107,8 @@ clntraw_create(prog, vers)
|
||||
call_msg.rm_call.cb_prog = prog;
|
||||
call_msg.rm_call.cb_vers = vers;
|
||||
xdrmem_create (xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
|
||||
if (! xdr_callhdr(xdrs, &call_msg)) {
|
||||
if (!xdr_callhdr (xdrs, &call_msg))
|
||||
{
|
||||
perror (_ ("clnt_raw.c - Fatal header serialization error."));
|
||||
}
|
||||
clp->mcnt = XDR_GETPOS (xdrs);
|
||||
@ -118,7 +124,7 @@ clntraw_create(prog, vers)
|
||||
*/
|
||||
client->cl_ops = &client_ops;
|
||||
client->cl_auth = authnone_create ();
|
||||
return (client);
|
||||
return client;
|
||||
}
|
||||
|
||||
static enum clnt_stat
|
||||
@ -131,14 +137,14 @@ clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
|
||||
caddr_t resultsp;
|
||||
struct timeval timeout;
|
||||
{
|
||||
register struct clntraw_private *clp = clntraw_private;
|
||||
register XDR *xdrs = &clp->xdr_stream;
|
||||
struct clntraw_private *clp = clntraw_private;
|
||||
XDR *xdrs = &clp->xdr_stream;
|
||||
struct rpc_msg msg;
|
||||
enum clnt_stat status;
|
||||
struct rpc_err error;
|
||||
|
||||
if (clp == 0)
|
||||
return (RPC_FAILED);
|
||||
if (clp == NULL)
|
||||
return RPC_FAILED;
|
||||
call_again:
|
||||
/*
|
||||
* send request
|
||||
@ -149,7 +155,8 @@ call_again:
|
||||
if ((!XDR_PUTBYTES (xdrs, clp->mashl_callmsg, clp->mcnt)) ||
|
||||
(!XDR_PUTLONG (xdrs, (long *) &proc)) ||
|
||||
(!AUTH_MARSHALL (h->cl_auth, xdrs)) ||
|
||||
(! (*xargs)(xdrs, argsp))) {
|
||||
(!(*xargs) (xdrs, argsp)))
|
||||
{
|
||||
return (RPC_CANTENCODEARGS);
|
||||
}
|
||||
(void) XDR_GETPOS (xdrs); /* called just to cause overhead */
|
||||
@ -169,35 +176,41 @@ call_again:
|
||||
msg.acpted_rply.ar_results.where = resultsp;
|
||||
msg.acpted_rply.ar_results.proc = xresults;
|
||||
if (!xdr_replymsg (xdrs, &msg))
|
||||
return (RPC_CANTDECODERES);
|
||||
return RPC_CANTDECODERES;
|
||||
_seterr_reply (&msg, &error);
|
||||
status = error.re_status;
|
||||
|
||||
if (status == RPC_SUCCESS) {
|
||||
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
|
||||
if (status == RPC_SUCCESS)
|
||||
{
|
||||
if (!AUTH_VALIDATE (h->cl_auth, &msg.acpted_rply.ar_verf))
|
||||
{
|
||||
status = RPC_AUTHERROR;
|
||||
}
|
||||
} /* end successful completion */
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (AUTH_REFRESH (h->cl_auth))
|
||||
goto call_again;
|
||||
} /* end of unsuccessful completion */
|
||||
|
||||
if (status == RPC_SUCCESS) {
|
||||
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
|
||||
if (status == RPC_SUCCESS)
|
||||
{
|
||||
if (!AUTH_VALIDATE (h->cl_auth, &msg.acpted_rply.ar_verf))
|
||||
{
|
||||
status = RPC_AUTHERROR;
|
||||
}
|
||||
if (msg.acpted_rply.ar_verf.oa_base != NULL) {
|
||||
if (msg.acpted_rply.ar_verf.oa_base != NULL)
|
||||
{
|
||||
xdrs->x_op = XDR_FREE;
|
||||
(void) xdr_opaque_auth (xdrs, &(msg.acpted_rply.ar_verf));
|
||||
}
|
||||
}
|
||||
|
||||
return (status);
|
||||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
clntraw_geterr()
|
||||
clntraw_geterr (CLIENT *cl, struct rpc_err *err)
|
||||
{
|
||||
}
|
||||
|
||||
@ -208,31 +221,31 @@ clntraw_freeres(cl, xdr_res, res_ptr)
|
||||
xdrproc_t xdr_res;
|
||||
caddr_t res_ptr;
|
||||
{
|
||||
register struct clntraw_private *clp = clntraw_private;
|
||||
register XDR *xdrs = &clp->xdr_stream;
|
||||
struct clntraw_private *clp = clntraw_private;
|
||||
XDR *xdrs = &clp->xdr_stream;
|
||||
bool_t rval;
|
||||
|
||||
if (clp == 0)
|
||||
if (clp == NULL)
|
||||
{
|
||||
rval = (bool_t) RPC_FAILED;
|
||||
return (rval);
|
||||
return rval;
|
||||
}
|
||||
xdrs->x_op = XDR_FREE;
|
||||
return ((*xdr_res)(xdrs, res_ptr));
|
||||
return (*xdr_res) (xdrs, res_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
clntraw_abort()
|
||||
clntraw_abort (void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t
|
||||
clntraw_control()
|
||||
clntraw_control (CLIENT *cl, int i, char *c)
|
||||
{
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clntraw_destroy()
|
||||
clntraw_destroy (CLIENT *cl)
|
||||
{
|
||||
}
|
||||
|
@ -41,44 +41,51 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <strings.h>
|
||||
|
||||
static struct callrpc_private {
|
||||
static struct callrpc_private
|
||||
{
|
||||
CLIENT *client;
|
||||
int socket;
|
||||
int oldprognum, oldversnum, valid;
|
||||
u_long oldprognum, oldversnum, valid;
|
||||
char *oldhost;
|
||||
} *callrpc_private;
|
||||
}
|
||||
*callrpc_private;
|
||||
|
||||
callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||
char *host;
|
||||
xdrproc_t inproc, outproc;
|
||||
char *in, *out;
|
||||
int
|
||||
callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
|
||||
xdrproc_t inproc, const char *in, xdrproc_t outproc, char *out)
|
||||
{
|
||||
register struct callrpc_private *crp = callrpc_private;
|
||||
struct callrpc_private *crp = callrpc_private;
|
||||
struct sockaddr_in server_addr;
|
||||
enum clnt_stat clnt_stat;
|
||||
struct hostent hostbuf, *hp;
|
||||
struct timeval timeout, tottimeout;
|
||||
|
||||
if (crp == 0) {
|
||||
if (crp == 0)
|
||||
{
|
||||
crp = (struct callrpc_private *) calloc (1, sizeof (*crp));
|
||||
if (crp == 0)
|
||||
return (0);
|
||||
return 0;
|
||||
callrpc_private = crp;
|
||||
}
|
||||
if (crp->oldhost == NULL) {
|
||||
if (crp->oldhost == NULL)
|
||||
{
|
||||
crp->oldhost = malloc (256);
|
||||
crp->oldhost[0] = 0;
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
}
|
||||
if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum
|
||||
&& strcmp(crp->oldhost, host) == 0) {
|
||||
&& strcmp (crp->oldhost, host) == 0)
|
||||
{
|
||||
/* reuse old client */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t buflen;
|
||||
char *buffer;
|
||||
int herr;
|
||||
@ -89,7 +96,8 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||
(void) close (crp->socket);
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
}
|
||||
if (crp->client) {
|
||||
if (crp->client)
|
||||
{
|
||||
clnt_destroy (crp->client);
|
||||
crp->client = NULL;
|
||||
}
|
||||
@ -114,7 +122,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||
server_addr.sin_port = 0;
|
||||
if ((crp->client = clntudp_create (&server_addr, (u_long) prognum,
|
||||
(u_long) versnum, timeout, &crp->socket)) == NULL)
|
||||
return ((int) rpc_createerr.cf_stat);
|
||||
return (int) rpc_createerr.cf_stat;
|
||||
crp->valid = 1;
|
||||
crp->oldprognum = prognum;
|
||||
crp->oldversnum = versnum;
|
||||
@ -123,12 +131,12 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||
}
|
||||
tottimeout.tv_sec = 25;
|
||||
tottimeout.tv_usec = 0;
|
||||
clnt_stat = clnt_call(crp->client, procnum, inproc, in,
|
||||
clnt_stat = clnt_call (crp->client, procnum, inproc, (char *) in,
|
||||
outproc, out, tottimeout);
|
||||
/*
|
||||
* if call failed, empty cache
|
||||
*/
|
||||
if (clnt_stat != RPC_SUCCESS)
|
||||
crp->valid = 0;
|
||||
return ((int) clnt_stat);
|
||||
return (int) clnt_stat;
|
||||
}
|
||||
|
@ -50,39 +50,20 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
|
||||
* Now go hang yourself.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
#define MCALL_MSG_SIZE 24
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static int readtcp();
|
||||
static int writetcp();
|
||||
|
||||
static enum clnt_stat clnttcp_call();
|
||||
static void clnttcp_abort();
|
||||
static void clnttcp_geterr();
|
||||
static bool_t clnttcp_freeres();
|
||||
static bool_t clnttcp_control();
|
||||
static void clnttcp_destroy();
|
||||
|
||||
static struct clnt_ops tcp_ops = {
|
||||
clnttcp_call,
|
||||
clnttcp_abort,
|
||||
clnttcp_geterr,
|
||||
clnttcp_freeres,
|
||||
clnttcp_destroy,
|
||||
clnttcp_control
|
||||
};
|
||||
|
||||
struct ct_data {
|
||||
struct ct_data
|
||||
{
|
||||
int ct_sock;
|
||||
bool_t ct_closeit;
|
||||
struct timeval ct_wait;
|
||||
@ -94,6 +75,27 @@ struct ct_data {
|
||||
XDR ct_xdrs;
|
||||
};
|
||||
|
||||
static int readtcp (char *, char *, int);
|
||||
static int writetcp (char *, char *, int);
|
||||
|
||||
static enum clnt_stat clnttcp_call (CLIENT *, u_long, xdrproc_t, caddr_t,
|
||||
xdrproc_t, caddr_t, struct timeval);
|
||||
static void clnttcp_abort (void);
|
||||
static void clnttcp_geterr (CLIENT *, struct rpc_err *);
|
||||
static bool_t clnttcp_freeres (CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clnttcp_control (CLIENT *, int, char *);
|
||||
static void clnttcp_destroy (CLIENT *);
|
||||
|
||||
static struct clnt_ops tcp_ops =
|
||||
{
|
||||
clnttcp_call,
|
||||
clnttcp_abort,
|
||||
clnttcp_geterr,
|
||||
clnttcp_freeres,
|
||||
clnttcp_destroy,
|
||||
clnttcp_control
|
||||
};
|
||||
|
||||
/*
|
||||
* Create a client handle for a tcp/ip connection.
|
||||
* If *sockp<0, *sockp is set to a newly created TCP socket and it is
|
||||
@ -109,29 +111,26 @@ struct ct_data {
|
||||
* something more useful.
|
||||
*/
|
||||
CLIENT *
|
||||
clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
struct sockaddr_in *raddr;
|
||||
u_long prog;
|
||||
u_long vers;
|
||||
register int *sockp;
|
||||
u_int sendsz;
|
||||
u_int recvsz;
|
||||
clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
|
||||
int *sockp, u_int sendsz, u_int recvsz)
|
||||
{
|
||||
CLIENT *h;
|
||||
register struct ct_data *ct;
|
||||
struct ct_data *ct = (struct ct_data *) mem_alloc (sizeof (*ct));
|
||||
struct timeval now;
|
||||
struct rpc_msg call_msg;
|
||||
|
||||
h = (CLIENT *) mem_alloc (sizeof (*h));
|
||||
if (h == NULL) {
|
||||
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
|
||||
if (h == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
}
|
||||
ct = (struct ct_data *)mem_alloc(sizeof(*ct));
|
||||
if (ct == NULL) {
|
||||
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
|
||||
/* ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */
|
||||
if (ct == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
@ -140,9 +139,11 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
/*
|
||||
* If no port number given ask the pmap for one
|
||||
*/
|
||||
if (raddr->sin_port == 0) {
|
||||
if (raddr->sin_port == 0)
|
||||
{
|
||||
u_short port;
|
||||
if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) {
|
||||
if ((port = pmap_getport (raddr, prog, vers, IPPROTO_TCP)) == 0)
|
||||
{
|
||||
mem_free ((caddr_t) ct, sizeof (struct ct_data));
|
||||
mem_free ((caddr_t) h, sizeof (CLIENT));
|
||||
return ((CLIENT *) NULL);
|
||||
@ -153,12 +154,14 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
/*
|
||||
* If no socket given, open one
|
||||
*/
|
||||
if (*sockp < 0) {
|
||||
if (*sockp < 0)
|
||||
{
|
||||
*sockp = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
(void) bindresvport (*sockp, (struct sockaddr_in *) 0);
|
||||
if ((*sockp < 0)
|
||||
|| (connect (*sockp, (struct sockaddr *) raddr,
|
||||
sizeof(*raddr)) < 0)) {
|
||||
sizeof (*raddr)) < 0))
|
||||
{
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
if (*sockp >= 0)
|
||||
@ -166,7 +169,9 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
goto fooy;
|
||||
}
|
||||
ct->ct_closeit = TRUE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ct->ct_closeit = FALSE;
|
||||
}
|
||||
|
||||
@ -193,8 +198,10 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
*/
|
||||
xdrmem_create (&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE,
|
||||
XDR_ENCODE);
|
||||
if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
|
||||
if (ct->ct_closeit) {
|
||||
if (!xdr_callhdr (&(ct->ct_xdrs), &call_msg))
|
||||
{
|
||||
if (ct->ct_closeit)
|
||||
{
|
||||
(void) close (*sockp);
|
||||
}
|
||||
goto fooy;
|
||||
@ -211,7 +218,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
h->cl_ops = &tcp_ops;
|
||||
h->cl_private = (caddr_t) ct;
|
||||
h->cl_auth = authnone_create ();
|
||||
return (h);
|
||||
return h;
|
||||
|
||||
fooy:
|
||||
/*
|
||||
@ -224,7 +231,7 @@ fooy:
|
||||
|
||||
static enum clnt_stat
|
||||
clnttcp_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
|
||||
register CLIENT *h;
|
||||
CLIENT *h;
|
||||
u_long proc;
|
||||
xdrproc_t xdr_args;
|
||||
caddr_t args_ptr;
|
||||
@ -232,15 +239,16 @@ clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
|
||||
caddr_t results_ptr;
|
||||
struct timeval timeout;
|
||||
{
|
||||
register struct ct_data *ct = (struct ct_data *) h->cl_private;
|
||||
register XDR *xdrs = &(ct->ct_xdrs);
|
||||
struct ct_data *ct = (struct ct_data *) h->cl_private;
|
||||
XDR *xdrs = &(ct->ct_xdrs);
|
||||
struct rpc_msg reply_msg;
|
||||
u_long x_id;
|
||||
u_int32_t *msg_x_id = (u_int32_t *) (ct->ct_mcall); /* yuk */
|
||||
register bool_t shipnow;
|
||||
bool_t shipnow;
|
||||
int refreshes = 2;
|
||||
|
||||
if (!ct->ct_waitset) {
|
||||
if (!ct->ct_waitset)
|
||||
{
|
||||
ct->ct_wait = timeout;
|
||||
}
|
||||
|
||||
@ -255,21 +263,23 @@ call_again:
|
||||
if ((!XDR_PUTBYTES (xdrs, ct->ct_mcall, ct->ct_mpos)) ||
|
||||
(!XDR_PUTLONG (xdrs, (long *) &proc)) ||
|
||||
(!AUTH_MARSHALL (h->cl_auth, xdrs)) ||
|
||||
(! (*xdr_args)(xdrs, args_ptr))) {
|
||||
(!(*xdr_args) (xdrs, args_ptr)))
|
||||
{
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
||||
ct->ct_error.re_status = RPC_CANTENCODEARGS;
|
||||
(void) xdrrec_endofrecord (xdrs, TRUE);
|
||||
return (ct->ct_error.re_status);
|
||||
}
|
||||
if (!xdrrec_endofrecord (xdrs, shipnow))
|
||||
return (ct->ct_error.re_status = RPC_CANTSEND);
|
||||
return ct->ct_error.re_status = RPC_CANTSEND;
|
||||
if (!shipnow)
|
||||
return (RPC_SUCCESS);
|
||||
return RPC_SUCCESS;
|
||||
/*
|
||||
* Hack to provide rpc-based message passing
|
||||
*/
|
||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
|
||||
return(ct->ct_error.re_status = RPC_TIMEDOUT);
|
||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0)
|
||||
{
|
||||
return ct->ct_error.re_status = RPC_TIMEDOUT;
|
||||
}
|
||||
|
||||
|
||||
@ -277,17 +287,19 @@ call_again:
|
||||
* Keep receiving until we get a valid transaction id
|
||||
*/
|
||||
xdrs->x_op = XDR_DECODE;
|
||||
while (TRUE) {
|
||||
while (TRUE)
|
||||
{
|
||||
reply_msg.acpted_rply.ar_verf = _null_auth;
|
||||
reply_msg.acpted_rply.ar_results.where = NULL;
|
||||
reply_msg.acpted_rply.ar_results.proc = xdr_void;
|
||||
reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
|
||||
if (!xdrrec_skiprecord (xdrs))
|
||||
return (ct->ct_error.re_status);
|
||||
/* now decode and validate the response header */
|
||||
if (! xdr_replymsg(xdrs, &reply_msg)) {
|
||||
if (!xdr_replymsg (xdrs, &reply_msg))
|
||||
{
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
||||
continue;
|
||||
return (ct->ct_error.re_status);
|
||||
return ct->ct_error.re_status;
|
||||
}
|
||||
if (reply_msg.rm_xid == x_id)
|
||||
break;
|
||||
@ -297,26 +309,32 @@ call_again:
|
||||
* process header
|
||||
*/
|
||||
_seterr_reply (&reply_msg, &(ct->ct_error));
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS) {
|
||||
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
||||
{
|
||||
if (!AUTH_VALIDATE (h->cl_auth, &reply_msg.acpted_rply.ar_verf))
|
||||
{
|
||||
ct->ct_error.re_status = RPC_AUTHERROR;
|
||||
ct->ct_error.re_why = AUTH_INVALIDRESP;
|
||||
} else if (! (*xdr_results)(xdrs, results_ptr)) {
|
||||
}
|
||||
else if (!(*xdr_results) (xdrs, results_ptr))
|
||||
{
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
||||
ct->ct_error.re_status = RPC_CANTDECODERES;
|
||||
}
|
||||
/* free verifier ... */
|
||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
|
||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
|
||||
{
|
||||
xdrs->x_op = XDR_FREE;
|
||||
(void) xdr_opaque_auth (xdrs, &(reply_msg.acpted_rply.ar_verf));
|
||||
}
|
||||
} /* end successful completion */
|
||||
else {
|
||||
else
|
||||
{
|
||||
/* maybe our credentials need to be refreshed ... */
|
||||
if (refreshes-- && AUTH_REFRESH (h->cl_auth))
|
||||
goto call_again;
|
||||
} /* end of unsuccessful completion */
|
||||
return (ct->ct_error.re_status);
|
||||
return ct->ct_error.re_status;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -324,7 +342,7 @@ clnttcp_geterr(h, errp)
|
||||
CLIENT *h;
|
||||
struct rpc_err *errp;
|
||||
{
|
||||
register struct ct_data *ct =
|
||||
struct ct_data *ct =
|
||||
(struct ct_data *) h->cl_private;
|
||||
|
||||
*errp = ct->ct_error;
|
||||
@ -336,11 +354,11 @@ clnttcp_freeres(cl, xdr_res, res_ptr)
|
||||
xdrproc_t xdr_res;
|
||||
caddr_t res_ptr;
|
||||
{
|
||||
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
|
||||
register XDR *xdrs = &(ct->ct_xdrs);
|
||||
struct ct_data *ct = (struct ct_data *) cl->cl_private;
|
||||
XDR *xdrs = &(ct->ct_xdrs);
|
||||
|
||||
xdrs->x_op = XDR_FREE;
|
||||
return ((*xdr_res)(xdrs, res_ptr));
|
||||
return (*xdr_res) (xdrs, res_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -354,9 +372,10 @@ clnttcp_control(cl, request, info)
|
||||
int request;
|
||||
char *info;
|
||||
{
|
||||
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
|
||||
struct ct_data *ct = (struct ct_data *) cl->cl_private;
|
||||
|
||||
switch (request) {
|
||||
switch (request)
|
||||
{
|
||||
case CLSET_TIMEOUT:
|
||||
ct->ct_wait = *(struct timeval *) info;
|
||||
ct->ct_waitset = TRUE;
|
||||
@ -368,20 +387,20 @@ clnttcp_control(cl, request, info)
|
||||
*(struct sockaddr_in *) info = ct->ct_addr;
|
||||
break;
|
||||
default:
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
clnttcp_destroy(h)
|
||||
CLIENT *h;
|
||||
clnttcp_destroy (CLIENT *h)
|
||||
{
|
||||
register struct ct_data *ct =
|
||||
struct ct_data *ct =
|
||||
(struct ct_data *) h->cl_private;
|
||||
|
||||
if (ct->ct_closeit) {
|
||||
if (ct->ct_closeit)
|
||||
{
|
||||
(void) close (ct->ct_sock);
|
||||
}
|
||||
XDR_DESTROY (&(ct->ct_xdrs));
|
||||
@ -395,46 +414,47 @@ clnttcp_destroy(h)
|
||||
* around for the rpc level.
|
||||
*/
|
||||
static int
|
||||
readtcp(ct, buf, len)
|
||||
register struct ct_data *ct;
|
||||
caddr_t buf;
|
||||
register int len;
|
||||
readtcp (char *ctptr, char *buf, int len)
|
||||
{
|
||||
struct ct_data *ct = (struct ct_data *)ctptr;
|
||||
#ifdef FD_SETSIZE
|
||||
fd_set mask;
|
||||
fd_set readfds;
|
||||
|
||||
if (len == 0)
|
||||
return (0);
|
||||
return 0;
|
||||
FD_ZERO (&mask);
|
||||
FD_SET (ct->ct_sock, &mask);
|
||||
#else
|
||||
register int mask = 1 << (ct->ct_sock);
|
||||
int mask = 1 << (ct->ct_sock);
|
||||
int readfds;
|
||||
|
||||
if (len == 0)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
#endif /* def FD_SETSIZE */
|
||||
while (TRUE) {
|
||||
while (TRUE)
|
||||
{
|
||||
struct timeval timeout = ct->ct_wait;
|
||||
readfds = mask;
|
||||
switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL,
|
||||
&timeout)) {
|
||||
switch (select (_rpc_dtablesize (), &readfds, (fd_set*)NULL,
|
||||
(fd_set*)NULL, &timeout))
|
||||
{
|
||||
case 0:
|
||||
ct->ct_error.re_status = RPC_TIMEDOUT;
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
case -1:
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
ct->ct_error.re_status = RPC_CANTRECV;
|
||||
ct->ct_error.re_errno = errno;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (len = read(ct->ct_sock, buf, len)) {
|
||||
switch (len = read (ct->ct_sock, buf, len))
|
||||
{
|
||||
|
||||
case 0:
|
||||
/* premature eof */
|
||||
@ -448,23 +468,23 @@ readtcp(ct, buf, len)
|
||||
ct->ct_error.re_status = RPC_CANTRECV;
|
||||
break;
|
||||
}
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
writetcp(ct, buf, len)
|
||||
struct ct_data *ct;
|
||||
caddr_t buf;
|
||||
int len;
|
||||
writetcp (char *ctptr, char *buf, int len)
|
||||
{
|
||||
register int i, cnt;
|
||||
int i, cnt;
|
||||
struct ct_data *ct = (struct ct_data*)ctptr;
|
||||
|
||||
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
|
||||
if ((i = write(ct->ct_sock, buf, cnt)) == -1) {
|
||||
for (cnt = len; cnt > 0; cnt -= i, buf += i)
|
||||
{
|
||||
if ((i = write (ct->ct_sock, buf, cnt)) == -1)
|
||||
{
|
||||
ct->ct_error.re_errno = errno;
|
||||
ct->ct_error.re_status = RPC_CANTSEND;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
@ -38,28 +38,31 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <rpc/clnt.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
/*
|
||||
* UDP bases client side rpc operations
|
||||
*/
|
||||
static enum clnt_stat clntudp_call();
|
||||
static void clntudp_abort();
|
||||
static void clntudp_geterr();
|
||||
static bool_t clntudp_freeres();
|
||||
static bool_t clntudp_control();
|
||||
static void clntudp_destroy();
|
||||
static enum clnt_stat clntudp_call (CLIENT *, u_long, xdrproc_t, caddr_t,
|
||||
xdrproc_t, caddr_t, struct timeval);
|
||||
static void clntudp_abort (void);
|
||||
static void clntudp_geterr (CLIENT *, struct rpc_err *);
|
||||
static bool_t clntudp_freeres (CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clntudp_control (CLIENT *, int, char *);
|
||||
static void clntudp_destroy (CLIENT *);
|
||||
|
||||
static struct clnt_ops udp_ops = {
|
||||
static struct clnt_ops udp_ops =
|
||||
{
|
||||
clntudp_call,
|
||||
clntudp_abort,
|
||||
clntudp_geterr,
|
||||
@ -71,7 +74,8 @@ static struct clnt_ops udp_ops = {
|
||||
/*
|
||||
* Private data kept per client handle
|
||||
*/
|
||||
struct cu_data {
|
||||
struct cu_data
|
||||
{
|
||||
int cu_sock;
|
||||
bool_t cu_closeit;
|
||||
struct sockaddr_in cu_raddr;
|
||||
@ -109,18 +113,19 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
u_long program;
|
||||
u_long version;
|
||||
struct timeval wait;
|
||||
register int *sockp;
|
||||
int *sockp;
|
||||
u_int sendsz;
|
||||
u_int recvsz;
|
||||
{
|
||||
CLIENT *cl;
|
||||
register struct cu_data *cu;
|
||||
struct cu_data *cu = NULL;
|
||||
struct timeval now;
|
||||
struct rpc_msg call_msg;
|
||||
|
||||
cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
|
||||
if (cl == NULL) {
|
||||
(void) fprintf(stderr, "clntudp_create: out of memory\n");
|
||||
if (cl == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("clntudp_create: out of memory\n"));
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
@ -128,8 +133,9 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
sendsz = ((sendsz + 3) / 4) * 4;
|
||||
recvsz = ((recvsz + 3) / 4) * 4;
|
||||
cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
|
||||
if (cu == NULL) {
|
||||
(void) fprintf(stderr, "clntudp_create: out of memory\n");
|
||||
if (cu == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("clntudp_create: out of memory\n"));
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
@ -137,10 +143,12 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
|
||||
|
||||
(void) gettimeofday (&now, (struct timezone *) 0);
|
||||
if (raddr->sin_port == 0) {
|
||||
if (raddr->sin_port == 0)
|
||||
{
|
||||
u_short port;
|
||||
if ((port =
|
||||
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
|
||||
pmap_getport (raddr, program, version, IPPROTO_UDP)) == 0)
|
||||
{
|
||||
goto fooy;
|
||||
}
|
||||
raddr->sin_port = htons (port);
|
||||
@ -161,15 +169,18 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
call_msg.rm_call.cb_vers = version;
|
||||
xdrmem_create (&(cu->cu_outxdrs), cu->cu_outbuf,
|
||||
sendsz, XDR_ENCODE);
|
||||
if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
|
||||
if (!xdr_callhdr (&(cu->cu_outxdrs), &call_msg))
|
||||
{
|
||||
goto fooy;
|
||||
}
|
||||
cu->cu_xdrpos = XDR_GETPOS (&(cu->cu_outxdrs));
|
||||
if (*sockp < 0) {
|
||||
if (*sockp < 0)
|
||||
{
|
||||
int dontblock = 1;
|
||||
|
||||
*sockp = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (*sockp < 0) {
|
||||
if (*sockp < 0)
|
||||
{
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
@ -179,18 +190,20 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
/* the sockets rpc controls are non-blocking */
|
||||
(void) ioctl (*sockp, FIONBIO, (char *) &dontblock);
|
||||
cu->cu_closeit = TRUE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cu->cu_closeit = FALSE;
|
||||
}
|
||||
cu->cu_sock = *sockp;
|
||||
cl->cl_auth = authnone_create ();
|
||||
return (cl);
|
||||
return cl;
|
||||
fooy:
|
||||
if (cu)
|
||||
mem_free ((caddr_t) cu, sizeof (*cu) + sendsz + recvsz);
|
||||
if (cl)
|
||||
mem_free ((caddr_t) cl, sizeof (CLIENT));
|
||||
return ((CLIENT *)NULL);
|
||||
return (CLIENT *) NULL;
|
||||
}
|
||||
|
||||
CLIENT *
|
||||
@ -199,16 +212,16 @@ clntudp_create(raddr, program, version, wait, sockp)
|
||||
u_long program;
|
||||
u_long version;
|
||||
struct timeval wait;
|
||||
register int *sockp;
|
||||
int *sockp;
|
||||
{
|
||||
|
||||
return(clntudp_bufcreate(raddr, program, version, wait, sockp,
|
||||
UDPMSGSIZE, UDPMSGSIZE));
|
||||
return clntudp_bufcreate (raddr, program, version, wait, sockp,
|
||||
UDPMSGSIZE, UDPMSGSIZE);
|
||||
}
|
||||
|
||||
static enum clnt_stat
|
||||
clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout)
|
||||
register CLIENT *cl; /* client handle */
|
||||
CLIENT *cl; /* client handle */
|
||||
u_long proc; /* procedure number */
|
||||
xdrproc_t xargs; /* xdr routine for args */
|
||||
caddr_t argsp; /* pointer to args */
|
||||
@ -216,17 +229,17 @@ clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
|
||||
caddr_t resultsp; /* pointer to results */
|
||||
struct timeval utimeout; /* seconds to wait before giving up */
|
||||
{
|
||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
register XDR *xdrs;
|
||||
register int outlen;
|
||||
register int inlen;
|
||||
struct cu_data *cu = (struct cu_data *) cl->cl_private;
|
||||
XDR *xdrs;
|
||||
int outlen;
|
||||
int inlen;
|
||||
int fromlen;
|
||||
#ifdef FD_SETSIZE
|
||||
fd_set readfds;
|
||||
fd_set mask;
|
||||
#else
|
||||
int readfds;
|
||||
register int mask;
|
||||
int mask;
|
||||
#endif /* def FD_SETSIZE */
|
||||
struct sockaddr_in from;
|
||||
struct rpc_msg reply_msg;
|
||||
@ -236,9 +249,12 @@ clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
|
||||
int nrefreshes = 2; /* number of times to refresh cred */
|
||||
struct timeval timeout;
|
||||
|
||||
if (cu->cu_total.tv_usec == -1) {
|
||||
if (cu->cu_total.tv_usec == -1)
|
||||
{
|
||||
timeout = utimeout; /* use supplied timeout */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
timeout = cu->cu_total; /* use default timeout */
|
||||
}
|
||||
|
||||
@ -261,7 +277,8 @@ call_again:
|
||||
send_again:
|
||||
if (sendto (cu->cu_sock, cu->cu_outbuf, outlen, 0,
|
||||
(struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen)
|
||||
!= outlen) {
|
||||
!= outlen)
|
||||
{
|
||||
cu->cu_error.re_errno = errno;
|
||||
return (cu->cu_error.re_status = RPC_CANTSEND);
|
||||
}
|
||||
@ -269,7 +286,8 @@ send_again:
|
||||
/*
|
||||
* Hack to provide rpc-based message passing
|
||||
*/
|
||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
|
||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0)
|
||||
{
|
||||
return (cu->cu_error.re_status = RPC_TIMEDOUT);
|
||||
}
|
||||
/*
|
||||
@ -286,16 +304,19 @@ send_again:
|
||||
#else
|
||||
mask = 1 << cu->cu_sock;
|
||||
#endif /* def FD_SETSIZE */
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
struct timeval timeout = cu->cu_wait;
|
||||
readfds = mask;
|
||||
switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
|
||||
(int *)NULL, &timeout)) {
|
||||
switch (select (_rpc_dtablesize (), &readfds, (fd_set*) NULL,
|
||||
(fd_set*) NULL, &timeout))
|
||||
{
|
||||
|
||||
case 0:
|
||||
time_waited.tv_sec += cu->cu_wait.tv_sec;
|
||||
time_waited.tv_usec += cu->cu_wait.tv_usec;
|
||||
while (time_waited.tv_usec >= 1000000) {
|
||||
while (time_waited.tv_usec >= 1000000)
|
||||
{
|
||||
time_waited.tv_sec++;
|
||||
time_waited.tv_usec -= 1000000;
|
||||
}
|
||||
@ -315,13 +336,16 @@ send_again:
|
||||
cu->cu_error.re_errno = errno;
|
||||
return (cu->cu_error.re_status = RPC_CANTRECV);
|
||||
}
|
||||
do {
|
||||
do
|
||||
{
|
||||
fromlen = sizeof (struct sockaddr);
|
||||
inlen = recvfrom (cu->cu_sock, cu->cu_inbuf,
|
||||
(int) cu->cu_recvsz, 0,
|
||||
(struct sockaddr *) &from, &fromlen);
|
||||
} while (inlen < 0 && errno == EINTR);
|
||||
if (inlen < 0) {
|
||||
}
|
||||
while (inlen < 0 && errno == EINTR);
|
||||
if (inlen < 0)
|
||||
{
|
||||
if (errno == EWOULDBLOCK)
|
||||
continue;
|
||||
cu->cu_error.re_errno = errno;
|
||||
@ -342,73 +366,72 @@ send_again:
|
||||
xdrmem_create (&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
|
||||
ok = xdr_replymsg (&reply_xdrs, &reply_msg);
|
||||
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
|
||||
if (ok) {
|
||||
if (ok)
|
||||
{
|
||||
_seterr_reply (&reply_msg, &(cu->cu_error));
|
||||
if (cu->cu_error.re_status == RPC_SUCCESS) {
|
||||
if (cu->cu_error.re_status == RPC_SUCCESS)
|
||||
{
|
||||
if (!AUTH_VALIDATE (cl->cl_auth,
|
||||
&reply_msg.acpted_rply.ar_verf)) {
|
||||
&reply_msg.acpted_rply.ar_verf))
|
||||
{
|
||||
cu->cu_error.re_status = RPC_AUTHERROR;
|
||||
cu->cu_error.re_why = AUTH_INVALIDRESP;
|
||||
}
|
||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
|
||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
|
||||
{
|
||||
xdrs->x_op = XDR_FREE;
|
||||
(void) xdr_opaque_auth (xdrs,
|
||||
&(reply_msg.acpted_rply.ar_verf));
|
||||
}
|
||||
} /* end successful completion */
|
||||
else {
|
||||
else
|
||||
{
|
||||
/* maybe our credentials need to be refreshed ... */
|
||||
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) {
|
||||
if (nrefreshes > 0 && AUTH_REFRESH (cl->cl_auth))
|
||||
{
|
||||
nrefreshes--;
|
||||
goto call_again;
|
||||
}
|
||||
} /* end of unsuccessful completion */
|
||||
} /* end of valid reply message */
|
||||
else {
|
||||
else
|
||||
{
|
||||
cu->cu_error.re_status = RPC_CANTDECODERES;
|
||||
}
|
||||
return (cu->cu_error.re_status);
|
||||
return cu->cu_error.re_status;
|
||||
}
|
||||
|
||||
static void
|
||||
clntudp_geterr(cl, errp)
|
||||
CLIENT *cl;
|
||||
struct rpc_err *errp;
|
||||
clntudp_geterr (CLIENT *cl, struct rpc_err *errp)
|
||||
{
|
||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
struct cu_data *cu = (struct cu_data *) cl->cl_private;
|
||||
|
||||
*errp = cu->cu_error;
|
||||
}
|
||||
|
||||
|
||||
static bool_t
|
||||
clntudp_freeres(cl, xdr_res, res_ptr)
|
||||
CLIENT *cl;
|
||||
xdrproc_t xdr_res;
|
||||
caddr_t res_ptr;
|
||||
clntudp_freeres (CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
|
||||
{
|
||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
register XDR *xdrs = &(cu->cu_outxdrs);
|
||||
struct cu_data *cu = (struct cu_data *) cl->cl_private;
|
||||
XDR *xdrs = &(cu->cu_outxdrs);
|
||||
|
||||
xdrs->x_op = XDR_FREE;
|
||||
return ((*xdr_res)(xdrs, res_ptr));
|
||||
return (*xdr_res) (xdrs, res_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
clntudp_abort(/*h*/)
|
||||
/*CLIENT *h;*/
|
||||
clntudp_abort (void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t
|
||||
clntudp_control(cl, request, info)
|
||||
CLIENT *cl;
|
||||
int request;
|
||||
char *info;
|
||||
clntudp_control (CLIENT *cl, int request, char *info)
|
||||
{
|
||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
struct cu_data *cu = (struct cu_data *) cl->cl_private;
|
||||
|
||||
switch (request) {
|
||||
switch (request)
|
||||
{
|
||||
case CLSET_TIMEOUT:
|
||||
cu->cu_total = *(struct timeval *) info;
|
||||
break;
|
||||
@ -425,18 +448,18 @@ clntudp_control(cl, request, info)
|
||||
*(struct sockaddr_in *) info = cu->cu_raddr;
|
||||
break;
|
||||
default:
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clntudp_destroy(cl)
|
||||
CLIENT *cl;
|
||||
clntudp_destroy (CLIENT *cl)
|
||||
{
|
||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
struct cu_data *cu = (struct cu_data *) cl->cl_private;
|
||||
|
||||
if (cu->cu_closeit) {
|
||||
if (cu->cu_closeit)
|
||||
{
|
||||
(void) close (cu->cu_sock);
|
||||
}
|
||||
XDR_DESTROY (&(cu->cu_outxdrs));
|
||||
|
@ -38,6 +38,7 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/pmap_prot.h>
|
||||
#include <sys/socket.h>
|
||||
@ -53,8 +54,8 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
|
||||
/*
|
||||
* don't use gethostbyname, which would invoke yellow pages
|
||||
*/
|
||||
get_myaddress(addr)
|
||||
struct sockaddr_in *addr;
|
||||
void
|
||||
get_myaddress (struct sockaddr_in *addr)
|
||||
{
|
||||
int s;
|
||||
char buf[BUFSIZ];
|
||||
@ -62,26 +63,30 @@ get_myaddress(addr)
|
||||
struct ifreq ifreq, *ifr;
|
||||
int len;
|
||||
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
perror ("get_myaddress: socket");
|
||||
exit (1);
|
||||
}
|
||||
ifc.ifc_len = sizeof (buf);
|
||||
ifc.ifc_buf = buf;
|
||||
if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
|
||||
perror(
|
||||
_("get_myaddress: ioctl (get interface configuration)"));
|
||||
if (ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
|
||||
{
|
||||
perror (_("get_myaddress: ioctl (get interface configuration)"));
|
||||
exit (1);
|
||||
}
|
||||
ifr = ifc.ifc_req;
|
||||
for (len = ifc.ifc_len; len; len -= sizeof ifreq) {
|
||||
for (len = ifc.ifc_len; len; len -= sizeof ifreq)
|
||||
{
|
||||
ifreq = *ifr;
|
||||
if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
|
||||
if (ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
|
||||
{
|
||||
perror ("get_myaddress: ioctl");
|
||||
exit (1);
|
||||
}
|
||||
if ((ifreq.ifr_flags & IFF_UP) &&
|
||||
ifr->ifr_addr.sa_family == AF_INET) {
|
||||
ifr->ifr_addr.sa_family == AF_INET)
|
||||
{
|
||||
*addr = *((struct sockaddr_in *) &ifr->ifr_addr);
|
||||
addr->sin_port = htons (PMAPPORT);
|
||||
break;
|
||||
|
@ -38,13 +38,15 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/clnt.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
int
|
||||
getrpcport(host, prognum, versnum, proto)
|
||||
char *host;
|
||||
getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
struct hostent hostbuf, *hp;
|
||||
@ -68,5 +70,5 @@ getrpcport(host, prognum, versnum, proto)
|
||||
bcopy (hp->h_addr, (char *) &addr.sin_addr, hp->h_length);
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = 0;
|
||||
return (pmap_getport(&addr, prognum, versnum, proto));
|
||||
return pmap_getport (&addr, prognum, versnum, proto);
|
||||
}
|
||||
|
@ -47,43 +47,34 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if 0 /* these seem to be gratuitous --roland@gnu */
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#define NAMELEN 255
|
||||
#define MAX_BROADCAST_SIZE 1400
|
||||
#endif
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get a copy of the current port maps.
|
||||
* Calls the pmap service remotely to do get the maps.
|
||||
*/
|
||||
struct pmaplist *
|
||||
pmap_getmaps(address)
|
||||
struct sockaddr_in *address;
|
||||
pmap_getmaps (struct sockaddr_in *address)
|
||||
{
|
||||
struct pmaplist *head = (struct pmaplist *) NULL;
|
||||
int socket = -1;
|
||||
struct timeval minutetimeout;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
|
||||
minutetimeout.tv_sec = 60;
|
||||
minutetimeout.tv_usec = 0;
|
||||
address->sin_port = htons (PMAPPORT);
|
||||
client = clnttcp_create (address, PMAPPROG,
|
||||
PMAPVERS, &socket, 50, 500);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
|
||||
&head, minutetimeout) != RPC_SUCCESS) {
|
||||
clnt_perror(client, "pmap_getmaps rpc problem");
|
||||
if (client != (CLIENT *) NULL)
|
||||
{
|
||||
if (CLNT_CALL (client, PMAPPROC_DUMP, (xdrproc_t)xdr_void, NULL,
|
||||
(xdrproc_t)xdr_pmaplist, (caddr_t)&head,
|
||||
minutetimeout) != RPC_SUCCESS)
|
||||
{
|
||||
clnt_perror (client, _("pmap_getmaps rpc problem"));
|
||||
}
|
||||
CLNT_DESTROY (client);
|
||||
}
|
||||
/* (void)close(socket); CLNT_DESTROY already closed it */
|
||||
address->sin_port = 0;
|
||||
return (head);
|
||||
return head;
|
||||
}
|
||||
|
@ -43,12 +43,10 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#if 0 /* these seem to be gratuitous --roland@gnu */
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
static struct timeval timeout = { 5, 0 };
|
||||
static struct timeval tottimeout = { 60, 0 };
|
||||
static const struct timeval timeout =
|
||||
{5, 0};
|
||||
static const struct timeval tottimeout =
|
||||
{60, 0};
|
||||
|
||||
/*
|
||||
* Find the mapped port for program,version.
|
||||
@ -64,27 +62,32 @@ pmap_getport(address, program, version, protocol)
|
||||
{
|
||||
u_short port = 0;
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct pmap parms;
|
||||
|
||||
address->sin_port = htons (PMAPPORT);
|
||||
client = clntudp_bufcreate (address, PMAPPROG,
|
||||
PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (client != (CLIENT *) NULL)
|
||||
{
|
||||
parms.pm_prog = program;
|
||||
parms.pm_vers = version;
|
||||
parms.pm_prot = protocol;
|
||||
parms.pm_port = 0; /* not needed or used */
|
||||
if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms,
|
||||
xdr_u_short, &port, tottimeout) != RPC_SUCCESS){
|
||||
if (CLNT_CALL (client, PMAPPROC_GETPORT, (xdrproc_t)xdr_pmap,
|
||||
(caddr_t)&parms, (xdrproc_t)xdr_u_short,
|
||||
(caddr_t)&port, tottimeout) != RPC_SUCCESS)
|
||||
{
|
||||
rpc_createerr.cf_stat = RPC_PMAPFAILURE;
|
||||
clnt_geterr (client, &rpc_createerr.cf_error);
|
||||
} else if (port == 0) {
|
||||
}
|
||||
else if (port == 0)
|
||||
{
|
||||
rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
|
||||
}
|
||||
CLNT_DESTROY (client);
|
||||
}
|
||||
/* (void)close(socket); CLNT_DESTROY already closed it */
|
||||
address->sin_port = 0;
|
||||
return (port);
|
||||
return port;
|
||||
}
|
||||
|
@ -42,26 +42,21 @@ static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <rpc/pmap_prot.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
|
||||
static struct timeval timeout = { 5, 0 };
|
||||
static struct timeval tottimeout = { 60, 0 };
|
||||
|
||||
void clnt_perror();
|
||||
extern void get_myaddress (struct sockaddr_in *addr);
|
||||
|
||||
static const struct timeval timeout = {5, 0};
|
||||
static const struct timeval tottimeout = {60, 0};
|
||||
|
||||
/*
|
||||
* Set a mapping between program,version and port.
|
||||
* Calls the pmap service remotely to do the mapping.
|
||||
*/
|
||||
bool_t
|
||||
pmap_set(program, version, protocol, port)
|
||||
u_long program;
|
||||
u_long version;
|
||||
int protocol;
|
||||
u_short port;
|
||||
pmap_set (u_long program, u_long version, int protocol, u_short port)
|
||||
{
|
||||
struct sockaddr_in myaddress;
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct pmap parms;
|
||||
bool_t rslt;
|
||||
|
||||
@ -74,14 +69,16 @@ pmap_set(program, version, protocol, port)
|
||||
parms.pm_vers = version;
|
||||
parms.pm_prot = protocol;
|
||||
parms.pm_port = port;
|
||||
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
tottimeout) != RPC_SUCCESS) {
|
||||
if (CLNT_CALL (client, PMAPPROC_SET, (xdrproc_t)xdr_pmap, (caddr_t)&parms,
|
||||
(xdrproc_t)xdr_bool, (caddr_t)&rslt,
|
||||
tottimeout) != RPC_SUCCESS)
|
||||
{
|
||||
clnt_perror (client, _("Cannot register service"));
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
CLNT_DESTROY (client);
|
||||
/* (void)close(socket); CLNT_DESTROY closes it */
|
||||
return (rslt);
|
||||
return rslt;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -89,13 +86,11 @@ pmap_set(program, version, protocol, port)
|
||||
* Calls the pmap service remotely to do the un-mapping.
|
||||
*/
|
||||
bool_t
|
||||
pmap_unset(program, version)
|
||||
u_long program;
|
||||
u_long version;
|
||||
pmap_unset (u_long program, u_long version)
|
||||
{
|
||||
struct sockaddr_in myaddress;
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct pmap parms;
|
||||
bool_t rslt;
|
||||
|
||||
@ -103,13 +98,13 @@ pmap_unset(program, version)
|
||||
client = clntudp_bufcreate (&myaddress, PMAPPROG, PMAPVERS,
|
||||
timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
|
||||
if (client == (CLIENT *) NULL)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
parms.pm_prog = program;
|
||||
parms.pm_vers = version;
|
||||
parms.pm_port = parms.pm_prot = 0;
|
||||
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
tottimeout);
|
||||
CLNT_CALL (client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, (caddr_t)&parms,
|
||||
(xdrproc_t)xdr_bool, (caddr_t)&rslt, tottimeout);
|
||||
CLNT_DESTROY (client);
|
||||
/* (void)close(socket); CLNT_DESTROY already closed it */
|
||||
return (rslt);
|
||||
return rslt;
|
||||
}
|
||||
|
@ -52,6 +52,6 @@ xdr_pmap(xdrs, regs)
|
||||
if (xdr_u_long (xdrs, ®s->pm_prog) &&
|
||||
xdr_u_long (xdrs, ®s->pm_vers) &&
|
||||
xdr_u_long (xdrs, ®s->pm_prot))
|
||||
return (xdr_u_long(xdrs, ®s->pm_port));
|
||||
return (FALSE);
|
||||
return xdr_u_long (xdrs, ®s->pm_port);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
bool_t
|
||||
xdr_pmaplist (xdrs, rp)
|
||||
register XDR *xdrs;
|
||||
register struct pmaplist **rp;
|
||||
XDR *xdrs;
|
||||
struct pmaplist **rp;
|
||||
{
|
||||
/*
|
||||
* more_elements is pre-computed in case the direction is
|
||||
@ -92,15 +92,16 @@ xdr_pmaplist(xdrs, rp)
|
||||
* xdr_bool when the direction is XDR_DECODE.
|
||||
*/
|
||||
bool_t more_elements;
|
||||
register int freeing = (xdrs->x_op == XDR_FREE);
|
||||
register struct pmaplist **next;
|
||||
int freeing = (xdrs->x_op == XDR_FREE);
|
||||
struct pmaplist **next = NULL;
|
||||
|
||||
while (TRUE) {
|
||||
while (TRUE)
|
||||
{
|
||||
more_elements = (bool_t) (*rp != NULL);
|
||||
if (!xdr_bool (xdrs, &more_elements))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
if (!more_elements)
|
||||
return (TRUE); /* we are done */
|
||||
return TRUE; /* we are done */
|
||||
/*
|
||||
* the unfortunate side effect of non-recursion is that in
|
||||
* the case of freeing we must remember the next object
|
||||
@ -109,8 +110,9 @@ xdr_pmaplist(xdrs, rp)
|
||||
if (freeing)
|
||||
next = &((*rp)->pml_next);
|
||||
if (!xdr_reference (xdrs, (caddr_t *) rp,
|
||||
(u_int)sizeof(struct pmaplist), xdr_pmap))
|
||||
return (FALSE);
|
||||
rp = (freeing) ? next : &((*rp)->pml_next);
|
||||
(u_int) sizeof (struct pmaplist),
|
||||
(xdrproc_t) xdr_pmap))
|
||||
return FALSE;
|
||||
rp = freeing ? next : &((*rp)->pml_next);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/pmap_prot.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
@ -53,12 +55,8 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
|
||||
#include <arpa/inet.h>
|
||||
#define MAX_BROADCAST_SIZE 1400
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
static struct timeval timeout = {3, 0};
|
||||
|
||||
|
||||
/*
|
||||
* pmapper remote-call-service interface.
|
||||
* This routine is used to call the pmapper remote call service
|
||||
@ -76,14 +74,15 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
|
||||
u_long *port_ptr;
|
||||
{
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct rmtcallargs a;
|
||||
struct rmtcallres r;
|
||||
enum clnt_stat stat;
|
||||
|
||||
addr->sin_port = htons (PMAPPORT);
|
||||
client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &socket);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (client != (CLIENT *) NULL)
|
||||
{
|
||||
a.prog = prog;
|
||||
a.vers = vers;
|
||||
a.proc = proc;
|
||||
@ -92,15 +91,18 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
|
||||
r.port_ptr = port_ptr;
|
||||
r.results_ptr = resp;
|
||||
r.xdr_results = xdrres;
|
||||
stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a,
|
||||
xdr_rmtcallres, &r, tout);
|
||||
stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)xdr_rmtcall_args,
|
||||
(caddr_t)&a, (xdrproc_t)xdr_rmtcallres,
|
||||
(caddr_t)&r, tout);
|
||||
CLNT_DESTROY (client);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
stat = RPC_FAILED;
|
||||
}
|
||||
/* (void)close(socket); CLNT_DESTROY already closed it */
|
||||
addr->sin_port = 0;
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
@ -110,29 +112,30 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
|
||||
*/
|
||||
bool_t
|
||||
xdr_rmtcall_args (xdrs, cap)
|
||||
register XDR *xdrs;
|
||||
register struct rmtcallargs *cap;
|
||||
XDR *xdrs;
|
||||
struct rmtcallargs *cap;
|
||||
{
|
||||
u_int lenposition, argposition, position;
|
||||
|
||||
if (xdr_u_long (xdrs, &(cap->prog)) &&
|
||||
xdr_u_long (xdrs, &(cap->vers)) &&
|
||||
xdr_u_long(xdrs, &(cap->proc))) {
|
||||
xdr_u_long (xdrs, &(cap->proc)))
|
||||
{
|
||||
lenposition = XDR_GETPOS (xdrs);
|
||||
if (!xdr_u_long (xdrs, &(cap->arglen)))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
argposition = XDR_GETPOS (xdrs);
|
||||
if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
position = XDR_GETPOS (xdrs);
|
||||
cap->arglen = (u_long) position - (u_long) argposition;
|
||||
XDR_SETPOS (xdrs, lenposition);
|
||||
if (!xdr_u_long (xdrs, &(cap->arglen)))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
XDR_SETPOS (xdrs, position);
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -141,18 +144,19 @@ xdr_rmtcall_args(xdrs, cap)
|
||||
*/
|
||||
bool_t
|
||||
xdr_rmtcallres (xdrs, crp)
|
||||
register XDR *xdrs;
|
||||
register struct rmtcallres *crp;
|
||||
XDR *xdrs;
|
||||
struct rmtcallres *crp;
|
||||
{
|
||||
caddr_t port_ptr;
|
||||
|
||||
port_ptr = (caddr_t) crp->port_ptr;
|
||||
if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
|
||||
xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
|
||||
if (xdr_reference (xdrs, &port_ptr, sizeof (u_long), (xdrproc_t) xdr_u_long)
|
||||
&& xdr_u_long (xdrs, &crp->resultslen))
|
||||
{
|
||||
crp->port_ptr = (u_long *) port_ptr;
|
||||
return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
|
||||
return (*(crp->xdr_results)) (xdrs, crp->results_ptr);
|
||||
}
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -163,10 +167,9 @@ xdr_rmtcallres(xdrs, crp)
|
||||
*/
|
||||
|
||||
static int
|
||||
getbroadcastnets(addrs, sock, buf)
|
||||
struct in_addr *addrs;
|
||||
int sock; /* any valid socket will do */
|
||||
char *buf; /* why allocate more when we can use existing... */
|
||||
getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
|
||||
/* int sock: any valid socket will do */
|
||||
/* char *buf: why allocate more when we can use existing... */
|
||||
{
|
||||
struct ifconf ifc;
|
||||
struct ifreq ifreq, *ifr;
|
||||
@ -175,28 +178,35 @@ getbroadcastnets(addrs, sock, buf)
|
||||
|
||||
ifc.ifc_len = UDPMSGSIZE;
|
||||
ifc.ifc_buf = buf;
|
||||
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
|
||||
if (ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
|
||||
{
|
||||
perror (_("broadcast: ioctl (get interface configuration)"));
|
||||
return (0);
|
||||
}
|
||||
ifr = ifc.ifc_req;
|
||||
for (i = 0, n = ifc.ifc_len/sizeof (struct ifreq); n > 0; n--, ifr++) {
|
||||
for (i = 0, n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
|
||||
{
|
||||
ifreq = *ifr;
|
||||
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
|
||||
if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
|
||||
{
|
||||
perror (_("broadcast: ioctl (get interface flags)"));
|
||||
continue;
|
||||
}
|
||||
if ((ifreq.ifr_flags & IFF_BROADCAST) &&
|
||||
(ifreq.ifr_flags & IFF_UP) &&
|
||||
ifr->ifr_addr.sa_family == AF_INET) {
|
||||
ifr->ifr_addr.sa_family == AF_INET)
|
||||
{
|
||||
sin = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||
#ifdef SIOCGIFBRDADDR /* 4.3BSD */
|
||||
if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) {
|
||||
if (ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
|
||||
{
|
||||
addrs[i++] = inet_makeaddr (inet_netof
|
||||
/* Changed to pass struct instead of s_addr member
|
||||
by roland@gnu. */
|
||||
(sin->sin_addr), INADDR_ANY);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
addrs[i++] = ((struct sockaddr_in *)
|
||||
&ifreq.ifr_addr)->sin_addr;
|
||||
}
|
||||
@ -206,7 +216,7 @@ getbroadcastnets(addrs, sock, buf)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return (i);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@ -224,20 +234,20 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
enum clnt_stat stat;
|
||||
AUTH *unix_auth = authunix_create_default ();
|
||||
XDR xdr_stream;
|
||||
register XDR *xdrs = &xdr_stream;
|
||||
XDR *xdrs = &xdr_stream;
|
||||
int outlen, inlen, fromlen, nets;
|
||||
register int sock;
|
||||
int sock;
|
||||
int on = 1;
|
||||
#ifdef FD_SETSIZE
|
||||
fd_set mask;
|
||||
fd_set readfds;
|
||||
#else
|
||||
int readfds;
|
||||
register int mask;
|
||||
int mask;
|
||||
#endif /* def FD_SETSIZE */
|
||||
register int i;
|
||||
int i;
|
||||
bool_t done = FALSE;
|
||||
register u_long xid;
|
||||
u_long xid;
|
||||
u_long port;
|
||||
struct in_addr addrs[20];
|
||||
struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
|
||||
@ -251,13 +261,15 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
* initialization: create a socket, a broadcast address, and
|
||||
* preserialize the arguments into a send buffer.
|
||||
*/
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
||||
{
|
||||
perror (_("Cannot create socket for broadcast rpc"));
|
||||
stat = RPC_CANTSEND;
|
||||
goto done_broad;
|
||||
}
|
||||
#ifdef SO_BROADCAST
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
|
||||
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
|
||||
{
|
||||
perror (_("Cannot set socket option SO_BROADCAST"));
|
||||
stat = RPC_CANTSEND;
|
||||
goto done_broad;
|
||||
@ -294,7 +306,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
r.xdr_results = xresults;
|
||||
r.results_ptr = resultsp;
|
||||
xdrmem_create (xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
|
||||
if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) {
|
||||
if ((!xdr_callmsg (xdrs, &msg)) || (!xdr_rmtcall_args (xdrs, &a)))
|
||||
{
|
||||
stat = RPC_CANTENCODEARGS;
|
||||
goto done_broad;
|
||||
}
|
||||
@ -304,29 +317,34 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
* Basic loop: broadcast a packet and wait a while for response(s).
|
||||
* The response timeout grows larger per iteration.
|
||||
*/
|
||||
for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) {
|
||||
for (i = 0; i < nets; i++) {
|
||||
for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2)
|
||||
{
|
||||
for (i = 0; i < nets; i++)
|
||||
{
|
||||
baddr.sin_addr = addrs[i];
|
||||
if (sendto (sock, outbuf, outlen, 0,
|
||||
(struct sockaddr *) &baddr,
|
||||
sizeof (struct sockaddr)) != outlen) {
|
||||
sizeof (struct sockaddr)) != outlen)
|
||||
{
|
||||
perror (_("Cannot send broadcast packet"));
|
||||
stat = RPC_CANTSEND;
|
||||
goto done_broad;
|
||||
}
|
||||
}
|
||||
if (eachresult == NULL) {
|
||||
if (eachresult == NULL)
|
||||
{
|
||||
stat = RPC_SUCCESS;
|
||||
goto done_broad;
|
||||
}
|
||||
recv_again:
|
||||
msg.acpted_rply.ar_verf = _null_auth;
|
||||
msg.acpted_rply.ar_results.where = (caddr_t) & r;
|
||||
msg.acpted_rply.ar_results.proc = xdr_rmtcallres;
|
||||
msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_rmtcallres;
|
||||
readfds = mask;
|
||||
t1 = t;
|
||||
switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
|
||||
(int *)NULL, &t1)) {
|
||||
switch (select (_rpc_dtablesize (), &readfds, (fd_set *) NULL,
|
||||
(fd_set *) NULL, &t1))
|
||||
{
|
||||
|
||||
case 0: /* timed out */
|
||||
stat = RPC_TIMEDOUT;
|
||||
@ -344,7 +362,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
fromlen = sizeof (struct sockaddr);
|
||||
inlen = recvfrom (sock, inbuf, UDPMSGSIZE, 0,
|
||||
(struct sockaddr *) &raddr, &fromlen);
|
||||
if (inlen < 0) {
|
||||
if (inlen < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
goto try_again;
|
||||
perror (_("Cannot receive reply to broadcast"));
|
||||
@ -358,15 +377,19 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
* If so, decode the results.
|
||||
*/
|
||||
xdrmem_create (xdrs, inbuf, (u_int) inlen, XDR_DECODE);
|
||||
if (xdr_replymsg(xdrs, &msg)) {
|
||||
if (xdr_replymsg (xdrs, &msg))
|
||||
{
|
||||
if ((msg.rm_xid == xid) &&
|
||||
(msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
|
||||
(msg.acpted_rply.ar_stat == SUCCESS)) {
|
||||
(msg.acpted_rply.ar_stat == SUCCESS))
|
||||
{
|
||||
raddr.sin_port = htons ((u_short) port);
|
||||
done = (*eachresult) (resultsp, &raddr);
|
||||
}
|
||||
/* otherwise, we just ignore the errors ... */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef notdef
|
||||
/* some kind of deserialization problem ... */
|
||||
if (msg.rm_xid == xid)
|
||||
@ -375,19 +398,22 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
#endif
|
||||
}
|
||||
xdrs->x_op = XDR_FREE;
|
||||
msg.acpted_rply.ar_results.proc = xdr_void;
|
||||
msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
|
||||
(void) xdr_replymsg (xdrs, &msg);
|
||||
(void) (*xresults) (xdrs, resultsp);
|
||||
xdr_destroy (xdrs);
|
||||
if (done) {
|
||||
if (done)
|
||||
{
|
||||
stat = RPC_SUCCESS;
|
||||
goto done_broad;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
goto recv_again;
|
||||
}
|
||||
}
|
||||
done_broad:
|
||||
(void) close (sock);
|
||||
AUTH_DESTROY (unix_auth);
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#define _RPC_AUTH_H 1
|
||||
#include <features.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@ -76,7 +77,7 @@ union des_block {
|
||||
char c[8];
|
||||
};
|
||||
typedef union des_block des_block;
|
||||
extern bool_t xdr_des_block();
|
||||
extern bool_t xdr_des_block __P ((XDR *__xdrs, des_block *__blkp));
|
||||
|
||||
/*
|
||||
* Authentication info. Opaque to client.
|
||||
@ -90,19 +91,21 @@ struct opaque_auth {
|
||||
/*
|
||||
* Auth handle, interface to client side authenticators.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct AUTH AUTH;
|
||||
struct AUTH {
|
||||
struct opaque_auth ah_cred;
|
||||
struct opaque_auth ah_verf;
|
||||
union des_block ah_key;
|
||||
struct auth_ops {
|
||||
void (*ah_nextverf)();
|
||||
int (*ah_marshal)(); /* nextverf & serialize */
|
||||
int (*ah_validate)(); /* validate verifier */
|
||||
int (*ah_refresh)(); /* refresh credentials */
|
||||
void (*ah_destroy)(); /* destroy this structure */
|
||||
void (*ah_nextverf) __P ((AUTH *));
|
||||
int (*ah_marshal) __P ((AUTH *, XDR *)); /* nextverf & serialize */
|
||||
int (*ah_validate) __P ((AUTH *, struct opaque_auth *));
|
||||
/* validate verifier */
|
||||
int (*ah_refresh) __P ((AUTH *)); /* refresh credentials */
|
||||
void (*ah_destroy) __P ((AUTH *)); /* destroy this structure */
|
||||
} *ah_ops;
|
||||
caddr_t ah_private;
|
||||
} AUTH;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@ -160,14 +163,17 @@ extern AUTH *authunix_create __P ((char *__machname, __uid_t __uid,
|
||||
__gid_t *__aup_gids));
|
||||
extern AUTH *authunix_create_default __P ((void));
|
||||
extern AUTH *authnone_create __P ((void));
|
||||
extern AUTH *authdes_create();
|
||||
extern AUTH *authdes_create __P ((char *__servername, u_int __window,
|
||||
struct sockaddr *__syncaddr,
|
||||
des_block *__ckey));
|
||||
|
||||
#define AUTH_NONE 0 /* no authentication */
|
||||
#define AUTH_NULL 0 /* backward compatibility */
|
||||
#define AUTH_UNIX 1 /* unix style (uid, gids) */
|
||||
#define AUTH_SYS 1 /* unix style (uid, gids) */
|
||||
#define AUTH_UNIX AUTH_SYS
|
||||
#define AUTH_SHORT 2 /* short hand unix style */
|
||||
#define AUTH_DES 3 /* des style (encrypted timestamps) */
|
||||
#define AUTH_KERB 4 /* kerberos style */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -66,22 +66,33 @@ enum clnt_stat {
|
||||
RPC_PROCUNAVAIL=10, /* procedure unavailable */
|
||||
RPC_CANTDECODEARGS=11, /* decode arguments error */
|
||||
RPC_SYSTEMERROR=12, /* generic "other problem" */
|
||||
|
||||
RPC_NOBROADCAST = 21, /* Broadcasting not supported */
|
||||
/*
|
||||
* callrpc & clnt_create errors
|
||||
*/
|
||||
RPC_UNKNOWNHOST=13, /* unknown host name */
|
||||
RPC_UNKNOWNPROTO=17, /* unknown protocol */
|
||||
RPC_UNKNOWNADDR = 19, /* Remote address unknown */
|
||||
|
||||
/*
|
||||
* _ create errors
|
||||
* rpcbind errors
|
||||
*/
|
||||
RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
|
||||
RPC_RPCBFAILURE=14, /* portmapper failed in its call */
|
||||
#define RPC_PMAPFAILURE RPC_RPCBFAILURE
|
||||
RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
|
||||
RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */
|
||||
/*
|
||||
* unspecified error
|
||||
*/
|
||||
RPC_FAILED=16
|
||||
RPC_FAILED=16,
|
||||
RPC_INTR=18,
|
||||
RPC_TLIERROR=20,
|
||||
RPC_UDERROR=23,
|
||||
/*
|
||||
* asynchronous errors
|
||||
*/
|
||||
RPC_INPROGRESS = 24,
|
||||
RPC_STALERACHANDLE = 25
|
||||
};
|
||||
|
||||
|
||||
@ -114,18 +125,25 @@ struct rpc_err {
|
||||
* Created by individual implementations, see e.g. rpc_udp.c.
|
||||
* Client is responsible for initializing auth, see e.g. auth_none.c.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct CLIENT CLIENT;
|
||||
struct CLIENT {
|
||||
AUTH *cl_auth; /* authenticator */
|
||||
struct clnt_ops {
|
||||
enum clnt_stat (*cl_call)(); /* call remote procedure */
|
||||
void (*cl_abort)(); /* abort a call */
|
||||
void (*cl_geterr)(); /* get specific error code */
|
||||
bool_t (*cl_freeres)(); /* frees results */
|
||||
void (*cl_destroy)();/* destroy this structure */
|
||||
bool_t (*cl_control)();/* the ioctl() of rpc */
|
||||
enum clnt_stat (*cl_call) __P ((CLIENT *, u_long, xdrproc_t,
|
||||
caddr_t, xdrproc_t,
|
||||
caddr_t, struct timeval));
|
||||
/* call remote procedure */
|
||||
void (*cl_abort) __P ((void)); /* abort a call */
|
||||
void (*cl_geterr) __P ((CLIENT *, struct rpc_err *));
|
||||
/* get specific error code */
|
||||
bool_t (*cl_freeres) __P ((CLIENT *, xdrproc_t, caddr_t));
|
||||
/* frees results */
|
||||
void (*cl_destroy) __P ((CLIENT *)); /* destroy this structure */
|
||||
bool_t (*cl_control) __P ((CLIENT *, int, char *));
|
||||
/* the ioctl() of rpc */
|
||||
} *cl_ops;
|
||||
caddr_t cl_private; /* private stuff */
|
||||
} CLIENT;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@ -189,13 +207,26 @@ typedef struct {
|
||||
#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
|
||||
|
||||
/*
|
||||
* control operations that apply to both udp and tcp transports
|
||||
* control operations that apply to all transports
|
||||
*/
|
||||
#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
|
||||
#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
|
||||
#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
|
||||
#define CLGET_FD 6 /* get connections file descriptor */
|
||||
#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */
|
||||
#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
|
||||
#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/
|
||||
#define CLGET_XID 10 /* Get xid */
|
||||
#define CLSET_XID 11 /* Set xid */
|
||||
#define CLGET_VERS 12 /* Get version number */
|
||||
#define CLSET_VERS 13 /* Set version number */
|
||||
#define CLGET_PROG 14 /* Get program number */
|
||||
#define CLSET_PROG 15 /* Set program number */
|
||||
#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */
|
||||
#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */
|
||||
#define CLSET_POP_TIMOD 18 /* pop timod */
|
||||
/*
|
||||
* udp only control operations
|
||||
* Connectionless only control operations
|
||||
*/
|
||||
#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
|
||||
#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
|
||||
@ -239,7 +270,8 @@ typedef struct {
|
||||
* u_long prog;
|
||||
* u_long vers;
|
||||
*/
|
||||
extern CLIENT *clntraw_create __P ((u_long __prog, u_long __vers));
|
||||
extern CLIENT *clntraw_create __P ((__const u_long __prog,
|
||||
__const u_long __vers));
|
||||
|
||||
|
||||
/*
|
||||
@ -247,12 +279,12 @@ extern CLIENT *clntraw_create __P ((u_long __prog, u_long __vers));
|
||||
* CLIENT *
|
||||
* clnt_create(host, prog, vers, prot)
|
||||
* char *host; -- hostname
|
||||
* u_int prog; -- program number
|
||||
* u_int vers; -- version number
|
||||
* u_long prog; -- program number
|
||||
* u_ong vers; -- version number
|
||||
* char *prot; -- protocol
|
||||
*/
|
||||
extern CLIENT *clnt_create __P ((char *__host, u_int __prog, u_int __vers,
|
||||
char *__prot));
|
||||
extern CLIENT *clnt_create __P ((__const char *__host, __const u_long __prog,
|
||||
__const u_long __vers, __const char *__prot));
|
||||
|
||||
|
||||
/*
|
||||
@ -302,11 +334,17 @@ extern CLIENT *clntudp_bufcreate __P ((struct sockaddr_in *__raddr,
|
||||
int *__sockp, u_int __sendsz,
|
||||
u_int __recvsz));
|
||||
|
||||
extern int callrpc __P ((__const char *__host, __const u_long __prognum,
|
||||
__const u_long __versnum, __const u_long __procnum,
|
||||
__const xdrproc_t __inproc, __const char *__in,
|
||||
__const xdrproc_t __outproc, char *__out));
|
||||
extern int _rpc_dtablesize __P ((void));
|
||||
|
||||
/*
|
||||
* Print why creation failed
|
||||
*/
|
||||
extern void clnt_pcreateerror __P ((char *__msg)); /* stderr */
|
||||
extern char *clnt_spcreateerror __P ((char *__msg)); /* string */
|
||||
extern void clnt_pcreateerror __P ((__const char *__msg)); /* stderr */
|
||||
extern char *clnt_spcreateerror __P ((__const char *__msg)); /* string */
|
||||
|
||||
/*
|
||||
* Like clnt_perror(), but is more verbose in its output
|
||||
@ -316,8 +354,10 @@ extern void clnt_perrno __P ((enum clnt_stat __num)); /* stderr */
|
||||
/*
|
||||
* Print an English error message, given the client error code
|
||||
*/
|
||||
extern void clnt_perror __P ((CLIENT *__clnt, char *__msg)); /* stderr */
|
||||
extern char *clnt_sperror __P ((CLIENT *__clnt, char *__msg)); /* string */
|
||||
extern void clnt_perror __P ((CLIENT *__clnt, __const char *__msg));
|
||||
/* stderr */
|
||||
extern char *clnt_sperror __P ((CLIENT *__clnt, __const char *__msg));
|
||||
/* string */
|
||||
|
||||
/*
|
||||
* If a creation fails, the following allows the user to figure out why.
|
||||
@ -336,7 +376,8 @@ extern struct rpc_createerr rpc_createerr;
|
||||
*/
|
||||
extern char *clnt_sperrno __P ((enum clnt_stat __num)); /* string */
|
||||
|
||||
|
||||
extern int getrpcport __P ((__const char * __host, u_long __prognum,
|
||||
u_long __versnum, u_int proto));
|
||||
|
||||
#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
|
||||
#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef bool_t (*resultproc_t)();
|
||||
typedef bool_t (*resultproc_t) __P ((caddr_t resp, struct sockaddr_in *raddr));
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
@ -65,29 +65,29 @@ typedef bool_t (*resultproc_t)();
|
||||
* address if the responder to the broadcast.
|
||||
*/
|
||||
|
||||
extern bool_t pmap_set __P ((u_long __program, u_long __version,
|
||||
extern bool_t pmap_set __P ((__const u_long __program, __const u_long __vers,
|
||||
int __protocol, u_short __port));
|
||||
|
||||
extern bool_t pmap_unset __P ((u_long __program, u_long __version));
|
||||
|
||||
extern bool_t pmap_unset __P ((__const u_long __program, __const u_long __vers));
|
||||
extern struct pmaplist *pmap_getmaps __P ((struct sockaddr_in *__address));
|
||||
|
||||
extern enum clnt_stat pmap_rmtcall __P ((struct sockaddr_in *__addr,
|
||||
u_long __prog, u_long __vers,
|
||||
u_long __proc, xdrproc_t __xdrargs,
|
||||
__const u_long __prog,
|
||||
__const u_long __vers,
|
||||
__const u_long __proc,
|
||||
xdrproc_t __xdrargs,
|
||||
caddr_t __argsp, xdrproc_t __xdrres,
|
||||
caddr_t __resp, struct timeval __tout,
|
||||
u_long *__port_ptr));
|
||||
|
||||
extern enum clnt_stat clnt_broadcast __P ((u_long __prog, u_long __vers,
|
||||
u_long __proc, xdrproc_t __xargs,
|
||||
extern enum clnt_stat clnt_broadcast __P ((__const u_long __prog,
|
||||
__const u_long __vers,
|
||||
__const u_long __proc,
|
||||
xdrproc_t __xargs,
|
||||
caddr_t __argsp,
|
||||
xdrproc_t __xresults,
|
||||
caddr_t __resultsp,
|
||||
resultproc_t __eachresult));
|
||||
|
||||
extern u_short pmap_getport __P ((struct sockaddr_in *__address,
|
||||
u_long __program, u_long __version,
|
||||
__const u_long __program,
|
||||
__const u_long __version,
|
||||
u_int __protocol));
|
||||
|
||||
__END_DECLS
|
||||
|
@ -37,6 +37,9 @@
|
||||
#ifndef __SVC_HEADER__
|
||||
#define __SVC_HEADER__
|
||||
|
||||
#include <features.h>
|
||||
#include <rpc/rpc_msg.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
@ -70,23 +73,31 @@ enum xprt_stat {
|
||||
/*
|
||||
* Server side transport handle
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct SVCXPRT SVCXPRT;
|
||||
struct SVCXPRT {
|
||||
int xp_sock;
|
||||
u_short xp_port; /* associated port number */
|
||||
struct xp_ops {
|
||||
bool_t (*xp_recv)(); /* receive incoming requests */
|
||||
enum xprt_stat (*xp_stat)(); /* get transport status */
|
||||
bool_t (*xp_getargs)(); /* get arguments */
|
||||
bool_t (*xp_reply)(); /* send reply */
|
||||
bool_t (*xp_freeargs)();/* free mem allocated for args */
|
||||
void (*xp_destroy)(); /* destroy this struct */
|
||||
const struct xp_ops {
|
||||
bool_t (*xp_recv) __P ((SVCXPRT *__xprt, struct rpc_msg *__msg));
|
||||
/* receive incoming requests */
|
||||
enum xprt_stat (*xp_stat) __P ((SVCXPRT *__xprt));
|
||||
/* get transport status */
|
||||
bool_t (*xp_getargs) __P ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
|
||||
caddr_t args_ptr)); /* get arguments */
|
||||
bool_t (*xp_reply) __P ((SVCXPRT *__xprt, struct rpc_msg *__msg));
|
||||
/* send reply */
|
||||
bool_t (*xp_freeargs) __P ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
|
||||
caddr_t args_ptr));
|
||||
/* free mem allocated for args */
|
||||
void (*xp_destroy) __P ((SVCXPRT *__xprt));
|
||||
/* destroy this struct */
|
||||
} *xp_ops;
|
||||
int xp_addrlen; /* length of remote address */
|
||||
struct sockaddr_in xp_raddr; /* remote address */
|
||||
struct opaque_auth xp_verf; /* raw response verifier */
|
||||
caddr_t xp_p1; /* private */
|
||||
caddr_t xp_p2; /* private */
|
||||
} SVCXPRT;
|
||||
};
|
||||
|
||||
/*
|
||||
* Approved way of getting address of caller
|
||||
@ -153,11 +164,12 @@ struct svc_req {
|
||||
* u_long prog;
|
||||
* u_long vers;
|
||||
* void (*dispatch)();
|
||||
* int protocol; like TCP or UDP, zero means do not register
|
||||
* u_long protocol; like TCP or UDP, zero means do not register
|
||||
*/
|
||||
extern bool_t svc_register __P ((SVCXPRT *__xprt, u_long __prog,
|
||||
u_long __vers, void (*__dispatch) (),
|
||||
int __protocol));
|
||||
u_long __vers, void (*__dispatch)
|
||||
__P ((struct svc_req *, SVCXPRT *)),
|
||||
u_long __protocol));
|
||||
|
||||
/*
|
||||
* Service un-registration
|
||||
@ -257,11 +269,9 @@ extern int svc_fds;
|
||||
* a small program implemented by the svc_rpc implementation itself;
|
||||
* also see clnt.h for protocol numbers.
|
||||
*/
|
||||
extern void rpctest_service();
|
||||
|
||||
extern void svc_getreq __P ((int __rdfds));
|
||||
extern void svc_getreqset __P ((fd_set *readfds));
|
||||
extern void svc_run __P ((void)) __attribute__ ((noreturn));
|
||||
extern void svc_run __P ((void)); /* __attribute__ ((noreturn)) */
|
||||
|
||||
/*
|
||||
* Socket to use on svcxxx_create call to get default socket
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#define _RPC_SVC_AUTH_H 1
|
||||
#include <features.h>
|
||||
#include <rpc/svc.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -35,11 +35,19 @@
|
||||
#ifndef __TYPES_RPC_HEADER__
|
||||
#define __TYPES_RPC_HEADER__
|
||||
|
||||
#define bool_t int
|
||||
#define enum_t int
|
||||
#define FALSE (0)
|
||||
#define TRUE (1)
|
||||
typedef int bool_t;
|
||||
typedef int enum_t;
|
||||
|
||||
#define __dontcare__ -1
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE (0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE (1)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
@ -80,7 +80,8 @@ __BEGIN_DECLS
|
||||
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
|
||||
* request.
|
||||
*/
|
||||
enum xdr_op {
|
||||
enum xdr_op
|
||||
{
|
||||
XDR_ENCODE = 0,
|
||||
XDR_DECODE = 1,
|
||||
XDR_FREE = 2
|
||||
@ -99,23 +100,36 @@ enum xdr_op {
|
||||
* an operations vector for the particular implementation (e.g. see xdr_mem.c),
|
||||
* and two private fields for the use of the particular implementation.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct XDR XDR;
|
||||
struct XDR
|
||||
{
|
||||
enum xdr_op x_op; /* operation; fast additional param */
|
||||
struct xdr_ops {
|
||||
bool_t (*x_getlong)(); /* get a long from underlying stream */
|
||||
bool_t (*x_putlong)(); /* put a long to " */
|
||||
bool_t (*x_getbytes)();/* get some bytes from " */
|
||||
bool_t (*x_putbytes)();/* put some bytes to " */
|
||||
u_int (*x_getpostn)();/* returns bytes off from beginning */
|
||||
bool_t (*x_setpostn)();/* lets you reposition the stream */
|
||||
long * (*x_inline)(); /* buf quick ptr to buffered data */
|
||||
void (*x_destroy)(); /* free privates of this xdr_stream */
|
||||
} *x_ops;
|
||||
const struct xdr_ops
|
||||
{
|
||||
bool_t (*x_getlong) __P ((XDR * __xdrs, long *__lp));
|
||||
/* get a long from underlying stream */
|
||||
bool_t (*x_putlong) __P ((XDR * __xdrs, long *__lp));
|
||||
/* put a long to " */
|
||||
bool_t (*x_getbytes) __P ((XDR * __xdrs, caddr_t __addr, u_int __len));
|
||||
/* get some bytes from " */
|
||||
bool_t (*x_putbytes) __P ((XDR * __xdrs, __const caddr_t __addr,
|
||||
u_int __len));
|
||||
/* put some bytes to " */
|
||||
u_int (*x_getpostn) __P ((XDR * __xdrs));
|
||||
/* returns bytes off from beginning */
|
||||
bool_t (*x_setpostn) __P ((XDR * __xdrs, u_int pos));
|
||||
/* lets you reposition the stream */
|
||||
long *(*x_inline) __P ((XDR * __xdrs, int len));
|
||||
/* buf quick ptr to buffered data */
|
||||
void (*x_destroy) __P ((XDR * __xdrs));
|
||||
/* free privates of this xdr_stream */
|
||||
}
|
||||
*x_ops;
|
||||
caddr_t x_public; /* users' data */
|
||||
caddr_t x_private; /* pointer to private data */
|
||||
caddr_t x_base; /* private used for position info */
|
||||
int x_handy; /* extra private word */
|
||||
} XDR;
|
||||
};
|
||||
|
||||
/*
|
||||
* A xdrproc_t exists for each data type which is to be encoded or decoded.
|
||||
@ -126,7 +140,8 @@ typedef struct {
|
||||
* allocate dynamic storage of the appropriate size and return it.
|
||||
* bool_t (*xdrproc_t)(XDR *, caddr_t *);
|
||||
*/
|
||||
typedef bool_t (*xdrproc_t) __P ((XDR *, void *, ...));
|
||||
typedef
|
||||
bool_t (*xdrproc_t) __P ((XDR *, void *,...));
|
||||
|
||||
/*
|
||||
* Operations defined on a XDR handle
|
||||
@ -190,7 +205,8 @@ typedef bool_t (*xdrproc_t) __P ((XDR *, void *, ...));
|
||||
* If there is no match and no default routine it is an error.
|
||||
*/
|
||||
#define NULL_xdrproc_t ((xdrproc_t)0)
|
||||
struct xdr_discrim {
|
||||
struct xdr_discrim
|
||||
{
|
||||
int value;
|
||||
xdrproc_t proc;
|
||||
};
|
||||
@ -228,7 +244,7 @@ struct xdr_discrim {
|
||||
/*
|
||||
* These are the "generic" xdr routines.
|
||||
*/
|
||||
extern bool_t xdr_void ();
|
||||
extern bool_t xdr_void __P ((void));
|
||||
extern bool_t xdr_int __P ((XDR * __xdrs, int *__ip));
|
||||
extern bool_t xdr_u_int __P ((XDR * __xdrs, u_int * __up));
|
||||
extern bool_t xdr_long __P ((XDR * __xdrs, long *__lp));
|
||||
@ -245,7 +261,7 @@ extern bool_t xdr_bytes __P ((XDR *__xdrs, char **__cpp, u_int *__sizep,
|
||||
extern bool_t xdr_opaque __P ((XDR * __xdrs, caddr_t __cp, u_int __cnt));
|
||||
extern bool_t xdr_string __P ((XDR * __xdrs, char **__cpp, u_int __maxsize));
|
||||
extern bool_t xdr_union __P ((XDR * __xdrs, enum_t * __dscmp, char *__unp,
|
||||
struct xdr_discrim *__choices,
|
||||
__const struct xdr_discrim * __choices,
|
||||
xdrproc_t dfault));
|
||||
extern bool_t xdr_char __P ((XDR * __xdrs, char *__cp));
|
||||
extern bool_t xdr_u_char __P ((XDR * __xdrs, u_char * __cp));
|
||||
@ -264,7 +280,8 @@ extern bool_t xdr_wrapstring __P ((XDR *__xdrs, char **__cpp));
|
||||
* declared here due to commonality.
|
||||
*/
|
||||
#define MAX_NETOBJ_SZ 1024
|
||||
struct netobj {
|
||||
struct netobj
|
||||
{
|
||||
u_int n_len;
|
||||
char *n_bytes;
|
||||
};
|
||||
@ -287,7 +304,8 @@ extern void xdrstdio_create __P ((XDR *__xdrs, FILE *__file,
|
||||
/* XDR pseudo records for tcp */
|
||||
extern void xdrrec_create __P ((XDR * __xdrs, u_int __sendsize,
|
||||
u_int __recvsize, caddr_t __tcp_handle,
|
||||
int (*__readit) (), int (*__writeit) ()));
|
||||
int (*__readit) (char *, char *, int),
|
||||
int (*__writeit) (char *, char *, int)));
|
||||
|
||||
/* make end of xdr record */
|
||||
extern bool_t xdrrec_endofrecord __P ((XDR * __xdrs, bool_t __sendnow));
|
||||
|
@ -46,7 +46,7 @@ char clntout_rcsid[] =
|
||||
#include "proto.h"
|
||||
|
||||
#define DEFAULT_TIMEOUT 25 /* in seconds */
|
||||
static char RESULT[] = "clnt_res";
|
||||
static const char RESULT[] = "clnt_res";
|
||||
|
||||
static void write_program (definition * def);
|
||||
static void printbody (proc_list * proc);
|
||||
@ -64,9 +64,11 @@ write_stubs(void)
|
||||
"\n/* Default timeout can be changed using clnt_control() */\n");
|
||||
f_print (fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
|
||||
DEFAULT_TIMEOUT);
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind == DEF_PROGRAM) {
|
||||
if (def->def_kind == DEF_PROGRAM)
|
||||
{
|
||||
write_program (def);
|
||||
}
|
||||
}
|
||||
@ -78,8 +80,10 @@ write_program(definition *def)
|
||||
version_list *vp;
|
||||
proc_list *proc;
|
||||
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
ptype (proc->res_prefix, proc->res_type, 1);
|
||||
f_print (fout, "*\n");
|
||||
@ -99,43 +103,56 @@ write_program(definition *def)
|
||||
|
||||
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
|
||||
|
||||
void printarglist(proc_list *proc,
|
||||
void
|
||||
printarglist (proc_list * proc,
|
||||
const char *addargname, const char *addargtype)
|
||||
{
|
||||
|
||||
decl_list *l;
|
||||
|
||||
if (!newstyle) { /* old style: always pass argument by reference */
|
||||
if (Cflag) { /* C++ style heading */
|
||||
if (!newstyle)
|
||||
{ /* old style: always pass argument by reference */
|
||||
if (Cflag)
|
||||
{ /* C++ style heading */
|
||||
f_print (fout, "(");
|
||||
ptype (proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
|
||||
f_print (fout, "*argp, %s%s)\n", addargtype, addargname);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (fout, "(argp, %s)\n", addargname);
|
||||
f_print (fout, "\t");
|
||||
ptype (proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
|
||||
f_print (fout, "*argp;\n");
|
||||
}
|
||||
} else if (streq( proc->args.decls->decl.type, "void")) {
|
||||
}
|
||||
else if (streq (proc->args.decls->decl.type, "void"))
|
||||
{
|
||||
/* newstyle, 0 argument */
|
||||
if (Cflag)
|
||||
f_print (fout, "(%s%s)\n", addargtype, addargname);
|
||||
else
|
||||
f_print (fout, "(%s)\n", addargname);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* new style, 1 or multiple arguments */
|
||||
if( !Cflag ) {
|
||||
if (!Cflag)
|
||||
{
|
||||
f_print (fout, "(");
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
f_print (fout, "%s, ", l->decl.name);
|
||||
f_print (fout, "%s)\n", addargname);
|
||||
for (l = proc->args.decls; l != NULL; l = l->next) {
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
{
|
||||
pdeclaration (proc->args.argname, &l->decl, 1, ";\n");
|
||||
}
|
||||
} else { /* C++ style header */
|
||||
}
|
||||
else
|
||||
{ /* C++ style header */
|
||||
f_print (fout, "(");
|
||||
for(l = proc->args.decls; l != NULL; l = l->next) {
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
{
|
||||
pdeclaration (proc->args.argname, &l->decl, 0, ", ");
|
||||
}
|
||||
f_print (fout, " %s%s)\n", addargtype, addargname);
|
||||
@ -152,10 +169,13 @@ static
|
||||
const char *
|
||||
ampr (const char *type)
|
||||
{
|
||||
if (isvectordef(type, REL_ALIAS)) {
|
||||
return ("");
|
||||
} else {
|
||||
return ("&");
|
||||
if (isvectordef (type, REL_ALIAS))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "&";
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,21 +188,26 @@ printbody(proc_list *proc)
|
||||
|
||||
/* For new style with multiple arguments, need a structure in which
|
||||
to stuff the arguments. */
|
||||
if ( newstyle && args2) {
|
||||
if (newstyle && args2)
|
||||
{
|
||||
f_print (fout, "\t%s", proc->args.argname);
|
||||
f_print (fout, " arg;\n");
|
||||
}
|
||||
f_print (fout, "\tstatic ");
|
||||
if (streq(proc->res_type, "void")) {
|
||||
if (streq (proc->res_type, "void"))
|
||||
{
|
||||
f_print (fout, "char ");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ptype (proc->res_prefix, proc->res_type, 0);
|
||||
}
|
||||
f_print (fout, "%s;\n", RESULT);
|
||||
f_print (fout, "\n");
|
||||
f_print (fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
|
||||
ampr (proc->res_type), RESULT, RESULT);
|
||||
if (newstyle && !args2 && (streq( proc->args.decls->decl.type, "void"))) {
|
||||
if (newstyle && !args2 && (streq (proc->args.decls->decl.type, "void")))
|
||||
{
|
||||
/* newstyle, 0 arguments */
|
||||
f_print (fout,
|
||||
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name);
|
||||
@ -190,9 +215,12 @@ printbody(proc_list *proc)
|
||||
", NULL, xdr_%s, %s,%s, TIMEOUT) != RPC_SUCCESS) {\n",
|
||||
stringfix (proc->res_type), ampr (proc->res_type), RESULT);
|
||||
|
||||
} else if ( newstyle && args2) {
|
||||
}
|
||||
else if (newstyle && args2)
|
||||
{
|
||||
/* newstyle, multiple arguments: stuff arguments into structure */
|
||||
for (l = proc->args.decls; l != NULL; l = l->next) {
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
{
|
||||
f_print (fout, "\targ.%s = %s;\n",
|
||||
l->decl.name, l->decl.name);
|
||||
}
|
||||
@ -202,7 +230,9 @@ printbody(proc_list *proc)
|
||||
f_print (fout,
|
||||
", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
|
||||
stringfix (proc->res_type), ampr (proc->res_type), RESULT);
|
||||
} else { /* single argument, new or old style */
|
||||
}
|
||||
else
|
||||
{ /* single argument, new or old style */
|
||||
f_print (fout,
|
||||
"\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
|
||||
proc->proc_name,
|
||||
@ -213,10 +243,13 @@ printbody(proc_list *proc)
|
||||
}
|
||||
f_print (fout, "\t\treturn (NULL);\n");
|
||||
f_print (fout, "\t}\n");
|
||||
if (streq(proc->res_type, "void")) {
|
||||
if (streq (proc->res_type, "void"))
|
||||
{
|
||||
f_print (fout, "\treturn ((void *)%s%s);\n",
|
||||
ampr (proc->res_type), RESULT);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "\treturn (%s%s);\n", ampr (proc->res_type), RESULT);
|
||||
}
|
||||
}
|
||||
|
@ -38,41 +38,47 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
|
||||
|
||||
/*
|
||||
* XDR a call message
|
||||
*/
|
||||
bool_t
|
||||
xdr_callmsg(xdrs, cmsg)
|
||||
register XDR *xdrs;
|
||||
register struct rpc_msg *cmsg;
|
||||
xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
|
||||
{
|
||||
register long *buf;
|
||||
register struct opaque_auth *oa;
|
||||
long *buf;
|
||||
struct opaque_auth *oa;
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
|
||||
if (xdrs->x_op == XDR_ENCODE)
|
||||
{
|
||||
if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
|
||||
if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT
|
||||
+ RNDUP (cmsg->rm_call.cb_cred.oa_length)
|
||||
+ 2 * BYTES_PER_XDR_UNIT
|
||||
+ RNDUP (cmsg->rm_call.cb_verf.oa_length));
|
||||
if (buf != NULL) {
|
||||
if (buf != NULL)
|
||||
{
|
||||
IXDR_PUT_LONG (buf, cmsg->rm_xid);
|
||||
IXDR_PUT_ENUM (buf, cmsg->rm_direction);
|
||||
if (cmsg->rm_direction != CALL) {
|
||||
return (FALSE);
|
||||
if (cmsg->rm_direction != CALL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
IXDR_PUT_LONG (buf, cmsg->rm_call.cb_rpcvers);
|
||||
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
|
||||
return (FALSE);
|
||||
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
IXDR_PUT_LONG (buf, cmsg->rm_call.cb_prog);
|
||||
IXDR_PUT_LONG (buf, cmsg->rm_call.cb_vers);
|
||||
@ -80,33 +86,39 @@ xdr_callmsg(xdrs, cmsg)
|
||||
oa = &cmsg->rm_call.cb_cred;
|
||||
IXDR_PUT_ENUM (buf, oa->oa_flavor);
|
||||
IXDR_PUT_LONG (buf, oa->oa_length);
|
||||
if (oa->oa_length) {
|
||||
if (oa->oa_length)
|
||||
{
|
||||
bcopy (oa->oa_base, (caddr_t) buf, oa->oa_length);
|
||||
buf = (long *) ((char *) buf + RNDUP (oa->oa_length));
|
||||
}
|
||||
oa = &cmsg->rm_call.cb_verf;
|
||||
IXDR_PUT_ENUM (buf, oa->oa_flavor);
|
||||
IXDR_PUT_LONG (buf, oa->oa_length);
|
||||
if (oa->oa_length) {
|
||||
if (oa->oa_length)
|
||||
{
|
||||
bcopy (oa->oa_base, (caddr_t) buf, oa->oa_length);
|
||||
/* no real need....
|
||||
buf = (long *) ((char *) buf + RNDUP(oa->oa_length));
|
||||
*/
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (xdrs->x_op == XDR_DECODE) {
|
||||
if (xdrs->x_op == XDR_DECODE)
|
||||
{
|
||||
buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT);
|
||||
if (buf != NULL) {
|
||||
if (buf != NULL)
|
||||
{
|
||||
cmsg->rm_xid = IXDR_GET_LONG (buf);
|
||||
cmsg->rm_direction = IXDR_GET_ENUM (buf, enum msg_type);
|
||||
if (cmsg->rm_direction != CALL) {
|
||||
return (FALSE);
|
||||
if (cmsg->rm_direction != CALL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG (buf);
|
||||
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
|
||||
return (FALSE);
|
||||
if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
cmsg->rm_call.cb_prog = IXDR_GET_LONG (buf);
|
||||
cmsg->rm_call.cb_vers = IXDR_GET_LONG (buf);
|
||||
@ -114,21 +126,28 @@ xdr_callmsg(xdrs, cmsg)
|
||||
oa = &cmsg->rm_call.cb_cred;
|
||||
oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t);
|
||||
oa->oa_length = IXDR_GET_LONG (buf);
|
||||
if (oa->oa_length) {
|
||||
if (oa->oa_length > MAX_AUTH_BYTES) {
|
||||
return (FALSE);
|
||||
if (oa->oa_length)
|
||||
{
|
||||
if (oa->oa_length > MAX_AUTH_BYTES)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (oa->oa_base == NULL) {
|
||||
if (oa->oa_base == NULL)
|
||||
{
|
||||
oa->oa_base = (caddr_t)
|
||||
mem_alloc (oa->oa_length);
|
||||
}
|
||||
buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length));
|
||||
if (buf == NULL) {
|
||||
if (buf == NULL)
|
||||
{
|
||||
if (xdr_opaque (xdrs, oa->oa_base,
|
||||
oa->oa_length) == FALSE) {
|
||||
return (FALSE);
|
||||
oa->oa_length) == FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
bcopy ((caddr_t) buf, oa->oa_base,
|
||||
oa->oa_length);
|
||||
/* no real need....
|
||||
@ -139,30 +158,41 @@ xdr_callmsg(xdrs, cmsg)
|
||||
}
|
||||
oa = &cmsg->rm_call.cb_verf;
|
||||
buf = XDR_INLINE (xdrs, 2 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (buf == NULL)
|
||||
{
|
||||
if (xdr_enum (xdrs, &oa->oa_flavor) == FALSE ||
|
||||
xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
|
||||
return (FALSE);
|
||||
xdr_u_int (xdrs, &oa->oa_length) == FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t);
|
||||
oa->oa_length = IXDR_GET_LONG (buf);
|
||||
}
|
||||
if (oa->oa_length) {
|
||||
if (oa->oa_length > MAX_AUTH_BYTES) {
|
||||
return (FALSE);
|
||||
if (oa->oa_length)
|
||||
{
|
||||
if (oa->oa_length > MAX_AUTH_BYTES)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (oa->oa_base == NULL) {
|
||||
if (oa->oa_base == NULL)
|
||||
{
|
||||
oa->oa_base = (caddr_t)
|
||||
mem_alloc (oa->oa_length);
|
||||
}
|
||||
buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length));
|
||||
if (buf == NULL) {
|
||||
if (buf == NULL)
|
||||
{
|
||||
if (xdr_opaque (xdrs, oa->oa_base,
|
||||
oa->oa_length) == FALSE) {
|
||||
return (FALSE);
|
||||
oa->oa_length) == FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
bcopy ((caddr_t) buf, oa->oa_base,
|
||||
oa->oa_length);
|
||||
/* no real need...
|
||||
@ -171,7 +201,7 @@ xdr_callmsg(xdrs, cmsg)
|
||||
*/
|
||||
}
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (
|
||||
@ -184,7 +214,6 @@ xdr_callmsg(xdrs, cmsg)
|
||||
xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers)) &&
|
||||
xdr_u_long (xdrs, &(cmsg->rm_call.cb_proc)) &&
|
||||
xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_cred)))
|
||||
return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
|
||||
return (FALSE);
|
||||
return xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_verf));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -31,16 +31,19 @@
|
||||
static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
* Cache the result of getdtablesize(), so we don't have to do an
|
||||
* expensive system call every time.
|
||||
*/
|
||||
_rpc_dtablesize()
|
||||
int
|
||||
_rpc_dtablesize (void)
|
||||
{
|
||||
static int size;
|
||||
|
||||
if (size == 0) {
|
||||
if (size == 0)
|
||||
size = getdtablesize ();
|
||||
}
|
||||
return (size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -55,26 +55,22 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
|
||||
* (see auth.h)
|
||||
*/
|
||||
bool_t
|
||||
xdr_opaque_auth(xdrs, ap)
|
||||
register XDR *xdrs;
|
||||
register struct opaque_auth *ap;
|
||||
xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
|
||||
{
|
||||
|
||||
if (xdr_enum (xdrs, &(ap->oa_flavor)))
|
||||
return (xdr_bytes(xdrs, &ap->oa_base,
|
||||
&ap->oa_length, MAX_AUTH_BYTES));
|
||||
return (FALSE);
|
||||
return xdr_bytes (xdrs, &ap->oa_base,
|
||||
&ap->oa_length, MAX_AUTH_BYTES);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* XDR a DES block
|
||||
*/
|
||||
bool_t
|
||||
xdr_des_block(xdrs, blkp)
|
||||
register XDR *xdrs;
|
||||
register des_block *blkp;
|
||||
xdr_des_block (XDR *xdrs, des_block *blkp)
|
||||
{
|
||||
return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
|
||||
return xdr_opaque (xdrs, (caddr_t) blkp, sizeof (des_block));
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
|
||||
@ -83,57 +79,53 @@ xdr_des_block(xdrs, blkp)
|
||||
* XDR the MSG_ACCEPTED part of a reply message union
|
||||
*/
|
||||
bool_t
|
||||
xdr_accepted_reply(xdrs, ar)
|
||||
register XDR *xdrs;
|
||||
register struct accepted_reply *ar;
|
||||
xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
|
||||
{
|
||||
|
||||
/* personalized union, rather than calling xdr_union */
|
||||
if (!xdr_opaque_auth (xdrs, &(ar->ar_verf)))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
if (!xdr_enum (xdrs, (enum_t *) & (ar->ar_stat)))
|
||||
return (FALSE);
|
||||
switch (ar->ar_stat) {
|
||||
|
||||
return FALSE;
|
||||
switch (ar->ar_stat)
|
||||
{
|
||||
case SUCCESS:
|
||||
return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where));
|
||||
|
||||
case PROG_MISMATCH:
|
||||
if (!xdr_u_long (xdrs, &(ar->ar_vers.low)))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
return (xdr_u_long (xdrs, &(ar->ar_vers.high)));
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
return (TRUE); /* TRUE => open ended set of problems */
|
||||
return TRUE; /* TRUE => open ended set of problems */
|
||||
}
|
||||
|
||||
/*
|
||||
* XDR the MSG_DENIED part of a reply message union
|
||||
*/
|
||||
bool_t
|
||||
xdr_rejected_reply(xdrs, rr)
|
||||
register XDR *xdrs;
|
||||
register struct rejected_reply *rr;
|
||||
xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
|
||||
{
|
||||
|
||||
/* personalized union, rather than calling xdr_union */
|
||||
if (!xdr_enum (xdrs, (enum_t *) & (rr->rj_stat)))
|
||||
return (FALSE);
|
||||
switch (rr->rj_stat) {
|
||||
|
||||
return FALSE;
|
||||
switch (rr->rj_stat)
|
||||
{
|
||||
case RPC_MISMATCH:
|
||||
if (!xdr_u_long (xdrs, &(rr->rj_vers.low)))
|
||||
return (FALSE);
|
||||
return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
|
||||
return FALSE;
|
||||
return xdr_u_long (xdrs, &(rr->rj_vers.high));
|
||||
|
||||
case AUTH_ERROR:
|
||||
return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
|
||||
return xdr_enum (xdrs, (enum_t *) & (rr->rj_why));
|
||||
}
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static struct xdr_discrim reply_dscrm[3] = {
|
||||
{ (int)MSG_ACCEPTED, xdr_accepted_reply },
|
||||
{ (int)MSG_DENIED, xdr_rejected_reply },
|
||||
static const struct xdr_discrim reply_dscrm[3] =
|
||||
{
|
||||
{(int) MSG_ACCEPTED, (xdrproc_t) xdr_accepted_reply},
|
||||
{(int) MSG_DENIED, (xdrproc_t) xdr_rejected_reply},
|
||||
{__dontcare__, NULL_xdrproc_t}};
|
||||
|
||||
/*
|
||||
@ -141,16 +133,16 @@ static struct xdr_discrim reply_dscrm[3] = {
|
||||
*/
|
||||
bool_t
|
||||
xdr_replymsg (xdrs, rmsg)
|
||||
register XDR *xdrs;
|
||||
register struct rpc_msg *rmsg;
|
||||
XDR *xdrs;
|
||||
struct rpc_msg *rmsg;
|
||||
{
|
||||
if (
|
||||
xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
|
||||
if (xdr_u_long (xdrs, &(rmsg->rm_xid)) &&
|
||||
xdr_enum (xdrs, (enum_t *) & (rmsg->rm_direction)) &&
|
||||
(rmsg->rm_direction == REPLY))
|
||||
return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
|
||||
(caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
|
||||
return (FALSE);
|
||||
return xdr_union (xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat),
|
||||
(caddr_t) & (rmsg->rm_reply.ru), reply_dscrm,
|
||||
NULL_xdrproc_t);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -161,8 +153,8 @@ xdr_replymsg(xdrs, rmsg)
|
||||
*/
|
||||
bool_t
|
||||
xdr_callhdr (xdrs, cmsg)
|
||||
register XDR *xdrs;
|
||||
register struct rpc_msg *cmsg;
|
||||
XDR *xdrs;
|
||||
struct rpc_msg *cmsg;
|
||||
{
|
||||
|
||||
cmsg->rm_direction = CALL;
|
||||
@ -173,19 +165,18 @@ xdr_callhdr(xdrs, cmsg)
|
||||
xdr_enum (xdrs, (enum_t *) & (cmsg->rm_direction)) &&
|
||||
xdr_u_long (xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
|
||||
xdr_u_long (xdrs, &(cmsg->rm_call.cb_prog)))
|
||||
return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
|
||||
return (FALSE);
|
||||
return xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* ************************** Client utility routine ************* */
|
||||
|
||||
static void
|
||||
accepted(acpt_stat, error)
|
||||
register enum accept_stat acpt_stat;
|
||||
register struct rpc_err *error;
|
||||
accepted (enum accept_stat acpt_stat,
|
||||
struct rpc_err *error)
|
||||
{
|
||||
switch (acpt_stat)
|
||||
{
|
||||
|
||||
switch (acpt_stat) {
|
||||
|
||||
case PROG_UNAVAIL:
|
||||
error->re_status = RPC_PROGUNAVAIL;
|
||||
@ -218,41 +209,39 @@ accepted(acpt_stat, error)
|
||||
}
|
||||
|
||||
static void
|
||||
rejected(rjct_stat, error)
|
||||
register enum reject_stat rjct_stat;
|
||||
register struct rpc_err *error;
|
||||
rejected (enum reject_stat rjct_stat,
|
||||
struct rpc_err *error)
|
||||
{
|
||||
switch (rjct_stat)
|
||||
{
|
||||
|
||||
switch (rjct_stat) {
|
||||
|
||||
case RPC_VERSMISMATCH:
|
||||
error->re_status = RPC_VERSMISMATCH;
|
||||
return;
|
||||
|
||||
case AUTH_ERROR:
|
||||
error->re_status = RPC_AUTHERROR;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
/* something's wrong, but we don't know what ... */
|
||||
error->re_status = RPC_FAILED;
|
||||
error->re_lb.s1 = (long) MSG_DENIED;
|
||||
error->re_lb.s2 = (long) rjct_stat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* given a reply message, fills in the error
|
||||
*/
|
||||
void
|
||||
_seterr_reply(msg, error)
|
||||
register struct rpc_msg *msg;
|
||||
register struct rpc_err *error;
|
||||
_seterr_reply (struct rpc_msg *msg,
|
||||
struct rpc_err *error)
|
||||
{
|
||||
|
||||
/* optimized for normal, SUCCESSful case */
|
||||
switch (msg->rm_reply.rp_stat) {
|
||||
|
||||
switch (msg->rm_reply.rp_stat)
|
||||
{
|
||||
case MSG_ACCEPTED:
|
||||
if (msg->acpted_rply.ar_stat == SUCCESS) {
|
||||
if (msg->acpted_rply.ar_stat == SUCCESS)
|
||||
{
|
||||
error->re_status = RPC_SUCCESS;
|
||||
return;
|
||||
};
|
||||
@ -268,7 +257,8 @@ _seterr_reply(msg, error)
|
||||
error->re_lb.s1 = (long) (msg->rm_reply.rp_stat);
|
||||
break;
|
||||
}
|
||||
switch (error->re_status) {
|
||||
switch (error->re_status)
|
||||
{
|
||||
|
||||
case RPC_VERSMISMATCH:
|
||||
error->re_vers.low = msg->rjcted_rply.rj_vers.low;
|
||||
@ -283,5 +273,7 @@ _seterr_reply(msg, error)
|
||||
error->re_vers.low = msg->acpted_rply.ar_vers.low;
|
||||
error->re_vers.high = msg->acpted_rply.ar_vers.high;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ char sample_rcsid[] =
|
||||
#include "proto.h"
|
||||
|
||||
|
||||
static char RQSTP[] = "rqstp";
|
||||
static const char RQSTP[] = "rqstp";
|
||||
|
||||
static void write_sample_client (const char *program_name, version_list * vp);
|
||||
static void write_sample_server (definition * def);
|
||||
@ -71,7 +71,8 @@ write_sample_clnt(definition *def)
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
return (0);
|
||||
/* generate sample code for each version */
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
write_sample_client (def->def_name, vp);
|
||||
++count;
|
||||
}
|
||||
@ -95,12 +96,14 @@ write_sample_client(const char *program_name, version_list *vp)
|
||||
f_print (fout, "\tCLIENT *clnt;\n");
|
||||
|
||||
i = 0;
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\t");
|
||||
ptype (proc->res_prefix, proc->res_type, 1);
|
||||
f_print (fout, " *result_%d;\n", ++i);
|
||||
/* print out declarations for arguments */
|
||||
if( proc->arg_num < 2 && !newstyle) {
|
||||
if (proc->arg_num < 2 && !newstyle)
|
||||
{
|
||||
f_print (fout, "\t");
|
||||
if (!streq (proc->args.decls->decl.type, "void"))
|
||||
ptype (proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
|
||||
@ -109,8 +112,11 @@ write_sample_client(const char *program_name, version_list *vp)
|
||||
f_print (fout, " ");
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
f_print (fout, "_arg;\n");
|
||||
} else if (!streq( proc->args.decls->decl.type, "void")) {
|
||||
for (l = proc->args.decls; l != NULL; l = l->next) {
|
||||
}
|
||||
else if (!streq (proc->args.decls->decl.type, "void"))
|
||||
{
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
{
|
||||
f_print (fout, "\t");
|
||||
ptype (l->decl.prefix, l->decl.type, 1);
|
||||
f_print (fout, " ");
|
||||
@ -130,22 +136,28 @@ write_sample_client(const char *program_name, version_list *vp)
|
||||
|
||||
/* generate calls to procedures */
|
||||
i = 0;
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\tresult_%d = ", ++i);
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
if (proc->arg_num < 2 && !newstyle) {
|
||||
if (proc->arg_num < 2 && !newstyle)
|
||||
{
|
||||
f_print (fout, "(");
|
||||
if (streq (proc->args.decls->decl.type, "void")) /* cast to void* */
|
||||
f_print (fout, "(void*)");
|
||||
f_print (fout, "&");
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
f_print (fout, "_arg, clnt);\n");
|
||||
} else if (streq( proc->args.decls->decl.type, "void")) {
|
||||
}
|
||||
else if (streq (proc->args.decls->decl.type, "void"))
|
||||
{
|
||||
f_print (fout, "(clnt);\n");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (fout, "(");
|
||||
for (l = proc->args.decls; l != NULL; l = l->next) {
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
{
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
f_print (fout, "_%s, ", l->decl.name);
|
||||
}
|
||||
@ -166,8 +178,10 @@ write_sample_server(definition *def)
|
||||
version_list *vp;
|
||||
proc_list *proc;
|
||||
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
/* if( Cflag )
|
||||
f_print( fout, "extern \"C\"{\n");
|
||||
@ -238,12 +252,15 @@ write_sample_clnt_main(void)
|
||||
f_print (fout, "\t\texit(1);\n\t}");
|
||||
f_print (fout, "\n\thost = argv[1];\n");
|
||||
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = l->val;
|
||||
if (def->def_kind != DEF_PROGRAM) {
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout, "\t");
|
||||
pvname (def->def_name, vp->vers_num);
|
||||
f_print (fout, "( host );\n");
|
||||
|
@ -69,7 +69,8 @@ void
|
||||
scan (tok_kind expect, token * tokp)
|
||||
{
|
||||
get_token (tokp);
|
||||
if (tokp->kind != expect) {
|
||||
if (tokp->kind != expect)
|
||||
{
|
||||
expected1 (expect);
|
||||
}
|
||||
}
|
||||
@ -81,7 +82,8 @@ void
|
||||
scan2 (tok_kind expect1, tok_kind expect2, token * tokp)
|
||||
{
|
||||
get_token (tokp);
|
||||
if (tokp->kind != expect1 && tokp->kind != expect2) {
|
||||
if (tokp->kind != expect1 && tokp->kind != expect2)
|
||||
{
|
||||
expected2 (expect1, expect2);
|
||||
}
|
||||
}
|
||||
@ -94,7 +96,8 @@ scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
|
||||
{
|
||||
get_token (tokp);
|
||||
if (tokp->kind != expect1 && tokp->kind != expect2
|
||||
&& tokp->kind != expect3) {
|
||||
&& tokp->kind != expect3)
|
||||
{
|
||||
expected3 (expect1, expect2, expect3);
|
||||
}
|
||||
}
|
||||
@ -106,7 +109,8 @@ void
|
||||
scan_num (token * tokp)
|
||||
{
|
||||
get_token (tokp);
|
||||
switch (tokp->kind) {
|
||||
switch (tokp->kind)
|
||||
{
|
||||
case TOK_IDENT:
|
||||
break;
|
||||
default:
|
||||
@ -131,7 +135,8 @@ int
|
||||
peekscan (tok_kind expect, token * tokp)
|
||||
{
|
||||
peek (tokp);
|
||||
if (tokp->kind == expect) {
|
||||
if (tokp->kind == expect)
|
||||
{
|
||||
get_token (tokp);
|
||||
return (1);
|
||||
}
|
||||
@ -146,50 +151,73 @@ get_token(token *tokp)
|
||||
{
|
||||
int commenting;
|
||||
|
||||
if (pushed) {
|
||||
if (pushed)
|
||||
{
|
||||
pushed = 0;
|
||||
*tokp = lasttok;
|
||||
return;
|
||||
}
|
||||
commenting = 0;
|
||||
for (;;) {
|
||||
if (*where == 0) {
|
||||
for (;;) {
|
||||
if (!fgets(curline, MAXLINESIZE, fin)) {
|
||||
for (;;)
|
||||
{
|
||||
if (*where == 0)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (!fgets (curline, MAXLINESIZE, fin))
|
||||
{
|
||||
tokp->kind = TOK_EOF;
|
||||
*curline = 0;
|
||||
where = curline;
|
||||
return;
|
||||
}
|
||||
linenum++;
|
||||
if (commenting) {
|
||||
if (commenting)
|
||||
{
|
||||
break;
|
||||
} else if (cppline(curline)) {
|
||||
}
|
||||
else if (cppline (curline))
|
||||
{
|
||||
docppline (curline, &linenum,
|
||||
&infilename);
|
||||
} else if (directive(curline)) {
|
||||
}
|
||||
else if (directive (curline))
|
||||
{
|
||||
printdirective (curline);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
where = curline;
|
||||
} else if (isspace(*where)) {
|
||||
while (isspace(*where)) {
|
||||
}
|
||||
else if (isspace (*where))
|
||||
{
|
||||
while (isspace (*where))
|
||||
{
|
||||
where++; /* eat */
|
||||
}
|
||||
} else if (commenting) {
|
||||
for (where++; *where; where++) {
|
||||
if (endcomment(where)) {
|
||||
}
|
||||
else if (commenting)
|
||||
{
|
||||
for (where++; *where; where++)
|
||||
{
|
||||
if (endcomment (where))
|
||||
{
|
||||
where++;
|
||||
commenting--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (startcomment(where)) {
|
||||
}
|
||||
else if (startcomment (where))
|
||||
{
|
||||
where += 2;
|
||||
commenting++;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -197,7 +225,8 @@ get_token(token *tokp)
|
||||
/*
|
||||
* 'where' is not whitespace, comment or directive Must be a token!
|
||||
*/
|
||||
switch (*where) {
|
||||
switch (*where)
|
||||
{
|
||||
case ':':
|
||||
tokp->kind = TOK_COLON;
|
||||
where++;
|
||||
@ -276,15 +305,19 @@ get_token(token *tokp)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!(isalpha(*where) || *where == '_')) {
|
||||
if (!(isalpha (*where) || *where == '_'))
|
||||
{
|
||||
char buf[100];
|
||||
char *p;
|
||||
|
||||
s_print(buf, "illegal character in file: ");
|
||||
s_print (buf, _("illegal character in file: "));
|
||||
p = buf + strlen (buf);
|
||||
if (isprint(*where)) {
|
||||
if (isprint (*where))
|
||||
{
|
||||
s_print (p, "%c", *where);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s_print (p, "%d", *where);
|
||||
}
|
||||
error (buf);
|
||||
@ -309,11 +342,14 @@ findstrconst(const char **str, const char **val)
|
||||
int size;
|
||||
|
||||
p = *str;
|
||||
do {
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (*p && *p != '"');
|
||||
if (*p == 0) {
|
||||
error("unterminated string constant");
|
||||
}
|
||||
while (*p && *p != '"');
|
||||
if (*p == 0)
|
||||
{
|
||||
error (_("unterminated string constant"));
|
||||
}
|
||||
p++;
|
||||
size = p - *str;
|
||||
@ -332,16 +368,20 @@ findchrconst(const char **str, const char **val)
|
||||
int size;
|
||||
|
||||
p = *str;
|
||||
do {
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (*p && *p != '\'');
|
||||
if (*p == 0) {
|
||||
error("unterminated string constant");
|
||||
}
|
||||
while (*p && *p != '\'');
|
||||
if (*p == 0)
|
||||
{
|
||||
error (_("unterminated string constant"));
|
||||
}
|
||||
p++;
|
||||
size = p - *str;
|
||||
if (size != 3) {
|
||||
error("empty char string");
|
||||
if (size != 3)
|
||||
{
|
||||
error (_("empty char string"));
|
||||
}
|
||||
tmp = alloc (size + 1);
|
||||
strncpy (tmp, *str, size);
|
||||
@ -358,15 +398,22 @@ findconst(const char **str, const char **val)
|
||||
int size;
|
||||
|
||||
p = *str;
|
||||
if (*p == '0' && *(p + 1) == 'x') {
|
||||
if (*p == '0' && *(p + 1) == 'x')
|
||||
{
|
||||
p++;
|
||||
do {
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (isxdigit(*p));
|
||||
} else {
|
||||
do {
|
||||
}
|
||||
while (isxdigit (*p));
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (isdigit(*p));
|
||||
}
|
||||
while (isdigit (*p));
|
||||
}
|
||||
size = p - *str;
|
||||
tmp = alloc (size + 1);
|
||||
@ -376,7 +423,8 @@ findconst(const char **str, const char **val)
|
||||
*str = p;
|
||||
}
|
||||
|
||||
static token symbols[] = {
|
||||
static const token symbols[] =
|
||||
{
|
||||
{TOK_CONST, "const"},
|
||||
{TOK_UNION, "union"},
|
||||
{TOK_SWITCH, "switch"},
|
||||
@ -410,10 +458,13 @@ findkind(const char **mark, token *tokp)
|
||||
char *tmp;
|
||||
|
||||
str = *mark;
|
||||
for (s = symbols; s->kind != TOK_EOF; s++) {
|
||||
for (s = symbols; s->kind != TOK_EOF; s++)
|
||||
{
|
||||
len = strlen (s->str);
|
||||
if (strncmp(str, s->str, len) == 0) {
|
||||
if (!isalnum(str[len]) && str[len] != '_') {
|
||||
if (strncmp (str, s->str, len) == 0)
|
||||
{
|
||||
if (!isalnum (str[len]) && str[len] != '_')
|
||||
{
|
||||
tokp->kind = s->kind;
|
||||
tokp->str = s->str;
|
||||
*mark = str + len;
|
||||
@ -433,13 +484,13 @@ findkind(const char **mark, token *tokp)
|
||||
static int
|
||||
cppline (const char *line)
|
||||
{
|
||||
return (line == curline && *line == '#');
|
||||
return line == curline && *line == '#';
|
||||
}
|
||||
|
||||
static int
|
||||
directive (const char *line)
|
||||
{
|
||||
return (line == curline && *line == '%');
|
||||
return line == curline && *line == '%';
|
||||
}
|
||||
|
||||
static void
|
||||
@ -456,31 +507,40 @@ docppline(const char *line, int *lineno, const char **fname)
|
||||
char *p;
|
||||
|
||||
line++;
|
||||
while (isspace(*line)) {
|
||||
while (isspace (*line))
|
||||
{
|
||||
line++;
|
||||
}
|
||||
num = atoi (line);
|
||||
while (isdigit(*line)) {
|
||||
while (isdigit (*line))
|
||||
{
|
||||
line++;
|
||||
}
|
||||
while (isspace(*line)) {
|
||||
while (isspace (*line))
|
||||
{
|
||||
line++;
|
||||
}
|
||||
if (*line != '"') {
|
||||
error("preprocessor error");
|
||||
if (*line != '"')
|
||||
{
|
||||
error (_("preprocessor error"));
|
||||
}
|
||||
line++;
|
||||
p = file = alloc (strlen (line) + 1);
|
||||
while (*line && *line != '"') {
|
||||
while (*line && *line != '"')
|
||||
{
|
||||
*p++ = *line++;
|
||||
}
|
||||
if (*line == 0) {
|
||||
error("preprocessor error");
|
||||
if (*line == 0)
|
||||
{
|
||||
error (_("preprocessor error"));
|
||||
}
|
||||
*p = 0;
|
||||
if (*file == 0) {
|
||||
if (*file == 0)
|
||||
{
|
||||
*fname = NULL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*fname = file;
|
||||
}
|
||||
*lineno = num - 1;
|
||||
|
@ -43,11 +43,11 @@ char svcout_rcsid[] =
|
||||
#include "rpc_util.h"
|
||||
#include "proto.h"
|
||||
|
||||
static char RQSTP[] = "rqstp";
|
||||
static char TRANSP[] = "transp";
|
||||
static char ARG[] = "argument";
|
||||
static char RESULT[] = "result";
|
||||
static char ROUTINE[] = "local";
|
||||
static const char RQSTP[] = "rqstp";
|
||||
static const char TRANSP[] = "transp";
|
||||
static const char ARG[] = "argument";
|
||||
static const char RESULT[] = "result";
|
||||
static const char ROUTINE[] = "local";
|
||||
|
||||
char _errbuf[256]; /* For all messages */
|
||||
|
||||
@ -92,7 +92,8 @@ internal_proctype(proc_list *plist)
|
||||
void
|
||||
write_most (const char *infile /* our name */ , int netflag, int nomain)
|
||||
{
|
||||
if (inetdflag || pmflag) {
|
||||
if (inetdflag || pmflag)
|
||||
{
|
||||
const char *var_type;
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* WHY? */
|
||||
@ -104,7 +105,8 @@ write_most(const char *infile /* our name */, int netflag, int nomain)
|
||||
f_print (fout, "\t\t/* Started by a port monitor ? */\n");
|
||||
f_print (fout, "%s int _rpcfdtype;", var_type);
|
||||
f_print (fout, "\t\t/* Whether Stream or Datagram ? */\n");
|
||||
if (timerflag) {
|
||||
if (timerflag)
|
||||
{
|
||||
f_print (fout, "%s int _rpcsvcdirty;", var_type);
|
||||
f_print (fout, "\t/* Still serving ? */\n");
|
||||
}
|
||||
@ -119,7 +121,8 @@ write_most(const char *infile /* our name */, int netflag, int nomain)
|
||||
#ifdef __GNU_LIBRARY__
|
||||
if (Cflag)
|
||||
f_print (fout, "\nint\nmain(int argc, char **argv)\n");
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (fout, "\nint\nmain(argc, argv)\n");
|
||||
f_print (fout, "\tint argc;\n");
|
||||
f_print (fout, "\tchar **argv;\n");
|
||||
@ -128,11 +131,16 @@ write_most(const char *infile /* our name */, int netflag, int nomain)
|
||||
f_print (fout, "\nmain()\n");
|
||||
#endif
|
||||
f_print (fout, "{\n");
|
||||
if (inetdflag) {
|
||||
if (inetdflag)
|
||||
{
|
||||
write_inetmost (infile); /* Includes call to write_rpc_svc_fg() */
|
||||
} else {
|
||||
if( tirpcflag ) {
|
||||
if (netflag) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tirpcflag)
|
||||
{
|
||||
if (netflag)
|
||||
{
|
||||
f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP);
|
||||
f_print (fout, "\tstruct netconfig *nconf = NULL;\n");
|
||||
}
|
||||
@ -143,14 +151,17 @@ write_most(const char *infile /* our name */, int netflag, int nomain)
|
||||
f_print (fout, "\telse {\n");
|
||||
write_rpc_svc_fg (infile, "\t\t");
|
||||
f_print (fout, "\t}\n");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "\tregister SVCXPRT *%s;\n", TRANSP);
|
||||
f_print (fout, "\n");
|
||||
print_pmapunset ("\t");
|
||||
}
|
||||
}
|
||||
|
||||
if (logflag && !inetdflag) {
|
||||
if (logflag && !inetdflag)
|
||||
{
|
||||
open_log_file (infile, "\t");
|
||||
}
|
||||
}
|
||||
@ -184,12 +195,15 @@ write_netid_register(const char *transp)
|
||||
f_print (fout, "%s\t\texit(1);\n", sp);
|
||||
f_print (fout, "%s\t}\n", sp);
|
||||
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind != DEF_PROGRAM) {
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout,
|
||||
"%s\t(void) rpcb_unset(%s, %s, nconf);\n",
|
||||
sp, def->def_name, vp->vers_name);
|
||||
@ -218,12 +232,15 @@ write_nettype_register(const char *transp)
|
||||
definition *def;
|
||||
version_list *vp;
|
||||
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind != DEF_PROGRAM) {
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout, "\tif (!svc_create(");
|
||||
pvname (def->def_name, vp->vers_num);
|
||||
f_print (fout, ", %s, %s, \"%s\")) {\n ",
|
||||
@ -245,13 +262,15 @@ void
|
||||
write_rest (void)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
if (inetdflag) {
|
||||
if (inetdflag)
|
||||
{
|
||||
f_print (fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP);
|
||||
(void) sprintf (_errbuf, "could not create a handle");
|
||||
print_err_message ("\t\t");
|
||||
f_print (fout, "\t\texit(1);\n");
|
||||
f_print (fout, "\t}\n");
|
||||
if (timerflag) {
|
||||
if (timerflag)
|
||||
{
|
||||
f_print (fout, "\tif (_rpcpmstart) {\n");
|
||||
f_print (fout,
|
||||
"\t\t(void) signal(SIGALRM, %s closedown);\n",
|
||||
@ -275,17 +294,21 @@ write_programs(const char *storage)
|
||||
definition *def;
|
||||
|
||||
/* write out stubs for procedure definitions */
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind == DEF_PROGRAM) {
|
||||
if (def->def_kind == DEF_PROGRAM)
|
||||
{
|
||||
write_real_program (def);
|
||||
}
|
||||
}
|
||||
|
||||
/* write out dispatcher for each program */
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind == DEF_PROGRAM) {
|
||||
if (def->def_kind == DEF_PROGRAM)
|
||||
{
|
||||
write_program (def, storage);
|
||||
}
|
||||
}
|
||||
@ -304,14 +327,18 @@ write_real_program(definition *def)
|
||||
proc_list *proc;
|
||||
decl_list *l;
|
||||
|
||||
if( !newstyle ) return; /* not needed for old style */
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
if (!newstyle)
|
||||
return; /* not needed for old style */
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
internal_proctype (proc);
|
||||
f_print (fout, "\n_");
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
if( Cflag ) {
|
||||
if (Cflag)
|
||||
{
|
||||
f_print (fout, "(");
|
||||
/* arg name */
|
||||
if (proc->arg_num > 1)
|
||||
@ -321,12 +348,15 @@ write_real_program(definition *def)
|
||||
proc->args.decls->decl.type, 0);
|
||||
f_print (fout, " *argp, struct svc_req *%s)\n",
|
||||
RQSTP);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "(argp, %s)\n", RQSTP);
|
||||
/* arg name */
|
||||
if (proc->arg_num > 1)
|
||||
f_print (fout, "\t%s *argp;\n", proc->args.argname);
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (fout, "\t");
|
||||
ptype (proc->args.decls->decl.prefix,
|
||||
proc->args.decls->decl.type, 0);
|
||||
@ -342,10 +372,13 @@ write_real_program(definition *def)
|
||||
else
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
f_print (fout, "(");
|
||||
if (proc->arg_num < 2) { /* single argument */
|
||||
if (proc->arg_num < 2)
|
||||
{ /* single argument */
|
||||
if (!streq (proc->args.decls->decl.type, "void"))
|
||||
f_print (fout, "*argp, "); /* non-void */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = proc->args.decls; l != NULL; l = l->next)
|
||||
f_print (fout, "argp->%s, ", l->decl.name);
|
||||
}
|
||||
@ -361,18 +394,23 @@ write_program(definition *def, const char *storage)
|
||||
proc_list *proc;
|
||||
int filled;
|
||||
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
if (storage != NULL) {
|
||||
if (storage != NULL)
|
||||
{
|
||||
f_print (fout, "%s ", storage);
|
||||
}
|
||||
f_print (fout, "void\n");
|
||||
pvname (def->def_name, vp->vers_num);
|
||||
|
||||
if (Cflag) {
|
||||
if (Cflag)
|
||||
{
|
||||
f_print (fout, "(struct svc_req *%s, ", RQSTP);
|
||||
f_print (fout, "register SVCXPRT *%s)\n", TRANSP);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "(%s, %s)\n", RQSTP, TRANSP);
|
||||
f_print (fout, " struct svc_req *%s;\n", RQSTP);
|
||||
f_print (fout, " register SVCXPRT *%s;\n", TRANSP);
|
||||
@ -382,10 +420,13 @@ write_program(definition *def, const char *storage)
|
||||
|
||||
filled = 0;
|
||||
f_print (fout, "\tunion {\n");
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
if (proc->arg_num < 2) { /* single argument */
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
if (proc->arg_num < 2)
|
||||
{ /* single argument */
|
||||
if (streq (proc->args.decls->decl.type,
|
||||
"void")) {
|
||||
"void"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
filled = 1;
|
||||
@ -396,7 +437,8 @@ write_program(definition *def, const char *storage)
|
||||
f_print (fout, "_arg;\n");
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
filled = 1;
|
||||
f_print (fout, "\t\t%s", proc->args.argname);
|
||||
f_print (fout, " ");
|
||||
@ -404,18 +446,22 @@ write_program(definition *def, const char *storage)
|
||||
f_print (fout, "_arg;\n");
|
||||
}
|
||||
}
|
||||
if (!filled) {
|
||||
if (!filled)
|
||||
{
|
||||
f_print (fout, "\t\tint fill;\n");
|
||||
}
|
||||
f_print (fout, "\t} %s;\n", ARG);
|
||||
f_print (fout, "\tchar *%s;\n", RESULT);
|
||||
|
||||
if (Cflag) {
|
||||
if (Cflag)
|
||||
{
|
||||
f_print (fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
|
||||
f_print (fout,
|
||||
"\tchar *(*%s)(char *, struct svc_req *);\n",
|
||||
ROUTINE);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
|
||||
f_print (fout, "\tchar *(*%s)();\n", ROUTINE);
|
||||
}
|
||||
@ -425,7 +471,8 @@ write_program(definition *def, const char *storage)
|
||||
if (timerflag)
|
||||
f_print (fout, "\t_rpcsvcdirty = 1;\n");
|
||||
f_print (fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
|
||||
if (!nullproc(vp->procs)) {
|
||||
if (!nullproc (vp->procs))
|
||||
{
|
||||
f_print (fout, "\tcase NULLPROC:\n");
|
||||
f_print (fout,
|
||||
Cflag
|
||||
@ -435,11 +482,15 @@ write_program(definition *def, const char *storage)
|
||||
print_return ("\t\t");
|
||||
f_print (fout, "\n");
|
||||
}
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
f_print (fout, "\tcase %s:\n", proc->proc_name);
|
||||
if (proc->arg_num < 2) { /* single argument */
|
||||
if (proc->arg_num < 2)
|
||||
{ /* single argument */
|
||||
p_xdrfunc (ARG, proc->args.decls->decl.type);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
p_xdrfunc (ARG, proc->args.argname);
|
||||
}
|
||||
p_xdrfunc (RESULT, proc->res_type);
|
||||
@ -450,7 +501,8 @@ write_program(definition *def, const char *storage)
|
||||
else
|
||||
f_print (fout, "\t\t%s = (char *(*)()) ", ROUTINE);
|
||||
|
||||
if (newstyle) { /* new style: calls internal routine */
|
||||
if (newstyle)
|
||||
{ /* new style: calls internal routine */
|
||||
f_print (fout, "_");
|
||||
}
|
||||
if (Cflag && !newstyle)
|
||||
@ -516,8 +568,10 @@ printif(const char *proc, const char *transp, const char *prefix,
|
||||
int
|
||||
nullproc (proc_list * proc)
|
||||
{
|
||||
for (; proc != NULL; proc = proc->next) {
|
||||
if (streq(proc->proc_num, "0")) {
|
||||
for (; proc != NULL; proc = proc->next)
|
||||
{
|
||||
if (streq (proc->proc_num, "0"))
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -557,7 +611,8 @@ print_return(const char *space)
|
||||
{
|
||||
if (exitnow)
|
||||
f_print (fout, "%sexit(0);\n", space);
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (timerflag)
|
||||
f_print (fout, "%s_rpcsvcdirty = 0;\n", space);
|
||||
f_print (fout, "%sreturn;\n", space);
|
||||
@ -571,11 +626,14 @@ print_pmapunset(const char *space)
|
||||
definition *def;
|
||||
version_list *vp;
|
||||
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind == DEF_PROGRAM) {
|
||||
if (def->def_kind == DEF_PROGRAM)
|
||||
{
|
||||
for (vp = def->def.pr.versions; vp != NULL;
|
||||
vp = vp->next) {
|
||||
vp = vp->next)
|
||||
{
|
||||
f_print (fout, "%s(void) pmap_unset(%s, %s);\n",
|
||||
space, def->def_name, vp->vers_name);
|
||||
}
|
||||
@ -615,10 +673,13 @@ write_msg_out(void)
|
||||
{
|
||||
f_print (fout, "\n");
|
||||
f_print (fout, "static\n");
|
||||
if( !Cflag ) {
|
||||
if (!Cflag)
|
||||
{
|
||||
f_print (fout, "void _msgout(msg)\n");
|
||||
f_print (fout, "\tchar *msg;\n");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "void _msgout(char* msg)\n");
|
||||
}
|
||||
f_print (fout, "{\n");
|
||||
@ -661,21 +722,27 @@ write_timeout_func(void)
|
||||
f_print (fout, "\t\textern fd_set svc_fdset;\n");
|
||||
f_print (fout, "\t\tstatic int size;\n");
|
||||
f_print (fout, "\t\tint i, openfd;\n");
|
||||
if (tirpcflag && pmflag) {
|
||||
if (tirpcflag && pmflag)
|
||||
{
|
||||
f_print (fout, "\t\tstruct t_info tinfo;\n\n");
|
||||
f_print (fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n");
|
||||
}
|
||||
f_print (fout, "\t\t\texit(0);\n");
|
||||
f_print (fout, "\t\tif (size == 0) {\n");
|
||||
if( tirpcflag ) {
|
||||
if (tirpcflag)
|
||||
{
|
||||
f_print (fout, "\t\t\tstruct rlimit rl;\n\n");
|
||||
f_print (fout, "\t\t\trl.rlim_max = 0;\n");
|
||||
f_print (fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n");
|
||||
f_print (fout, "\t\t\tif ((size = rl.rlim_max) == 0)\n");
|
||||
f_print (fout, "\t\t\t\treturn;\n");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "\t\t\tsize = getdtablesize();\n");
|
||||
}
|
||||
f_print (fout, "\t\t}\n");
|
||||
@ -703,7 +770,8 @@ write_pm_most(const char *infile, int netflag)
|
||||
f_print (fout, "\t\t(!strcmp(mname, \"sockmod\") ||");
|
||||
f_print (fout, " !strcmp(mname, \"timod\"))) {\n");
|
||||
f_print (fout, "\t\tchar *netid;\n");
|
||||
if (!netflag) { /* Not included by -n option */
|
||||
if (!netflag)
|
||||
{ /* Not included by -n option */
|
||||
f_print (fout, "\t\tstruct netconfig *nconf = NULL;\n");
|
||||
f_print (fout, "\t\tSVCXPRT *%s;\n", TRANSP);
|
||||
}
|
||||
@ -743,12 +811,15 @@ write_pm_most(const char *infile, int netflag)
|
||||
f_print (fout, "\t\t}\n");
|
||||
f_print (fout, "\t\tif (nconf)\n");
|
||||
f_print (fout, "\t\t\tfreenetconfigent(nconf);\n");
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind != DEF_PROGRAM) {
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout,
|
||||
"\t\tif (!svc_reg(%s, %s, %s, ",
|
||||
TRANSP, def->def_name, vp->vers_name);
|
||||
@ -761,7 +832,8 @@ write_pm_most(const char *infile, int netflag)
|
||||
f_print (fout, "\t\t}\n");
|
||||
}
|
||||
}
|
||||
if (timerflag) {
|
||||
if (timerflag)
|
||||
{
|
||||
f_print (fout, "\t\tif (pmclose) {\n");
|
||||
f_print (fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n",
|
||||
Cflag ? "(SIG_PF)" : "(void(*)())");
|
||||
@ -794,12 +866,15 @@ write_rpc_svc_fg(const char *infile, const char *sp)
|
||||
f_print (fout, "%sif (pid)\n", sp);
|
||||
f_print (fout, "%s\texit(0);\n", sp);
|
||||
/* get number of file descriptors */
|
||||
if( tirpcflag ) {
|
||||
if (tirpcflag)
|
||||
{
|
||||
f_print (fout, "%srl.rlim_max = 0;\n", sp);
|
||||
f_print (fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
|
||||
f_print (fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
|
||||
f_print (fout, "%s\texit(1);\n", sp);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "%ssize = getdtablesize();\n", sp);
|
||||
}
|
||||
|
||||
@ -812,7 +887,8 @@ write_rpc_svc_fg(const char *infile, const char *sp)
|
||||
/* This removes control of the controlling terminal */
|
||||
if (tirpcflag)
|
||||
f_print (fout, "%ssetsid();\n", sp);
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (fout, "%si = open(\"/dev/tty\", 2);\n", sp);
|
||||
f_print (fout, "%sif (i >= 0) {\n", sp);
|
||||
f_print (fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);;
|
||||
@ -864,7 +940,8 @@ write_inetd_register(const char *transp)
|
||||
else
|
||||
isudp = 0;
|
||||
f_print (fout, "\n");
|
||||
if (inetdflag) {
|
||||
if (inetdflag)
|
||||
{
|
||||
f_print (fout, "\tif ((_rpcfdtype == 0) || (_rpcfdtype == %s)) {\n",
|
||||
isudp ? "SOCK_DGRAM" : "SOCK_STREAM");
|
||||
}
|
||||
@ -880,17 +957,21 @@ write_inetd_register(const char *transp)
|
||||
f_print (fout, "%s\t\texit(1);\n", sp);
|
||||
f_print (fout, "%s\t}\n", sp);
|
||||
|
||||
if (inetdflag) {
|
||||
if (inetdflag)
|
||||
{
|
||||
f_print (fout, "%s\tif (!_rpcpmstart)\n\t", sp);
|
||||
f_print (fout, "%s\tproto = IPPROTO_%s;\n",
|
||||
sp, isudp ? "UDP" : "TCP");
|
||||
}
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind != DEF_PROGRAM) {
|
||||
if (def->def_kind != DEF_PROGRAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
f_print (fout, "%s\tif (!svc_register(%s, %s, %s, ",
|
||||
sp, TRANSP, def->def_name, vp->vers_name);
|
||||
pvname (def->def_name, vp->vers_num);
|
||||
|
@ -47,17 +47,17 @@ char tblout_rcsid[] =
|
||||
#define TABCOUNT 5
|
||||
#define TABSTOP (TABSIZE*TABCOUNT)
|
||||
|
||||
static char tabstr[TABCOUNT+1] = "\t\t\t\t\t";
|
||||
static const char tabstr[TABCOUNT + 1] = "\t\t\t\t\t";
|
||||
|
||||
static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n";
|
||||
static char tbl_end[] = "};\n";
|
||||
static const char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n";
|
||||
static const char tbl_end[] = "};\n";
|
||||
|
||||
static char null_entry[] = "\n\t(char *(*)())0,\n\
|
||||
static const char null_entry[] = "\n\t(char *(*)())0,\n\
|
||||
\t(xdrproc_t) xdr_void,\t\t\t0,\n\
|
||||
\t(xdrproc_t) xdr_void,\t\t\t0,\n";
|
||||
|
||||
|
||||
static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
|
||||
static const char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
|
||||
|
||||
static void write_table (const definition * def);
|
||||
static void printit (const char *prefix, const char *type);
|
||||
@ -69,9 +69,11 @@ write_tables(void)
|
||||
definition *def;
|
||||
|
||||
f_print (fout, "\n");
|
||||
for (l = defined; l != NULL; l = l->next) {
|
||||
for (l = defined; l != NULL; l = l->next)
|
||||
{
|
||||
def = (definition *) l->val;
|
||||
if (def->def_kind == DEF_PROGRAM) {
|
||||
if (def->def_kind == DEF_PROGRAM)
|
||||
{
|
||||
write_table (def);
|
||||
}
|
||||
}
|
||||
@ -87,26 +89,32 @@ write_table(const definition *def)
|
||||
char progvers[100];
|
||||
int warning;
|
||||
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
|
||||
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
|
||||
{
|
||||
warning = 0;
|
||||
s_print (progvers, "%s_%s",
|
||||
locase (def->def_name), vp->vers_num);
|
||||
/* print the table header */
|
||||
f_print (fout, tbl_hdr, progvers);
|
||||
|
||||
if (nullproc(vp->procs)) {
|
||||
if (nullproc (vp->procs))
|
||||
{
|
||||
expected = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
expected = 1;
|
||||
f_print (fout, null_entry);
|
||||
}
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next) {
|
||||
for (proc = vp->procs; proc != NULL; proc = proc->next)
|
||||
{
|
||||
current = atoi (proc->proc_num);
|
||||
if (current != expected++) {
|
||||
if (current != expected++)
|
||||
{
|
||||
f_print (fout,
|
||||
"\n/*\n * WARNING: table out of order\n */\n");
|
||||
if (warning == 0) {
|
||||
if (warning == 0)
|
||||
{
|
||||
f_print (stderr,
|
||||
"WARNING %s table is out of order\n",
|
||||
progvers);
|
||||
@ -120,7 +128,8 @@ write_table(const definition *def)
|
||||
/* routine to invoke */
|
||||
if (Cflag && !newstyle)
|
||||
pvname_svc (proc->proc_name, vp->vers_num);
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (newstyle)
|
||||
f_print (fout, "_"); /* calls internal func */
|
||||
pvname (proc->proc_name, vp->vers_num);
|
||||
@ -158,9 +167,12 @@ printit(const char *prefix, const char *type)
|
||||
tabs = (TABSTOP - len + TABSIZE - 1) / TABSIZE;
|
||||
f_print (fout, "%s", &tabstr[TABCOUNT - tabs]);
|
||||
|
||||
if (streq(type, "void")) {
|
||||
if (streq (type, "void"))
|
||||
{
|
||||
f_print (fout, "0");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "sizeof ( ");
|
||||
/* XXX: should "follow" be 1 ??? */
|
||||
ptype (prefix, type, 0);
|
||||
|
@ -88,7 +88,7 @@ reinitialize(void)
|
||||
int
|
||||
streq (const char *a, const char *b)
|
||||
{
|
||||
return (strcmp(a, b) == 0);
|
||||
return strcmp (a, b) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -99,9 +99,11 @@ findval(list *lst, const char *val,
|
||||
int (*cmp) (const definition *, const char *))
|
||||
{
|
||||
|
||||
for (; lst != NULL; lst = lst->next) {
|
||||
if (cmp(lst->val, val)) {
|
||||
return (lst->val);
|
||||
for (; lst != NULL; lst = lst->next)
|
||||
{
|
||||
if (cmp (lst->val, val))
|
||||
{
|
||||
return lst->val;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@ -127,7 +129,7 @@ storeval(list **lstp, definition *val)
|
||||
static int
|
||||
findit (const definition * def, const char *type)
|
||||
{
|
||||
return (streq(def->def_name, type));
|
||||
return streq (def->def_name, type);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -136,32 +138,36 @@ fixit(const char *type, const char *orig)
|
||||
definition *def;
|
||||
|
||||
def = findval (defined, type, findit);
|
||||
if (def == NULL || def->def_kind != DEF_TYPEDEF) {
|
||||
return (orig);
|
||||
if (def == NULL || def->def_kind != DEF_TYPEDEF)
|
||||
{
|
||||
return orig;
|
||||
}
|
||||
switch (def->def.ty.rel) {
|
||||
switch (def->def.ty.rel)
|
||||
{
|
||||
case REL_VECTOR:
|
||||
return (def->def.ty.old_type);
|
||||
case REL_ALIAS:
|
||||
return (fixit (def->def.ty.old_type, orig));
|
||||
default:
|
||||
return (orig);
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
fixtype (const char *type)
|
||||
{
|
||||
return (fixit(type, type));
|
||||
return fixit (type, type);
|
||||
}
|
||||
|
||||
const char *
|
||||
stringfix (const char *type)
|
||||
{
|
||||
if (streq(type, "string")) {
|
||||
if (streq (type, "string"))
|
||||
{
|
||||
return "wrapstring";
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -169,18 +175,27 @@ stringfix(const char *type)
|
||||
void
|
||||
ptype (const char *prefix, const char *type, int follow)
|
||||
{
|
||||
if (prefix != NULL) {
|
||||
if (streq(prefix, "enum")) {
|
||||
if (prefix != NULL)
|
||||
{
|
||||
if (streq (prefix, "enum"))
|
||||
{
|
||||
f_print (fout, "enum ");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "struct ");
|
||||
}
|
||||
}
|
||||
if (streq(type, "bool")) {
|
||||
if (streq (type, "bool"))
|
||||
{
|
||||
f_print (fout, "bool_t ");
|
||||
} else if (streq(type, "string")) {
|
||||
}
|
||||
else if (streq (type, "string"))
|
||||
{
|
||||
f_print (fout, "char *");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
f_print (fout, "%s ", follow ? fixtype (type) : type);
|
||||
}
|
||||
}
|
||||
@ -188,10 +203,13 @@ ptype(const char *prefix, const char *type, int follow)
|
||||
static int
|
||||
typedefed (const definition * def, const char *type)
|
||||
{
|
||||
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
|
||||
return (0);
|
||||
} else {
|
||||
return (streq(def->def_name, type));
|
||||
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return streq (def->def_name, type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,18 +218,21 @@ isvectordef(const char *type, relation rel)
|
||||
{
|
||||
definition *def;
|
||||
|
||||
for (;;) {
|
||||
switch (rel) {
|
||||
for (;;)
|
||||
{
|
||||
switch (rel)
|
||||
{
|
||||
case REL_VECTOR:
|
||||
return (!streq(type, "string"));
|
||||
return !streq (type, "string");
|
||||
case REL_ARRAY:
|
||||
return (0);
|
||||
return 0;
|
||||
case REL_POINTER:
|
||||
return (0);
|
||||
case REL_ALIAS:
|
||||
def = findval (defined, type, typedefed);
|
||||
if (def == NULL) {
|
||||
return (0);
|
||||
if (def == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
type = def->def.ty.old_type;
|
||||
rel = def->def.ty.rel;
|
||||
@ -226,11 +247,12 @@ locase(const char *str)
|
||||
static char buf[100];
|
||||
char *p = buf;
|
||||
|
||||
while ((c = *str++)!=0) {
|
||||
while ((c = *str++) != 0)
|
||||
{
|
||||
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
|
||||
}
|
||||
*p = 0;
|
||||
return (buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
@ -266,7 +288,8 @@ crash(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
for (i = 0; i < nfiles; i++)
|
||||
{
|
||||
(void) unlink (outfiles[i]);
|
||||
}
|
||||
exit (1);
|
||||
@ -275,10 +298,12 @@ crash(void)
|
||||
void
|
||||
record_open (const char *file)
|
||||
{
|
||||
if (nfiles < NFILES) {
|
||||
if (nfiles < NFILES)
|
||||
{
|
||||
outfiles[nfiles++] = file;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
f_print (stderr, "too many files!\n");
|
||||
crash ();
|
||||
}
|
||||
@ -325,13 +350,15 @@ expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
|
||||
void
|
||||
tabify (FILE * f, int tab)
|
||||
{
|
||||
while (tab--) {
|
||||
while (tab--)
|
||||
{
|
||||
(void) fputc ('\t', f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static token tokstrings[] = {
|
||||
static const token tokstrings[] =
|
||||
{
|
||||
{TOK_IDENT, "identifier"},
|
||||
{TOK_CONST, "const"},
|
||||
{TOK_RPAREN, ")"},
|
||||
@ -386,14 +413,19 @@ printbuf(void)
|
||||
|
||||
#define TABSIZE 4
|
||||
|
||||
for (i = 0; (c = curline[i])!=0; i++) {
|
||||
if (c == '\t') {
|
||||
for (i = 0; (c = curline[i]) != 0; i++)
|
||||
{
|
||||
if (c == '\t')
|
||||
{
|
||||
cnt = 8 - (i % TABSIZE);
|
||||
c = ' ';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = 1;
|
||||
}
|
||||
while (cnt--) {
|
||||
while (cnt--)
|
||||
{
|
||||
(void) fputc (c, stderr);
|
||||
}
|
||||
}
|
||||
@ -407,14 +439,19 @@ printwhere(void)
|
||||
int cnt;
|
||||
|
||||
printbuf ();
|
||||
for (i = 0; i < where - curline; i++) {
|
||||
for (i = 0; i < where - curline; i++)
|
||||
{
|
||||
c = curline[i];
|
||||
if (c == '\t') {
|
||||
if (c == '\t')
|
||||
{
|
||||
cnt = 8 - (i % TABSIZE);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = 1;
|
||||
}
|
||||
while (cnt--) {
|
||||
while (cnt--)
|
||||
{
|
||||
(void) fputc ('^', stderr);
|
||||
}
|
||||
}
|
||||
@ -427,7 +464,8 @@ make_argname(const char *pname, const char *vname)
|
||||
char *name;
|
||||
|
||||
name = malloc (strlen (pname) + strlen (vname) + strlen (ARGEXT) + 3);
|
||||
if (!name) {
|
||||
if (!name)
|
||||
{
|
||||
fprintf (stderr, "failed in malloc");
|
||||
exit (1);
|
||||
}
|
||||
@ -444,7 +482,8 @@ add_type(int len, const char *type)
|
||||
bas_type *ptr;
|
||||
|
||||
|
||||
if ((ptr = malloc(sizeof(bas_type))) == NULL) {
|
||||
if ((ptr = malloc (sizeof (bas_type))) == NULL)
|
||||
{
|
||||
fprintf (stderr, "failed in malloc");
|
||||
exit (1);
|
||||
}
|
||||
@ -468,7 +507,8 @@ add_type(int len, const char *type)
|
||||
}
|
||||
|
||||
|
||||
bas_type *find_type(const char *type)
|
||||
bas_type *
|
||||
find_type (const char *type)
|
||||
{
|
||||
bas_type *ptr;
|
||||
|
||||
@ -478,10 +518,9 @@ bas_type *find_type(const char *type)
|
||||
while (ptr != NULL)
|
||||
{
|
||||
if (strcmp (ptr->name, type) == 0)
|
||||
return(ptr);
|
||||
return ptr;
|
||||
else
|
||||
ptr = ptr->next;
|
||||
};
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
262
sunrpc/rpcinfo.c
262
sunrpc/rpcinfo.c
@ -1,5 +1,6 @@
|
||||
|
||||
/* @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC */
|
||||
#ifndef lint
|
||||
#if !defined(lint) && defined (SCCSID)
|
||||
static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI";
|
||||
#endif
|
||||
|
||||
@ -41,33 +42,38 @@ static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI";
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <rpc/pmap_prot.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
|
||||
#define MAXHOSTLEN 256
|
||||
|
||||
#define MIN_VERS ((u_long) 0)
|
||||
#define MAX_VERS ((u_long) 4294967295L)
|
||||
#define MAX_VERS ((u_long) 4294967295UL)
|
||||
|
||||
static void udpping(/*u_short portflag, int argc, char **argv*/);
|
||||
static void tcpping(/*u_short portflag, int argc, char **argv*/);
|
||||
static int pstatus(/*CLIENT *client, u_long prognum, u_long vers*/);
|
||||
static void pmapdump(/*int argc, char **argv*/);
|
||||
static bool_t reply_proc(/*void *res, struct sockaddr_in *who*/);
|
||||
static void brdcst(/*int argc, char **argv*/);
|
||||
static void deletereg(/* int argc, char **argv */) ;
|
||||
static void usage(/*void*/);
|
||||
static u_long getprognum(/*char *arg*/);
|
||||
static u_long getvers(/*char *arg*/);
|
||||
static void get_inet_address(/*struct sockaddr_in *addr, char *host*/);
|
||||
extern u_long inet_addr(); /* in 4.2BSD, arpa/inet.h called that a in_addr */
|
||||
extern char *inet_ntoa();
|
||||
static void udpping (u_short portflag, int argc, char **argv);
|
||||
static void tcpping (u_short portflag, int argc, char **argv);
|
||||
static int pstatus (CLIENT *client, u_long prognum, u_long vers);
|
||||
static void pmapdump (int argc, char **argv);
|
||||
static bool_t reply_proc (void *res, struct sockaddr_in *who);
|
||||
static void brdcst (int argc, char **argv);
|
||||
static void deletereg (int argc, char **argv);
|
||||
static void usage (void);
|
||||
static u_long getprognum (char *arg);
|
||||
static u_long getvers (char *arg);
|
||||
static void get_inet_address (struct sockaddr_in *addr, char *host);
|
||||
|
||||
/*
|
||||
* Functions to be performed.
|
||||
@ -80,22 +86,23 @@ extern char *inet_ntoa();
|
||||
#define DELETES 5 /* delete registration for the service */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
register int c;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
int errflg;
|
||||
int function;
|
||||
u_short portnum;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
textdomain (_libc_intl_domainname);
|
||||
|
||||
function = NONE;
|
||||
portnum = 0;
|
||||
errflg = 0;
|
||||
while ((c = getopt(argc, argv, "ptubdn:")) != -1) {
|
||||
switch (c) {
|
||||
while ((c = getopt (argc, argv, "ptubdn:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
case 'p':
|
||||
if (function != NONE)
|
||||
@ -141,15 +148,18 @@ main(argc, argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (errflg || function == NONE) {
|
||||
if (errflg || function == NONE)
|
||||
{
|
||||
usage ();
|
||||
return (1);
|
||||
}
|
||||
|
||||
switch (function) {
|
||||
switch (function)
|
||||
{
|
||||
|
||||
case PMAPDUMP:
|
||||
if (portnum != 0) {
|
||||
if (portnum != 0)
|
||||
{
|
||||
usage ();
|
||||
return (1);
|
||||
}
|
||||
@ -165,7 +175,8 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
case BRDCST:
|
||||
if (portnum != 0) {
|
||||
if (portnum != 0)
|
||||
{
|
||||
usage ();
|
||||
return (1);
|
||||
}
|
||||
@ -195,7 +206,8 @@ udpping(portnum, argc, argv)
|
||||
struct rpc_err rpcerr;
|
||||
int failure;
|
||||
|
||||
if (argc < 2 || argc > 3) {
|
||||
if (argc < 2 || argc > 3)
|
||||
{
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
@ -203,12 +215,14 @@ udpping(portnum, argc, argv)
|
||||
get_inet_address (&addr, argv[0]);
|
||||
/* Open the socket here so it will survive calls to clnt_destroy */
|
||||
sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sock < 0) {
|
||||
if (sock < 0)
|
||||
{
|
||||
perror ("rpcinfo: socket");
|
||||
exit (1);
|
||||
}
|
||||
failure = 0;
|
||||
if (argc == 2) {
|
||||
if (argc == 2)
|
||||
{
|
||||
/*
|
||||
* A call to version 0 should fail with a program/version
|
||||
* mismatch, and give us the range of versions supported.
|
||||
@ -217,7 +231,8 @@ udpping(portnum, argc, argv)
|
||||
to.tv_sec = 5;
|
||||
to.tv_usec = 0;
|
||||
if ((client = clntudp_create (&addr, prognum, (u_long) 0,
|
||||
to, &sock)) == NULL) {
|
||||
to, &sock)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu is not available\n"),
|
||||
prognum);
|
||||
@ -225,13 +240,17 @@ udpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL,
|
||||
xdr_void, (char *)NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
||||
rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
|
||||
(char *) NULL, (xdrproc_t) xdr_void,
|
||||
(char *) NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH)
|
||||
{
|
||||
clnt_geterr (client, &rpcerr);
|
||||
minvers = rpcerr.re_vers.low;
|
||||
maxvers = rpcerr.re_vers.high;
|
||||
} else if (rpc_stat == RPC_SUCCESS) {
|
||||
}
|
||||
else if (rpc_stat == RPC_SUCCESS)
|
||||
{
|
||||
/*
|
||||
* Oh dear, it DOES support version 0.
|
||||
* Let's try version MAX_VERS.
|
||||
@ -240,7 +259,8 @@ udpping(portnum, argc, argv)
|
||||
to.tv_sec = 5;
|
||||
to.tv_usec = 0;
|
||||
if ((client = clntudp_create (&addr, prognum, MAX_VERS,
|
||||
to, &sock)) == NULL) {
|
||||
to, &sock)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, MAX_VERS);
|
||||
@ -248,13 +268,16 @@ udpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
||||
rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
|
||||
NULL, (xdrproc_t) xdr_void, NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH)
|
||||
{
|
||||
clnt_geterr (client, &rpcerr);
|
||||
minvers = rpcerr.re_vers.low;
|
||||
maxvers = rpcerr.re_vers.high;
|
||||
} else if (rpc_stat == RPC_SUCCESS) {
|
||||
}
|
||||
else if (rpc_stat == RPC_SUCCESS)
|
||||
{
|
||||
/*
|
||||
* It also supports version MAX_VERS.
|
||||
* Looks like we have a wise guy.
|
||||
@ -263,21 +286,27 @@ udpping(portnum, argc, argv)
|
||||
*/
|
||||
minvers = 0;
|
||||
maxvers = MAX_VERS;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) pstatus (client, prognum, MAX_VERS);
|
||||
exit (1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) pstatus (client, prognum, (u_long) 0);
|
||||
exit (1);
|
||||
}
|
||||
clnt_destroy (client);
|
||||
for (vers = minvers; vers <= maxvers; vers++) {
|
||||
for (vers = minvers; vers <= maxvers; vers++)
|
||||
{
|
||||
addr.sin_port = htons (portnum);
|
||||
to.tv_sec = 5;
|
||||
to.tv_usec = 0;
|
||||
if ((client = clntudp_create (&addr, prognum, vers,
|
||||
to, &sock)) == NULL) {
|
||||
to, &sock)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, vers);
|
||||
@ -285,20 +314,22 @@ udpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
||||
rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
|
||||
NULL, (xdrproc_t) xdr_void, NULL, to);
|
||||
if (pstatus (client, prognum, vers) < 0)
|
||||
failure = 1;
|
||||
clnt_destroy (client);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
vers = getvers (argv[2]);
|
||||
addr.sin_port = htons (portnum);
|
||||
to.tv_sec = 5;
|
||||
to.tv_usec = 0;
|
||||
if ((client = clntudp_create (&addr, prognum, vers,
|
||||
to, &sock)) == NULL) {
|
||||
to, &sock)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf ("program %lu version %lu is not available\n",
|
||||
prognum, vers);
|
||||
@ -306,8 +337,8 @@ udpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
||||
xdr_void, (char *)NULL, to);
|
||||
rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_void, NULL, to);
|
||||
if (pstatus (client, prognum, vers) < 0)
|
||||
failure = 1;
|
||||
}
|
||||
@ -331,21 +362,24 @@ tcpping(portnum, argc, argv)
|
||||
struct rpc_err rpcerr;
|
||||
int failure;
|
||||
|
||||
if (argc < 2 || argc > 3) {
|
||||
if (argc < 2 || argc > 3)
|
||||
{
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
prognum = getprognum (argv[1]);
|
||||
get_inet_address (&addr, argv[0]);
|
||||
failure = 0;
|
||||
if (argc == 2) {
|
||||
if (argc == 2)
|
||||
{
|
||||
/*
|
||||
* A call to version 0 should fail with a program/version
|
||||
* mismatch, and give us the range of versions supported.
|
||||
*/
|
||||
addr.sin_port = htons (portnum);
|
||||
if ((client = clnttcp_create (&addr, prognum, MIN_VERS,
|
||||
&sock, 0, 0)) == NULL) {
|
||||
&sock, 0, 0)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu is not available\n"),
|
||||
prognum);
|
||||
@ -353,20 +387,24 @@ tcpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL,
|
||||
xdr_void, (char *)NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
||||
rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_void, NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH)
|
||||
{
|
||||
clnt_geterr (client, &rpcerr);
|
||||
minvers = rpcerr.re_vers.low;
|
||||
maxvers = rpcerr.re_vers.high;
|
||||
} else if (rpc_stat == RPC_SUCCESS) {
|
||||
}
|
||||
else if (rpc_stat == RPC_SUCCESS)
|
||||
{
|
||||
/*
|
||||
* Oh dear, it DOES support version 0.
|
||||
* Let's try version MAX_VERS.
|
||||
*/
|
||||
addr.sin_port = htons (portnum);
|
||||
if ((client = clnttcp_create (&addr, prognum, MAX_VERS,
|
||||
&sock, 0, 0)) == NULL) {
|
||||
&sock, 0, 0)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, MAX_VERS);
|
||||
@ -374,13 +412,16 @@ tcpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_sec = 10;
|
||||
to.tv_usec = 0;
|
||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
||||
rpc_stat = clnt_call (client, NULLPROC, (xdrproc_t) xdr_void,
|
||||
NULL, (xdrproc_t) xdr_void, NULL, to);
|
||||
if (rpc_stat == RPC_PROGVERSMISMATCH)
|
||||
{
|
||||
clnt_geterr (client, &rpcerr);
|
||||
minvers = rpcerr.re_vers.low;
|
||||
maxvers = rpcerr.re_vers.high;
|
||||
} else if (rpc_stat == RPC_SUCCESS) {
|
||||
}
|
||||
else if (rpc_stat == RPC_SUCCESS)
|
||||
{
|
||||
/*
|
||||
* It also supports version MAX_VERS.
|
||||
* Looks like we have a wise guy.
|
||||
@ -389,21 +430,27 @@ tcpping(portnum, argc, argv)
|
||||
*/
|
||||
minvers = 0;
|
||||
maxvers = MAX_VERS;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) pstatus (client, prognum, MAX_VERS);
|
||||
exit (1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) pstatus (client, prognum, MIN_VERS);
|
||||
exit (1);
|
||||
}
|
||||
clnt_destroy (client);
|
||||
(void) close (sock);
|
||||
sock = RPC_ANYSOCK; /* Re-initialize it for later */
|
||||
for (vers = minvers; vers <= maxvers; vers++) {
|
||||
for (vers = minvers; vers <= maxvers; vers++)
|
||||
{
|
||||
addr.sin_port = htons (portnum);
|
||||
if ((client = clnttcp_create (&addr, prognum, vers,
|
||||
&sock, 0, 0)) == NULL) {
|
||||
&sock, 0, 0)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, vers);
|
||||
@ -411,8 +458,8 @@ tcpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_usec = 0;
|
||||
to.tv_sec = 10;
|
||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
||||
xdr_void, (char *)NULL, to);
|
||||
rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_void, NULL, to);
|
||||
if (pstatus (client, prognum, vers) < 0)
|
||||
failure = 1;
|
||||
clnt_destroy (client);
|
||||
@ -420,11 +467,13 @@ tcpping(portnum, argc, argv)
|
||||
sock = RPC_ANYSOCK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
vers = getvers (argv[2]);
|
||||
addr.sin_port = htons (portnum);
|
||||
if ((client = clnttcp_create (&addr, prognum, vers, &sock,
|
||||
0, 0)) == NULL) {
|
||||
0, 0)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror ("rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, vers);
|
||||
@ -432,8 +481,8 @@ tcpping(portnum, argc, argv)
|
||||
}
|
||||
to.tv_usec = 0;
|
||||
to.tv_sec = 10;
|
||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
||||
xdr_void, (char *)NULL, to);
|
||||
rpc_stat = clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_void, NULL, to);
|
||||
if (pstatus (client, prognum, vers) < 0)
|
||||
failure = 1;
|
||||
}
|
||||
@ -457,12 +506,15 @@ pstatus(client, prognum, vers)
|
||||
struct rpc_err rpcerr;
|
||||
|
||||
clnt_geterr (client, &rpcerr);
|
||||
if (rpcerr.re_status != RPC_SUCCESS) {
|
||||
if (rpcerr.re_status != RPC_SUCCESS)
|
||||
{
|
||||
clnt_perror (client, "rpcinfo");
|
||||
printf (_ ("program %lu version %lu is not available\n"),
|
||||
prognum, vers);
|
||||
return (-1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (_ ("program %lu version %lu ready and waiting\n"),
|
||||
prognum, vers);
|
||||
return (0);
|
||||
@ -482,13 +534,15 @@ pmapdump(argc, argv)
|
||||
register CLIENT *client;
|
||||
struct rpcent *rpc;
|
||||
|
||||
if (argc > 1) {
|
||||
if (argc > 1)
|
||||
{
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
if (argc == 1)
|
||||
get_inet_address (&server_addr, argv[0]);
|
||||
else {
|
||||
else
|
||||
{
|
||||
bzero ((char *) &server_addr, sizeof server_addr);
|
||||
server_addr.sin_family = AF_INET;
|
||||
if ((hp = gethostbyname ("localhost")) != NULL)
|
||||
@ -501,21 +555,28 @@ pmapdump(argc, argv)
|
||||
minutetimeout.tv_usec = 0;
|
||||
server_addr.sin_port = htons (PMAPPORT);
|
||||
if ((client = clnttcp_create (&server_addr, PMAPPROG,
|
||||
PMAPVERS, &socket, 50, 500)) == NULL) {
|
||||
PMAPVERS, &socket, 50, 500)) == NULL)
|
||||
{
|
||||
clnt_pcreateerror (_ ("rpcinfo: can't contact portmapper"));
|
||||
exit (1);
|
||||
}
|
||||
if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL,
|
||||
xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) {
|
||||
if (clnt_call (client, PMAPPROC_DUMP, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_pmaplist, (caddr_t) &head,
|
||||
minutetimeout) != RPC_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, _ ("rpcinfo: can't contact portmapper: "));
|
||||
clnt_perror (client, "rpcinfo");
|
||||
exit (1);
|
||||
}
|
||||
if (head == NULL) {
|
||||
if (head == NULL)
|
||||
{
|
||||
printf (_ ("No remote programs registered.\n"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (_ (" program vers proto port\n"));
|
||||
for (; head != NULL; head = head->pml_next) {
|
||||
for (; head != NULL; head = head->pml_next)
|
||||
{
|
||||
printf ("%10ld%5ld",
|
||||
head->pml_map.pm_prog,
|
||||
head->pml_map.pm_vers);
|
||||
@ -564,15 +625,18 @@ brdcst(argc, argv)
|
||||
enum clnt_stat rpc_stat;
|
||||
u_long prognum, vers;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2)
|
||||
{
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
prognum = getprognum (argv[0]);
|
||||
vers = getvers (argv[1]);
|
||||
rpc_stat = clnt_broadcast(prognum, vers, NULLPROC, xdr_void,
|
||||
(char *)NULL, xdr_void, (char *)NULL, reply_proc);
|
||||
if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT)) {
|
||||
rpc_stat = clnt_broadcast (prognum, vers, NULLPROC, (xdrproc_t) xdr_void,
|
||||
NULL, (xdrproc_t) xdr_void, NULL,
|
||||
(resultproc_t) reply_proc);
|
||||
if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT))
|
||||
{
|
||||
fprintf (stderr, _ ("rpcinfo: broadcast failed: %s\n"),
|
||||
clnt_sperrno (rpc_stat));
|
||||
exit (1);
|
||||
@ -584,19 +648,23 @@ static void
|
||||
deletereg (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{ u_long prog_num, version_num ;
|
||||
{
|
||||
u_long prog_num, version_num;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2)
|
||||
{
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
if (getuid()) { /* This command allowed only to root */
|
||||
if (getuid ())
|
||||
{ /* This command allowed only to root */
|
||||
fprintf (stderr, "Sorry. You are not root\n");
|
||||
exit (1);
|
||||
}
|
||||
prog_num = getprognum (argv[0]);
|
||||
version_num = getvers (argv[1]);
|
||||
if ((pmap_unset(prog_num, version_num)) == 0) {
|
||||
if ((pmap_unset (prog_num, version_num)) == 0)
|
||||
{
|
||||
fprintf (stderr, _ ("rpcinfo: Could not delete registration for prog %s version %s\n"),
|
||||
argv[0], argv[1]);
|
||||
exit (1);
|
||||
@ -620,15 +688,19 @@ getprognum(arg)
|
||||
register struct rpcent *rpc;
|
||||
register u_long prognum;
|
||||
|
||||
if (isalpha(*arg)) {
|
||||
if (isalpha (*arg))
|
||||
{
|
||||
rpc = getrpcbyname (arg);
|
||||
if (rpc == NULL) {
|
||||
if (rpc == NULL)
|
||||
{
|
||||
fprintf (stderr, _ ("rpcinfo: %s is unknown service\n"),
|
||||
arg);
|
||||
exit (1);
|
||||
}
|
||||
prognum = rpc->r_number;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prognum = (u_long) atoi (arg);
|
||||
}
|
||||
|
||||
@ -654,8 +726,10 @@ get_inet_address(addr, host)
|
||||
|
||||
bzero ((char *) addr, sizeof *addr);
|
||||
addr->sin_addr.s_addr = (u_long) inet_addr (host);
|
||||
if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) {
|
||||
if ((hp = gethostbyname(host)) == NULL) {
|
||||
if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0)
|
||||
{
|
||||
if ((hp = gethostbyname (host)) == NULL)
|
||||
{
|
||||
fprintf (stderr, _ ("rpcinfo: %s is unknown host\n"),
|
||||
host);
|
||||
exit (1);
|
||||
|
111
sunrpc/svc.c
111
sunrpc/svc.c
@ -41,8 +41,9 @@ static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro";
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <sys/errno.h>
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/svc.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
|
||||
#ifndef errno
|
||||
@ -66,14 +67,16 @@ static SVCXPRT *xports[NOFILE];
|
||||
* The dispatch routine takes request structs and runs the
|
||||
* appropriate procedure.
|
||||
*/
|
||||
static struct svc_callout {
|
||||
static struct svc_callout
|
||||
{
|
||||
struct svc_callout *sc_next;
|
||||
u_long sc_prog;
|
||||
u_long sc_vers;
|
||||
void (*sc_dispatch)();
|
||||
} *svc_head;
|
||||
void (*sc_dispatch) (struct svc_req *, SVCXPRT *);
|
||||
}
|
||||
*svc_head;
|
||||
|
||||
static struct svc_callout *svc_find();
|
||||
static struct svc_callout *svc_find (u_long, u_long, struct svc_callout **);
|
||||
|
||||
/* *************** SVCXPRT related stuff **************** */
|
||||
|
||||
@ -81,22 +84,24 @@ static struct svc_callout *svc_find();
|
||||
* Activate a transport handle.
|
||||
*/
|
||||
void
|
||||
xprt_register(xprt)
|
||||
SVCXPRT *xprt;
|
||||
xprt_register (SVCXPRT *xprt)
|
||||
{
|
||||
register int sock = xprt->xp_sock;
|
||||
|
||||
#ifdef FD_SETSIZE
|
||||
if (xports == NULL) {
|
||||
if (xports == NULL)
|
||||
{
|
||||
xports = (SVCXPRT **)
|
||||
mem_alloc (FD_SETSIZE * sizeof (SVCXPRT *));
|
||||
}
|
||||
if (sock < _rpc_dtablesize()) {
|
||||
if (sock < _rpc_dtablesize ())
|
||||
{
|
||||
xports[sock] = xprt;
|
||||
FD_SET (sock, &svc_fdset);
|
||||
}
|
||||
#else
|
||||
if (sock < NOFILE) {
|
||||
if (sock < NOFILE)
|
||||
{
|
||||
xports[sock] = xprt;
|
||||
svc_fds |= (1 << sock);
|
||||
}
|
||||
@ -114,12 +119,14 @@ xprt_unregister(xprt)
|
||||
register int sock = xprt->xp_sock;
|
||||
|
||||
#ifdef FD_SETSIZE
|
||||
if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) {
|
||||
if ((sock < _rpc_dtablesize ()) && (xports[sock] == xprt))
|
||||
{
|
||||
xports[sock] = (SVCXPRT *) 0;
|
||||
FD_CLR (sock, &svc_fdset);
|
||||
}
|
||||
#else
|
||||
if ((sock < NOFILE) && (xports[sock] == xprt)) {
|
||||
if ((sock < NOFILE) && (xports[sock] == xprt))
|
||||
{
|
||||
xports[sock] = (SVCXPRT *) 0;
|
||||
svc_fds &= ~(1 << sock);
|
||||
}
|
||||
@ -135,24 +142,22 @@ xprt_unregister(xprt)
|
||||
* program number comes in.
|
||||
*/
|
||||
bool_t
|
||||
svc_register(xprt, prog, vers, dispatch, protocol)
|
||||
SVCXPRT *xprt;
|
||||
u_long prog;
|
||||
u_long vers;
|
||||
void (*dispatch)();
|
||||
int protocol;
|
||||
svc_register (SVCXPRT *xprt, u_long prog, u_long vers,
|
||||
void (*dispatch) (struct svc_req *, SVCXPRT *), u_long protocol)
|
||||
{
|
||||
struct svc_callout *prev;
|
||||
register struct svc_callout *s;
|
||||
|
||||
if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) {
|
||||
if ((s = svc_find (prog, vers, &prev)) != NULL_SVC)
|
||||
{
|
||||
if (s->sc_dispatch == dispatch)
|
||||
goto pmap_it; /* he is registering another xptr */
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
s = (struct svc_callout *) mem_alloc (sizeof (struct svc_callout));
|
||||
if (s == (struct svc_callout *)0) {
|
||||
return (FALSE);
|
||||
if (s == (struct svc_callout *) 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
s->sc_prog = prog;
|
||||
s->sc_vers = vers;
|
||||
@ -161,10 +166,11 @@ svc_register(xprt, prog, vers, dispatch, protocol)
|
||||
svc_head = s;
|
||||
pmap_it:
|
||||
/* now register the information with the local binder service */
|
||||
if (protocol) {
|
||||
return (pmap_set(prog, vers, protocol, xprt->xp_port));
|
||||
if (protocol)
|
||||
{
|
||||
return pmap_set (prog, vers, protocol, xprt->xp_port);
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -180,9 +186,12 @@ svc_unregister(prog, vers)
|
||||
|
||||
if ((s = svc_find (prog, vers, &prev)) == NULL_SVC)
|
||||
return;
|
||||
if (prev == NULL_SVC) {
|
||||
if (prev == NULL_SVC)
|
||||
{
|
||||
svc_head = s->sc_next;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prev->sc_next = s->sc_next;
|
||||
}
|
||||
s->sc_next = NULL_SVC;
|
||||
@ -196,22 +205,20 @@ svc_unregister(prog, vers)
|
||||
* struct.
|
||||
*/
|
||||
static struct svc_callout *
|
||||
svc_find(prog, vers, prev)
|
||||
u_long prog;
|
||||
u_long vers;
|
||||
struct svc_callout **prev;
|
||||
svc_find (u_long prog, u_long vers, struct svc_callout **prev)
|
||||
{
|
||||
register struct svc_callout *s, *p;
|
||||
|
||||
p = NULL_SVC;
|
||||
for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
|
||||
for (s = svc_head; s != NULL_SVC; s = s->sc_next)
|
||||
{
|
||||
if ((s->sc_prog == prog) && (s->sc_vers == vers))
|
||||
goto done;
|
||||
p = s;
|
||||
}
|
||||
done:
|
||||
*prev = p;
|
||||
return (s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/* ******************* REPLY GENERATION ROUTINES ************ */
|
||||
@ -233,7 +240,7 @@ svc_sendreply(xprt, xdr_results, xdr_location)
|
||||
rply.acpted_rply.ar_stat = SUCCESS;
|
||||
rply.acpted_rply.ar_results.where = xdr_location;
|
||||
rply.acpted_rply.ar_results.proc = xdr_results;
|
||||
return (SVC_REPLY(xprt, &rply));
|
||||
return SVC_REPLY (xprt, &rply);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -414,19 +421,25 @@ svc_getreqset(readfds)
|
||||
#ifdef FD_SETSIZE
|
||||
setsize = _rpc_dtablesize ();
|
||||
maskp = (u_int32_t *) readfds->fds_bits;
|
||||
for (sock = 0; sock < setsize; sock += 32) {
|
||||
for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) {
|
||||
for (sock = 0; sock < setsize; sock += 32)
|
||||
{
|
||||
for (mask = *maskp++; bit = ffs (mask); mask ^= (1 << (bit - 1)))
|
||||
{
|
||||
/* sock has input waiting */
|
||||
xprt = xports[sock + bit - 1];
|
||||
#else
|
||||
for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) {
|
||||
if ((readfds_local & 1) != 0) {
|
||||
for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1)
|
||||
{
|
||||
if ((readfds_local & 1) != 0)
|
||||
{
|
||||
/* sock has input waiting */
|
||||
xprt = xports[sock];
|
||||
#endif /* def FD_SETSIZE */
|
||||
/* now receive msgs from xprtprt (support batch calls) */
|
||||
do {
|
||||
if (SVC_RECV(xprt, &msg)) {
|
||||
do
|
||||
{
|
||||
if (SVC_RECV (xprt, &msg))
|
||||
{
|
||||
|
||||
/* now find the exported program and call it */
|
||||
register struct svc_callout *s;
|
||||
@ -438,7 +451,8 @@ svc_getreqset(readfds)
|
||||
r.rq_proc = msg.rm_call.cb_proc;
|
||||
r.rq_cred = msg.rm_call.cb_cred;
|
||||
/* first authenticate the message */
|
||||
if ((why= _authenticate(&r, &msg)) != AUTH_OK) {
|
||||
if ((why = _authenticate (&r, &msg)) != AUTH_OK)
|
||||
{
|
||||
svcerr_auth (xprt, why);
|
||||
goto call_done;
|
||||
}
|
||||
@ -446,9 +460,12 @@ svc_getreqset(readfds)
|
||||
prog_found = FALSE;
|
||||
low_vers = 0 - 1;
|
||||
high_vers = 0;
|
||||
for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
|
||||
if (s->sc_prog == r.rq_prog) {
|
||||
if (s->sc_vers == r.rq_vers) {
|
||||
for (s = svc_head; s != NULL_SVC; s = s->sc_next)
|
||||
{
|
||||
if (s->sc_prog == r.rq_prog)
|
||||
{
|
||||
if (s->sc_vers == r.rq_vers)
|
||||
{
|
||||
(*s->sc_dispatch) (&r, xprt);
|
||||
goto call_done;
|
||||
} /* found correct version */
|
||||
@ -471,11 +488,13 @@ svc_getreqset(readfds)
|
||||
/* Fall through to ... */
|
||||
}
|
||||
call_done:
|
||||
if ((stat = SVC_STAT(xprt)) == XPRT_DIED){
|
||||
if ((stat = SVC_STAT (xprt)) == XPRT_DIED)
|
||||
{
|
||||
SVC_DESTROY (xprt);
|
||||
break;
|
||||
}
|
||||
} while (stat == XPRT_MOREREQS);
|
||||
}
|
||||
while (stat == XPRT_MOREREQS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
#endif
|
||||
/* @(#)svc_auth.c 2.4 88/08/15 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
|
||||
@ -29,15 +27,20 @@ static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* svc_auth_nodes.c, Server-side rpc authenticator interface,
|
||||
* svc_auth.c, Server-side rpc authenticator interface.
|
||||
* *WITHOUT* DES authentication.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/svc.h>
|
||||
#include <rpc/svc_auth.h>
|
||||
|
||||
/*
|
||||
* svcauthsw is the bdevsw of server side authentication.
|
||||
@ -54,16 +57,22 @@ static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/
|
||||
*
|
||||
*/
|
||||
|
||||
enum auth_stat _svcauth_null(); /* no authentication */
|
||||
enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */
|
||||
enum auth_stat _svcauth_short(); /* short hand unix style */
|
||||
static enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *);
|
||||
/* no authentication */
|
||||
extern enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *);
|
||||
/* unix style (uid, gids) */
|
||||
extern enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *);
|
||||
/* short hand unix style */
|
||||
|
||||
static struct {
|
||||
enum auth_stat (*authenticator)();
|
||||
} svcauthsw[] = {
|
||||
_svcauth_null, /* AUTH_NULL */
|
||||
_svcauth_unix, /* AUTH_UNIX */
|
||||
_svcauth_short, /* AUTH_SHORT */
|
||||
static const struct
|
||||
{
|
||||
enum auth_stat (*authenticator) (struct svc_req *, struct rpc_msg *);
|
||||
}
|
||||
svcauthsw[] =
|
||||
{
|
||||
{ _svcauth_null }, /* AUTH_NULL */
|
||||
{ _svcauth_unix }, /* AUTH_UNIX */
|
||||
{ _svcauth_short } /* AUTH_SHORT */
|
||||
};
|
||||
#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */
|
||||
|
||||
@ -87,9 +96,7 @@ static struct {
|
||||
* invalid.
|
||||
*/
|
||||
enum auth_stat
|
||||
_authenticate(rqst, msg)
|
||||
register struct svc_req *rqst;
|
||||
struct rpc_msg *msg;
|
||||
_authenticate (register struct svc_req *rqst, struct rpc_msg *msg)
|
||||
{
|
||||
register int cred_flavor;
|
||||
|
||||
@ -97,18 +104,14 @@ _authenticate(rqst, msg)
|
||||
rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor;
|
||||
rqst->rq_xprt->xp_verf.oa_length = 0;
|
||||
cred_flavor = rqst->rq_cred.oa_flavor;
|
||||
if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) {
|
||||
return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg));
|
||||
if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL))
|
||||
return (*(svcauthsw[cred_flavor].authenticator)) (rqst, msg);
|
||||
|
||||
return AUTH_REJECTEDCRED;
|
||||
}
|
||||
|
||||
return (AUTH_REJECTEDCRED);
|
||||
}
|
||||
|
||||
enum auth_stat
|
||||
_svcauth_null(/*rqst, msg*/)
|
||||
/*struct svc_req *rqst;
|
||||
struct rpc_msg *msg;*/
|
||||
static enum auth_stat
|
||||
_svcauth_null (struct svc_req *rqst, struct rpc_msg *msg)
|
||||
{
|
||||
|
||||
return (AUTH_OK);
|
||||
return AUTH_OK;
|
||||
}
|
||||
|
@ -43,28 +43,30 @@ static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/svc.h>
|
||||
|
||||
/*
|
||||
* Unix longhand authenticator
|
||||
*/
|
||||
enum auth_stat
|
||||
_svcauth_unix(rqst, msg)
|
||||
register struct svc_req *rqst;
|
||||
register struct rpc_msg *msg;
|
||||
_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg)
|
||||
{
|
||||
register enum auth_stat stat;
|
||||
enum auth_stat stat;
|
||||
XDR xdrs;
|
||||
register struct authunix_parms *aup;
|
||||
register long *buf;
|
||||
struct area {
|
||||
struct authunix_parms *aup;
|
||||
long *buf;
|
||||
struct area
|
||||
{
|
||||
struct authunix_parms area_aup;
|
||||
char area_machname[MAX_MACHINE_NAME + 1];
|
||||
gid_t area_gids[NGRPS];
|
||||
} *area;
|
||||
}
|
||||
*area;
|
||||
u_int auth_len;
|
||||
int str_len, gid_len;
|
||||
register int i;
|
||||
u_int str_len, gid_len;
|
||||
u_int i;
|
||||
|
||||
area = (struct area *) rqst->rq_clntcred;
|
||||
aup = &area->area_aup;
|
||||
@ -73,10 +75,12 @@ _svcauth_unix(rqst, msg)
|
||||
auth_len = (u_int) msg->rm_call.cb_cred.oa_length;
|
||||
xdrmem_create (&xdrs, msg->rm_call.cb_cred.oa_base, auth_len, XDR_DECODE);
|
||||
buf = XDR_INLINE (&xdrs, auth_len);
|
||||
if (buf != NULL) {
|
||||
if (buf != NULL)
|
||||
{
|
||||
aup->aup_time = IXDR_GET_LONG (buf);
|
||||
str_len = IXDR_GET_U_LONG (buf);
|
||||
if (str_len > MAX_MACHINE_NAME) {
|
||||
if (str_len > MAX_MACHINE_NAME)
|
||||
{
|
||||
stat = AUTH_BADCRED;
|
||||
goto done;
|
||||
}
|
||||
@ -87,25 +91,30 @@ _svcauth_unix(rqst, msg)
|
||||
aup->aup_uid = IXDR_GET_LONG (buf);
|
||||
aup->aup_gid = IXDR_GET_LONG (buf);
|
||||
gid_len = IXDR_GET_U_LONG (buf);
|
||||
if (gid_len > NGRPS) {
|
||||
if (gid_len > NGRPS)
|
||||
{
|
||||
stat = AUTH_BADCRED;
|
||||
goto done;
|
||||
}
|
||||
aup->aup_len = gid_len;
|
||||
for (i = 0; i < gid_len; i++) {
|
||||
for (i = 0; i < gid_len; i++)
|
||||
{
|
||||
aup->aup_gids[i] = IXDR_GET_LONG (buf);
|
||||
}
|
||||
/*
|
||||
* five is the smallest unix credentials structure -
|
||||
* timestamp, hostname len (0), uid, gid, and gids len (0).
|
||||
*/
|
||||
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) {
|
||||
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len)
|
||||
{
|
||||
(void) printf ("bad auth_len gid %d str %d auth %d\n",
|
||||
gid_len, str_len, auth_len);
|
||||
stat = AUTH_BADCRED;
|
||||
goto done;
|
||||
}
|
||||
} else if (! xdr_authunix_parms(&xdrs, aup)) {
|
||||
}
|
||||
else if (!xdr_authunix_parms (&xdrs, aup))
|
||||
{
|
||||
xdrs.x_op = XDR_FREE;
|
||||
(void) xdr_authunix_parms (&xdrs, aup);
|
||||
stat = AUTH_BADCRED;
|
||||
@ -116,7 +125,7 @@ _svcauth_unix(rqst, msg)
|
||||
stat = AUTH_OK;
|
||||
done:
|
||||
XDR_DESTROY (&xdrs);
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
@ -126,9 +135,7 @@ done:
|
||||
*/
|
||||
/*ARGSUSED */
|
||||
enum auth_stat
|
||||
_svcauth_short(rqst, msg)
|
||||
struct svc_req *rqst;
|
||||
struct rpc_msg *msg;
|
||||
_svcauth_short (struct svc_req *rqst, struct rpc_msg *msg)
|
||||
{
|
||||
return (AUTH_REJECTEDCRED);
|
||||
return AUTH_REJECTEDCRED;
|
||||
}
|
||||
|
@ -41,26 +41,29 @@ static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
#include <rpc/svc.h>
|
||||
|
||||
/*
|
||||
* This is the "network" that we will be moving data over
|
||||
*/
|
||||
static struct svcraw_private {
|
||||
static struct svcraw_private
|
||||
{
|
||||
char _raw_buf[UDPMSGSIZE];
|
||||
SVCXPRT server;
|
||||
XDR xdr_stream;
|
||||
char verf_body[MAX_AUTH_BYTES];
|
||||
} *svcraw_private;
|
||||
}
|
||||
*svcraw_private;
|
||||
|
||||
static bool_t svcraw_recv();
|
||||
static enum xprt_stat svcraw_stat();
|
||||
static bool_t svcraw_getargs();
|
||||
static bool_t svcraw_reply();
|
||||
static bool_t svcraw_freeargs();
|
||||
static void svcraw_destroy();
|
||||
static bool_t svcraw_recv (SVCXPRT *, struct rpc_msg *);
|
||||
static enum xprt_stat svcraw_stat (SVCXPRT *);
|
||||
static bool_t svcraw_getargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static bool_t svcraw_reply (SVCXPRT *, struct rpc_msg *);
|
||||
static bool_t svcraw_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static void svcraw_destroy (SVCXPRT *);
|
||||
|
||||
static struct xp_ops server_ops = {
|
||||
static struct xp_ops server_ops =
|
||||
{
|
||||
svcraw_recv,
|
||||
svcraw_stat,
|
||||
svcraw_getargs,
|
||||
@ -70,28 +73,28 @@ static struct xp_ops server_ops = {
|
||||
};
|
||||
|
||||
SVCXPRT *
|
||||
svcraw_create()
|
||||
svcraw_create (void)
|
||||
{
|
||||
register struct svcraw_private *srp = svcraw_private;
|
||||
struct svcraw_private *srp = svcraw_private;
|
||||
|
||||
if (srp == 0) {
|
||||
if (srp == 0)
|
||||
{
|
||||
srp = (struct svcraw_private *) calloc (1, sizeof (*srp));
|
||||
if (srp == 0)
|
||||
return (0);
|
||||
return NULL;
|
||||
}
|
||||
srp->server.xp_sock = 0;
|
||||
srp->server.xp_port = 0;
|
||||
srp->server.xp_ops = &server_ops;
|
||||
srp->server.xp_verf.oa_base = srp->verf_body;
|
||||
xdrmem_create (&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE);
|
||||
return (&srp->server);
|
||||
return &srp->server;
|
||||
}
|
||||
|
||||
static enum xprt_stat
|
||||
svcraw_stat()
|
||||
svcraw_stat (SVCXPRT *xprt)
|
||||
{
|
||||
|
||||
return (XPRT_IDLE);
|
||||
return XPRT_IDLE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
@ -99,68 +102,60 @@ svcraw_recv(xprt, msg)
|
||||
SVCXPRT *xprt;
|
||||
struct rpc_msg *msg;
|
||||
{
|
||||
register struct svcraw_private *srp = svcraw_private;
|
||||
register XDR *xdrs;
|
||||
struct svcraw_private *srp = svcraw_private;
|
||||
XDR *xdrs;
|
||||
|
||||
if (srp == 0)
|
||||
return (0);
|
||||
return FALSE;
|
||||
xdrs = &srp->xdr_stream;
|
||||
xdrs->x_op = XDR_DECODE;
|
||||
XDR_SETPOS (xdrs, 0);
|
||||
if (!xdr_callmsg (xdrs, msg))
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
svcraw_reply(xprt, msg)
|
||||
SVCXPRT *xprt;
|
||||
struct rpc_msg *msg;
|
||||
svcraw_reply (SVCXPRT *xprt, struct rpc_msg *msg)
|
||||
{
|
||||
register struct svcraw_private *srp = svcraw_private;
|
||||
register XDR *xdrs;
|
||||
struct svcraw_private *srp = svcraw_private;
|
||||
XDR *xdrs;
|
||||
|
||||
if (srp == 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
xdrs = &srp->xdr_stream;
|
||||
xdrs->x_op = XDR_ENCODE;
|
||||
XDR_SETPOS (xdrs, 0);
|
||||
if (!xdr_replymsg (xdrs, msg))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
(void) XDR_GETPOS (xdrs); /* called just for overhead */
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
svcraw_getargs(xprt, xdr_args, args_ptr)
|
||||
SVCXPRT *xprt;
|
||||
xdrproc_t xdr_args;
|
||||
caddr_t args_ptr;
|
||||
svcraw_getargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
|
||||
{
|
||||
register struct svcraw_private *srp = svcraw_private;
|
||||
struct svcraw_private *srp = svcraw_private;
|
||||
|
||||
if (srp == 0)
|
||||
return (FALSE);
|
||||
return ((*xdr_args)(&srp->xdr_stream, args_ptr));
|
||||
return FALSE;
|
||||
return (*xdr_args) (&srp->xdr_stream, args_ptr);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
svcraw_freeargs(xprt, xdr_args, args_ptr)
|
||||
SVCXPRT *xprt;
|
||||
xdrproc_t xdr_args;
|
||||
caddr_t args_ptr;
|
||||
svcraw_freeargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
|
||||
{
|
||||
register struct svcraw_private *srp = svcraw_private;
|
||||
register XDR *xdrs;
|
||||
struct svcraw_private *srp = svcraw_private;
|
||||
XDR *xdrs;
|
||||
|
||||
if (srp == 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
xdrs = &srp->xdr_stream;
|
||||
xdrs->x_op = XDR_FREE;
|
||||
return ((*xdr_args)(xdrs, args_ptr));
|
||||
return (*xdr_args) (xdrs, args_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
svcraw_destroy()
|
||||
svcraw_destroy (SVCXPRT *xprt)
|
||||
{
|
||||
}
|
||||
|
@ -36,34 +36,34 @@ static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
|
||||
* This is the rpc server side idle loop
|
||||
* Wait for input, call server program.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
void
|
||||
svc_run()
|
||||
svc_run (void)
|
||||
{
|
||||
#ifdef FD_SETSIZE
|
||||
fd_set readfds;
|
||||
#else
|
||||
int readfds;
|
||||
#endif /* def FD_SETSIZE */
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
#ifdef FD_SETSIZE
|
||||
readfds = svc_fdset;
|
||||
#else
|
||||
readfds = svc_fds;
|
||||
#endif /* def FD_SETSIZE */
|
||||
switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0,
|
||||
(struct timeval *)0)) {
|
||||
switch (select (_rpc_dtablesize (), &readfds, (fd_set *)NULL,
|
||||
(fd_set *)NULL, (struct timeval *) 0))
|
||||
{
|
||||
case -1:
|
||||
if (errno == EINTR) {
|
||||
if (errno == EINTR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
perror("svc_run: - select failed");
|
||||
perror (_("svc_run: - select failed"));
|
||||
return;
|
||||
case 0:
|
||||
continue;
|
||||
|
@ -39,49 +39,59 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
static struct proglst {
|
||||
char *(*p_progname)();
|
||||
static struct proglst
|
||||
{
|
||||
char *(*p_progname) (char *);
|
||||
int p_prognum;
|
||||
int p_procnum;
|
||||
xdrproc_t p_inproc, p_outproc;
|
||||
struct proglst *p_nxt;
|
||||
} *proglst;
|
||||
static void universal();
|
||||
}
|
||||
*proglst;
|
||||
|
||||
static void universal (struct svc_req *rqstp, SVCXPRT *transp);
|
||||
static SVCXPRT *transp;
|
||||
|
||||
registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
|
||||
char *(*progname)();
|
||||
xdrproc_t inproc, outproc;
|
||||
int
|
||||
registerrpc (u_long prognum, u_long versnum, u_long procnum,
|
||||
char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
|
||||
{
|
||||
struct proglst *pl;
|
||||
|
||||
if (procnum == NULLPROC) {
|
||||
if (procnum == NULLPROC)
|
||||
{
|
||||
(void) fprintf (stderr,
|
||||
_("can't reassign procedure number %d\n"), NULLPROC);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (transp == 0) {
|
||||
if (transp == 0)
|
||||
{
|
||||
transp = svcudp_create (RPC_ANYSOCK);
|
||||
if (transp == NULL) {
|
||||
(void) fprintf(stderr, _("couldn't create an rpc server\n"));
|
||||
return (-1);
|
||||
if (transp == NULL)
|
||||
{
|
||||
(void) fputs (_("couldn't create an rpc server\n"), stderr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
(void) pmap_unset ((u_long) prognum, (u_long) versnum);
|
||||
if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
|
||||
universal, IPPROTO_UDP)) {
|
||||
universal, IPPROTO_UDP))
|
||||
{
|
||||
(void) fprintf (stderr, _("couldn't register prog %d vers %d\n"),
|
||||
prognum, versnum);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
pl = (struct proglst *) malloc (sizeof (struct proglst));
|
||||
if (pl == NULL) {
|
||||
if (pl == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, _("registerrpc: out of memory\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
pl->p_progname = progname;
|
||||
pl->p_prognum = prognum;
|
||||
@ -90,13 +100,11 @@ registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
|
||||
pl->p_outproc = outproc;
|
||||
pl->p_nxt = proglst;
|
||||
proglst = pl;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
universal(rqstp, transp)
|
||||
struct svc_req *rqstp;
|
||||
SVCXPRT *transp;
|
||||
universal (struct svc_req *rqstp, SVCXPRT *transp)
|
||||
{
|
||||
int prog, proc;
|
||||
char *outdata;
|
||||
@ -106,8 +114,10 @@ universal(rqstp, transp)
|
||||
/*
|
||||
* enforce "procnum 0 is echo" convention
|
||||
*/
|
||||
if (rqstp->rq_proc == NULLPROC) {
|
||||
if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) {
|
||||
if (rqstp->rq_proc == NULLPROC)
|
||||
{
|
||||
if (svc_sendreply (transp, (xdrproc_t)xdr_void, (char *) NULL) == FALSE)
|
||||
{
|
||||
(void) fprintf (stderr, "xxx\n");
|
||||
exit (1);
|
||||
}
|
||||
@ -116,18 +126,21 @@ universal(rqstp, transp)
|
||||
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) {
|
||||
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)) {
|
||||
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)
|
||||
if (outdata == NULL && pl->p_outproc != (xdrproc_t)xdr_void)
|
||||
/* there was an error */
|
||||
return;
|
||||
if (!svc_sendreply(transp, pl->p_outproc, outdata)) {
|
||||
if (!svc_sendreply (transp, pl->p_outproc, outdata))
|
||||
{
|
||||
(void) fprintf (stderr,
|
||||
_ ("trouble replying to prog %d\n"),
|
||||
pl->p_prognum);
|
||||
@ -140,4 +153,3 @@ universal(rqstp, transp)
|
||||
(void) fprintf (stderr, _ ("never registered prog %d\n"), prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
218
sunrpc/svc_tcp.c
218
sunrpc/svc_tcp.c
@ -42,25 +42,25 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#define abort ((bool_t (*) ()) abort)
|
||||
#ifndef errno
|
||||
extern errno;
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Ops vector for TCP/IP based rpc service handle
|
||||
*/
|
||||
static bool_t svctcp_recv();
|
||||
static enum xprt_stat svctcp_stat();
|
||||
static bool_t svctcp_getargs();
|
||||
static bool_t svctcp_reply();
|
||||
static bool_t svctcp_freeargs();
|
||||
static void svctcp_destroy();
|
||||
static bool_t svctcp_recv (SVCXPRT *, struct rpc_msg *);
|
||||
static enum xprt_stat svctcp_stat (SVCXPRT *);
|
||||
static bool_t svctcp_getargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static bool_t svctcp_reply (SVCXPRT *, struct rpc_msg *);
|
||||
static bool_t svctcp_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static void svctcp_destroy (SVCXPRT *);
|
||||
|
||||
static struct xp_ops svctcp_op = {
|
||||
static const struct xp_ops svctcp_op =
|
||||
{
|
||||
svctcp_recv,
|
||||
svctcp_stat,
|
||||
svctcp_getargs,
|
||||
@ -72,27 +72,31 @@ static struct xp_ops svctcp_op = {
|
||||
/*
|
||||
* Ops vector for TCP/IP rendezvous handler
|
||||
*/
|
||||
static bool_t rendezvous_request();
|
||||
static enum xprt_stat rendezvous_stat();
|
||||
static bool_t rendezvous_request (SVCXPRT *, struct rpc_msg *);
|
||||
static enum xprt_stat rendezvous_stat (SVCXPRT *);
|
||||
|
||||
static struct xp_ops svctcp_rendezvous_op = {
|
||||
static const struct xp_ops svctcp_rendezvous_op =
|
||||
{
|
||||
rendezvous_request,
|
||||
rendezvous_stat,
|
||||
abort,
|
||||
abort,
|
||||
abort,
|
||||
(bool_t (*) (SVCXPRT *, xdrproc_t, caddr_t)) abort,
|
||||
(bool_t (*) (SVCXPRT *, struct rpc_msg *)) abort,
|
||||
(bool_t (*) (SVCXPRT *, xdrproc_t, caddr_t)) abort,
|
||||
svctcp_destroy
|
||||
};
|
||||
|
||||
static int readtcp(), writetcp();
|
||||
static SVCXPRT *makefd_xprt();
|
||||
static int readtcp (char*, char *, int);
|
||||
static int writetcp (char *, char *, int);
|
||||
static SVCXPRT *makefd_xprt (int, u_int, u_int);
|
||||
|
||||
struct tcp_rendezvous { /* kept in xprt->xp_p1 */
|
||||
struct tcp_rendezvous
|
||||
{ /* kept in xprt->xp_p1 */
|
||||
u_int sendsize;
|
||||
u_int recvsize;
|
||||
};
|
||||
|
||||
struct tcp_conn { /* kept in xprt->xp_p1 */
|
||||
struct tcp_conn
|
||||
{ /* kept in xprt->xp_p1 */
|
||||
enum xprt_stat strm_stat;
|
||||
u_long x_id;
|
||||
XDR xdrs;
|
||||
@ -120,48 +124,51 @@ struct tcp_conn { /* kept in xprt->xp_p1 */
|
||||
* 0 => use the system default.
|
||||
*/
|
||||
SVCXPRT *
|
||||
svctcp_create(sock, sendsize, recvsize)
|
||||
register int sock;
|
||||
u_int sendsize;
|
||||
u_int recvsize;
|
||||
svctcp_create (int sock, u_int sendsize, u_int recvsize)
|
||||
{
|
||||
bool_t madesock = FALSE;
|
||||
register SVCXPRT *xprt;
|
||||
register struct tcp_rendezvous *r;
|
||||
SVCXPRT *xprt;
|
||||
struct tcp_rendezvous *r;
|
||||
struct sockaddr_in addr;
|
||||
int len = sizeof (struct sockaddr_in);
|
||||
|
||||
if (sock == RPC_ANYSOCK) {
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
|
||||
if (sock == RPC_ANYSOCK)
|
||||
{
|
||||
if ((sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
|
||||
{
|
||||
perror (_("svctcp_.c - udp socket creation problem"));
|
||||
return ((SVCXPRT *)NULL);
|
||||
return (SVCXPRT *) NULL;
|
||||
}
|
||||
madesock = TRUE;
|
||||
}
|
||||
bzero ((char *) &addr, sizeof (addr));
|
||||
addr.sin_family = AF_INET;
|
||||
if (bindresvport(sock, &addr)) {
|
||||
if (bindresvport (sock, &addr))
|
||||
{
|
||||
addr.sin_port = 0;
|
||||
(void) bind (sock, (struct sockaddr *) &addr, len);
|
||||
}
|
||||
if ((getsockname (sock, (struct sockaddr *) &addr, &len) != 0) ||
|
||||
(listen(sock, 2) != 0)) {
|
||||
(listen (sock, 2) != 0))
|
||||
{
|
||||
perror (_("svctcp_.c - cannot getsockname or listen"));
|
||||
if (madesock)
|
||||
(void) close (sock);
|
||||
return ((SVCXPRT *)NULL);
|
||||
return (SVCXPRT *) NULL;
|
||||
}
|
||||
r = (struct tcp_rendezvous *) mem_alloc (sizeof (*r));
|
||||
if (r == NULL) {
|
||||
(void) fprintf(stderr, _("svctcp_create: out of memory\n"));
|
||||
return (NULL);
|
||||
if (r == NULL)
|
||||
{
|
||||
(void) fputs (_("svctcp_create: out of memory\n"), stderr);
|
||||
return NULL;
|
||||
}
|
||||
r->sendsize = sendsize;
|
||||
r->recvsize = recvsize;
|
||||
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
|
||||
if (xprt == NULL) {
|
||||
(void) fprintf(stderr, _("svctcp_create: out of memory\n"));
|
||||
return (NULL);
|
||||
if (xprt == NULL)
|
||||
{
|
||||
(void) fputs (_("svctcp_create: out of memory\n"), stderr);
|
||||
return NULL;
|
||||
}
|
||||
xprt->xp_p2 = NULL;
|
||||
xprt->xp_p1 = (caddr_t) r;
|
||||
@ -170,7 +177,7 @@ svctcp_create(sock, sendsize, recvsize)
|
||||
xprt->xp_port = ntohs (addr.sin_port);
|
||||
xprt->xp_sock = sock;
|
||||
xprt_register (xprt);
|
||||
return (xprt);
|
||||
return xprt;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -178,32 +185,27 @@ svctcp_create(sock, sendsize, recvsize)
|
||||
* descriptor as its first input.
|
||||
*/
|
||||
SVCXPRT *
|
||||
svcfd_create(fd, sendsize, recvsize)
|
||||
int fd;
|
||||
u_int sendsize;
|
||||
u_int recvsize;
|
||||
svcfd_create (int fd, u_int sendsize, u_int recvsize)
|
||||
{
|
||||
|
||||
return (makefd_xprt(fd, sendsize, recvsize));
|
||||
return makefd_xprt (fd, sendsize, recvsize);
|
||||
}
|
||||
|
||||
static SVCXPRT *
|
||||
makefd_xprt(fd, sendsize, recvsize)
|
||||
int fd;
|
||||
u_int sendsize;
|
||||
u_int recvsize;
|
||||
makefd_xprt (int fd, u_int sendsize, u_int recvsize)
|
||||
{
|
||||
register SVCXPRT *xprt;
|
||||
register struct tcp_conn *cd;
|
||||
SVCXPRT *xprt;
|
||||
struct tcp_conn *cd;
|
||||
|
||||
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
|
||||
if (xprt == (SVCXPRT *)NULL) {
|
||||
(void) fprintf(stderr, _("svc_tcp: makefd_xprt: out of memory\n"));
|
||||
if (xprt == (SVCXPRT *) NULL)
|
||||
{
|
||||
(void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
|
||||
goto done;
|
||||
}
|
||||
cd = (struct tcp_conn *) mem_alloc (sizeof (struct tcp_conn));
|
||||
if (cd == (struct tcp_conn *)NULL) {
|
||||
(void) fprintf(stderr, _("svc_tcp: makefd_xprt: out of memory\n"));
|
||||
if (cd == (struct tcp_conn *) NULL)
|
||||
{
|
||||
(void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
|
||||
mem_free ((char *) xprt, sizeof (SVCXPRT));
|
||||
xprt = (SVCXPRT *) NULL;
|
||||
goto done;
|
||||
@ -220,12 +222,11 @@ makefd_xprt(fd, sendsize, recvsize)
|
||||
xprt->xp_sock = fd;
|
||||
xprt_register (xprt);
|
||||
done:
|
||||
return (xprt);
|
||||
return xprt;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
rendezvous_request(xprt)
|
||||
register SVCXPRT *xprt;
|
||||
rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg)
|
||||
{
|
||||
int sock;
|
||||
struct tcp_rendezvous *r;
|
||||
@ -236,10 +237,11 @@ rendezvous_request(xprt)
|
||||
again:
|
||||
len = sizeof (struct sockaddr_in);
|
||||
if ((sock = accept (xprt->xp_sock, (struct sockaddr *) &addr,
|
||||
&len)) < 0) {
|
||||
&len)) < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
goto again;
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* make a new transporter (re-uses xprt)
|
||||
@ -247,28 +249,29 @@ rendezvous_request(xprt)
|
||||
xprt = makefd_xprt (sock, r->sendsize, r->recvsize);
|
||||
xprt->xp_raddr = addr;
|
||||
xprt->xp_addrlen = len;
|
||||
return (FALSE); /* there is never an rpc msg to be processed */
|
||||
return FALSE; /* there is never an rpc msg to be processed */
|
||||
}
|
||||
|
||||
static enum xprt_stat
|
||||
rendezvous_stat()
|
||||
rendezvous_stat (SVCXPRT *xprt)
|
||||
{
|
||||
|
||||
return (XPRT_IDLE);
|
||||
return XPRT_IDLE;
|
||||
}
|
||||
|
||||
static void
|
||||
svctcp_destroy(xprt)
|
||||
register SVCXPRT *xprt;
|
||||
svctcp_destroy (SVCXPRT *xprt)
|
||||
{
|
||||
register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
|
||||
struct tcp_conn *cd = (struct tcp_conn *) xprt->xp_p1;
|
||||
|
||||
xprt_unregister (xprt);
|
||||
(void) close (xprt->xp_sock);
|
||||
if (xprt->xp_port != 0) {
|
||||
if (xprt->xp_port != 0)
|
||||
{
|
||||
/* a rendezvouser socket */
|
||||
xprt->xp_port = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* an actual connection socket */
|
||||
XDR_DESTROY (&(cd->xdrs));
|
||||
}
|
||||
@ -280,7 +283,8 @@ svctcp_destroy(xprt)
|
||||
* All read operations timeout after 35 seconds.
|
||||
* A timeout is fatal for the connection.
|
||||
*/
|
||||
static struct timeval wait_per_try = { 35, 0 };
|
||||
static struct timeval wait_per_try =
|
||||
{35, 0};
|
||||
|
||||
/*
|
||||
* reads data from the tcp connection.
|
||||
@ -288,12 +292,10 @@ static struct timeval wait_per_try = { 35, 0 };
|
||||
* (And a read of zero bytes is a half closed stream => error.)
|
||||
*/
|
||||
static int
|
||||
readtcp(xprt, buf, len)
|
||||
register SVCXPRT *xprt;
|
||||
caddr_t buf;
|
||||
register int len;
|
||||
readtcp (char *xprtptr, char *buf, int len)
|
||||
{
|
||||
register int sock = xprt->xp_sock;
|
||||
SVCXPRT *xprt = (SVCXPRT *)xprtptr;
|
||||
int sock = xprt->xp_sock;
|
||||
#ifdef FD_SETSIZE
|
||||
fd_set mask;
|
||||
fd_set readfds;
|
||||
@ -301,30 +303,36 @@ readtcp(xprt, buf, len)
|
||||
FD_ZERO (&mask);
|
||||
FD_SET (sock, &mask);
|
||||
#else
|
||||
register int mask = 1 << sock;
|
||||
int mask = 1 << sock;
|
||||
int readfds;
|
||||
#endif /* def FD_SETSIZE */
|
||||
do {
|
||||
do
|
||||
{
|
||||
struct timeval timeout = wait_per_try;
|
||||
readfds = mask;
|
||||
if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL,
|
||||
&timeout) <= 0) {
|
||||
if (errno == EINTR) {
|
||||
if (select (_rpc_dtablesize (), &readfds, (fd_set *) NULL,
|
||||
(fd_set *) NULL, &timeout) <= 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
goto fatal_err;
|
||||
}
|
||||
#ifdef FD_SETSIZE
|
||||
} while (!FD_ISSET(sock, &readfds));
|
||||
}
|
||||
while (!FD_ISSET (sock, &readfds));
|
||||
#else
|
||||
} while (readfds != mask);
|
||||
}
|
||||
while (readfds != mask);
|
||||
#endif /* def FD_SETSIZE */
|
||||
if ((len = read(sock, buf, len)) > 0) {
|
||||
return (len);
|
||||
if ((len = read (sock, buf, len)) > 0)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
fatal_err:
|
||||
((struct tcp_conn *) (xprt->xp_p1))->strm_stat = XPRT_DIED;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -332,15 +340,15 @@ fatal_err:
|
||||
* Any error is fatal and the connection is closed.
|
||||
*/
|
||||
static int
|
||||
writetcp(xprt, buf, len)
|
||||
register SVCXPRT *xprt;
|
||||
caddr_t buf;
|
||||
int len;
|
||||
writetcp (char *xprtptr, char * buf, int len)
|
||||
{
|
||||
register int i, cnt;
|
||||
SVCXPRT *xprt = (SVCXPRT *)xprtptr;
|
||||
int i, cnt;
|
||||
|
||||
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
|
||||
if ((i = write(xprt->xp_sock, buf, cnt)) < 0) {
|
||||
for (cnt = len; cnt > 0; cnt -= i, buf += i)
|
||||
{
|
||||
if ((i = write (xprt->xp_sock, buf, cnt)) < 0)
|
||||
{
|
||||
((struct tcp_conn *) (xprt->xp_p1))->strm_stat =
|
||||
XPRT_DIED;
|
||||
return (-1);
|
||||
@ -350,10 +358,9 @@ writetcp(xprt, buf, len)
|
||||
}
|
||||
|
||||
static enum xprt_stat
|
||||
svctcp_stat(xprt)
|
||||
SVCXPRT *xprt;
|
||||
svctcp_stat (SVCXPRT *xprt)
|
||||
{
|
||||
register struct tcp_conn *cd =
|
||||
struct tcp_conn *cd =
|
||||
(struct tcp_conn *) (xprt->xp_p1);
|
||||
|
||||
if (cd->strm_stat == XPRT_DIED)
|
||||
@ -366,15 +373,16 @@ svctcp_stat(xprt)
|
||||
static bool_t
|
||||
svctcp_recv (xprt, msg)
|
||||
SVCXPRT *xprt;
|
||||
register struct rpc_msg *msg;
|
||||
struct rpc_msg *msg;
|
||||
{
|
||||
register struct tcp_conn *cd =
|
||||
struct tcp_conn *cd =
|
||||
(struct tcp_conn *) (xprt->xp_p1);
|
||||
register XDR *xdrs = &(cd->xdrs);
|
||||
XDR *xdrs = &(cd->xdrs);
|
||||
|
||||
xdrs->x_op = XDR_DECODE;
|
||||
(void) xdrrec_skiprecord (xdrs);
|
||||
if (xdr_callmsg(xdrs, msg)) {
|
||||
if (xdr_callmsg (xdrs, msg))
|
||||
{
|
||||
cd->x_id = msg->rm_xid;
|
||||
return (TRUE);
|
||||
}
|
||||
@ -397,7 +405,7 @@ svctcp_freeargs(xprt, xdr_args, args_ptr)
|
||||
xdrproc_t xdr_args;
|
||||
caddr_t args_ptr;
|
||||
{
|
||||
register XDR *xdrs =
|
||||
XDR *xdrs =
|
||||
&(((struct tcp_conn *) (xprt->xp_p1))->xdrs);
|
||||
|
||||
xdrs->x_op = XDR_FREE;
|
||||
@ -407,12 +415,12 @@ svctcp_freeargs(xprt, xdr_args, args_ptr)
|
||||
static bool_t
|
||||
svctcp_reply (xprt, msg)
|
||||
SVCXPRT *xprt;
|
||||
register struct rpc_msg *msg;
|
||||
struct rpc_msg *msg;
|
||||
{
|
||||
register struct tcp_conn *cd =
|
||||
struct tcp_conn *cd =
|
||||
(struct tcp_conn *) (xprt->xp_p1);
|
||||
register XDR *xdrs = &(cd->xdrs);
|
||||
register bool_t stat;
|
||||
XDR *xdrs = &(cd->xdrs);
|
||||
bool_t stat;
|
||||
|
||||
xdrs->x_op = XDR_ENCODE;
|
||||
msg->rm_xid = cd->x_id;
|
||||
|
218
sunrpc/svc_udp.c
218
sunrpc/svc_udp.c
@ -40,6 +40,8 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
@ -50,14 +52,15 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
|
||||
#define MAX(a, b) ((a > b) ? a : b)
|
||||
#endif
|
||||
|
||||
static bool_t svcudp_recv();
|
||||
static bool_t svcudp_reply();
|
||||
static enum xprt_stat svcudp_stat();
|
||||
static bool_t svcudp_getargs();
|
||||
static bool_t svcudp_freeargs();
|
||||
static void svcudp_destroy();
|
||||
static bool_t svcudp_recv (SVCXPRT *, struct rpc_msg *);
|
||||
static bool_t svcudp_reply (SVCXPRT *, struct rpc_msg *);
|
||||
static enum xprt_stat svcudp_stat (SVCXPRT *);
|
||||
static bool_t svcudp_getargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static bool_t svcudp_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
static void svcudp_destroy (SVCXPRT *);
|
||||
|
||||
static struct xp_ops svcudp_op = {
|
||||
static const struct xp_ops svcudp_op =
|
||||
{
|
||||
svcudp_recv,
|
||||
svcudp_stat,
|
||||
svcudp_getargs,
|
||||
@ -66,14 +69,15 @@ static struct xp_ops svcudp_op = {
|
||||
svcudp_destroy
|
||||
};
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
static int cache_get (SVCXPRT *, struct rpc_msg *, char **replyp,
|
||||
u_long *replylenp);
|
||||
static void cache_set (SVCXPRT *xprt, u_long replylen);
|
||||
|
||||
/*
|
||||
* kept in xprt->xp_p2
|
||||
*/
|
||||
struct svcudp_data {
|
||||
struct svcudp_data
|
||||
{
|
||||
u_int su_iosz; /* byte size of send.recv buffer */
|
||||
u_long su_xid; /* transaction id */
|
||||
XDR su_xdrs; /* XDR handle */
|
||||
@ -97,51 +101,57 @@ struct svcudp_data {
|
||||
*/
|
||||
SVCXPRT *
|
||||
svcudp_bufcreate (sock, sendsz, recvsz)
|
||||
register int sock;
|
||||
int sock;
|
||||
u_int sendsz, recvsz;
|
||||
{
|
||||
bool_t madesock = FALSE;
|
||||
register SVCXPRT *xprt;
|
||||
register struct svcudp_data *su;
|
||||
SVCXPRT *xprt;
|
||||
struct svcudp_data *su;
|
||||
struct sockaddr_in addr;
|
||||
int len = sizeof (struct sockaddr_in);
|
||||
|
||||
if (sock == RPC_ANYSOCK) {
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||
if (sock == RPC_ANYSOCK)
|
||||
{
|
||||
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
||||
{
|
||||
perror (_("svcudp_create: socket creation problem"));
|
||||
return ((SVCXPRT *)NULL);
|
||||
return (SVCXPRT *) NULL;
|
||||
}
|
||||
madesock = TRUE;
|
||||
}
|
||||
bzero ((char *) &addr, sizeof (addr));
|
||||
addr.sin_family = AF_INET;
|
||||
if (bindresvport(sock, &addr)) {
|
||||
if (bindresvport (sock, &addr))
|
||||
{
|
||||
addr.sin_port = 0;
|
||||
(void) bind (sock, (struct sockaddr *) &addr, len);
|
||||
}
|
||||
if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) {
|
||||
if (getsockname (sock, (struct sockaddr *) &addr, &len) != 0)
|
||||
{
|
||||
perror (_("svcudp_create - cannot getsockname"));
|
||||
if (madesock)
|
||||
(void) close (sock);
|
||||
return ((SVCXPRT *)NULL);
|
||||
return (SVCXPRT *) NULL;
|
||||
}
|
||||
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
|
||||
if (xprt == NULL) {
|
||||
(void)fprintf(stderr, "svcudp_create: out of memory\n");
|
||||
return (NULL);
|
||||
if (xprt == NULL)
|
||||
{
|
||||
(void) fputs (_("svcudp_create: out of memory\n"), stderr);
|
||||
return NULL;
|
||||
}
|
||||
su = (struct svcudp_data *) mem_alloc (sizeof (*su));
|
||||
if (su == NULL) {
|
||||
(void)fprintf(stderr, "svcudp_create: out of memory\n");
|
||||
return (NULL);
|
||||
if (su == NULL)
|
||||
{
|
||||
(void) fputs (_("svcudp_create: out of memory\n"), stderr);
|
||||
return NULL;
|
||||
}
|
||||
su->su_iosz = ((MAX (sendsz, recvsz) + 3) / 4) * 4;
|
||||
if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) {
|
||||
(void)fprintf(stderr, "svcudp_create: out of memory\n");
|
||||
return (NULL);
|
||||
if ((rpc_buffer (xprt) = mem_alloc (su->su_iosz)) == NULL)
|
||||
{
|
||||
(void) fputs (_("svcudp_create: out of memory\n"), stderr);
|
||||
return NULL;
|
||||
}
|
||||
xdrmem_create(
|
||||
&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE);
|
||||
xdrmem_create (&(su->su_xdrs), rpc_buffer (xprt), su->su_iosz, XDR_DECODE);
|
||||
su->su_cache = NULL;
|
||||
xprt->xp_p2 = (caddr_t) su;
|
||||
xprt->xp_verf.oa_base = su->su_verfbody;
|
||||
@ -149,7 +159,7 @@ svcudp_bufcreate(sock, sendsz, recvsz)
|
||||
xprt->xp_port = ntohs (addr.sin_port);
|
||||
xprt->xp_sock = sock;
|
||||
xprt_register (xprt);
|
||||
return (xprt);
|
||||
return xprt;
|
||||
}
|
||||
|
||||
SVCXPRT *
|
||||
@ -157,7 +167,7 @@ svcudp_create(sock)
|
||||
int sock;
|
||||
{
|
||||
|
||||
return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE));
|
||||
return svcudp_bufcreate (sock, UDPMSGSIZE, UDPMSGSIZE);
|
||||
}
|
||||
|
||||
static enum xprt_stat
|
||||
@ -165,68 +175,73 @@ svcudp_stat(xprt)
|
||||
SVCXPRT *xprt;
|
||||
{
|
||||
|
||||
return (XPRT_IDLE);
|
||||
return XPRT_IDLE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
svcudp_recv (xprt, msg)
|
||||
register SVCXPRT *xprt;
|
||||
SVCXPRT *xprt;
|
||||
struct rpc_msg *msg;
|
||||
{
|
||||
register struct svcudp_data *su = su_data(xprt);
|
||||
register XDR *xdrs = &(su->su_xdrs);
|
||||
register int rlen;
|
||||
struct svcudp_data *su = su_data (xprt);
|
||||
XDR *xdrs = &(su->su_xdrs);
|
||||
int rlen;
|
||||
char *reply;
|
||||
u_long replylen;
|
||||
|
||||
again:
|
||||
xprt->xp_addrlen = sizeof (struct sockaddr_in);
|
||||
rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz,
|
||||
0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen));
|
||||
rlen = recvfrom (xprt->xp_sock, rpc_buffer (xprt), (int) su->su_iosz, 0,
|
||||
(struct sockaddr *) &(xprt->xp_raddr), &(xprt->xp_addrlen));
|
||||
if (rlen == -1 && errno == EINTR)
|
||||
goto again;
|
||||
if (rlen < 16) /* < 4 32-bit ints? */
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
xdrs->x_op = XDR_DECODE;
|
||||
XDR_SETPOS (xdrs, 0);
|
||||
if (!xdr_callmsg (xdrs, msg))
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
su->su_xid = msg->rm_xid;
|
||||
if (su->su_cache != NULL) {
|
||||
if (cache_get(xprt, msg, &reply, &replylen)) {
|
||||
if (su->su_cache != NULL)
|
||||
{
|
||||
if (cache_get (xprt, msg, &reply, &replylen))
|
||||
{
|
||||
(void) sendto (xprt->xp_sock, reply, (int) replylen, 0,
|
||||
(struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen);
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
svcudp_reply (xprt, msg)
|
||||
register SVCXPRT *xprt;
|
||||
SVCXPRT *xprt;
|
||||
struct rpc_msg *msg;
|
||||
{
|
||||
register struct svcudp_data *su = su_data(xprt);
|
||||
register XDR *xdrs = &(su->su_xdrs);
|
||||
register int slen;
|
||||
register bool_t stat = FALSE;
|
||||
struct svcudp_data *su = su_data (xprt);
|
||||
XDR *xdrs = &(su->su_xdrs);
|
||||
int slen;
|
||||
bool_t stat = FALSE;
|
||||
|
||||
xdrs->x_op = XDR_ENCODE;
|
||||
XDR_SETPOS (xdrs, 0);
|
||||
msg->rm_xid = su->su_xid;
|
||||
if (xdr_replymsg(xdrs, msg)) {
|
||||
if (xdr_replymsg (xdrs, msg))
|
||||
{
|
||||
slen = (int) XDR_GETPOS (xdrs);
|
||||
if (sendto (xprt->xp_sock, rpc_buffer (xprt), slen, 0,
|
||||
(struct sockaddr *) &(xprt->xp_raddr), xprt->xp_addrlen)
|
||||
== slen) {
|
||||
== slen)
|
||||
{
|
||||
stat = TRUE;
|
||||
if (su->su_cache && slen >= 0) {
|
||||
if (su->su_cache && slen >= 0)
|
||||
{
|
||||
cache_set (xprt, (u_long) slen);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
@ -236,7 +251,7 @@ svcudp_getargs(xprt, xdr_args, args_ptr)
|
||||
caddr_t args_ptr;
|
||||
{
|
||||
|
||||
return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr));
|
||||
return (*xdr_args) (&(su_data (xprt)->su_xdrs), args_ptr);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
@ -245,17 +260,17 @@ svcudp_freeargs(xprt, xdr_args, args_ptr)
|
||||
xdrproc_t xdr_args;
|
||||
caddr_t args_ptr;
|
||||
{
|
||||
register XDR *xdrs = &(su_data(xprt)->su_xdrs);
|
||||
XDR *xdrs = &(su_data (xprt)->su_xdrs);
|
||||
|
||||
xdrs->x_op = XDR_FREE;
|
||||
return ((*xdr_args)(xdrs, args_ptr));
|
||||
return (*xdr_args) (xdrs, args_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
svcudp_destroy (xprt)
|
||||
register SVCXPRT *xprt;
|
||||
SVCXPRT *xprt;
|
||||
{
|
||||
register struct svcudp_data *su = su_data(xprt);
|
||||
struct svcudp_data *su = su_data (xprt);
|
||||
|
||||
xprt_unregister (xprt);
|
||||
(void) close (xprt->xp_sock);
|
||||
@ -289,7 +304,8 @@ svcudp_destroy(xprt)
|
||||
* An entry in the cache
|
||||
*/
|
||||
typedef struct cache_node *cache_ptr;
|
||||
struct cache_node {
|
||||
struct cache_node
|
||||
{
|
||||
/*
|
||||
* Index into cache is xid, proc, vers, prog and address
|
||||
*/
|
||||
@ -314,7 +330,8 @@ struct cache_node {
|
||||
/*
|
||||
* The entire cache
|
||||
*/
|
||||
struct udp_cache {
|
||||
struct udp_cache
|
||||
{
|
||||
u_long uc_size; /* size of cache */
|
||||
cache_ptr *uc_entries; /* hash table of entries in cache */
|
||||
cache_ptr *uc_fifo; /* fifo list of entries in cache */
|
||||
@ -337,52 +354,53 @@ struct udp_cache {
|
||||
* Enable use of the cache.
|
||||
* Note: there is no disable.
|
||||
*/
|
||||
svcudp_enablecache(transp, size)
|
||||
SVCXPRT *transp;
|
||||
u_long size;
|
||||
int
|
||||
svcudp_enablecache (SVCXPRT *transp, u_long size)
|
||||
{
|
||||
struct svcudp_data *su = su_data (transp);
|
||||
struct udp_cache *uc;
|
||||
|
||||
if (su->su_cache != NULL) {
|
||||
if (su->su_cache != NULL)
|
||||
{
|
||||
CACHE_PERROR (_("enablecache: cache already enabled"));
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
uc = ALLOC (struct udp_cache, 1);
|
||||
if (uc == NULL) {
|
||||
if (uc == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("enablecache: could not allocate cache"));
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
uc->uc_size = size;
|
||||
uc->uc_nextvictim = 0;
|
||||
uc->uc_entries = ALLOC (cache_ptr, size * SPARSENESS);
|
||||
if (uc->uc_entries == NULL) {
|
||||
if (uc->uc_entries == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("enablecache: could not allocate cache data"));
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
BZERO (uc->uc_entries, cache_ptr, size * SPARSENESS);
|
||||
uc->uc_fifo = ALLOC (cache_ptr, size);
|
||||
if (uc->uc_fifo == NULL) {
|
||||
if (uc->uc_fifo == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("enablecache: could not allocate cache fifo"));
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
BZERO (uc->uc_fifo, cache_ptr, size);
|
||||
su->su_cache = (char *) uc;
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set an entry in the cache
|
||||
*/
|
||||
static
|
||||
cache_set(xprt, replylen)
|
||||
SVCXPRT *xprt;
|
||||
u_long replylen;
|
||||
static void
|
||||
cache_set (SVCXPRT *xprt, u_long replylen)
|
||||
{
|
||||
register cache_ptr victim;
|
||||
register cache_ptr *vicp;
|
||||
register struct svcudp_data *su = su_data(xprt);
|
||||
cache_ptr victim;
|
||||
cache_ptr *vicp;
|
||||
struct svcudp_data *su = su_data (xprt);
|
||||
struct udp_cache *uc = (struct udp_cache *) su->su_cache;
|
||||
u_int loc;
|
||||
char *newbuf;
|
||||
@ -392,27 +410,33 @@ cache_set(xprt, replylen)
|
||||
* reusing an old entry, or by mallocing a new one
|
||||
*/
|
||||
victim = uc->uc_fifo[uc->uc_nextvictim];
|
||||
if (victim != NULL) {
|
||||
if (victim != NULL)
|
||||
{
|
||||
loc = CACHE_LOC (xprt, victim->cache_xid);
|
||||
for (vicp = &uc->uc_entries[loc];
|
||||
*vicp != NULL && *vicp != victim;
|
||||
vicp = &(*vicp)->cache_next)
|
||||
;
|
||||
if (*vicp == NULL) {
|
||||
if (*vicp == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("cache_set: victim not found"));
|
||||
return;
|
||||
}
|
||||
*vicp = victim->cache_next; /* remote from cache */
|
||||
newbuf = victim->cache_reply;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
victim = ALLOC (struct cache_node, 1);
|
||||
if (victim == NULL) {
|
||||
CACHE_PERROR("cache_set: victim alloc failed");
|
||||
if (victim == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("cache_set: victim alloc failed"));
|
||||
return;
|
||||
}
|
||||
newbuf = mem_alloc (su->su_iosz);
|
||||
if (newbuf == NULL) {
|
||||
CACHE_PERROR("cache_set: could not allocate new rpc_buffer");
|
||||
if (newbuf == NULL)
|
||||
{
|
||||
CACHE_PERROR (_("cache_set: could not allocate new rpc_buffer"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -440,7 +464,7 @@ cache_set(xprt, replylen)
|
||||
* Try to get an entry from the cache
|
||||
* return 1 if found, 0 if not found
|
||||
*/
|
||||
static
|
||||
static int
|
||||
cache_get (xprt, msg, replyp, replylenp)
|
||||
SVCXPRT *xprt;
|
||||
struct rpc_msg *msg;
|
||||
@ -448,22 +472,24 @@ cache_get(xprt, msg, replyp, replylenp)
|
||||
u_long *replylenp;
|
||||
{
|
||||
u_int loc;
|
||||
register cache_ptr ent;
|
||||
register struct svcudp_data *su = su_data(xprt);
|
||||
register struct udp_cache *uc = (struct udp_cache *) su->su_cache;
|
||||
cache_ptr ent;
|
||||
struct svcudp_data *su = su_data (xprt);
|
||||
struct udp_cache *uc = (struct udp_cache *) su->su_cache;
|
||||
|
||||
#define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0)
|
||||
|
||||
loc = CACHE_LOC (xprt, su->su_xid);
|
||||
for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {
|
||||
for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next)
|
||||
{
|
||||
if (ent->cache_xid == su->su_xid &&
|
||||
ent->cache_proc == uc->uc_proc &&
|
||||
ent->cache_vers == uc->uc_vers &&
|
||||
ent->cache_prog == uc->uc_prog &&
|
||||
EQADDR(ent->cache_addr, uc->uc_addr)) {
|
||||
EQADDR (ent->cache_addr, uc->uc_addr))
|
||||
{
|
||||
*replyp = ent->cache_reply;
|
||||
*replylenp = ent->cache_replylen;
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -474,5 +500,5 @@ cache_get(xprt, msg, replyp, replylenp)
|
||||
uc->uc_vers = msg->rm_call.cb_vers;
|
||||
uc->uc_prog = msg->rm_call.cb_prog;
|
||||
uc->uc_addr = xprt->xp_raddr;
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
183
sunrpc/xdr.c
183
sunrpc/xdr.c
@ -57,7 +57,8 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
|
||||
/*
|
||||
* for unit alignment
|
||||
*/
|
||||
static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
|
||||
static const char xdr_zero[BYTES_PER_XDR_UNIT] =
|
||||
{0, 0, 0, 0};
|
||||
|
||||
/*
|
||||
* Free a data structure using XDR
|
||||
@ -78,12 +79,9 @@ xdr_free(proc, objp)
|
||||
* XDR nothing
|
||||
*/
|
||||
bool_t
|
||||
xdr_void(/* xdrs, addr */)
|
||||
/* XDR *xdrs; */
|
||||
/* caddr_t addr; */
|
||||
xdr_void (void)
|
||||
{
|
||||
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -102,13 +100,15 @@ xdr_int(xdrs, ip)
|
||||
#if INT_MAX < LONG_MAX
|
||||
long l;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
l = (long) *ip;
|
||||
return XDR_PUTLONG (xdrs, &l);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &l)) {
|
||||
if (!XDR_GETLONG (xdrs, &l))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*ip = (int) l;
|
||||
@ -141,13 +141,15 @@ xdr_u_int(xdrs, up)
|
||||
#if UINT_MAX < ULONG_MAX
|
||||
u_long l;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
l = (u_long) * up;
|
||||
return XDR_PUTLONG (xdrs, &l);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &l)) {
|
||||
if (!XDR_GETLONG (xdrs, &l))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*up = (u_int) l;
|
||||
@ -171,20 +173,20 @@ xdr_u_int(xdrs, up)
|
||||
*/
|
||||
bool_t
|
||||
xdr_long (xdrs, lp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
{
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE)
|
||||
return (XDR_PUTLONG(xdrs, lp));
|
||||
return XDR_PUTLONG (xdrs, lp);
|
||||
|
||||
if (xdrs->x_op == XDR_DECODE)
|
||||
return (XDR_GETLONG(xdrs, lp));
|
||||
return XDR_GETLONG (xdrs, lp);
|
||||
|
||||
if (xdrs->x_op == XDR_FREE)
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -193,10 +195,11 @@ xdr_long(xdrs, lp)
|
||||
*/
|
||||
bool_t
|
||||
xdr_u_long (xdrs, ulp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
u_long *ulp;
|
||||
{
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
return XDR_GETLONG (xdrs, (long *) ulp);
|
||||
|
||||
@ -214,18 +217,20 @@ xdr_u_long(xdrs, ulp)
|
||||
*/
|
||||
bool_t
|
||||
xdr_short (xdrs, sp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
short *sp;
|
||||
{
|
||||
long l;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
l = (long) *sp;
|
||||
return XDR_PUTLONG (xdrs, &l);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &l)) {
|
||||
if (!XDR_GETLONG (xdrs, &l))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*sp = (short) l;
|
||||
@ -242,18 +247,20 @@ xdr_short(xdrs, sp)
|
||||
*/
|
||||
bool_t
|
||||
xdr_u_short (xdrs, usp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
u_short *usp;
|
||||
{
|
||||
u_long l;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
l = (u_long) * usp;
|
||||
return XDR_PUTLONG (xdrs, &l);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &l)) {
|
||||
if (!XDR_GETLONG (xdrs, &l))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*usp = (u_short) l;
|
||||
@ -277,7 +284,8 @@ xdr_char(xdrs, cp)
|
||||
int i;
|
||||
|
||||
i = (*cp);
|
||||
if (!xdr_int(xdrs, &i)) {
|
||||
if (!xdr_int (xdrs, &i))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*cp = i;
|
||||
@ -295,7 +303,8 @@ xdr_u_char(xdrs, cp)
|
||||
u_int u;
|
||||
|
||||
u = (*cp);
|
||||
if (!xdr_u_int(xdrs, &u)) {
|
||||
if (!xdr_u_int (xdrs, &u))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*cp = u;
|
||||
@ -307,18 +316,20 @@ xdr_u_char(xdrs, cp)
|
||||
*/
|
||||
bool_t
|
||||
xdr_bool (xdrs, bp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
bool_t *bp;
|
||||
{
|
||||
long lb;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
lb = *bp ? XDR_TRUE : XDR_FALSE;
|
||||
return XDR_PUTLONG (xdrs, &lb);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &lb)) {
|
||||
if (!XDR_GETLONG (xdrs, &lb))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*bp = (lb == XDR_FALSE) ? FALSE : TRUE;
|
||||
@ -339,22 +350,28 @@ xdr_enum(xdrs, ep)
|
||||
enum_t *ep;
|
||||
{
|
||||
#ifndef lint
|
||||
enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
|
||||
enum sizecheck
|
||||
{
|
||||
SIZEVAL
|
||||
}; /* used to find the size of an enum */
|
||||
|
||||
/*
|
||||
* enums are treated as ints
|
||||
*/
|
||||
if (sizeof (enum sizecheck) == 4) {
|
||||
if (sizeof (enum sizecheck) == 4)
|
||||
{
|
||||
#if INT_MAX < LONG_MAX
|
||||
long l;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_ENCODE:
|
||||
l = *ep;
|
||||
return XDR_PUTLONG (xdrs, &l);
|
||||
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETLONG(xdrs, &l)) {
|
||||
if (!XDR_GETLONG (xdrs, &l))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*ep = l;
|
||||
@ -364,16 +381,20 @@ xdr_enum(xdrs, ep)
|
||||
}
|
||||
return FALSE;
|
||||
#else
|
||||
return (xdr_long(xdrs, (long *)ep));
|
||||
return xdr_long (xdrs, (long *) ep);
|
||||
#endif
|
||||
} else if (sizeof (enum sizecheck) == sizeof (short)) {
|
||||
}
|
||||
else if (sizeof (enum sizecheck) == sizeof (short))
|
||||
{
|
||||
return xdr_short (xdrs, (short *) ep);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#else /* lint */
|
||||
(void) (xdr_short (xdrs, (short *) ep));
|
||||
return (xdr_long(xdrs, (long *)ep));
|
||||
return xdr_long (xdrs, (long *) ep);
|
||||
#endif /* lint */
|
||||
}
|
||||
|
||||
@ -384,12 +405,12 @@ xdr_enum(xdrs, ep)
|
||||
*/
|
||||
bool_t
|
||||
xdr_opaque (xdrs, cp, cnt)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t cp;
|
||||
register u_int cnt;
|
||||
u_int cnt;
|
||||
{
|
||||
register u_int rndup;
|
||||
static crud[BYTES_PER_XDR_UNIT];
|
||||
u_int rndup;
|
||||
static char crud[BYTES_PER_XDR_UNIT];
|
||||
|
||||
/*
|
||||
* if no data we are done
|
||||
@ -404,17 +425,20 @@ xdr_opaque(xdrs, cp, cnt)
|
||||
if (rndup > 0)
|
||||
rndup = BYTES_PER_XDR_UNIT - rndup;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
if (!XDR_GETBYTES(xdrs, cp, cnt)) {
|
||||
if (!XDR_GETBYTES (xdrs, cp, cnt))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (rndup == 0)
|
||||
return TRUE;
|
||||
return XDR_GETBYTES(xdrs, crud, rndup);
|
||||
return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup);
|
||||
|
||||
case XDR_ENCODE:
|
||||
if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
|
||||
if (!XDR_PUTBYTES (xdrs, cp, cnt))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (rndup == 0)
|
||||
@ -434,37 +458,43 @@ xdr_opaque(xdrs, cp, cnt)
|
||||
*/
|
||||
bool_t
|
||||
xdr_bytes (xdrs, cpp, sizep, maxsize)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
char **cpp;
|
||||
register u_int *sizep;
|
||||
u_int *sizep;
|
||||
u_int maxsize;
|
||||
{
|
||||
register char *sp = *cpp; /* sp is the actual string pointer */
|
||||
register u_int nodesize;
|
||||
char *sp = *cpp; /* sp is the actual string pointer */
|
||||
u_int nodesize;
|
||||
|
||||
/*
|
||||
* first deal with the length since xdr bytes are counted
|
||||
*/
|
||||
if (! xdr_u_int(xdrs, sizep)) {
|
||||
if (!xdr_u_int (xdrs, sizep))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
nodesize = *sizep;
|
||||
if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
|
||||
if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* now deal with the actual bytes
|
||||
*/
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
if (nodesize == 0) {
|
||||
if (nodesize == 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (sp == NULL) {
|
||||
if (sp == NULL)
|
||||
{
|
||||
*cpp = sp = (char *) mem_alloc (nodesize);
|
||||
}
|
||||
if (sp == NULL) {
|
||||
if (sp == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, "xdr_bytes: out of memory\n");
|
||||
return FALSE;
|
||||
}
|
||||
@ -474,7 +504,8 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
|
||||
return xdr_opaque (xdrs, sp, nodesize);
|
||||
|
||||
case XDR_FREE:
|
||||
if (sp != NULL) {
|
||||
if (sp != NULL)
|
||||
{
|
||||
mem_free (sp, nodesize);
|
||||
*cpp = NULL;
|
||||
}
|
||||
@ -508,18 +539,19 @@ xdr_netobj(xdrs, np)
|
||||
*/
|
||||
bool_t
|
||||
xdr_union (xdrs, dscmp, unp, choices, dfault)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
enum_t *dscmp; /* enum to decide which arm to work on */
|
||||
char *unp; /* the union itself */
|
||||
struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
|
||||
const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
|
||||
xdrproc_t dfault; /* default xdr routine */
|
||||
{
|
||||
register enum_t dscm;
|
||||
enum_t dscm;
|
||||
|
||||
/*
|
||||
* we deal with the discriminator; it's an enum
|
||||
*/
|
||||
if (! xdr_enum(xdrs, dscmp)) {
|
||||
if (!xdr_enum (xdrs, dscmp))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
dscm = *dscmp;
|
||||
@ -528,7 +560,8 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
|
||||
* search choices for a value that matches the discriminator.
|
||||
* if we find one, execute the xdr routine for that value.
|
||||
*/
|
||||
for (; choices->proc != NULL_xdrproc_t; choices++) {
|
||||
for (; choices->proc != NULL_xdrproc_t; choices++)
|
||||
{
|
||||
if (choices->value == dscm)
|
||||
return (*(choices->proc)) (xdrs, unp, LASTUNSIGNED);
|
||||
}
|
||||
@ -557,20 +590,22 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
|
||||
*/
|
||||
bool_t
|
||||
xdr_string (xdrs, cpp, maxsize)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
char **cpp;
|
||||
u_int maxsize;
|
||||
{
|
||||
register char *sp = *cpp; /* sp is the actual string pointer */
|
||||
char *sp = *cpp; /* sp is the actual string pointer */
|
||||
u_int size;
|
||||
u_int nodesize;
|
||||
|
||||
/*
|
||||
* first deal with the length since xdr strings are counted-strings
|
||||
*/
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_FREE:
|
||||
if (sp == NULL) {
|
||||
if (sp == NULL)
|
||||
{
|
||||
return TRUE; /* already free */
|
||||
}
|
||||
/* fall through... */
|
||||
@ -579,11 +614,15 @@ xdr_string(xdrs, cpp, maxsize)
|
||||
return FALSE;
|
||||
size = strlen (sp);
|
||||
break;
|
||||
case XDR_DECODE:
|
||||
break;
|
||||
}
|
||||
if (! xdr_u_int(xdrs, &size)) {
|
||||
if (!xdr_u_int (xdrs, &size))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (size > maxsize) {
|
||||
if (size > maxsize)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
nodesize = size + 1;
|
||||
@ -591,14 +630,17 @@ xdr_string(xdrs, cpp, maxsize)
|
||||
/*
|
||||
* now deal with the actual bytes
|
||||
*/
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
if (nodesize == 0) {
|
||||
if (nodesize == 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (sp == NULL)
|
||||
*cpp = sp = (char *) mem_alloc (nodesize);
|
||||
if (sp == NULL) {
|
||||
if (sp == NULL)
|
||||
{
|
||||
(void) fprintf (stderr, "xdr_string: out of memory\n");
|
||||
return FALSE;
|
||||
}
|
||||
@ -625,7 +667,8 @@ xdr_wrapstring(xdrs, cpp)
|
||||
XDR *xdrs;
|
||||
char **cpp;
|
||||
{
|
||||
if (xdr_string(xdrs, cpp, LASTUNSIGNED)) {
|
||||
if (xdr_string (xdrs, cpp, LASTUNSIGNED))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -41,7 +41,7 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
@ -57,26 +57,28 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
bool_t
|
||||
xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t *addrp; /* array pointer */
|
||||
u_int *sizep; /* number of elements */
|
||||
u_int maxsize; /* max numberof elements */
|
||||
u_int elsize; /* size in bytes of each element */
|
||||
xdrproc_t elproc; /* xdr routine to handle each element */
|
||||
{
|
||||
register u_int i;
|
||||
register caddr_t target = *addrp;
|
||||
register u_int c; /* the actual element count */
|
||||
register bool_t stat = TRUE;
|
||||
register u_int nodesize;
|
||||
u_int i;
|
||||
caddr_t target = *addrp;
|
||||
u_int c; /* the actual element count */
|
||||
bool_t stat = TRUE;
|
||||
u_int nodesize;
|
||||
|
||||
/* like strings, arrays are really counted arrays */
|
||||
if (! xdr_u_int(xdrs, sizep)) {
|
||||
return (FALSE);
|
||||
if (!xdr_u_int (xdrs, sizep))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
c = *sizep;
|
||||
if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
|
||||
return (FALSE);
|
||||
if ((c > maxsize) && (xdrs->x_op != XDR_FREE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
nodesize = c * elsize;
|
||||
|
||||
@ -85,27 +87,32 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
|
||||
* We also save time by checking for a null array if we are freeing.
|
||||
*/
|
||||
if (target == NULL)
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
if (c == 0)
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
*addrp = target = mem_alloc (nodesize);
|
||||
if (target == NULL) {
|
||||
if (target == NULL)
|
||||
{
|
||||
(void) fprintf (stderr,
|
||||
"xdr_array: out of memory\n");
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
bzero (target, nodesize);
|
||||
break;
|
||||
|
||||
case XDR_FREE:
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* now we xdr each element of array
|
||||
*/
|
||||
for (i = 0; (i < c) && stat; i++) {
|
||||
for (i = 0; (i < c) && stat; i++)
|
||||
{
|
||||
stat = (*elproc) (xdrs, target, LASTUNSIGNED);
|
||||
target += elsize;
|
||||
}
|
||||
@ -113,11 +120,12 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
|
||||
/*
|
||||
* the array may need freeing
|
||||
*/
|
||||
if (xdrs->x_op == XDR_FREE) {
|
||||
if (xdrs->x_op == XDR_FREE)
|
||||
{
|
||||
mem_free (*addrp, nodesize);
|
||||
*addrp = NULL;
|
||||
}
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -132,21 +140,23 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
|
||||
*/
|
||||
bool_t
|
||||
xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem)
|
||||
register XDR *xdrs;
|
||||
register char *basep;
|
||||
register u_int nelem;
|
||||
register u_int elemsize;
|
||||
register xdrproc_t xdr_elem;
|
||||
XDR *xdrs;
|
||||
char *basep;
|
||||
u_int nelem;
|
||||
u_int elemsize;
|
||||
xdrproc_t xdr_elem;
|
||||
{
|
||||
register u_int i;
|
||||
register char *elptr;
|
||||
u_int i;
|
||||
char *elptr;
|
||||
|
||||
elptr = basep;
|
||||
for (i = 0; i < nelem; i++) {
|
||||
if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) {
|
||||
return(FALSE);
|
||||
for (i = 0; i < nelem; i++)
|
||||
{
|
||||
if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
elptr += elemsize;
|
||||
}
|
||||
return(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -43,20 +43,20 @@ static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
static bool_t xdrmem_getlong();
|
||||
static bool_t xdrmem_putlong();
|
||||
static bool_t xdrmem_getbytes();
|
||||
static bool_t xdrmem_putbytes();
|
||||
static u_int xdrmem_getpos();
|
||||
static bool_t xdrmem_setpos();
|
||||
static long * xdrmem_inline();
|
||||
static void xdrmem_destroy();
|
||||
static bool_t xdrmem_getlong (XDR *, long *);
|
||||
static bool_t xdrmem_putlong (XDR *, long *);
|
||||
static bool_t xdrmem_getbytes (XDR *, caddr_t, u_int);
|
||||
static bool_t xdrmem_putbytes (XDR *, caddr_t, u_int);
|
||||
static u_int xdrmem_getpos (XDR *);
|
||||
static bool_t xdrmem_setpos (XDR *, u_int);
|
||||
static long *xdrmem_inline (XDR *, int);
|
||||
static void xdrmem_destroy (XDR *);
|
||||
|
||||
static struct xdr_ops xdrmem_ops = {
|
||||
static const struct xdr_ops xdrmem_ops =
|
||||
{
|
||||
xdrmem_getlong,
|
||||
xdrmem_putlong,
|
||||
xdrmem_getbytes,
|
||||
@ -73,7 +73,7 @@ static struct xdr_ops xdrmem_ops = {
|
||||
*/
|
||||
void
|
||||
xdrmem_create (xdrs, addr, size, op)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t addr;
|
||||
u_int size;
|
||||
enum xdr_op op;
|
||||
@ -86,99 +86,99 @@ xdrmem_create(xdrs, addr, size, op)
|
||||
}
|
||||
|
||||
static void
|
||||
xdrmem_destroy(/*xdrs*/)
|
||||
/*XDR *xdrs;*/
|
||||
xdrmem_destroy (XDR *xdrs)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrmem_getlong (xdrs, lp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
{
|
||||
|
||||
if ((xdrs->x_handy -= 4) < 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
*lp = (int32_t) ntohl ((*((int32_t *) (xdrs->x_private))));
|
||||
xdrs->x_private += 4;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrmem_putlong (xdrs, lp)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
{
|
||||
|
||||
if ((xdrs->x_handy -= 4) < 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
*(int32_t *) xdrs->x_private = htonl (*lp);
|
||||
xdrs->x_private += 4;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrmem_getbytes (xdrs, addr, len)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t addr;
|
||||
register u_int len;
|
||||
u_int len;
|
||||
{
|
||||
|
||||
if ((xdrs->x_handy -= len) < 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
bcopy (xdrs->x_private, addr, len);
|
||||
xdrs->x_private += len;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrmem_putbytes (xdrs, addr, len)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t addr;
|
||||
register u_int len;
|
||||
u_int len;
|
||||
{
|
||||
|
||||
if ((xdrs->x_handy -= len) < 0)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
bcopy (addr, xdrs->x_private, len);
|
||||
xdrs->x_private += len;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
xdrmem_getpos (xdrs)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
{
|
||||
|
||||
return ((u_long)xdrs->x_private - (u_long)xdrs->x_base);
|
||||
return (u_long) xdrs->x_private - (u_long) xdrs->x_base;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrmem_setpos (xdrs, pos)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
u_int pos;
|
||||
{
|
||||
register caddr_t newaddr = xdrs->x_base + pos;
|
||||
register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
|
||||
caddr_t newaddr = xdrs->x_base + pos;
|
||||
caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
|
||||
|
||||
if ((long) newaddr > (long) lastaddr)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
xdrs->x_private = newaddr;
|
||||
xdrs->x_handy = (long) lastaddr - (long) newaddr;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static long *
|
||||
xdrmem_inline (xdrs, len)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
int len;
|
||||
{
|
||||
long *buf = 0;
|
||||
|
||||
if (xdrs->x_handy >= len) {
|
||||
if (xdrs->x_handy >= len)
|
||||
{
|
||||
xdrs->x_handy -= len;
|
||||
buf = (long *) xdrs->x_private;
|
||||
xdrs->x_private += len;
|
||||
}
|
||||
return (buf);
|
||||
return buf;
|
||||
}
|
||||
|
219
sunrpc/xdr_rec.c
219
sunrpc/xdr_rec.c
@ -49,24 +49,21 @@ static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
extern long lseek();
|
||||
static bool_t xdrrec_getlong (XDR *, long *);
|
||||
static bool_t xdrrec_putlong (XDR *, long *);
|
||||
static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int);
|
||||
static bool_t xdrrec_putbytes (XDR *, caddr_t, u_int);
|
||||
static u_int xdrrec_getpos (XDR *);
|
||||
static bool_t xdrrec_setpos (XDR *, u_int);
|
||||
static long *xdrrec_inline (XDR *, int);
|
||||
static void xdrrec_destroy (XDR *);
|
||||
|
||||
static u_int fix_buf_size();
|
||||
|
||||
static bool_t xdrrec_getlong();
|
||||
static bool_t xdrrec_putlong();
|
||||
static bool_t xdrrec_getbytes();
|
||||
static bool_t xdrrec_putbytes();
|
||||
static u_int xdrrec_getpos();
|
||||
static bool_t xdrrec_setpos();
|
||||
static long * xdrrec_inline();
|
||||
static void xdrrec_destroy();
|
||||
|
||||
static struct xdr_ops xdrrec_ops = {
|
||||
static const struct xdr_ops xdrrec_ops =
|
||||
{
|
||||
xdrrec_getlong,
|
||||
xdrrec_putlong,
|
||||
xdrrec_getbytes,
|
||||
@ -92,13 +89,14 @@ static struct xdr_ops xdrrec_ops = {
|
||||
|
||||
#define LAST_FRAG (1UL << 31)
|
||||
|
||||
typedef struct rec_strm {
|
||||
typedef struct rec_strm
|
||||
{
|
||||
caddr_t tcp_handle;
|
||||
caddr_t the_buffer;
|
||||
/*
|
||||
* out-going bits
|
||||
*/
|
||||
int (*writeit)();
|
||||
int (*writeit) (char *, char *, int);
|
||||
caddr_t out_base; /* output buffer (points to frag header) */
|
||||
caddr_t out_finger; /* next output position */
|
||||
caddr_t out_boundry; /* data cannot up to this address */
|
||||
@ -107,7 +105,7 @@ typedef struct rec_strm {
|
||||
/*
|
||||
* in-coming bits
|
||||
*/
|
||||
int (*readit)();
|
||||
int (*readit) (char *, char *, int);
|
||||
u_long in_size; /* fixed size of the input buffer */
|
||||
caddr_t in_base;
|
||||
caddr_t in_finger; /* location of next byte to be had */
|
||||
@ -116,8 +114,14 @@ typedef struct rec_strm {
|
||||
bool_t last_frag;
|
||||
u_int sendsize;
|
||||
u_int recvsize;
|
||||
} RECSTREAM;
|
||||
}
|
||||
RECSTREAM;
|
||||
|
||||
static u_int fix_buf_size (u_int);
|
||||
static bool_t skip_input_bytes (RECSTREAM *, long);
|
||||
static bool_t flush_out (RECSTREAM *, bool_t);
|
||||
static bool_t set_input_fragment (RECSTREAM *);
|
||||
static bool_t get_input_bytes (RECSTREAM *, caddr_t, int);
|
||||
|
||||
/*
|
||||
* Create an xdr handle for xdrrec
|
||||
@ -129,19 +133,17 @@ typedef struct rec_strm {
|
||||
* calls expect that they take an opaque handle rather than an fd.
|
||||
*/
|
||||
void
|
||||
xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
|
||||
register XDR *xdrs;
|
||||
register u_int sendsize;
|
||||
register u_int recvsize;
|
||||
caddr_t tcp_handle;
|
||||
int (*readit)(); /* like read, but pass it a tcp_handle, not sock */
|
||||
int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */
|
||||
xdrrec_create (XDR *xdrs, u_int sendsize,
|
||||
u_int recvsize, caddr_t tcp_handle,
|
||||
int (*readit) (char *, char *, int),
|
||||
int (*writeit) (char *, char *, int))
|
||||
{
|
||||
register RECSTREAM *rstrm =
|
||||
RECSTREAM *rstrm =
|
||||
(RECSTREAM *) mem_alloc (sizeof (RECSTREAM));
|
||||
|
||||
if (rstrm == NULL) {
|
||||
(void)fprintf(stderr, "xdrrec_create: out of memory\n");
|
||||
if (rstrm == NULL)
|
||||
{
|
||||
(void) fputs (_("xdrrec_create: out of memory\n"), stderr);
|
||||
/*
|
||||
* This is bad. Should rework xdrrec_create to
|
||||
* return a handle, and in this case return NULL
|
||||
@ -154,8 +156,9 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
|
||||
rstrm->sendsize = sendsize = fix_buf_size (sendsize);
|
||||
rstrm->recvsize = recvsize = fix_buf_size (recvsize);
|
||||
rstrm->the_buffer = mem_alloc (sendsize + recvsize + BYTES_PER_XDR_UNIT);
|
||||
if (rstrm->the_buffer == NULL) {
|
||||
(void)fprintf(stderr, "xdrrec_create: out of memory\n");
|
||||
if (rstrm->the_buffer == NULL)
|
||||
{
|
||||
(void) fputs (_("xdrrec_create: out of memory\n"), stderr);
|
||||
return;
|
||||
}
|
||||
for (rstrm->out_base = rstrm->the_buffer;
|
||||
@ -193,8 +196,8 @@ xdrrec_getlong(xdrs, lp)
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
register int32_t *buflp = (int32_t *) rstrm->in_finger;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
int32_t *buflp = (int32_t *) rstrm->in_finger;
|
||||
int32_t mylong;
|
||||
|
||||
/* first try the inline, fast case */
|
||||
@ -204,7 +207,9 @@ xdrrec_getlong(xdrs, lp)
|
||||
*lp = (int32_t) ntohl (*buflp);
|
||||
rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
|
||||
rstrm->in_finger += BYTES_PER_XDR_UNIT;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xdrrec_getbytes (xdrs, (caddr_t) & mylong,
|
||||
BYTES_PER_XDR_UNIT))
|
||||
return FALSE;
|
||||
@ -218,10 +223,11 @@ xdrrec_putlong(xdrs, lp)
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
register int32_t *dest_lp = (int32_t *) rstrm->out_finger;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
int32_t *dest_lp = (int32_t *) rstrm->out_finger;
|
||||
|
||||
if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry) {
|
||||
if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
|
||||
{
|
||||
/*
|
||||
* this case should almost never happen so the code is
|
||||
* inefficient
|
||||
@ -240,15 +246,17 @@ xdrrec_putlong(xdrs, lp)
|
||||
static bool_t /* must manage buffers, fragments, and records */
|
||||
xdrrec_getbytes (xdrs, addr, len)
|
||||
XDR *xdrs;
|
||||
register caddr_t addr;
|
||||
register u_int len;
|
||||
caddr_t addr;
|
||||
u_int len;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
register int current;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
u_int current;
|
||||
|
||||
while (len > 0) {
|
||||
while (len > 0)
|
||||
{
|
||||
current = rstrm->fbtbc;
|
||||
if (current == 0) {
|
||||
if (current == 0)
|
||||
{
|
||||
if (rstrm->last_frag)
|
||||
return FALSE;
|
||||
if (!set_input_fragment (rstrm))
|
||||
@ -268,20 +276,22 @@ xdrrec_getbytes(xdrs, addr, len)
|
||||
static bool_t
|
||||
xdrrec_putbytes (xdrs, addr, len)
|
||||
XDR *xdrs;
|
||||
register caddr_t addr;
|
||||
register u_int len;
|
||||
caddr_t addr;
|
||||
u_int len;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
register int current;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
u_int current;
|
||||
|
||||
while (len > 0) {
|
||||
while (len > 0)
|
||||
{
|
||||
current = rstrm->out_boundry - rstrm->out_finger;
|
||||
current = (len < current) ? len : current;
|
||||
bcopy (addr, rstrm->out_finger, current);
|
||||
rstrm->out_finger += current;
|
||||
addr += current;
|
||||
len -= current;
|
||||
if (rstrm->out_finger == rstrm->out_boundry) {
|
||||
if (rstrm->out_finger == rstrm->out_boundry)
|
||||
{
|
||||
rstrm->frag_sent = TRUE;
|
||||
if (!flush_out (rstrm, FALSE))
|
||||
return FALSE;
|
||||
@ -291,15 +301,15 @@ xdrrec_putbytes(xdrs, addr, len)
|
||||
}
|
||||
|
||||
static u_int
|
||||
xdrrec_getpos(xdrs)
|
||||
register XDR *xdrs;
|
||||
xdrrec_getpos (XDR *xdrs)
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
|
||||
register long pos;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
long pos;
|
||||
|
||||
pos = lseek ((int) rstrm->tcp_handle, (long) 0, 1);
|
||||
if (pos != -1)
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
pos += rstrm->out_finger - rstrm->out_base;
|
||||
@ -313,21 +323,22 @@ xdrrec_getpos(xdrs)
|
||||
pos = (u_int) - 1;
|
||||
break;
|
||||
}
|
||||
return ((u_int) pos);
|
||||
return (u_int) pos;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrrec_setpos (xdrs, pos)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
u_int pos;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
u_int currpos = xdrrec_getpos (xdrs);
|
||||
int delta = currpos - pos;
|
||||
caddr_t newpos;
|
||||
|
||||
if ((int) currpos != -1)
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
newpos = rstrm->out_finger - delta;
|
||||
@ -343,28 +354,32 @@ xdrrec_setpos(xdrs, pos)
|
||||
newpos = rstrm->in_finger - delta;
|
||||
if ((delta < (int) (rstrm->fbtbc)) &&
|
||||
(newpos <= rstrm->in_boundry) &&
|
||||
(newpos >= rstrm->in_base)) {
|
||||
(newpos >= rstrm->in_base))
|
||||
{
|
||||
rstrm->in_finger = newpos;
|
||||
rstrm->fbtbc -= delta;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static long *
|
||||
xdrrec_inline(xdrs, len)
|
||||
register XDR *xdrs;
|
||||
int len;
|
||||
xdrrec_inline (XDR *xdrs, int len)
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
long *buf = NULL;
|
||||
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
if ((rstrm->out_finger + len) <= rstrm->out_boundry) {
|
||||
if ((rstrm->out_finger + len) <= rstrm->out_boundry)
|
||||
{
|
||||
buf = (long *) rstrm->out_finger;
|
||||
rstrm->out_finger += len;
|
||||
}
|
||||
@ -372,21 +387,25 @@ xdrrec_inline(xdrs, len)
|
||||
|
||||
case XDR_DECODE:
|
||||
if ((len <= rstrm->fbtbc) &&
|
||||
((rstrm->in_finger + len) <= rstrm->in_boundry)) {
|
||||
((rstrm->in_finger + len) <= rstrm->in_boundry))
|
||||
{
|
||||
buf = (long *) rstrm->in_finger;
|
||||
rstrm->fbtbc -= len;
|
||||
rstrm->in_finger += len;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
xdrrec_destroy (xdrs)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
|
||||
mem_free (rstrm->the_buffer,
|
||||
rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT);
|
||||
@ -406,9 +425,10 @@ bool_t
|
||||
xdrrec_skiprecord (xdrs)
|
||||
XDR *xdrs;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
|
||||
while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
|
||||
while (rstrm->fbtbc > 0 || (!rstrm->last_frag))
|
||||
{
|
||||
if (!skip_input_bytes (rstrm, rstrm->fbtbc))
|
||||
return FALSE;
|
||||
rstrm->fbtbc = 0;
|
||||
@ -428,9 +448,10 @@ bool_t
|
||||
xdrrec_eof (xdrs)
|
||||
XDR *xdrs;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
|
||||
while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
|
||||
while (rstrm->fbtbc > 0 || (!rstrm->last_frag))
|
||||
{
|
||||
if (!skip_input_bytes (rstrm, rstrm->fbtbc))
|
||||
return TRUE;
|
||||
rstrm->fbtbc = 0;
|
||||
@ -453,8 +474,8 @@ xdrrec_endofrecord(xdrs, sendnow)
|
||||
XDR *xdrs;
|
||||
bool_t sendnow;
|
||||
{
|
||||
register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
register u_long len; /* fragment length */
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
u_long len; /* fragment length */
|
||||
|
||||
if (sendnow || rstrm->frag_sent
|
||||
|| rstrm->out_finger + BYTES_PER_XDR_UNIT >= rstrm->out_boundry)
|
||||
@ -475,13 +496,10 @@ xdrrec_endofrecord(xdrs, sendnow)
|
||||
* Internal useful routines
|
||||
*/
|
||||
static bool_t
|
||||
flush_out(rstrm, eor)
|
||||
register RECSTREAM *rstrm;
|
||||
bool_t eor;
|
||||
flush_out (RECSTREAM *rstrm, bool_t eor)
|
||||
{
|
||||
register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0;
|
||||
register u_long len = (rstrm->out_finger
|
||||
- (char *) rstrm->frag_header
|
||||
u_long eormask = (eor == TRUE) ? LAST_FRAG : 0;
|
||||
u_long len = (rstrm->out_finger - (char *) rstrm->frag_header
|
||||
- BYTES_PER_XDR_UNIT);
|
||||
|
||||
*rstrm->frag_header = htonl (len | eormask);
|
||||
@ -495,12 +513,11 @@ flush_out(rstrm, eor)
|
||||
}
|
||||
|
||||
static bool_t /* knows nothing about records! Only about input buffers */
|
||||
fill_input_buf(rstrm)
|
||||
register RECSTREAM *rstrm;
|
||||
fill_input_buf (RECSTREAM *rstrm)
|
||||
{
|
||||
register caddr_t where;
|
||||
caddr_t where;
|
||||
u_int i;
|
||||
register int len;
|
||||
int len;
|
||||
|
||||
where = rstrm->in_base;
|
||||
i = (u_int) rstrm->in_boundry % BYTES_PER_XDR_UNIT;
|
||||
@ -515,16 +532,15 @@ fill_input_buf(rstrm)
|
||||
}
|
||||
|
||||
static bool_t /* knows nothing about records! Only about input buffers */
|
||||
get_input_bytes(rstrm, addr, len)
|
||||
register RECSTREAM *rstrm;
|
||||
register caddr_t addr;
|
||||
register int len;
|
||||
get_input_bytes (RECSTREAM *rstrm, caddr_t addr, int len)
|
||||
{
|
||||
register int current;
|
||||
int current;
|
||||
|
||||
while (len > 0) {
|
||||
while (len > 0)
|
||||
{
|
||||
current = rstrm->in_boundry - rstrm->in_finger;
|
||||
if (current == 0) {
|
||||
if (current == 0)
|
||||
{
|
||||
if (!fill_input_buf (rstrm))
|
||||
return FALSE;
|
||||
continue;
|
||||
@ -539,8 +555,7 @@ get_input_bytes(rstrm, addr, len)
|
||||
}
|
||||
|
||||
static bool_t /* next two bytes of the input stream are treated as a header */
|
||||
set_input_fragment(rstrm)
|
||||
register RECSTREAM *rstrm;
|
||||
set_input_fragment (RECSTREAM *rstrm)
|
||||
{
|
||||
u_long header;
|
||||
|
||||
@ -553,15 +568,15 @@ set_input_fragment(rstrm)
|
||||
}
|
||||
|
||||
static bool_t /* consumes input bytes; knows nothing about records! */
|
||||
skip_input_bytes(rstrm, cnt)
|
||||
register RECSTREAM *rstrm;
|
||||
long cnt;
|
||||
skip_input_bytes (RECSTREAM *rstrm, long cnt)
|
||||
{
|
||||
register int current;
|
||||
int current;
|
||||
|
||||
while (cnt > 0) {
|
||||
while (cnt > 0)
|
||||
{
|
||||
current = rstrm->in_boundry - rstrm->in_finger;
|
||||
if (current == 0) {
|
||||
if (current == 0)
|
||||
{
|
||||
if (!fill_input_buf (rstrm))
|
||||
return FALSE;
|
||||
continue;
|
||||
@ -574,10 +589,8 @@ skip_input_bytes(rstrm, cnt)
|
||||
}
|
||||
|
||||
static u_int
|
||||
fix_buf_size(s)
|
||||
register u_int s;
|
||||
fix_buf_size (u_int s)
|
||||
{
|
||||
|
||||
if (s < 100)
|
||||
s = 4000;
|
||||
return RNDUP (s);
|
||||
|
@ -41,6 +41,7 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
@ -57,37 +58,41 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
|
||||
*/
|
||||
bool_t
|
||||
xdr_reference (xdrs, pp, size, proc)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
caddr_t *pp; /* the pointer to work on */
|
||||
u_int size; /* size of the object pointed to */
|
||||
xdrproc_t proc; /* xdr routine to handle the object */
|
||||
{
|
||||
register caddr_t loc = *pp;
|
||||
register bool_t stat;
|
||||
caddr_t loc = *pp;
|
||||
bool_t stat;
|
||||
|
||||
if (loc == NULL)
|
||||
switch (xdrs->x_op) {
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_FREE:
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
|
||||
case XDR_DECODE:
|
||||
*pp = loc = (caddr_t) mem_alloc (size);
|
||||
if (loc == NULL) {
|
||||
(void) fprintf(stderr,
|
||||
"xdr_reference: out of memory\n");
|
||||
return (FALSE);
|
||||
if (loc == NULL)
|
||||
{
|
||||
(void) fputs (_("xdr_reference: out of memory\n"), stderr);
|
||||
return FALSE;
|
||||
}
|
||||
bzero (loc, (int) size);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
stat = (*proc) (xdrs, loc, LASTUNSIGNED);
|
||||
|
||||
if (xdrs->x_op == XDR_FREE) {
|
||||
if (xdrs->x_op == XDR_FREE)
|
||||
{
|
||||
mem_free (loc, size);
|
||||
*pp = NULL;
|
||||
}
|
||||
return (stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +117,7 @@ xdr_reference(xdrs, pp, size, proc)
|
||||
*/
|
||||
bool_t
|
||||
xdr_pointer (xdrs, objpp, obj_size, xdr_obj)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
char **objpp;
|
||||
u_int obj_size;
|
||||
xdrproc_t xdr_obj;
|
||||
@ -121,12 +126,14 @@ xdr_pointer(xdrs,objpp,obj_size,xdr_obj)
|
||||
bool_t more_data;
|
||||
|
||||
more_data = (*objpp != NULL);
|
||||
if (! xdr_bool(xdrs,&more_data)) {
|
||||
return (FALSE);
|
||||
if (!xdr_bool (xdrs, &more_data))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (! more_data) {
|
||||
if (!more_data)
|
||||
{
|
||||
*objpp = NULL;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
return (xdr_reference(xdrs,objpp,obj_size,xdr_obj));
|
||||
return xdr_reference (xdrs, objpp, obj_size, xdr_obj);
|
||||
}
|
||||
|
@ -45,19 +45,20 @@ static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
|
||||
#include <stdio.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
static bool_t xdrstdio_getlong();
|
||||
static bool_t xdrstdio_putlong();
|
||||
static bool_t xdrstdio_getbytes();
|
||||
static bool_t xdrstdio_putbytes();
|
||||
static u_int xdrstdio_getpos();
|
||||
static bool_t xdrstdio_setpos();
|
||||
static long * xdrstdio_inline();
|
||||
static void xdrstdio_destroy();
|
||||
static bool_t xdrstdio_getlong (XDR *, long *);
|
||||
static bool_t xdrstdio_putlong (XDR *, long *);
|
||||
static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int);
|
||||
static bool_t xdrstdio_putbytes (XDR *, caddr_t, u_int);
|
||||
static u_int xdrstdio_getpos (XDR *);
|
||||
static bool_t xdrstdio_setpos (XDR *, u_int);
|
||||
static long *xdrstdio_inline (XDR *, int);
|
||||
static void xdrstdio_destroy (XDR *);
|
||||
|
||||
/*
|
||||
* Ops vector for stdio type XDR
|
||||
*/
|
||||
static struct xdr_ops xdrstdio_ops = {
|
||||
static const struct xdr_ops xdrstdio_ops =
|
||||
{
|
||||
xdrstdio_getlong, /* deserialize a long int */
|
||||
xdrstdio_putlong, /* serialize a long int */
|
||||
xdrstdio_getbytes, /* deserialize counted bytes */
|
||||
@ -75,7 +76,7 @@ static struct xdr_ops xdrstdio_ops = {
|
||||
*/
|
||||
void
|
||||
xdrstdio_create (xdrs, file, op)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
FILE *file;
|
||||
enum xdr_op op;
|
||||
{
|
||||
@ -93,7 +94,7 @@ xdrstdio_create(xdrs, file, op)
|
||||
*/
|
||||
static void
|
||||
xdrstdio_destroy (xdrs)
|
||||
register XDR *xdrs;
|
||||
XDR *xdrs;
|
||||
{
|
||||
(void) fflush ((FILE *) xdrs->x_private);
|
||||
/* xx should we close the file ?? */
|
||||
@ -102,27 +103,25 @@ xdrstdio_destroy(xdrs)
|
||||
static bool_t
|
||||
xdrstdio_getlong (xdrs, lp)
|
||||
XDR *xdrs;
|
||||
register long *lp;
|
||||
long *lp;
|
||||
{
|
||||
int32_t mycopy;
|
||||
|
||||
if (fread ((caddr_t) & mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
*lp = (int32_t) ntohl (mycopy);
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrstdio_putlong(xdrs, lp)
|
||||
XDR *xdrs;
|
||||
long *lp;
|
||||
xdrstdio_putlong (XDR *xdrs, long *lp)
|
||||
{
|
||||
|
||||
int32_t mycopy = htonl(*lp);
|
||||
long mycopy = htonl (*lp);
|
||||
lp = &mycopy;
|
||||
if (fwrite ((caddr_t) lp, 4, 1, (FILE *) xdrs->x_private) != 1)
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
@ -133,44 +132,32 @@ xdrstdio_getbytes(xdrs, addr, len)
|
||||
{
|
||||
|
||||
if ((len != 0) && (fread (addr, (int) len, 1, (FILE *) xdrs->x_private) != 1))
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrstdio_putbytes(xdrs, addr, len)
|
||||
XDR *xdrs;
|
||||
caddr_t addr;
|
||||
u_int len;
|
||||
xdrstdio_putbytes (XDR *xdrs, caddr_t addr, u_int len)
|
||||
{
|
||||
|
||||
if ((len != 0) && (fwrite (addr, (int) len, 1, (FILE *) xdrs->x_private) != 1))
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
xdrstdio_getpos(xdrs)
|
||||
XDR *xdrs;
|
||||
xdrstdio_getpos (XDR *xdrs)
|
||||
{
|
||||
|
||||
return ((u_int) ftell((FILE *)xdrs->x_private));
|
||||
return (u_int) ftell ((FILE *) xdrs->x_private);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdrstdio_setpos(xdrs, pos)
|
||||
XDR *xdrs;
|
||||
u_int pos;
|
||||
xdrstdio_setpos (XDR *xdrs, u_int pos)
|
||||
{
|
||||
|
||||
return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
|
||||
FALSE : TRUE);
|
||||
return fseek ((FILE *) xdrs->x_private, (long) pos, 0) < 0 ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
static long *
|
||||
xdrstdio_inline(xdrs, len)
|
||||
XDR *xdrs;
|
||||
u_int len;
|
||||
xdrstdio_inline (XDR *xdrs, int len)
|
||||
{
|
||||
|
||||
/*
|
||||
@ -182,5 +169,5 @@ xdrstdio_inline(xdrs, len)
|
||||
* most of the gains to be had here and require storage
|
||||
* management on this buffer, so we don't do this.
|
||||
*/
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version.
|
||||
Copyright (C) 1991, 1992, 1994, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1994, 1996, 1997 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
|
||||
@ -48,6 +48,14 @@ typedef unsigned long int __sigset_t;
|
||||
#define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0)
|
||||
#define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0)
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
# define __sigisemptyset(set) (*(set) == (__sigset_t) 0)
|
||||
# define __sigandset(dest, left, right) \
|
||||
((*(set) = (*(left) & *(right))), 0)
|
||||
# define __sigorset(dest, left, right) \
|
||||
((*(set) = (*(left) | *(right))), 0)
|
||||
#endif
|
||||
|
||||
/* These functions needn't check for a bogus signal number -- error
|
||||
checking is done in the non __ versions. */
|
||||
|
||||
|
38
sysdeps/libm-i387/s_exp2.S
Normal file
38
sysdeps/libm-i387/s_exp2.S
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(__exp2)
|
||||
fldl 4(%esp)
|
||||
/* I added the following ugly construct because exp(+-Inf) resulted
|
||||
in NaN. The ugliness results from the bright minds at Intel.
|
||||
For the i686 the code can be written better.
|
||||
-- drepper@cygnus.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
frndint /* int(x) */
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: ret
|
||||
END (__exp2)
|
||||
weak_alias (__exp2, exp2)
|
38
sysdeps/libm-i387/s_exp2f.S
Normal file
38
sysdeps/libm-i387/s_exp2f.S
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(__exp2f)
|
||||
flds 4(%esp)
|
||||
/* I added the following ugly construct because exp(+-Inf) resulted
|
||||
in NaN. The ugliness results from the bright minds at Intel.
|
||||
For the i686 the code can be written better.
|
||||
-- drepper@cygnus.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
frndint /* int(x) */
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: ret
|
||||
END (__exp2f)
|
||||
weak_alias (__exp2f, exp2f)
|
38
sysdeps/libm-i387/s_exp2l.S
Normal file
38
sysdeps/libm-i387/s_exp2l.S
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(__exp2l)
|
||||
fldt 4(%esp)
|
||||
/* I added the following ugly construct because exp(+-Inf) resulted
|
||||
in NaN. The ugliness results from the bright minds at Intel.
|
||||
For the i686 the code can be written better.
|
||||
-- drepper@cygnus.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
frndint /* int(x) */
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: ret
|
||||
END (__exp2l)
|
||||
weak_alias (__exp2l, exp2l)
|
59
sysdeps/libm-i387/s_log2.S
Normal file
59
sysdeps/libm-i387/s_log2.S
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*
|
||||
* Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef __ELF__
|
||||
.section .rodata
|
||||
#else
|
||||
.text
|
||||
#endif
|
||||
.align ALIGNARG(4)
|
||||
ASM_TYPE_DIRECTIVE(one,@object)
|
||||
one: .double 1.0
|
||||
ASM_SIZE_DIRECTIVE(one)
|
||||
/* It is not important that this constant is precise. It is only
|
||||
a value which is known to be on the safe side for using the
|
||||
fyl2xp1 instruction. */
|
||||
ASM_TYPE_DIRECTIVE(limit,@object)
|
||||
limit: .double 0.29
|
||||
ASM_SIZE_DIRECTIVE(limit)
|
||||
|
||||
|
||||
#ifdef PIC
|
||||
#define MO(op) op##@GOTOFF(%edx)
|
||||
#else
|
||||
#define MO(op) op
|
||||
#endif
|
||||
|
||||
.text
|
||||
ENTRY(__log2)
|
||||
#ifdef PIC
|
||||
call 1f
|
||||
1: popl %edx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
|
||||
#endif
|
||||
fldl MO(one)
|
||||
fldl 4(%esp) // x : 1
|
||||
fld %st // x : x : 1
|
||||
fsub %st(2), %st // x-1 : x : 1
|
||||
fld %st // x-1 : x-1 : x : 1
|
||||
fabs // |x-1| : x-1 : x : 1
|
||||
fcompl MO(limit) // x-1 : x : 1
|
||||
fnstsw // x-1 : x : 1
|
||||
andb $0x45, %ah
|
||||
jz 2f
|
||||
fstp %st(1) // x-1 : 1
|
||||
fyl2xp1 // log(x)
|
||||
ret
|
||||
|
||||
2: fstp %st(0) // x : 1
|
||||
fyl2x // log(x)
|
||||
ret
|
||||
END (__log2)
|
||||
weak_alias (__log2, log2)
|
59
sysdeps/libm-i387/s_log2f.S
Normal file
59
sysdeps/libm-i387/s_log2f.S
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*
|
||||
* Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef __ELF__
|
||||
.section .rodata
|
||||
#else
|
||||
.text
|
||||
#endif
|
||||
.align ALIGNARG(4)
|
||||
ASM_TYPE_DIRECTIVE(one,@object)
|
||||
one: .double 1.0
|
||||
ASM_SIZE_DIRECTIVE(one)
|
||||
/* It is not important that this constant is precise. It is only
|
||||
a value which is known to be on the safe side for using the
|
||||
fyl2xp1 instruction. */
|
||||
ASM_TYPE_DIRECTIVE(limit,@object)
|
||||
limit: .double 0.29
|
||||
ASM_SIZE_DIRECTIVE(limit)
|
||||
|
||||
|
||||
#ifdef PIC
|
||||
#define MO(op) op##@GOTOFF(%edx)
|
||||
#else
|
||||
#define MO(op) op
|
||||
#endif
|
||||
|
||||
.text
|
||||
ENTRY(__log2f)
|
||||
#ifdef PIC
|
||||
call 1f
|
||||
1: popl %edx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
|
||||
#endif
|
||||
fldl MO(one)
|
||||
flds 4(%esp) // x : 1
|
||||
fld %st // x : x : 1
|
||||
fsub %st(2), %st // x-1 : x : 1
|
||||
fld %st // x-1 : x-1 : x : 1
|
||||
fabs // |x-1| : x-1 : x : 1
|
||||
fcompl MO(limit) // x-1 : x : 1
|
||||
fnstsw // x-1 : x : 1
|
||||
andb $0x45, %ah
|
||||
jz 2f
|
||||
fstp %st(1) // x-1 : 1
|
||||
fyl2xp1 // log(x)
|
||||
ret
|
||||
|
||||
2: fstp %st(0) // x : 1
|
||||
fyl2x // log(x)
|
||||
ret
|
||||
END (__log2f)
|
||||
weak_alias (__log2f, log2f)
|
59
sysdeps/libm-i387/s_log2l.S
Normal file
59
sysdeps/libm-i387/s_log2l.S
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*
|
||||
* Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef __ELF__
|
||||
.section .rodata
|
||||
#else
|
||||
.text
|
||||
#endif
|
||||
.align ALIGNARG(4)
|
||||
ASM_TYPE_DIRECTIVE(one,@object)
|
||||
one: .double 1.0
|
||||
ASM_SIZE_DIRECTIVE(one)
|
||||
/* It is not important that this constant is precise. It is only
|
||||
a value which is known to be on the safe side for using the
|
||||
fyl2xp1 instruction. */
|
||||
ASM_TYPE_DIRECTIVE(limit,@object)
|
||||
limit: .double 0.29
|
||||
ASM_SIZE_DIRECTIVE(limit)
|
||||
|
||||
|
||||
#ifdef PIC
|
||||
#define MO(op) op##@GOTOFF(%edx)
|
||||
#else
|
||||
#define MO(op) op
|
||||
#endif
|
||||
|
||||
.text
|
||||
ENTRY(__log2l)
|
||||
#ifdef PIC
|
||||
call 1f
|
||||
1: popl %edx
|
||||
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
|
||||
#endif
|
||||
fldl MO(one)
|
||||
fldt 4(%esp) // x : 1
|
||||
fld %st // x : x : 1
|
||||
fsub %st(2), %st // x-1 : x : 1
|
||||
fld %st // x-1 : x-1 : x : 1
|
||||
fabs // |x-1| : x-1 : x : 1
|
||||
fcompl MO(limit) // x-1 : x : 1
|
||||
fnstsw // x-1 : x : 1
|
||||
andb $0x45, %ah
|
||||
jz 2f
|
||||
fstp %st(1) // x-1 : 1
|
||||
fyl2xp1 // log(x)
|
||||
ret
|
||||
|
||||
2: fstp %st(0) // x : 1
|
||||
fyl2x // log(x)
|
||||
ret
|
||||
END (__log2l)
|
||||
weak_alias (__log2l, log2l)
|
@ -31,13 +31,18 @@ __cexpf (__complex__ float x)
|
||||
{
|
||||
if (isfinite (__imag__ x))
|
||||
{
|
||||
retval = __expf (__real__ x) * (__cosf (__imag__ x)
|
||||
+ 1i * __sinf (__imag__ x));
|
||||
float exp_val = __expf (__real__ x);
|
||||
|
||||
__real__ retval = exp_val * __cosf (__imag__ x);
|
||||
__imag__ retval = exp_val * __sinf (__imag__ x);
|
||||
}
|
||||
else
|
||||
/* If the imaginary part is +-inf or NaN and the real part is
|
||||
not +-inf the result is NaN + iNan. */
|
||||
retval = __nanf ("") + 1.0i * __nanf ("");
|
||||
{
|
||||
/* If the imaginary part is +-inf or NaN and the real part
|
||||
is not +-inf the result is NaN + iNaN. */
|
||||
__real__ retval = __nanf ("");
|
||||
__imag__ retval = __nanf ("");
|
||||
}
|
||||
}
|
||||
else if (__isinff (__real__ x))
|
||||
{
|
||||
@ -46,17 +51,27 @@ __cexpf (__complex__ float x)
|
||||
if (signbit (__real__ x) == 0 && __imag__ x == 0.0)
|
||||
retval = HUGE_VALF;
|
||||
else
|
||||
retval = ((signbit (__real__ x) ? 0.0 : HUGE_VALF)
|
||||
* (__cosf (__imag__ x) + 1i * __sinf (__imag__ x)));
|
||||
{
|
||||
float value = signbit (__real__ x) ? 0.0 : HUGE_VALF;
|
||||
|
||||
__real__ retval = value * __cosf (__imag__ x);
|
||||
__imag__ retval = value * __sinf (__imag__ x);
|
||||
}
|
||||
}
|
||||
else if (signbit (__real__ x) == 0)
|
||||
{
|
||||
__real__ retval = HUGE_VALF;
|
||||
__imag__ retval = __nanf ("");
|
||||
}
|
||||
else if (signbit (__real__ x))
|
||||
retval = HUGE_VALF + 1.0i * __nanf ("");
|
||||
else
|
||||
retval = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the real part is NaN the result is NaN + iNan. */
|
||||
retval = __nanf ("") + 1.0i * __nanf ("");
|
||||
__real__ retval = __nanf ("");
|
||||
__imag__ retval = __nanf ("");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Return value of complex exponential function for long double complex value.
|
||||
/* Return value of complex exponential function for float complex value.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||
@ -31,33 +31,48 @@ __cexpl (__complex__ long double x)
|
||||
{
|
||||
if (isfinite (__imag__ x))
|
||||
{
|
||||
retval = __expl (__real__ x) * (__cosl (__imag__ x)
|
||||
+ 1i * __sinl (__imag__ x));
|
||||
long double exp_val = __expl (__real__ x);
|
||||
|
||||
__real__ retval = exp_val * __cosl (__imag__ x);
|
||||
__imag__ retval = exp_val * __sinl (__imag__ x);
|
||||
}
|
||||
else
|
||||
/* If the imaginary part is +-inf or NaN and the real part is
|
||||
not +-inf the result is NaN + iNan. */
|
||||
retval = __nanl ("") + 1.0i * __nanl ("");
|
||||
{
|
||||
/* If the imaginary part is +-inf or NaN and the real part
|
||||
is not +-inf the result is NaN + iNaN. */
|
||||
__real__ retval = __nanl ("");
|
||||
__imag__ retval = __nanl ("");
|
||||
}
|
||||
}
|
||||
else if (__isinfl (__real__ x))
|
||||
{
|
||||
if (isfinite (__imag x))
|
||||
if (isfinite (__imag__ x))
|
||||
{
|
||||
if (signbit (__real__ x) == 0 && __imag__ x == 0.0)
|
||||
retval = HUGE_VALL;
|
||||
retval = HUGE_VAL;
|
||||
else
|
||||
retval = ((signbit (__real__ x) ? 0.0 : HUGE_VALL)
|
||||
* (__cosl (__imag__ x) + 1i * __sinl (__imag__ x)));
|
||||
{
|
||||
long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL;
|
||||
|
||||
__real__ retval = value * __cosl (__imag__ x);
|
||||
__imag__ retval = value * __sinl (__imag__ x);
|
||||
}
|
||||
}
|
||||
else if (signbit (__real__ x) == 0)
|
||||
{
|
||||
__real__ retval = HUGE_VALL;
|
||||
__imag__ retval = __nanl ("");
|
||||
}
|
||||
else if (signbit (__real__ x))
|
||||
retval = HUGE_VALL + 1.0i * __nanl ("");
|
||||
else
|
||||
retval = 0.0;
|
||||
}
|
||||
else
|
||||
/* If the real part is NaN the result is NaN + iNan. */
|
||||
retval = __nanl ("") + 1.0i * __nanl ("");
|
||||
{
|
||||
/* If the real part is NaN the result is NaN + iNaN. */
|
||||
__real__ retval = __nanl ("");
|
||||
__imag__ retval = __nanl ("");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
weak_alias (__cexpl, cexpl)
|
||||
weak_alias (__cexp, cexp)
|
||||
|
129
sysdeps/libm-ieee754/s_log2.c
Normal file
129
sysdeps/libm-ieee754/s_log2.c
Normal file
@ -0,0 +1,129 @@
|
||||
/* Adapted for log2 by Ulrich Drepper <drepper@cygnus.com>.
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/* __log2(x)
|
||||
* Return the logarithm to base 2 of x
|
||||
*
|
||||
* Method :
|
||||
* 1. Argument Reduction: find k and f such that
|
||||
* x = 2^k * (1+f),
|
||||
* where sqrt(2)/2 < 1+f < sqrt(2) .
|
||||
*
|
||||
* 2. Approximation of log(1+f).
|
||||
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
|
||||
* = 2s + 2/3 s**3 + 2/5 s**5 + .....,
|
||||
* = 2s + s*R
|
||||
* We use a special Reme algorithm on [0,0.1716] to generate
|
||||
* a polynomial of degree 14 to approximate R The maximum error
|
||||
* of this polynomial approximation is bounded by 2**-58.45. In
|
||||
* other words,
|
||||
* 2 4 6 8 10 12 14
|
||||
* R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
|
||||
* (the values of Lg1 to Lg7 are listed in the program)
|
||||
* and
|
||||
* | 2 14 | -58.45
|
||||
* | Lg1*s +...+Lg7*s - R(z) | <= 2
|
||||
* | |
|
||||
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
|
||||
* In order to guarantee error in log below 1ulp, we compute log
|
||||
* by
|
||||
* log(1+f) = f - s*(f - R) (if f is not too large)
|
||||
* log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
|
||||
*
|
||||
* 3. Finally, log(x) = k + log(1+f).
|
||||
* = k+(f-(hfsq-(s*(hfsq+R))))
|
||||
*
|
||||
* Special cases:
|
||||
* log2(x) is NaN with signal if x < 0 (including -INF) ;
|
||||
* log2(+INF) is +INF; log(0) is -INF with signal;
|
||||
* log2(NaN) is that NaN with no signal.
|
||||
*
|
||||
* Constants:
|
||||
* The hexadecimal values are the intended ones for the following
|
||||
* constants. The decimal values may be used, provided that the
|
||||
* compiler will convert from decimal to binary accurately enough
|
||||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
static const double
|
||||
#else
|
||||
static double
|
||||
#endif
|
||||
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
|
||||
Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
|
||||
Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
|
||||
Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
|
||||
Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
|
||||
Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
|
||||
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
|
||||
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
#ifdef __STDC__
|
||||
static const double zero = 0.0;
|
||||
#else
|
||||
static double zero = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
double __log2(double x)
|
||||
#else
|
||||
double __log2(x)
|
||||
double x;
|
||||
#endif
|
||||
{
|
||||
double hfsq,f,s,z,R,w,t1,t2,dk;
|
||||
int32_t k,hx,i,j;
|
||||
u_int32_t lx;
|
||||
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
|
||||
k=0;
|
||||
if (hx < 0x00100000) { /* x < 2**-1022 */
|
||||
if (((hx&0x7fffffff)|lx)==0)
|
||||
return -two54/zero; /* log(+-0)=-inf */
|
||||
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
|
||||
k -= 54; x *= two54; /* subnormal number, scale up x */
|
||||
GET_HIGH_WORD(hx,x);
|
||||
}
|
||||
if (hx >= 0x7ff00000) return x+x;
|
||||
k += (hx>>20)-1023;
|
||||
hx &= 0x000fffff;
|
||||
i = (hx+0x95f64)&0x100000;
|
||||
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
|
||||
k += (i>>20);
|
||||
dk = (double) k;
|
||||
f = x-1.0;
|
||||
if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
|
||||
if(f==zero) return dk;
|
||||
R = f*f*(0.5-0.33333333333333333*f);
|
||||
return dk-(R-f);
|
||||
}
|
||||
s = f/(2.0+f);
|
||||
z = s*s;
|
||||
i = hx-0x6147a;
|
||||
w = z*z;
|
||||
j = 0x6b851-hx;
|
||||
t1= w*(Lg2+w*(Lg4+w*Lg6));
|
||||
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
|
||||
i |= j;
|
||||
R = t2+t1;
|
||||
if(i>0) {
|
||||
hfsq=0.5*f*f;
|
||||
return dk-((hfsq-(s*(hfsq+R)))-f);
|
||||
} else {
|
||||
return dk-((s*(f-R))-f);
|
||||
}
|
||||
}
|
90
sysdeps/libm-ieee754/s_log2f.c
Normal file
90
sysdeps/libm-ieee754/s_log2f.c
Normal file
@ -0,0 +1,90 @@
|
||||
/* e_logf.c -- float version of e_log.c.
|
||||
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
||||
* adapted for log2 by Ulrich Drepper <drepper@cygnus.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float
|
||||
#else
|
||||
static float
|
||||
#endif
|
||||
two25 = 3.355443200e+07, /* 0x4c000000 */
|
||||
Lg1 = 6.6666668653e-01, /* 3F2AAAAB */
|
||||
Lg2 = 4.0000000596e-01, /* 3ECCCCCD */
|
||||
Lg3 = 2.8571429849e-01, /* 3E924925 */
|
||||
Lg4 = 2.2222198546e-01, /* 3E638E29 */
|
||||
Lg5 = 1.8183572590e-01, /* 3E3A3325 */
|
||||
Lg6 = 1.5313838422e-01, /* 3E1CD04F */
|
||||
Lg7 = 1.4798198640e-01; /* 3E178897 */
|
||||
|
||||
#ifdef __STDC__
|
||||
static const float zero = 0.0;
|
||||
#else
|
||||
static float zero = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
float __log2f(float x)
|
||||
#else
|
||||
float __log2f(x)
|
||||
float x;
|
||||
#endif
|
||||
{
|
||||
float hfsq,f,s,z,R,w,t1,t2,dk;
|
||||
int32_t k,ix,i,j;
|
||||
|
||||
GET_FLOAT_WORD(ix,x);
|
||||
|
||||
k=0;
|
||||
if (ix < 0x00800000) { /* x < 2**-126 */
|
||||
if ((ix&0x7fffffff)==0)
|
||||
return -two25/zero; /* log(+-0)=-inf */
|
||||
if (ix<0) return (x-x)/zero; /* log(-#) = NaN */
|
||||
k -= 25; x *= two25; /* subnormal number, scale up x */
|
||||
GET_FLOAT_WORD(ix,x);
|
||||
}
|
||||
if (ix >= 0x7f800000) return x+x;
|
||||
k += (ix>>23)-127;
|
||||
ix &= 0x007fffff;
|
||||
i = (ix+(0x95f64<<3))&0x800000;
|
||||
SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */
|
||||
k += (i>>23);
|
||||
dk = (float)k;
|
||||
f = x-(float)1.0;
|
||||
if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */
|
||||
if(f==zero) return dk;
|
||||
R = f*f*((float)0.5-(float)0.33333333333333333*f);
|
||||
return dk-(R-f);}
|
||||
}
|
||||
s = f/((float)2.0+f);
|
||||
z = s*s;
|
||||
i = ix-(0x6147a<<3);
|
||||
w = z*z;
|
||||
j = (0x6b851<<3)-ix;
|
||||
t1= w*(Lg2+w*(Lg4+w*Lg6));
|
||||
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
|
||||
i |= j;
|
||||
R = t2+t1;
|
||||
if(i>0) {
|
||||
hfsq=(float)0.5*f*f;
|
||||
return dk-((hfsq-(s*(hfsq+R)))-f);
|
||||
} else {
|
||||
return dk-((s*(f-R))-f);
|
||||
}
|
||||
}
|
||||
weak_alias (__log2f, log2f)
|
@ -32,5 +32,5 @@ CFLAGS-setjmp.c := -fno-omit-frame-pointer
|
||||
long-double-fcts = yes
|
||||
|
||||
ifeq ($(subdir),elf)
|
||||
CFLAGS-rtld.c += -Wno-uninitialized
|
||||
CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
|
||||
endif
|
||||
|
@ -184,9 +184,16 @@ _dl_start_user:
|
||||
| Jump to the user's entry point.
|
||||
jmp (%a4)");
|
||||
|
||||
/* Nonzero iff TYPE describes a relocation that should
|
||||
skip the executable when looking up the symbol value. */
|
||||
#define elf_machine_lookup_noexec_p(type) ((type) == R_68K_COPY)
|
||||
|
||||
/* Nonzero iff TYPE describes relocation of a PLT entry, so
|
||||
PLT entries should not be allowed to define the value. */
|
||||
#define elf_machine_pltrel_p(type) ((type) == R_68K_JMP_SLOT)
|
||||
#define elf_machine_lookup_noplt_p(type) ((type) == R_68K_JMP_SLOT)
|
||||
|
||||
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
|
||||
#define ELF_MACHINE_RELOC_NOPLT R_68K_JMP_SLOT
|
||||
|
||||
/* The m68k never uses Elf32_Rel relocations. */
|
||||
#define ELF_MACHINE_NO_REL 1
|
||||
@ -203,54 +210,43 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||
const Elf32_Sym *sym, const struct r_found_version *version)
|
||||
{
|
||||
Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
|
||||
Elf32_Addr loadbase;
|
||||
|
||||
if (ELF32_R_TYPE (reloc->r_info) == R_68K_RELATIVE)
|
||||
*reloc_addr = map->l_addr + reloc->r_addend;
|
||||
else
|
||||
{
|
||||
Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
|
||||
if (sym)
|
||||
value += sym->st_value;
|
||||
|
||||
switch (ELF32_R_TYPE (reloc->r_info))
|
||||
{
|
||||
case R_68K_COPY:
|
||||
loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOEXEC);
|
||||
memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
|
||||
memcpy (reloc_addr, (void *) value, sym->st_size);
|
||||
break;
|
||||
case R_68K_GLOB_DAT:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*reloc_addr = sym ? (loadbase + sym->st_value) : 0;
|
||||
break;
|
||||
case R_68K_JMP_SLOT:
|
||||
loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOPLT);
|
||||
*reloc_addr = sym ? (loadbase + sym->st_value) : 0;
|
||||
*reloc_addr = value;
|
||||
break;
|
||||
case R_68K_8:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend);
|
||||
*(char *) reloc_addr = value + reloc->r_addend;
|
||||
break;
|
||||
case R_68K_16:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend);
|
||||
*(short *) reloc_addr = value + reloc->r_addend;
|
||||
break;
|
||||
case R_68K_32:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend);
|
||||
break;
|
||||
case R_68K_RELATIVE:
|
||||
*reloc_addr = map->l_addr + reloc->r_addend;
|
||||
*reloc_addr = value + reloc->r_addend;
|
||||
break;
|
||||
case R_68K_PC8:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend - (Elf32_Addr) reloc_addr);
|
||||
*(char *) reloc_addr
|
||||
= value + reloc->r_addend - (Elf32_Addr) reloc_addr;
|
||||
break;
|
||||
case R_68K_PC16:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend - (Elf32_Addr) reloc_addr);
|
||||
*(short *) reloc_addr
|
||||
= value + reloc->r_addend - (Elf32_Addr) reloc_addr;
|
||||
break;
|
||||
case R_68K_PC32:
|
||||
loadbase = RESOLVE (&sym, version, 0);
|
||||
*reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
|
||||
+ reloc->r_addend - (Elf32_Addr) reloc_addr);
|
||||
*reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
|
||||
break;
|
||||
case R_68K_NONE: /* Alright, Wilbur. */
|
||||
break;
|
||||
@ -259,6 +255,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc)
|
||||
|
@ -1,112 +0,0 @@
|
||||
/* Startup code compliant to the ELF SPARC ABI.
|
||||
Copyright (C) 1996, 1997 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. */
|
||||
|
||||
/* This is the canonical entry point, usually the first thing in the text
|
||||
segment. The SVR4/SPARC ABI (NOTE: I don't actually have it) says that
|
||||
when the entry point runs, most registers' values are unspecified,
|
||||
except for:
|
||||
|
||||
%g1 Contains a function pointer to be registered with `atexit'.
|
||||
This is how the dynamic linker arranges to have DT_FINI
|
||||
functions called for shared libraries that have been loaded
|
||||
before this code runs.
|
||||
|
||||
%sp The stack contains the arguments and environment:
|
||||
0(%sp) argc
|
||||
4(%sp) argv[0]
|
||||
...
|
||||
(4*argc)(%sp) NULL
|
||||
(4*(argc+1))(%sp) envp[0]
|
||||
...
|
||||
NULL
|
||||
*/
|
||||
|
||||
.text
|
||||
.align 16
|
||||
.global _start
|
||||
_start:
|
||||
/* %g1 contains the address of the shared library termination
|
||||
function, which we will register with `atexit' to be called by
|
||||
`exit'. I suspect that on some systems, and when statically
|
||||
linked, this will not be set by anything to any function
|
||||
pointer; hopefully it will be zero so we don't try to call
|
||||
random pointers. */
|
||||
orcc %g1, %g0, %o0 /* Move %g1 to %o0 while testing it. */
|
||||
be nofini
|
||||
|
||||
/* In delay slot: clear the frame pointer. The ABI suggests this
|
||||
be done, to mark the outermost frame obviously. */
|
||||
clr %fp
|
||||
|
||||
/* Call atexit, argument was set in %o0 above. */
|
||||
call atexit
|
||||
nop
|
||||
nofini:
|
||||
|
||||
/* We will use some local variables in registers below. %g1 and
|
||||
the %oN registers are call-clobbered, so we can't just use them. */
|
||||
#define ARGC %l0
|
||||
#define ARGV %l1
|
||||
#define ENVP %l2
|
||||
#define TMP %l3
|
||||
|
||||
/* Do essential libc initialization. In statically linked
|
||||
programs under the GNU Hurd, this is what sets up the
|
||||
arguments on the stack for the code below. */
|
||||
call __libc_init_first
|
||||
sethi %hi(_environ), TMP /* In delay slot: prepare to use &_environ. */
|
||||
|
||||
/* Extract the arguments and environment as encoded on the stack
|
||||
and save them in local variables. */
|
||||
ld [%sp + 64], ARGC /* After the register save area, ARGC. */
|
||||
add %sp, 64+4, ARGV /* Next, the ARGV elements. */
|
||||
/* After ARGC words that are the ARGV elements, and a zero word,
|
||||
are the ENVP elements. Do ENVP = &ARGV[ARGC + 1]. */
|
||||
add ARGC, 1, ENVP
|
||||
sll ENVP, 2, ENVP
|
||||
add ARGV, ENVP, ENVP
|
||||
/* Store ENVP in the global variable `_environ'. */
|
||||
ld [TMP + %lo(_environ)], ENVP
|
||||
|
||||
/* Call `_init', which is the entry point to our own `.init'
|
||||
section; and register with `atexit' to have `exit' call
|
||||
`_fini', which is the entry point to our own `.fini' section. */
|
||||
call _init
|
||||
sethi %hi(_fini), TMP /* In delay slot of call. */
|
||||
or TMP, %lo(_fini), %o0 /* Argument to atexit is &_fini. */
|
||||
call atexit
|
||||
nop
|
||||
|
||||
/* Call the user's main function, and exit with its value. */
|
||||
mov ARGC, %o0
|
||||
mov ARGV, %o1
|
||||
call main
|
||||
mov ENVP, %o2
|
||||
|
||||
call exit /* This should never return. */
|
||||
nop
|
||||
unimp 0 /* Crash if somehow it does return. */
|
||||
|
||||
/* Define a symbol for the first piece of initialized data. */
|
||||
.data
|
||||
.global __data_start
|
||||
__data_start:
|
||||
.long 0
|
||||
.weak data_start
|
||||
data_start = __data_start
|
11
sysdeps/stub/s_log2l.c
Normal file
11
sysdeps/stub/s_log2l.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
long double
|
||||
__log2l (long double x)
|
||||
{
|
||||
fputs ("__log2l not implemented\n", stderr);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
stub_warning (__log2l)
|
@ -112,10 +112,6 @@ struct termios
|
||||
#define VT1 00200000
|
||||
#define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */
|
||||
|
||||
/* On Linux there is no OXTABS bit defined. Take it as an alias for
|
||||
XTABS. */
|
||||
#define OXTABS XTABS
|
||||
|
||||
/* c_cflag bit meaning */
|
||||
#define CBAUD 0000037
|
||||
#define B0 0000000 /* hang up */
|
||||
|
@ -64,6 +64,37 @@ typedef struct
|
||||
sigset_t *__set = (set); \
|
||||
while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \
|
||||
0; }))
|
||||
|
||||
# ifdef _GNU_SOURCE
|
||||
/* The POSIX does not specify for handling the whole signal set in one
|
||||
command. This is often wanted and so we define three more functions
|
||||
here. */
|
||||
# define __sigisemptyset(set) \
|
||||
(__extension__ ({ int __cnt = _SIGSET_NWORDS; \
|
||||
const sigset_t *__set = (set); \
|
||||
int __ret = __set->__val[--__cnt]; \
|
||||
while (!__ret && --__cnt >= 0) \
|
||||
__ret = __set->__val[__cnt]; \
|
||||
__ret; }))
|
||||
# define __sigandset(dest, left, right) \
|
||||
(__extension__ ({ int __cnt = _SIGSET_NWORDS; \
|
||||
sigset_t *__dest = (dest); \
|
||||
const sigset_t *__left = (left); \
|
||||
const sigset_t *__right = (right); \
|
||||
while (--__cnt >= 0) \
|
||||
__dest->__val[__cnt] = (__left->__val[__cnt] \
|
||||
& __right->__val[__cnt]); \
|
||||
0; }))
|
||||
# define __sigorset(dest, left, right) \
|
||||
(__extension__ ({ int __cnt = _SIGSET_NWORDS; \
|
||||
sigset_t *__dest = (dest); \
|
||||
const sigset_t *__left = (left); \
|
||||
const sigset_t *__right = (right); \
|
||||
while (--__cnt >= 0) \
|
||||
__dest->__val[__cnt] = (__left->__val[__cnt] \
|
||||
| __right->__val[__cnt]); \
|
||||
0; }))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* These functions needn't check for a bogus signal number -- error
|
||||
|
@ -105,10 +105,6 @@ struct termios
|
||||
#define FF0 0000000
|
||||
#define FF1 0100000
|
||||
|
||||
/* On Linux there is no OXTABS bit defined. Take it as an alias for
|
||||
XTABS. */
|
||||
#define OXTABS XTABS
|
||||
|
||||
/* c_cflag bit meaning */
|
||||
#define CBAUD 0010017
|
||||
#define B0 0000000 /* hang up */
|
||||
|
@ -48,7 +48,15 @@
|
||||
* Defaults on "first" open.
|
||||
*/
|
||||
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
|
||||
#ifdef OXTABS
|
||||
# define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
|
||||
#else
|
||||
# if defined TAB3
|
||||
# define TTYDEF_OFLAG (OPOST | ONLCR | TAB3)
|
||||
# else
|
||||
# define TTYDEF_OFLAG (OPOST | ONLCR)
|
||||
# endif
|
||||
#endif
|
||||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
|
||||
#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
|
||||
#define TTYDEF_SPEED (B9600)
|
||||
|
@ -27,5 +27,11 @@
|
||||
#define MPN2FLOAT __mpn_construct_float
|
||||
#define FLOAT_HUGE_VAL HUGE_VALF
|
||||
#define USE_WIDE_CHAR 1
|
||||
#define SET_MANTISSA(flt, mant) \
|
||||
do { union ieee754_float u; \
|
||||
u.f = (flt); \
|
||||
u.ieee.mantissa = (mant) & 0x7fffff; \
|
||||
(flt) = u.f; \
|
||||
} while (0)
|
||||
|
||||
#include "../stdlib/strtod.c"
|
||||
|
@ -27,5 +27,12 @@
|
||||
#define MPN2FLOAT __mpn_construct_long_double
|
||||
#define FLOAT_HUGE_VAL HUGE_VALL
|
||||
#define USE_WIDE_CHAR 1
|
||||
#define SET_MANTISSA(flt, mant) \
|
||||
do { union ieee854_long_double u; \
|
||||
u.d = (flt); \
|
||||
u.ieee.mantissa0 = ((mant) >> 32) & 0x7fffffff; \
|
||||
u.ieee.mantissa1 = (mant) & 0xffffffff; \
|
||||
(flt) = u.d; \
|
||||
} while (0)
|
||||
|
||||
#include "../stdlib/strtod.c"
|
||||
|
Reference in New Issue
Block a user