Build system: Move install definitions to include
[openafs.git] / src / rxgen / rpc_hout.c
index 751fdbb..9df8cf7 100644 (file)
@@ -6,47 +6,39 @@
  * 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
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
 
 /*
- * rpc_hout.c, Header file outputter for the RPC protocol compiler 
- * Copyright (C) 1987, Sun Microsystems, Inc. 
+ * rpc_hout.c, Header file outputter for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsystems, Inc.
  */
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
 
-#include <stdio.h>
-#include <string.h>
 #include <ctype.h>
 
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include "rpc_scan.h"
 #include "rpc_parse.h"
 #include "rpc_util.h"
@@ -67,7 +59,7 @@ static void pdeclaration(char *name, declaration * dec, int tab);
 static int undefined2(char *type, char *stop);
 
 /*
- * Print the C-version of an xdr definition 
+ * Print the C-version of an xdr definition
  */
 void
 print_datadef(definition * def)
@@ -157,7 +149,11 @@ puniondef(definition * def)
     if (decl && !streq(decl->type, "void")) {
        pdeclaration(name, decl, 2);
     }
-    f_print(fout, "\t} %s_u;\n", name);
+    if (brief_flag) {
+       f_print(fout, "\t} u;\n");
+    } else {
+       f_print(fout, "\t} %s_u;\n", name);
+    }
     f_print(fout, "};\n");
     f_print(fout, "typedef struct %s %s;\n", name, name);
     STOREVAL(&uniondef_defined, def);
@@ -270,7 +266,7 @@ psprocdef(definition * defp)
                (1 << DEF_INPARAM) | (1 << DEF_INOUTPARAM));
        psproc1(defp, 1, "int", "End",
                (1 << DEF_OUTPARAM) | (1 << DEF_INOUTPARAM));
-    } 
+    }
     if (!(!multi_flag && split_flag))
         psproc1(defp, 0, "int", "", 0xFFFFFFFF);
 
@@ -345,7 +341,7 @@ ptypedef(definition * def)
        if (streq(old, "string")) {
            old = "char";
            rel = REL_POINTER;
-       } else if (streq(old, "opaque")) {
+       } else if (!brief_flag && streq(old, "opaque")) {
            old = "char";
        } else if (streq(old, "bool")) {
            old = "bool_t";
@@ -358,10 +354,21 @@ ptypedef(definition * def)
        f_print(fout, "typedef ");
        switch (rel) {
        case REL_ARRAY:
-           f_print(fout, "struct %s {\n", name);
-           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);
+           if (brief_flag) {
+               if (streq(old, "opaque")) {
+                   f_print(fout, "struct rx_opaque %s", name);
+               } else {
+                   f_print(fout, "struct {\n");
+                   f_print(fout, "\tu_int len;\n");
+                   f_print(fout, "\t%s%s *val;\n", prefix, old);
+                   f_print(fout, "} %s", name);
+               }
+           } else {
+               f_print(fout, "struct %s {\n", name);
+               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);
+           }
            break;
        case REL_POINTER:
            f_print(fout, "%s%s *%s", prefix, old, name);
@@ -422,13 +429,27 @@ pdeclaration(char *name, declaration * dec, int tab)
            f_print(fout, "%s%s *%s", prefix, type, dec->name);
            break;
        case REL_ARRAY:
-           f_print(fout, "struct %s {\n", dec->name);
-           tabify(fout, tab);
-           f_print(fout, "\tu_int %s_len;\n", dec->name);
-           tabify(fout, tab);
-           f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);
-           tabify(fout, tab);
-           f_print(fout, "} %s", dec->name);
+           if (brief_flag) {
+               if (streq(dec->type, "opaque")) {
+                   f_print(fout, "struct rx_opaque %s",dec->name);
+               } else {
+                   f_print(fout, "struct {\n");
+                   tabify(fout, tab);
+                   f_print(fout, "\tu_int len;\n");
+                   tabify(fout, tab);
+                   f_print(fout, "\t%s%s *val;\n", prefix, type);
+                   tabify(fout, tab);
+                   f_print(fout, "} %s", dec->name);
+               }
+           } else {
+               f_print(fout, "struct %s {\n", dec->name);
+               tabify(fout, tab);
+               f_print(fout, "\tu_int %s_len;\n", dec->name);
+               tabify(fout, tab);
+               f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);
+               tabify(fout, tab);
+               f_print(fout, "} %s", dec->name);
+           }
            break;
        }
     }