aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-10-17 01:51:38 +0000
committerUlrich Drepper <drepper@redhat.com>1996-10-17 01:51:38 +0000
commit0d204b0a522b9fef2168e1808a0566c9209d0893 (patch)
tree70ea6e1aec8f2cc5ab9b53f4ef15f24a9503fd5a
parentb207ff4bd88564215ef7c68e61ec46aa4cb461c1 (diff)
downloadglibc-0d204b0a522b9fef2168e1808a0566c9209d0893.zip
glibc-0d204b0a522b9fef2168e1808a0566c9209d0893.tar.gz
glibc-0d204b0a522b9fef2168e1808a0566c9209d0893.tar.bz2
update from main archive 961016cvs/libc-961019cvs/libc-961018cvs/libc-961017
Thu Oct 17 01:55:34 1996 Ulrich Drepper <drepper@cygnus.com> * sunrpc/Makefile ($(objpfx)rpcsvc/%.h, $(objpfx)x%.c): Write output to $@T and move to $@ later since the new rpcgen will not overwrite existing files. * po/Makefile (libc.pot): Fix typo. Sun Oct 13 20:52:07 1996 Thorsten Kukuk <kukuk@weber.uni-paderborn.de> Update rpcgen program to TI-rpc code. * sunrpc/Makefile (rpcgen-objs): Add rpc_tblout.o and rpc_sample.o. (distribute): Add proto.h. * sunrpc/proto.h: New file. Prototypes for all the RPC functions. * sunrpc/rpc_clntout.c: Change to allow generation of ISO C code. * sunrpc/rpc_cout.c: Likewise. * sunrpc/rpc_hout.c: Likewise. * sunrpc/rpc_main.c: Likewise. * sunrpc/rpc_parse.c: Likewise. * sunrpc/rpc_parse.h: Likewise. * sunrpc/rpc_scan.c: Likewise. * sunrpc/rpc_scan.h: Likewise. * sunrpc/rpc_svcout.c: Likewise. * sunrpc/rpc_util.c: Likewise. * sunrpc/rpc_util.h: Likewise. * sunrpc/rpc_tblout.c: New file. * sunrpc/rpc_sample.c: Likewise. Thu Oct 17 00:26:20 1996 NIIBE Yutaka <gniibe@mri.co.jp> * sysdeps/unix/opendir.c: Add semicolon for consistency. Wed Oct 16 12:26:53 1996 Sven Verdoolaege <skimo@breughel.ufsia.ac.be> * locale/progams/localedef.c (main): Test with -1 to find out whether read failed. Wed Oct 16 14:54:59 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/i386/clone.S: Use JUMPTARGET and PSEUDO_END macro. Tue Oct 15 21:27:42 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/sigcontext.h: Removed. Tue Oct 15 15:52:29 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/clone.S: Add CALL_MCOUNT. * sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise. * sysdeps/unix/sysv/linux/m68k/sigreturn.S: Likewise. * sysdeps/unix/sysv/linux/m68k/socket.S: Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location): Likewise. * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise. Correct generation of system call. Tue Oct 15 15:13:16 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makerules (sysd-Makefile): Fix command so that it works in the subdirectories. (BUILD_CFLAGS): Change back using $(..) instead of $(common-objpfx), the latter fails in the toplevel directory when $(objdir) is relative. (common-objdir-compile): Run compiler in $(objdir). * sysdeps/posix/Makefile (mk-stdiolim): Likewise. Tue Oct 15 23:39:48 1996 Ulrich Drepper <drepper@cygnus.com> * string/string.h [__USE_SVID]: Add prototype for swab. * time/sys/time.h [__USE_BSD]: Add prototype for ualarm. Reported by Andreas Jaeger. The available nlist implementation is not generally usable. Especially on the currently supported ELF systems the nlist function comes with the libelf. * misc/Makefile (headers): Remove nlist.h. (routines): Remove nlist. * Makefile ($(objpfx)version-info.h): Include information about system the libc is built on in version-info.h file. * po/Makefile (distribute): Add header.pot. Tue Oct 15 16:34:15 1996 Andreas Jaeger <aj@arthur.pfalz.de> * sysdeps/unix/sysv/linux/sleep.c: Include file with prototype. * sysdeps/unix/sysv/linux/reboot.c: Likewise. * misc/error.c: Likewise. Tue Oct 15 22:41:27 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/syscalls.list: Add {get,set}resuid. Tue Oct 15 08:06:02 1996 Andreas Jaeger <aj@arthur.pfalz.de> * crypt/Makefiel (rpath-link): Extend search path to current directory. Fri Oct 11 09:18:06 1996 Sven Verdoolaege <skimo@breughel.ufsia.ac.be> * sysdeps/i386/i586/strlen.S: Correct handling of prolog for aligning pointer. Tue Oct 15 02:13:21 1996 Ulrich Drepper <drepper@cygnus.com> * stdio-common/vfprintf.c: Don't declare __flockfile as weak. * crypt/md5-crypt.c (md5_crypt_r): Add cast to prevent warning. Sun Oct 13 19:16:10 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/sysdep.h (POUND): Macro removed, replaced by `&'. (PSEUDO_END): Provide definition to use .size directive. (PSEUDO): Don't interpret negative return values less than -128 as syscall error. * sysdeps/unix/sysv/linux/m68k/syscall.S (syscall): Likewise. * sysdeps/m68k/bsd-_setjmp.S: Use PSEUDO_END macro to provide .size directive. * sysdeps/m68k/bsd-setjmp.S: Likewise. * sysdeps/unix/sysv/linux/m68k/clone.S: Likewise. * sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise. * sysdeps/unix/sysv/linux/m68k/sigreturn.S: Likewise. * sysdeps/unix/sysv/linux/m68k/socket.S: Likewise. * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep.S: Use PSEUDO_END instead of explicit .size directive. * libio/iogets.c: Warn when gets is used. cd * time/strptime.c: Recognize %s, %u, %g, and %G format.
-rw-r--r--ChangeLog134
-rw-r--r--FAQ12
-rw-r--r--MakeTAGS4
-rw-r--r--Makefile18
-rw-r--r--Makerules14
-rw-r--r--README4
-rw-r--r--locale/programs/localedef.c2
-rw-r--r--misc/Makefile4
-rw-r--r--misc/error.c2
-rw-r--r--po/Makefile2
-rw-r--r--po/libc.pot531
-rw-r--r--stdio-common/vfprintf.c1
-rw-r--r--string/string.h8
-rw-r--r--sunrpc/Makefile32
-rw-r--r--sunrpc/proto.h53
-rw-r--r--sunrpc/rpc_clntout.c179
-rw-r--r--sunrpc/rpc_cout.c660
-rw-r--r--sunrpc/rpc_hout.c320
-rw-r--r--sunrpc/rpc_main.c930
-rw-r--r--sunrpc/rpc_parse.c395
-rw-r--r--sunrpc/rpc_parse.h85
-rw-r--r--sunrpc/rpc_sample.c253
-rw-r--r--sunrpc/rpc_scan.c220
-rw-r--r--sunrpc/rpc_scan.h40
-rw-r--r--sunrpc/rpc_svcout.c848
-rw-r--r--sunrpc/rpc_tblout.c170
-rw-r--r--sunrpc/rpc_util.c283
-rw-r--r--sunrpc/rpc_util.h119
-rw-r--r--sysdeps/i386/i586/strlen.S10
-rw-r--r--sysdeps/m68k/bsd-_setjmp.S1
-rw-r--r--sysdeps/m68k/bsd-setjmp.S1
-rw-r--r--sysdeps/posix/Makefile6
-rw-r--r--sysdeps/unix/opendir.c2
-rw-r--r--sysdeps/unix/sysv/linux/i386/clone.S8
-rw-r--r--sysdeps/unix/sysv/linux/m68k/clone.S3
-rw-r--r--sysdeps/unix/sysv/linux/m68k/mmap.S2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/sigcontext.h31
-rw-r--r--sysdeps/unix/sysv/linux/m68k/sigreturn.S3
-rw-r--r--sysdeps/unix/sysv/linux/m68k/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/syscall.S20
-rw-r--r--sysdeps/unix/sysv/linux/m68k/sysdep.S9
-rw-r--r--sysdeps/unix/sysv/linux/m68k/sysdep.h28
-rw-r--r--sysdeps/unix/sysv/linux/reboot.c2
-rw-r--r--sysdeps/unix/sysv/linux/sleep.c1
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
-rw-r--r--time/sys/time.h9
46 files changed, 4169 insertions, 1294 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c8c938..f13faaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,133 @@
+Thu Oct 17 01:55:34 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sunrpc/Makefile ($(objpfx)rpcsvc/%.h, $(objpfx)x%.c): Write
+ output to $@T and move to $@ later since the new rpcgen will not
+ overwrite existing files.
+
+ * po/Makefile (libc.pot): Fix typo.
+
+Sun Oct 13 20:52:07 1996 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
+
+ Update rpcgen program to TI-rpc code.
+ * sunrpc/Makefile (rpcgen-objs): Add rpc_tblout.o and rpc_sample.o.
+ (distribute): Add proto.h.
+ * sunrpc/proto.h: New file. Prototypes for all the RPC functions.
+ * sunrpc/rpc_clntout.c: Change to allow generation of ISO C code.
+ * sunrpc/rpc_cout.c: Likewise.
+ * sunrpc/rpc_hout.c: Likewise.
+ * sunrpc/rpc_main.c: Likewise.
+ * sunrpc/rpc_parse.c: Likewise.
+ * sunrpc/rpc_parse.h: Likewise.
+ * sunrpc/rpc_scan.c: Likewise.
+ * sunrpc/rpc_scan.h: Likewise.
+ * sunrpc/rpc_svcout.c: Likewise.
+ * sunrpc/rpc_util.c: Likewise.
+ * sunrpc/rpc_util.h: Likewise.
+
+ * sunrpc/rpc_tblout.c: New file.
+ * sunrpc/rpc_sample.c: Likewise.
+
+Thu Oct 17 00:26:20 1996 NIIBE Yutaka <gniibe@mri.co.jp>
+
+ * sysdeps/unix/opendir.c: Add semicolon for consistency.
+
+Wed Oct 16 12:26:53 1996 Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
+
+ * locale/progams/localedef.c (main): Test with -1 to find out
+ whether read failed.
+
+Wed Oct 16 14:54:59 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/i386/clone.S: Use JUMPTARGET and
+ PSEUDO_END macro.
+
+Tue Oct 15 21:27:42 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/unix/sysv/linux/m68k/sigcontext.h: Removed.
+
+Tue Oct 15 15:52:29 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/unix/sysv/linux/m68k/clone.S: Add CALL_MCOUNT.
+ * sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sigreturn.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/socket.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location):
+ Likewise.
+ * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise.
+ Correct generation of system call.
+
+Tue Oct 15 15:13:16 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makerules (sysd-Makefile): Fix command so that it works in the
+ subdirectories.
+ (BUILD_CFLAGS): Change back using $(..) instead of
+ $(common-objpfx), the latter fails in the toplevel directory when
+ $(objdir) is relative.
+ (common-objdir-compile): Run compiler in $(objdir).
+ * sysdeps/posix/Makefile (mk-stdiolim): Likewise.
+
+Tue Oct 15 23:39:48 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * string/string.h [__USE_SVID]: Add prototype for swab.
+ * time/sys/time.h [__USE_BSD]: Add prototype for ualarm.
+ Reported by Andreas Jaeger.
+
+ The available nlist implementation is not generally usable.
+ Especially on the currently supported ELF systems the nlist
+ function comes with the libelf.
+ * misc/Makefile (headers): Remove nlist.h.
+ (routines): Remove nlist.
+
+ * Makefile ($(objpfx)version-info.h): Include information about
+ system the libc is built on in version-info.h file.
+
+ * po/Makefile (distribute): Add header.pot.
+
+Tue Oct 15 16:34:15 1996 Andreas Jaeger <aj@arthur.pfalz.de>
+
+ * sysdeps/unix/sysv/linux/sleep.c: Include file with prototype.
+ * sysdeps/unix/sysv/linux/reboot.c: Likewise.
+ * misc/error.c: Likewise.
+
+Tue Oct 15 22:41:27 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/syscalls.list: Add {get,set}resuid.
+
+Tue Oct 15 08:06:02 1996 Andreas Jaeger <aj@arthur.pfalz.de>
+
+ * crypt/Makefiel (rpath-link): Extend search path to current directory.
+
+Fri Oct 11 09:18:06 1996 Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
+
+ * sysdeps/i386/i586/strlen.S: Correct handling of prolog for
+ aligning pointer.
+
+Tue Oct 15 02:13:21 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * stdio-common/vfprintf.c: Don't declare __flockfile as weak.
+
+ * crypt/md5-crypt.c (md5_crypt_r): Add cast to prevent warning.
+
+Sun Oct 13 19:16:10 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/unix/sysv/linux/m68k/sysdep.h (POUND): Macro removed,
+ replaced by `&'.
+ (PSEUDO_END): Provide definition to use .size directive.
+ (PSEUDO): Don't interpret negative return values less than -128 as
+ syscall error.
+ * sysdeps/unix/sysv/linux/m68k/syscall.S (syscall): Likewise.
+
+ * sysdeps/m68k/bsd-_setjmp.S: Use PSEUDO_END macro to provide
+ .size directive.
+ * sysdeps/m68k/bsd-setjmp.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/mmap.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sigreturn.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/socket.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sysdep.S: Use PSEUDO_END instead of
+ explicit .size directive.
+
Sun Oct 13 22:52:56 1996 Ulrich Drepper <drepper@cygnus.com>
* shlib-versions: Add version number/name for ld.so.
@@ -8,7 +138,7 @@ Sun Oct 13 22:52:56 1996 Ulrich Drepper <drepper@cygnus.com>
Sat Oct 12 20:31:58 1996 Richard Henderson <rth@tamu.edu>
- * libio/iogets.c: Warn when gets used.
+ * libio/iogets.c: Warn when gets is used.
* stdio/gets.c: Strengthen the warning.
Sat Oct 12 23:10:43 1996 Ulrich Drepper <drepper@cygnus.com>
@@ -57,7 +187,7 @@ Sat Oct 12 23:10:43 1996 Ulrich Drepper <drepper@cygnus.com>
* po/fr.po: Update.
- * time/strptime.c: Recognize %s, %u, %g, and %G format.
+cd * time/strptime.c: Recognize %s, %u, %g, and %G format.
* posix/getopt.c: Add some more casts and initializations to
prevent warnings.
diff --git a/FAQ b/FAQ
index 5cf093e..a855028 100644
--- a/FAQ
+++ b/FAQ
@@ -456,7 +456,7 @@ change the `specs' file of your gcc. This file is normally found at
In this file you have to change a few things:
-- change `ld-linux.so.1' to `ld.so.1'
+- change `ld-linux.so.1' to `ld.so.1' (or to ld-linux.so.2, see below)
- remove all expression `%{...:-lgmon}'; there is no libgmon in glibc
@@ -517,6 +517,16 @@ example the gcc-2.7.2 specs file when GNU libc is installed at
-----------------------------------------------------------------------
+The above is currently correct for all systems but ix86/Linux.
+Because of compatibility issues on this platform the dynamic linker
+must have a different name: ld-linux.so.2. So you have to replace
+
+ %{!dynamic-linker:-dynamic-linker=/home/gnu/lib/ld.so.1}
+by
+ %{!dynamic-linker:-dynamic-linker=/home/gnu/lib/ld-linux.so.2}
+
+in the above example specs file.
+
Future versions of GCC will automatically provide the correct specs.
diff --git a/MakeTAGS b/MakeTAGS
index a11ff9b..da9cdd7 100644
--- a/MakeTAGS
+++ b/MakeTAGS
@@ -169,9 +169,9 @@ include $(common-objpfx)version.mk
# The following code requires GNU date.
$P/libc.pot: $(all-pot)
@rm -f $@.new
- disp='set `date -R`; echo $$6'; \
+ set `date -R`; disp="$$6"; \
sed -e 's/VERSION/$(version)/' \
- -e "s/DATE/`date +'%Y-%m-%d %I:%M'$$disp/" \
+ -e "s/DATE/`date +'%Y-%m-%d %H:%M'$$disp`/" \
po/header.pot > $@.new
$(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
mv -f $@.new $@
diff --git a/Makefile b/Makefile
index 9220372..65e54a1 100644
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,23 @@ $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
$(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
- (files="$(all-Banner-files)"; \
+ (case $(config-os) in \
+ linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
+ | $(CC) -E -P - | \
+ sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
+ if [ -z "$$version" ]; then \
+ if [ -r /proc/version ]; then \
+ version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
+ < /proc/version`; \
+ else \
+ version=`uname -r`; \
+ fi; \
+ fi; \
+ echo -n "\"Compiled on a Linux $$version system "; \
+ echo "on `date +%Y/%m/%d`.\\n\"" ;; \
+ *) ;; \
+ esac; \
+ files="$(all-Banner-files)"; \
if test -n "$$files"; then \
echo "\"Available extensions:"; \
sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
diff --git a/Makerules b/Makerules
index beb251f..3d4d4d2 100644
--- a/Makerules
+++ b/Makerules
@@ -104,13 +104,17 @@ $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
(echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \
for dir in $(config-sysdirs); do \
file=$$dir/Makefile; \
- if [ -f $(..)$$file ]; then \
+ case $$dir in \
+ /*) rel= ;; \
+ *) rel=$(..) ;; \
+ esac; \
+ if [ -f $$rel$$file ]; then \
case $$dir in \
/*) echo include "$$file" ;; \
*) echo include "\$$(..)$$file" ;; \
esac; \
else true; fi; \
- done; \
+ done; \
echo 'sysd-Makefile-done=t') > $@T
mv -f $@T $@
endif
@@ -758,12 +762,14 @@ cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \
endef
# Command to compile $< in $(common-objdir) using the native libraries.
+# We must cd to $(objdir) anyway so that $(..)config.h is valid.
define common-objdir-compile
-cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F)
+cd $(objpfx).; \
+$(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=$(..)%) -o $(..)$(@F)
endef
# We always want to use configuration definitions.
-BUILD_CFLAGS = -include $(common-objpfx)config.h
+BUILD_CFLAGS = -include $(..)config.h
# Support the GNU standard name for this target.
.PHONY: check
diff --git a/README b/README
index 305ffd2..7f8b4a2 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This directory contains the version 1.94 test release of the GNU C Library.
+This directory contains the version 1.96 test release of the GNU C Library.
Many bugs have been fixed since the last release.
Some bugs surely remain.
@@ -46,7 +46,7 @@ provides the Unix `crypt' function, plus some other entry points.
Because of the United States export restriction on DES implementations,
we are distributing this code separately from the rest of the C
library. There is an extra distribution tar file just for crypt; it is
-called `glibc-1.94-crypt.tar.gz'. You can just unpack the crypt
+called `glibc-1.96-crypt.tar.gz'. You can just unpack the crypt
distribution along with the rest of the C library and build; you can
also build the library without getting crypt. Users outside the USA
can get the crypt distribution via anonymous FTP from ftp.uni-c.dk
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 6d37a0e..fbcd04a 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -305,7 +305,7 @@ cannot `stat' locale file `%s'"),
{
long int n;
n = read (fd, read_ptr, left);
- if (n == 1)
+ if (n == -1)
error (5, errno, _("cannot read locale file `%s'"),
fname);
read_ptr += n;
diff --git a/misc/Makefile b/misc/Makefile
index 343cc3e..43b6bbd 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -24,7 +24,7 @@ subdir := misc
headers := sys/uio.h iovec.h sys/ioctl.h ioctls.h ioctl-types.h \
sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \
- ar.h a.out.h nlist.h stab.h stab.def sgtty.h \
+ ar.h a.out.h stab.h stab.def sgtty.h \
ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \
sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h\
sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \
@@ -44,7 +44,7 @@ routines := brk sbrk sstk ioctl \
swapon swapoff mktemp mkstemp \
ualarm usleep \
gtty stty \
- ptrace nlist \
+ ptrace \
fstab mntent mntent_r \
utimes \
truncate ftruncate \
diff --git a/misc/error.c b/misc/error.c
index 82de137..3d2777b 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -47,6 +47,8 @@ Cambridge, MA 02139, USA. */
void exit ();
#endif
+#include "error.h"
+
#ifndef _
#define _(String) String
#endif
diff --git a/po/Makefile b/po/Makefile
index 2b12628..b013cd9 100644
--- a/po/Makefile
+++ b/po/Makefile
@@ -47,7 +47,7 @@ mo-installed = $(localedir)/%/LC_MESSAGES/$(domainname).mo
install-others = $(LINGUAS:%=$(mo-installed))
# Files to distribute: all the source and compiled binary translation files.
-distribute = $(ALL_LINGUAS:=.po) $(ALL_LINGUAS:=.mo) libc.pot
+distribute = $(ALL_LINGUAS:=.po) $(ALL_LINGUAS:=.mo) libc.pot header.pot
include ../Rules
diff --git a/po/libc.pot b/po/libc.pot
index fe893ec..cd873a1 100644
--- a/po/libc.pot
+++ b/po/libc.pot
@@ -1,12 +1,12 @@
-# GNU libc message catalog of translations
+# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: libc 1.94\n"
-"POT-Creation-Date: 1996-09-08 3:45\n"
+"Project-Id-Version: libc 1.96\n"
+"POT-Creation-Date: 1996-10-17 03:22+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+DIST\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -14,16 +14,6 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
-#: sunrpc/rpc_main.c:80
-#, c-format
-msgid " %s [-c | -h | -l | -m] [-o outfile] [infile]\n"
-msgstr ""
-
-#: sunrpc/rpc_main.c:83
-#, c-format
-msgid " %s [-s udp|tcp]* [-o outfile] [infile]\n"
-msgstr ""
-
#: sunrpc/rpcinfo.c:612
msgid " rpcinfo -b prognum versnum\n"
msgstr ""
@@ -44,31 +34,31 @@ msgstr ""
msgid " program vers proto port\n"
msgstr ""
-#: time/zic.c:425
+#: time/zic.c:424
#, c-format
msgid " (rule from \"%s\", line %d)"
msgstr ""
-#: locale/programs/ld-collate.c:360 locale/programs/ld-ctype.c:1233
+#: locale/programs/ld-collate.c:360 locale/programs/ld-ctype.c:1234
msgid " done\n"
msgstr ""
-#: time/zic.c:422
+#: time/zic.c:421
#, c-format
msgid "\"%s\", line %d: %s"
msgstr ""
-#: time/zic.c:946
+#: time/zic.c:945
#, c-format
msgid "\"Zone %s\" line and -l option are mutually exclusive"
msgstr ""
-#: time/zic.c:954
+#: time/zic.c:953
#, c-format
msgid "\"Zone %s\" line and -p option are mutually exclusive"
msgstr ""
-#: time/zic.c:759
+#: time/zic.c:758
#, c-format
msgid "%s in ruleless zone"
msgstr ""
@@ -88,12 +78,7 @@ msgstr ""
msgid "%s%sUnknown signal %d\n"
msgstr ""
-#: sunrpc/rpc_util.c:258
-#, c-format
-msgid "%s, line %d: "
-msgstr ""
-
-#: time/zic.c:2140
+#: time/zic.c:2139
#, c-format
msgid "%s: %d did not sign extend correctly\n"
msgstr ""
@@ -103,37 +88,37 @@ msgstr ""
msgid "%s: <mb_cur_max> must be greater than <mb_cur_min>\n"
msgstr ""
-#: time/zic.c:1431
+#: time/zic.c:1430
#, c-format
msgid "%s: Can't create %s: %s\n"
msgstr ""
-#: time/zic.c:2119
+#: time/zic.c:2118
#, c-format
msgid "%s: Can't create directory %s: %s\n"
msgstr ""
-#: time/zic.c:613
+#: time/zic.c:612
#, c-format
msgid "%s: Can't link from %s to %s: %s\n"
msgstr ""
-#: time/zic.c:784
+#: time/zic.c:783
#, c-format
msgid "%s: Can't open %s: %s\n"
msgstr ""
-#: time/zic.c:852
+#: time/zic.c:851
#, c-format
msgid "%s: Error closing %s: %s\n"
msgstr ""
-#: time/zic.c:846
+#: time/zic.c:845
#, c-format
msgid "%s: Error reading %s\n"
msgstr ""
-#: time/zic.c:1495
+#: time/zic.c:1494
#, c-format
msgid "%s: Error writing %s\n"
msgstr ""
@@ -143,7 +128,7 @@ msgstr ""
msgid "%s: Error writing standard output "
msgstr ""
-#: time/zic.c:831
+#: time/zic.c:830
#, c-format
msgid "%s: Leap line in non leap seconds file %s\n"
msgstr ""
@@ -153,32 +138,32 @@ msgstr ""
msgid "%s: Memory exhausted: %s\n"
msgstr ""
-#: time/zic.c:528
+#: time/zic.c:527
#, c-format
msgid "%s: More than one -L option specified\n"
msgstr ""
-#: time/zic.c:488
+#: time/zic.c:487
#, c-format
msgid "%s: More than one -d option specified\n"
msgstr ""
-#: time/zic.c:498
+#: time/zic.c:497
#, c-format
msgid "%s: More than one -l option specified\n"
msgstr ""
-#: time/zic.c:508
+#: time/zic.c:507
#, c-format
msgid "%s: More than one -p option specified\n"
msgstr ""
-#: time/zic.c:518
+#: time/zic.c:517
#, c-format
msgid "%s: More than one -y option specified\n"
msgstr ""
-#: time/zic.c:1846
+#: time/zic.c:1845
#, c-format
msgid "%s: command was '%s', result was %d\n"
msgstr ""
@@ -188,72 +173,72 @@ msgstr ""
msgid "%s: error in state machine"
msgstr ""
-#: posix/getopt.c:686
+#: posix/getopt.c:687
#, c-format
msgid "%s: illegal option -- %c\n"
msgstr ""
-#: posix/getopt.c:689
+#: posix/getopt.c:690
#, c-format
msgid "%s: invalid option -- %c\n"
msgstr ""
-#: posix/getopt.c:610
+#: posix/getopt.c:611
#, c-format
msgid "%s: option `%c%s' doesn't allow an argument\n"
msgstr ""
-#: posix/getopt.c:581
+#: posix/getopt.c:582
#, c-format
msgid "%s: option `%s' is ambiguous\n"
msgstr ""
-#: posix/getopt.c:627
+#: posix/getopt.c:628 posix/getopt.c:801
#, c-format
msgid "%s: option `%s' requires an argument\n"
msgstr ""
-#: posix/getopt.c:605
+#: posix/getopt.c:606
#, c-format
msgid "%s: option `--%s' doesn't allow an argument\n"
msgstr ""
-#: posix/getopt.c:725
+#: posix/getopt.c:786
#, c-format
-msgid "%s: option requires an argument -- %c\n"
+msgid "%s: option `-W %s' doesn't allow an argument\n"
msgstr ""
-#: sunrpc/rpc_main.c:146
+#: posix/getopt.c:767
#, c-format
-msgid "%s: output would overwrite %s\n"
+msgid "%s: option `-W %s' is ambiguous\n"
msgstr ""
-#: time/zic.c:838 time/zic.c:1249 time/zic.c:1269
+#: posix/getopt.c:721 posix/getopt.c:850
#, c-format
-msgid "%s: panic: Invalid l_value %d\n"
+msgid "%s: option requires an argument -- %c\n"
msgstr ""
-#: locale/programs/charmap.c:600
+#: time/zic.c:837 time/zic.c:1248 time/zic.c:1268
#, c-format
-msgid "%s: premature end of file"
+msgid "%s: panic: Invalid l_value %d\n"
msgstr ""
-#: sunrpc/rpc_main.c:152
+#: locale/programs/charmap.c:600
#, c-format
-msgid "%s: unable to open "
+msgid "%s: premature end of file"
msgstr ""
-#: posix/getopt.c:660
+#: posix/getopt.c:661
#, c-format
msgid "%s: unrecognized option `%c%s'\n"
msgstr ""
-#: posix/getopt.c:656
+#: posix/getopt.c:657
#, c-format
msgid "%s: unrecognized option `--%s'\n"
msgstr ""
-#: time/zic.c:447
+#: time/zic.c:446
#, c-format
msgid ""
"%s: usage is %s [ -s ] [ -v ] [ -l localtime ] [ -p posixrules ] [ -d "
@@ -275,7 +260,7 @@ msgstr ""
msgid "(unknown)"
msgstr ""
-#: catgets/gencat.c:244
+#: catgets/gencat.c:253
msgid "*standard input*"
msgstr ""
@@ -283,19 +268,19 @@ msgstr ""
msgid ".lib section in a.out corrupted"
msgstr ""
-#: inet/rcmd.c:325
+#: inet/rcmd.c:328
msgid ".rhosts fstat failed"
msgstr ""
-#: inet/rcmd.c:321
+#: inet/rcmd.c:324
msgid ".rhosts lstat failed"
msgstr ""
-#: inet/rcmd.c:323
+#: inet/rcmd.c:326
msgid ".rhosts not regular file"
msgstr ""
-#: inet/rcmd.c:329
+#: inet/rcmd.c:332
msgid ".rhosts writeable by other than owner"
msgstr ""
@@ -308,12 +293,12 @@ msgstr ""
msgid "; why = "
msgstr ""
-#: locale/programs/ld-ctype.c:325
+#: locale/programs/ld-ctype.c:326
#, c-format
msgid "<SP> character must not be in class `%s'"
msgstr ""
-#: locale/programs/ld-ctype.c:316
+#: locale/programs/ld-ctype.c:317
#, c-format
msgid "<SP> character not in class `%s'"
msgstr ""
@@ -392,7 +377,7 @@ msgstr ""
msgid "Block device required"
msgstr ""
-#: sunrpc/pmap_rmt.c:335
+#: sunrpc/pmap_rmt.c:337
msgid "Broadcast select problem"
msgstr ""
@@ -428,7 +413,7 @@ msgstr ""
msgid "Cannot assign requested address"
msgstr ""
-#: sunrpc/pmap_rmt.c:253
+#: sunrpc/pmap_rmt.c:255
msgid "Cannot create socket for broadcast rpc"
msgstr ""
@@ -436,7 +421,7 @@ msgstr ""
msgid "Cannot exec a shared library directly"
msgstr ""
-#: sunrpc/pmap_rmt.c:347
+#: sunrpc/pmap_rmt.c:349
msgid "Cannot receive reply to broadcast"
msgstr ""
@@ -449,11 +434,11 @@ msgstr ""
msgid "Cannot send after transport endpoint shutdown"
msgstr ""
-#: sunrpc/pmap_rmt.c:311
+#: sunrpc/pmap_rmt.c:313
msgid "Cannot send broadcast packet"
msgstr ""
-#: sunrpc/pmap_rmt.c:259
+#: sunrpc/pmap_rmt.c:261
msgid "Cannot set socket option SO_BROADCAST"
msgstr ""
@@ -477,7 +462,7 @@ msgstr ""
msgid "Computer bought the farm"
msgstr ""
-#: locale/programs/ld-ctype.c:1196
+#: locale/programs/ld-ctype.c:1197
msgid "Computing table size for character classes might take a while..."
msgstr ""
@@ -507,6 +492,15 @@ msgstr ""
msgid "Continued"
msgstr ""
+#: catgets/gencat.c:169 db/makedb.c:120 locale/programs/locale.c:187
+#: locale/programs/localedef.c:177
+#, c-format
+msgid ""
+"Copyright (C) %s Free Software Foundation, Inc.\n"
+"This is free software; see the source for copying conditions. There is NO\n"
+"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+msgstr ""
+
#. TRANS No default destination address was set for the socket. You get this
#. TRANS error when you try to transmit data over a connectionless socket,
#. TRANS without first specifying a destination for the data with @code{connect}.
@@ -554,7 +548,7 @@ msgstr ""
msgid "Error in unknown error system: "
msgstr ""
-#: inet/ruserpass.c:156
+#: inet/ruserpass.c:161
msgid "Error: .netrc file is readable by others."
msgstr ""
@@ -568,7 +562,7 @@ msgstr ""
msgid "Exec format error"
msgstr ""
-#: locale/programs/localedef.c:207
+#: locale/programs/localedef.c:213
msgid "FATAL: system does not define `_POSIX2_LOCALEDEF'"
msgstr ""
@@ -903,7 +897,7 @@ msgstr ""
msgid "No message of desired type"
msgstr ""
-#: posix/regex.c:5202
+#: posix/regex.c:5204
msgid "No previous regular expression"
msgstr ""
@@ -967,7 +961,7 @@ msgstr ""
msgid "Object is remote"
msgstr ""
-#: time/zic.c:1940
+#: time/zic.c:1939
msgid "Odd number of quotation marks"
msgstr ""
@@ -1199,10 +1193,15 @@ msgstr ""
msgid "Remote address changed"
msgstr ""
-#: inet/ruserpass.c:157
+#: inet/ruserpass.c:162
msgid "Remove password or make file unreadable by others."
msgstr ""
+#: catgets/gencat.c:224 db/makedb.c:227 locale/programs/locale.c:257
+#: locale/programs/localedef.c:408
+msgid "Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"
+msgstr ""
+
#: resolv/herror.c:73
msgid "Resolver Error 0 (no error)"
msgstr ""
@@ -1407,18 +1406,18 @@ msgstr ""
msgid "Transport endpoint is not connected"
msgstr ""
-#: catgets/gencat.c:202 db/makedb.c:197 locale/programs/locale.c:234
-#: locale/programs/localedef.c:383
+#: catgets/gencat.c:208 db/makedb.c:209 locale/programs/locale.c:241
+#: locale/programs/localedef.c:389
#, c-format
msgid "Try `%s --help' for more information.\n"
msgstr ""
-#: inet/rcmd.c:118
+#: inet/rcmd.c:121
#, c-format
msgid "Trying %s...\n"
msgstr ""
-#: inet/ruserpass.c:241
+#: inet/ruserpass.c:246
#, c-format
msgid "Unknown .netrc keyword %s"
msgstr ""
@@ -1445,7 +1444,7 @@ msgstr ""
msgid "Unknown signal %d"
msgstr ""
-#: misc/error.c:92
+#: misc/error.c:94
msgid "Unknown system error"
msgstr ""
@@ -1465,7 +1464,7 @@ msgstr ""
msgid "Unmatched \\{"
msgstr ""
-#: posix/getconf.c:184
+#: posix/getconf.c:191
#, c-format
msgid "Unrecognized variable `%s'"
msgstr ""
@@ -1473,7 +1472,7 @@ msgstr ""
msgid "Urgent I/O condition"
msgstr ""
-#: catgets/gencat.c:205
+#: catgets/gencat.c:212
#, c-format
msgid ""
"Usage: %s [OPTION]... -o OUTPUT-FILE [INPUT-FILE]...\n"
@@ -1486,10 +1485,9 @@ msgid ""
" -V, --version output version information and exit\n"
"If INPUT-FILE is -, input is read from standard input. If OUTPUT-FILE\n"
"is -, output is written to standard output.\n"
-"Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"
msgstr ""
-#: db/makedb.c:200
+#: db/makedb.c:213
#, c-format
msgid ""
"Usage: %s [OPTION]... INPUT-FILE OUTPUT-FILE\n"
@@ -1503,10 +1501,9 @@ msgid ""
" -u, --undo print content of database file, one entry a line\n"
" -V, --version output version information and exit\n"
"If INPUT-FILE is -, input is read from standard input.\n"
-"Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"
msgstr ""
-#: locale/programs/localedef.c:386
+#: locale/programs/localedef.c:393
#, c-format
msgid ""
"Usage: %s [OPTION]... name\n"
@@ -1523,10 +1520,9 @@ msgid ""
"\n"
"System's directory for character maps: %s\n"
" locale files : %s\n"
-"Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"
msgstr ""
-#: locale/programs/locale.c:237
+#: locale/programs/locale.c:245
#, c-format
msgid ""
"Usage: %s [OPTION]... name\n"
@@ -1539,10 +1535,9 @@ msgid ""
"\n"
" -c, --category-name write names of selected categories\n"
" -k, --keyword-name write names of selected keywords\n"
-"Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"
msgstr ""
-#: posix/getconf.c:131
+#: posix/getconf.c:138
#, c-format
msgid "Usage: %s variable_name [pathname]\n"
msgstr ""
@@ -1564,19 +1559,25 @@ msgstr ""
msgid "Virtual timer expired"
msgstr ""
-#: time/zic.c:1845
+#: time/zic.c:1844
msgid "Wild result from command execution"
msgstr ""
msgid "Window changed"
msgstr ""
+#: catgets/gencat.c:174 db/makedb.c:125 locale/programs/locale.c:192
+#: locale/programs/localedef.c:182
+#, c-format
+msgid "Written by %s.\n"
+msgstr ""
+
#. TRANS You did @strong{what}?
#: stdio-common/../sysdeps/gnu/errlist.c:596
msgid "You really blew it this time"
msgstr ""
-#: time/zic.c:1051
+#: time/zic.c:1050
msgid "Zone continuation line end time is not after end time of previous line"
msgstr ""
@@ -1613,15 +1614,11 @@ msgstr ""
msgid "argument to `%s' must be a single character"
msgstr ""
-#: sunrpc/rpc_parse.c:326
-msgid "array declaration expected"
-msgstr ""
-
-#: sunrpc/auth_unix.c:314
+#: sunrpc/auth_unix.c:322
msgid "auth_none.c - Fatal marshalling problem"
msgstr ""
-#: inet/rcmd.c:327
+#: inet/rcmd.c:330
msgid "bad .rhosts owner"
msgstr ""
@@ -1629,11 +1626,11 @@ msgstr ""
msgid "bad argument"
msgstr ""
-#: time/zic.c:1173
+#: time/zic.c:1172
msgid "blank FROM field on Link line"
msgstr ""
-#: time/zic.c:1177
+#: time/zic.c:1176
msgid "blank TO field on Link line"
msgstr ""
@@ -1645,19 +1642,19 @@ msgstr ""
msgid "bogus mcheck_status, library is buggy"
msgstr ""
-#: sunrpc/pmap_rmt.c:177
+#: sunrpc/pmap_rmt.c:179
msgid "broadcast: ioctl (get interface configuration)"
msgstr ""
-#: sunrpc/pmap_rmt.c:184
+#: sunrpc/pmap_rmt.c:186
msgid "broadcast: ioctl (get interface flags)"
msgstr ""
-#: sunrpc/svc_udp.c:398
+#: sunrpc/svc_udp.c:402
msgid "cache_set: victim not found"
msgstr ""
-#: time/zic.c:1686
+#: time/zic.c:1685
msgid "can't determine time zone abbrevation to use just after until time"
msgstr ""
@@ -1666,7 +1663,7 @@ msgstr ""
msgid "can't reassign procedure number %d\n"
msgstr ""
-#: locale/programs/localedef.c:281
+#: locale/programs/localedef.c:287
#, c-format
msgid "cannot `stat' locale file `%s'"
msgstr ""
@@ -1685,22 +1682,22 @@ msgstr ""
msgid "cannot insert new collating symbol definition: %s"
msgstr ""
-#: db/makedb.c:149
+#: db/makedb.c:161
#, c-format
msgid "cannot open database file `%s': %s"
msgstr ""
-#: catgets/gencat.c:250 db/makedb.c:168
+#: catgets/gencat.c:259 db/makedb.c:180
#, c-format
msgid "cannot open input file `%s'"
msgstr ""
-#: locale/programs/localedef.c:215
+#: locale/programs/localedef.c:221
#, c-format
msgid "cannot open locale definition file `%s'"
msgstr ""
-#: catgets/gencat.c:755 catgets/gencat.c:796 db/makedb.c:177
+#: catgets/gencat.c:764 catgets/gencat.c:805 db/makedb.c:189
#, c-format
msgid "cannot open output file `%s'"
msgstr ""
@@ -1714,65 +1711,65 @@ msgstr ""
msgid "cannot process order specification"
msgstr ""
-#: locale/programs/locale.c:293
+#: locale/programs/locale.c:303
#, c-format
msgid "cannot read character map directory `%s'"
msgstr ""
-#: locale/programs/locale.c:268
+#: locale/programs/locale.c:278
#, c-format
msgid "cannot read locale directory `%s'"
msgstr ""
-#: locale/programs/localedef.c:303
+#: locale/programs/localedef.c:309
#, c-format
msgid "cannot read locale file `%s'"
msgstr ""
-#: locale/programs/localedef.c:328
+#: locale/programs/localedef.c:334
#, c-format
msgid "cannot write output files to `%s'"
msgstr ""
-#: locale/programs/localedef.c:371
+#: locale/programs/localedef.c:377
msgid "category data requested more than once: should not happen"
msgstr ""
-#: locale/programs/ld-ctype.c:264
+#: locale/programs/ld-ctype.c:265
#, c-format
msgid "character %s'%s' in class `%s' must be in class `%s'"
msgstr ""
-#: locale/programs/ld-ctype.c:288
+#: locale/programs/ld-ctype.c:289
#, c-format
msgid "character %s'%s' in class `%s' must not be in class `%s'"
msgstr ""
-#: locale/programs/ld-ctype.c:309
+#: locale/programs/ld-ctype.c:310
msgid "character <SP> not defined in character map"
msgstr ""
-#: locale/programs/ld-ctype.c:1140
+#: locale/programs/ld-ctype.c:1141
#, c-format
msgid "character `%c' not defined while needed as default value"
msgstr ""
-#: locale/programs/ld-ctype.c:938 locale/programs/ld-ctype.c:1001
-#: locale/programs/ld-ctype.c:1009 locale/programs/ld-ctype.c:1017
-#: locale/programs/ld-ctype.c:1025 locale/programs/ld-ctype.c:1033
-#: locale/programs/ld-ctype.c:1041 locale/programs/ld-ctype.c:1067
-#: locale/programs/ld-ctype.c:1075 locale/programs/ld-ctype.c:1113
-#: locale/programs/ld-ctype.c:1151
+#: locale/programs/ld-ctype.c:939 locale/programs/ld-ctype.c:1002
+#: locale/programs/ld-ctype.c:1010 locale/programs/ld-ctype.c:1018
+#: locale/programs/ld-ctype.c:1026 locale/programs/ld-ctype.c:1034
+#: locale/programs/ld-ctype.c:1042 locale/programs/ld-ctype.c:1068
+#: locale/programs/ld-ctype.c:1076 locale/programs/ld-ctype.c:1114
+#: locale/programs/ld-ctype.c:1152
#, c-format
msgid "character `%s' not defined while needed as default value"
msgstr ""
-#: locale/programs/ld-ctype.c:800
+#: locale/programs/ld-ctype.c:801
#, c-format
msgid "character class `%s' already defined"
msgstr ""
-#: locale/programs/ld-ctype.c:832
+#: locale/programs/ld-ctype.c:833
#, c-format
msgid "character map `%s' already defined"
msgstr ""
@@ -1800,15 +1797,11 @@ msgstr ""
msgid "collation symbol expected after `%s'"
msgstr ""
-#: inet/rcmd.c:112
+#: inet/rcmd.c:114
#, c-format
msgid "connect to address %s: "
msgstr ""
-#: sunrpc/rpc_scan.c:109
-msgid "constant or identifier expected"
-msgstr ""
-
#: sunrpc/svc_simple.c:70
msgid "couldn't create an rpc server\n"
msgstr ""
@@ -1831,8 +1824,18 @@ msgstr ""
msgid "default character map file `%s' not found"
msgstr ""
-#: sunrpc/rpc_parse.c:77
-msgid "definition keyword expected"
+#: locale/programs/ld-time.c:154
+#, c-format
+msgid ""
+"direction flag in string %d in `era' field in category `%s' is not '+' nor "
+"'-'"
+msgstr ""
+
+#: locale/programs/ld-time.c:164
+#, c-format
+msgid ""
+"direction flag in string %d in `era' field in category `%s' is not a single "
+"character"
msgstr ""
#: locale/programs/charset.c:87 locale/programs/charset.c:132
@@ -1849,24 +1852,24 @@ msgstr ""
msgid "duplicate definition for character `%.*s'"
msgstr ""
-#: db/makedb.c:295
+#: db/makedb.c:310
msgid "duplicate key"
msgstr ""
-#: catgets/gencat.c:369
+#: catgets/gencat.c:378
msgid "duplicate set definition"
msgstr ""
-#: time/zic.c:966
+#: time/zic.c:965
#, c-format
msgid "duplicate zone name %s (file \"%s\", line %d)"
msgstr ""
-#: catgets/gencat.c:532
+#: catgets/gencat.c:541
msgid "duplicated message identifier"
msgstr ""
-#: catgets/gencat.c:505
+#: catgets/gencat.c:514
msgid "duplicated message number"
msgstr ""
@@ -1874,19 +1877,19 @@ msgstr ""
msgid "empty weight name: line ignored"
msgstr ""
-#: sunrpc/svc_udp.c:344
+#: sunrpc/svc_udp.c:348
msgid "enablecache: cache already enabled"
msgstr ""
-#: sunrpc/svc_udp.c:349
+#: sunrpc/svc_udp.c:353
msgid "enablecache: could not allocate cache"
msgstr ""
-#: sunrpc/svc_udp.c:356
+#: sunrpc/svc_udp.c:360
msgid "enablecache: could not allocate cache data"
msgstr ""
-#: sunrpc/svc_udp.c:362
+#: sunrpc/svc_udp.c:366
msgid "enablecache: could not allocate cache fifo"
msgstr ""
@@ -1906,29 +1909,10 @@ msgstr ""
msgid "expect string argument for `copy'"
msgstr ""
-#: sunrpc/rpc_util.c:300
-#, c-format
-msgid "expected '%s'"
-msgstr ""
-
-#: sunrpc/rpc_util.c:312
-#, c-format
-msgid "expected '%s' or '%s'"
-msgstr ""
-
-#: sunrpc/rpc_util.c:325
-#, c-format
-msgid "expected '%s', '%s' or '%s'"
-msgstr ""
-
-#: time/zic.c:857
+#: time/zic.c:856
msgid "expected continuation line not found"
msgstr ""
-#: sunrpc/rpc_parse.c:384
-msgid "expected type specifier"
-msgstr ""
-
#: locale/programs/locfile.c:1010
#, c-format
msgid "failure while writing data for category `%s'"
@@ -1956,15 +1940,33 @@ msgstr ""
msgid "garbage at end of digit"
msgstr ""
+#: locale/programs/ld-time.c:183
+#, c-format
+msgid ""
+"garbage at end of offset value in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: locale/programs/ld-time.c:238
+#, c-format
+msgid ""
+"garbage at end of starting date in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: locale/programs/ld-time.c:310
+#, c-format
+msgid ""
+"garbage at end of stopping date in string %d in `era' field in category `%s'"
+msgstr ""
+
#: sunrpc/get_myaddr.c:73
msgid "get_myaddress: ioctl (get interface configuration)"
msgstr ""
-#: time/zic.c:1150
+#: time/zic.c:1149
msgid "illegal CORRECTION field on Leap line"
msgstr ""
-#: time/zic.c:1154
+#: time/zic.c:1153
msgid "illegal Rolling/Stationary field on Leap line"
msgstr ""
@@ -1972,10 +1974,6 @@ msgstr ""
msgid "illegal character constant in string"
msgstr ""
-#: sunrpc/rpc_scan.c:281
-msgid "illegal character in file: "
-msgstr ""
-
#: locale/programs/ld-collate.c:1115
msgid "illegal collation element"
msgstr ""
@@ -1996,86 +1994,97 @@ msgstr ""
msgid "illegal names for character range"
msgstr ""
-#: sunrpc/rpc_parse.c:146
-msgid "illegal result type"
+#: locale/programs/ld-time.c:176
+#, c-format
+msgid "illegal number for offset in string %d in `era' field in category `%s'"
msgstr ""
-#: catgets/gencat.c:342 catgets/gencat.c:419
+#: catgets/gencat.c:351 catgets/gencat.c:428
msgid "illegal set number"
msgstr ""
-#: locale/programs/ld-ctype.c:806
+#: locale/programs/ld-time.c:230
+#, c-format
+msgid "illegal starting date in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: locale/programs/ld-time.c:302
+#, c-format
+msgid "illegal stopping date in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: locale/programs/ld-ctype.c:807
#, c-format
msgid "implementation limit: no more than %d character classes allowed"
msgstr ""
-#: locale/programs/ld-ctype.c:838
+#: locale/programs/ld-ctype.c:839
#, c-format
msgid "implementation limit: no more than %d character maps allowed"
msgstr ""
-#: db/makedb.c:151
+#: db/makedb.c:163
msgid "incorrectly formatted file"
msgstr ""
-#: time/zic.c:815
+#: time/zic.c:814
msgid "input line of unknown type"
msgstr ""
-#: time/zic.c:1734
+#: time/zic.c:1733
msgid "internal error - addtype called with bad isdst"
msgstr ""
-#: time/zic.c:1742
+#: time/zic.c:1741
msgid "internal error - addtype called with bad ttisgmt"
msgstr ""
-#: time/zic.c:1738
+#: time/zic.c:1737
msgid "internal error - addtype called with bad ttisstd"
msgstr ""
-#: locale/programs/ld-ctype.c:300
+#: locale/programs/ld-ctype.c:301
#, c-format
msgid "internal error in %s, line %u"
msgstr ""
-#: time/zic.c:1022
+#: time/zic.c:1021
msgid "invalid GMT offset"
msgstr ""
-#: time/zic.c:1025
+#: time/zic.c:1024
msgid "invalid abbreviation format"
msgstr ""
-#: time/zic.c:1115 time/zic.c:1314 time/zic.c:1328
+#: time/zic.c:1114 time/zic.c:1313 time/zic.c:1327
msgid "invalid day of month"
msgstr ""
-#: time/zic.c:1273
+#: time/zic.c:1272
msgid "invalid ending year"
msgstr ""
-#: time/zic.c:1087
+#: time/zic.c:1086
msgid "invalid leaping year"
msgstr ""
-#: time/zic.c:1102 time/zic.c:1205
+#: time/zic.c:1101 time/zic.c:1204
msgid "invalid month name"
msgstr ""
-#: time/zic.c:921
+#: time/zic.c:920
msgid "invalid saved time"
msgstr ""
-#: time/zic.c:1253
+#: time/zic.c:1252
msgid "invalid starting year"
msgstr ""
-#: time/zic.c:1131 time/zic.c:1233
+#: time/zic.c:1130 time/zic.c:1232
msgid "invalid time of day"
msgstr ""
-#: time/zic.c:1319
+#: time/zic.c:1318
msgid "invalid weekday name"
msgstr ""
@@ -2087,16 +2096,16 @@ msgstr ""
msgid "line before ellipsis does not contain definition for character constant"
msgstr ""
-#: time/zic.c:795
+#: time/zic.c:794
msgid "line too long"
msgstr ""
-#: locale/programs/localedef.c:275
+#: locale/programs/localedef.c:281
#, c-format
msgid "locale file `%s', used in `copy' statement, not found"
msgstr ""
-#: catgets/gencat.c:600
+#: catgets/gencat.c:609
msgid "malformed line ignored"
msgstr ""
@@ -2111,7 +2120,7 @@ msgstr ""
#: locale/programs/ld-collate.c:167 locale/programs/ld-collate.c:173
#: locale/programs/ld-collate.c:177 locale/programs/ld-collate.c:1438
#: locale/programs/ld-collate.c:1467 locale/programs/locfile.c:940
-#: locale/programs/xmalloc.c:64 posix/getconf.c:174
+#: locale/programs/xmalloc.c:68 posix/getconf.c:181
msgid "memory exhausted"
msgstr ""
@@ -2119,7 +2128,17 @@ msgstr ""
msgid "memory is consistent, library is buggy"
msgstr ""
-#: time/zic.c:916
+#: locale/programs/ld-time.c:348
+#, c-format
+msgid "missing era format in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: locale/programs/ld-time.c:337
+#, c-format
+msgid "missing era name in string %d in `era' fieldin category `%s'"
+msgstr ""
+
+#: time/zic.c:915
msgid "nameless rule"
msgstr ""
@@ -2128,16 +2147,12 @@ msgstr ""
msgid "never registered prog %d\n"
msgstr ""
-#: sunrpc/rpc_parse.c:305 sunrpc/rpc_parse.c:313
-msgid "no array-of-pointer declarations -- use typedef"
-msgstr ""
-
#: locale/programs/ld-messages.c:95 locale/programs/ld-messages.c:116
#, c-format
msgid "no correct regular expression for field `%s' in category `%s': %s"
msgstr ""
-#: time/zic.c:2060
+#: time/zic.c:2059
msgid "no day in month matches rule"
msgstr ""
@@ -2149,7 +2164,7 @@ msgstr ""
msgid "no other keyword shall be specified when `copy' is used"
msgstr ""
-#: locale/programs/localedef.c:334
+#: locale/programs/localedef.c:340
msgid "no output file produced because warning were issued"
msgstr ""
@@ -2184,11 +2199,7 @@ msgstr ""
msgid "portmap cannot create socket"
msgstr ""
-#: sunrpc/rpc_scan.c:456 sunrpc/rpc_scan.c:464
-msgid "preprocessor error"
-msgstr ""
-
-#: db/makedb.c:311
+#: db/makedb.c:326
#, c-format
msgid "problems while reading `%s'"
msgstr ""
@@ -2209,16 +2220,16 @@ msgstr ""
msgid "program %lu version %lu ready and waiting\n"
msgstr ""
-#: inet/rcmd.c:154
+#: inet/rcmd.c:157
#, c-format
msgid "rcmd: select (setting up stderr): %s\n"
msgstr ""
-#: inet/rcmd.c:86
+#: inet/rcmd.c:87
msgid "rcmd: socket: All ports in use\n"
msgstr ""
-#: inet/rcmd.c:141
+#: inet/rcmd.c:144
#, c-format
msgid "rcmd: write (setting up stderr): %s\n"
msgstr ""
@@ -2227,7 +2238,7 @@ msgstr ""
msgid "registerrpc: out of memory\n"
msgstr ""
-#: time/zic.c:1795
+#: time/zic.c:1794
msgid "repeated leap second moment"
msgstr ""
@@ -2263,16 +2274,16 @@ msgstr ""
msgid "run_svc returned unexpectedly\n"
msgstr ""
-#: time/zic.c:709 time/zic.c:711
+#: time/zic.c:708 time/zic.c:710
msgid "same rule name in multiple files"
msgstr ""
-#: inet/rcmd.c:158
+#: inet/rcmd.c:161
msgid "select: protocol failure in circuit setup\n"
msgstr ""
-#: inet/rcmd.c:176
-msgid "socket: protocol failure in circuit setup.\n"
+#: inet/rcmd.c:179
+msgid "socket: protocol failure in circuit setup\n"
msgstr ""
#: locale/programs/locfile.c:600
@@ -2284,7 +2295,7 @@ msgid ""
"specification of sorting weight for collation symbol does not make sense"
msgstr ""
-#: time/zic.c:780
+#: time/zic.c:779
msgid "standard input"
msgstr ""
@@ -2292,31 +2303,41 @@ msgstr ""
msgid "standard output"
msgstr ""
-#: time/zic.c:1277
+#: locale/programs/ld-time.c:256
+#, c-format
+msgid "starting date is illegal in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: time/zic.c:1276
msgid "starting year greater than ending year"
msgstr ""
-#: sunrpc/svc_tcp.c:199 sunrpc/svc_tcp.c:204
+#: locale/programs/ld-time.c:328
+#, c-format
+msgid "stopping date is illegal in string %d in `era' field in category `%s'"
+msgstr ""
+
+#: sunrpc/svc_tcp.c:201 sunrpc/svc_tcp.c:206
msgid "svc_tcp: makefd_xprt: out of memory\n"
msgstr ""
-#: sunrpc/svc_tcp.c:147
+#: sunrpc/svc_tcp.c:149
msgid "svctcp_.c - cannot getsockname or listen"
msgstr ""
-#: sunrpc/svc_tcp.c:134
+#: sunrpc/svc_tcp.c:136
msgid "svctcp_.c - udp socket creation problem"
msgstr ""
-#: sunrpc/svc_tcp.c:154 sunrpc/svc_tcp.c:161
+#: sunrpc/svc_tcp.c:156 sunrpc/svc_tcp.c:163
msgid "svctcp_create: out of memory\n"
msgstr ""
-#: sunrpc/svc_udp.c:119
+#: sunrpc/svc_udp.c:123
msgid "svcudp_create - cannot getsockname"
msgstr ""
-#: sunrpc/svc_udp.c:107
+#: sunrpc/svc_udp.c:111
msgid "svcudp_create: socket creation problem"
msgstr ""
@@ -2424,15 +2445,15 @@ msgstr ""
msgid "syntax error: not inside a locale definition section"
msgstr ""
-#: catgets/gencat.c:371 catgets/gencat.c:507 catgets/gencat.c:534
+#: catgets/gencat.c:380 catgets/gencat.c:516 catgets/gencat.c:543
msgid "this is the first definition"
msgstr ""
-#: time/zic.c:1120
+#: time/zic.c:1119
msgid "time before zero"
msgstr ""
-#: time/zic.c:1128 time/zic.c:1960 time/zic.c:1979
+#: time/zic.c:1127 time/zic.c:1959 time/zic.c:1978
msgid "time overflow"
msgstr ""
@@ -2448,19 +2469,15 @@ msgstr ""
msgid "too many character classes defined"
msgstr ""
-#: sunrpc/rpc_util.c:285
-msgid "too many files!\n"
-msgstr ""
-
-#: time/zic.c:1789
+#: time/zic.c:1788
msgid "too many leap seconds"
msgstr ""
-#: time/zic.c:1761
+#: time/zic.c:1760
msgid "too many local time types"
msgstr ""
-#: time/zic.c:1715
+#: time/zic.c:1714
msgid "too many transitions?!"
msgstr ""
@@ -2468,7 +2485,7 @@ msgstr ""
msgid "too many weights"
msgstr ""
-#: time/zic.c:2083
+#: time/zic.c:2082
msgid "too many, or too long, time zone abbreviations"
msgstr ""
@@ -2485,7 +2502,7 @@ msgstr ""
msgid "two lines in a row containing `...' are not allowed"
msgstr ""
-#: time/zic.c:1284
+#: time/zic.c:1283
msgid "typed single year"
msgstr ""
@@ -2496,6 +2513,7 @@ msgstr ""
#: locale/programs/ld-messages.c:193 locale/programs/ld-messages.c:204
#: locale/programs/ld-messages.c:215 locale/programs/ld-messages.c:226
+#: locale/programs/ld-time.c:696
#, c-format
msgid "unknown character in field `%s' of category `%s'"
msgstr ""
@@ -2504,12 +2522,12 @@ msgstr ""
msgid "unknown collation directive"
msgstr ""
-#: catgets/gencat.c:468
+#: catgets/gencat.c:477
#, c-format
msgid "unknown directive `%s': line ignored"
msgstr ""
-#: catgets/gencat.c:447
+#: catgets/gencat.c:456
#, c-format
msgid "unknown set `%s'"
msgstr ""
@@ -2523,11 +2541,11 @@ msgstr ""
msgid "unknown symbol `%.*s': line ignored"
msgstr ""
-#: time/zic.c:752
+#: time/zic.c:751
msgid "unruly zone"
msgstr ""
-#: catgets/gencat.c:952
+#: catgets/gencat.c:961
msgid "unterminated message"
msgstr ""
@@ -2535,10 +2553,6 @@ msgstr ""
msgid "unterminated string"
msgstr ""
-#: sunrpc/rpc_scan.c:319
-msgid "unterminated string constant"
-msgstr ""
-
#: locale/programs/linereader.c:385
msgid "unterminated symbolic name"
msgstr ""
@@ -2551,12 +2565,7 @@ msgstr ""
msgid "upper limit in range is not smaller then lower limit"
msgstr ""
-#: sunrpc/rpc_main.c:78
-#, c-format
-msgid "usage: %s infile\n"
-msgstr ""
-
-#: time/zic.c:2026
+#: time/zic.c:2025
msgid "use of 2/29 in non leap-year"
msgstr ""
@@ -2600,50 +2609,42 @@ msgstr ""
msgid "values for field `%s' in category `%s' must not be zero"
msgstr ""
-#: sunrpc/rpc_parse.c:330
-msgid "variable-length array declaration expected"
-msgstr ""
-
-#: sunrpc/rpc_parse.c:370
-msgid "voids allowed only inside union and program definitions"
-msgstr ""
-
#: login/setutent_r.c:47
msgid "while opening UTMP file"
msgstr ""
-#: catgets/gencat.c:979
+#: catgets/gencat.c:988
msgid "while opening old catalog file"
msgstr ""
-#: db/makedb.c:338
+#: db/makedb.c:353
msgid "while reading database"
msgstr ""
-#: db/makedb.c:300
+#: db/makedb.c:315
msgid "while writing data base file"
msgstr ""
-#: db/makedb.c:130
+#: db/makedb.c:142
msgid "wrong number of arguments"
msgstr ""
-#: time/zic.c:1078
+#: time/zic.c:1077
msgid "wrong number of fields on Leap line"
msgstr ""
-#: time/zic.c:1169
+#: time/zic.c:1168
msgid "wrong number of fields on Link line"
msgstr ""
-#: time/zic.c:912
+#: time/zic.c:911
msgid "wrong number of fields on Rule line"
msgstr ""
-#: time/zic.c:982
+#: time/zic.c:981
msgid "wrong number of fields on Zone continuation line"
msgstr ""
-#: time/zic.c:940
+#: time/zic.c:939
msgid "wrong number of fields on Zone line"
msgstr ""
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 7c2b50c..44072a4 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -153,7 +153,6 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
#endif
extern void __flockfile (FILE *);
-weak_extern (__flockfile);
extern void __funlockfile (FILE *);
/* Global variables. */
diff --git a/string/string.h b/string/string.h
index 8b9fd5c..a8b34b2 100644
--- a/string/string.h
+++ b/string/string.h
@@ -238,6 +238,14 @@ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n));
extern char *basename __P ((__const char *__filename));
#endif
+#ifdef __USE_SVID
+/* Swab pairs bytes in the first N bytes of the area pointed to by
+ FROM and copy the result to TO. The value of TO must not be in the
+ range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
+ is without partner. */
+extern void swab __P ((__const char *__from, __const char *__to, size_t __n));
+#endif
+
__END_DECLS
#endif /* string.h */
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 7612f1a..5bd8f9b 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -21,13 +21,15 @@
#
subdir := sunrpc
-# The code in this subdirectory is taken verbatim from Sun's RPCSRC-4.0
-# distribution. A few files needed trivial modifications to compile in the
-# GNU environment; these changes are marked by comments that say
-# `roland@gnu'. All the code from Sun's rpc, etc, and rpcgen
-# subdirectories is in this directory; the rpc subdirectory contains only
-# the header files. Other than that, several files were renamed so as not
-# to exceed 14-character file name limits:
+# The code in this subdirectory is taken from Sun's RPCSRC-4.0
+# distribution with some additional changes from the TI-RPC package
+# which is also available from Sun. A few files needed trivial
+# modifications to compile in the GNU environment; these changes are
+# marked by comments that say `roland@gnu'. All the code from Sun's
+# rpc, etc, and rpcgen subdirectories is in this directory; the rpc
+# subdirectory contains only the header files. Other than that,
+# several files were renamed so as not to exceed 14-character file
+# name limits:
#
# authunix_prot.c -> authuxprot.c
# bindresvport.c -> bindrsvprt.c
@@ -68,9 +70,11 @@ others := portmap rpcinfo
install-bin := rpcgen
install-sbin := rpcinfo portmap
rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
- rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o
+ rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
+ rpc_tblout.o rpc_sample.o
# These headers are part of rpcgen.
-distribute := rpc_util.h rpc_parse.h rpc_scan.h $(rpcgen-objs:.o=.c) etc.rpc
+distribute := proto.h rpc_util.h rpc_parse.h rpc_scan.h \
+ $(rpcgen-objs:.o=.c) etc.rpc
extra-objs = $(rpcgen-objs)
all: # Make this the default target; it will be defined in Rules.
@@ -112,10 +116,16 @@ defines := $(defines) -D_PATH_RPC='"$(sysconfdir)/rpc"'
# Generate the rpcsvc headers with rpcgen.
$(objpfx)rpcsvc/%.h: rpcsvc/%.x $(objpfx)rpcgen
$(make-target-directory)
- $(rpcgen-cmd) -h $< -o $@
+ -@rm -f $@T
+ $(rpcgen-cmd) -h $< -o $@T
+ mv -f $@T $@
+
# Generate the rpcsvc XDR functions with rpcgen.
$(objpfx)x%.c: rpcsvc/%.x $(objpfx)rpcgen
- $(rpcgen-cmd) -c $< -o $@
+ -@rm -f $@T
+ $(rpcgen-cmd) -c $< -o $@T
+ mv -f $@T $@
+
# The generated source files depend on the corresponding generated headers.
# Gratuitous dependency on generated .c file here just gets it mentioned to
# avoid being an intermediate file and getting removed.
diff --git a/sunrpc/proto.h b/sunrpc/proto.h
new file mode 100644
index 0000000..ed010f8
--- /dev/null
+++ b/sunrpc/proto.h
@@ -0,0 +1,53 @@
+/****** rpc_clntout.c ******/
+
+void write_stubs(void);
+void printarglist(proc_list *proc,
+ const char *addargname, const char *addargtype);
+
+/****** rpc_cout.c ******/
+
+void emit(definition *def);
+void emit_inline(declaration *decl, int flag);
+void emit_single_in_line(declaration *decl, int flag, relation rel);
+
+/****** rpc_hout.c ******/
+
+void print_datadef(definition *def);
+void print_funcdef(definition *def);
+void pxdrfuncdecl(const char *name, int pointerp);
+void pprocdef(proc_list *proc, version_list *vp,
+ const char *addargtype, int server_p, int mode);
+void pdeclaration(const char *name, declaration *dec, int tab,
+ const char *separator);
+
+/****** rpc_main.c ******/
+ /* nil */
+
+/****** rpc_parse.c ******/
+definition *get_definition(void);
+
+/****** rpc_sample.c ******/
+void write_sample_svc(definition *def);
+int write_sample_clnt(definition *def);
+void add_sample_msg(void);
+void write_sample_clnt_main(void);
+
+/****** rpc_scan.c ******/
+ /* see rpc_scan.h */
+
+/****** rpc_svcout.c ******/
+int nullproc(proc_list *proc);
+void write_svc_aux(int nomain);
+void write_msg_out(void);
+
+/****** rpc_tblout.c ******/
+void write_tables(void);
+
+/****** rpc_util.c ******/
+void reinitialize(void);
+int streq(const char *a, const char *b);
+void error(const char *msg);
+void crash(void);
+void tabify(FILE *f, int tab);
+char *make_argname(const char *pname, const char *vname);
+void add_type(int len, const char *type);
diff --git a/sunrpc/rpc_clntout.c b/sunrpc/rpc_clntout.c
index 555681b..7bfe491 100644
--- a/sunrpc/rpc_clntout.c
+++ b/sunrpc/rpc_clntout.c
@@ -1,56 +1,68 @@
-/* @(#)rpc_clntout.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_clntout.c 1.2 87/06/24 (C) 1987 SMI";
-#endif
+
+/*
+ * From: @(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI
+ */
+char clntout_rcsid[] =
+ "$Id$";
/*
* rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
* Copyright (C) 1987, Sun Microsytsems, Inc.
*/
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
+#include <rpc/types.h>
#include "rpc_parse.h"
#include "rpc_util.h"
+#include "proto.h"
#define DEFAULT_TIMEOUT 25 /* in seconds */
+static char RESULT[] = "clnt_res";
+
+static void write_program(definition *def);
+static void printbody(proc_list *proc);
+static const char *ampr(const char *type);
+static void printbody(proc_list *proc);
+
void
-write_stubs()
+write_stubs(void)
{
list *l;
definition *def;
- f_print(fout,
- "\n/* Default timeout can be changed using clnt_control() */\n");
- f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
+ f_print(fout,
+ "\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) {
def = (definition *) l->val;
@@ -60,10 +72,8 @@ write_stubs()
}
}
-
-static
-write_program(def)
- definition *def;
+static void
+write_program(definition *def)
{
version_list *vp;
proc_list *proc;
@@ -74,21 +84,73 @@ write_program(def)
ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, "*\n");
pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "(argp, clnt)\n");
- f_print(fout, "\t");
- ptype(proc->arg_prefix, proc->arg_type, 1);
- f_print(fout, "*argp;\n");
- f_print(fout, "\tCLIENT *clnt;\n");
+ printarglist( proc, "clnt", "CLIENT *" );
f_print(fout, "{\n");
printbody(proc);
- f_print(fout, "}\n\n");
+ f_print(fout, "}\n");
}
}
}
-static char *
-ampr(type)
- char *type;
+/* Writes out declarations of procedure's argument list.
+ In either ANSI C style, in one of old rpcgen style (pass by reference),
+ or new rpcgen style (multiple arguments, pass by value);
+ */
+
+/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
+
+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 */
+ 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 {
+ 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")) {
+ /* newstyle, 0 argument */
+ if( Cflag )
+ f_print(fout, "(%s%s)\n", addargtype, addargname );
+ else
+ f_print(fout, "(%s)\n", addargname);
+ } else {
+ /* new style, 1 or multiple arguments */
+ 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) {
+ pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );
+ }
+ } else { /* C++ style header */
+ f_print(fout, "(");
+ 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 );
+ }
+ }
+
+ if( !Cflag )
+ f_print(fout, "\t%s%s;\n", addargtype, addargname );
+}
+
+
+
+static
+const char *
+ampr(const char *type)
{
if (isvectordef(type, REL_ALIAS)) {
return ("");
@@ -97,30 +159,65 @@ ampr(type)
}
}
-static
-printbody(proc)
- proc_list *proc;
+static void
+printbody(proc_list *proc)
{
+ decl_list *l;
+ bool_t args2 = (proc->arg_num > 1);
+/* int i; */
+
+ /* For new style with multiple arguments, need a structure in which
+ to stuff the arguments. */
+ 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")) {
f_print(fout, "char ");
} else {
ptype(proc->res_prefix, proc->res_type, 0);
}
- f_print(fout, "res;\n");
+ f_print(fout, "%s;\n",RESULT);
f_print(fout, "\n");
- f_print(fout, "\tbzero((char *)%sres, sizeof(res));\n",
- ampr(proc->res_type));
- f_print(fout,
- "\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n",
- proc->proc_name, stringfix(proc->arg_type),
- stringfix(proc->res_type), ampr(proc->res_type));
+ 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"))) {
+ /* newstyle, 0 arguments */
+ f_print(fout,
+ "\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name);
+ f_print(fout,
+ ", NULL, xdr_%s, %s,%s, TIMEOUT) != RPC_SUCCESS) {\n",
+ stringfix(proc->res_type), ampr(proc->res_type), RESULT);
+
+ } else if ( newstyle && args2) {
+ /* newstyle, multiple arguments: stuff arguments into structure */
+ for (l = proc->args.decls; l != NULL; l = l->next) {
+ f_print(fout, "\targ.%s = %s;\n",
+ l->decl.name, l->decl.name);
+ }
+ f_print(fout,
+ "\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name,
+ proc->args.argname);
+ 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 */
+ f_print(fout,
+ "\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+ proc->proc_name,
+ stringfix(proc->args.decls->decl.type),
+ (newstyle ? "&" : ""),
+ (newstyle ? proc->args.decls->decl.name : "argp"),
+ stringfix(proc->res_type), ampr(proc->res_type),RESULT);
+ }
f_print(fout, "\t\treturn (NULL);\n");
f_print(fout, "\t}\n");
if (streq(proc->res_type, "void")) {
- f_print(fout, "\treturn ((void *)%sres);\n",
- ampr(proc->res_type));
+ f_print(fout, "\treturn ((void *)%s%s);\n",
+ ampr(proc->res_type),RESULT);
} else {
- f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type));
+ f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT);
}
}
+
diff --git a/sunrpc/rpc_cout.c b/sunrpc/rpc_cout.c
index 86d3865..378a686 100644
--- a/sunrpc/rpc_cout.c
+++ b/sunrpc/rpc_cout.c
@@ -1,55 +1,92 @@
-/* @(#)rpc_cout.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_cout.c 1.8 87/06/24 (C) 1987 SMI";
-#endif
/*
- * rpc_cout.c, XDR routine outputter for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
+ * From: @(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI
+ */
+char cout_rcsid[] =
+ "$Id$";
+
+/*
+ * rpc_cout.c, XDR routine outputter for the RPC protocol compiler
*/
+#include <ctype.h>
#include <stdio.h>
-#include <strings.h>
-#include "rpc_util.h"
+#include <string.h>
#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "proto.h"
+
+static void emit_enum(definition *def);
+static void emit_program(definition *def);
+static void emit_union(definition *def);
+static void emit_struct(definition *def);
+static void emit_typedef(definition *def);
+static int findtype(const definition *def, const char *type);
+static int undefined(const char *type);
+static void print_generic_header(const char *procname, int pointerp);
+static void print_ifopen(int indent, const char *name);
+static void print_ifarg(const char *arg);
+static void print_ifsizeof(const char *prefix, const char *type);
+static void print_ifclose(int indent);
+static void print_ifstat(int indent, const char *prefix, const char *type,
+ relation rel, const char *amax,
+ const char *objname, const char *name);
+static void print_stat(int indent, declaration *dec);
+static void print_header(definition *def);
+static void print_trailer(void);
+static char *upcase(const char *str);
/*
- * Emit the C-routine for the given definition
+ * Emit the C-routine for the given definition
*/
void
-emit(def)
- definition *def;
+emit(definition *def)
{
- if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
+ if (def->def_kind == DEF_CONST) {
return;
}
+ if (def->def_kind == DEF_PROGRAM) {
+ emit_program(def);
+ return;
+ }
+ if(def->def_kind == DEF_TYPEDEF)
+ {
+ /* now we need to handle declarations like
+ struct typedef foo foo;
+ since we dont want this to be expanded into 2 calls to xdr_foo */
+
+ if(strcmp(def->def.ty.old_type,def->def_name)==0)
+ return;
+ };
+
print_header(def);
switch (def->def_kind) {
case DEF_UNION:
@@ -64,15 +101,16 @@ emit(def)
case DEF_TYPEDEF:
emit_typedef(def);
break;
+ default:
+ /* can't happen */
}
print_trailer();
}
-static
-findtype(def, type)
- definition *def;
- char *type;
+static int
+findtype(const definition *def, const char *type)
{
+
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
return (0);
} else {
@@ -80,105 +118,121 @@ findtype(def, type)
}
}
-static
-undefined(type)
- char *type;
+static int
+undefined(const char *type)
{
definition *def;
def = (definition *) FINDVAL(defined, type, findtype);
+
+
return (def == NULL);
}
-static
-print_header(def)
- definition *def;
+static void
+print_generic_header(const char *procname, int pointerp)
{
- space();
+ f_print(fout, "\n");
f_print(fout, "bool_t\n");
- f_print(fout, "xdr_%s(xdrs, objp)\n", def->def_name);
- f_print(fout, "\tXDR *xdrs;\n");
- f_print(fout, "\t%s ", def->def_name);
- if (def->def_kind != DEF_TYPEDEF ||
- !isvectordef(def->def.ty.old_type, def->def.ty.rel)) {
- f_print(fout, "*");
+ if (Cflag) {
+ f_print(fout, "xdr_%s(", procname);
+ f_print(fout, "XDR *xdrs, ");
+ f_print(fout, "%s ", procname);
+ if( pointerp )
+ f_print(fout, "*");
+ f_print(fout, "objp)\n{\n\n");
+ } else {
+ f_print(fout, "xdr_%s(xdrs, objp)\n", procname);
+ f_print(fout, "\tXDR *xdrs;\n");
+ f_print(fout, "\t%s ", procname);
+ if( pointerp )
+ f_print(fout, "*");
+ f_print(fout, "objp;\n{\n\n");
}
- f_print(fout, "objp;\n");
- f_print(fout, "{\n");
}
-static
-print_trailer()
+static void
+print_header(definition *def)
+{
+
+/*
+ decl_list *dl;
+ bas_type *ptr;
+ int i;
+ */
+
+ print_generic_header( def->def_name,
+ def->def_kind != DEF_TYPEDEF ||
+ !isvectordef(def->def.ty.old_type, def->def.ty.rel));
+
+ /* Now add Inline support */
+
+
+ if(inlineflag == 0 )
+ return;
+ /*May cause lint to complain. but ... */
+f_print(fout, "\t register long *buf;\n\n");
+
+}
+
+static void
+print_prog_header(proc_list *plist)
+{
+ print_generic_header( plist->args.argname, 1 );
+}
+
+static void
+print_trailer(void)
{
f_print(fout, "\treturn (TRUE);\n");
f_print(fout, "}\n");
- space();
}
-static
-print_ifopen(indent, name)
- int indent;
- char *name;
+static void
+print_ifopen(int indent, const char *name)
{
tabify(fout, indent);
- f_print(fout, "if (!xdr_%s(xdrs", name);
+ f_print(fout, " if (!xdr_%s(xdrs", name);
}
-
-static
-print_ifarg(arg)
- char *arg;
+static void
+print_ifarg(const char *arg)
{
f_print(fout, ", %s", arg);
}
-
-static
-print_ifsizeof(prefix, type)
- char *prefix;
- char *type;
+static void
+print_ifsizeof(const char *prefix, const char *type)
{
if (streq(type, "bool")) {
- f_print(fout, ", sizeof(bool_t), xdr_bool");
- } else {
+ f_print(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool");
+ }
+ else {
f_print(fout, ", sizeof(");
if (undefined(type) && prefix) {
f_print(fout, "%s ", prefix);
}
- f_print(fout, "%s), xdr_%s", type, type);
+ f_print(fout, "%s), (xdrproc_t)xdr_%s", type, type);
}
}
-static
-print_ifclose(indent)
- int indent;
+static void
+print_ifclose(int indent)
{
f_print(fout, ")) {\n");
tabify(fout, indent);
- f_print(fout, "\treturn (FALSE);\n");
+ f_print(fout, "\t return (FALSE);\n");
tabify(fout, indent);
- f_print(fout, "}\n");
-}
-
-static
-space()
-{
- f_print(fout, "\n\n");
+ f_print(fout, " }\n");
}
-static
-print_ifstat(indent, prefix, type, rel, amax, objname, name)
- int indent;
- char *prefix;
- char *type;
- relation rel;
- char *amax;
- char *objname;
- char *name;
+static void
+print_ifstat(int indent, const char *prefix, const char *type, relation rel,
+ const char *amax, const char *objname, const char *name)
{
- char *alt = NULL;
+ const char *alt = NULL;
switch (rel) {
case REL_POINTER:
@@ -243,101 +297,331 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
print_ifclose(indent);
}
-
-/* ARGSUSED */
-static
-emit_enum(def)
- definition *def;
+static void
+emit_enum(definition *def)
{
+ (void)def;
+
print_ifopen(1, "enum");
print_ifarg("(enum_t *)objp");
print_ifclose(1);
}
-
-static
-emit_union(def)
- definition *def;
+static void
+emit_program(definition *def)
{
- declaration *dflt;
- case_list *cl;
- declaration *cs;
- char *object;
- char *format = "&objp->%s_u.%s";
-
- print_stat(&def->def.un.enum_decl);
- f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
- for (cl = def->def.un.cases; cl != NULL; cl = cl->next) {
- cs = &cl->case_decl;
- f_print(fout, "\tcase %s:\n", cl->case_name);
- if (!streq(cs->type, "void")) {
- object = alloc(strlen(def->def_name) + strlen(format) +
- strlen(cs->name) + 1);
- s_print(object, format, def->def_name, cs->name);
- print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max,
- object, cs->name);
- free(object);
- }
- f_print(fout, "\t\tbreak;\n");
- }
- dflt = def->def.un.default_decl;
- if (dflt != NULL) {
- if (!streq(dflt->type, "void")) {
- f_print(fout, "\tdefault:\n");
- object = alloc(strlen(def->def_name) + strlen(format) +
- strlen(dflt->name) + 1);
- s_print(object, format, def->def_name, dflt->name);
- print_ifstat(2, dflt->prefix, dflt->type, dflt->rel,
- dflt->array_max, object, dflt->name);
- free(object);
- f_print(fout, "\t\tbreak;\n");
- }
- } else {
- f_print(fout, "\tdefault:\n");
- f_print(fout, "\t\treturn (FALSE);\n");
- }
- f_print(fout, "\t}\n");
+ decl_list *dl;
+ version_list *vlist;
+ proc_list *plist;
+
+ for (vlist = def->def.pr.versions; vlist != NULL;vlist = vlist->next)
+ for(plist = vlist->procs; plist != NULL; plist = plist->next) {
+ if (!newstyle || plist->arg_num < 2)
+ continue; /* old style, or single argument */
+ print_prog_header(plist);
+ for (dl = plist->args.decls; dl != NULL;
+ dl = dl->next)
+ print_stat(1,&dl->decl);
+ print_trailer();
+ }
}
+static void
+emit_union(definition *def)
+{
+ declaration *dflt;
+ case_list *cl;
+ declaration *cs;
+ char *object;
+ const char *vecformat = "objp->%s_u.%s";
+ const char *format = "&objp->%s_u.%s";
+
+ print_stat(1,&def->def.un.enum_decl);
+ f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
+ for (cl = def->def.un.cases; cl != NULL; cl = cl->next) {
+
+ f_print(fout, "\tcase %s:\n", cl->case_name);
+ if(cl->contflag == 1) /* a continued case statement */
+ continue;
+ cs = &cl->case_decl;
+ if (!streq(cs->type, "void")) {
+ object = alloc(strlen(def->def_name) + strlen(format) +
+ strlen(cs->name) + 1);
+ if (isvectordef(cs->type, cs->rel)) {
+ s_print(object, vecformat, def->def_name,
+ cs->name);
+ } else {
+ s_print(object, format, def->def_name,
+ cs->name);
+ }
+ print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max,
+ object, cs->name);
+ free(object);
+ }
+ f_print(fout, "\t\tbreak;\n");
+ }
+ dflt = def->def.un.default_decl;
+ if (dflt != NULL) {
+ if (!streq(dflt->type, "void")) {
+ f_print(fout, "\tdefault:\n");
+ object = alloc(strlen(def->def_name) + strlen(format) +
+ strlen(dflt->name) + 1);
+ if (isvectordef(dflt->type, dflt->rel)) {
+ s_print(object, vecformat, def->def_name,
+ dflt->name);
+ } else {
+ s_print(object, format, def->def_name,
+ dflt->name);
+ }
+
+ print_ifstat(2, dflt->prefix, dflt->type, dflt->rel,
+ dflt->array_max, object, dflt->name);
+ free(object);
+ f_print(fout, "\t\tbreak;\n");
+ }
+#ifdef __GNU_LIBRARY__
+ else {
+ f_print(fout, "\tdefault:\n");
+ f_print(fout, "\t\tbreak;\n");
+ }
+#endif
+ } else {
+ f_print(fout, "\tdefault:\n");
+ f_print(fout, "\t\treturn (FALSE);\n");
+ }
+ f_print(fout, "\t}\n");
+}
-static
-emit_struct(def)
- definition *def;
+static void
+emit_struct(definition *def)
{
decl_list *dl;
-
- for (dl = def->def.st.decls; dl != NULL; dl = dl->next) {
- print_stat(&dl->decl);
+ int i,j,size,flag;
+ decl_list *cur = NULL,*psav;
+ bas_type *ptr;
+ char *sizestr;
+ const char *plus;
+ char ptemp[256];
+ int can_inline;
+
+
+ if(inlineflag == 0) {
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+ print_stat(1,&dl->decl);
}
-}
+ else {
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+ if(dl->decl.rel == REL_VECTOR){
+ f_print(fout,"\t int i;\n");
+ break;
+ }
+ size=0;can_inline=0;
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+ if((dl->decl.prefix == NULL) && ((ptr=find_type(dl->decl.type))!= NULL) && ((dl->decl.rel == REL_ALIAS)||(dl->decl.rel == REL_VECTOR))){
-static
-emit_typedef(def)
- definition *def;
-{
- char *prefix = def->def.ty.old_prefix;
- char *type = def->def.ty.old_type;
- char *amax = def->def.ty.array_max;
- relation rel = def->def.ty.rel;
+ if(dl->decl.rel == REL_ALIAS)
+ size+=ptr->length;
+ else {
+ can_inline=1;
+ break; /* can be inlined */
+ };
+ }
+ else {
+ if(size >= inlineflag){
+ can_inline=1;
+ break; /* can be inlined */
+ }
+ size=0;
+ }
+ if(size > inlineflag)
+ can_inline=1;
+
+ if(can_inline == 0){ /* can not inline, drop back to old mode */
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+ print_stat(1,&dl->decl);
+ return;
+ };
+
+
+
+
+ flag=PUT;
+ for(j=0; j<2; j++){
+
+ if(flag == PUT)
+ f_print(fout,"\n\t if (xdrs->x_op == XDR_ENCODE) {\n");
+ else
+ f_print(fout,"\n \t return (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n");
+
+
+ i=0;
+ size=0;
+ sizestr=NULL;
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next) { /* xxx */
+
+ /* now walk down the list and check for basic types */
+ if((dl->decl.prefix == NULL) && ((ptr=find_type(dl->decl.type))!= NULL) && ((dl->decl.rel == REL_ALIAS)||(dl->decl.rel == REL_VECTOR))){
+ if(i ==0 )
+ cur=dl;
+ i++;
+
+ if(dl->decl.rel == REL_ALIAS)
+ size+=ptr->length;
+ else {
+ /* this is required to handle arrays */
+
+ if(sizestr == NULL)
+ plus = " ";
+ else
+ plus = "+";
+
+ if(ptr->length != 1)
+ s_print(ptemp," %s %s * %d",plus,dl->decl.array_max,ptr->length);
+ else
+ s_print(ptemp," %s %s ",plus,dl->decl.array_max);
+
+ /*now concatenate to sizestr !!!! */
+ if (sizestr == NULL)
+ sizestr=strdup(ptemp);
+ else{
+ sizestr=realloc(sizestr,strlen(sizestr)+strlen(ptemp)+1);
+ if(sizestr == NULL){
+
+ f_print(stderr, "Fatal error : no memory \n");
+ crash();
+ };
+ sizestr=strcat(sizestr,ptemp); /*build up length of array */
+
+ }
+ }
+
+ }
+ else{
+ if(i > 0 )
+ if(sizestr == NULL && size < inlineflag){
+ /* don't expand into inline code if size < inlineflag */
+ while(cur != dl){
+ print_stat(1,&cur->decl);
+ cur=cur->next;
+ }
+ }
+ else{
+
+
+
+ /* were already looking at a xdr_inlineable structure */
+ if(sizestr == NULL)
+ f_print(fout,"\t buf = XDR_INLINE(xdrs,%d * BYTES_PER_XDR_UNIT);",
+ size);
+ else
+ if(size == 0)
+ f_print(fout,
+ "\t buf = XDR_INLINE(xdrs,%s * BYTES_PER_XDR_UNIT);",
+ sizestr);
+ else
+ f_print(fout,
+ "\t buf = XDR_INLINE(xdrs,(%d + %s)* BYTES_PER_XDR_UNIT);",
+ size,sizestr);
+
+ f_print(fout,"\n\t if (buf == NULL) {\n");
+
+ psav=cur;
+ while(cur != dl){
+ print_stat(2,&cur->decl);
+ cur=cur->next;
+ }
+
+ f_print(fout,"\n\t }\n\t else {\n");
+
+ cur=psav;
+ while(cur != dl){
+ emit_inline(&cur->decl,flag);
+ cur=cur->next;
+ }
+
+ f_print(fout,"\t }\n");
+ }
+ size=0;i=0;sizestr=NULL;
+ print_stat(1,&dl->decl);
+ }
- print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
+ }
+ if(i > 0 )
+ if(sizestr == NULL && size < inlineflag){
+ /* don't expand into inline code if size < inlineflag */
+ while(cur != dl){
+ print_stat(1,&cur->decl);
+ cur=cur->next;
+ }
+ }
+ else{
+
+ /* were already looking at a xdr_inlineable structure */
+ if(sizestr == NULL)
+ f_print(fout,"\t\tbuf = XDR_INLINE(xdrs,%d * BYTES_PER_XDR_UNIT);",
+ size);
+ else
+ if(size == 0)
+ f_print(fout,
+ "\t\tbuf = XDR_INLINE(xdrs,%s * BYTES_PER_XDR_UNIT);",
+ sizestr);
+ else
+ f_print(fout,
+ "\t\tbuf = XDR_INLINE(xdrs,(%d + %s)* BYTES_PER_XDR_UNIT);",
+ size,sizestr);
+
+ f_print(fout,"\n\t\tif (buf == NULL) {\n");
+
+ psav=cur;
+ while(cur != NULL){
+ print_stat(2,&cur->decl);
+ cur=cur->next;
+ }
+ f_print(fout,"\n\t }\n\t else {\n");
+
+ cur=psav;
+ while(cur != dl){
+ emit_inline(&cur->decl,flag);
+ cur=cur->next;
+ }
+
+ f_print(fout,"\t }\n");
+
+ }
+ flag=GET;
+ }
+ f_print(fout,"\t return(TRUE);\n\t}\n\n");
+
+ /* now take care of XDR_FREE case */
+
+ for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+ print_stat(1,&dl->decl);
+ }
}
+static void
+emit_typedef(definition *def)
+{
+ const char *prefix = def->def.ty.old_prefix;
+ const char *type = def->def.ty.old_type;
+ const char *amax = def->def.ty.array_max;
+ relation rel = def->def.ty.rel;
+ print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
+}
-static
-print_stat(dec)
- declaration *dec;
+static void
+print_stat(int indent, declaration *dec)
{
- char *prefix = dec->prefix;
- char *type = dec->type;
- char *amax = dec->array_max;
+ const char *prefix = dec->prefix;
+ const char *type = dec->type;
+ const char *amax = dec->array_max;
relation rel = dec->rel;
char name[256];
@@ -346,5 +630,85 @@ print_stat(dec)
} else {
s_print(name, "&objp->%s", dec->name);
}
- print_ifstat(1, prefix, type, rel, amax, name, dec->name);
+ print_ifstat(indent, prefix, type, rel, amax, name, dec->name);
+}
+
+
+void
+emit_inline(declaration *decl, int flag)
+{
+
+/*check whether an array or not */
+
+switch(decl->rel)
+ {
+ case REL_ALIAS :
+ emit_single_in_line(decl,flag,REL_ALIAS);
+ break;
+ case REL_VECTOR :
+ f_print(fout,"\t\t{ register %s *genp; \n",decl->type);
+ f_print(fout,"\t\t for ( i = 0,genp=objp->%s;\n \t\t\ti < %s; i++){\n\t\t",
+ decl->name,decl->array_max);
+ emit_single_in_line(decl,flag,REL_VECTOR);
+ f_print(fout,"\t\t }\n\t\t };\n");
+
+ default:
+ /* ?... do nothing I guess */
+ }
+}
+
+void
+emit_single_in_line(declaration *decl, int flag, relation rel)
+{
+ char *upp_case1;
+ const char *upp_case;
+
+ if (flag == PUT) {
+ f_print(fout,"\t\t IXDR_PUT_");
+ }
+ else {
+ if(rel== REL_ALIAS) {
+ f_print(fout, "\t\t objp->%s = IXDR_GET_", decl->name);
+ }
+ else {
+ f_print(fout,"\t\t *genp++ = IXDR_GET_");
+ }
+ }
+
+ upp_case1 = upcase(decl->type);
+ upp_case = upp_case1;
+
+ /* hack - XX */
+ if (!strcmp(upp_case, "INT")) upp_case="LONG";
+ if (!strcmp(upp_case, "U_INT")) upp_case="U_LONG";
+
+ if (flag == PUT) {
+ if (rel==REL_ALIAS) {
+ f_print(fout,"%s(buf,objp->%s);\n",upp_case,decl->name);
+ }
+ else {
+ f_print(fout,"%s(buf,*genp++);\n",upp_case);
+ }
+ }
+ else {
+ f_print(fout,"%s(buf);\n",upp_case);
+ }
+
+ free(upp_case1);
+}
+
+
+static char *upcase(const char *str) {
+ char *ptr, *hptr;
+ ptr = malloc(strlen(str));
+ if (ptr == NULL) {
+ f_print(stderr,"malloc failed\n");
+ exit(1);
+ }
+ hptr=ptr;
+ while (*str != 0) {
+ *ptr++ = toupper(*str++);
+ }
+ *ptr=0;
+ return hptr;
}
diff --git a/sunrpc/rpc_hout.c b/sunrpc/rpc_hout.c
index 1bf0097..beca276 100644
--- a/sunrpc/rpc_hout.c
+++ b/sunrpc/rpc_hout.c
@@ -1,53 +1,71 @@
-/* @(#)rpc_hout.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI";
-#endif
+
+/*
+ * From: @(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI
+ */
+char hout_rcsid[] =
+ "$Id$";
/*
* rpc_hout.c, Header file outputter for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <ctype.h>
-#include "rpc_util.h"
#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "proto.h"
+static void pconstdef(definition *def);
+static void pargdef(definition *def);
+static void pstructdef(definition *def);
+static void puniondef(definition *def);
+static void pdefine(const char *name, const char *num);
+static void puldefine(const char *name, const char *num);
+static int define_printed(proc_list *stop, version_list *start);
+static void pprogramdef(definition *def);
+static void parglist(proc_list *proc, const char *addargtype);
+static void penumdef(definition *def);
+static void ptypedef(definition *def);
+static int undefined2(const char *type, const char *stop);
/*
* Print the C-version of an xdr definition
*/
void
-print_datadef(def)
- definition *def;
+print_datadef(definition *def)
{
+
+ if (def->def_kind == DEF_PROGRAM ) /* handle data only */
+ return;
+
if (def->def_kind != DEF_CONST) {
f_print(fout, "\n");
}
@@ -72,41 +90,101 @@ print_datadef(def)
break;
}
if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
- f_print(fout, "bool_t xdr_%s();\n", def->def_name);
+ pxdrfuncdecl( def->def_name,
+ def->def_kind != DEF_TYPEDEF ||
+ !isvectordef(def->def.ty.old_type, def->def.ty.rel));
+
}
- if (def->def_kind != DEF_CONST) {
+}
+
+
+void
+print_funcdef(definition *def)
+{
+ switch (def->def_kind) {
+ case DEF_PROGRAM:
f_print(fout, "\n");
+ pprogramdef(def);
+ break;
+ default:
+ /* ?... shouldn't happen I guess */
}
}
-static
-pconstdef(def)
- definition *def;
+void
+pxdrfuncdecl(const char *name, int pointerp)
+{
+
+ f_print(fout,"#ifdef __cplusplus \n");
+ f_print(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? "*" : "");
+ f_print(fout,"#elif __STDC__ \n");
+ f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? "*" : "");
+ f_print(fout,"#else /* Old Style C */ \n");
+ f_print(fout, "bool_t xdr_%s();\n", name);
+ f_print(fout,"#endif /* Old Style C */ \n\n");
+}
+
+
+static void
+pconstdef(definition *def)
{
pdefine(def->def_name, def->def.co);
}
-static
-pstructdef(def)
- definition *def;
+/* print out the definitions for the arguments of functions in the
+ header file
+*/
+static void
+pargdef(definition *def)
+{
+ decl_list *l;
+ version_list *vers;
+ const char *name;
+ proc_list *plist;
+
+
+ for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+ for(plist = vers->procs; plist != NULL;
+ plist = plist->next) {
+
+ if (!newstyle || plist->arg_num < 2) {
+ continue; /* old style or single args */
+ }
+ name = plist->args.argname;
+ f_print(fout, "struct %s {\n", name);
+ for (l = plist->args.decls;
+ l != NULL; l = l->next) {
+ pdeclaration(name, &l->decl, 1, ";\n" );
+ }
+ f_print(fout, "};\n");
+ f_print(fout, "typedef struct %s %s;\n", name, name);
+ pxdrfuncdecl(name, 0);
+ f_print( fout, "\n" );
+ }
+ }
+
+}
+
+
+static void
+pstructdef(definition *def)
{
decl_list *l;
- char *name = def->def_name;
+ const char *name = def->def_name;
f_print(fout, "struct %s {\n", name);
for (l = def->def.st.decls; l != NULL; l = l->next) {
- pdeclaration(name, &l->decl, 1);
+ pdeclaration(name, &l->decl, 1, ";\n");
}
f_print(fout, "};\n");
f_print(fout, "typedef struct %s %s;\n", name, name);
}
-static
-puniondef(def)
- definition *def;
+static void
+puniondef(definition *def)
{
case_list *l;
- char *name = def->def_name;
+ const char *name = def->def_name;
declaration *decl;
f_print(fout, "struct %s {\n", name);
@@ -118,39 +196,32 @@ puniondef(def)
}
f_print(fout, "\tunion {\n");
for (l = def->def.un.cases; l != NULL; l = l->next) {
- pdeclaration(name, &l->case_decl, 2);
+ if(l->contflag == 0)
+ pdeclaration(name, &l->case_decl, 2, ";\n" );
}
decl = def->def.un.default_decl;
if (decl && !streq(decl->type, "void")) {
- pdeclaration(name, decl, 2);
+ pdeclaration(name, decl, 2, ";\n" );
}
f_print(fout, "\t} %s_u;\n", name);
f_print(fout, "};\n");
f_print(fout, "typedef struct %s %s;\n", name, name);
}
-
-
-static
-pdefine(name, num)
- char *name;
- char *num;
+static void
+pdefine(const char *name, const char *num)
{
f_print(fout, "#define %s %s\n", name, num);
}
-static
-puldefine(name, num)
- char *name;
- char *num;
+static void
+puldefine(const char *name, const char *num)
{
f_print(fout, "#define %s ((u_long)%s)\n", name, num);
}
-static
-define_printed(stop, start)
- proc_list *stop;
- version_list *start;
+static int
+define_printed(proc_list *stop, version_list *start)
{
version_list *vers;
proc_list *proc;
@@ -168,57 +239,122 @@ define_printed(stop, start)
/* NOTREACHED */
}
-
-static
-pprogramdef(def)
- definition *def;
+static void
+pprogramdef(definition *def)
{
version_list *vers;
proc_list *proc;
+ int i;
+ const char *ext;
+
+ pargdef(def);
puldefine(def->def_name, def->def.pr.prog_num);
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+ if (tblflag) {
+ f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",
+ locase(def->def_name), vers->vers_num);
+ f_print(fout, "extern %s_%s_nproc;\n",
+ locase(def->def_name), vers->vers_num);
+ }
puldefine(vers->vers_name, vers->vers_num);
- for (proc = vers->procs; proc != NULL; proc = proc->next) {
- if (!define_printed(proc, def->def.pr.versions)) {
- puldefine(proc->proc_name, proc->proc_num);
+
+ /*
+ * Print out 3 definitions, one for ANSI-C, another for C++,
+ * a third for old style C
+ */
+
+ for (i=0;i<3;i++) {
+ if (i==0) {
+ f_print(fout,"\n#ifdef __cplusplus\n");
+ ext="extern \"C\" ";
+ }
+ else if (i==1) {
+ f_print(fout,"\n#elif __STDC__\n");
+ ext="extern " ;
+ }
+ else {
+ f_print(fout,"\n#else /* Old Style C */ \n");
+ ext="extern ";
}
- pprocdef(proc, vers);
+
+
+ for (proc = vers->procs; proc != NULL; proc = proc->next) {
+ if (!define_printed(proc, def->def.pr.versions)) {
+ puldefine(proc->proc_name, proc->proc_num);
+ }
+ f_print(fout,"%s",ext);
+ pprocdef(proc, vers, "CLIENT *", 0,i);
+ f_print(fout,"%s",ext);
+ pprocdef(proc, vers, "struct svc_req *", 1,i);
+
+ }
+
}
+ f_print(fout,"#endif /* Old Style C */ \n");
}
}
+void
+pprocdef(proc_list *proc, version_list *vp,
+ const char *addargtype, int server_p, int mode)
+{
-pprocdef(proc, vp)
- proc_list *proc;
- version_list *vp;
+
+
+
+ ptype( proc->res_prefix, proc->res_type, 1 );
+ f_print( fout, "* " );
+ if( server_p )
+ pvname_svc(proc->proc_name, vp->vers_num);
+ else
+ pvname(proc->proc_name, vp->vers_num);
+
+ /*
+ * mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C
+ */
+ if(mode == 0 || mode ==1)
+ parglist(proc, addargtype);
+ else
+ f_print(fout, "();\n");
+
+
+
+}
+
+
+
+/* print out argument list of procedure */
+static void
+parglist(proc_list *proc, const char *addargtype)
{
- f_print(fout, "extern ");
- if (proc->res_prefix) {
- if (streq(proc->res_prefix, "enum")) {
- f_print(fout, "enum ");
+ decl_list *dl;
+
+ f_print(fout,"(");
+
+ if( proc->arg_num < 2 && newstyle &&
+ streq( proc->args.decls->decl.type, "void")) {
+ /* 0 argument in new style: do nothing */
} else {
- f_print(fout, "struct ");
+ for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
+ ptype( dl->decl.prefix, dl->decl.type, 1 );
+ if( !newstyle )
+ f_print( fout, "*" ); /* old style passes by reference */
+
+ f_print( fout, ", " );
+ }
}
- }
- if (streq(proc->res_type, "bool")) {
- f_print(fout, "bool_t *");
- } else if (streq(proc->res_type, "string")) {
- f_print(fout, "char **");
- } else {
- f_print(fout, "%s *", fixtype(proc->res_type));
- }
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "();\n");
+
+ f_print(fout, "%s);\n", addargtype);
+
}
-static
-penumdef(def)
- definition *def;
+static void
+penumdef(definition *def)
{
- char *name = def->def_name;
+ const char *name = def->def_name;
enumval_list *l;
- char *last = NULL;
+ const char *last = NULL;
int count = 0;
f_print(fout, "enum %s {\n", name);
@@ -241,12 +377,11 @@ penumdef(def)
f_print(fout, "typedef enum %s %s;\n", name, name);
}
-static
-ptypedef(def)
- definition *def;
+static void
+ptypedef(definition *def)
{
- char *name = def->def_name;
- char *old = def->def.ty.old_type;
+ const char *name = def->def_name;
+ const char *old = def->def.ty.old_type;
char prefix[8]; /* enough to contain "struct ", including NUL */
relation rel = def->def.ty.rel;
@@ -281,23 +416,20 @@ ptypedef(def)
def->def.ty.array_max);
break;
case REL_ALIAS:
- f_print(fout, "%s%s %s", prefix, old, name);
+ f_print(fout, "%s%s %s", prefix, old, name);
break;
}
f_print(fout, ";\n");
}
}
-
-static
-pdeclaration(name, dec, tab)
- char *name;
- declaration *dec;
- int tab;
+void
+pdeclaration(const char *name, declaration *dec, int tab,
+ const char *separator)
{
char buf[8]; /* enough to hold "struct ", include NUL */
- char *prefix;
- char *type;
+ const char *prefix;
+ const char *type;
if (streq(dec->type, "void")) {
return;
@@ -343,15 +475,11 @@ pdeclaration(name, dec, tab)
break;
}
}
- f_print(fout, ";\n");
+ f_print(fout, separator );
}
-
-
-static
-undefined2(type, stop)
- char *type;
- char *stop;
+static int
+undefined2(const char *type, const char *stop)
{
list *l;
definition *def;
diff --git a/sunrpc/rpc_main.c b/sunrpc/rpc_main.c
index 053b301..c6fbad1 100644
--- a/sunrpc/rpc_main.c
+++ b/sunrpc/rpc_main.c
@@ -1,11 +1,11 @@
-/* @(#)rpc_main.c 2.2 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
@@ -27,101 +27,223 @@
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_main.c 1.7 87/06/24 (C) 1987 SMI";
-#endif
+
+/*
+ * From @(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI;
+ */
+char main_rcsid[] =
+ "$Id$";
/*
* rpc_main.c, Top level of the RPC protocol compiler.
- * Copyright (C) 1987, Sun Microsystems, Inc.
*/
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/param.h>
#include <sys/file.h>
-#include "rpc_util.h"
+#include <sys/stat.h>
#include "rpc_parse.h"
+#include "rpc_util.h"
#include "rpc_scan.h"
+#include "proto.h"
+
#define EXTEND 1 /* alias for TRUE */
+#define DONT_EXTEND 0 /* alias for FALSE */
+
+#define SVR4_CPP "/usr/ccs/lib/cpp"
+#define SUNOS_CPP "/lib/cpp"
+static int cppDefined = 0; /* explicit path for C preprocessor */
struct commandline {
- int cflag;
- int hflag;
- int lflag;
- int sflag;
- int mflag;
- char *infile;
- char *outfile;
+ int cflag; /* xdr C routines */
+ int hflag; /* header file */
+ int lflag; /* client side stubs */
+ int mflag; /* server side stubs */
+ int nflag; /* netid flag */
+ int sflag; /* server stubs for the given transport */
+ int tflag; /* dispatch Table file */
+ int Ssflag; /* produce server sample code */
+ int Scflag; /* produce client sample code */
+ const char *infile; /* input module name */
+ const char *outfile; /* output module name */
};
-static char *cmdname;
-static char CPP[] = "/lib/cpp";
+
+static const char *cmdname;
+
+static const char *svcclosetime = "120";
+static const char *CPP = SVR4_CPP;
static char CPPFLAGS[] = "-C";
-static char *allv[] = {
+static char pathbuf[MAXPATHLEN + 1];
+static const char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp",
};
static int allc = sizeof(allv)/sizeof(allv[0]);
+static const char *allnv[] = {
+ "rpcgen", "-s", "netpath",
+};
+static int allnc = sizeof(allnv)/sizeof(allnv[0]);
+
+/*
+ * machinations for handling expanding argument list
+ */
+static void addarg(const char *); /* add another argument to the list */
+static void putarg(int, const char *); /* put argument at specified location */
+static void clear_args(void); /* clear argument list */
+static void checkfiles(const char *, const char *);
+ /* check if out file already exists */
+
+static void clear_args(void);
+static char *extendfile(const char *file, const char *ext);
+static void open_output(const char *infile, const char *outfile);
+static void add_warning(void);
+static void clear_args(void);
+static void find_cpp(void);
+static void open_input(const char *infile, const char *define);
+static int check_nettype(const char *name, const char *list_to_check[]);
+static void c_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static void h_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static void s_output(int argc, const char *argv[], const char *infile,
+ const char *define, int extend,
+ const char *outfile, int nomain, int netflag);
+static void l_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static void t_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static void svc_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static void clnt_output(const char *infile, const char *define,
+ int extend, const char *outfile);
+static int do_registers(int argc, const char *argv[]);
+static void addarg(const char *cp);
+static void putarg(int whereto, const char *cp);
+static void checkfiles(const char *infile, const char *outfile);
+static int parseargs(int argc, const char *argv[], struct commandline *cmd);
+static void usage(void);
+static void options_usage(void);
+static void c_initialize(void);
+static char *generate_guard(const char *pathname);
+
+
+#define ARGLISTLEN 20
+#define FIXEDARGS 2
+
+static const char *arglist[ARGLISTLEN];
+static int argcount = FIXEDARGS;
+
+
+int nonfatalerrors; /* errors */
+int inetdflag/* = 1*/; /* Support for inetd */ /* is now the default */
+int pmflag; /* Support for port monitors */
+int logflag; /* Use syslog instead of fprintf for errors */
+int tblflag; /* Support for dispatch table file */
-main(argc, argv)
- int argc;
- char *argv[];
+#define INLINE 3
+/*length at which to start doing an inline */
+int inlineflag=INLINE; /* length at which to start doing an inline. 3 = default
+ if 0, no xdr_inline code */
+
+int indefinitewait; /* If started by port monitors, hang till it wants */
+int exitnow; /* If started by port monitors, exit after the call */
+int timerflag; /* TRUE if !indefinite && !exitnow */
+int newstyle; /* newstyle of passing arguments (by value) */
+#ifdef __GNU_LIBRARY__
+int Cflag = 1 ; /* ANSI C syntax */
+#else
+int Cflag = 0 ; /* ANSI C syntax */
+#endif
+static int allfiles; /* generate all files */
+#ifdef __GNU_LIBRARY__
+int tirpcflag = 0; /* generating code for tirpc, by default */
+#else
+int tirpcflag = 1; /* generating code for tirpc, by default */
+#endif
+
+int
+main(int argc, const char *argv[])
{
struct commandline cmd;
- /* Use the libc message catalog for translations. */
- textdomain (_libc_intl_domainname);
+ (void) memset((char *)&cmd, 0, sizeof (struct commandline));
+ clear_args();
+ if (!parseargs(argc, argv, &cmd))
+ usage();
- if (!parseargs(argc, argv, &cmd)) {
- f_print(stderr,
- _("usage: %s infile\n"), cmdname);
- f_print(stderr,
- _(" %s [-c | -h | -l | -m] [-o outfile] [infile]\n"),
- cmdname);
- f_print(stderr,
- _(" %s [-s udp|tcp]* [-o outfile] [infile]\n"),
- cmdname);
- exit(1);
+ if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
+ cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag ) {
+ checkfiles(cmd.infile, cmd.outfile);
}
+ else
+ checkfiles(cmd.infile,NULL);
+
if (cmd.cflag) {
- c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile);
+ c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
} else if (cmd.hflag) {
- h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile);
+ h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
} else if (cmd.lflag) {
- l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile);
- } else if (cmd.sflag || cmd.mflag) {
- s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND,
- cmd.outfile, cmd.mflag);
+ l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
+ } else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
+ s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
+ cmd.outfile, cmd.mflag, cmd.nflag);
+ } else if (cmd.tflag) {
+ t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
+ } else if (cmd.Ssflag) {
+ svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
+ } else if (cmd.Scflag) {
+ clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
} else {
+ /* the rescans are required, since cpp may effect input */
c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
reinitialize();
h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
reinitialize();
l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
reinitialize();
- s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
- "_svc.c", cmd.mflag);
+ if (inetdflag || !tirpcflag )
+ s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
+ "_svc.c", cmd.mflag, cmd.nflag);
+ else
+ s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
+ EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
+ if (tblflag) {
+ reinitialize();
+ t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
+ }
+ if (allfiles) {
+ reinitialize();
+ svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
+ }
+ if (allfiles) {
+ reinitialize();
+ clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
+ }
}
- exit(0);
+ exit(nonfatalerrors);
+ /* NOTREACHED */
}
/*
* add extension to filename
*/
static char *
-extendfile(file, ext)
- char *file;
- char *ext;
+extendfile(const char *file, const char *ext)
{
char *res;
- char *p;
+ const char *p;
res = alloc(strlen(file) + strlen(ext) + 1);
if (res == NULL) {
abort();
}
- p = rindex(file, '.');
+ p = strrchr(file, '.');
if (p == NULL) {
p = file + strlen(file);
}
@@ -133,36 +255,78 @@ extendfile(file, ext)
/*
* Open output file with given extension
*/
-static
-open_output(infile, outfile)
- char *infile;
- char *outfile;
+static void
+open_output(const char *infile, const char *outfile)
{
+
if (outfile == NULL) {
fout = stdout;
return;
}
+
if (infile != NULL && streq(outfile, infile)) {
- f_print(stderr, _("%s: output would overwrite %s\n"), cmdname,
+ f_print(stderr, "%s: output would overwrite %s\n", cmdname,
infile);
crash();
}
fout = fopen(outfile, "w");
if (fout == NULL) {
- f_print(stderr, _("%s: unable to open "), cmdname);
+ f_print(stderr, "%s: unable to open ", cmdname);
perror(outfile);
crash();
}
record_open(outfile);
}
+static void
+add_warning(void)
+{
+ f_print(fout, "/*\n");
+ f_print(fout, " * Please do not edit this file.\n");
+ f_print(fout, " * It was generated using rpcgen.\n");
+ f_print(fout, " */\n\n");
+}
+
+static void
+add_stdheaders(void)
+{
+ f_print(fout, "#include <rpc/types.h>\n");
+ f_print(fout, "#include <rpc/xdr.h>\n\n");
+}
+
+/* clear list of arguments */
+static void clear_args(void)
+{
+ int i;
+ for( i=FIXEDARGS; i<ARGLISTLEN; i++ )
+ arglist[i] = NULL;
+ argcount = FIXEDARGS;
+}
+
+/* make sure that a CPP exists */
+static void find_cpp(void)
+{
+ struct stat buf;
+
+ if (stat(CPP, &buf) < 0 ) { /* SVR4 or explicit cpp does not exist */
+ if (cppDefined) {
+ fprintf( stderr, "cannot find C preprocessor: %s \n", CPP );
+ crash();
+ } else { /* try the other one */
+ CPP = SUNOS_CPP;
+ if( stat( CPP, &buf ) < 0 ) { /* can't find any cpp */
+ fprintf( stderr, "cannot find any C preprocessor (cpp)\n" );
+ crash();
+ }
+ }
+ }
+}
+
/*
* Open input file with given define for C-preprocessor
*/
-static
-open_input(infile, define)
- char *infile;
- char *define;
+static void
+open_input(const char *infile, const char *define)
{
int pd[2];
@@ -170,11 +334,17 @@ open_input(infile, define)
(void) pipe(pd);
switch (fork()) {
case 0:
+ find_cpp();
+ putarg(0, CPP);
+ putarg(1, CPPFLAGS);
+ addarg(define);
+ addarg(infile);
+ addarg((char *)NULL);
(void) close(1);
(void) dup2(pd[1], 1);
(void) close(pd[0]);
- execl(CPP, CPP, CPPFLAGS, define, infile, NULL);
- perror("execl");
+ execv(arglist[0], (char **)arglist);
+ perror("execv");
exit(1);
case -1:
perror("fork");
@@ -189,31 +359,67 @@ open_input(infile, define)
}
}
+/* valid tirpc nettypes */
+static const char *valid_ti_nettypes[] =
+{
+ "netpath",
+ "visible",
+ "circuit_v",
+ "datagram_v",
+ "circuit_n",
+ "datagram_n",
+ "udp",
+ "tcp",
+ "raw",
+ NULL
+ };
+
+/* valid inetd nettypes */
+static const char *valid_i_nettypes[] =
+{
+ "udp",
+ "tcp",
+ NULL
+};
+
+static int check_nettype(const char *name, const char *list_to_check[]) {
+ int i;
+ for( i = 0; list_to_check[i] != NULL; i++ ) {
+ if( strcmp( name, list_to_check[i] ) == 0 ) {
+ return 1;
+ }
+ }
+ f_print( stderr, "illegal nettype :\'%s\'\n", name );
+ return 0;
+}
+
/*
* Compile into an XDR routine output file
*/
-static
-c_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+
+static void
+c_output(const char *infile, const char *define, int extend,
+ const char *outfile)
{
definition *def;
char *include;
- char *outfilename;
+ const char *outfilename;
long tell;
+ c_initialize();
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
- f_print(fout, "#include <rpc/rpc.h>\n");
+ add_warning();
+ add_stdheaders();
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
- }
+ /* .h file already contains rpc/rpc.h */
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
tell = ftell(fout);
- while (def = get_definition()) {
+ while ((def = get_definition())!=NULL) {
emit(def);
}
if (extend && tell == ftell(fout)) {
@@ -221,99 +427,236 @@ c_output(infile, define, extend, outfile)
}
}
+void
+c_initialize(void)
+{
+
+ /* add all the starting basic types */
+
+ add_type(1,"int");
+ add_type(1,"long");
+ add_type(1,"short");
+ add_type(1,"bool");
+
+ add_type(1,"u_int");
+ add_type(1,"u_long");
+ add_type(1,"u_short");
+
+}
+
+char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
+ char *(*proc)();\n\
+ xdrproc_t xdr_arg;\n\
+ unsigned len_arg;\n\
+ xdrproc_t xdr_res;\n\
+ unsigned len_res;\n\
+};\n";
+
+
+static char *generate_guard(const char *pathname) {
+ const char *filename;
+ char *guard, *tmp;
+
+ filename = strrchr(pathname, '/' ); /* find last component */
+ filename = ((filename == NULL) ? pathname : filename+1);
+ guard = strdup(filename);
+ /* convert to upper case */
+ tmp = guard;
+ while (*tmp) {
+ if (islower(*tmp))
+ *tmp = toupper(*tmp);
+ tmp++;
+ }
+
+ guard = extendfile(guard, "_H_RPCGEN");
+ return guard;
+}
+
/*
* Compile into an XDR header file
*/
-static
-h_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+
+
+static void
+h_output(const char *infile, const char *define, int extend,
+ const char *outfile)
{
definition *def;
- char *outfilename;
+ const char *ifilename;
+ const char *outfilename;
long tell;
+ char *guard;
+ list *l;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
+ add_warning();
+ ifilename = (infile == NULL) ? "STDIN" : infile;
+ guard = generate_guard( outfilename ? outfilename: ifilename );
+
+ f_print(fout,"#ifndef _%s\n#define _%s\n\n", guard,
+ guard);
+
+ f_print(fout, "#include <rpc/rpc.h>\n\n");
+
tell = ftell(fout);
- while (def = get_definition()) {
+ /* print data definitions */
+ while ((def = get_definition())!=NULL) {
print_datadef(def);
}
+
+ /* print function declarations.
+ Do this after data definitions because they might be used as
+ arguments for functions */
+ for (l = defined; l != NULL; l = l->next) {
+ print_funcdef(l->val);
+ }
if (extend && tell == ftell(fout)) {
(void) unlink(outfilename);
+ } else if (tblflag) {
+ f_print(fout, rpcgen_table_dcl);
}
+ f_print(fout, "\n#endif /* !_%s */\n", guard);
}
/*
* Compile into an RPC service
*/
-static
-s_output(argc, argv, infile, define, extend, outfile, nomain)
- int argc;
- char *argv[];
- char *infile;
- char *define;
- int extend;
- char *outfile;
- int nomain;
+static void
+s_output(int argc, const char *argv[], const char *infile, const char *define,
+ int extend, const char *outfile, int nomain, int netflag)
{
char *include;
definition *def;
- int foundprogram;
- char *outfilename;
+ int foundprogram = 0;
+ const char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
- f_print(fout, "#include <stdio.h>\n");
- f_print(fout, "#include <rpc/rpc.h>\n");
+ add_warning();
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+
+ f_print(fout, "#include <stdio.h>\n");
+ f_print(fout, "#include <stdlib.h>/* getenv, exit */\n");
+ if (Cflag) {
+ f_print (fout, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
+ f_print (fout, "#include <string.h> /* strcmp */ \n");
+ }
+ if (strcmp(svcclosetime, "-1") == 0)
+ indefinitewait = 1;
+ else if (strcmp(svcclosetime, "0") == 0)
+ exitnow = 1;
+ else if (inetdflag || pmflag) {
+ f_print(fout, "#include <signal.h>\n");
+ timerflag = 1;
+ }
+
+ if( !tirpcflag && inetdflag )
+#ifdef __GNU_LIBRARY__
+ f_print(fout, "#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */\n");
+#else
+ f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
+#endif
+ if( Cflag && (inetdflag || pmflag ) ) {
+#ifdef __GNU_LIBRARY__
+ f_print(fout, "#include <sys/types.h> /* open */\n");
+ f_print(fout, "#include <sys/stat.h> /* open */\n");
+ f_print(fout, "#include <fcntl.h> /* open */\n");
+ f_print(fout, "#include <unistd.h> /* getdtablesize */\n");
+#else
+ f_print(fout, "#ifdef __cplusplus\n");
+ f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n");
+ f_print(fout, "#endif /* __cplusplus */\n");
+#endif
+ if( tirpcflag )
+ f_print(fout, "#include <unistd.h> /* setsid */\n");
+ }
+ if( tirpcflag )
+ f_print(fout, "#include <sys/types.h>\n");
+
+ f_print(fout, "#include <memory.h>\n");
+#ifndef __GNU_LIBRARY__
+ f_print(fout, "#include <stropts.h>\n");
+#endif
+ if (inetdflag || !tirpcflag ) {
+ f_print(fout, "#include <sys/socket.h>\n");
+ f_print(fout, "#include <netinet/in.h>\n");
+ }
+
+ if ( (netflag || pmflag) && tirpcflag ) {
+ f_print(fout, "#include <netconfig.h>\n");
+ }
+ if (/*timerflag &&*/ tirpcflag)
+ f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
+ if (logflag || inetdflag || pmflag) {
+#ifdef __GNU_LIBRARY__
+ f_print(fout, "#include <syslog.h>\n");
+#else
+ f_print(fout, "#ifdef SYSLOG\n");
+ f_print(fout, "#include <syslog.h>\n");
+ f_print(fout, "#else\n");
+ f_print(fout, "#define LOG_ERR 1\n");
+ f_print(fout, "#define openlog(a, b, c)\n");
+ f_print(fout, "#endif\n");
+#endif
}
- foundprogram = 0;
- while (def = get_definition()) {
+
+ /* for ANSI-C */
+ f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
+
+#ifndef __GNU_LIBRARY__
+ f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
+#endif
+ if (timerflag)
+ f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime);
+ while ((def = get_definition())!=NULL) {
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram) {
(void) unlink(outfilename);
return;
}
- if (nomain) {
- write_programs((char *)NULL);
- } else {
- write_most();
- do_registers(argc, argv);
+ write_most(infile, netflag, nomain);
+ if (!nomain) {
+ if( !do_registers(argc, argv) ) {
+ if (outfilename)
+ (void) unlink(outfilename);
+ usage();
+ }
write_rest();
- write_programs("static");
}
}
-static
-l_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+/*
+ * generate client side stubs
+ */
+static void
+l_output(const char *infile, const char *define, int extend,
+ const char *outfile)
{
char *include;
definition *def;
- int foundprogram;
- char *outfilename;
+ int foundprogram = 0;
+ const char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
- f_print(fout, "#include <rpc/rpc.h>\n");
+ add_warning();
+ if (Cflag)
+ f_print (fout, "#include <memory.h> /* for memset */\n");
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
- }
- foundprogram = 0;
- while (def = get_definition()) {
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+ while ((def = get_definition())!=NULL) {
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram) {
@@ -324,37 +667,195 @@ l_output(infile, define, extend, outfile)
}
/*
- * Perform registrations for service output
+ * generate the dispatch table
*/
-static
-do_registers(argc, argv)
- int argc;
- char *argv[];
+static void
+t_output(const char *infile, const char *define, int extend,
+ const char *outfile)
+{
+ definition *def;
+ int foundprogram = 0;
+ const char *outfilename;
+
+ open_input(infile, define);
+ outfilename = extend ? extendfile(infile, outfile) : outfile;
+ open_output(infile, outfilename);
+ add_warning();
+ while ((def = get_definition())!=NULL) {
+ foundprogram |= (def->def_kind == DEF_PROGRAM);
+ }
+ if (extend && !foundprogram) {
+ (void) unlink(outfilename);
+ return;
+ }
+ write_tables();
+}
+
+/* sample routine for the server template */
+static void
+svc_output(const char *infile, const char *define, int extend,
+ const char *outfile)
+{
+ definition *def;
+ char *include;
+ const char *outfilename;
+ long tell;
+
+ open_input(infile, define);
+ outfilename = extend ? extendfile(infile, outfile) : outfile;
+ checkfiles(infile,outfilename); /*check if outfile already exists.
+ if so, print an error message and exit*/
+ open_output(infile, outfilename);
+ add_sample_msg();
+
+ if (infile && (include = extendfile(infile, ".h"))) {
+ f_print(fout, "#include \"%s\"\n", include);
+ free(include);
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+
+ tell = ftell(fout);
+ while ((def = get_definition())!=NULL) {
+ write_sample_svc(def);
+ }
+ if (extend && tell == ftell(fout)) {
+ (void) unlink(outfilename);
+ }
+}
+
+
+/* sample main routine for client */
+static void
+clnt_output(const char *infile, const char *define, int extend,
+ const char *outfile)
+{
+ definition *def;
+ char *include;
+ const char *outfilename;
+ long tell;
+ int has_program = 0;
+ open_input(infile, define);
+ outfilename = extend ? extendfile(infile, outfile) : outfile;
+ checkfiles(infile,outfilename); /*check if outfile already exists.
+ if so, print an error message and exit*/
+
+ open_output(infile, outfilename);
+ add_sample_msg();
+ if (infile && (include = extendfile(infile, ".h"))) {
+ f_print(fout, "#include \"%s\"\n", include);
+ free(include);
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+ tell = ftell(fout);
+ while ((def = get_definition())!=NULL) {
+ has_program += write_sample_clnt(def);
+ }
+
+ if( has_program )
+ write_sample_clnt_main();
+
+ if (extend && tell == ftell(fout)) {
+ (void) unlink(outfilename);
+ }
+}
+
+/*
+ * Perform registrations for service output
+ * Return 0 if failed; 1 otherwise.
+ */
+static int do_registers(int argc, const char *argv[])
{
int i;
- for (i = 1; i < argc; i++) {
- if (streq(argv[i], "-s")) {
- write_register(argv[i + 1]);
- i++;
+ if ( inetdflag || !tirpcflag) {
+ for (i = 1; i < argc; i++) {
+ if (streq(argv[i], "-s")) {
+ if(!check_nettype( argv[i + 1], valid_i_nettypes ))
+ return 0;
+ write_inetd_register(argv[i + 1]);
+ i++;
+ }
}
+ } else {
+ for (i = 1; i < argc; i++)
+ if (streq(argv[i], "-s")) {
+ if(!check_nettype( argv[i + 1], valid_ti_nettypes ))
+ return 0;
+ write_nettype_register(argv[i + 1]);
+ i++;
+ } else if (streq(argv[i], "-n")) {
+ write_netid_register(argv[i + 1]);
+ i++;
+ }
}
+ return 1;
}
/*
- * Parse command line arguments
+ * Add another argument to the arg list
*/
-static
-parseargs(argc, argv, cmd)
- int argc;
- char *argv[];
- struct commandline *cmd;
+static void
+addarg(const char *cp)
+{
+ if (argcount >= ARGLISTLEN) {
+ f_print(stderr, "rpcgen: too many defines\n");
+ crash();
+ /*NOTREACHED*/
+ }
+ arglist[argcount++] = cp;
+
+}
+
+static void
+putarg(int whereto, const char *cp)
+{
+ if (whereto >= ARGLISTLEN) {
+ f_print(stderr, "rpcgen: arglist coding error\n");
+ crash();
+ /*NOTREACHED*/
+ }
+ arglist[whereto] = cp;
+}
+/*
+ * if input file is stdin and an output file is specified then complain
+ * if the file already exists. Otherwise the file may get overwritten
+ * If input file does not exist, exit with an error
+ */
+
+static void
+checkfiles(const char *infile, const char *outfile)
+{
+
+ struct stat buf;
+
+ if(infile) /* infile ! = NULL */
+ if(stat(infile,&buf) < 0)
+ {
+ perror(infile);
+ crash();
+ };
+ if (outfile) {
+ if (stat(outfile, &buf) < 0)
+ return; /* file does not exist */
+ else {
+ f_print(stderr,
+ "file '%s' already exists and may be overwritten\n", outfile);
+ crash();
+ }
+ }
+}
+
+/*
+ * Parse command line arguments
+ */
+static int
+parseargs(int argc, const char *argv[], struct commandline *cmd)
{
int i;
int j;
- char c;
+ int c;
char flag[(1 << 8 * sizeof(char))];
int nflags;
@@ -363,15 +864,22 @@ parseargs(argc, argv, cmd)
if (argc < 2) {
return (0);
}
+ allfiles = 0;
flag['c'] = 0;
flag['h'] = 0;
- flag['s'] = 0;
- flag['o'] = 0;
flag['l'] = 0;
flag['m'] = 0;
+ flag['o'] = 0;
+ flag['s'] = 0;
+ flag['n'] = 0;
+ flag['t'] = 0;
+ flag['S'] = 0;
+ flag['C'] = 0;
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
if (cmd->infile) {
+ f_print( stderr, "Cannot specify more than one input file!\n");
+
return (0);
}
cmd->infile = argv[i];
@@ -379,15 +887,85 @@ parseargs(argc, argv, cmd)
for (j = 1; argv[i][j] != 0; j++) {
c = argv[i][j];
switch (c) {
+ case 'a':
+ allfiles = 1;
+ break;
case 'c':
case 'h':
case 'l':
case 'm':
+ case 't':
if (flag[c]) {
return (0);
}
flag[c] = 1;
break;
+ case 'S':
+ /* sample flag: Ss or Sc.
+ Ss means set flag['S'];
+ Sc means set flag['C']; */
+ c = argv[i][++j]; /* get next char */
+ if( c == 's' )
+ c = 'S';
+ else if( c == 'c' )
+ c = 'C';
+ else
+ return( 0 );
+
+ if (flag[c]) {
+ return (0);
+ }
+ flag[c] = 1;
+ break;
+ case 'C': /* ANSI C syntax */
+ Cflag = 1;
+ break;
+
+#ifdef __GNU_LIBRARY__
+ case 'k': /* K&R C syntax */
+ Cflag = 0;
+ break;
+
+#endif
+ case 'b': /* turn TIRPC flag off for
+ generating backward compatible
+ */
+ tirpcflag = 0;
+ break;
+
+#ifdef __GNU_LIBRARY__
+ case '5': /* turn TIRPC flag on for
+ generating SysVr4 compatible
+ */
+ tirpcflag = 1;
+ break;
+
+#endif
+ case 'I':
+ inetdflag = 1;
+ break;
+ case 'N':
+ newstyle = 1;
+ break;
+ case 'L':
+ logflag = 1;
+ break;
+ case 'K':
+ if (++i == argc) {
+ return (0);
+ }
+ svcclosetime = argv[i];
+ goto nextarg;
+ case 'T':
+ tblflag = 1;
+ break;
+ case 'i' :
+ if (++i == argc) {
+ return (0);
+ }
+ inlineflag = atoi(argv[i]);
+ goto nextarg;
+ case 'n':
case 'o':
case 's':
if (argv[i][j - 1] != '-' ||
@@ -410,6 +988,23 @@ parseargs(argc, argv, cmd)
cmd->outfile = argv[i];
}
goto nextarg;
+ case 'D':
+ if (argv[i][j - 1] != '-') {
+ return (0);
+ }
+ (void) addarg(argv[i]);
+ goto nextarg;
+ case 'Y':
+ if (++i == argc) {
+ return (0);
+ }
+ (void) strcpy(pathbuf, argv[i]);
+ (void) strcat(pathbuf, "/cpp");
+ CPP = pathbuf;
+ cppDefined = 1;
+ goto nextarg;
+
+
default:
return (0);
@@ -419,18 +1014,93 @@ parseargs(argc, argv, cmd)
;
}
}
+
cmd->cflag = flag['c'];
cmd->hflag = flag['h'];
- cmd->sflag = flag['s'];
cmd->lflag = flag['l'];
cmd->mflag = flag['m'];
- nflags = cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag;
+ cmd->nflag = flag['n'];
+ cmd->sflag = flag['s'];
+ cmd->tflag = flag['t'];
+ cmd->Ssflag = flag['S'];
+ cmd->Scflag = flag['C'];
+
+ if( tirpcflag ) {
+ pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */
+ if( (inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */
+ f_print(stderr, "Cannot use netid flag with inetd flag!\n");
+ return (0);
+ }
+ } else { /* 4.1 mode */
+ pmflag = 0; /* set pmflag only in tirpcmode */
+#ifndef __GNU_LIBRARY__
+ inetdflag = 1; /* inetdflag is TRUE by default */
+#endif
+ if( cmd->nflag ) { /* netid needs TIRPC */
+ f_print( stderr, "Cannot use netid flag without TIRPC!\n");
+ return( 0 );
+ }
+ }
+
+ if( newstyle && ( tblflag || cmd->tflag) ) {
+ f_print( stderr, "Cannot use table flags with newstyle!\n");
+ return( 0 );
+ }
+
+ /* check no conflicts with file generation flags */
+ nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
+ cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
+
if (nflags == 0) {
if (cmd->outfile != NULL || cmd->infile == NULL) {
return (0);
}
} else if (nflags > 1) {
+ f_print( stderr, "Cannot have more than one file generation flag!\n");
return (0);
}
return (1);
}
+
+static void
+usage(void)
+{
+ f_print(stderr, "usage: %s infile\n", cmdname);
+ f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-L][-N][-T] infile\n",
+ cmdname);
+ f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
+ cmdname);
+ f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);
+ f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);
+ options_usage();
+ exit(1);
+}
+
+static void
+options_usage(void)
+{
+ f_print(stderr, "options:\n");
+ f_print(stderr, "-a\t\tgenerate all files, including samples\n");
+ f_print(stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
+ f_print(stderr, "-c\t\tgenerate XDR routines\n");
+ f_print(stderr, "-C\t\tANSI C mode\n");
+ f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
+ f_print(stderr, "-h\t\tgenerate header file\n");
+ f_print(stderr, "-i size\t\tsize at which to start generating inline code\n");
+ f_print(stderr, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
+ f_print(stderr, "-K seconds\tserver exits after K seconds of inactivity\n");
+ f_print(stderr, "-l\t\tgenerate client side stubs\n");
+ f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");
+ f_print(stderr, "-m\t\tgenerate server side stubs\n");
+ f_print(stderr, "-n netid\tgenerate server code that supports named netid\n");
+ f_print(stderr, "-N\t\tsupports multiple arguments and call-by-value\n");
+ f_print(stderr, "-o outfile\tname of the output file\n");
+ f_print(stderr, "-s nettype\tgenerate server code that supports named nettype\n");
+ f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
+ f_print(stderr, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
+ f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");
+ f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");
+ f_print(stderr, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");
+
+ exit(1);
+}
diff --git a/sunrpc/rpc_parse.c b/sunrpc/rpc_parse.c
index 325f75f..92f365e 100644
--- a/sunrpc/rpc_parse.c
+++ b/sunrpc/rpc_parse.c
@@ -1,11 +1,11 @@
-/* @(#)rpc_parse.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
@@ -27,24 +27,45 @@
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_parse.c 1.4 87/04/28 (C) 1987 SMI";
-#endif
/*
- * rpc_parse.c, Parser for the RPC protocol compiler
+ * From: @(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI
+ */
+char parse_rcsid[] =
+ "$Id$";
+
+/*
+ * rpc_parse.c, Parser for the RPC protocol compiler
* Copyright (C) 1987 Sun Microsystems, Inc.
*/
#include <stdio.h>
-#include "rpc_util.h"
+#include <string.h>
+#include "rpc/types.h"
#include "rpc_scan.h"
#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "proto.h"
+
+#define ARGNAME "arg"
+
+static void isdefined(definition *defp);
+static void def_struct(definition *defp);
+static void def_program(definition *defp);
+static void def_enum(definition *defp);
+static void def_const(definition *defp);
+static void def_union(definition *defp);
+static void check_type_name(const char *name, int new_type);
+static void def_typedef(definition *defp);
+static void get_declaration(declaration *dec, defkind dkind);
+static void get_prog_declaration(declaration *dec, defkind dkind, int num);
+static void get_type(const char **prefixp, const char **typep, defkind dkind);
+static void unsigned_dec(const char **typep);
/*
* return the next definition you see
*/
definition *
-get_definition()
+get_definition(void)
{
definition *defp;
token tok;
@@ -72,26 +93,22 @@ get_definition()
break;
case TOK_EOF:
return (NULL);
- break;
default:
- error(_("definition keyword expected"));
+ error("definition keyword expected");
}
scan(TOK_SEMICOLON, &tok);
isdefined(defp);
return (defp);
}
-static
-isdefined(defp)
- definition *defp;
+static void
+isdefined(definition *defp)
{
STOREVAL(&defined, defp);
}
-
-static
-def_struct(defp)
- definition *defp;
+static void
+def_struct(definition *defp)
{
token tok;
declaration dec;
@@ -117,21 +134,25 @@ def_struct(defp)
*tailp = NULL;
}
-static
-def_program(defp)
- definition *defp;
+static void
+def_program(definition *defp)
{
token tok;
+ declaration dec;
+ decl_list *decls;
+ decl_list **tailp;
version_list *vlist;
version_list **vtailp;
proc_list *plist;
proc_list **ptailp;
-
+ int num_args;
+ bool_t isvoid = FALSE; /* whether first argument is void */
defp->def_kind = DEF_PROGRAM;
scan(TOK_IDENT, &tok);
defp->def_name = tok.str;
scan(TOK_LBRACE, &tok);
vtailp = &defp->def.pr.versions;
+ tailp = &defp->def.st.decls;
scan(TOK_VERSION, &tok);
do {
scan(TOK_IDENT, &tok);
@@ -140,33 +161,74 @@ def_program(defp)
scan(TOK_LBRACE, &tok);
ptailp = &vlist->procs;
do {
+ /* get result type */
plist = ALLOC(proc_list);
- get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM);
+ get_type(&plist->res_prefix, &plist->res_type,
+ DEF_PROGRAM);
if (streq(plist->res_type, "opaque")) {
- error(_("illegal result type"));
+ error("illegal result type");
}
scan(TOK_IDENT, &tok);
plist->proc_name = tok.str;
scan(TOK_LPAREN, &tok);
- get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
- if (streq(plist->arg_type, "opaque")) {
- error("illegal argument type");
+ /* get args - first one*/
+ num_args = 1;
+ isvoid = FALSE;
+ /* type of DEF_PROGRAM in the first
+ * get_prog_declaration and DEF_STURCT in the next
+ * allows void as argument if it is the only argument
+ */
+ get_prog_declaration(&dec, DEF_PROGRAM, num_args);
+ if (streq(dec.type, "void"))
+ isvoid = TRUE;
+ decls = ALLOC(decl_list);
+ plist->args.decls = decls;
+ decls->decl = dec;
+ tailp = &decls->next;
+ /* get args */
+ while(peekscan(TOK_COMMA, &tok)) {
+ num_args++;
+ get_prog_declaration(&dec, DEF_STRUCT,
+ num_args);
+ decls = ALLOC(decl_list);
+ decls->decl = dec;
+ *tailp = decls;
+ if (streq(dec.type, "void"))
+ isvoid = TRUE;
+ tailp = &decls->next;
+ }
+ /* multiple arguments are only allowed in newstyle */
+ if( !newstyle && num_args > 1 ) {
+ error("only one argument is allowed" );
+ }
+ if (isvoid && num_args > 1) {
+ error("illegal use of void in program definition");
}
+ *tailp = NULL;
scan(TOK_RPAREN, &tok);
scan(TOK_EQUAL, &tok);
scan_num(&tok);
scan(TOK_SEMICOLON, &tok);
plist->proc_num = tok.str;
+ plist->arg_num = num_args;
*ptailp = plist;
ptailp = &plist->next;
peek(&tok);
} while (tok.kind != TOK_RBRACE);
+ *ptailp = NULL;
*vtailp = vlist;
vtailp = &vlist->next;
scan(TOK_RBRACE, &tok);
scan(TOK_EQUAL, &tok);
scan_num(&tok);
vlist->vers_num = tok.str;
+ /* make the argument structure name for each arg*/
+ for(plist = vlist->procs; plist != NULL;
+ plist = plist->next) {
+ plist->args.argname = make_argname(plist->proc_name,
+ vlist->vers_num);
+ /* free the memory ??*/
+ }
scan(TOK_SEMICOLON, &tok);
scan2(TOK_VERSION, TOK_RBRACE, &tok);
} while (tok.kind == TOK_VERSION);
@@ -176,9 +238,9 @@ def_program(defp)
*vtailp = NULL;
}
-static
-def_enum(defp)
- definition *defp;
+
+static void
+def_enum(definition *defp)
{
token tok;
enumval_list *elist;
@@ -206,9 +268,8 @@ def_enum(defp)
*tailp = NULL;
}
-static
-def_const(defp)
- definition *defp;
+static void
+def_const(definition *defp)
{
token tok;
@@ -220,72 +281,150 @@ def_const(defp)
defp->def.co = tok.str;
}
-static
-def_union(defp)
- definition *defp;
+static void
+def_union(definition *defp)
{
- token tok;
- declaration dec;
- case_list *cases;
- case_list **tailp;
+ token tok;
+ declaration dec;
+ case_list *cases;
+/* case_list *tcase; */
+ case_list **tailp;
+ int flag;
- defp->def_kind = DEF_UNION;
- scan(TOK_IDENT, &tok);
- defp->def_name = tok.str;
- scan(TOK_SWITCH, &tok);
- scan(TOK_LPAREN, &tok);
- get_declaration(&dec, DEF_UNION);
- defp->def.un.enum_decl = dec;
- tailp = &defp->def.un.cases;
- scan(TOK_RPAREN, &tok);
- scan(TOK_LBRACE, &tok);
- scan(TOK_CASE, &tok);
- while (tok.kind == TOK_CASE) {
- scan(TOK_IDENT, &tok);
- cases = ALLOC(case_list);
- cases->case_name = tok.str;
- scan(TOK_COLON, &tok);
- get_declaration(&dec, DEF_UNION);
- cases->case_decl = dec;
- *tailp = cases;
- tailp = &cases->next;
- scan(TOK_SEMICOLON, &tok);
- scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
- }
- *tailp = NULL;
- if (tok.kind == TOK_DEFAULT) {
- scan(TOK_COLON, &tok);
- get_declaration(&dec, DEF_UNION);
- defp->def.un.default_decl = ALLOC(declaration);
- *defp->def.un.default_decl = dec;
- scan(TOK_SEMICOLON, &tok);
- scan(TOK_RBRACE, &tok);
- } else {
- defp->def.un.default_decl = NULL;
- }
+ defp->def_kind = DEF_UNION;
+ scan(TOK_IDENT, &tok);
+ defp->def_name = tok.str;
+ scan(TOK_SWITCH, &tok);
+ scan(TOK_LPAREN, &tok);
+ get_declaration(&dec, DEF_UNION);
+ defp->def.un.enum_decl = dec;
+ tailp = &defp->def.un.cases;
+ scan(TOK_RPAREN, &tok);
+ scan(TOK_LBRACE, &tok);
+ scan(TOK_CASE, &tok);
+ while (tok.kind == TOK_CASE) {
+ scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+ cases = ALLOC(case_list);
+ cases->case_name = tok.str;
+ scan(TOK_COLON, &tok);
+ /* now peek at next token */
+ flag=0;
+ if(peekscan(TOK_CASE,&tok))
+ {
+
+ do
+ {
+ scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+ cases->contflag=1; /* continued case statement */
+ *tailp = cases;
+ tailp = &cases->next;
+ cases = ALLOC(case_list);
+ cases->case_name = tok.str;
+ scan(TOK_COLON, &tok);
+
+ }while(peekscan(TOK_CASE,&tok));
+ }
+ else
+ if(flag)
+ {
+
+ *tailp = cases;
+ tailp = &cases->next;
+ cases = ALLOC(case_list);
+ };
+
+ get_declaration(&dec, DEF_UNION);
+ cases->case_decl = dec;
+ cases->contflag=0; /* no continued case statement */
+ *tailp = cases;
+ tailp = &cases->next;
+ scan(TOK_SEMICOLON, &tok);
+
+ scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
+ }
+ *tailp = NULL;
+ if (tok.kind == TOK_DEFAULT) {
+ scan(TOK_COLON, &tok);
+ get_declaration(&dec, DEF_UNION);
+ defp->def.un.default_decl = ALLOC(declaration);
+ *defp->def.un.default_decl = dec;
+ scan(TOK_SEMICOLON, &tok);
+ scan(TOK_RBRACE, &tok);
+ } else {
+ defp->def.un.default_decl = NULL;
+ }
}
+static const char *reserved_words[] =
+{
+ "array",
+ "bytes",
+ "destroy",
+ "free",
+ "getpos",
+ "inline",
+ "pointer",
+ "reference",
+ "setpos",
+ "sizeof",
+ "union",
+ "vector",
+ NULL
+ };
-static
-def_typedef(defp)
- definition *defp;
+static const char *reserved_types[] =
+{
+ "opaque",
+ "string",
+ NULL
+ };
+
+/*
+ * check that the given name is not one that would eventually result in
+ * xdr routines that would conflict with internal XDR routines.
+ */
+static void check_type_name(const char *name, int new_type)
+{
+ int i;
+ char tmp[100];
+
+ for( i = 0; reserved_words[i] != NULL; i++ ) {
+ if( strcmp( name, reserved_words[i] ) == 0 ) {
+ sprintf(tmp,
+ "illegal (reserved) name :\'%s\' in type definition", name );
+ error(tmp);
+ }
+ }
+ if( new_type ) {
+ for( i = 0; reserved_types[i] != NULL; i++ ) {
+ if( strcmp( name, reserved_types[i] ) == 0 ) {
+ sprintf(tmp,
+ "illegal (reserved) name :\'%s\' in type definition", name );
+ error(tmp);
+ }
+ }
+ }
+}
+
+
+
+static void
+def_typedef(definition *defp)
{
declaration dec;
defp->def_kind = DEF_TYPEDEF;
get_declaration(&dec, DEF_TYPEDEF);
defp->def_name = dec.name;
+ check_type_name(dec.name, 1);
defp->def.ty.old_prefix = dec.prefix;
defp->def.ty.old_type = dec.type;
defp->def.ty.rel = dec.rel;
defp->def.ty.array_max = dec.array_max;
}
-
-static
-get_declaration(dec, dkind)
- declaration *dec;
- defkind dkind;
+static void
+get_declaration(declaration *dec, defkind dkind)
{
token tok;
@@ -294,6 +433,9 @@ get_declaration(dec, dkind)
if (streq(dec->type, "void")) {
return;
}
+
+ check_type_name(dec->type, 0);
+
scan2(TOK_STAR, TOK_IDENT, &tok);
if (tok.kind == TOK_STAR) {
dec->rel = REL_POINTER;
@@ -302,7 +444,7 @@ get_declaration(dec, dkind)
dec->name = tok.str;
if (peekscan(TOK_LBRACKET, &tok)) {
if (dec->rel == REL_POINTER) {
- error(_("no array-of-pointer declarations -- use typedef"));
+ error("no array-of-pointer declarations -- use typedef");
}
dec->rel = REL_VECTOR;
scan_num(&tok);
@@ -310,7 +452,7 @@ get_declaration(dec, dkind)
scan(TOK_RBRACKET, &tok);
} else if (peekscan(TOK_LANGLE, &tok)) {
if (dec->rel == REL_POINTER) {
- error(_("no array-of-pointer declarations -- use typedef"));
+ error("no array-of-pointer declarations -- use typedef");
}
dec->rel = REL_ARRAY;
if (peekscan(TOK_RANGLE, &tok)) {
@@ -323,21 +465,84 @@ get_declaration(dec, dkind)
}
if (streq(dec->type, "opaque")) {
if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
- error(_("array declaration expected"));
+ error("array declaration expected");
}
} else if (streq(dec->type, "string")) {
if (dec->rel != REL_ARRAY) {
- error(_("variable-length array declaration expected"));
+ error("variable-length array declaration expected");
}
}
}
-static
-get_type(prefixp, typep, dkind)
- char **prefixp;
- char **typep;
- defkind dkind;
+static void
+get_prog_declaration(declaration *dec, defkind dkind, int num /* arg number */)
+{
+ token tok;
+ char name[10]; /* argument name */
+
+ if (dkind == DEF_PROGRAM) {
+ peek(&tok);
+ if (tok.kind == TOK_RPAREN) { /* no arguments */
+ dec->rel = REL_ALIAS;
+ dec->type = "void";
+ dec->prefix = NULL;
+ dec->name = NULL;
+ return;
+ }
+ }
+ get_type(&dec->prefix, &dec->type, dkind);
+ dec->rel = REL_ALIAS;
+ if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */
+ strcpy(name, tok.str);
+ else
+ sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */
+
+ dec->name = (char *) strdup(name);
+
+ if (streq(dec->type, "void")) {
+ return;
+ }
+
+ if (streq(dec->type, "opaque")) {
+ error("opaque -- illegal argument type");
+ }
+ if (peekscan(TOK_STAR, &tok)) {
+ if (streq(dec->type, "string")) {
+ error("pointer to string not allowed in program arguments\n");
+ }
+ dec->rel = REL_POINTER;
+ if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */
+ dec->name = strdup(tok.str);
+ }
+ if (peekscan(TOK_LANGLE, &tok)) {
+ if (!streq(dec->type, "string")) {
+ error("arrays cannot be declared as arguments to procedures -- use typedef");
+ }
+ dec->rel = REL_ARRAY;
+ if (peekscan(TOK_RANGLE, &tok)) {
+ dec->array_max = "~0";/* unspecified size, use max */
+ } else {
+ scan_num(&tok);
+ dec->array_max = tok.str;
+ scan(TOK_RANGLE, &tok);
+ }
+ }
+ if (streq(dec->type, "string")) {
+ if (dec->rel != REL_ARRAY) { /* .x specifies just string as
+ * type of argument
+ * - make it string<>
+ */
+ dec->rel = REL_ARRAY;
+ dec->array_max = "~0";/* unspecified size, use max */
+ }
+ }
+}
+
+
+
+static void
+get_type(const char **prefixp, const char **typep, defkind dkind)
{
token tok;
@@ -367,7 +572,7 @@ get_type(prefixp, typep, dkind)
break;
case TOK_VOID:
if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
- error(_("voids allowed only inside union and program definitions"));
+ error("voids allowed only inside union and program definitions with one argument");
}
*typep = tok.str;
break;
@@ -381,14 +586,12 @@ get_type(prefixp, typep, dkind)
*typep = tok.str;
break;
default:
- error(_("expected type specifier"));
+ error("expected type specifier");
}
}
-
-static
-unsigned_dec(typep)
- char **typep;
+static void
+unsigned_dec(const char **typep)
{
token tok;
diff --git a/sunrpc/rpc_parse.h b/sunrpc/rpc_parse.h
index b53cc56..07c1f67 100644
--- a/sunrpc/rpc_parse.h
+++ b/sunrpc/rpc_parse.h
@@ -4,33 +4,34 @@
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-/* @(#)rpc_parse.h 1.3 87/03/09 (C) 1987 SMI */
+
+/* @(#)rpc_parse.h 1.3 90/08/29 (C) 1987 SMI */
/*
* rpc_parse.h, Definitions for the RPCL parser
- * Copyright (C) 1987, Sun Microsystems, Inc.
*/
enum defkind {
@@ -43,7 +44,7 @@ enum defkind {
};
typedef enum defkind defkind;
-typedef char *const_def;
+typedef const char *const_def;
enum relation {
REL_VECTOR, /* fixed length array */
@@ -54,17 +55,16 @@ enum relation {
typedef enum relation relation;
struct typedef_def {
- char *old_prefix;
- char *old_type;
+ const char *old_prefix;
+ const char *old_type;
relation rel;
- char *array_max;
+ const char *array_max;
};
typedef struct typedef_def typedef_def;
-
struct enumval_list {
- char *name;
- char *assignment;
+ const char *name;
+ const char *assignment;
struct enumval_list *next;
};
typedef struct enumval_list enumval_list;
@@ -74,17 +74,15 @@ struct enum_def {
};
typedef struct enum_def enum_def;
-
struct declaration {
- char *prefix;
- char *type;
- char *name;
+ const char *prefix;
+ const char *type;
+ const char *name;
relation rel;
- char *array_max;
+ const char *array_max;
};
typedef struct declaration declaration;
-
struct decl_list {
declaration decl;
struct decl_list *next;
@@ -96,9 +94,9 @@ struct struct_def {
};
typedef struct struct_def struct_def;
-
struct case_list {
- char *case_name;
+ const char *case_name;
+ int contflag;
declaration case_decl;
struct case_list *next;
};
@@ -111,36 +109,40 @@ struct union_def {
};
typedef struct union_def union_def;
-
+struct arg_list {
+ const char *argname; /* name of struct for arg*/
+ decl_list *decls;
+};
+
+typedef struct arg_list arg_list;
struct proc_list {
- char *proc_name;
- char *proc_num;
- char *arg_type;
- char *arg_prefix;
- char *res_type;
- char *res_prefix;
+ const char *proc_name;
+ const char *proc_num;
+ arg_list args;
+ int arg_num;
+ const char *res_type;
+ const char *res_prefix;
struct proc_list *next;
};
typedef struct proc_list proc_list;
-
struct version_list {
- char *vers_name;
- char *vers_num;
+ const char *vers_name;
+ const char *vers_num;
proc_list *procs;
struct version_list *next;
};
typedef struct version_list version_list;
struct program_def {
- char *prog_num;
+ const char *prog_num;
version_list *versions;
};
typedef struct program_def program_def;
struct definition {
- char *def_name;
+ const char *def_name;
defkind def_kind;
union {
const_def co;
@@ -153,5 +155,14 @@ struct definition {
};
typedef struct definition definition;
-/* @(#)rpc_parse.h 2.1 88/08/01 4.0 RPCSRC */
-definition *get_definition();
+definition *get_definition(void);
+
+
+struct bas_type
+{
+ const char *name;
+ int length;
+ struct bas_type *next;
+};
+
+typedef struct bas_type bas_type;
diff --git a/sunrpc/rpc_sample.c b/sunrpc/rpc_sample.c
new file mode 100644
index 0000000..a5551d9
--- /dev/null
+++ b/sunrpc/rpc_sample.c
@@ -0,0 +1,253 @@
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+/*
+ * From: @(#)rpc_sample.c 1.1 90/08/30 (C) 1987 SMI
+ */
+char sample_rcsid[] =
+ "$Id$";
+
+/*
+ * rpc_sample.c, Sample client-server code outputter for the RPC protocol compiler
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "proto.h"
+
+
+static char RQSTP[] = "rqstp";
+
+static void write_sample_client(const char *program_name, version_list *vp);
+static void write_sample_server(definition *def);
+static void return_type(proc_list *plist);
+
+
+void
+write_sample_svc(definition *def)
+{
+
+ if (def->def_kind != DEF_PROGRAM)
+ return;
+ write_sample_server(def);
+}
+
+
+int
+write_sample_clnt(definition *def)
+{
+ version_list *vp;
+ int count = 0;
+
+ 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) {
+ write_sample_client(def->def_name, vp );
+ ++count;
+ }
+ return( count );
+}
+
+
+static void
+write_sample_client(const char *program_name, version_list *vp)
+{
+ proc_list *proc;
+ int i;
+ decl_list *l;
+
+ f_print(fout, "\n\nvoid\n" );
+ pvname( program_name, vp->vers_num );
+ if( Cflag )
+ f_print(fout,"( char* host )\n{\n" );
+ else
+ f_print(fout, "(host)\nchar *host;\n{\n" );
+ f_print(fout, "\tCLIENT *clnt;\n");
+
+ i = 0;
+ 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) {
+ f_print( fout, "\t" );
+ if( !streq( proc->args.decls->decl.type, "void") )
+ ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+ else
+ f_print(fout, "char* "); /* cannot have "void" type */
+ 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) {
+ f_print( fout, "\t" );
+ ptype(l->decl.prefix, l->decl.type, 1);
+ f_print( fout, " ");
+ pvname( proc->proc_name, vp->vers_num );
+ f_print(fout, "_%s;\n", l->decl.name );
+/* pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );*/
+ }
+ }
+ }
+
+ /* generate creation of client handle */
+ f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
+ program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
+ f_print(fout, "\tif (clnt == NULL) {\n");
+ f_print(fout, "\t\tclnt_pcreateerror(host);\n");
+ f_print(fout, "\t\texit(1);\n\t}\n");
+
+ /* generate calls to procedures */
+ i = 0;
+ 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) {
+ 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")) {
+ f_print(fout, "(clnt);\n");
+ }
+ else {
+ f_print(fout, "(");
+ for (l = proc->args.decls; l != NULL; l = l->next) {
+ pvname( proc->proc_name, vp->vers_num );
+ f_print(fout, "_%s, ", l->decl.name);
+ }
+ f_print(fout, "clnt);\n");
+ }
+ f_print(fout, "\tif (result_%d == NULL) {\n", i);
+ f_print(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
+ f_print(fout, "\t}\n");
+ }
+
+ f_print(fout, "\tclnt_destroy( clnt );\n" );
+ f_print(fout, "}\n");
+}
+
+static void
+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) {
+ f_print(fout, "\n");
+/* if( Cflag )
+ f_print( fout, "extern \"C\"{\n");
+*/
+ return_type(proc);
+ f_print(fout, "* \n");
+ if( Cflag )
+ pvname_svc(proc->proc_name, vp->vers_num);
+ else
+ pvname(proc->proc_name, vp->vers_num);
+ printarglist( proc, RQSTP, "struct svc_req *" );
+
+ f_print(fout, "{\n");
+ f_print(fout, "\n\tstatic ");
+ if( !streq( proc->res_type, "void") )
+ return_type(proc);
+ else
+ f_print(fout, "char*" ); /* cannot have void type */
+ f_print(fout, " result;\n" /*, proc->res_type*/ /*?*/);
+ f_print(fout,
+ "\n\t/*\n\t * insert server code here\n\t */\n\n");
+ if( !streq( proc->res_type, "void") )
+ f_print(fout, "\treturn(&result);\n}\n");
+ else /* cast back to void * */
+ f_print(fout, "\treturn((void*) &result);\n}\n");
+/* if( Cflag)
+ f_print( fout, "};\n");
+*/
+
+ }
+ }
+}
+
+
+
+static void
+return_type(proc_list *plist)
+{
+ ptype( plist->res_prefix, plist->res_type, 1 );
+}
+
+void
+add_sample_msg(void)
+{
+ f_print(fout, "/*\n");
+ f_print(fout, " * This is sample code generated by rpcgen.\n");
+ f_print(fout, " * These are only templates and you can use them\n");
+ f_print(fout, " * as a guideline for developing your own functions.\n");
+ f_print(fout, " */\n\n");
+}
+
+void
+write_sample_clnt_main(void)
+{
+ list *l;
+ definition *def;
+ version_list *vp;
+
+ f_print(fout, "\n\n" );
+ if( Cflag )
+ f_print(fout,"main( int argc, char* argv[] )\n{\n" );
+ else
+ f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n" );
+
+ f_print(fout, "\tchar *host;");
+ f_print(fout, "\n\n\tif(argc < 2) {");
+ f_print(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n" );
+ f_print(fout, "\t\texit(1);\n\t}");
+ f_print(fout, "\n\thost = argv[1];\n");
+
+ for (l = defined; l != NULL; l = l->next) {
+ def = l->val;
+ if (def->def_kind != DEF_PROGRAM) {
+ continue;
+ }
+ 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" );
+ }
+ }
+ f_print(fout, "}\n");
+}
diff --git a/sunrpc/rpc_scan.c b/sunrpc/rpc_scan.c
index 41049b6..c0293a3 100644
--- a/sunrpc/rpc_scan.c
+++ b/sunrpc/rpc_scan.c
@@ -1,11 +1,11 @@
-/* @(#)rpc_scan.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
@@ -27,19 +27,24 @@
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_scan.c 1.6 87/06/24 (C) 1987 SMI";
-#endif
/*
- * rpc_scan.c, Scanner for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
+ * From: @(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI
+ */
+char scan_rcsid[] =
+ "$Id$";
+
+/*
+ * rpc_scan.c, Scanner for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <ctype.h>
-#include <strings.h>
+#include <string.h>
#include "rpc_scan.h"
+#include "rpc_parse.h"
#include "rpc_util.h"
+#include "proto.h"
#define startcomment(where) (where[0] == '/' && where[1] == '*')
#define endcomment(where) (where[-1] == '*' && where[0] == '/')
@@ -47,13 +52,21 @@ static char sccsid[] = "@(#)rpc_scan.c 1.6 87/06/24 (C) 1987 SMI";
static int pushed = 0; /* is a token pushed */
static token lasttok; /* last token, if pushed */
+static void unget_token(token *tokp);
+static void findstrconst(const char **str, const char **val);
+static void findchrconst(const char **str, const char **val);
+static void findconst(const char **str, const char **val);
+static void findkind(const char **mark, token *tokp);
+static int cppline(const char *line);
+static int directive(const char *line);
+static void printdirective(const char *line);
+static void docppline(const char *line, int *lineno, const char **fname);
+
/*
- * scan expecting 1 given token
+ * scan expecting 1 given token
*/
void
-scan(expect, tokp)
- tok_kind expect;
- token *tokp;
+scan(tok_kind expect, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect) {
@@ -62,13 +75,10 @@ scan(expect, tokp)
}
/*
- * scan expecting 2 given tokens
+ * scan expecting any of the 2 given tokens
*/
void
-scan2(expect1, expect2, tokp)
- tok_kind expect1;
- tok_kind expect2;
- token *tokp;
+scan2(tok_kind expect1, tok_kind expect2, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2) {
@@ -77,14 +87,10 @@ scan2(expect1, expect2, tokp)
}
/*
- * scan expecting 3 given token
+ * scan expecting any of the 3 given token
*/
void
-scan3(expect1, expect2, expect3, tokp)
- tok_kind expect1;
- tok_kind expect2;
- tok_kind expect3;
- token *tokp;
+scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2
@@ -93,43 +99,36 @@ scan3(expect1, expect2, expect3, tokp)
}
}
-
/*
- * scan expecting a constant, possibly symbolic
+ * scan expecting a constant, possibly symbolic
*/
void
-scan_num(tokp)
- token *tokp;
+scan_num(token *tokp)
{
get_token(tokp);
switch (tokp->kind) {
case TOK_IDENT:
break;
default:
- error(_("constant or identifier expected"));
+ error("constant or identifier expected");
}
}
-
/*
- * Peek at the next token
+ * Peek at the next token
*/
void
-peek(tokp)
- token *tokp;
+peek(token *tokp)
{
get_token(tokp);
unget_token(tokp);
}
-
/*
- * Peek at the next token and scan it if it matches what you expect
+ * Peek at the next token and scan it if it matches what you expect
*/
int
-peekscan(expect, tokp)
- tok_kind expect;
- token *tokp;
+peekscan(tok_kind expect, token *tokp)
{
peek(tokp);
if (tokp->kind == expect) {
@@ -139,14 +138,11 @@ peekscan(expect, tokp)
return (0);
}
-
-
/*
- * Get the next token, printing out any directive that are encountered.
+ * Get the next token, printing out any directive that are encountered.
*/
void
-get_token(tokp)
- token *tokp;
+get_token(token *tokp)
{
int commenting;
@@ -161,14 +157,15 @@ get_token(tokp)
for (;;) {
if (!fgets(curline, MAXLINESIZE, fin)) {
tokp->kind = TOK_EOF;
- *where = 0;
+ *curline = 0;
+ where = curline;
return;
}
linenum++;
if (commenting) {
break;
} else if (cppline(curline)) {
- docppline(curline, &linenum,
+ docppline(curline, &linenum,
&infilename);
} else if (directive(curline)) {
printdirective(curline);
@@ -182,10 +179,12 @@ get_token(tokp)
where++; /* eat */
}
} else if (commenting) {
- where++;
- if (endcomment(where)) {
- where++;
- commenting--;
+ for (where++; *where; where++) {
+ if (endcomment(where)) {
+ where++;
+ commenting--;
+ break;
+ }
}
} else if (startcomment(where)) {
where += 2;
@@ -196,7 +195,7 @@ get_token(tokp)
}
/*
- * 'where' is not whitespace, comment or directive Must be a token!
+ * 'where' is not whitespace, comment or directive Must be a token!
*/
switch (*where) {
case ':':
@@ -256,6 +255,10 @@ get_token(tokp)
tokp->kind = TOK_STRCONST;
findstrconst(&where, &tokp->str);
break;
+ case '\'':
+ tokp->kind = TOK_CHARCONST;
+ findchrconst(&where, &tokp->str);
+ break;
case '-':
case '0':
@@ -272,13 +275,12 @@ get_token(tokp)
findconst(&where, &tokp->str);
break;
-
default:
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)) {
s_print(p, "%c", *where);
@@ -292,46 +294,67 @@ get_token(tokp)
}
}
-
-
-static
-unget_token(tokp)
- token *tokp;
+static void
+unget_token(token *tokp)
{
lasttok = *tokp;
pushed = 1;
}
-
-static
-findstrconst(str, val)
- char **str;
- char **val;
+static void
+findstrconst(const char **str, const char **val)
{
- char *p;
+ const char *p;
+ char *tmp;
int size;
p = *str;
do {
- *p++;
+ p++;
} while (*p && *p != '"');
if (*p == 0) {
- error(_("unterminated string constant"));
+ error("unterminated string constant");
}
p++;
size = p - *str;
- *val = alloc(size + 1);
- (void) strncpy(*val, *str, size);
- (*val)[size] = 0;
+ tmp = alloc(size + 1);
+ strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
*str = p;
}
-static
-findconst(str, val)
- char **str;
- char **val;
+static void
+findchrconst(const char **str, const char **val)
{
- char *p;
+ const char *p;
+ char *tmp;
+ int size;
+
+ p = *str;
+ do {
+ p++;
+ } while (*p && *p != '\'');
+ if (*p == 0) {
+ error("unterminated string constant");
+ }
+ p++;
+ size = p - *str;
+ if (size != 3) {
+ error("empty char string");
+ }
+ tmp = alloc(size + 1);
+ strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
+ *str = p;
+}
+
+static void
+findconst(const char **str, const char **val)
+{
+ const char *p;
+ char *tmp;
int size;
p = *str;
@@ -346,14 +369,13 @@ findconst(str, val)
} while (isdigit(*p));
}
size = p - *str;
- *val = alloc(size + 1);
- (void) strncpy(*val, *str, size);
- (*val)[size] = 0;
+ tmp = alloc(size + 1);
+ strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
*str = p;
}
-
-
static token symbols[] = {
{TOK_CONST, "const"},
{TOK_UNION, "union"},
@@ -379,16 +401,13 @@ static token symbols[] = {
{TOK_EOF, "??????"},
};
-
-static
-findkind(mark, tokp)
- char **mark;
- token *tokp;
+static void
+findkind(const char **mark, token *tokp)
{
-
int len;
token *s;
- char *str;
+ const char *str;
+ char *tmp;
str = *mark;
for (s = symbols; s->kind != TOK_EOF; s++) {
@@ -404,38 +423,33 @@ findkind(mark, tokp)
}
tokp->kind = TOK_IDENT;
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
- tokp->str = alloc(len + 1);
- (void) strncpy(tokp->str, str, len);
- tokp->str[len] = 0;
+ tmp = alloc(len + 1);
+ strncpy(tmp, str, len);
+ tmp[len] = 0;
+ tokp->str = tmp;
*mark = str + len;
}
-static
-cppline(line)
- char *line;
+static int
+cppline(const char *line)
{
return (line == curline && *line == '#');
}
-static
-directive(line)
- char *line;
+static int
+directive(const char *line)
{
return (line == curline && *line == '%');
}
-static
-printdirective(line)
- char *line;
+static void
+printdirective(const char *line)
{
f_print(fout, "%s", line + 1);
}
-static
-docppline(line, lineno, fname)
- char *line;
- int *lineno;
- char **fname;
+static void
+docppline(const char *line, int *lineno, const char **fname)
{
char *file;
int num;
@@ -453,7 +467,7 @@ docppline(line, lineno, fname)
line++;
}
if (*line != '"') {
- error(_("preprocessor error"));
+ error("preprocessor error");
}
line++;
p = file = alloc(strlen(line) + 1);
@@ -461,7 +475,7 @@ docppline(line, lineno, fname)
*p++ = *line++;
}
if (*line == 0) {
- error(_("preprocessor error"));
+ error("preprocessor error");
}
*p = 0;
if (*file == 0) {
diff --git a/sunrpc/rpc_scan.h b/sunrpc/rpc_scan.h
index ad243d5..9a4383d 100644
--- a/sunrpc/rpc_scan.h
+++ b/sunrpc/rpc_scan.h
@@ -1,37 +1,37 @@
-/* @(#)rpc_scan.h 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-/* @(#)rpc_scan.h 1.3 87/03/09 (C) 1987 SMI */
+
+/* @(#)rpc_scan.h 1.3 90/08/29 (C) 1987 SMI */
/*
* rpc_scan.h, Definitions for the RPCL scanner
- * Copyright (C) 1987, Sun Microsystems, Inc.
*/
/*
@@ -39,6 +39,7 @@
*/
enum tok_kind {
TOK_IDENT,
+ TOK_CHARCONST,
TOK_STRCONST,
TOK_LPAREN,
TOK_RPAREN,
@@ -83,7 +84,7 @@ typedef enum tok_kind tok_kind;
*/
struct token {
tok_kind kind;
- char *str;
+ const char *str;
};
typedef struct token token;
@@ -91,11 +92,14 @@ typedef struct token token;
/*
* routine interface
*/
-void scanprint();
-void scan();
-void scan2();
-void scan3();
-void scan_num();
-void peek();
-int peekscan();
-void get_token();
+void scan(tok_kind expect, token *tokp);
+void scan2(tok_kind expect1, tok_kind expect2, token *tokp);
+void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp);
+void scan_num(token *tokp);
+void peek(token *tokp);
+int peekscan(tok_kind expect, token *tokp);
+void get_token(token *tokp);
+void expected1(tok_kind exp1);
+void expected2(tok_kind exp1, tok_kind exp2);
+void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
+
diff --git a/sunrpc/rpc_svcout.c b/sunrpc/rpc_svcout.c
index 7289b0d..f959a32 100644
--- a/sunrpc/rpc_svcout.c
+++ b/sunrpc/rpc_svcout.c
@@ -1,44 +1,47 @@
-/* @(#)rpc_svcout.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_svcout.c 1.6 87/06/24 (C) 1987 SMI";
-#endif
+
+/*
+ * From: @(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI
+ */
+char svcout_rcsid[] =
+ "$Id$";
/*
* rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsytsems, Inc.
*/
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include "rpc_parse.h"
#include "rpc_util.h"
+#include "proto.h"
static char RQSTP[] = "rqstp";
static char TRANSP[] = "transp";
@@ -46,120 +49,313 @@ static char ARG[] = "argument";
static char RESULT[] = "result";
static char ROUTINE[] = "local";
+char _errbuf[256]; /* For all messages */
+
+static void internal_proctype(proc_list *plist);
+static void p_xdrfunc(const char *rname, const char *typename);
+static void write_real_program(definition *def);
+static void write_program(definition *def, const char *storage);
+static void printerr(const char *err, const char *transp);
+static void printif(const char *proc, const char *transp,
+ const char *prefix, const char *arg);
+static void write_inetmost(const char *infile);
+static void print_return(const char *space);
+static void print_pmapunset(const char *space);
+static void print_err_message(const char *space);
+static void write_timeout_func(void);
+static void write_pm_most(const char *infile, int netflag);
+static void write_rpc_svc_fg(const char *infile, const char *sp);
+static void open_log_file(const char *infile, const char *sp);
+
+static void
+p_xdrfunc(const char *rname, const char *typename)
+{
+ if( Cflag )
+ f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n", rname,
+ stringfix(typename) );
+ else
+ f_print(fout, "\t\txdr_%s = xdr_%s;\n", rname, stringfix(typename) );
+}
+
+void
+internal_proctype(proc_list *plist)
+{
+ f_print(fout, "static ");
+ ptype( plist->res_prefix, plist->res_type, 1 );
+ f_print( fout, "*" );
+}
+
/*
- * write most of the service, that is, everything but the registrations.
+ * write most of the service, that is, everything but the registrations.
*/
void
-write_most()
+write_most(const char *infile /* our name */, int netflag, int nomain)
+{
+ if (inetdflag || pmflag) {
+ const char *var_type;
+#ifdef __GNU_LIBRARY__
+ /* WHY? */
+ var_type = (nomain? "extern" : "");
+#else
+ var_type = (nomain? "extern" : "static");
+#endif
+ f_print(fout, "%s int _rpcpmstart;", var_type );
+ 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) {
+ f_print(fout, "%s int _rpcsvcdirty;", var_type );
+ f_print(fout, "\t/* Still serving ? */\n");
+ }
+ write_svc_aux( nomain );
+ }
+ /* write out dispatcher and stubs */
+ write_programs(nomain ? NULL : "static");
+
+ if( nomain )
+ return;
+
+#ifdef __GNU_LIBRARY__
+ if (Cflag)
+ f_print(fout, "\nint\nmain(int argc, char **argv)\n");
+ else {
+ f_print(fout, "\nint\nmain(argc, argv)\n");
+ f_print(fout, "\tint argc;\n");
+ f_print(fout, "\tchar **argv;\n");
+ }
+#else
+ f_print(fout, "\nmain()\n");
+#endif
+ f_print(fout, "{\n");
+ if (inetdflag) {
+ write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */
+ } else {
+ if( tirpcflag ) {
+ if (netflag) {
+ f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "\tstruct netconfig *nconf = NULL;\n");
+ }
+ f_print(fout, "\tpid_t pid;\n");
+ f_print(fout, "\tint i;\n");
+ f_print(fout, "\tchar mname[FMNAMESZ + 1];\n\n");
+ write_pm_most(infile, netflag);
+ f_print(fout, "\telse {\n");
+ write_rpc_svc_fg(infile, "\t\t");
+ f_print(fout, "\t}\n");
+ } else {
+ f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "\n");
+ print_pmapunset("\t");
+ }
+ }
+
+ if (logflag && !inetdflag) {
+ open_log_file(infile, "\t");
+ }
+}
+
+/*
+ * write a registration for the given transport
+ */
+void
+write_netid_register(const char *transp)
{
list *l;
definition *def;
version_list *vp;
+ const char *sp;
+ char tmpbuf[32];
- for (l = defined; l != NULL; l = l->next) {
- def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM) {
- for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\nstatic void ");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "();");
- }
- }
- }
- f_print(fout, "\n\n");
- f_print(fout, "main()\n");
- f_print(fout, "{\n");
- f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
+ sp = "";
f_print(fout, "\n");
+ f_print(fout, "%s\tnconf = getnetconfigent(\"%s\");\n", sp, transp);
+ f_print(fout, "%s\tif (nconf == NULL) {\n", sp);
+ (void) sprintf(_errbuf, "cannot find %s netid.", transp);
+ sprintf(tmpbuf, "%s\t\t", sp);
+ print_err_message(tmpbuf);
+ f_print(fout, "%s\t\texit(1);\n", sp);
+ f_print(fout, "%s\t}\n", sp);
+ f_print(fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n",
+ sp, TRANSP /*, transp*/ /* ?!?... */ );
+ f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
+ (void) sprintf(_errbuf, "cannot create %s service.", transp);
+ print_err_message(tmpbuf);
+ f_print(fout, "%s\t\texit(1);\n", sp);
+ f_print(fout, "%s\t}\n", sp);
+
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
if (def->def_kind != DEF_PROGRAM) {
continue;
}
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\t(void)pmap_unset(%s, %s);\n", def->def_name, vp->vers_name);
+ f_print(fout,
+ "%s\t(void) rpcb_unset(%s, %s, nconf);\n",
+ sp, def->def_name, vp->vers_name);
+ f_print(fout,
+ "%s\tif (!svc_reg(%s, %s, %s, ",
+ sp, TRANSP, def->def_name, vp->vers_name);
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, ", nconf)) {\n");
+ (void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
+ def->def_name, vp->vers_name, transp);
+ print_err_message(tmpbuf);
+ f_print(fout, "%s\t\texit(1);\n", sp);
+ f_print(fout, "%s\t}\n", sp);
}
}
+ f_print(fout, "%s\tfreenetconfigent(nconf);\n", sp);
}
-
/*
- * write a registration for the given transport
+ * write a registration for the given transport for TLI
*/
void
-write_register(transp)
- char *transp;
+write_nettype_register(const char *transp)
{
list *l;
definition *def;
version_list *vp;
- f_print(fout, "\n");
- f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp);
- if (streq(transp, "tcp")) {
- f_print(fout, ", 0, 0");
- }
- f_print(fout, ");\n");
- f_print(fout, "\tif (%s == NULL) {\n", TRANSP);
- f_print(fout, "\t\t(void)fprintf(stderr, \"cannot create %s service.\\n\");\n", transp);
- f_print(fout, "\t\texit(1);\n");
- f_print(fout, "\t}\n");
-
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
if (def->def_kind != DEF_PROGRAM) {
continue;
}
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout,
- "\tif (!svc_register(%s, %s, %s, ",
- TRANSP, def->def_name, vp->vers_name);
+ f_print(fout, "\tif (!svc_create(");
pvname(def->def_name, vp->vers_num);
- f_print(fout, ", IPPROTO_%s)) {\n",
- streq(transp, "udp") ? "UDP" : "TCP");
- f_print(fout,
- "\t\t(void)fprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n",
+ f_print(fout, ", %s, %s, \"%s\")) {\n ",
def->def_name, vp->vers_name, transp);
+ (void) sprintf(_errbuf,
+ "unable to create (%s, %s) for %s.",
+ def->def_name, vp->vers_name, transp);
+ print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
f_print(fout, "\t}\n");
}
}
}
-
/*
- * write the rest of the service
+ * write the rest of the service
*/
void
-write_rest()
+write_rest(void)
{
+ f_print(fout, "\n");
+ 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) {
+ f_print(fout, "\tif (_rpcpmstart) {\n");
+ f_print(fout,
+ "\t\t(void) signal(SIGALRM, %s closedown);\n",
+ Cflag? "(SIG_PF)" : "(void(*)())" );
+ f_print(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+ f_print(fout, "\t}\n");
+ }
+ }
f_print(fout, "\tsvc_run();\n");
- f_print(fout, "\t(void)fprintf(stderr, \"svc_run returned\\n\");\n");
+ (void) sprintf(_errbuf, "svc_run returned");
+ print_err_message("\t");
f_print(fout, "\texit(1);\n");
+ f_print(fout, "\t/* NOTREACHED */\n");
f_print(fout, "}\n");
}
void
-write_programs(storage)
- char *storage;
+write_programs(const char *storage)
{
list *l;
definition *def;
+ /* write out stubs for procedure definitions */
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind == DEF_PROGRAM) {
+ write_real_program(def);
+ }
+ }
+
+ /* write out dispatcher for each program */
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
if (def->def_kind == DEF_PROGRAM) {
write_program(def, storage);
}
}
+
+
}
+/* write out definition of internal function (e.g. _printmsg_1(...))
+ which calls server's defintion of actual function (e.g. printmsg_1(...)).
+ Unpacks single user argument of printmsg_1 to call-by-value format
+ expected by printmsg_1. */
+static void
+write_real_program(definition *def)
+{
+ version_list *vp;
+ proc_list *proc;
+ decl_list *l;
-static
-write_program(def, storage)
- definition *def;
- char *storage;
+ 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 ) {
+ f_print(fout, "(" );
+ /* arg name */
+ if (proc->arg_num > 1)
+ f_print(fout, proc->args.argname);
+ else
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ f_print(fout, " *argp, struct svc_req *%s)\n",
+ RQSTP);
+ } 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 {
+ f_print(fout, "\t");
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ f_print(fout, " *argp;\n");
+ }
+ f_print(fout, " struct svc_req *%s;\n", RQSTP);
+ }
+
+ f_print(fout, "{\n");
+ f_print(fout, "\treturn(");
+ if( Cflag )
+ pvname_svc(proc->proc_name, vp->vers_num);
+ else
+ pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, "(");
+ if (proc->arg_num < 2) { /* single argument */
+ if (!streq( proc->args.decls->decl.type, "void"))
+ f_print(fout, "*argp, "); /* non-void */
+ } else {
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ f_print(fout, "argp->%s, ", l->decl.name);
+ }
+ f_print(fout, "%s));\n}\n", RQSTP);
+ }
+ }
+}
+
+static void
+write_program(definition *def, const char *storage)
{
version_list *vp;
proc_list *proc;
@@ -172,99 +368,153 @@ write_program(def, storage)
}
f_print(fout, "void\n");
pvname(def->def_name, vp->vers_num);
- f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
- f_print(fout, " struct svc_req *%s;\n", RQSTP);
- f_print(fout, " SVCXPRT *%s;\n", TRANSP);
+
+ if (Cflag) {
+ f_print(fout, "(struct svc_req *%s, ", RQSTP);
+ f_print(fout, "register SVCXPRT *%s)\n", TRANSP);
+ } 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);
+ }
+
f_print(fout, "{\n");
filled = 0;
f_print(fout, "\tunion {\n");
for (proc = vp->procs; proc != NULL; proc = proc->next) {
- if (streq(proc->arg_type, "void")) {
- continue;
+ if (proc->arg_num < 2) { /* single argument */
+ if (streq(proc->args.decls->decl.type,
+ "void")) {
+ continue;
+ }
+ filled = 1;
+ f_print(fout, "\t\t");
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, "_arg;\n");
+
+ }
+ else {
+ filled = 1;
+ f_print(fout, "\t\t%s", proc->args.argname);
+ f_print(fout, " ");
+ pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, "_arg;\n");
}
- filled = 1;
- f_print(fout, "\t\t");
- ptype(proc->arg_prefix, proc->arg_type, 0);
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "_arg;\n");
}
if (!filled) {
f_print(fout, "\t\tint fill;\n");
}
f_print(fout, "\t} %s;\n", ARG);
f_print(fout, "\tchar *%s;\n", RESULT);
- f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
+
+ 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 {
+ f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
+ f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
+ }
+
f_print(fout, "\n");
- f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
+ if (timerflag)
+ f_print(fout, "\t_rpcsvcdirty = 1;\n");
+ f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
if (!nullproc(vp->procs)) {
f_print(fout, "\tcase NULLPROC:\n");
- f_print(fout, "\t\t(void)svc_sendreply(%s, xdr_void, (char *)NULL);\n", TRANSP);
- f_print(fout, "\t\treturn;\n\n");
+ f_print(fout,
+ Cflag
+ ? "\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n"
+ : "\t\t(void) svc_sendreply(%s, xdr_void, (char *)NULL);\n",
+ TRANSP);
+ print_return("\t\t");
+ f_print(fout, "\n");
}
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\tcase %s:\n", proc->proc_name);
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG,
- stringfix(proc->arg_type));
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT,
- stringfix(proc->res_type));
- f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
- pvname(proc->proc_name, vp->vers_num);
+ if (proc->arg_num < 2) { /* single argument */
+ p_xdrfunc( ARG, proc->args.decls->decl.type);
+ } else {
+ p_xdrfunc( ARG, proc->args.argname);
+ }
+ p_xdrfunc( RESULT, proc->res_type);
+ if( Cflag )
+ f_print(fout,
+ "\t\t%s = (char *(*)(char *, struct svc_req *)) ",
+ ROUTINE);
+ else
+ f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
+
+ if (newstyle) { /* new style: calls internal routine */
+ f_print(fout,"_");
+ }
+ if( Cflag && !newstyle )
+ pvname_svc(proc->proc_name, vp->vers_num);
+ else
+ pvname(proc->proc_name, vp->vers_num);
f_print(fout, ";\n");
f_print(fout, "\t\tbreak;\n\n");
}
f_print(fout, "\tdefault:\n");
printerr("noproc", TRANSP);
- f_print(fout, "\t\treturn;\n");
+ print_return("\t\t");
f_print(fout, "\t}\n");
- f_print(fout, "\tbzero((char *)&%s, sizeof(%s));\n", ARG, ARG);
- printif("getargs", TRANSP, "&", ARG);
+ f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG);
+ if (Cflag)
+ printif("getargs", TRANSP, "(caddr_t) &", ARG);
+ else
+ printif("getargs", TRANSP, "&", ARG);
printerr("decode", TRANSP);
- f_print(fout, "\t\treturn;\n");
+ print_return("\t\t");
f_print(fout, "\t}\n");
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
- RQSTP);
- f_print(fout,
+ if (Cflag)
+ f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
+ RESULT, ROUTINE, ARG, RQSTP);
+ else
+ f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
+ RESULT, ROUTINE, ARG, RQSTP);
+ f_print(fout,
"\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
RESULT, TRANSP, RESULT, RESULT);
printerr("systemerr", TRANSP);
f_print(fout, "\t}\n");
- printif("freeargs", TRANSP, "&", ARG);
- f_print(fout, "\t\t(void)fprintf(stderr, \"unable to free arguments\\n\");\n");
+ if (Cflag)
+ printif("freeargs", TRANSP, "(caddr_t) &", ARG);
+ else
+ printif("freeargs", TRANSP, "&", ARG);
+ (void) sprintf(_errbuf, "unable to free arguments");
+ print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
f_print(fout, "\t}\n");
-
- f_print(fout, "}\n\n");
+ print_return("\t");
+ f_print(fout, "}\n");
}
}
-static
-printerr(err, transp)
- char *err;
- char *transp;
+static void
+printerr(const char *err, const char *transp)
{
f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
}
-static
-printif(proc, transp, prefix, arg)
- char *proc;
- char *transp;
- char *prefix;
- char *arg;
+static void
+printif(const char *proc, const char *transp, const char *prefix,
+ const char *arg)
{
f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n",
proc, transp, arg, prefix, arg);
}
-
-nullproc(proc)
- proc_list *proc;
+int
+nullproc(proc_list *proc)
{
for (; proc != NULL; proc = proc->next) {
if (streq(proc->proc_num, "0")) {
@@ -273,3 +523,389 @@ nullproc(proc)
}
return (0);
}
+
+static void
+write_inetmost(const char *infile)
+{
+ f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "\tint sock;\n");
+ f_print(fout, "\tint proto;\n");
+ f_print(fout, "\tstruct sockaddr_in saddr;\n");
+ f_print(fout, "\tint asize = sizeof (saddr);\n");
+ f_print(fout, "\n");
+ f_print(fout,
+ "\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n");
+ f_print(fout, "\t\tint ssize = sizeof (int);\n\n");
+ f_print(fout, "\t\tif (saddr.sin_family != AF_INET)\n");
+ f_print(fout, "\t\t\texit(1);\n");
+ f_print(fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n");
+ f_print(fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n");
+ f_print(fout, "\t\t\texit(1);\n");
+ f_print(fout, "\t\tsock = 0;\n");
+ f_print(fout, "\t\t_rpcpmstart = 1;\n");
+ f_print(fout, "\t\tproto = 0;\n");
+ open_log_file(infile, "\t\t");
+ f_print(fout, "\t} else {\n");
+ write_rpc_svc_fg(infile, "\t\t");
+ f_print(fout, "\t\tsock = RPC_ANYSOCK;\n");
+ print_pmapunset("\t\t");
+ f_print(fout, "\t}\n");
+}
+
+static void
+print_return(const char *space)
+{
+ if (exitnow)
+ f_print(fout, "%sexit(0);\n", space);
+ else {
+ if (timerflag)
+ f_print(fout, "%s_rpcsvcdirty = 0;\n", space);
+ f_print(fout, "%sreturn;\n", space);
+ }
+}
+
+static void
+print_pmapunset(const char *space)
+{
+ list *l;
+ definition *def;
+ version_list *vp;
+
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind == DEF_PROGRAM) {
+ for (vp = def->def.pr.versions; vp != NULL;
+ vp = vp->next) {
+ f_print(fout, "%s(void) pmap_unset(%s, %s);\n",
+ space, def->def_name, vp->vers_name);
+ }
+ }
+ }
+}
+
+static void
+print_err_message(const char *space)
+{
+ if (logflag)
+ f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf);
+ else if (inetdflag || pmflag)
+ f_print(fout, "%s_msgout(\"%s\");\n", space, _errbuf);
+ else
+ f_print(fout, "%sfprintf(stderr, \"%s\");\n", space, _errbuf);
+}
+
+/*
+ * Write the server auxiliary function ( _msgout, timeout)
+ */
+void
+write_svc_aux(int nomain)
+{
+ if (!logflag)
+ write_msg_out();
+ if( !nomain )
+ write_timeout_func();
+}
+
+/*
+ * Write the _msgout function
+ */
+
+void
+write_msg_out(void)
+{
+ f_print(fout, "\n");
+ f_print(fout, "static\n");
+ if( !Cflag ) {
+ f_print(fout, "void _msgout(msg)\n");
+ f_print(fout, "\tchar *msg;\n");
+ } else {
+ f_print(fout, "void _msgout(char* msg)\n");
+ }
+ f_print(fout, "{\n");
+ f_print(fout, "#ifdef RPC_SVC_FG\n");
+ if (inetdflag || pmflag)
+ f_print(fout, "\tif (_rpcpmstart)\n");
+ f_print(fout, "\t\tsyslog(LOG_ERR, msg);\n");
+ f_print(fout, "\telse\n");
+ f_print(fout, "\t\t(void) fprintf(stderr, \"%%s\\n\", msg);\n");
+ f_print(fout, "#else\n");
+ f_print(fout, "\tsyslog(LOG_ERR, msg);\n");
+ f_print(fout, "#endif\n");
+ f_print(fout, "}\n");
+}
+
+/*
+ * Write the timeout function
+ */
+static void
+write_timeout_func(void)
+{
+ if (!timerflag)
+ return;
+ f_print(fout, "\n");
+ f_print(fout, "static void\n");
+#ifdef __GNU_LIBRARY__
+ if (Cflag)
+ f_print(fout, "closedown(int sig)\n");
+ else
+ f_print(fout, "closedown(sig)\n\tint sig;\n");
+#else
+ f_print(fout, "closedown()\n");
+#endif
+ f_print(fout, "{\n");
+#ifdef __GNU_LIBRARY__
+ f_print(fout, "\t(void) signal(sig, %s closedown);\n",
+ Cflag? "(SIG_PF)" : "(void(*)())" );
+#endif
+ f_print(fout, "\tif (_rpcsvcdirty == 0) {\n");
+ 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) {
+ 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 {
+ 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 ) {
+ 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 {
+ f_print(fout, "\t\t\tsize = getdtablesize();\n");
+ }
+ f_print(fout, "\t\t}\n");
+ f_print(fout, "\t\tfor (i = 0, openfd = 0; i < size && openfd < 2; i++)\n");
+ f_print(fout, "\t\t\tif (FD_ISSET(i, &svc_fdset))\n");
+ f_print(fout, "\t\t\t\topenfd++;\n");
+ f_print(fout, "\t\tif (openfd <= 1)\n");
+ f_print(fout, "\t\t\texit(0);\n");
+ f_print(fout, "\t}\n");
+ f_print(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+ f_print(fout, "}\n");
+}
+
+/*
+ * Write the most of port monitor support
+ */
+static void
+write_pm_most(const char *infile, int netflag)
+{
+ list *l;
+ definition *def;
+ version_list *vp;
+
+ f_print(fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n");
+ 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 */
+ f_print(fout, "\t\tstruct netconfig *nconf = NULL;\n");
+ f_print(fout, "\t\tSVCXPRT *%s;\n", TRANSP);
+ }
+ if( timerflag )
+ f_print(fout, "\t\tint pmclose;\n");
+/* not necessary, defined in /usr/include/stdlib */
+/* f_print(fout, "\t\textern char *getenv();\n");*/
+ f_print(fout, "\n");
+ f_print(fout, "\t\t_rpcpmstart = 1;\n");
+ if (logflag)
+ open_log_file(infile, "\t\t");
+ f_print(fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n");
+ sprintf(_errbuf, "cannot get transport name");
+ print_err_message("\t\t\t");
+ f_print(fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n");
+ sprintf(_errbuf, "cannot get transport info");
+ print_err_message("\t\t\t");
+ f_print(fout, "\t\t}\n");
+ /*
+ * A kludgy support for inetd services. Inetd only works with
+ * sockmod, and RPC works only with timod, hence all this jugglery
+ */
+ f_print(fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n");
+ f_print(fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n");
+ sprintf(_errbuf, "could not get the right module");
+ print_err_message("\t\t\t\t");
+ f_print(fout, "\t\t\t\texit(1);\n");
+ f_print(fout, "\t\t\t}\n");
+ f_print(fout, "\t\t}\n");
+ if( timerflag )
+ f_print(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n");
+ f_print(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n",
+ TRANSP);
+ sprintf(_errbuf, "cannot create server handle");
+ print_err_message("\t\t\t");
+ f_print(fout, "\t\t\texit(1);\n");
+ 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) {
+ def = (definition *) l->val;
+ if (def->def_kind != DEF_PROGRAM) {
+ continue;
+ }
+ 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);
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, ", 0)) {\n");
+ (void) sprintf(_errbuf, "unable to register (%s, %s).",
+ def->def_name, vp->vers_name);
+ print_err_message("\t\t\t");
+ f_print(fout, "\t\t\texit(1);\n");
+ f_print(fout, "\t\t}\n");
+ }
+ }
+ 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(*)())" );
+ f_print(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+ f_print(fout, "\t\t}\n");
+ }
+ f_print(fout, "\t\tsvc_run();\n");
+ f_print(fout, "\t\texit(1);\n");
+ f_print(fout, "\t\t/* NOTREACHED */\n");
+ f_print(fout, "\t}\n");
+}
+
+/*
+ * Support for backgrounding the server if self started.
+ */
+static void
+write_rpc_svc_fg(const char *infile, const char *sp)
+{
+ f_print(fout, "#ifndef RPC_SVC_FG\n");
+ f_print(fout, "%sint size;\n", sp);
+ if( tirpcflag )
+ f_print(fout, "%sstruct rlimit rl;\n", sp);
+ if (inetdflag)
+ f_print(fout, "%sint pid, i;\n\n", sp);
+ f_print(fout, "%spid = fork();\n", sp);
+ f_print(fout, "%sif (pid < 0) {\n", sp);
+ f_print(fout, "%s\tperror(\"cannot fork\");\n", sp);
+ f_print(fout, "%s\texit(1);\n", sp);
+ f_print(fout, "%s}\n", sp);
+ f_print(fout, "%sif (pid)\n", sp);
+ f_print(fout, "%s\texit(0);\n", sp);
+ /* get number of file descriptors */
+ 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 {
+ f_print(fout, "%ssize = getdtablesize();\n", sp);
+ }
+
+ f_print(fout, "%sfor (i = 0; i < size; i++)\n", sp);
+ f_print(fout, "%s\t(void) close(i);\n", sp);
+ /* Redirect stderr and stdout to console */
+ f_print(fout, "%si = open(\"/dev/console\", 2);\n", sp);
+ f_print(fout, "%s(void) dup2(i, 1);\n", sp);
+ f_print(fout, "%s(void) dup2(i, 2);\n", sp);
+ /* This removes control of the controlling terminal */
+ if( tirpcflag )
+ f_print(fout, "%ssetsid();\n", sp);
+ 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);;
+ f_print(fout, "%s\t(void) close(i);\n", sp);
+ f_print(fout, "%s}\n", sp);
+ }
+ if (!logflag)
+ open_log_file(infile, sp);
+ f_print(fout, "#endif\n");
+ if (logflag)
+ open_log_file(infile, sp);
+}
+
+static void
+open_log_file(const char *infile, const char *sp)
+{
+ char *s;
+
+ s = strrchr(infile, '.');
+ if (s)
+ *s = '\0';
+ f_print(fout,"%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile);
+ if (s)
+ *s = '.';
+}
+
+
+
+
+/*
+ * write a registration for the given transport for Inetd
+ */
+void
+write_inetd_register(const char *transp)
+{
+ list *l;
+ definition *def;
+ version_list *vp;
+ const char *sp;
+ int isudp;
+ char tmpbuf[32];
+
+ if (inetdflag)
+ sp = "\t";
+ else
+ sp = "";
+ if (streq(transp, "udp"))
+ isudp = 1;
+ else
+ isudp = 0;
+ f_print(fout, "\n");
+ if (inetdflag) {
+ f_print(fout, "\tif ((_rpcfdtype == 0) || (_rpcfdtype == %s)) {\n",
+ isudp ? "SOCK_DGRAM" : "SOCK_STREAM");
+ }
+ f_print(fout, "%s\t%s = svc%s_create(%s",
+ sp, TRANSP, transp, inetdflag? "sock": "RPC_ANYSOCK");
+ if (!isudp)
+ f_print(fout, ", 0, 0");
+ f_print(fout, ");\n");
+ f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
+ (void) sprintf(_errbuf, "cannot create %s service.", transp);
+ (void) sprintf(tmpbuf, "%s\t\t", sp);
+ print_err_message(tmpbuf);
+ f_print(fout, "%s\t\texit(1);\n", sp);
+ f_print(fout, "%s\t}\n", sp);
+
+ 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) {
+ def = (definition *) l->val;
+ if (def->def_kind != DEF_PROGRAM) {
+ continue;
+ }
+ 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);
+ if (inetdflag)
+ f_print(fout, ", proto)) {\n");
+ else
+ f_print(fout, ", IPPROTO_%s)) {\n",
+ isudp ? "UDP": "TCP");
+ (void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
+ def->def_name, vp->vers_name, transp);
+ print_err_message(tmpbuf);
+ f_print(fout, "%s\t\texit(1);\n", sp);
+ f_print(fout, "%s\t}\n", sp);
+ }
+ }
+ if (inetdflag)
+ f_print(fout, "\t}\n");
+}
diff --git a/sunrpc/rpc_tblout.c b/sunrpc/rpc_tblout.c
new file mode 100644
index 0000000..7a36247
--- /dev/null
+++ b/sunrpc/rpc_tblout.c
@@ -0,0 +1,170 @@
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+/*
+ * From: @(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI
+ */
+char tblout_rcsid[] =
+ "$Id$";
+
+/*
+ * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler
+ */
+#include <stdio.h>
+#include <string.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "proto.h"
+
+#define TABSIZE 8
+#define TABCOUNT 5
+#define TABSTOP (TABSIZE*TABCOUNT)
+
+static 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 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 void write_table(const definition *def);
+static void printit(const char *prefix, const char *type);
+
+void
+write_tables(void)
+{
+ list *l;
+ definition *def;
+
+ f_print(fout, "\n");
+ for (l = defined; l != NULL; l = l->next) {
+ def = (definition *) l->val;
+ if (def->def_kind == DEF_PROGRAM) {
+ write_table(def);
+ }
+ }
+}
+
+static void
+write_table(const definition *def)
+{
+ version_list *vp;
+ proc_list *proc;
+ int current;
+ int expected;
+ char progvers[100];
+ int warning;
+
+ 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)) {
+ expected = 0;
+ }
+ else {
+ expected = 1;
+ f_print(fout, null_entry);
+ }
+ for (proc = vp->procs; proc != NULL; proc = proc->next) {
+ current = atoi(proc->proc_num);
+ if (current != expected++) {
+ f_print(fout,
+ "\n/*\n * WARNING: table out of order\n */\n");
+ if (warning == 0) {
+ f_print(stderr,
+ "WARNING %s table is out of order\n",
+ progvers);
+ warning = 1;
+ nonfatalerrors = 1;
+ }
+ expected = current + 1;
+ }
+ f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION(");
+
+ /* routine to invoke */
+ if( Cflag && !newstyle )
+ pvname_svc(proc->proc_name, vp->vers_num);
+ else {
+ if( newstyle )
+ f_print( fout, "_"); /* calls internal func */
+ pvname(proc->proc_name, vp->vers_num);
+ }
+ f_print(fout, "),\n");
+
+ /* argument info */
+ if( proc->arg_num > 1 )
+ printit((char*) NULL, proc->args.argname );
+ else
+ /* do we have to do something special for newstyle */
+ printit( proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type );
+ /* result info */
+ printit(proc->res_prefix, proc->res_type);
+ }
+
+ /* print the table trailer */
+ f_print(fout, tbl_end);
+ f_print(fout, tbl_nproc, progvers, progvers, progvers);
+ }
+}
+
+static void
+printit(const char *prefix, const char *type)
+{
+ int len;
+ int tabs;
+
+
+ len = fprintf(fout, "\txdr_%s,", stringfix(type));
+ /* account for leading tab expansion */
+ len += TABSIZE - 1;
+ /* round up to tabs required */
+ tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE;
+ f_print(fout, "%s", &tabstr[TABCOUNT-tabs]);
+
+ if (streq(type, "void")) {
+ f_print(fout, "0");
+ } else {
+ f_print(fout, "sizeof ( ");
+ /* XXX: should "follow" be 1 ??? */
+ ptype(prefix, type, 0);
+ f_print(fout, ")");
+ }
+ f_print(fout, ",\n");
+}
diff --git a/sunrpc/rpc_util.c b/sunrpc/rpc_util.c
index ebb037a..cb4561e 100644
--- a/sunrpc/rpc_util.c
+++ b/sunrpc/rpc_util.c
@@ -1,11 +1,11 @@
-/* @(#)rpc_util.c 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
@@ -27,84 +27,96 @@
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-#ifndef lint
-static char sccsid[] = "@(#)rpc_util.c 1.5 87/06/24 (C) 1987 SMI";
-#endif
+
+/*
+ * From: @(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI
+ */
+char util_rcsid[] =
+ "$Id$";
/*
- * rpc_util.c, Utility routines for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
+ * rpc_util.c, Utility routines for the RPC protocol compiler
*/
#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
#include "rpc_scan.h"
#include "rpc_parse.h"
#include "rpc_util.h"
+#include "proto.h"
+
+#define ARGEXT "argument"
char curline[MAXLINESIZE]; /* current read line */
-char *where = curline; /* current point in line */
-int linenum = 0; /* current line number */
+const char *where = curline; /* current point in line */
+int linenum = 0; /* current line number */
-char *infilename; /* input filename */
+const char *infilename; /* input filename */
-#define NFILES 4
-char *outfiles[NFILES]; /* output file names */
+#define NFILES 7
+const char *outfiles[NFILES]; /* output file names */
int nfiles;
-FILE *fout; /* file pointer of current output */
-FILE *fin; /* file pointer of current input */
+FILE *fout; /* file pointer of current output */
+FILE *fin; /* file pointer of current input */
-list *defined; /* list of defined things */
+list *defined; /* list of defined things */
+
+static int findit(const definition *def, const char *type);
+static const char *fixit(const char *type, const char *orig);
+static int typedefed(const definition *def, const char *type);
+static const char *toktostr(tok_kind kind);
+static void printbuf(void);
+static void printwhere(void);
/*
- * Reinitialize the world
+ * Reinitialize the world
*/
-reinitialize()
+void
+reinitialize(void)
{
- bzero(curline, MAXLINESIZE);
+ memset(curline, 0, MAXLINESIZE);
where = curline;
linenum = 0;
defined = NULL;
}
/*
- * string equality
+ * string equality
*/
-streq(a, b)
- char *a;
- char *b;
+int
+streq(const char *a, const char *b)
{
return (strcmp(a, b) == 0);
}
/*
- * find a value in a list
+ * find a value in a list
*/
-char *
-findval(lst, val, cmp)
- list *lst;
- char *val;
- int (*cmp) ();
-
+definition *
+findval(list *lst, const char *val,
+ int (*cmp)(const definition *, const char *))
{
+
for (; lst != NULL; lst = lst->next) {
- if ((*cmp) (lst->val, val)) {
+ if (cmp(lst->val, val)) {
return (lst->val);
}
}
- return (NULL);
+ return NULL;
}
/*
- * store a value in a list
+ * store a value in a list
*/
void
-storeval(lstp, val)
- list **lstp;
- char *val;
+storeval(list **lstp, definition *val)
{
list **l;
list *lst;
+
for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
lst = ALLOC(list);
lst->val = val;
@@ -112,24 +124,18 @@ storeval(lstp, val)
*l = lst;
}
-
-static
-findit(def, type)
- definition *def;
- char *type;
+static int
+findit(const definition *def, const char *type)
{
return (streq(def->def_name, type));
}
-
-static char *
-fixit(type, orig)
- char *type;
- char *orig;
+static const char *
+fixit(const char *type, const char *orig)
{
definition *def;
- def = (definition *) FINDVAL(defined, type, findit);
+ def = findval(defined, type, findit);
if (def == NULL || def->def_kind != DEF_TYPEDEF) {
return (orig);
}
@@ -143,29 +149,25 @@ fixit(type, orig)
}
}
-char *
-fixtype(type)
- char *type;
+const char *
+fixtype(const char *type)
{
return (fixit(type, type));
}
-char *
-stringfix(type)
- char *type;
+const char *
+stringfix(const char *type)
{
if (streq(type, "string")) {
- return ("wrapstring");
- } else {
- return (type);
+ return "wrapstring";
+ }
+ else {
+ return type;
}
}
void
-ptype(prefix, type, follow)
- char *prefix;
- char *type;
- int follow;
+ptype(const char *prefix, const char *type, int follow)
{
if (prefix != NULL) {
if (streq(prefix, "enum")) {
@@ -183,11 +185,8 @@ ptype(prefix, type, follow)
}
}
-
-static
-typedefed(def, type)
- definition *def;
- char *type;
+static int
+typedefed(const definition *def, const char *type)
{
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
return (0);
@@ -196,9 +195,8 @@ typedefed(def, type)
}
}
-isvectordef(type, rel)
- char *type;
- relation rel;
+int
+isvectordef(const char *type, relation rel)
{
definition *def;
@@ -211,7 +209,7 @@ isvectordef(type, rel)
case REL_POINTER:
return (0);
case REL_ALIAS:
- def = (definition *) FINDVAL(defined, type, typedefed);
+ def = findval(defined, type, typedefed);
if (def == NULL) {
return (0);
}
@@ -221,50 +219,50 @@ isvectordef(type, rel)
}
}
-
-static char *
-locase(str)
- char *str;
+char *
+locase(const char *str)
{
char c;
static char buf[100];
char *p = buf;
- while (c = *str++) {
+ while ((c = *str++)!=0) {
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
}
*p = 0;
return (buf);
}
+void
+pvname_svc(const char *pname, const char *vnum)
+{
+ f_print(fout, "%s_%s_svc", locase(pname), vnum);
+}
void
-pvname(pname, vnum)
- char *pname;
- char *vnum;
+pvname(const char *pname, const char *vnum)
{
f_print(fout, "%s_%s", locase(pname), vnum);
}
-
/*
- * print a useful (?) error message, and then die
+ * print a useful (?) error message, and then die
*/
void
-error(msg)
- char *msg;
+error(const char *msg)
{
printwhere();
- f_print(stderr, _("%s, line %d: "), infilename, linenum);
+ f_print(stderr, "%s, line %d: ", infilename, linenum);
f_print(stderr, "%s\n", msg);
crash();
}
/*
* Something went wrong, unlink any files that we may have created and then
- * die.
+ * die.
*/
-crash()
+void
+crash(void)
{
int i;
@@ -274,55 +272,50 @@ crash()
exit(1);
}
-
void
-record_open(file)
- char *file;
+record_open(const char *file)
{
if (nfiles < NFILES) {
outfiles[nfiles++] = file;
- } else {
- f_print(stderr, _("too many files!\n"));
+ }
+ else {
+ f_print(stderr, "too many files!\n");
crash();
}
}
static char expectbuf[100];
-static char *toktostr();
/*
- * error, token encountered was not the expected one
+ * error, token encountered was not the expected one
*/
void
-expected1(exp1)
- tok_kind exp1;
+expected1(tok_kind exp1)
{
- s_print(expectbuf, _("expected '%s'"),
+ s_print(expectbuf, "expected '%s'",
toktostr(exp1));
error(expectbuf);
}
/*
- * error, token encountered was not one of two expected ones
+ * error, token encountered was not one of two expected ones
*/
void
-expected2(exp1, exp2)
- tok_kind exp1, exp2;
+expected2(tok_kind exp1, tok_kind exp2)
{
- s_print(expectbuf, _("expected '%s' or '%s'"),
+ s_print(expectbuf, "expected '%s' or '%s'",
toktostr(exp1),
toktostr(exp2));
error(expectbuf);
}
/*
- * error, token encountered was not one of 3 expected ones
+ * error, token encountered was not one of 3 expected ones
*/
void
-expected3(exp1, exp2, exp3)
- tok_kind exp1, exp2, exp3;
+expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
{
- s_print(expectbuf, _("expected '%s', '%s' or '%s'"),
+ s_print(expectbuf, "expected '%s', '%s' or '%s'",
toktostr(exp1),
toktostr(exp2),
toktostr(exp3));
@@ -330,9 +323,7 @@ expected3(exp1, exp2, exp3)
}
void
-tabify(f, tab)
- FILE *f;
- int tab;
+tabify(FILE *f, int tab)
{
while (tab--) {
(void) fputc('\t', f);
@@ -340,7 +331,6 @@ tabify(f, tab)
}
-
static token tokstrings[] = {
{TOK_IDENT, "identifier"},
{TOK_CONST, "const"},
@@ -378,9 +368,8 @@ static token tokstrings[] = {
{TOK_EOF, "??????"}
};
-static char *
-toktostr(kind)
- tok_kind kind;
+static const char *
+toktostr(tok_kind kind)
{
token *sp;
@@ -388,10 +377,8 @@ toktostr(kind)
return (sp->str);
}
-
-
-static
-printbuf()
+static void
+printbuf(void)
{
char c;
int i;
@@ -399,7 +386,7 @@ printbuf()
# define TABSIZE 4
- for (i = 0; c = curline[i]; i++) {
+ for (i = 0; (c = curline[i])!=0; i++) {
if (c == '\t') {
cnt = 8 - (i % TABSIZE);
c = ' ';
@@ -412,9 +399,8 @@ printbuf()
}
}
-
-static
-printwhere()
+static void
+printwhere(void)
{
int i;
char c;
@@ -434,3 +420,68 @@ printwhere()
}
(void) fputc('\n', stderr);
}
+
+char *
+make_argname(const char *pname, const char *vname)
+{
+ char *name;
+
+ name = malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);
+ if (!name) {
+ fprintf(stderr, "failed in malloc");
+ exit(1);
+ }
+ sprintf(name, "%s_%s_%s", locase(pname), vname, ARGEXT);
+ return name;
+}
+
+bas_type *typ_list_h;
+bas_type *typ_list_t;
+
+void
+add_type(int len, const char *type)
+{
+ bas_type *ptr;
+
+
+ if ((ptr = malloc(sizeof(bas_type))) == NULL) {
+ fprintf(stderr, "failed in malloc");
+ exit(1);
+ }
+
+ ptr->name=type;
+ ptr->length=len;
+ ptr->next=NULL;
+ if(typ_list_t == NULL)
+ {
+
+ typ_list_t=ptr;
+ typ_list_h=ptr;
+ }
+ else
+ {
+
+ typ_list_t->next=ptr;
+ typ_list_t=ptr;
+ }
+
+}
+
+
+bas_type *find_type(const char *type)
+{
+ bas_type *ptr;
+
+ ptr=typ_list_h;
+
+
+ while(ptr != NULL)
+ {
+ if(strcmp(ptr->name,type) == 0)
+ return(ptr);
+ else
+ ptr=ptr->next;
+ };
+return(NULL);
+}
+
diff --git a/sunrpc/rpc_util.h b/sunrpc/rpc_util.h
index 0dd1882..bdbe183 100644
--- a/sunrpc/rpc_util.h
+++ b/sunrpc/rpc_util.h
@@ -1,114 +1,147 @@
-/* @(#)rpc_util.h 2.1 88/08/01 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
+ * program developed by the user or with the express written consent of
+ * Sun Microsystems, Inc.
+ *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
+ *
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
- *
+ *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
- *
+ *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
- *
+ *
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
-/* @(#)rpc_util.h 1.6 87/06/24 (C) 1987 SMI */
+
+/* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */
/*
* rpc_util.h, Useful definitions for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
*/
-extern char *malloc();
+
+#include <stdlib.h>
#define alloc(size) malloc((unsigned)(size))
#define ALLOC(object) (object *) malloc(sizeof(object))
-/* extern char *sprintf(); --roland@gnu */
-
#define s_print (void) sprintf
#define f_print (void) fprintf
struct list {
- char *val;
+ definition *val;
struct list *next;
};
typedef struct list list;
+#define PUT 1
+#define GET 2
+
/*
* Global variables
*/
#define MAXLINESIZE 1024
extern char curline[MAXLINESIZE];
-extern char *where;
+extern const char *where;
extern int linenum;
-extern char *infilename;
+extern const char *infilename;
extern FILE *fout;
extern FILE *fin;
extern list *defined;
+
+extern bas_type *typ_list_h;
+extern bas_type *typ_list_t;
+
/*
- * rpc_util routines
+ * All the option flags
*/
-void storeval();
+extern int inetdflag;
+extern int pmflag;
+extern int tblflag;
+extern int logflag;
+extern int newstyle;
+extern int Cflag; /* C++ flag */
+extern int tirpcflag; /* flag for generating tirpc code */
+extern int inlineflag; /* if this is 0, then do not generate inline code */
-#define STOREVAL(list,item) \
- storeval(list,(char *)item)
+/*
+ * Other flags related with inetd jumpstart.
+ */
+extern int indefinitewait;
+extern int exitnow;
+extern int timerflag;
-char *findval();
+extern int nonfatalerrors;
-#define FINDVAL(list,item,finder) \
- findval(list, (char *) item, finder)
+/*
+ * rpc_util routines
+ */
+void storeval(list **lstp, definition *val);
+#define STOREVAL(list,item) storeval(list,item)
+
+definition *findval(list *lst, const char *val,
+ int (*cmp)(const definition *, const char *));
+#define FINDVAL(list,item,finder) findval(list, item, finder)
+
+const char *fixtype(const char *type);
+const char *stringfix(const char *type);
+char *locase(const char *str);
+void pvname_svc(const char *pname, const char *vnum);
+void pvname(const char *pname, const char *vnum);
+void ptype(const char *prefix, const char *type, int follow);
+int isvectordef(const char *type, relation rel);
+int streq(const char *a, const char *b);
+void error(const char *msg);
+void tabify(FILE *f, int tab);
+void record_open(const char *file);
+bas_type *find_type(const char *type);
-char *fixtype();
-char *stringfix();
-void pvname();
-void ptype();
-int isvectordef();
-int streq();
-void error();
-void expected1();
-void expected2();
-void expected3();
-void tabify();
-void record_open();
/*
* rpc_cout routines
*/
-void cprint();
-void emit();
+void emit(definition *def);
/*
* rpc_hout routines
*/
-void print_datadef();
+void print_datadef(definition *def);
+void print_funcdef(definition *def);
/*
* rpc_svcout routines
*/
-void write_most();
-void write_register();
-void write_rest();
-void write_programs();
-
+void write_most(const char *infile, int netflag, int nomain);
+void write_register(void);
+void write_rest(void);
+void write_programs(const char *storage);
+void write_svc_aux(int nomain);
+void write_inetd_register(const char *transp);
+void write_netid_register(const char *);
+void write_nettype_register(const char *);
/*
* rpc_clntout routines
*/
-void write_stubs();
+void write_stubs(void);
+
+/*
+ * rpc_tblout routines
+ */
+void write_tables(void);
diff --git a/sysdeps/i386/i586/strlen.S b/sysdeps/i386/i586/strlen.S
index 12ea354..cce750c 100644
--- a/sysdeps/i386/i586/strlen.S
+++ b/sysdeps/i386/i586/strlen.S
@@ -53,16 +53,16 @@ ENTRY(strlen)
je L2 /* yes => return */
incl %eax /* increment pointer */
- xorl $3, %edx /* was alignment = 3? */
-
- jz L1 /* yes => now it is aligned and start loop */
+ cmpb %dh, (%eax) /* is byte NUL? */
-L0: cmpb %dh, (%eax) /* is byte NUL? */
je L2 /* yes => return */
incl %eax /* increment pointer */
+ xorl $2, %edx
- cmpb %dh, (%eax) /* is byte NUL? */
+ jz L1
+
+L0: cmpb %dh, (%eax) /* is byte NUL? */
je L2 /* yes => return */
incl %eax /* increment pointer */
diff --git a/sysdeps/m68k/bsd-_setjmp.S b/sysdeps/m68k/bsd-_setjmp.S
index 69aa7de..32d25e4 100644
--- a/sysdeps/m68k/bsd-_setjmp.S
+++ b/sysdeps/m68k/bsd-_setjmp.S
@@ -46,3 +46,4 @@ ENTRY (_setjmp)
#else
jmp C_SYMBOL_NAME (__sigsetjmp)
#endif
+PSEUDO_END (_setjmp)
diff --git a/sysdeps/m68k/bsd-setjmp.S b/sysdeps/m68k/bsd-setjmp.S
index c853516..a4053bd 100644
--- a/sysdeps/m68k/bsd-setjmp.S
+++ b/sysdeps/m68k/bsd-setjmp.S
@@ -44,3 +44,4 @@ ENTRY (setjmp)
#else
jmp C_SYMBOL_NAME (__sigsetjmp)
#endif
+PSEUDO_END (setjmp)
diff --git a/sysdeps/posix/Makefile b/sysdeps/posix/Makefile
index c925b72..3dd0f3e 100644
--- a/sysdeps/posix/Makefile
+++ b/sysdeps/posix/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -26,9 +26,9 @@ cded-objdir-includes = $(patsubst -I$$cwd//%,-I/%,\
# $(BUILD_CFLAGS) needs to come last because it contains unwanted -Is.
$(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
posix1_lim.h local_lim.h
- cwd=`pwd`; cd $(common-objdir); \
+ cwd=`pwd`; cd $(objpfx).; \
$(BUILD_CC) $(cded-objdir-includes) $(BUILD_CFLAGS) \
- $$cwd/$< -o $(patsubst $(common-objpfx)%,%,$@)
+ $$cwd/$< -o $(patsubst $(common-objpfx)%,$(..)%,$@)
common-generated := $(common-generated) stdio_lim.h mk-stdiolim
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index c38c8d4..6a9c7ac 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -91,7 +91,7 @@ __opendir (const char *name)
dirp->fd = fd;
- __libc_lock_init (dirp->lock)
+ __libc_lock_init (dirp->lock);
return dirp;
}
diff --git a/sysdeps/unix/sysv/linux/i386/clone.S b/sysdeps/unix/sysv/linux/i386/clone.S
index 0742cc5..d213b80 100644
--- a/sysdeps/unix/sysv/linux/i386/clone.S
+++ b/sysdeps/unix/sysv/linux/i386/clone.S
@@ -66,7 +66,7 @@ ENTRY(__clone)
jz thread_start
ret
- .size __clone,.-__clone
+PSEUDO_END (__clone)
SYSCALL_ERROR_HANDLER
@@ -74,10 +74,6 @@ thread_start:
subl %ebp,%ebp /* terminate the stack frame */
call *%ebx
pushl %eax
-#ifdef PIC
- call _exit@PLT
-#else
- call _exit
-#endif
+ call JUMPTARGET (_exit)
weak_alias(__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
index 0728003..4dcd90e 100644
--- a/sysdeps/unix/sysv/linux/m68k/clone.S
+++ b/sysdeps/unix/sysv/linux/m68k/clone.S
@@ -27,6 +27,8 @@ Cambridge, MA 02139, USA. */
.text
ENTRY (__clone)
+ CALL_MCOUNT
+
/* Sanity check arguments. */
movel #-EINVAL, %d0
movel 4(%sp), %a0 /* no NULL function pointers */
@@ -72,5 +74,6 @@ thread_start:
#else
jbsr _exit
#endif
+PSEUDO_END (__clone)
weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/m68k/mmap.S b/sysdeps/unix/sysv/linux/m68k/mmap.S
index ed0480d..9bac533 100644
--- a/sysdeps/unix/sysv/linux/m68k/mmap.S
+++ b/sysdeps/unix/sysv/linux/m68k/mmap.S
@@ -22,6 +22,7 @@ Cambridge, MA 02139, USA. */
SYSCALL_ERROR_HANDLER
ENTRY (__mmap)
+ CALL_MCOUNT
move.l #SYS_ify (mmap), %d0 /* System call number in %d0. */
@@ -40,5 +41,6 @@ ENTRY (__mmap)
mmap is declared to return a pointer. */
move.l %d0, %a0
rts
+PSEUDO_END (__mmap)
weak_alias (__mmap, mmap)
diff --git a/sysdeps/unix/sysv/linux/m68k/sigcontext.h b/sysdeps/unix/sysv/linux/m68k/sigcontext.h
deleted file mode 100644
index 585b479..0000000
--- a/sysdeps/unix/sysv/linux/m68k/sigcontext.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Structure describing state saved while handling a signal. Linux/m68k version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-/* State of this thread when the signal was taken. */
-struct sigcontext
-{
- __sigset_t sc_mask;
- unsigned long sc_usp;
- unsigned long sc_d0;
- unsigned long sc_d1;
- unsigned long sc_a0;
- unsigned long sc_a1;
- unsigned short sc_sr;
- unsigned long sc_pc;
-};
diff --git a/sysdeps/unix/sysv/linux/m68k/sigreturn.S b/sysdeps/unix/sysv/linux/m68k/sigreturn.S
index 7f6d643..04f0db5 100644
--- a/sysdeps/unix/sysv/linux/m68k/sigreturn.S
+++ b/sysdeps/unix/sysv/linux/m68k/sigreturn.S
@@ -20,9 +20,12 @@ Cambridge, MA 02139, USA. */
.text
ENTRY (__sigreturn)
+ CALL_MCOUNT
+
addq.l #4, %sp /* Pop the return PC. */
DO_CALL (#SYS_ify (sigreturn), 0)
/* Do the system call; it never returns. */
/* NOTREACHED */
+PSEUDO_END (__sigreturn)
weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/sysv/linux/m68k/socket.S b/sysdeps/unix/sysv/linux/m68k/socket.S
index a85f41c..1294287 100644
--- a/sysdeps/unix/sysv/linux/m68k/socket.S
+++ b/sysdeps/unix/sysv/linux/m68k/socket.S
@@ -35,6 +35,7 @@ Cambridge, MA 02139, USA. */
.globl P(__,socket)
ENTRY (P(__,socket))
+ CALL_MCOUNT
/* Save registers. */
move.l %d2, %a0
@@ -58,5 +59,6 @@ ENTRY (P(__,socket))
/* Successful; return the syscall's value. */
rts
+PSEUDO_END (P(__,socket))
weak_alias (P(__,socket), socket)
diff --git a/sysdeps/unix/sysv/linux/m68k/syscall.S b/sysdeps/unix/sysv/linux/m68k/syscall.S
index 2cc451c..1c7bd6b 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscall.S
+++ b/sysdeps/unix/sysv/linux/m68k/syscall.S
@@ -18,14 +18,20 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
+/* Please consult the file sysdeps/unix/sysv/linux/m68k/sysdep.h for
+ more information about the value -128 used below.*/
+
.text
SYSCALL_ERROR_HANDLER
ENTRY (syscall)
- move.l (%sp)+, %a0 /* Pop return address. */
- DO_CALL ((%sp), 5) /* Frob the args and do the system call. */
- tst.l %d0 /* Check %d0 for error. */
- jmi error /* Jump to error handler if negative. */
- jmp (%a0) /* Return to caller. */
+ CALL_MCOUNT
-error: pea (%a0)
- jra syscall_error
+ move.l 4(%sp), %d0 /* Load syscall number. */
+ _DOARGS_5 (24) /* Frob arguments. */
+ trap &0 /* Do the system call. */
+ UNDOARGS_5 /* Unfrob arguments. */
+ moveq.l &-128, %d1
+ cmp.l %d1, %d0 /* Check %d0 for error. */
+ jcc syscall_error /* Jump to error handler if negative. */
+ rts /* Return to caller. */
+PSEUDO_END (syscall)
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.S b/sysdeps/unix/sysv/linux/m68k/sysdep.S
index 407c2d3..31fa20f 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.S
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.S
@@ -46,7 +46,7 @@ __errno = errno /* This name is expected by the MT code. */
/* The syscall stubs jump here when they detect an error. */
-ENTRY(__syscall_error)
+ENTRY (__syscall_error)
neg.l %d0
move.l %d0, errno
#ifdef _LIBC_REENTRANT
@@ -59,14 +59,15 @@ ENTRY(__syscall_error)
return a pointer. */
move.l %d0, %a0
rts
- .size __syscall_error, . - __syscall_error
+PSEUDO_END (__syscall_error)
#endif /* PIC */
-ERRNO(__errno_location)
+ENTRY (__errno_location)
+ CALL_MCOUNT
#ifdef PIC
move.l (%pc, errno@GOTPC), %a0
#else
lea errno, %a0
#endif
rts
- .size __errno_location, . - __errno_location
+PSEUDO_END (__errno_location)
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index cfc9b04..9cddd20 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -33,8 +33,6 @@ Cambridge, MA 02139, USA. */
#ifdef ASSEMBLER
-#define POUND #
-
/* Define an entry point visible from C. */
#define ENTRY(name) \
.globl name; \
@@ -67,14 +65,26 @@ Cambridge, MA 02139, USA. */
#define syscall_error __syscall_error
/* Linux uses a negative return value to indicate syscall errors, unlike
- most Unices, which use the condition codes' carry flag. */
+ most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be negative
+ even if the call succeeded. E.g., the `lseek' system call might return
+ a large offset. Therefore we must not anymore test for < 0, but test
+ for a real error by making sure the value in %d0 is a real error
+ number. For now (as of 2.1.1) 122 is the largest defined error number.
+ We allow for a bit of room for development and treat -128 to -1 as
+ error values. */
#define PSEUDO(name, syscall_name, args) \
.text; \
SYSCALL_ERROR_HANDLER \
ENTRY (name) \
- DO_CALL (POUND SYS_ify (syscall_name), args); \
- tst.l %d0; \
- jmi syscall_error;
+ DO_CALL (&SYS_ify (syscall_name), args); \
+ moveq.l &-128, %d1; \
+ cmp.l %d1, %d0; \
+ jcc syscall_error
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) .size name, . - name
#ifdef PIC
/* Store (- %d0) into errno through the GOT. */
@@ -88,7 +98,7 @@ syscall_error: \
move.l %d0, -(%sp); \
jbsr __errno_location@PLTPC; \
move.l (%sp)+, (%a0); \
- move.l POUND -1, %d0; \
+ move.l &-1, %d0; \
/* Copy return value to %a0 for syscalls that are declared to return \
a pointer (e.g., mmap). */ \
move.l %d0, %a0; \
@@ -100,7 +110,7 @@ syscall_error: \
move.l (errno@GOTPC, %pc), %a0; \
neg.l %d0; \
move.l %d0, (%a0); \
- move.l POUND -1, %d0; \
+ move.l &-1, %d0; \
/* Copy return value to %a0 for syscalls that are declared to return \
a pointer (e.g., mmap). */ \
move.l %d0, %a0; \
@@ -138,7 +148,7 @@ syscall_error: \
#define DO_CALL(syscall, args) \
move.l syscall, %d0; \
DOARGS_##args \
- trap POUND 0; \
+ trap &0; \
UNDOARGS_##args
#define DOARGS_0 /* No arguments to frob. */
diff --git a/sysdeps/unix/sysv/linux/reboot.c b/sysdeps/unix/sysv/linux/reboot.c
index ecda522..f1b9153 100644
--- a/sysdeps/unix/sysv/linux/reboot.c
+++ b/sysdeps/unix/sysv/linux/reboot.c
@@ -16,7 +16,7 @@ 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 <unistd.h>
+#include <sys/reboot.h>
extern int __syscall_reboot (int magic, int magic_too, int flag);
diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c
index a4cf47b..e669541 100644
--- a/sysdeps/unix/sysv/linux/sleep.c
+++ b/sysdeps/unix/sysv/linux/sleep.c
@@ -19,6 +19,7 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <time.h>
+#include <unistd.h>
unsigned int
sleep (unsigned int seconds)
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 1dd2f4d..d616560 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -13,6 +13,7 @@ geteuid - geteuid 0 __geteuid geteuid
getpgid - getpgid 1 __getpgid getpgid
getpgrp - getpgrp 0 getpgrp
getppid - getppid 0 __getppid getppid
+getresuid - getresuid 3 getresuid
getsid - getsid 1 getsid
init_module EXTRA init_module 5 init_module
ioperm - ioperm 3 ioperm
@@ -46,6 +47,7 @@ select - _newselect 5 __select select
setfsgid EXTRA setfsgid 1 setfsgid
setfsuid EXTRA setfsuid 1 setfsuid
setpgid - setpgid 2 __setpgid setpgid
+setresuid - setresuid 3 setresuid
sigpending - sigpending 1 sigpending
sigprocmask - sigprocmask 3 __sigprocmask sigprocmask
s_sysctl sysctl _sysctl 1 __syscall__sysctl
diff --git a/time/sys/time.h b/time/sys/time.h
index ca82d87..f7553dd 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -155,4 +155,13 @@ extern int utimes __P ((__const char *__file, struct timeval __tvp[2]));
__END_DECLS
+#ifdef __USE_BSD
+/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
+ microseconds. If INTERVAL is nonzero, when the alarm goes off, the
+ timer is reset to go off every INTERVAL microseconds thereafter.
+ Returns the number of microseconds remaining before the alarm. */
+extern unsigned int ualarm __P ((unsigned int __value,
+ unsigned int __interval));
+#endif
+
#endif /* sys/time.h */