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

Diff for /src/usr.bin/rpcgen/rpc_hout.c between version 1.10 and 1.11

version 1.10, 2002/02/16 21:27:51 version 1.11, 2002/06/01 01:40:38
Line 71 
Line 71 
                 return;                  return;
   
         if (def->def_kind != DEF_CONST)          if (def->def_kind != DEF_CONST)
                 f_print(fout, "\n");                  fprintf(fout, "\n");
         switch (def->def_kind) {          switch (def->def_kind) {
         case DEF_STRUCT:          case DEF_STRUCT:
                 pstructdef(def);                  pstructdef(def);
Line 106 
Line 106 
 {  {
         switch (def->def_kind) {          switch (def->def_kind) {
         case DEF_PROGRAM:          case DEF_PROGRAM:
                 f_print(fout, "\n");                  fprintf(fout, "\n");
                 pprogramdef(def);                  pprogramdef(def);
                 break;                  break;
         }          }
Line 118 
Line 118 
         int pointerp;          int pointerp;
 {  {
   
         f_print(fout,"#ifdef __cplusplus\n");          fprintf(fout,"#ifdef __cplusplus\n");
         f_print(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n",          fprintf(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n",
             name, name, pointerp ? ("*") : "");              name, name, pointerp ? ("*") : "");
         f_print(fout,"#elif defined(__STDC__)\n");          fprintf(fout,"#elif defined(__STDC__)\n");
         f_print(fout, "extern  bool_t xdr_%s(XDR *, %s%s);\n",          fprintf(fout, "extern  bool_t xdr_%s(XDR *, %s%s);\n",
             name, name, pointerp ? ("*") : "");              name, name, pointerp ? ("*") : "");
         f_print(fout,"#else /* Old Style C */\n");          fprintf(fout,"#else /* Old Style C */\n");
         f_print(fout, "bool_t xdr_%s();\n", name);          fprintf(fout, "bool_t xdr_%s();\n", name);
         f_print(fout,"#endif /* Old Style C */\n\n");          fprintf(fout,"#endif /* Old Style C */\n\n");
 }  }
   
   
Line 156 
Line 156 
                                 continue; /* old style or single args */                                  continue; /* old style or single args */
                         }                          }
                         name = plist->args.argname;                          name = plist->args.argname;
                         f_print(fout, "struct %s {\n", name);                          fprintf(fout, "struct %s {\n", name);
                         for (l = plist->args.decls;                          for (l = plist->args.decls;
                              l != NULL; l = l->next) {                               l != NULL; l = l->next) {
                                 pdeclaration(name, &l->decl, 1, ";\n");                                  pdeclaration(name, &l->decl, 1, ";\n");
                         }                          }
                         f_print(fout, "};\n");                          fprintf(fout, "};\n");
                         f_print(fout, "typedef struct %s %s;\n", name, name);                          fprintf(fout, "typedef struct %s %s;\n", name, name);
                         pxdrfuncdecl(name, NULL);                          pxdrfuncdecl(name, NULL);
                         f_print(fout, "\n");                          fprintf(fout, "\n");
                 }                  }
         }          }
 }  }
Line 176 
Line 176 
         char *name = def->def_name;          char *name = def->def_name;
         decl_list *l;          decl_list *l;
   
         f_print(fout, "struct %s {\n", name);          fprintf(fout, "struct %s {\n", name);
         for (l = def->def.st.decls; l != NULL; l = l->next)          for (l = def->def.st.decls; l != NULL; l = l->next)
                 pdeclaration(name, &l->decl, 1, ";\n");                  pdeclaration(name, &l->decl, 1, ";\n");
         f_print(fout, "};\n");          fprintf(fout, "};\n");
         f_print(fout, "typedef struct %s %s;\n", name, name);          fprintf(fout, "typedef struct %s %s;\n", name, name);
 }  }
   
 static void  static void
Line 191 
Line 191 
         char *name = def->def_name;          char *name = def->def_name;
         declaration *decl;          declaration *decl;
   
         f_print(fout, "struct %s {\n", name);          fprintf(fout, "struct %s {\n", name);
         decl = &def->def.un.enum_decl;          decl = &def->def.un.enum_decl;
         if (streq(decl->type, "bool")) {          if (streq(decl->type, "bool")) {
                 f_print(fout, "\tbool_t %s;\n", decl->name);                  fprintf(fout, "\tbool_t %s;\n", decl->name);
         } else {          } else {
                 f_print(fout, "\t%s %s;\n", decl->type, decl->name);                  fprintf(fout, "\t%s %s;\n", decl->type, decl->name);
         }          }
         f_print(fout, "\tunion {\n");          fprintf(fout, "\tunion {\n");
         for (l = def->def.un.cases; l != NULL; l = l->next) {          for (l = def->def.un.cases; l != NULL; l = l->next) {
           if (l->contflag == 0)            if (l->contflag == 0)
                 pdeclaration(name, &l->case_decl, 2, ";\n");                  pdeclaration(name, &l->case_decl, 2, ";\n");
Line 207 
Line 207 
         if (decl && !streq(decl->type, "void")) {          if (decl && !streq(decl->type, "void")) {
                 pdeclaration(name, decl, 2, ";\n");                  pdeclaration(name, decl, 2, ";\n");
         }          }
         f_print(fout, "\t} %s_u;\n", name);          fprintf(fout, "\t} %s_u;\n", name);
         f_print(fout, "};\n");          fprintf(fout, "};\n");
         f_print(fout, "typedef struct %s %s;\n", name, name);          fprintf(fout, "typedef struct %s %s;\n", name, name);
 }  }
   
 static void  static void
Line 217 
Line 217 
         char *name;          char *name;
         char *num;          char *num;
 {  {
         f_print(fout, "#define %s %s\n", name, num);          fprintf(fout, "#define %s %s\n", name, num);
 }  }
   
 static void  static void
Line 225 
Line 225 
         char *name;          char *name;
         char *num;          char *num;
 {  {
         f_print(fout, "#define %s ((u_long)%s)\n", name, num);          fprintf(fout, "#define %s ((u_long)%s)\n", name, num);
 }  }
   
 static int  static int
Line 263 
Line 263 
         puldefine(def->def_name, def->def.pr.prog_num);          puldefine(def->def_name, def->def.pr.prog_num);
         for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {          for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
                 if (tblflag) {                  if (tblflag) {
                         f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",                          fprintf(fout, "extern struct rpcgen_table %s_%s_table[];\n",
                             locase(def->def_name), vers->vers_num);                              locase(def->def_name), vers->vers_num);
                         f_print(fout, "extern %s_%s_nproc;\n",                          fprintf(fout, "extern %s_%s_nproc;\n",
                             locase(def->def_name), vers->vers_num);                              locase(def->def_name), vers->vers_num);
                 }                  }
                 puldefine(vers->vers_name, vers->vers_num);                  puldefine(vers->vers_name, vers->vers_num);
Line 276 
Line 276 
                  */                   */
                 for(i=0; i<3; i++) {                  for(i=0; i<3; i++) {
                         if (i==0) {                          if (i==0) {
                                 f_print(fout,"\n#ifdef __cplusplus\n");                                  fprintf(fout,"\n#ifdef __cplusplus\n");
                                 ext = "extern \"C\" ";                                  ext = "extern \"C\" ";
                         } else if (i==1) {                          } else if (i==1) {
                                 f_print(fout,"\n#elif defined(__STDC__)\n");                                  fprintf(fout,"\n#elif defined(__STDC__)\n");
                                 ext = "extern  ";                                  ext = "extern  ";
                         } else {                          } else {
                                 f_print(fout,"\n#else /* Old Style C */\n");                                  fprintf(fout,"\n#else /* Old Style C */\n");
                                 ext = "extern  ";                                  ext = "extern  ";
                         }                          }
   
                         for (proc = vers->procs; proc != NULL; proc = proc->next) {                          for (proc = vers->procs; proc != NULL; proc = proc->next) {
                                 if (!define_printed(proc, def->def.pr.versions))                                  if (!define_printed(proc, def->def.pr.versions))
                                         puldefine(proc->proc_name, proc->proc_num);                                          puldefine(proc->proc_name, proc->proc_num);
                                 f_print(fout,"%s",ext);                                  fprintf(fout,"%s",ext);
                                 pprocdef(proc, vers, "CLIENT *", 0,i);                                  pprocdef(proc, vers, "CLIENT *", 0,i);
                                 f_print(fout,"%s",ext);                                  fprintf(fout,"%s",ext);
                                 pprocdef(proc, vers, "struct svc_req *", 1,i);                                  pprocdef(proc, vers, "struct svc_req *", 1,i);
                         }                          }
                 }                  }
                 f_print(fout,"#endif /* Old Style C */\n");                  fprintf(fout,"#endif /* Old Style C */\n");
         }          }
 }  }
   
Line 309 
Line 309 
 {  {
   
         ptype(proc->res_prefix, proc->res_type, 1);          ptype(proc->res_prefix, proc->res_type, 1);
         f_print(fout, "* ");          fprintf(fout, "* ");
         if (server_p)          if (server_p)
                 pvname_svc(proc->proc_name, vp->vers_num);                  pvname_svc(proc->proc_name, vp->vers_num);
         else          else
Line 321 
Line 321 
         if (mode == 0 || mode == 1)          if (mode == 0 || mode == 1)
                 parglist(proc, addargtype);                  parglist(proc, addargtype);
         else          else
                 f_print(fout, "();\n");                  fprintf(fout, "();\n");
 }  }
   
 /* print out argument list of procedure */  /* print out argument list of procedure */
Line 332 
Line 332 
 {  {
         decl_list *dl;          decl_list *dl;
   
         f_print(fout,"(");          fprintf(fout,"(");
   
         if (proc->arg_num < 2 && newstyle &&          if (proc->arg_num < 2 && newstyle &&
            streq(proc->args.decls->decl.type, "void")) {             streq(proc->args.decls->decl.type, "void")) {
Line 341 
Line 341 
                 for (dl = proc->args.decls; dl != NULL; dl = dl->next) {                  for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
                         ptype(dl->decl.prefix, dl->decl.type, 1);                          ptype(dl->decl.prefix, dl->decl.type, 1);
                         if (!newstyle)                          if (!newstyle)
                                 f_print(fout, "*"); /* old style passes by reference */                                  fprintf(fout, "*"); /* old style passes by reference */
                         f_print(fout, ", ");                          fprintf(fout, ", ");
                 }                  }
         }          }
         f_print(fout, "%s);\n", addargtype);          fprintf(fout, "%s);\n", addargtype);
 }  }
   
 static void  static void
Line 357 
Line 357 
         char *last = NULL;          char *last = NULL;
         int count = 0;          int count = 0;
   
         f_print(fout, "enum %s {\n", name);          fprintf(fout, "enum %s {\n", name);
         for (l = def->def.en.vals; l != NULL; l = l->next) {          for (l = def->def.en.vals; l != NULL; l = l->next) {
                 f_print(fout, "\t%s", l->name);                  fprintf(fout, "\t%s", l->name);
                 if (l->assignment) {                  if (l->assignment) {
                         f_print(fout, " = %s", l->assignment);                          fprintf(fout, " = %s", l->assignment);
                         last = l->assignment;                          last = l->assignment;
                         count = 1;                          count = 1;
                 } else {                  } else {
                         if (last == NULL) {                          if (last == NULL) {
                                 f_print(fout, " = %d", count++);                                  fprintf(fout, " = %d", count++);
                         } else {                          } else {
                                 f_print(fout, " = %s + %d", last, count++);                                  fprintf(fout, " = %s + %d", last, count++);
                         }                          }
                 }                  }
                 if (l->next)                  if (l->next)
                         f_print(fout, ",\n");                          fprintf(fout, ",\n");
                 else                  else
                         f_print(fout, "\n");                          fprintf(fout, "\n");
         }          }
         f_print(fout, "};\n");          fprintf(fout, "};\n");
         f_print(fout, "typedef enum %s %s;\n", name, name);          fprintf(fout, "typedef enum %s %s;\n", name, name);
 }  }
   
 static void  static void
Line 399 
Line 399 
                         old = "bool_t";                          old = "bool_t";
                 }                  }
                 if (undefined2(old, name) && def->def.ty.old_prefix) {                  if (undefined2(old, name) && def->def.ty.old_prefix) {
                         s_print(prefix, "%s ", def->def.ty.old_prefix);                          snprintf(prefix, sizeof prefix, "%s ", def->def.ty.old_prefix);
                 } else {                  } else {
                         prefix[0] = 0;                          prefix[0] = 0;
                 }                  }
                 f_print(fout, "typedef ");                  fprintf(fout, "typedef ");
                 switch (rel) {                  switch (rel) {
                 case REL_ARRAY:                  case REL_ARRAY:
                         f_print(fout, "struct {\n");                          fprintf(fout, "struct {\n");
                         f_print(fout, "\tu_int %s_len;\n", name);                          fprintf(fout, "\tu_int %s_len;\n", name);
                         f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name);                          fprintf(fout, "\t%s%s *%s_val;\n", prefix, old, name);
                         f_print(fout, "} %s", name);                          fprintf(fout, "} %s", name);
                         break;                          break;
                 case REL_POINTER:                  case REL_POINTER:
                         f_print(fout, "%s%s *%s", prefix, old, name);                          fprintf(fout, "%s%s *%s", prefix, old, name);
                         break;                          break;
                 case REL_VECTOR:                  case REL_VECTOR:
                         f_print(fout, "%s%s %s[%s]", prefix, old, name,                          fprintf(fout, "%s%s %s[%s]", prefix, old, name,
                                 def->def.ty.array_max);                                  def->def.ty.array_max);
                         break;                          break;
                 case REL_ALIAS:                  case REL_ALIAS:
                         f_print(fout, "%s%s %s", prefix, old, name);                          fprintf(fout, "%s%s %s", prefix, old, name);
                         break;                          break;
                 }                  }
                 f_print(fout, ";\n");                  fprintf(fout, ";\n");
         }          }
 }  }
   
Line 441 
Line 441 
                 return;                  return;
         tabify(fout, tab);          tabify(fout, tab);
         if (streq(dec->type, name) && !dec->prefix) {          if (streq(dec->type, name) && !dec->prefix) {
                 f_print(fout, "struct ");                  fprintf(fout, "struct ");
         }          }
         if (streq(dec->type, "string")) {          if (streq(dec->type, "string")) {
                 f_print(fout, "char *%s", dec->name);                  fprintf(fout, "char *%s", dec->name);
         } else {          } else {
                 prefix = "";                  prefix = "";
                 if (streq(dec->type, "bool")) {                  if (streq(dec->type, "bool")) {
Line 453 
Line 453 
                         type = "char";                          type = "char";
                 } else {                  } else {
                         if (dec->prefix) {                          if (dec->prefix) {
                                 s_print(buf, "%s ", dec->prefix);                                  snprintf(buf, sizeof buf, "%s ", dec->prefix);
                                 prefix = buf;                                  prefix = buf;
                         }                          }
                         type = dec->type;                          type = dec->type;
                 }                  }
                 switch (dec->rel) {                  switch (dec->rel) {
                 case REL_ALIAS:                  case REL_ALIAS:
                         f_print(fout, "%s%s %s", prefix, type, dec->name);                          fprintf(fout, "%s%s %s", prefix, type, dec->name);
                         break;                          break;
                 case REL_VECTOR:                  case REL_VECTOR:
                         f_print(fout, "%s%s %s[%s]", prefix, type, dec->name,                          fprintf(fout, "%s%s %s[%s]", prefix, type, dec->name,
                                 dec->array_max);                                  dec->array_max);
                         break;                          break;
                 case REL_POINTER:                  case REL_POINTER:
                         f_print(fout, "%s%s *%s", prefix, type, dec->name);                          fprintf(fout, "%s%s *%s", prefix, type, dec->name);
                         break;                          break;
                 case REL_ARRAY:                  case REL_ARRAY:
                         f_print(fout, "struct {\n");                          fprintf(fout, "struct {\n");
                         tabify(fout, tab);                          tabify(fout, tab);
                         f_print(fout, "\tu_int %s_len;\n", dec->name);                          fprintf(fout, "\tu_int %s_len;\n", dec->name);
                         tabify(fout, tab);                          tabify(fout, tab);
                         f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);                          fprintf(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);
                         tabify(fout, tab);                          tabify(fout, tab);
                         f_print(fout, "} %s", dec->name);                          fprintf(fout, "} %s", dec->name);
                         break;                          break;
                 }                  }
         }          }
         f_print(fout, separator);          fprintf(fout, separator);
 }  }
   
 static int  static int

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11