[BACK]Return to rpc_cout.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rpcgen

Diff for /src/usr.bin/rpcgen/rpc_cout.c between version 1.4 and 1.5

version 1.4, 1997/10/11 21:10:41 version 1.5, 2001/07/17 02:23:59
Line 41 
Line 41 
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <ctype.h>
   #include <err.h>
 #include "rpc_parse.h"  #include "rpc_parse.h"
 #include "rpc_util.h"  #include "rpc_util.h"
   
 static findtype __P((definition *, char *));  static int findtype __P((definition *, char *));
 static undefined __P((char *));  static int undefined __P((char *));
 static print_generic_header __P((char *, int));  static void print_generic_header __P((char *, int));
 static print_header __P((definition *));  static void print_header __P((definition *));
 static print_prog_header __P((proc_list *));  static void print_prog_header __P((proc_list *));
 static print_trailer __P((void));  static void print_trailer __P((void));
 static print_ifopen __P((int, char *));  static void print_ifopen __P((int, char *));
 static print_ifarg __P((char *));  static void print_ifarg __P((char *));
 static print_ifsizeof __P((char *, char *));  static void print_ifsizeof __P((char *, char *));
 static print_ifclose __P((int));  static void print_ifclose __P((int));
 static print_ifstat __P((int, char *, char *, relation, char *, char *, char *));  static void print_ifstat __P((int, char *, char *, relation, char *, char *, char *));
 static emit_num __P((definition *));  static void emit_program __P((definition *));
 static emit_program __P((definition *));  static void emit_enum __P((definition *));
 static emit_enum __P((definition *));  static void emit_union __P((definition *));
 static emit_union __P((definition *));  static void emit_struct __P((definition *));
 static emit_struct __P((definition *));  static void emit_typedef __P((definition *));
 static emit_typedef __P((definition *));  static void print_stat __P((int, declaration *));
 static print_stat __P((int, declaration *));  
   
   
 /*  /*
Line 101 
Line 102 
         case DEF_TYPEDEF:          case DEF_TYPEDEF:
                 emit_typedef(def);                  emit_typedef(def);
                 break;                  break;
           case DEF_CONST:
           case DEF_PROGRAM:
                   errx(1, "Internal error %s, %d: Case %d not handled\n",
                       __FILE__, __LINE__, def->def_kind);
                   break;
         }          }
         print_trailer();          print_trailer();
 }  }
   
 static  static int
 findtype(def, type)  findtype(def, type)
         definition *def;          definition *def;
         char   *type;          char   *type;
Line 118 
Line 124 
         }          }
 }  }
   
 static  static int
 undefined(type)  undefined(type)
         char   *type;          char   *type;
 {  {
Line 130 
Line 136 
         return (def == NULL);          return (def == NULL);
 }  }
   
 static  static void
 print_generic_header(procname, pointerp)  print_generic_header(procname, pointerp)
         char   *procname;          char   *procname;
         int     pointerp;          int     pointerp;
Line 154 
Line 160 
         }          }
 }  }
   
 static  static void
 print_header(def)  print_header(def)
         definition *def;          definition *def;
 {  {
   
         decl_list *dl;  
         bas_type *ptr;  
         int     i;  
   
   
         print_generic_header(def->def_name,          print_generic_header(def->def_name,
             def->def_kind != DEF_TYPEDEF ||              def->def_kind != DEF_TYPEDEF ||
             !isvectordef(def->def.ty.old_type, def->def.ty.rel));              !isvectordef(def->def.ty.old_type, def->def.ty.rel));
Line 178 
Line 179 
   
 }  }
   
 static  static void
 print_prog_header(plist)  print_prog_header(plist)
         proc_list *plist;          proc_list *plist;
 {  {
         print_generic_header(plist->args.argname, 1);          print_generic_header(plist->args.argname, 1);
 }  }
   
 static  static void
 print_trailer()  print_trailer()
 {  {
         f_print(fout, "\treturn (TRUE);\n");          f_print(fout, "\treturn (TRUE);\n");
Line 193 
Line 194 
 }  }
   
   
 static  static void
 print_ifopen(indent, name)  print_ifopen(indent, name)
         int     indent;          int     indent;
         char   *name;          char   *name;
Line 202 
Line 203 
         f_print(fout, " if (!xdr_%s(xdrs", name);          f_print(fout, " if (!xdr_%s(xdrs", name);
 }  }
   
 static  static void
 print_ifarg(arg)  print_ifarg(arg)
         char   *arg;          char   *arg;
 {  {
         f_print(fout, ", %s", arg);          f_print(fout, ", %s", arg);
 }  }
   
 static  static void
 print_ifsizeof(prefix, type)  print_ifsizeof(prefix, type)
         char   *prefix;          char   *prefix;
         char   *type;          char   *type;
Line 225 
Line 226 
         }          }
 }  }
   
 static  static void
 print_ifclose(indent)  print_ifclose(indent)
         int     indent;          int     indent;
 {  {
Line 236 
Line 237 
         f_print(fout, " }\n");          f_print(fout, " }\n");
 }  }
   
 static  static void
 print_ifstat(indent, prefix, type, rel, amax, objname, name)  print_ifstat(indent, prefix, type, rel, amax, objname, name)
         int     indent;          int     indent;
         char   *prefix;          char   *prefix;
Line 314 
Line 315 
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
 static  static void
 emit_enum(def)  emit_enum(def)
         definition *def;          definition *def;
 {  {
Line 323 
Line 324 
         print_ifclose(1);          print_ifclose(1);
 }  }
   
 static  static void
 emit_program(def)  emit_program(def)
         definition *def;          definition *def;
 {  {
Line 345 
Line 346 
 }  }
   
   
 static  static void
 emit_union(def)  emit_union(def)
         definition *def;          definition *def;
 {  {
Line 407 
Line 408 
         f_print(fout, "\t}\n");          f_print(fout, "\t}\n");
 }  }
   
 static  static void
 emit_struct(def)  emit_struct(def)
         definition *def;          definition *def;
 {  {
Line 514 
Line 515 
                                 }                                  }
   
                         } else {                          } else {
                                 if (i > 0)                                  if (i > 0) {
                                         if (sizestr == NULL && size < doinline) {                                          if (sizestr == NULL && size < doinline) {
                                                 /* don't expand into inline                                                  /* don't expand into inline
                                                  * code if size < doinline */                                                   * code if size < doinline */
Line 559 
Line 560 
   
                                                 f_print(fout, "\t  }\n");                                                  f_print(fout, "\t  }\n");
                                         }                                          }
                                   }
                                 size = 0;                                  size = 0;
                                 i = 0;                                  i = 0;
                                 sizestr = NULL;                                  sizestr = NULL;
Line 566 
Line 568 
                         }                          }
   
                 }                  }
                 if (i > 0)                  if (i > 0) {
                         if (sizestr == NULL && size < doinline) {                          if (sizestr == NULL && size < doinline) {
                                 /* don't expand into inline code if size <                                  /* don't expand into inline code if size <
                                  * doinline */                                   * doinline */
Line 610 
Line 612 
   
                         }                          }
                 flag = GET;                  flag = GET;
                   }
         }          }
         f_print(fout, "\t return(TRUE);\n\t}\n\n");          f_print(fout, "\t return(TRUE);\n\t}\n\n");
   
Line 619 
Line 622 
                 print_stat(1, &dl->decl);                  print_stat(1, &dl->decl);
 }  }
   
 static  static void
 emit_typedef(def)  emit_typedef(def)
         definition *def;          definition *def;
 {  {
Line 632 
Line 635 
         print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);          print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
 }  }
   
 static  static void
 print_stat(indent, dec)  print_stat(indent, dec)
         declaration *dec;          declaration *dec;
         int     indent;          int     indent;
Line 655 
Line 658 
 char   *upcase __P((char *));  char   *upcase __P((char *));
   
   
   void
 emit_inline(decl, flag)  emit_inline(decl, flag)
         declaration *decl;          declaration *decl;
         int     flag;          int     flag;
Line 672 
Line 676 
                     decl->name, decl->array_max);                      decl->name, decl->array_max);
                 emit_single_in_line(decl, flag, REL_VECTOR);                  emit_single_in_line(decl, flag, REL_VECTOR);
                 f_print(fout, "\t\t   }\n\t\t };\n");                  f_print(fout, "\t\t   }\n\t\t };\n");
           case REL_ARRAY:
           case REL_POINTER:
                   errx(1, "Internal error %s, %d: Case %d not handled\n",
                       __FILE__, __LINE__, decl->rel);
   
         }          }
 }  }
   
   void
 emit_single_in_line(decl, flag, rel)  emit_single_in_line(decl, flag, rel)
         declaration *decl;          declaration *decl;
         int     flag;          int     flag;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5