diff options
28 files changed, 8183 insertions, 35 deletions
diff --git a/package/libtirpc/Makefile b/package/libtirpc/Makefile index f88d3a6fb..e17a3b65c 100644 --- a/package/libtirpc/Makefile +++ b/package/libtirpc/Makefile @@ -4,9 +4,9 @@ include ${ADK_TOPDIR}/rules.mk PKG_NAME:= libtirpc -PKG_VERSION:= 0.3.2 -PKG_RELEASE:= 2 -PKG_HASH:= 2008a379f37f2c5d5a87a568b06707422cc3e4f5da305f7fb71f3f4c6d473ffc +PKG_VERSION:= 1.0.1 +PKG_RELEASE:= 1 +PKG_HASH:= 5156974f31be7ccbc8ab1de37c4739af6d9d42c87b1d5caf4835dda75fcbb89e PKG_DESCR:= transport independent rpc library PKG_SECTION:= libs/net PKG_URL:= http://sourceforge.net/projects/libtirpc/ @@ -40,6 +40,10 @@ else CONFIGURE_ARGS+= --disable-ipv6 endif +post-extract: + rm $(WRKBUILD)/tirpc/rpcsvc/crypt.h + rm $(WRKBUILD)/tirpc/rpc/rpcb_prot.h + libtirpc-install: ${INSTALL_DIR} ${IDIR_LIBTIRPC}/usr/lib ${IDIR_LIBTIRPC}/etc ${CP} ${WRKINST}/usr/lib/libtirpc*.so* ${IDIR_LIBTIRPC}/usr/lib/ diff --git a/package/libtirpc/patches/patch-Makefile_am b/package/libtirpc/patches/patch-Makefile_am new file mode 100644 index 000000000..80bc6991c --- /dev/null +++ b/package/libtirpc/patches/patch-Makefile_am @@ -0,0 +1,54 @@ +--- libtirpc-1.0.1.orig/Makefile.am 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/Makefile.am 2015-11-29 16:38:58.340674483 +0100 +@@ -1,6 +1,12 @@ +-SUBDIRS = src man doc ++SUBDIRS = src man doc rpcgen + ACLOCAL_AMFLAGS = -I m4 + ++GENFILES = tirpc/rpcsvc/crypt.h \ ++ tirpc/rpcsvc/mount.h \ ++ tirpc/rpcsvc/nfs_prot.h \ ++ tirpc/rpcsvc/rquota.h \ ++ tirpc/rpc/rpcb_prot.h ++ + noinst_HEADERS = tirpc/reentrant.h \ + tirpc/getpeereid.h \ + tirpc/libc_private.h \ +@@ -8,7 +14,9 @@ noinst_HEADERS = tirpc/reentrant. + + nobase_include_HEADERS = tirpc/netconfig.h \ + tirpc/rpcsvc/crypt.x \ +- tirpc/rpcsvc/crypt.h \ ++ tirpc/rpcsvc/mount.x \ ++ tirpc/rpcsvc/nfs_prot.x \ ++ tirpc/rpcsvc/rquota.x \ + tirpc/rpc/xdr.h \ + tirpc/rpc/types.h \ + tirpc/rpc/svc_soc.h \ +@@ -21,7 +29,6 @@ nobase_include_HEADERS = tirpc/netconfig + tirpc/rpc/rpcent.h \ + tirpc/rpc/rpc_com.h \ + tirpc/rpc/rpcb_prot.x \ +- tirpc/rpc/rpcb_prot.h \ + tirpc/rpc/rpcb_clnt.h \ + tirpc/rpc/raw.h \ + tirpc/rpc/pmap_rmt.h \ +@@ -48,5 +55,17 @@ endif + pkgconfigdir=$(libdir)/pkgconfig + pkgconfig_DATA = libtirpc.pc + +-CLEANFILES = cscope.* *~ ++nobase_nodist_include_HEADERS = $(GENFILES) ++BUILT_SOURCES = $(GENFILES) ++ ++$(GENFILES): %.h: %.x $(top_builddir)/rpcgen/rpcgen ++ mkdir -p $(dir $@) ++ $(top_builddir)/rpcgen/rpcgen -h -o $@ $< ++ ++$(top_builddir)/rpcgen/rpcgen: force ++ cd rpcgen && $(MAKE) ++ ++force: ++ ++CLEANFILES = cscope.* *~ $(GENFILES) + DISTCLEANFILES = Makefile.in libtirpc*.tar.gz diff --git a/package/libtirpc/patches/patch-configure_ac b/package/libtirpc/patches/patch-configure_ac new file mode 100644 index 000000000..659bdad8c --- /dev/null +++ b/package/libtirpc/patches/patch-configure_ac @@ -0,0 +1,23 @@ +--- libtirpc-1.0.1.orig/configure.ac 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/configure.ac 2015-11-29 16:38:38.817971632 +0100 +@@ -89,7 +89,19 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h li + AC_CHECK_LIB([pthread], [pthread_create]) + AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent]) + +-AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile]) ++AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes) ++ ++AC_MSG_CHECKING([for a C compiler for build tools]) ++if test $cross_compiling = yes; then ++ AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) ++else ++ CC_FOR_BUILD=$CC ++fi ++AC_MSG_RESULT([$CC_FOR_BUILD]) ++AC_SUBST(CC_FOR_BUILD) ++ ++AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile rpcgen/Makefile]) ++ + AC_OUTPUT(libtirpc.pc) + + diff --git a/package/libtirpc/patches/patch-src_Makefile_am b/package/libtirpc/patches/patch-src_Makefile_am index 5c8e5dccb..2188984f9 100644 --- a/package/libtirpc/patches/patch-src_Makefile_am +++ b/package/libtirpc/patches/patch-src_Makefile_am @@ -1,31 +1,33 @@ ---- libtirpc-0.3.2.orig/src/Makefile.am 2015-06-16 17:35:08.000000000 +0200 -+++ libtirpc-0.3.2/src/Makefile.am 2015-06-27 12:05:34.000000000 +0200 -@@ -41,7 +41,7 @@ lib_LTLIBRARIES = libtirpc.la - # release number of your package. This is an abuse that only fosters - # misunderstanding of the purpose of library versions." - # --libtirpc_la_LDFLAGS = -lpthread -version-info 1:10:0 -+libtirpc_la_LDFLAGS = -no-undefined -lpthread -version-info 1:10:0 +--- libtirpc-1.0.1.orig/src/Makefile.am 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/src/Makefile.am 2015-11-29 16:39:17.803381320 +0100 +@@ -8,7 +8,7 @@ + noinst_HEADERS = rpc_com.h debug.h - libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \ - clnt_dg.c clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c \ -@@ -51,7 +51,7 @@ libtirpc_la_SOURCES = auth_none.c auth_u + AM_CPPFLAGS = -I$(top_srcdir)/tirpc -include config.h -DPORTMAP -DINET6 \ +- -D_GNU_SOURCE -Wall -pipe ++ -D_GNU_SOURCE -Wall -pipe -I$(top_builddir)/tirpc + + lib_LTLIBRARIES = libtirpc.la + +@@ -22,9 +22,8 @@ libtirpc_la_SOURCES = auth_none.c auth_u + pmap_prot.c pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c \ rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \ rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \ +- svc_auth_des.c \ svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \ - auth_time.c auth_des.c authdes_prot.c debug.c + debug.c ## XDR - libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c -@@ -68,8 +68,8 @@ if GSS + libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c xdr_sizeof.c +@@ -41,8 +40,8 @@ if GSS libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS) endif -libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c --libtirpc_la_SOURCES += netname.c netnamer.c rtime.c -+libtirpc_la_SOURCES += key_call.c key_prot_xdr.c -+libtirpc_la_SOURCES += rtime.c +-libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c ++#libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c ++#libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c CLEANFILES = cscope.* *~ DISTCLEANFILES = Makefile.in diff --git a/package/libtirpc/patches/patch-src_clnt_bcast_c b/package/libtirpc/patches/patch-src_clnt_bcast_c new file mode 100644 index 000000000..7472e6272 --- /dev/null +++ b/package/libtirpc/patches/patch-src_clnt_bcast_c @@ -0,0 +1,18 @@ +--- libtirpc-1.0.1.orig/src/clnt_bcast.c 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/src/clnt_bcast.c 2015-11-29 16:50:32.363665821 +0100 +@@ -40,7 +40,6 @@ + */ + #include <sys/socket.h> + #include <sys/types.h> +-#include <sys/queue.h> + + #include <net/if.h> + #include <netinet/in.h> +@@ -62,6 +61,7 @@ + #include <err.h> + #include <string.h> + ++#include "sys/queue.h" + #include "rpc_com.h" + #include "debug.h" + diff --git a/package/libtirpc/patches/patch-src_rpc_soc_c b/package/libtirpc/patches/patch-src_rpc_soc_c index a03858799..b43a80877 100644 --- a/package/libtirpc/patches/patch-src_rpc_soc_c +++ b/package/libtirpc/patches/patch-src_rpc_soc_c @@ -1,18 +1,97 @@ ---- libtirpc-0.3.2.orig/src/rpc_soc.c 2015-06-16 17:35:08.000000000 +0200 -+++ libtirpc-0.3.2/src/rpc_soc.c 2015-06-27 11:37:58.000000000 +0200 -@@ -520,6 +520,7 @@ clnt_broadcast(prog, vers, proc, xargs, - (resultproc_t) rpc_wrap_bcast, "udp"); - } +--- libtirpc-1.0.1.orig/src/rpc_soc.c 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/src/rpc_soc.c 2015-11-29 16:39:17.831379460 +0100 +@@ -61,7 +61,6 @@ + #include <string.h> + #include <unistd.h> + #include <fcntl.h> +-#include <rpcsvc/nis.h> -+#if 0 - /* - * Create the client des authentication object. Obsoleted by - * authdes_seccreate(). -@@ -551,6 +552,7 @@ fallback: - dummy = authdes_seccreate(servername, window, NULL, ckey); - return (dummy); + #include "rpc_com.h" + +@@ -522,86 +521,6 @@ clnt_broadcast(prog, vers, proc, xargs, } -+#endif /* +- * Create the client des authentication object. Obsoleted by +- * authdes_seccreate(). +- */ +-AUTH * +-authdes_create(servername, window, syncaddr, ckey) +- char *servername; /* network name of server */ +- u_int window; /* time to live */ +- struct sockaddr *syncaddr; /* optional hostaddr to sync with */ +- des_block *ckey; /* optional conversation key to use */ +-{ +- AUTH *nauth; +- char hostname[NI_MAXHOST]; +- +- if (syncaddr) { +- /* +- * Change addr to hostname, because that is the way +- * new interface takes it. +- */ +- switch (syncaddr->sa_family) { +- case AF_INET: +- if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, +- sizeof hostname, NULL, 0, 0) != 0) +- goto fallback; +- break; +- case AF_INET6: +- if (getnameinfo(syncaddr, sizeof(struct sockaddr_in6), hostname, +- sizeof hostname, NULL, 0, 0) != 0) +- goto fallback; +- break; +- default: +- goto fallback; +- } +- nauth = authdes_seccreate(servername, window, hostname, ckey); +- return (nauth); +- } +-fallback: +- return authdes_seccreate(servername, window, NULL, ckey); +-} +- +-/* +- * Create the client des authentication object. Obsoleted by +- * authdes_pk_seccreate(). +- */ +-extern AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *, +- const des_block *, nis_server *); +- +-AUTH * +-authdes_pk_create(servername, pkey, window, syncaddr, ckey) +- char *servername; /* network name of server */ +- netobj *pkey; /* public key */ +- u_int window; /* time to live */ +- struct sockaddr *syncaddr; /* optional hostaddr to sync with */ +- des_block *ckey; /* optional conversation key to use */ +-{ +- AUTH *nauth; +- char hostname[NI_MAXHOST]; +- +- if (syncaddr) { +- /* +- * Change addr to hostname, because that is the way +- * new interface takes it. +- */ +- switch (syncaddr->sa_family) { +- case AF_INET: +- if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname, +- sizeof hostname, NULL, 0, 0) != 0) +- goto fallback; +- break; +- default: +- goto fallback; +- } +- nauth = authdes_pk_seccreate(servername, pkey, window, hostname, ckey, NULL); +- return (nauth); +- } +-fallback: +- return authdes_pk_seccreate(servername, pkey, window, NULL, ckey, NULL); +-} +- +- +-/* * Create a client handle for a unix connection. Obsoleted by clnt_vc_create() + */ + CLIENT * diff --git a/package/libtirpc/patches/patch-src_svc_auth_c b/package/libtirpc/patches/patch-src_svc_auth_c new file mode 100644 index 000000000..05436f3b7 --- /dev/null +++ b/package/libtirpc/patches/patch-src_svc_auth_c @@ -0,0 +1,12 @@ +--- libtirpc-1.0.1.orig/src/svc_auth.c 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/src/svc_auth.c 2015-11-29 16:39:17.807381054 +0100 +@@ -114,9 +114,6 @@ _gss_authenticate(rqst, msg, no_dispatch + case AUTH_SHORT: + dummy = _svcauth_short(rqst, msg); + return (dummy); +- case AUTH_DES: +- dummy = _svcauth_des(rqst, msg); +- return (dummy); + #ifdef HAVE_RPCSEC_GSS + case RPCSEC_GSS: + dummy = _svcauth_gss(rqst, msg, no_dispatch); diff --git a/package/libtirpc/patches/patch-src_svc_c b/package/libtirpc/patches/patch-src_svc_c new file mode 100644 index 000000000..b2ce784ca --- /dev/null +++ b/package/libtirpc/patches/patch-src_svc_c @@ -0,0 +1,36 @@ +--- libtirpc-1.0.1.orig/src/svc.c 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/src/svc.c 2015-11-29 16:39:24.994903493 +0100 +@@ -99,7 +99,7 @@ xprt_register (xprt) + { + __svc_xports = (SVCXPRT **) calloc (_rpc_dtablesize(), sizeof (SVCXPRT *)); + if (__svc_xports == NULL) +- return; ++ goto unlock; + } + if (sock < _rpc_dtablesize()) + { +@@ -120,14 +120,14 @@ xprt_register (xprt) + svc_pollfd[i].fd = sock; + svc_pollfd[i].events = (POLLIN | POLLPRI | + POLLRDNORM | POLLRDBAND); +- return; ++ goto unlock; + } + + new_svc_pollfd = (struct pollfd *) realloc (svc_pollfd, + sizeof (struct pollfd) + * (svc_max_pollfd + 1)); + if (new_svc_pollfd == NULL) /* Out of memory */ +- return; ++ goto unlock; + svc_pollfd = new_svc_pollfd; + ++svc_max_pollfd; + +@@ -135,6 +135,7 @@ xprt_register (xprt) + svc_pollfd[svc_max_pollfd - 1].events = (POLLIN | POLLPRI | + POLLRDNORM | POLLRDBAND); + } ++unlock: + rwlock_unlock (&svc_fd_lock); + } + diff --git a/package/libtirpc/patches/patch-tirpc_rpc_rpcent_h b/package/libtirpc/patches/patch-tirpc_rpc_rpcent_h index 73c8ef727..46dd86d8b 100644 --- a/package/libtirpc/patches/patch-tirpc_rpc_rpcent_h +++ b/package/libtirpc/patches/patch-tirpc_rpc_rpcent_h @@ -1,5 +1,5 @@ ---- libtirpc-0.3.1.orig/tirpc/rpc/rpcent.h 2015-06-01 14:13:24.000000000 +0200 -+++ libtirpc-0.3.1/tirpc/rpc/rpcent.h 2015-06-17 22:09:32.000000000 +0200 +--- libtirpc-1.0.1.orig/tirpc/rpc/rpcent.h 2015-10-30 16:15:14.000000000 +0100 ++++ libtirpc-1.0.1/tirpc/rpc/rpcent.h 2015-11-29 16:38:28.630648509 +0100 @@ -48,8 +48,9 @@ extern "C" { #endif @@ -8,7 +8,7 @@ -#if !defined(__GLIBC__) +/* These are defined in /usr/include/rpc/netdb.h, unless we are using + the C library without RPC support. */ -+#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) ++#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__) struct rpcent { char *r_name; /* name of server for this rpc program */ char **r_aliases; /* alias list */ diff --git a/package/libtirpc/src/rpcgen/Makefile.am b/package/libtirpc/src/rpcgen/Makefile.am new file mode 100644 index 000000000..18026f832 --- /dev/null +++ b/package/libtirpc/src/rpcgen/Makefile.am @@ -0,0 +1,22 @@ +COMPILE = $(CC_FOR_BUILD) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS_FOR_BUILD) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) +LINK = $(CC_FOR_BUILD) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD) -o $@ + +noinst_PROGRAMS = rpcgen + +rpcgen_SOURCES = \ + rpc_clntout.c \ + rpc_cout.c \ + rpc_hout.c \ + rpc_main.c \ + rpc_parse.c \ + rpc_sample.c \ + rpc_scan.c \ + rpc_svcout.c \ + rpc_tblout.c \ + rpc_util.c \ + rpc_parse.h \ + rpc_scan.h \ + rpc_util.h + +dist_man1_MANS = rpcgen.1 diff --git a/package/libtirpc/src/rpcgen/rpc_clntout.c b/package/libtirpc/src/rpcgen/rpc_clntout.c new file mode 100644 index 000000000..e2f4382c5 --- /dev/null +++ b/package/libtirpc/src/rpcgen/rpc_clntout.c @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI"; +#endif + +/* + * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsytsems, Inc. + */ +#include <stdio.h> +#include <string.h> +#include <rpc/types.h> +#include "rpc_parse.h" +#include "rpc_util.h" +#include "rpc_output.h" + +/* extern pdeclaration(); */ +/* void printarglist(); */ + +#define DEFAULT_TIMEOUT 25 /* in seconds */ +static char RESULT[] = "clnt_res"; + +static void write_program(definition *def); +static void printbody(proc_list *proc); + + +void +write_stubs(void) +{ + list *l; + definition *def; + + f_print(fout, + "\n/* Default timeout can be changed using clnt_control() */\n"); + f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", + DEFAULT_TIMEOUT); + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind == DEF_PROGRAM) { + write_program(def); + } + } +} + +static void +write_program(definition *def) +{ + version_list *vp; + proc_list *proc; + + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + for (proc = vp->procs; proc != NULL; proc = proc->next) { + f_print(fout, "\n"); + ptype(proc->res_prefix, proc->res_type, 1); + f_print(fout, "*\n"); + pvname(proc->proc_name, vp->vers_num); + printarglist(proc, "clnt", "CLIENT *"); + f_print(fout, "{\n"); + printbody(proc); + f_print(fout, "}\n"); + } + } +} + +/* + * Writes out declarations of procedure's argument list. + * In either ANSI C style, in one of old rpcgen style (pass by reference), + * or new rpcgen style (multiple arguments, pass by value); + */ + +/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */ + +void +printarglist(proc_list *proc, char *addargname, char *addargtype) +{ + + decl_list *l; + + if (!newstyle) { /* old style: always pass arg 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 char * +ampr(char *type) +{ + if (isvectordef(type, REL_ALIAS)) { + return (""); + } else { + return ("&"); + } +} + +static void +printbody(proc_list *proc) +{ + decl_list *l; + bool_t args2 = (proc->arg_num > 1); + + /* For new style with multiple arguments, need a structure in which + * to stuff the arguments. */ + if (newstyle && args2) { + f_print(fout, "\t%s", proc->args.argname); + f_print(fout, " arg;\n"); + } + f_print(fout, "\tstatic "); + if (streq(proc->res_type, "void")) { + f_print(fout, "char "); + } else { + ptype(proc->res_prefix, proc->res_type, 0); + } + f_print(fout, "%s;\n", RESULT); + f_print(fout, "\n"); + f_print(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n", + ampr(proc->res_type), RESULT, RESULT); + if (newstyle && !args2 && (streq(proc->args.decls->decl.type, "void"))) { + /* newstyle, 0 arguments */ + f_print(fout, + "\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_void, (caddr_t) NULL, " + "(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n", + proc->proc_name, + 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, (xdrproc_t) xdr_%s, (caddr_t) &arg, " + "(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n", + proc->proc_name, proc->args.argname, + stringfix(proc->res_type), ampr(proc->res_type), RESULT); + } else { /* single argument, new or old style */ + f_print(fout, + "\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_%s, " + "(caddr_t) %s%s, (xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n", + proc->proc_name, + stringfix(proc->args.decls->decl.type), + (newstyle ? "&" : ""), + (newstyle ? proc->args.decls->decl.name : "argp"), + stringfix(proc->res_type), ampr(proc->res_type), RESULT); + } + f_print(fout, "\t\treturn (NULL);\n"); + f_print(fout, "\t}\n"); + if (streq(proc->res_type, "void")) { + f_print(fout, "\treturn ((void *)%s%s);\n", + ampr(proc->res_type), RESULT); + } else { + f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type), RESULT); + } +} diff --git a/package/libtirpc/src/rpcgen/rpc_cout.c b/package/libtirpc/src/rpcgen/rpc_cout.c new file mode 100644 index 000000000..a61214fdb --- /dev/null +++ b/package/libtirpc/src/rpcgen/rpc_cout.c @@ -0,0 +1,706 @@ +/* + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI"; +#endif + +/* + * rpc_cout.c, XDR routine outputter for the RPC protocol compiler + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <malloc.h> +#include <ctype.h> +#include "rpc_parse.h" +#include "rpc_util.h" + +static int findtype(definition *def, char *type); +static int undefined(char *type); +static void print_generic_header(char *procname, int pointerp); +static void print_header(definition *def); +static void print_prog_header(proc_list *plist); +static void print_trailer(void); +static void print_ifopen(int indent, char *name); +static void print_ifarg(char *arg); +static void print_ifsizeof(char *prefix, char *type); +static void print_ifclose(int indent); +static void print_ifstat(int indent, char *prefix, char *type, relation rel, + char *amax, char *objname, char *name); +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 void print_stat(int indent, declaration *dec); +static void emit_inline(declaration *decl, int flag); +static void emit_single_in_line(declaration *decl, int flag, relation rel); +static char * upcase(char *str); + +/* + * Emit the C-routine for the given definition + */ +void +emit(definition *def) +{ + if (def->def_kind == DEF_CONST) { + return; + } + if (def->def_kind == DEF_PROGRAM) { + emit_program(def); + return; + } + if (def->def_kind == DEF_TYPEDEF) { + /* now we need to handle declarations like + * struct typedef foo foo; + * since we dont want this to be expanded into 2 calls + * to xdr_foo */ + + if (strcmp(def->def.ty.old_type, def->def_name) == 0) + return; + }; + + print_header(def); + switch (def->def_kind) { + case DEF_UNION: + emit_union(def); + break; + case DEF_ENUM: + emit_enum(def); + break; + case DEF_STRUCT: + emit_struct(def); + break; + case DEF_TYPEDEF: + emit_typedef(def); + break; + default: + break; + } + print_trailer(); +} + +static int +findtype(definition *def, char *type) +{ + + if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { + return (0); + } else { + return (streq(def->def_name, type)); + } +} + +static int +undefined(char *type) +{ + definition *def; + + def = (definition *) FINDVAL(defined, type, findtype); + + return (def == NULL); +} + + +static void +print_generic_header(char *procname, int pointerp) +{ + f_print(fout, "\n"); + f_print(fout, "bool_t\n"); + if (Cflag) { + f_print(fout, "xdr_%s(", procname); + f_print(fout, "XDR *xdrs, "); + f_print(fout, "%s ", procname); + if (pointerp) + f_print(fout, "*"); + f_print(fout, "objp)\n{\n\n"); + } else { + f_print(fout, "xdr_%s(xdrs, objp)\n", procname); + f_print(fout, "\tXDR *xdrs;\n"); + f_print(fout, "\t%s ", procname); + if (pointerp) + f_print(fout, "*"); + f_print(fout, "objp;\n{\n\n"); + } +} + +static void +print_header(definition *def) +{ + 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 (Inline == 0) + return; +} + +static void +print_prog_header(proc_list *plist) +{ + print_generic_header(plist->args.argname, 1); +} + +static void +print_ |