/* @(#)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.
* 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
* 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.
* Mountain View, California 94043
/*static char sccsid[] = "from: @(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI";*/
static char rcsid
[] = "$Id: rpc_hout.c,v 1.3 1993/08/01 18:09:21 mycroft Exp $";
static int pconstdef(), pstructdef(), puniondef(), pdefine(), pprogramdef(),
penumdef(), ptypedef(), pdeclaration(), undefined2();
* rpc_hout.c, Header file outputter for the RPC protocol compiler
* Copyright (C) 1987, Sun Microsystems, Inc.
* Print the C-version of an xdr definition
if (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
);
if (def
->def_kind
!= DEF_CONST
) {
pdefine(def
->def_name
, def
->def
.co
);
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);
f_print(fout
, "typedef struct %s %s;\n", name
, name
);
char *name
= def
->def_name
;
f_print(fout
, "struct %s {\n", name
);
decl
= &def
->def
.un
.enum_decl
;
if (streq(decl
->type
, "bool")) {
f_print(fout
, "\tbool_t %s;\n", decl
->name
);
f_print(fout
, "\t%s %s;\n", decl
->type
, decl
->name
);
f_print(fout
, "\tunion {\n");
for (l
= def
->def
.un
.cases
; l
!= NULL
; l
= l
->next
) {
pdeclaration(name
, &l
->case_decl
, 2);
decl
= def
->def
.un
.default_decl
;
if (decl
&& !streq(decl
->type
, "void")) {
pdeclaration(name
, decl
, 2);
f_print(fout
, "\t} %s_u;\n", name
);
f_print(fout
, "typedef struct %s %s;\n", name
, name
);
f_print(fout
, "#define %s %s\n", name
, num
);
f_print(fout
, "#define %s ((u_long)%s)\n", name
, num
);
define_printed(stop
, start
)
for (vers
= start
; vers
!= NULL
; vers
= vers
->next
) {
for (proc
= vers
->procs
; proc
!= NULL
; proc
= proc
->next
) {
} else if (streq(proc
->proc_name
, stop
->proc_name
)) {
puldefine(def
->def_name
, def
->def
.pr
.prog_num
);
for (vers
= def
->def
.pr
.versions
; vers
!= NULL
; vers
= vers
->next
) {
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
);
f_print(fout
, "extern ");
if (streq(proc
->res_prefix
, "enum")) {
f_print(fout
, "struct ");
if (streq(proc
->res_type
, "bool")) {
f_print(fout
, "bool_t *");
} else if (streq(proc
->res_type
, "string")) {
f_print(fout
, "char **");
f_print(fout
, "%s *", fixtype(proc
->res_type
));
pvname(proc
->proc_name
, vp
->vers_num
);
char *name
= def
->def_name
;
f_print(fout
, "enum %s {\n", name
);
for (l
= def
->def
.en
.vals
; l
!= NULL
; l
= l
->next
) {
f_print(fout
, "\t%s", l
->name
);
f_print(fout
, " = %s", l
->assignment
);
f_print(fout
, " = %d", count
++);
f_print(fout
, " = %s + %d", last
, count
++);
f_print(fout
, "typedef enum %s %s;\n", name
, name
);
char *name
= def
->def_name
;
char *old
= def
->def
.ty
.old_type
;
char prefix
[8]; /* enough to contain "struct ", including NUL */
relation rel
= def
->def
.ty
.rel
;
if (streq(old
, "string")) {
} else if (streq(old
, "opaque")) {
} else if (streq(old
, "bool")) {
if (undefined2(old
, name
) && def
->def
.ty
.old_prefix
) {
s_print(prefix
, "%s ", def
->def
.ty
.old_prefix
);
f_print(fout
, "typedef ");
f_print(fout
, "struct {\n");
f_print(fout
, "\tu_int %s_len;\n", name
);
f_print(fout
, "\t%s%s *%s_val;\n", prefix
, old
, name
);
f_print(fout
, "} %s", name
);
f_print(fout
, "%s%s *%s", prefix
, old
, name
);
f_print(fout
, "%s%s %s[%s]", prefix
, old
, name
,
f_print(fout
, "%s%s %s", prefix
, old
, name
);
pdeclaration(name
, dec
, tab
)
char buf
[8]; /* enough to hold "struct ", include NUL */
if (streq(dec
->type
, "void")) {
if (streq(dec
->type
, name
) && !dec
->prefix
) {
f_print(fout
, "struct ");
if (streq(dec
->type
, "string")) {
f_print(fout
, "char *%s", dec
->name
);
if (streq(dec
->type
, "bool")) {
} else if (streq(dec
->type
, "opaque")) {
s_print(buf
, "%s ", dec
->prefix
);
f_print(fout
, "%s%s %s", prefix
, type
, dec
->name
);
f_print(fout
, "%s%s %s[%s]", prefix
, type
, dec
->name
,
f_print(fout
, "%s%s *%s", prefix
, type
, dec
->name
);
f_print(fout
, "struct {\n");
f_print(fout
, "\tu_int %s_len;\n", dec
->name
);
f_print(fout
, "\t%s%s *%s_val;\n", prefix
, type
, dec
->name
);
f_print(fout
, "} %s", dec
->name
);
for (l
= defined
; l
!= NULL
; l
= l
->next
) {
def
= (definition
*) l
->val
;
if (def
->def_kind
!= DEF_PROGRAM
) {
if (streq(def
->def_name
, stop
)) {
} else if (streq(def
->def_name
, type
)) {