mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
update from main archive 961016
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.
This commit is contained in:
134
ChangeLog
134
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>
|
Sun Oct 13 22:52:56 1996 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
* shlib-versions: Add version number/name for ld.so.
|
* 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>
|
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.
|
* stdio/gets.c: Strengthen the warning.
|
||||||
|
|
||||||
Sat Oct 12 23:10:43 1996 Ulrich Drepper <drepper@cygnus.com>
|
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.
|
* 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
|
* posix/getopt.c: Add some more casts and initializations to
|
||||||
prevent warnings.
|
prevent warnings.
|
||||||
|
12
FAQ
12
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:
|
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
|
- 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.
|
Future versions of GCC will automatically provide the correct specs.
|
||||||
|
|
||||||
|
|
||||||
|
4
MakeTAGS
4
MakeTAGS
@ -169,9 +169,9 @@ include $(common-objpfx)version.mk
|
|||||||
# The following code requires GNU date.
|
# The following code requires GNU date.
|
||||||
$P/libc.pot: $(all-pot)
|
$P/libc.pot: $(all-pot)
|
||||||
@rm -f $@.new
|
@rm -f $@.new
|
||||||
disp='set `date -R`; echo $$6'; \
|
set `date -R`; disp="$$6"; \
|
||||||
sed -e 's/VERSION/$(version)/' \
|
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
|
po/header.pot > $@.new
|
||||||
$(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
|
$(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
|
||||||
mv -f $@.new $@
|
mv -f $@.new $@
|
||||||
|
18
Makefile
18
Makefile
@ -124,7 +124,23 @@ $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
|
|||||||
|
|
||||||
all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
|
all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
|
||||||
$(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
|
$(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 \
|
if test -n "$$files"; then \
|
||||||
echo "\"Available extensions:"; \
|
echo "\"Available extensions:"; \
|
||||||
sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
|
sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
|
||||||
|
14
Makerules
14
Makerules
@ -104,13 +104,17 @@ $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
|
|||||||
(echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \
|
(echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \
|
||||||
for dir in $(config-sysdirs); do \
|
for dir in $(config-sysdirs); do \
|
||||||
file=$$dir/Makefile; \
|
file=$$dir/Makefile; \
|
||||||
if [ -f $(..)$$file ]; then \
|
case $$dir in \
|
||||||
|
/*) rel= ;; \
|
||||||
|
*) rel=$(..) ;; \
|
||||||
|
esac; \
|
||||||
|
if [ -f $$rel$$file ]; then \
|
||||||
case $$dir in \
|
case $$dir in \
|
||||||
/*) echo include "$$file" ;; \
|
/*) echo include "$$file" ;; \
|
||||||
*) echo include "\$$(..)$$file" ;; \
|
*) echo include "\$$(..)$$file" ;; \
|
||||||
esac; \
|
esac; \
|
||||||
else true; fi; \
|
else true; fi; \
|
||||||
done; \
|
done; \
|
||||||
echo 'sysd-Makefile-done=t') > $@T
|
echo 'sysd-Makefile-done=t') > $@T
|
||||||
mv -f $@T $@
|
mv -f $@T $@
|
||||||
endif
|
endif
|
||||||
@ -758,12 +762,14 @@ cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
# Command to compile $< in $(common-objdir) using the native libraries.
|
# 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
|
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
|
endef
|
||||||
|
|
||||||
# We always want to use configuration definitions.
|
# 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.
|
# Support the GNU standard name for this target.
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
|
4
README
4
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.
|
Many bugs have been fixed since the last release.
|
||||||
Some bugs surely remain.
|
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,
|
Because of the United States export restriction on DES implementations,
|
||||||
we are distributing this code separately from the rest of the C
|
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
|
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
|
distribution along with the rest of the C library and build; you can
|
||||||
also build the library without getting crypt. Users outside the USA
|
also build the library without getting crypt. Users outside the USA
|
||||||
can get the crypt distribution via anonymous FTP from ftp.uni-c.dk
|
can get the crypt distribution via anonymous FTP from ftp.uni-c.dk
|
||||||
|
@ -305,7 +305,7 @@ cannot `stat' locale file `%s'"),
|
|||||||
{
|
{
|
||||||
long int n;
|
long int n;
|
||||||
n = read (fd, read_ptr, left);
|
n = read (fd, read_ptr, left);
|
||||||
if (n == 1)
|
if (n == -1)
|
||||||
error (5, errno, _("cannot read locale file `%s'"),
|
error (5, errno, _("cannot read locale file `%s'"),
|
||||||
fname);
|
fname);
|
||||||
read_ptr += n;
|
read_ptr += n;
|
||||||
|
@ -24,7 +24,7 @@ subdir := misc
|
|||||||
|
|
||||||
headers := sys/uio.h iovec.h sys/ioctl.h ioctls.h ioctl-types.h \
|
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 \
|
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 \
|
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/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 \
|
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 \
|
swapon swapoff mktemp mkstemp \
|
||||||
ualarm usleep \
|
ualarm usleep \
|
||||||
gtty stty \
|
gtty stty \
|
||||||
ptrace nlist \
|
ptrace \
|
||||||
fstab mntent mntent_r \
|
fstab mntent mntent_r \
|
||||||
utimes \
|
utimes \
|
||||||
truncate ftruncate \
|
truncate ftruncate \
|
||||||
|
@ -47,6 +47,8 @@ Cambridge, MA 02139, USA. */
|
|||||||
void exit ();
|
void exit ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
#ifndef _
|
#ifndef _
|
||||||
#define _(String) String
|
#define _(String) String
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,7 +47,7 @@ mo-installed = $(localedir)/%/LC_MESSAGES/$(domainname).mo
|
|||||||
install-others = $(LINGUAS:%=$(mo-installed))
|
install-others = $(LINGUAS:%=$(mo-installed))
|
||||||
|
|
||||||
# Files to distribute: all the source and compiled binary translation files.
|
# 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
|
include ../Rules
|
||||||
|
535
po/libc.pot
535
po/libc.pot
File diff suppressed because it is too large
Load Diff
@ -153,7 +153,6 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void __flockfile (FILE *);
|
extern void __flockfile (FILE *);
|
||||||
weak_extern (__flockfile);
|
|
||||||
extern void __funlockfile (FILE *);
|
extern void __funlockfile (FILE *);
|
||||||
|
|
||||||
/* Global variables. */
|
/* Global variables. */
|
||||||
|
@ -238,6 +238,14 @@ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n));
|
|||||||
extern char *basename __P ((__const char *__filename));
|
extern char *basename __P ((__const char *__filename));
|
||||||
#endif
|
#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
|
__END_DECLS
|
||||||
|
|
||||||
#endif /* string.h */
|
#endif /* string.h */
|
||||||
|
@ -21,13 +21,15 @@
|
|||||||
#
|
#
|
||||||
subdir := sunrpc
|
subdir := sunrpc
|
||||||
|
|
||||||
# The code in this subdirectory is taken verbatim from Sun's RPCSRC-4.0
|
# The code in this subdirectory is taken from Sun's RPCSRC-4.0
|
||||||
# distribution. A few files needed trivial modifications to compile in the
|
# distribution with some additional changes from the TI-RPC package
|
||||||
# GNU environment; these changes are marked by comments that say
|
# which is also available from Sun. A few files needed trivial
|
||||||
# `roland@gnu'. All the code from Sun's rpc, etc, and rpcgen
|
# modifications to compile in the GNU environment; these changes are
|
||||||
# subdirectories is in this directory; the rpc subdirectory contains only
|
# marked by comments that say `roland@gnu'. All the code from Sun's
|
||||||
# the header files. Other than that, several files were renamed so as not
|
# rpc, etc, and rpcgen subdirectories is in this directory; the rpc
|
||||||
# to exceed 14-character file name limits:
|
# 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
|
# authunix_prot.c -> authuxprot.c
|
||||||
# bindresvport.c -> bindrsvprt.c
|
# bindresvport.c -> bindrsvprt.c
|
||||||
@ -68,9 +70,11 @@ others := portmap rpcinfo
|
|||||||
install-bin := rpcgen
|
install-bin := rpcgen
|
||||||
install-sbin := rpcinfo portmap
|
install-sbin := rpcinfo portmap
|
||||||
rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
|
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.
|
# 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)
|
extra-objs = $(rpcgen-objs)
|
||||||
|
|
||||||
all: # Make this the default target; it will be defined in Rules.
|
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.
|
# Generate the rpcsvc headers with rpcgen.
|
||||||
$(objpfx)rpcsvc/%.h: rpcsvc/%.x $(objpfx)rpcgen
|
$(objpfx)rpcsvc/%.h: rpcsvc/%.x $(objpfx)rpcgen
|
||||||
$(make-target-directory)
|
$(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.
|
# Generate the rpcsvc XDR functions with rpcgen.
|
||||||
$(objpfx)x%.c: rpcsvc/%.x $(objpfx)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.
|
# The generated source files depend on the corresponding generated headers.
|
||||||
# Gratuitous dependency on generated .c file here just gets it mentioned to
|
# Gratuitous dependency on generated .c file here just gets it mentioned to
|
||||||
# avoid being an intermediate file and getting removed.
|
# avoid being an intermediate file and getting removed.
|
||||||
|
53
sunrpc/proto.h
Normal file
53
sunrpc/proto.h
Normal file
@ -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);
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
|
||||||
* Copyright (C) 1987, Sun Microsytsems, Inc.
|
* Copyright (C) 1987, Sun Microsytsems, Inc.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <strings.h>
|
#include <string.h>
|
||||||
|
#include <rpc/types.h>
|
||||||
#include "rpc_parse.h"
|
#include "rpc_parse.h"
|
||||||
#include "rpc_util.h"
|
#include "rpc_util.h"
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
#define DEFAULT_TIMEOUT 25 /* in seconds */
|
#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
|
void
|
||||||
write_stubs()
|
write_stubs(void)
|
||||||
{
|
{
|
||||||
list *l;
|
list *l;
|
||||||
definition *def;
|
definition *def;
|
||||||
|
|
||||||
f_print(fout,
|
f_print(fout,
|
||||||
"\n/* Default timeout can be changed using clnt_control() */\n");
|
"\n/* Default timeout can be changed using clnt_control() */\n");
|
||||||
f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
|
f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
|
||||||
DEFAULT_TIMEOUT);
|
DEFAULT_TIMEOUT);
|
||||||
for (l = defined; l != NULL; l = l->next) {
|
for (l = defined; l != NULL; l = l->next) {
|
||||||
def = (definition *) l->val;
|
def = (definition *) l->val;
|
||||||
@ -60,10 +72,8 @@ write_stubs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
write_program(definition *def)
|
||||||
write_program(def)
|
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
version_list *vp;
|
version_list *vp;
|
||||||
proc_list *proc;
|
proc_list *proc;
|
||||||
@ -74,21 +84,73 @@ write_program(def)
|
|||||||
ptype(proc->res_prefix, proc->res_type, 1);
|
ptype(proc->res_prefix, proc->res_type, 1);
|
||||||
f_print(fout, "*\n");
|
f_print(fout, "*\n");
|
||||||
pvname(proc->proc_name, vp->vers_num);
|
pvname(proc->proc_name, vp->vers_num);
|
||||||
f_print(fout, "(argp, clnt)\n");
|
printarglist( proc, "clnt", "CLIENT *" );
|
||||||
f_print(fout, "\t");
|
|
||||||
ptype(proc->arg_prefix, proc->arg_type, 1);
|
|
||||||
f_print(fout, "*argp;\n");
|
|
||||||
f_print(fout, "\tCLIENT *clnt;\n");
|
|
||||||
f_print(fout, "{\n");
|
f_print(fout, "{\n");
|
||||||
printbody(proc);
|
printbody(proc);
|
||||||
f_print(fout, "}\n\n");
|
f_print(fout, "}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
/* Writes out declarations of procedure's argument list.
|
||||||
ampr(type)
|
In either ANSI C style, in one of old rpcgen style (pass by reference),
|
||||||
char *type;
|
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)) {
|
if (isvectordef(type, REL_ALIAS)) {
|
||||||
return ("");
|
return ("");
|
||||||
@ -97,30 +159,65 @@ ampr(type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
printbody(proc)
|
printbody(proc_list *proc)
|
||||||
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 ");
|
f_print(fout, "\tstatic ");
|
||||||
if (streq(proc->res_type, "void")) {
|
if (streq(proc->res_type, "void")) {
|
||||||
f_print(fout, "char ");
|
f_print(fout, "char ");
|
||||||
} else {
|
} else {
|
||||||
ptype(proc->res_prefix, proc->res_type, 0);
|
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, "\n");
|
||||||
f_print(fout, "\tbzero((char *)%sres, sizeof(res));\n",
|
f_print(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
|
||||||
ampr(proc->res_type));
|
ampr(proc->res_type ), RESULT, RESULT);
|
||||||
f_print(fout,
|
if (newstyle && !args2 && (streq( proc->args.decls->decl.type, "void"))) {
|
||||||
"\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n",
|
/* newstyle, 0 arguments */
|
||||||
proc->proc_name, stringfix(proc->arg_type),
|
f_print(fout,
|
||||||
stringfix(proc->res_type), ampr(proc->res_type));
|
"\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\treturn (NULL);\n");
|
||||||
f_print(fout, "\t}\n");
|
f_print(fout, "\t}\n");
|
||||||
if (streq(proc->res_type, "void")) {
|
if (streq(proc->res_type, "void")) {
|
||||||
f_print(fout, "\treturn ((void *)%sres);\n",
|
f_print(fout, "\treturn ((void *)%s%s);\n",
|
||||||
ampr(proc->res_type));
|
ampr(proc->res_type),RESULT);
|
||||||
} else {
|
} else {
|
||||||
f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type));
|
f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* From: @(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
char cout_rcsid[] =
|
||||||
#include <strings.h>
|
"$Id$";
|
||||||
#include "rpc_util.h"
|
|
||||||
#include "rpc_parse.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Emit the C-routine for the given definition
|
* rpc_cout.c, XDR routine outputter for the RPC protocol compiler
|
||||||
|
*/
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdio.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
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
emit(def)
|
emit(definition *def)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
|
if (def->def_kind == DEF_CONST) {
|
||||||
return;
|
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);
|
print_header(def);
|
||||||
switch (def->def_kind) {
|
switch (def->def_kind) {
|
||||||
case DEF_UNION:
|
case DEF_UNION:
|
||||||
@ -64,15 +101,16 @@ emit(def)
|
|||||||
case DEF_TYPEDEF:
|
case DEF_TYPEDEF:
|
||||||
emit_typedef(def);
|
emit_typedef(def);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* can't happen */
|
||||||
}
|
}
|
||||||
print_trailer();
|
print_trailer();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
findtype(def, type)
|
findtype(const definition *def, const char *type)
|
||||||
definition *def;
|
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
|
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
|
||||||
return (0);
|
return (0);
|
||||||
} else {
|
} else {
|
||||||
@ -80,105 +118,121 @@ findtype(def, type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
undefined(type)
|
undefined(const char *type)
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
definition *def;
|
definition *def;
|
||||||
|
|
||||||
def = (definition *) FINDVAL(defined, type, findtype);
|
def = (definition *) FINDVAL(defined, type, findtype);
|
||||||
|
|
||||||
|
|
||||||
return (def == NULL);
|
return (def == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static void
|
||||||
print_header(def)
|
print_generic_header(const char *procname, int pointerp)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
space();
|
f_print(fout, "\n");
|
||||||
f_print(fout, "bool_t\n");
|
f_print(fout, "bool_t\n");
|
||||||
f_print(fout, "xdr_%s(xdrs, objp)\n", def->def_name);
|
if (Cflag) {
|
||||||
f_print(fout, "\tXDR *xdrs;\n");
|
f_print(fout, "xdr_%s(", procname);
|
||||||
f_print(fout, "\t%s ", def->def_name);
|
f_print(fout, "XDR *xdrs, ");
|
||||||
if (def->def_kind != DEF_TYPEDEF ||
|
f_print(fout, "%s ", procname);
|
||||||
!isvectordef(def->def.ty.old_type, def->def.ty.rel)) {
|
if( pointerp )
|
||||||
f_print(fout, "*");
|
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
|
static void
|
||||||
print_trailer()
|
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, "\treturn (TRUE);\n");
|
||||||
f_print(fout, "}\n");
|
f_print(fout, "}\n");
|
||||||
space();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static void
|
||||||
print_ifopen(indent, name)
|
print_ifopen(int indent, const char *name)
|
||||||
int indent;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
tabify(fout, indent);
|
tabify(fout, indent);
|
||||||
f_print(fout, "if (!xdr_%s(xdrs", name);
|
f_print(fout, " if (!xdr_%s(xdrs", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
print_ifarg(const char *arg)
|
||||||
print_ifarg(arg)
|
|
||||||
char *arg;
|
|
||||||
{
|
{
|
||||||
f_print(fout, ", %s", arg);
|
f_print(fout, ", %s", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
print_ifsizeof(const char *prefix, const char *type)
|
||||||
print_ifsizeof(prefix, type)
|
|
||||||
char *prefix;
|
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
if (streq(type, "bool")) {
|
if (streq(type, "bool")) {
|
||||||
f_print(fout, ", sizeof(bool_t), xdr_bool");
|
f_print(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
f_print(fout, ", sizeof(");
|
f_print(fout, ", sizeof(");
|
||||||
if (undefined(type) && prefix) {
|
if (undefined(type) && prefix) {
|
||||||
f_print(fout, "%s ", 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
|
static void
|
||||||
print_ifclose(indent)
|
print_ifclose(int indent)
|
||||||
int indent;
|
|
||||||
{
|
{
|
||||||
f_print(fout, ")) {\n");
|
f_print(fout, ")) {\n");
|
||||||
tabify(fout, indent);
|
tabify(fout, indent);
|
||||||
f_print(fout, "\treturn (FALSE);\n");
|
f_print(fout, "\t return (FALSE);\n");
|
||||||
tabify(fout, indent);
|
tabify(fout, indent);
|
||||||
f_print(fout, "}\n");
|
f_print(fout, " }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
space()
|
print_ifstat(int indent, const char *prefix, const char *type, relation rel,
|
||||||
|
const char *amax, const char *objname, const char *name)
|
||||||
{
|
{
|
||||||
f_print(fout, "\n\n");
|
const char *alt = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
print_ifstat(indent, prefix, type, rel, amax, objname, name)
|
|
||||||
int indent;
|
|
||||||
char *prefix;
|
|
||||||
char *type;
|
|
||||||
relation rel;
|
|
||||||
char *amax;
|
|
||||||
char *objname;
|
|
||||||
char *name;
|
|
||||||
{
|
|
||||||
char *alt = NULL;
|
|
||||||
|
|
||||||
switch (rel) {
|
switch (rel) {
|
||||||
case REL_POINTER:
|
case REL_POINTER:
|
||||||
@ -243,101 +297,331 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
|
|||||||
print_ifclose(indent);
|
print_ifclose(indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
/* ARGSUSED */
|
emit_enum(definition *def)
|
||||||
static
|
|
||||||
emit_enum(def)
|
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
|
(void)def;
|
||||||
|
|
||||||
print_ifopen(1, "enum");
|
print_ifopen(1, "enum");
|
||||||
print_ifarg("(enum_t *)objp");
|
print_ifarg("(enum_t *)objp");
|
||||||
print_ifclose(1);
|
print_ifclose(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
emit_program(definition *def)
|
||||||
emit_union(def)
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static
|
|
||||||
emit_struct(def)
|
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
decl_list *dl;
|
decl_list *dl;
|
||||||
|
version_list *vlist;
|
||||||
|
proc_list *plist;
|
||||||
|
|
||||||
for (dl = def->def.st.decls; dl != NULL; dl = dl->next) {
|
for (vlist = def->def.pr.versions; vlist != NULL;vlist = vlist->next)
|
||||||
print_stat(&dl->decl);
|
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 void
|
||||||
|
emit_struct(definition *def)
|
||||||
|
{
|
||||||
|
decl_list *dl;
|
||||||
|
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))){
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
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)
|
||||||
static
|
|
||||||
emit_typedef(def)
|
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
char *prefix = def->def.ty.old_prefix;
|
const char *prefix = def->def.ty.old_prefix;
|
||||||
char *type = def->def.ty.old_type;
|
const char *type = def->def.ty.old_type;
|
||||||
char *amax = def->def.ty.array_max;
|
const char *amax = def->def.ty.array_max;
|
||||||
relation rel = def->def.ty.rel;
|
relation rel = def->def.ty.rel;
|
||||||
|
|
||||||
|
|
||||||
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
|
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_stat(int indent, declaration *dec)
|
||||||
|
|
||||||
|
|
||||||
static
|
|
||||||
print_stat(dec)
|
|
||||||
declaration *dec;
|
|
||||||
{
|
{
|
||||||
char *prefix = dec->prefix;
|
const char *prefix = dec->prefix;
|
||||||
char *type = dec->type;
|
const char *type = dec->type;
|
||||||
char *amax = dec->array_max;
|
const char *amax = dec->array_max;
|
||||||
relation rel = dec->rel;
|
relation rel = dec->rel;
|
||||||
char name[256];
|
char name[256];
|
||||||
|
|
||||||
@ -346,5 +630,85 @@ print_stat(dec)
|
|||||||
} else {
|
} else {
|
||||||
s_print(name, "&objp->%s", dec->name);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* rpc_hout.c, Header file outputter for the RPC protocol compiler
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "rpc_util.h"
|
|
||||||
#include "rpc_parse.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
|
* Print the C-version of an xdr definition
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
print_datadef(def)
|
print_datadef(definition *def)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (def->def_kind == DEF_PROGRAM ) /* handle data only */
|
||||||
|
return;
|
||||||
|
|
||||||
if (def->def_kind != DEF_CONST) {
|
if (def->def_kind != DEF_CONST) {
|
||||||
f_print(fout, "\n");
|
f_print(fout, "\n");
|
||||||
}
|
}
|
||||||
@ -72,41 +90,101 @@ print_datadef(def)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
|
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 ||
|
||||||
if (def->def_kind != DEF_CONST) {
|
!isvectordef(def->def.ty.old_type, def->def.ty.rel));
|
||||||
f_print(fout, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
pconstdef(def)
|
void
|
||||||
definition *def;
|
print_funcdef(definition *def)
|
||||||
|
{
|
||||||
|
switch (def->def_kind) {
|
||||||
|
case DEF_PROGRAM:
|
||||||
|
f_print(fout, "\n");
|
||||||
|
pprogramdef(def);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* ?... shouldn't happen I guess */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
pdefine(def->def_name, def->def.co);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
/* print out the definitions for the arguments of functions in the
|
||||||
pstructdef(def)
|
header file
|
||||||
definition *def;
|
*/
|
||||||
|
static void
|
||||||
|
pargdef(definition *def)
|
||||||
{
|
{
|
||||||
decl_list *l;
|
decl_list *l;
|
||||||
char *name = def->def_name;
|
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;
|
||||||
|
const char *name = def->def_name;
|
||||||
|
|
||||||
f_print(fout, "struct %s {\n", name);
|
f_print(fout, "struct %s {\n", name);
|
||||||
for (l = def->def.st.decls; l != NULL; l = l->next) {
|
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, "};\n");
|
||||||
f_print(fout, "typedef struct %s %s;\n", name, name);
|
f_print(fout, "typedef struct %s %s;\n", name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
puniondef(def)
|
puniondef(definition *def)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
case_list *l;
|
case_list *l;
|
||||||
char *name = def->def_name;
|
const char *name = def->def_name;
|
||||||
declaration *decl;
|
declaration *decl;
|
||||||
|
|
||||||
f_print(fout, "struct %s {\n", name);
|
f_print(fout, "struct %s {\n", name);
|
||||||
@ -118,39 +196,32 @@ puniondef(def)
|
|||||||
}
|
}
|
||||||
f_print(fout, "\tunion {\n");
|
f_print(fout, "\tunion {\n");
|
||||||
for (l = def->def.un.cases; l != NULL; l = l->next) {
|
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;
|
decl = def->def.un.default_decl;
|
||||||
if (decl && !streq(decl->type, "void")) {
|
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, "\t} %s_u;\n", name);
|
||||||
f_print(fout, "};\n");
|
f_print(fout, "};\n");
|
||||||
f_print(fout, "typedef struct %s %s;\n", name, name);
|
f_print(fout, "typedef struct %s %s;\n", name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pdefine(const char *name, const char *num)
|
||||||
static
|
|
||||||
pdefine(name, num)
|
|
||||||
char *name;
|
|
||||||
char *num;
|
|
||||||
{
|
{
|
||||||
f_print(fout, "#define %s %s\n", name, num);
|
f_print(fout, "#define %s %s\n", name, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
puldefine(name, num)
|
puldefine(const char *name, const char *num)
|
||||||
char *name;
|
|
||||||
char *num;
|
|
||||||
{
|
{
|
||||||
f_print(fout, "#define %s ((u_long)%s)\n", name, num);
|
f_print(fout, "#define %s ((u_long)%s)\n", name, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
define_printed(stop, start)
|
define_printed(proc_list *stop, version_list *start)
|
||||||
proc_list *stop;
|
|
||||||
version_list *start;
|
|
||||||
{
|
{
|
||||||
version_list *vers;
|
version_list *vers;
|
||||||
proc_list *proc;
|
proc_list *proc;
|
||||||
@ -168,57 +239,122 @@ define_printed(stop, start)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
pprogramdef(definition *def)
|
||||||
pprogramdef(def)
|
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
version_list *vers;
|
version_list *vers;
|
||||||
proc_list *proc;
|
proc_list *proc;
|
||||||
|
int i;
|
||||||
|
const char *ext;
|
||||||
|
|
||||||
|
pargdef(def);
|
||||||
|
|
||||||
puldefine(def->def_name, def->def.pr.prog_num);
|
puldefine(def->def_name, def->def.pr.prog_num);
|
||||||
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
|
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);
|
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, vp)
|
pprocdef(proc_list *proc, version_list *vp,
|
||||||
proc_list *proc;
|
const char *addargtype, int server_p, int mode)
|
||||||
version_list *vp;
|
|
||||||
{
|
{
|
||||||
f_print(fout, "extern ");
|
|
||||||
if (proc->res_prefix) {
|
|
||||||
if (streq(proc->res_prefix, "enum")) {
|
|
||||||
f_print(fout, "enum ");
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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 {
|
} 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, "%s);\n", addargtype);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
penumdef(def)
|
penumdef(definition *def)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
char *name = def->def_name;
|
const char *name = def->def_name;
|
||||||
enumval_list *l;
|
enumval_list *l;
|
||||||
char *last = NULL;
|
const char *last = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
f_print(fout, "enum %s {\n", name);
|
f_print(fout, "enum %s {\n", name);
|
||||||
@ -241,12 +377,11 @@ penumdef(def)
|
|||||||
f_print(fout, "typedef enum %s %s;\n", name, name);
|
f_print(fout, "typedef enum %s %s;\n", name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
ptypedef(def)
|
ptypedef(definition *def)
|
||||||
definition *def;
|
|
||||||
{
|
{
|
||||||
char *name = def->def_name;
|
const char *name = def->def_name;
|
||||||
char *old = def->def.ty.old_type;
|
const char *old = def->def.ty.old_type;
|
||||||
char prefix[8]; /* enough to contain "struct ", including NUL */
|
char prefix[8]; /* enough to contain "struct ", including NUL */
|
||||||
relation rel = def->def.ty.rel;
|
relation rel = def->def.ty.rel;
|
||||||
|
|
||||||
@ -281,23 +416,20 @@ ptypedef(def)
|
|||||||
def->def.ty.array_max);
|
def->def.ty.array_max);
|
||||||
break;
|
break;
|
||||||
case REL_ALIAS:
|
case REL_ALIAS:
|
||||||
f_print(fout, "%s%s %s", prefix, old, name);
|
f_print(fout, "%s%s %s", prefix, old, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
f_print(fout, ";\n");
|
f_print(fout, ";\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
static
|
pdeclaration(const char *name, declaration *dec, int tab,
|
||||||
pdeclaration(name, dec, tab)
|
const char *separator)
|
||||||
char *name;
|
|
||||||
declaration *dec;
|
|
||||||
int tab;
|
|
||||||
{
|
{
|
||||||
char buf[8]; /* enough to hold "struct ", include NUL */
|
char buf[8]; /* enough to hold "struct ", include NUL */
|
||||||
char *prefix;
|
const char *prefix;
|
||||||
char *type;
|
const char *type;
|
||||||
|
|
||||||
if (streq(dec->type, "void")) {
|
if (streq(dec->type, "void")) {
|
||||||
return;
|
return;
|
||||||
@ -343,15 +475,11 @@ pdeclaration(name, dec, tab)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f_print(fout, ";\n");
|
f_print(fout, separator );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
undefined2(const char *type, const char *stop)
|
||||||
static
|
|
||||||
undefined2(type, stop)
|
|
||||||
char *type;
|
|
||||||
char *stop;
|
|
||||||
{
|
{
|
||||||
list *l;
|
list *l;
|
||||||
definition *def;
|
definition *def;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
@ -27,24 +27,45 @@
|
|||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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.
|
* Copyright (C) 1987 Sun Microsystems, Inc.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "rpc_util.h"
|
#include <string.h>
|
||||||
|
#include "rpc/types.h"
|
||||||
#include "rpc_scan.h"
|
#include "rpc_scan.h"
|
||||||
#include "rpc_parse.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
|
* return the next definition you see
|
||||||
*/
|
*/
|
||||||
definition *
|
definition *
|
||||||
get_definition()
|
get_definition(void)
|
||||||
{
|
{
|
||||||
definition *defp;
|
definition *defp;
|
||||||
token tok;
|
token tok;
|
||||||
@ -72,26 +93,22 @@ get_definition()
|
|||||||
break;
|
break;
|
||||||
case TOK_EOF:
|
case TOK_EOF:
|
||||||
return (NULL);
|
return (NULL);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
error(_("definition keyword expected"));
|
error("definition keyword expected");
|
||||||
}
|
}
|
||||||
scan(TOK_SEMICOLON, &tok);
|
scan(TOK_SEMICOLON, &tok);
|
||||||
isdefined(defp);
|
isdefined(defp);
|
||||||
return (defp);
|
return (defp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
isdefined(defp)
|
isdefined(definition *defp)
|
||||||
definition *defp;
|
|
||||||
{
|
{
|
||||||
STOREVAL(&defined, defp);
|
STOREVAL(&defined, defp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
def_struct(definition *defp)
|
||||||
def_struct(defp)
|
|
||||||
definition *defp;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
declaration dec;
|
declaration dec;
|
||||||
@ -117,21 +134,25 @@ def_struct(defp)
|
|||||||
*tailp = NULL;
|
*tailp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
def_program(defp)
|
def_program(definition *defp)
|
||||||
definition *defp;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
|
declaration dec;
|
||||||
|
decl_list *decls;
|
||||||
|
decl_list **tailp;
|
||||||
version_list *vlist;
|
version_list *vlist;
|
||||||
version_list **vtailp;
|
version_list **vtailp;
|
||||||
proc_list *plist;
|
proc_list *plist;
|
||||||
proc_list **ptailp;
|
proc_list **ptailp;
|
||||||
|
int num_args;
|
||||||
|
bool_t isvoid = FALSE; /* whether first argument is void */
|
||||||
defp->def_kind = DEF_PROGRAM;
|
defp->def_kind = DEF_PROGRAM;
|
||||||
scan(TOK_IDENT, &tok);
|
scan(TOK_IDENT, &tok);
|
||||||
defp->def_name = tok.str;
|
defp->def_name = tok.str;
|
||||||
scan(TOK_LBRACE, &tok);
|
scan(TOK_LBRACE, &tok);
|
||||||
vtailp = &defp->def.pr.versions;
|
vtailp = &defp->def.pr.versions;
|
||||||
|
tailp = &defp->def.st.decls;
|
||||||
scan(TOK_VERSION, &tok);
|
scan(TOK_VERSION, &tok);
|
||||||
do {
|
do {
|
||||||
scan(TOK_IDENT, &tok);
|
scan(TOK_IDENT, &tok);
|
||||||
@ -140,33 +161,74 @@ def_program(defp)
|
|||||||
scan(TOK_LBRACE, &tok);
|
scan(TOK_LBRACE, &tok);
|
||||||
ptailp = &vlist->procs;
|
ptailp = &vlist->procs;
|
||||||
do {
|
do {
|
||||||
|
/* get result type */
|
||||||
plist = ALLOC(proc_list);
|
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")) {
|
if (streq(plist->res_type, "opaque")) {
|
||||||
error(_("illegal result type"));
|
error("illegal result type");
|
||||||
}
|
}
|
||||||
scan(TOK_IDENT, &tok);
|
scan(TOK_IDENT, &tok);
|
||||||
plist->proc_name = tok.str;
|
plist->proc_name = tok.str;
|
||||||
scan(TOK_LPAREN, &tok);
|
scan(TOK_LPAREN, &tok);
|
||||||
get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM);
|
/* get args - first one*/
|
||||||
if (streq(plist->arg_type, "opaque")) {
|
num_args = 1;
|
||||||
error("illegal argument type");
|
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_RPAREN, &tok);
|
||||||
scan(TOK_EQUAL, &tok);
|
scan(TOK_EQUAL, &tok);
|
||||||
scan_num(&tok);
|
scan_num(&tok);
|
||||||
scan(TOK_SEMICOLON, &tok);
|
scan(TOK_SEMICOLON, &tok);
|
||||||
plist->proc_num = tok.str;
|
plist->proc_num = tok.str;
|
||||||
|
plist->arg_num = num_args;
|
||||||
*ptailp = plist;
|
*ptailp = plist;
|
||||||
ptailp = &plist->next;
|
ptailp = &plist->next;
|
||||||
peek(&tok);
|
peek(&tok);
|
||||||
} while (tok.kind != TOK_RBRACE);
|
} while (tok.kind != TOK_RBRACE);
|
||||||
|
*ptailp = NULL;
|
||||||
*vtailp = vlist;
|
*vtailp = vlist;
|
||||||
vtailp = &vlist->next;
|
vtailp = &vlist->next;
|
||||||
scan(TOK_RBRACE, &tok);
|
scan(TOK_RBRACE, &tok);
|
||||||
scan(TOK_EQUAL, &tok);
|
scan(TOK_EQUAL, &tok);
|
||||||
scan_num(&tok);
|
scan_num(&tok);
|
||||||
vlist->vers_num = tok.str;
|
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);
|
scan(TOK_SEMICOLON, &tok);
|
||||||
scan2(TOK_VERSION, TOK_RBRACE, &tok);
|
scan2(TOK_VERSION, TOK_RBRACE, &tok);
|
||||||
} while (tok.kind == TOK_VERSION);
|
} while (tok.kind == TOK_VERSION);
|
||||||
@ -176,9 +238,9 @@ def_program(defp)
|
|||||||
*vtailp = NULL;
|
*vtailp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
def_enum(defp)
|
static void
|
||||||
definition *defp;
|
def_enum(definition *defp)
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
enumval_list *elist;
|
enumval_list *elist;
|
||||||
@ -206,9 +268,8 @@ def_enum(defp)
|
|||||||
*tailp = NULL;
|
*tailp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
def_const(defp)
|
def_const(definition *defp)
|
||||||
definition *defp;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
|
|
||||||
@ -220,72 +281,150 @@ def_const(defp)
|
|||||||
defp->def.co = tok.str;
|
defp->def.co = tok.str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
def_union(defp)
|
def_union(definition *defp)
|
||||||
definition *defp;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
declaration dec;
|
declaration dec;
|
||||||
case_list *cases;
|
case_list *cases;
|
||||||
case_list **tailp;
|
/* case_list *tcase; */
|
||||||
|
case_list **tailp;
|
||||||
|
int flag;
|
||||||
|
|
||||||
defp->def_kind = DEF_UNION;
|
defp->def_kind = DEF_UNION;
|
||||||
scan(TOK_IDENT, &tok);
|
scan(TOK_IDENT, &tok);
|
||||||
defp->def_name = tok.str;
|
defp->def_name = tok.str;
|
||||||
scan(TOK_SWITCH, &tok);
|
scan(TOK_SWITCH, &tok);
|
||||||
scan(TOK_LPAREN, &tok);
|
scan(TOK_LPAREN, &tok);
|
||||||
get_declaration(&dec, DEF_UNION);
|
get_declaration(&dec, DEF_UNION);
|
||||||
defp->def.un.enum_decl = dec;
|
defp->def.un.enum_decl = dec;
|
||||||
tailp = &defp->def.un.cases;
|
tailp = &defp->def.un.cases;
|
||||||
scan(TOK_RPAREN, &tok);
|
scan(TOK_RPAREN, &tok);
|
||||||
scan(TOK_LBRACE, &tok);
|
scan(TOK_LBRACE, &tok);
|
||||||
scan(TOK_CASE, &tok);
|
scan(TOK_CASE, &tok);
|
||||||
while (tok.kind == TOK_CASE) {
|
while (tok.kind == TOK_CASE) {
|
||||||
scan(TOK_IDENT, &tok);
|
scan2(TOK_IDENT, TOK_CHARCONST, &tok);
|
||||||
cases = ALLOC(case_list);
|
cases = ALLOC(case_list);
|
||||||
cases->case_name = tok.str;
|
cases->case_name = tok.str;
|
||||||
scan(TOK_COLON, &tok);
|
scan(TOK_COLON, &tok);
|
||||||
get_declaration(&dec, DEF_UNION);
|
/* now peek at next token */
|
||||||
cases->case_decl = dec;
|
flag=0;
|
||||||
*tailp = cases;
|
if(peekscan(TOK_CASE,&tok))
|
||||||
tailp = &cases->next;
|
{
|
||||||
scan(TOK_SEMICOLON, &tok);
|
|
||||||
scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
|
do
|
||||||
}
|
{
|
||||||
*tailp = NULL;
|
scan2(TOK_IDENT, TOK_CHARCONST, &tok);
|
||||||
if (tok.kind == TOK_DEFAULT) {
|
cases->contflag=1; /* continued case statement */
|
||||||
scan(TOK_COLON, &tok);
|
*tailp = cases;
|
||||||
get_declaration(&dec, DEF_UNION);
|
tailp = &cases->next;
|
||||||
defp->def.un.default_decl = ALLOC(declaration);
|
cases = ALLOC(case_list);
|
||||||
*defp->def.un.default_decl = dec;
|
cases->case_name = tok.str;
|
||||||
scan(TOK_SEMICOLON, &tok);
|
scan(TOK_COLON, &tok);
|
||||||
scan(TOK_RBRACE, &tok);
|
|
||||||
} else {
|
}while(peekscan(TOK_CASE,&tok));
|
||||||
defp->def.un.default_decl = NULL;
|
}
|
||||||
}
|
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 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
|
|
||||||
def_typedef(defp)
|
static void
|
||||||
definition *defp;
|
def_typedef(definition *defp)
|
||||||
{
|
{
|
||||||
declaration dec;
|
declaration dec;
|
||||||
|
|
||||||
defp->def_kind = DEF_TYPEDEF;
|
defp->def_kind = DEF_TYPEDEF;
|
||||||
get_declaration(&dec, DEF_TYPEDEF);
|
get_declaration(&dec, DEF_TYPEDEF);
|
||||||
defp->def_name = dec.name;
|
defp->def_name = dec.name;
|
||||||
|
check_type_name(dec.name, 1);
|
||||||
defp->def.ty.old_prefix = dec.prefix;
|
defp->def.ty.old_prefix = dec.prefix;
|
||||||
defp->def.ty.old_type = dec.type;
|
defp->def.ty.old_type = dec.type;
|
||||||
defp->def.ty.rel = dec.rel;
|
defp->def.ty.rel = dec.rel;
|
||||||
defp->def.ty.array_max = dec.array_max;
|
defp->def.ty.array_max = dec.array_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
get_declaration(declaration *dec, defkind dkind)
|
||||||
get_declaration(dec, dkind)
|
|
||||||
declaration *dec;
|
|
||||||
defkind dkind;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
|
|
||||||
@ -294,6 +433,9 @@ get_declaration(dec, dkind)
|
|||||||
if (streq(dec->type, "void")) {
|
if (streq(dec->type, "void")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_type_name(dec->type, 0);
|
||||||
|
|
||||||
scan2(TOK_STAR, TOK_IDENT, &tok);
|
scan2(TOK_STAR, TOK_IDENT, &tok);
|
||||||
if (tok.kind == TOK_STAR) {
|
if (tok.kind == TOK_STAR) {
|
||||||
dec->rel = REL_POINTER;
|
dec->rel = REL_POINTER;
|
||||||
@ -302,7 +444,7 @@ get_declaration(dec, dkind)
|
|||||||
dec->name = tok.str;
|
dec->name = tok.str;
|
||||||
if (peekscan(TOK_LBRACKET, &tok)) {
|
if (peekscan(TOK_LBRACKET, &tok)) {
|
||||||
if (dec->rel == REL_POINTER) {
|
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;
|
dec->rel = REL_VECTOR;
|
||||||
scan_num(&tok);
|
scan_num(&tok);
|
||||||
@ -310,7 +452,7 @@ get_declaration(dec, dkind)
|
|||||||
scan(TOK_RBRACKET, &tok);
|
scan(TOK_RBRACKET, &tok);
|
||||||
} else if (peekscan(TOK_LANGLE, &tok)) {
|
} else if (peekscan(TOK_LANGLE, &tok)) {
|
||||||
if (dec->rel == REL_POINTER) {
|
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;
|
dec->rel = REL_ARRAY;
|
||||||
if (peekscan(TOK_RANGLE, &tok)) {
|
if (peekscan(TOK_RANGLE, &tok)) {
|
||||||
@ -323,21 +465,84 @@ get_declaration(dec, dkind)
|
|||||||
}
|
}
|
||||||
if (streq(dec->type, "opaque")) {
|
if (streq(dec->type, "opaque")) {
|
||||||
if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
|
if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
|
||||||
error(_("array declaration expected"));
|
error("array declaration expected");
|
||||||
}
|
}
|
||||||
} else if (streq(dec->type, "string")) {
|
} else if (streq(dec->type, "string")) {
|
||||||
if (dec->rel != REL_ARRAY) {
|
if (dec->rel != REL_ARRAY) {
|
||||||
error(_("variable-length array declaration expected"));
|
error("variable-length array declaration expected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static void
|
||||||
get_type(prefixp, typep, dkind)
|
get_prog_declaration(declaration *dec, defkind dkind, int num /* arg number */)
|
||||||
char **prefixp;
|
{
|
||||||
char **typep;
|
token tok;
|
||||||
defkind dkind;
|
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;
|
token tok;
|
||||||
|
|
||||||
@ -367,7 +572,7 @@ get_type(prefixp, typep, dkind)
|
|||||||
break;
|
break;
|
||||||
case TOK_VOID:
|
case TOK_VOID:
|
||||||
if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
|
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;
|
*typep = tok.str;
|
||||||
break;
|
break;
|
||||||
@ -381,14 +586,12 @@ get_type(prefixp, typep, dkind)
|
|||||||
*typep = tok.str;
|
*typep = tok.str;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error(_("expected type specifier"));
|
error("expected type specifier");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
unsigned_dec(const char **typep)
|
||||||
unsigned_dec(typep)
|
|
||||||
char **typep;
|
|
||||||
{
|
{
|
||||||
token tok;
|
token tok;
|
||||||
|
|
||||||
|
@ -4,33 +4,34 @@
|
|||||||
* media and as a part of the software program in whole or part. Users
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* rpc_parse.h, Definitions for the RPCL parser
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum defkind {
|
enum defkind {
|
||||||
@ -43,7 +44,7 @@ enum defkind {
|
|||||||
};
|
};
|
||||||
typedef enum defkind defkind;
|
typedef enum defkind defkind;
|
||||||
|
|
||||||
typedef char *const_def;
|
typedef const char *const_def;
|
||||||
|
|
||||||
enum relation {
|
enum relation {
|
||||||
REL_VECTOR, /* fixed length array */
|
REL_VECTOR, /* fixed length array */
|
||||||
@ -54,17 +55,16 @@ enum relation {
|
|||||||
typedef enum relation relation;
|
typedef enum relation relation;
|
||||||
|
|
||||||
struct typedef_def {
|
struct typedef_def {
|
||||||
char *old_prefix;
|
const char *old_prefix;
|
||||||
char *old_type;
|
const char *old_type;
|
||||||
relation rel;
|
relation rel;
|
||||||
char *array_max;
|
const char *array_max;
|
||||||
};
|
};
|
||||||
typedef struct typedef_def typedef_def;
|
typedef struct typedef_def typedef_def;
|
||||||
|
|
||||||
|
|
||||||
struct enumval_list {
|
struct enumval_list {
|
||||||
char *name;
|
const char *name;
|
||||||
char *assignment;
|
const char *assignment;
|
||||||
struct enumval_list *next;
|
struct enumval_list *next;
|
||||||
};
|
};
|
||||||
typedef struct enumval_list enumval_list;
|
typedef struct enumval_list enumval_list;
|
||||||
@ -74,17 +74,15 @@ struct enum_def {
|
|||||||
};
|
};
|
||||||
typedef struct enum_def enum_def;
|
typedef struct enum_def enum_def;
|
||||||
|
|
||||||
|
|
||||||
struct declaration {
|
struct declaration {
|
||||||
char *prefix;
|
const char *prefix;
|
||||||
char *type;
|
const char *type;
|
||||||
char *name;
|
const char *name;
|
||||||
relation rel;
|
relation rel;
|
||||||
char *array_max;
|
const char *array_max;
|
||||||
};
|
};
|
||||||
typedef struct declaration declaration;
|
typedef struct declaration declaration;
|
||||||
|
|
||||||
|
|
||||||
struct decl_list {
|
struct decl_list {
|
||||||
declaration decl;
|
declaration decl;
|
||||||
struct decl_list *next;
|
struct decl_list *next;
|
||||||
@ -96,9 +94,9 @@ struct struct_def {
|
|||||||
};
|
};
|
||||||
typedef struct struct_def struct_def;
|
typedef struct struct_def struct_def;
|
||||||
|
|
||||||
|
|
||||||
struct case_list {
|
struct case_list {
|
||||||
char *case_name;
|
const char *case_name;
|
||||||
|
int contflag;
|
||||||
declaration case_decl;
|
declaration case_decl;
|
||||||
struct case_list *next;
|
struct case_list *next;
|
||||||
};
|
};
|
||||||
@ -111,36 +109,40 @@ struct union_def {
|
|||||||
};
|
};
|
||||||
typedef struct union_def 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 {
|
struct proc_list {
|
||||||
char *proc_name;
|
const char *proc_name;
|
||||||
char *proc_num;
|
const char *proc_num;
|
||||||
char *arg_type;
|
arg_list args;
|
||||||
char *arg_prefix;
|
int arg_num;
|
||||||
char *res_type;
|
const char *res_type;
|
||||||
char *res_prefix;
|
const char *res_prefix;
|
||||||
struct proc_list *next;
|
struct proc_list *next;
|
||||||
};
|
};
|
||||||
typedef struct proc_list proc_list;
|
typedef struct proc_list proc_list;
|
||||||
|
|
||||||
|
|
||||||
struct version_list {
|
struct version_list {
|
||||||
char *vers_name;
|
const char *vers_name;
|
||||||
char *vers_num;
|
const char *vers_num;
|
||||||
proc_list *procs;
|
proc_list *procs;
|
||||||
struct version_list *next;
|
struct version_list *next;
|
||||||
};
|
};
|
||||||
typedef struct version_list version_list;
|
typedef struct version_list version_list;
|
||||||
|
|
||||||
struct program_def {
|
struct program_def {
|
||||||
char *prog_num;
|
const char *prog_num;
|
||||||
version_list *versions;
|
version_list *versions;
|
||||||
};
|
};
|
||||||
typedef struct program_def program_def;
|
typedef struct program_def program_def;
|
||||||
|
|
||||||
struct definition {
|
struct definition {
|
||||||
char *def_name;
|
const char *def_name;
|
||||||
defkind def_kind;
|
defkind def_kind;
|
||||||
union {
|
union {
|
||||||
const_def co;
|
const_def co;
|
||||||
@ -153,5 +155,14 @@ struct definition {
|
|||||||
};
|
};
|
||||||
typedef struct definition definition;
|
typedef struct definition definition;
|
||||||
|
|
||||||
/* @(#)rpc_parse.h 2.1 88/08/01 4.0 RPCSRC */
|
definition *get_definition(void);
|
||||||
definition *get_definition();
|
|
||||||
|
|
||||||
|
struct bas_type
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int length;
|
||||||
|
struct bas_type *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct bas_type bas_type;
|
||||||
|
253
sunrpc/rpc_sample.c
Normal file
253
sunrpc/rpc_sample.c
Normal file
@ -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");
|
||||||
|
}
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
@ -27,19 +27,24 @@
|
|||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* From: @(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
*/
|
||||||
|
char scan_rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rpc_scan.c, Scanner for the RPC protocol compiler
|
||||||
|
* Copyright (C) 1987, Sun Microsystems, Inc.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <strings.h>
|
#include <string.h>
|
||||||
#include "rpc_scan.h"
|
#include "rpc_scan.h"
|
||||||
|
#include "rpc_parse.h"
|
||||||
#include "rpc_util.h"
|
#include "rpc_util.h"
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
#define startcomment(where) (where[0] == '/' && where[1] == '*')
|
#define startcomment(where) (where[0] == '/' && where[1] == '*')
|
||||||
#define endcomment(where) (where[-1] == '*' && where[0] == '/')
|
#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 int pushed = 0; /* is a token pushed */
|
||||||
static token lasttok; /* last token, if 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
|
void
|
||||||
scan(expect, tokp)
|
scan(tok_kind expect, token *tokp)
|
||||||
tok_kind expect;
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
get_token(tokp);
|
get_token(tokp);
|
||||||
if (tokp->kind != expect) {
|
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
|
void
|
||||||
scan2(expect1, expect2, tokp)
|
scan2(tok_kind expect1, tok_kind expect2, token *tokp)
|
||||||
tok_kind expect1;
|
|
||||||
tok_kind expect2;
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
get_token(tokp);
|
get_token(tokp);
|
||||||
if (tokp->kind != expect1 && tokp->kind != expect2) {
|
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
|
void
|
||||||
scan3(expect1, expect2, expect3, tokp)
|
scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
|
||||||
tok_kind expect1;
|
|
||||||
tok_kind expect2;
|
|
||||||
tok_kind expect3;
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
get_token(tokp);
|
get_token(tokp);
|
||||||
if (tokp->kind != expect1 && tokp->kind != expect2
|
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
|
void
|
||||||
scan_num(tokp)
|
scan_num(token *tokp)
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
get_token(tokp);
|
get_token(tokp);
|
||||||
switch (tokp->kind) {
|
switch (tokp->kind) {
|
||||||
case TOK_IDENT:
|
case TOK_IDENT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error(_("constant or identifier expected"));
|
error("constant or identifier expected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Peek at the next token
|
* Peek at the next token
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
peek(tokp)
|
peek(token *tokp)
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
get_token(tokp);
|
get_token(tokp);
|
||||||
unget_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
|
int
|
||||||
peekscan(expect, tokp)
|
peekscan(tok_kind expect, token *tokp)
|
||||||
tok_kind expect;
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
peek(tokp);
|
peek(tokp);
|
||||||
if (tokp->kind == expect) {
|
if (tokp->kind == expect) {
|
||||||
@ -139,14 +138,11 @@ peekscan(expect, tokp)
|
|||||||
return (0);
|
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
|
void
|
||||||
get_token(tokp)
|
get_token(token *tokp)
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
int commenting;
|
int commenting;
|
||||||
|
|
||||||
@ -161,14 +157,15 @@ get_token(tokp)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (!fgets(curline, MAXLINESIZE, fin)) {
|
if (!fgets(curline, MAXLINESIZE, fin)) {
|
||||||
tokp->kind = TOK_EOF;
|
tokp->kind = TOK_EOF;
|
||||||
*where = 0;
|
*curline = 0;
|
||||||
|
where = curline;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linenum++;
|
linenum++;
|
||||||
if (commenting) {
|
if (commenting) {
|
||||||
break;
|
break;
|
||||||
} else if (cppline(curline)) {
|
} else if (cppline(curline)) {
|
||||||
docppline(curline, &linenum,
|
docppline(curline, &linenum,
|
||||||
&infilename);
|
&infilename);
|
||||||
} else if (directive(curline)) {
|
} else if (directive(curline)) {
|
||||||
printdirective(curline);
|
printdirective(curline);
|
||||||
@ -182,10 +179,12 @@ get_token(tokp)
|
|||||||
where++; /* eat */
|
where++; /* eat */
|
||||||
}
|
}
|
||||||
} else if (commenting) {
|
} else if (commenting) {
|
||||||
where++;
|
for (where++; *where; where++) {
|
||||||
if (endcomment(where)) {
|
if (endcomment(where)) {
|
||||||
where++;
|
where++;
|
||||||
commenting--;
|
commenting--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (startcomment(where)) {
|
} else if (startcomment(where)) {
|
||||||
where += 2;
|
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) {
|
switch (*where) {
|
||||||
case ':':
|
case ':':
|
||||||
@ -256,6 +255,10 @@ get_token(tokp)
|
|||||||
tokp->kind = TOK_STRCONST;
|
tokp->kind = TOK_STRCONST;
|
||||||
findstrconst(&where, &tokp->str);
|
findstrconst(&where, &tokp->str);
|
||||||
break;
|
break;
|
||||||
|
case '\'':
|
||||||
|
tokp->kind = TOK_CHARCONST;
|
||||||
|
findchrconst(&where, &tokp->str);
|
||||||
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
case '0':
|
case '0':
|
||||||
@ -272,13 +275,12 @@ get_token(tokp)
|
|||||||
findconst(&where, &tokp->str);
|
findconst(&where, &tokp->str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!(isalpha(*where) || *where == '_')) {
|
if (!(isalpha(*where) || *where == '_')) {
|
||||||
char buf[100];
|
char buf[100];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
s_print(buf, _("illegal character in file: "));
|
s_print(buf, "illegal character in file: ");
|
||||||
p = buf + strlen(buf);
|
p = buf + strlen(buf);
|
||||||
if (isprint(*where)) {
|
if (isprint(*where)) {
|
||||||
s_print(p, "%c", *where);
|
s_print(p, "%c", *where);
|
||||||
@ -292,46 +294,67 @@ get_token(tokp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unget_token(token *tokp)
|
||||||
static
|
|
||||||
unget_token(tokp)
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
lasttok = *tokp;
|
lasttok = *tokp;
|
||||||
pushed = 1;
|
pushed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
findstrconst(const char **str, const char **val)
|
||||||
findstrconst(str, val)
|
|
||||||
char **str;
|
|
||||||
char **val;
|
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
|
char *tmp;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
p = *str;
|
p = *str;
|
||||||
do {
|
do {
|
||||||
*p++;
|
p++;
|
||||||
} while (*p && *p != '"');
|
} while (*p && *p != '"');
|
||||||
if (*p == 0) {
|
if (*p == 0) {
|
||||||
error(_("unterminated string constant"));
|
error("unterminated string constant");
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
size = p - *str;
|
size = p - *str;
|
||||||
*val = alloc(size + 1);
|
tmp = alloc(size + 1);
|
||||||
(void) strncpy(*val, *str, size);
|
strncpy(tmp, *str, size);
|
||||||
(*val)[size] = 0;
|
tmp[size] = 0;
|
||||||
|
*val = tmp;
|
||||||
*str = p;
|
*str = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
findconst(str, val)
|
findchrconst(const char **str, const char **val)
|
||||||
char **str;
|
|
||||||
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;
|
int size;
|
||||||
|
|
||||||
p = *str;
|
p = *str;
|
||||||
@ -346,14 +369,13 @@ findconst(str, val)
|
|||||||
} while (isdigit(*p));
|
} while (isdigit(*p));
|
||||||
}
|
}
|
||||||
size = p - *str;
|
size = p - *str;
|
||||||
*val = alloc(size + 1);
|
tmp = alloc(size + 1);
|
||||||
(void) strncpy(*val, *str, size);
|
strncpy(tmp, *str, size);
|
||||||
(*val)[size] = 0;
|
tmp[size] = 0;
|
||||||
|
*val = tmp;
|
||||||
*str = p;
|
*str = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static token symbols[] = {
|
static token symbols[] = {
|
||||||
{TOK_CONST, "const"},
|
{TOK_CONST, "const"},
|
||||||
{TOK_UNION, "union"},
|
{TOK_UNION, "union"},
|
||||||
@ -379,16 +401,13 @@ static token symbols[] = {
|
|||||||
{TOK_EOF, "??????"},
|
{TOK_EOF, "??????"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
findkind(const char **mark, token *tokp)
|
||||||
findkind(mark, tokp)
|
|
||||||
char **mark;
|
|
||||||
token *tokp;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
token *s;
|
token *s;
|
||||||
char *str;
|
const char *str;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
str = *mark;
|
str = *mark;
|
||||||
for (s = symbols; s->kind != TOK_EOF; s++) {
|
for (s = symbols; s->kind != TOK_EOF; s++) {
|
||||||
@ -404,38 +423,33 @@ findkind(mark, tokp)
|
|||||||
}
|
}
|
||||||
tokp->kind = TOK_IDENT;
|
tokp->kind = TOK_IDENT;
|
||||||
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
|
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
|
||||||
tokp->str = alloc(len + 1);
|
tmp = alloc(len + 1);
|
||||||
(void) strncpy(tokp->str, str, len);
|
strncpy(tmp, str, len);
|
||||||
tokp->str[len] = 0;
|
tmp[len] = 0;
|
||||||
|
tokp->str = tmp;
|
||||||
*mark = str + len;
|
*mark = str + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
cppline(line)
|
cppline(const char *line)
|
||||||
char *line;
|
|
||||||
{
|
{
|
||||||
return (line == curline && *line == '#');
|
return (line == curline && *line == '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
directive(line)
|
directive(const char *line)
|
||||||
char *line;
|
|
||||||
{
|
{
|
||||||
return (line == curline && *line == '%');
|
return (line == curline && *line == '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
printdirective(line)
|
printdirective(const char *line)
|
||||||
char *line;
|
|
||||||
{
|
{
|
||||||
f_print(fout, "%s", line + 1);
|
f_print(fout, "%s", line + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
docppline(line, lineno, fname)
|
docppline(const char *line, int *lineno, const char **fname)
|
||||||
char *line;
|
|
||||||
int *lineno;
|
|
||||||
char **fname;
|
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
int num;
|
int num;
|
||||||
@ -453,7 +467,7 @@ docppline(line, lineno, fname)
|
|||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
if (*line != '"') {
|
if (*line != '"') {
|
||||||
error(_("preprocessor error"));
|
error("preprocessor error");
|
||||||
}
|
}
|
||||||
line++;
|
line++;
|
||||||
p = file = alloc(strlen(line) + 1);
|
p = file = alloc(strlen(line) + 1);
|
||||||
@ -461,7 +475,7 @@ docppline(line, lineno, fname)
|
|||||||
*p++ = *line++;
|
*p++ = *line++;
|
||||||
}
|
}
|
||||||
if (*line == 0) {
|
if (*line == 0) {
|
||||||
error(_("preprocessor error"));
|
error("preprocessor error");
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
if (*file == 0) {
|
if (*file == 0) {
|
||||||
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* rpc_scan.h, Definitions for the RPCL scanner
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -39,6 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
enum tok_kind {
|
enum tok_kind {
|
||||||
TOK_IDENT,
|
TOK_IDENT,
|
||||||
|
TOK_CHARCONST,
|
||||||
TOK_STRCONST,
|
TOK_STRCONST,
|
||||||
TOK_LPAREN,
|
TOK_LPAREN,
|
||||||
TOK_RPAREN,
|
TOK_RPAREN,
|
||||||
@ -83,7 +84,7 @@ typedef enum tok_kind tok_kind;
|
|||||||
*/
|
*/
|
||||||
struct token {
|
struct token {
|
||||||
tok_kind kind;
|
tok_kind kind;
|
||||||
char *str;
|
const char *str;
|
||||||
};
|
};
|
||||||
typedef struct token token;
|
typedef struct token token;
|
||||||
|
|
||||||
@ -91,11 +92,14 @@ typedef struct token token;
|
|||||||
/*
|
/*
|
||||||
* routine interface
|
* routine interface
|
||||||
*/
|
*/
|
||||||
void scanprint();
|
void scan(tok_kind expect, token *tokp);
|
||||||
void scan();
|
void scan2(tok_kind expect1, tok_kind expect2, token *tokp);
|
||||||
void scan2();
|
void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp);
|
||||||
void scan3();
|
void scan_num(token *tokp);
|
||||||
void scan_num();
|
void peek(token *tokp);
|
||||||
void peek();
|
int peekscan(tok_kind expect, token *tokp);
|
||||||
int peekscan();
|
void get_token(token *tokp);
|
||||||
void get_token();
|
void expected1(tok_kind exp1);
|
||||||
|
void expected2(tok_kind exp1, tok_kind exp2);
|
||||||
|
void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
170
sunrpc/rpc_tblout.c
Normal file
170
sunrpc/rpc_tblout.c
Normal file
@ -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");
|
||||||
|
}
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
@ -27,84 +27,96 @@
|
|||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* rpc_util.c, Utility routines for the RPC protocol compiler
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "rpc_scan.h"
|
#include "rpc_scan.h"
|
||||||
#include "rpc_parse.h"
|
#include "rpc_parse.h"
|
||||||
#include "rpc_util.h"
|
#include "rpc_util.h"
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
|
#define ARGEXT "argument"
|
||||||
|
|
||||||
char curline[MAXLINESIZE]; /* current read line */
|
char curline[MAXLINESIZE]; /* current read line */
|
||||||
char *where = curline; /* current point in line */
|
const char *where = curline; /* current point in line */
|
||||||
int linenum = 0; /* current line number */
|
int linenum = 0; /* current line number */
|
||||||
|
|
||||||
char *infilename; /* input filename */
|
const char *infilename; /* input filename */
|
||||||
|
|
||||||
#define NFILES 4
|
#define NFILES 7
|
||||||
char *outfiles[NFILES]; /* output file names */
|
const char *outfiles[NFILES]; /* output file names */
|
||||||
int nfiles;
|
int nfiles;
|
||||||
|
|
||||||
FILE *fout; /* file pointer of current output */
|
FILE *fout; /* file pointer of current output */
|
||||||
FILE *fin; /* file pointer of current input */
|
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;
|
where = curline;
|
||||||
linenum = 0;
|
linenum = 0;
|
||||||
defined = NULL;
|
defined = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* string equality
|
* string equality
|
||||||
*/
|
*/
|
||||||
streq(a, b)
|
int
|
||||||
char *a;
|
streq(const char *a, const char *b)
|
||||||
char *b;
|
|
||||||
{
|
{
|
||||||
return (strcmp(a, b) == 0);
|
return (strcmp(a, b) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find a value in a list
|
* find a value in a list
|
||||||
*/
|
*/
|
||||||
char *
|
definition *
|
||||||
findval(lst, val, cmp)
|
findval(list *lst, const char *val,
|
||||||
list *lst;
|
int (*cmp)(const definition *, const char *))
|
||||||
char *val;
|
|
||||||
int (*cmp) ();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
for (; lst != NULL; lst = lst->next) {
|
for (; lst != NULL; lst = lst->next) {
|
||||||
if ((*cmp) (lst->val, val)) {
|
if (cmp(lst->val, val)) {
|
||||||
return (lst->val);
|
return (lst->val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* store a value in a list
|
* store a value in a list
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
storeval(lstp, val)
|
storeval(list **lstp, definition *val)
|
||||||
list **lstp;
|
|
||||||
char *val;
|
|
||||||
{
|
{
|
||||||
list **l;
|
list **l;
|
||||||
list *lst;
|
list *lst;
|
||||||
|
|
||||||
|
|
||||||
for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
|
for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
|
||||||
lst = ALLOC(list);
|
lst = ALLOC(list);
|
||||||
lst->val = val;
|
lst->val = val;
|
||||||
@ -112,24 +124,18 @@ storeval(lstp, val)
|
|||||||
*l = lst;
|
*l = lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
static
|
findit(const definition *def, const char *type)
|
||||||
findit(def, type)
|
|
||||||
definition *def;
|
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
return (streq(def->def_name, type));
|
return (streq(def->def_name, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
static char *
|
fixit(const char *type, const char *orig)
|
||||||
fixit(type, orig)
|
|
||||||
char *type;
|
|
||||||
char *orig;
|
|
||||||
{
|
{
|
||||||
definition *def;
|
definition *def;
|
||||||
|
|
||||||
def = (definition *) FINDVAL(defined, type, findit);
|
def = findval(defined, type, findit);
|
||||||
if (def == NULL || def->def_kind != DEF_TYPEDEF) {
|
if (def == NULL || def->def_kind != DEF_TYPEDEF) {
|
||||||
return (orig);
|
return (orig);
|
||||||
}
|
}
|
||||||
@ -143,29 +149,25 @@ fixit(type, orig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
fixtype(type)
|
fixtype(const char *type)
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
return (fixit(type, type));
|
return (fixit(type, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
stringfix(type)
|
stringfix(const char *type)
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
if (streq(type, "string")) {
|
if (streq(type, "string")) {
|
||||||
return ("wrapstring");
|
return "wrapstring";
|
||||||
} else {
|
}
|
||||||
return (type);
|
else {
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ptype(prefix, type, follow)
|
ptype(const char *prefix, const char *type, int follow)
|
||||||
char *prefix;
|
|
||||||
char *type;
|
|
||||||
int follow;
|
|
||||||
{
|
{
|
||||||
if (prefix != NULL) {
|
if (prefix != NULL) {
|
||||||
if (streq(prefix, "enum")) {
|
if (streq(prefix, "enum")) {
|
||||||
@ -183,11 +185,8 @@ ptype(prefix, type, follow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
static
|
typedefed(const definition *def, const char *type)
|
||||||
typedefed(def, type)
|
|
||||||
definition *def;
|
|
||||||
char *type;
|
|
||||||
{
|
{
|
||||||
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
|
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
|
||||||
return (0);
|
return (0);
|
||||||
@ -196,9 +195,8 @@ typedefed(def, type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isvectordef(type, rel)
|
int
|
||||||
char *type;
|
isvectordef(const char *type, relation rel)
|
||||||
relation rel;
|
|
||||||
{
|
{
|
||||||
definition *def;
|
definition *def;
|
||||||
|
|
||||||
@ -211,7 +209,7 @@ isvectordef(type, rel)
|
|||||||
case REL_POINTER:
|
case REL_POINTER:
|
||||||
return (0);
|
return (0);
|
||||||
case REL_ALIAS:
|
case REL_ALIAS:
|
||||||
def = (definition *) FINDVAL(defined, type, typedefed);
|
def = findval(defined, type, typedefed);
|
||||||
if (def == NULL) {
|
if (def == NULL) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -221,50 +219,50 @@ isvectordef(type, rel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
static char *
|
locase(const char *str)
|
||||||
locase(str)
|
|
||||||
char *str;
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
static char buf[100];
|
static char buf[100];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
|
||||||
while (c = *str++) {
|
while ((c = *str++)!=0) {
|
||||||
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
|
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pvname_svc(const char *pname, const char *vnum)
|
||||||
|
{
|
||||||
|
f_print(fout, "%s_%s_svc", locase(pname), vnum);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pvname(pname, vnum)
|
pvname(const char *pname, const char *vnum)
|
||||||
char *pname;
|
|
||||||
char *vnum;
|
|
||||||
{
|
{
|
||||||
f_print(fout, "%s_%s", locase(pname), 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
|
void
|
||||||
error(msg)
|
error(const char *msg)
|
||||||
char *msg;
|
|
||||||
{
|
{
|
||||||
printwhere();
|
printwhere();
|
||||||
f_print(stderr, _("%s, line %d: "), infilename, linenum);
|
f_print(stderr, "%s, line %d: ", infilename, linenum);
|
||||||
f_print(stderr, "%s\n", msg);
|
f_print(stderr, "%s\n", msg);
|
||||||
crash();
|
crash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Something went wrong, unlink any files that we may have created and then
|
* Something went wrong, unlink any files that we may have created and then
|
||||||
* die.
|
* die.
|
||||||
*/
|
*/
|
||||||
crash()
|
void
|
||||||
|
crash(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -274,55 +272,50 @@ crash()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
record_open(file)
|
record_open(const char *file)
|
||||||
char *file;
|
|
||||||
{
|
{
|
||||||
if (nfiles < NFILES) {
|
if (nfiles < NFILES) {
|
||||||
outfiles[nfiles++] = file;
|
outfiles[nfiles++] = file;
|
||||||
} else {
|
}
|
||||||
f_print(stderr, _("too many files!\n"));
|
else {
|
||||||
|
f_print(stderr, "too many files!\n");
|
||||||
crash();
|
crash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char expectbuf[100];
|
static char expectbuf[100];
|
||||||
static char *toktostr();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* error, token encountered was not the expected one
|
* error, token encountered was not the expected one
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
expected1(exp1)
|
expected1(tok_kind exp1)
|
||||||
tok_kind exp1;
|
|
||||||
{
|
{
|
||||||
s_print(expectbuf, _("expected '%s'"),
|
s_print(expectbuf, "expected '%s'",
|
||||||
toktostr(exp1));
|
toktostr(exp1));
|
||||||
error(expectbuf);
|
error(expectbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* error, token encountered was not one of two expected ones
|
* error, token encountered was not one of two expected ones
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
expected2(exp1, exp2)
|
expected2(tok_kind exp1, tok_kind exp2)
|
||||||
tok_kind exp1, exp2;
|
|
||||||
{
|
{
|
||||||
s_print(expectbuf, _("expected '%s' or '%s'"),
|
s_print(expectbuf, "expected '%s' or '%s'",
|
||||||
toktostr(exp1),
|
toktostr(exp1),
|
||||||
toktostr(exp2));
|
toktostr(exp2));
|
||||||
error(expectbuf);
|
error(expectbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* error, token encountered was not one of 3 expected ones
|
* error, token encountered was not one of 3 expected ones
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
expected3(exp1, exp2, exp3)
|
expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
|
||||||
tok_kind exp1, exp2, exp3;
|
|
||||||
{
|
{
|
||||||
s_print(expectbuf, _("expected '%s', '%s' or '%s'"),
|
s_print(expectbuf, "expected '%s', '%s' or '%s'",
|
||||||
toktostr(exp1),
|
toktostr(exp1),
|
||||||
toktostr(exp2),
|
toktostr(exp2),
|
||||||
toktostr(exp3));
|
toktostr(exp3));
|
||||||
@ -330,9 +323,7 @@ expected3(exp1, exp2, exp3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tabify(f, tab)
|
tabify(FILE *f, int tab)
|
||||||
FILE *f;
|
|
||||||
int tab;
|
|
||||||
{
|
{
|
||||||
while (tab--) {
|
while (tab--) {
|
||||||
(void) fputc('\t', f);
|
(void) fputc('\t', f);
|
||||||
@ -340,7 +331,6 @@ tabify(f, tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static token tokstrings[] = {
|
static token tokstrings[] = {
|
||||||
{TOK_IDENT, "identifier"},
|
{TOK_IDENT, "identifier"},
|
||||||
{TOK_CONST, "const"},
|
{TOK_CONST, "const"},
|
||||||
@ -378,9 +368,8 @@ static token tokstrings[] = {
|
|||||||
{TOK_EOF, "??????"}
|
{TOK_EOF, "??????"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
toktostr(kind)
|
toktostr(tok_kind kind)
|
||||||
tok_kind kind;
|
|
||||||
{
|
{
|
||||||
token *sp;
|
token *sp;
|
||||||
|
|
||||||
@ -388,10 +377,8 @@ toktostr(kind)
|
|||||||
return (sp->str);
|
return (sp->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
printbuf(void)
|
||||||
static
|
|
||||||
printbuf()
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
int i;
|
int i;
|
||||||
@ -399,7 +386,7 @@ printbuf()
|
|||||||
|
|
||||||
# define TABSIZE 4
|
# define TABSIZE 4
|
||||||
|
|
||||||
for (i = 0; c = curline[i]; i++) {
|
for (i = 0; (c = curline[i])!=0; i++) {
|
||||||
if (c == '\t') {
|
if (c == '\t') {
|
||||||
cnt = 8 - (i % TABSIZE);
|
cnt = 8 - (i % TABSIZE);
|
||||||
c = ' ';
|
c = ' ';
|
||||||
@ -412,9 +399,8 @@ printbuf()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
static
|
printwhere(void)
|
||||||
printwhere()
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
@ -434,3 +420,68 @@ printwhere()
|
|||||||
}
|
}
|
||||||
(void) fputc('\n', stderr);
|
(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* 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
|
* 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
|
* 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
|
* 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
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
* 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
|
* Sun RPC is provided with no support and without any obligation on the
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||||
* modification or enhancement.
|
* modification or enhancement.
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||||
* OR ANY PART THEREOF.
|
* OR ANY PART THEREOF.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* or profits or other special, indirect and consequential damages, even if
|
||||||
* Sun has been advised of the possibility of such damages.
|
* Sun has been advised of the possibility of such damages.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* Sun Microsystems, Inc.
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* 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
|
* 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(size) malloc((unsigned)(size))
|
||||||
#define ALLOC(object) (object *) malloc(sizeof(object))
|
#define ALLOC(object) (object *) malloc(sizeof(object))
|
||||||
|
|
||||||
/* extern char *sprintf(); --roland@gnu */
|
|
||||||
|
|
||||||
#define s_print (void) sprintf
|
#define s_print (void) sprintf
|
||||||
#define f_print (void) fprintf
|
#define f_print (void) fprintf
|
||||||
|
|
||||||
struct list {
|
struct list {
|
||||||
char *val;
|
definition *val;
|
||||||
struct list *next;
|
struct list *next;
|
||||||
};
|
};
|
||||||
typedef struct list list;
|
typedef struct list list;
|
||||||
|
|
||||||
|
#define PUT 1
|
||||||
|
#define GET 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
#define MAXLINESIZE 1024
|
#define MAXLINESIZE 1024
|
||||||
extern char curline[MAXLINESIZE];
|
extern char curline[MAXLINESIZE];
|
||||||
extern char *where;
|
extern const char *where;
|
||||||
extern int linenum;
|
extern int linenum;
|
||||||
|
|
||||||
extern char *infilename;
|
extern const char *infilename;
|
||||||
extern FILE *fout;
|
extern FILE *fout;
|
||||||
extern FILE *fin;
|
extern FILE *fin;
|
||||||
|
|
||||||
extern list *defined;
|
extern list *defined;
|
||||||
|
|
||||||
|
|
||||||
|
extern bas_type *typ_list_h;
|
||||||
|
extern bas_type *typ_list_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* All the option flags
|
||||||
|
*/
|
||||||
|
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 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other flags related with inetd jumpstart.
|
||||||
|
*/
|
||||||
|
extern int indefinitewait;
|
||||||
|
extern int exitnow;
|
||||||
|
extern int timerflag;
|
||||||
|
|
||||||
|
extern int nonfatalerrors;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rpc_util routines
|
* rpc_util routines
|
||||||
*/
|
*/
|
||||||
void storeval();
|
void storeval(list **lstp, definition *val);
|
||||||
|
#define STOREVAL(list,item) storeval(list,item)
|
||||||
|
|
||||||
#define STOREVAL(list,item) \
|
definition *findval(list *lst, const char *val,
|
||||||
storeval(list,(char *)item)
|
int (*cmp)(const definition *, const char *));
|
||||||
|
#define FINDVAL(list,item,finder) findval(list, item, finder)
|
||||||
|
|
||||||
char *findval();
|
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);
|
||||||
|
|
||||||
#define FINDVAL(list,item,finder) \
|
|
||||||
findval(list, (char *) item, finder)
|
|
||||||
|
|
||||||
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
|
* rpc_cout routines
|
||||||
*/
|
*/
|
||||||
void cprint();
|
void emit(definition *def);
|
||||||
void emit();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rpc_hout routines
|
* rpc_hout routines
|
||||||
*/
|
*/
|
||||||
void print_datadef();
|
void print_datadef(definition *def);
|
||||||
|
void print_funcdef(definition *def);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rpc_svcout routines
|
* rpc_svcout routines
|
||||||
*/
|
*/
|
||||||
void write_most();
|
void write_most(const char *infile, int netflag, int nomain);
|
||||||
void write_register();
|
void write_register(void);
|
||||||
void write_rest();
|
void write_rest(void);
|
||||||
void write_programs();
|
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
|
* rpc_clntout routines
|
||||||
*/
|
*/
|
||||||
void write_stubs();
|
void write_stubs(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rpc_tblout routines
|
||||||
|
*/
|
||||||
|
void write_tables(void);
|
||||||
|
@ -53,16 +53,16 @@ ENTRY(strlen)
|
|||||||
je L2 /* yes => return */
|
je L2 /* yes => return */
|
||||||
|
|
||||||
incl %eax /* increment pointer */
|
incl %eax /* increment pointer */
|
||||||
xorl $3, %edx /* was alignment = 3? */
|
cmpb %dh, (%eax) /* is byte NUL? */
|
||||||
|
|
||||||
jz L1 /* yes => now it is aligned and start loop */
|
|
||||||
|
|
||||||
L0: cmpb %dh, (%eax) /* is byte NUL? */
|
|
||||||
je L2 /* yes => return */
|
je L2 /* yes => return */
|
||||||
|
|
||||||
incl %eax /* increment pointer */
|
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 */
|
je L2 /* yes => return */
|
||||||
|
|
||||||
incl %eax /* increment pointer */
|
incl %eax /* increment pointer */
|
||||||
|
@ -46,3 +46,4 @@ ENTRY (_setjmp)
|
|||||||
#else
|
#else
|
||||||
jmp C_SYMBOL_NAME (__sigsetjmp)
|
jmp C_SYMBOL_NAME (__sigsetjmp)
|
||||||
#endif
|
#endif
|
||||||
|
PSEUDO_END (_setjmp)
|
||||||
|
@ -44,3 +44,4 @@ ENTRY (setjmp)
|
|||||||
#else
|
#else
|
||||||
jmp C_SYMBOL_NAME (__sigsetjmp)
|
jmp C_SYMBOL_NAME (__sigsetjmp)
|
||||||
#endif
|
#endif
|
||||||
|
PSEUDO_END (setjmp)
|
||||||
|
@ -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.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# 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.
|
# $(BUILD_CFLAGS) needs to come last because it contains unwanted -Is.
|
||||||
$(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
|
$(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
|
||||||
posix1_lim.h local_lim.h
|
posix1_lim.h local_lim.h
|
||||||
cwd=`pwd`; cd $(common-objdir); \
|
cwd=`pwd`; cd $(objpfx).; \
|
||||||
$(BUILD_CC) $(cded-objdir-includes) $(BUILD_CFLAGS) \
|
$(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
|
common-generated := $(common-generated) stdio_lim.h mk-stdiolim
|
||||||
|
@ -91,7 +91,7 @@ __opendir (const char *name)
|
|||||||
|
|
||||||
dirp->fd = fd;
|
dirp->fd = fd;
|
||||||
|
|
||||||
__libc_lock_init (dirp->lock)
|
__libc_lock_init (dirp->lock);
|
||||||
|
|
||||||
return dirp;
|
return dirp;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ ENTRY(__clone)
|
|||||||
jz thread_start
|
jz thread_start
|
||||||
|
|
||||||
ret
|
ret
|
||||||
.size __clone,.-__clone
|
PSEUDO_END (__clone)
|
||||||
|
|
||||||
SYSCALL_ERROR_HANDLER
|
SYSCALL_ERROR_HANDLER
|
||||||
|
|
||||||
@ -74,10 +74,6 @@ thread_start:
|
|||||||
subl %ebp,%ebp /* terminate the stack frame */
|
subl %ebp,%ebp /* terminate the stack frame */
|
||||||
call *%ebx
|
call *%ebx
|
||||||
pushl %eax
|
pushl %eax
|
||||||
#ifdef PIC
|
call JUMPTARGET (_exit)
|
||||||
call _exit@PLT
|
|
||||||
#else
|
|
||||||
call _exit
|
|
||||||
#endif
|
|
||||||
|
|
||||||
weak_alias(__clone, clone)
|
weak_alias(__clone, clone)
|
||||||
|
@ -27,6 +27,8 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
.text
|
.text
|
||||||
ENTRY (__clone)
|
ENTRY (__clone)
|
||||||
|
CALL_MCOUNT
|
||||||
|
|
||||||
/* Sanity check arguments. */
|
/* Sanity check arguments. */
|
||||||
movel #-EINVAL, %d0
|
movel #-EINVAL, %d0
|
||||||
movel 4(%sp), %a0 /* no NULL function pointers */
|
movel 4(%sp), %a0 /* no NULL function pointers */
|
||||||
@ -72,5 +74,6 @@ thread_start:
|
|||||||
#else
|
#else
|
||||||
jbsr _exit
|
jbsr _exit
|
||||||
#endif
|
#endif
|
||||||
|
PSEUDO_END (__clone)
|
||||||
|
|
||||||
weak_alias (__clone, clone)
|
weak_alias (__clone, clone)
|
||||||
|
@ -22,6 +22,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
SYSCALL_ERROR_HANDLER
|
SYSCALL_ERROR_HANDLER
|
||||||
|
|
||||||
ENTRY (__mmap)
|
ENTRY (__mmap)
|
||||||
|
CALL_MCOUNT
|
||||||
|
|
||||||
move.l #SYS_ify (mmap), %d0 /* System call number in %d0. */
|
move.l #SYS_ify (mmap), %d0 /* System call number in %d0. */
|
||||||
|
|
||||||
@ -40,5 +41,6 @@ ENTRY (__mmap)
|
|||||||
mmap is declared to return a pointer. */
|
mmap is declared to return a pointer. */
|
||||||
move.l %d0, %a0
|
move.l %d0, %a0
|
||||||
rts
|
rts
|
||||||
|
PSEUDO_END (__mmap)
|
||||||
|
|
||||||
weak_alias (__mmap, mmap)
|
weak_alias (__mmap, mmap)
|
||||||
|
@ -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;
|
|
||||||
};
|
|
@ -20,9 +20,12 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
.text
|
.text
|
||||||
ENTRY (__sigreturn)
|
ENTRY (__sigreturn)
|
||||||
|
CALL_MCOUNT
|
||||||
|
|
||||||
addq.l #4, %sp /* Pop the return PC. */
|
addq.l #4, %sp /* Pop the return PC. */
|
||||||
DO_CALL (#SYS_ify (sigreturn), 0)
|
DO_CALL (#SYS_ify (sigreturn), 0)
|
||||||
/* Do the system call; it never returns. */
|
/* Do the system call; it never returns. */
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
PSEUDO_END (__sigreturn)
|
||||||
|
|
||||||
weak_alias (__sigreturn, sigreturn)
|
weak_alias (__sigreturn, sigreturn)
|
||||||
|
@ -35,6 +35,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
.globl P(__,socket)
|
.globl P(__,socket)
|
||||||
ENTRY (P(__,socket))
|
ENTRY (P(__,socket))
|
||||||
|
CALL_MCOUNT
|
||||||
|
|
||||||
/* Save registers. */
|
/* Save registers. */
|
||||||
move.l %d2, %a0
|
move.l %d2, %a0
|
||||||
@ -58,5 +59,6 @@ ENTRY (P(__,socket))
|
|||||||
|
|
||||||
/* Successful; return the syscall's value. */
|
/* Successful; return the syscall's value. */
|
||||||
rts
|
rts
|
||||||
|
PSEUDO_END (P(__,socket))
|
||||||
|
|
||||||
weak_alias (P(__,socket), socket)
|
weak_alias (P(__,socket), socket)
|
||||||
|
@ -18,14 +18,20 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
|
|
||||||
|
/* Please consult the file sysdeps/unix/sysv/linux/m68k/sysdep.h for
|
||||||
|
more information about the value -128 used below.*/
|
||||||
|
|
||||||
.text
|
.text
|
||||||
SYSCALL_ERROR_HANDLER
|
SYSCALL_ERROR_HANDLER
|
||||||
ENTRY (syscall)
|
ENTRY (syscall)
|
||||||
move.l (%sp)+, %a0 /* Pop return address. */
|
CALL_MCOUNT
|
||||||
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. */
|
|
||||||
|
|
||||||
error: pea (%a0)
|
move.l 4(%sp), %d0 /* Load syscall number. */
|
||||||
jra syscall_error
|
_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)
|
||||||
|
@ -46,7 +46,7 @@ __errno = errno /* This name is expected by the MT code. */
|
|||||||
|
|
||||||
/* The syscall stubs jump here when they detect an error. */
|
/* The syscall stubs jump here when they detect an error. */
|
||||||
|
|
||||||
ENTRY(__syscall_error)
|
ENTRY (__syscall_error)
|
||||||
neg.l %d0
|
neg.l %d0
|
||||||
move.l %d0, errno
|
move.l %d0, errno
|
||||||
#ifdef _LIBC_REENTRANT
|
#ifdef _LIBC_REENTRANT
|
||||||
@ -59,14 +59,15 @@ ENTRY(__syscall_error)
|
|||||||
return a pointer. */
|
return a pointer. */
|
||||||
move.l %d0, %a0
|
move.l %d0, %a0
|
||||||
rts
|
rts
|
||||||
.size __syscall_error, . - __syscall_error
|
PSEUDO_END (__syscall_error)
|
||||||
#endif /* PIC */
|
#endif /* PIC */
|
||||||
|
|
||||||
ERRNO(__errno_location)
|
ENTRY (__errno_location)
|
||||||
|
CALL_MCOUNT
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
move.l (%pc, errno@GOTPC), %a0
|
move.l (%pc, errno@GOTPC), %a0
|
||||||
#else
|
#else
|
||||||
lea errno, %a0
|
lea errno, %a0
|
||||||
#endif
|
#endif
|
||||||
rts
|
rts
|
||||||
.size __errno_location, . - __errno_location
|
PSEUDO_END (__errno_location)
|
||||||
|
@ -33,8 +33,6 @@ Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#ifdef ASSEMBLER
|
#ifdef ASSEMBLER
|
||||||
|
|
||||||
#define POUND #
|
|
||||||
|
|
||||||
/* Define an entry point visible from C. */
|
/* Define an entry point visible from C. */
|
||||||
#define ENTRY(name) \
|
#define ENTRY(name) \
|
||||||
.globl name; \
|
.globl name; \
|
||||||
@ -67,14 +65,26 @@ Cambridge, MA 02139, USA. */
|
|||||||
#define syscall_error __syscall_error
|
#define syscall_error __syscall_error
|
||||||
|
|
||||||
/* Linux uses a negative return value to indicate syscall errors, unlike
|
/* 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) \
|
#define PSEUDO(name, syscall_name, args) \
|
||||||
.text; \
|
.text; \
|
||||||
SYSCALL_ERROR_HANDLER \
|
SYSCALL_ERROR_HANDLER \
|
||||||
ENTRY (name) \
|
ENTRY (name) \
|
||||||
DO_CALL (POUND SYS_ify (syscall_name), args); \
|
DO_CALL (&SYS_ify (syscall_name), args); \
|
||||||
tst.l %d0; \
|
moveq.l &-128, %d1; \
|
||||||
jmi syscall_error;
|
cmp.l %d1, %d0; \
|
||||||
|
jcc syscall_error
|
||||||
|
|
||||||
|
#undef PSEUDO_END
|
||||||
|
#define PSEUDO_END(name) .size name, . - name
|
||||||
|
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
/* Store (- %d0) into errno through the GOT. */
|
/* Store (- %d0) into errno through the GOT. */
|
||||||
@ -88,7 +98,7 @@ syscall_error: \
|
|||||||
move.l %d0, -(%sp); \
|
move.l %d0, -(%sp); \
|
||||||
jbsr __errno_location@PLTPC; \
|
jbsr __errno_location@PLTPC; \
|
||||||
move.l (%sp)+, (%a0); \
|
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 \
|
/* Copy return value to %a0 for syscalls that are declared to return \
|
||||||
a pointer (e.g., mmap). */ \
|
a pointer (e.g., mmap). */ \
|
||||||
move.l %d0, %a0; \
|
move.l %d0, %a0; \
|
||||||
@ -100,7 +110,7 @@ syscall_error: \
|
|||||||
move.l (errno@GOTPC, %pc), %a0; \
|
move.l (errno@GOTPC, %pc), %a0; \
|
||||||
neg.l %d0; \
|
neg.l %d0; \
|
||||||
move.l %d0, (%a0); \
|
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 \
|
/* Copy return value to %a0 for syscalls that are declared to return \
|
||||||
a pointer (e.g., mmap). */ \
|
a pointer (e.g., mmap). */ \
|
||||||
move.l %d0, %a0; \
|
move.l %d0, %a0; \
|
||||||
@ -138,7 +148,7 @@ syscall_error: \
|
|||||||
#define DO_CALL(syscall, args) \
|
#define DO_CALL(syscall, args) \
|
||||||
move.l syscall, %d0; \
|
move.l syscall, %d0; \
|
||||||
DOARGS_##args \
|
DOARGS_##args \
|
||||||
trap POUND 0; \
|
trap &0; \
|
||||||
UNDOARGS_##args
|
UNDOARGS_##args
|
||||||
|
|
||||||
#define DOARGS_0 /* No arguments to frob. */
|
#define DOARGS_0 /* No arguments to frob. */
|
||||||
|
@ -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,
|
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <sys/reboot.h>
|
||||||
|
|
||||||
extern int __syscall_reboot (int magic, int magic_too, int flag);
|
extern int __syscall_reboot (int magic, int magic_too, int flag);
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
sleep (unsigned int seconds)
|
sleep (unsigned int seconds)
|
||||||
|
@ -13,6 +13,7 @@ geteuid - geteuid 0 __geteuid geteuid
|
|||||||
getpgid - getpgid 1 __getpgid getpgid
|
getpgid - getpgid 1 __getpgid getpgid
|
||||||
getpgrp - getpgrp 0 getpgrp
|
getpgrp - getpgrp 0 getpgrp
|
||||||
getppid - getppid 0 __getppid getppid
|
getppid - getppid 0 __getppid getppid
|
||||||
|
getresuid - getresuid 3 getresuid
|
||||||
getsid - getsid 1 getsid
|
getsid - getsid 1 getsid
|
||||||
init_module EXTRA init_module 5 init_module
|
init_module EXTRA init_module 5 init_module
|
||||||
ioperm - ioperm 3 ioperm
|
ioperm - ioperm 3 ioperm
|
||||||
@ -46,6 +47,7 @@ select - _newselect 5 __select select
|
|||||||
setfsgid EXTRA setfsgid 1 setfsgid
|
setfsgid EXTRA setfsgid 1 setfsgid
|
||||||
setfsuid EXTRA setfsuid 1 setfsuid
|
setfsuid EXTRA setfsuid 1 setfsuid
|
||||||
setpgid - setpgid 2 __setpgid setpgid
|
setpgid - setpgid 2 __setpgid setpgid
|
||||||
|
setresuid - setresuid 3 setresuid
|
||||||
sigpending - sigpending 1 sigpending
|
sigpending - sigpending 1 sigpending
|
||||||
sigprocmask - sigprocmask 3 __sigprocmask sigprocmask
|
sigprocmask - sigprocmask 3 __sigprocmask sigprocmask
|
||||||
s_sysctl sysctl _sysctl 1 __syscall__sysctl
|
s_sysctl sysctl _sysctl 1 __syscall__sysctl
|
||||||
|
@ -155,4 +155,13 @@ extern int utimes __P ((__const char *__file, struct timeval __tvp[2]));
|
|||||||
|
|
||||||
__END_DECLS
|
__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 */
|
#endif /* sys/time.h */
|
||||||
|
Reference in New Issue
Block a user