From 0d204b0a522b9fef2168e1808a0566c9209d0893 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 17 Oct 1996 01:51:38 +0000 Subject: update from main archive 961016 Thu Oct 17 01:55:34 1996 Ulrich Drepper * 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 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 * sysdeps/unix/opendir.c: Add semicolon for consistency. Wed Oct 16 12:26:53 1996 Sven Verdoolaege * locale/progams/localedef.c (main): Test with -1 to find out whether read failed. Wed Oct 16 14:54:59 1996 Ulrich Drepper * sysdeps/unix/sysv/linux/i386/clone.S: Use JUMPTARGET and PSEUDO_END macro. Tue Oct 15 21:27:42 1996 Andreas Schwab * sysdeps/unix/sysv/linux/m68k/sigcontext.h: Removed. Tue Oct 15 15:52:29 1996 Andreas Schwab * 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 * 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 * 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 * 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 * sysdeps/unix/sysv/linux/syscalls.list: Add {get,set}resuid. Tue Oct 15 08:06:02 1996 Andreas Jaeger * crypt/Makefiel (rpath-link): Extend search path to current directory. Fri Oct 11 09:18:06 1996 Sven Verdoolaege * sysdeps/i386/i586/strlen.S: Correct handling of prolog for aligning pointer. Tue Oct 15 02:13:21 1996 Ulrich Drepper * 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 * 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. --- sunrpc/rpc_hout.c | 320 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 224 insertions(+), 96 deletions(-) (limited to 'sunrpc/rpc_hout.c') diff --git a/sunrpc/rpc_hout.c b/sunrpc/rpc_hout.c index 1bf0097..beca276 100644 --- a/sunrpc/rpc_hout.c +++ b/sunrpc/rpc_hout.c @@ -1,53 +1,71 @@ -/* @(#)rpc_hout.c 2.1 88/08/01 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * + * program developed by the user or with the express written consent of + * Sun Microsystems, Inc. + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ -#ifndef lint -static char sccsid[] = "@(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI"; -#endif + +/* + * From: @(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI + */ +char hout_rcsid[] = + "$Id$"; /* * rpc_hout.c, Header file outputter for the RPC protocol compiler - * Copyright (C) 1987, Sun Microsystems, Inc. */ #include #include -#include "rpc_util.h" #include "rpc_parse.h" +#include "rpc_util.h" +#include "proto.h" +static void pconstdef(definition *def); +static void pargdef(definition *def); +static void pstructdef(definition *def); +static void puniondef(definition *def); +static void pdefine(const char *name, const char *num); +static void puldefine(const char *name, const char *num); +static int define_printed(proc_list *stop, version_list *start); +static void pprogramdef(definition *def); +static void parglist(proc_list *proc, const char *addargtype); +static void penumdef(definition *def); +static void ptypedef(definition *def); +static int undefined2(const char *type, const char *stop); /* * Print the C-version of an xdr definition */ void -print_datadef(def) - definition *def; +print_datadef(definition *def) { + + if (def->def_kind == DEF_PROGRAM ) /* handle data only */ + return; + if (def->def_kind != DEF_CONST) { f_print(fout, "\n"); } @@ -72,41 +90,101 @@ print_datadef(def) break; } if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) { - f_print(fout, "bool_t xdr_%s();\n", def->def_name); + pxdrfuncdecl( def->def_name, + def->def_kind != DEF_TYPEDEF || + !isvectordef(def->def.ty.old_type, def->def.ty.rel)); + } - if (def->def_kind != DEF_CONST) { +} + + +void +print_funcdef(definition *def) +{ + switch (def->def_kind) { + case DEF_PROGRAM: f_print(fout, "\n"); + pprogramdef(def); + break; + default: + /* ?... shouldn't happen I guess */ } } -static -pconstdef(def) - definition *def; +void +pxdrfuncdecl(const char *name, int pointerp) +{ + + f_print(fout,"#ifdef __cplusplus \n"); + f_print(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? "*" : ""); + f_print(fout,"#elif __STDC__ \n"); + f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? "*" : ""); + f_print(fout,"#else /* Old Style C */ \n"); + f_print(fout, "bool_t xdr_%s();\n", name); + f_print(fout,"#endif /* Old Style C */ \n\n"); +} + + +static void +pconstdef(definition *def) { pdefine(def->def_name, def->def.co); } -static -pstructdef(def) - definition *def; +/* print out the definitions for the arguments of functions in the + header file +*/ +static void +pargdef(definition *def) +{ + decl_list *l; + version_list *vers; + const char *name; + proc_list *plist; + + + for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { + for(plist = vers->procs; plist != NULL; + plist = plist->next) { + + if (!newstyle || plist->arg_num < 2) { + continue; /* old style or single args */ + } + name = plist->args.argname; + f_print(fout, "struct %s {\n", name); + for (l = plist->args.decls; + l != NULL; l = l->next) { + pdeclaration(name, &l->decl, 1, ";\n" ); + } + f_print(fout, "};\n"); + f_print(fout, "typedef struct %s %s;\n", name, name); + pxdrfuncdecl(name, 0); + f_print( fout, "\n" ); + } + } + +} + + +static void +pstructdef(definition *def) { decl_list *l; - char *name = def->def_name; + const char *name = def->def_name; f_print(fout, "struct %s {\n", name); for (l = def->def.st.decls; l != NULL; l = l->next) { - pdeclaration(name, &l->decl, 1); + pdeclaration(name, &l->decl, 1, ";\n"); } f_print(fout, "};\n"); f_print(fout, "typedef struct %s %s;\n", name, name); } -static -puniondef(def) - definition *def; +static void +puniondef(definition *def) { case_list *l; - char *name = def->def_name; + const char *name = def->def_name; declaration *decl; f_print(fout, "struct %s {\n", name); @@ -118,39 +196,32 @@ puniondef(def) } f_print(fout, "\tunion {\n"); for (l = def->def.un.cases; l != NULL; l = l->next) { - pdeclaration(name, &l->case_decl, 2); + if(l->contflag == 0) + pdeclaration(name, &l->case_decl, 2, ";\n" ); } decl = def->def.un.default_decl; if (decl && !streq(decl->type, "void")) { - pdeclaration(name, decl, 2); + pdeclaration(name, decl, 2, ";\n" ); } f_print(fout, "\t} %s_u;\n", name); f_print(fout, "};\n"); f_print(fout, "typedef struct %s %s;\n", name, name); } - - -static -pdefine(name, num) - char *name; - char *num; +static void +pdefine(const char *name, const char *num) { f_print(fout, "#define %s %s\n", name, num); } -static -puldefine(name, num) - char *name; - char *num; +static void +puldefine(const char *name, const char *num) { f_print(fout, "#define %s ((u_long)%s)\n", name, num); } -static -define_printed(stop, start) - proc_list *stop; - version_list *start; +static int +define_printed(proc_list *stop, version_list *start) { version_list *vers; proc_list *proc; @@ -168,57 +239,122 @@ define_printed(stop, start) /* NOTREACHED */ } - -static -pprogramdef(def) - definition *def; +static void +pprogramdef(definition *def) { version_list *vers; proc_list *proc; + int i; + const char *ext; + + pargdef(def); puldefine(def->def_name, def->def.pr.prog_num); for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { + if (tblflag) { + f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n", + locase(def->def_name), vers->vers_num); + f_print(fout, "extern %s_%s_nproc;\n", + locase(def->def_name), vers->vers_num); + } puldefine(vers->vers_name, vers->vers_num); - for (proc = vers->procs; proc != NULL; proc = proc->next) { - if (!define_printed(proc, def->def.pr.versions)) { - puldefine(proc->proc_name, proc->proc_num); + + /* + * Print out 3 definitions, one for ANSI-C, another for C++, + * a third for old style C + */ + + for (i=0;i<3;i++) { + if (i==0) { + f_print(fout,"\n#ifdef __cplusplus\n"); + ext="extern \"C\" "; + } + else if (i==1) { + f_print(fout,"\n#elif __STDC__\n"); + ext="extern " ; + } + else { + f_print(fout,"\n#else /* Old Style C */ \n"); + ext="extern "; } - pprocdef(proc, vers); + + + for (proc = vers->procs; proc != NULL; proc = proc->next) { + if (!define_printed(proc, def->def.pr.versions)) { + puldefine(proc->proc_name, proc->proc_num); + } + f_print(fout,"%s",ext); + pprocdef(proc, vers, "CLIENT *", 0,i); + f_print(fout,"%s",ext); + pprocdef(proc, vers, "struct svc_req *", 1,i); + + } + } + f_print(fout,"#endif /* Old Style C */ \n"); } } +void +pprocdef(proc_list *proc, version_list *vp, + const char *addargtype, int server_p, int mode) +{ -pprocdef(proc, vp) - proc_list *proc; - version_list *vp; + + + + ptype( proc->res_prefix, proc->res_type, 1 ); + f_print( fout, "* " ); + if( server_p ) + pvname_svc(proc->proc_name, vp->vers_num); + else + pvname(proc->proc_name, vp->vers_num); + + /* + * mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C + */ + if(mode == 0 || mode ==1) + parglist(proc, addargtype); + else + f_print(fout, "();\n"); + + + +} + + + +/* print out argument list of procedure */ +static void +parglist(proc_list *proc, const char *addargtype) { - f_print(fout, "extern "); - if (proc->res_prefix) { - if (streq(proc->res_prefix, "enum")) { - f_print(fout, "enum "); + decl_list *dl; + + f_print(fout,"("); + + if( proc->arg_num < 2 && newstyle && + streq( proc->args.decls->decl.type, "void")) { + /* 0 argument in new style: do nothing */ } else { - f_print(fout, "struct "); + for (dl = proc->args.decls; dl != NULL; dl = dl->next) { + ptype( dl->decl.prefix, dl->decl.type, 1 ); + if( !newstyle ) + f_print( fout, "*" ); /* old style passes by reference */ + + f_print( fout, ", " ); + } } - } - if (streq(proc->res_type, "bool")) { - f_print(fout, "bool_t *"); - } else if (streq(proc->res_type, "string")) { - f_print(fout, "char **"); - } else { - f_print(fout, "%s *", fixtype(proc->res_type)); - } - pvname(proc->proc_name, vp->vers_num); - f_print(fout, "();\n"); + + f_print(fout, "%s);\n", addargtype); + } -static -penumdef(def) - definition *def; +static void +penumdef(definition *def) { - char *name = def->def_name; + const char *name = def->def_name; enumval_list *l; - char *last = NULL; + const char *last = NULL; int count = 0; f_print(fout, "enum %s {\n", name); @@ -241,12 +377,11 @@ penumdef(def) f_print(fout, "typedef enum %s %s;\n", name, name); } -static -ptypedef(def) - definition *def; +static void +ptypedef(definition *def) { - char *name = def->def_name; - char *old = def->def.ty.old_type; + const char *name = def->def_name; + const char *old = def->def.ty.old_type; char prefix[8]; /* enough to contain "struct ", including NUL */ relation rel = def->def.ty.rel; @@ -281,23 +416,20 @@ ptypedef(def) def->def.ty.array_max); break; case REL_ALIAS: - f_print(fout, "%s%s %s", prefix, old, name); + f_print(fout, "%s%s %s", prefix, old, name); break; } f_print(fout, ";\n"); } } - -static -pdeclaration(name, dec, tab) - char *name; - declaration *dec; - int tab; +void +pdeclaration(const char *name, declaration *dec, int tab, + const char *separator) { char buf[8]; /* enough to hold "struct ", include NUL */ - char *prefix; - char *type; + const char *prefix; + const char *type; if (streq(dec->type, "void")) { return; @@ -343,15 +475,11 @@ pdeclaration(name, dec, tab) break; } } - f_print(fout, ";\n"); + f_print(fout, separator ); } - - -static -undefined2(type, stop) - char *type; - char *stop; +static int +undefined2(const char *type, const char *stop) { list *l; definition *def; -- cgit v1.1