static void
pprogramdef (definition * def)
{
  version_list *vers;
  proc_list *proc;

#if 0
  static int puttbl;
  if (!puttbl) {
    puttbl = 1;
    f_print (fout,
	     "#ifndef _RPCGEN_TABLE_DEFINED_\n"
	     "#define _RPCGEN_TABLE_DEFINED_ 1\n"
	     "#ifndef RPCGEN_ACTION\n"
	     "#define RPCGEN_ACTION(x) 0\n"
	     "#endif /* !RPCGEN_ACTION */\n"
	     "struct rpcgen_table {\n"
	     "  char *(*proc)();\n"
	     "  xdrproc_t xdr_arg;\n"
	     "  unsigned len_arg;\n"
	     "  xdrproc_t xdr_res;\n"
	     "  unsigned len_res;\n"
	     "};\n"
	     "\n"
	     "struct rpc_program {\n"
	     "  u_int32_t progno;\n"
	     "  u_int32_t versno;\n"
	     "  const struct rpcgen_table *tbl;\n"
	     "  size_t nproc;\n"
	     "};\n"
	     "#endif /* !_RPCGEN_TABLE_DEFINED_ */\n\n");
  }
#endif

  pargdef (def);

  puldefine (def->def_name, def->def.pr.prog_num);
  for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
    if (tblflag) {
      f_print (fout, "RPC_EXTERN const struct rpcgen_table %s_%s_table[];\n",
	       locase (def->def_name), vers->vers_num);
      f_print (fout, "RPC_EXTERN const int %s_%s_nproc;\n",
	       locase (def->def_name), vers->vers_num);
      f_print (fout, "RPC_EXTERN const struct rpc_program  %s_%s;\n",
	       locase (def->def_name), vers->vers_num);
    }
    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);
#if 0
      pprocdef (proc, vers, "CLIENT *", 0, 0);
      pprocdef (proc, vers, "struct svc_req *", 1, 0);
#endif
    }
  }
}
示例#2
0
文件: rpc_hout.c 项目: libogdi/ogdi
static void
pprogramdef(definition *def)
{
	version_list *vers;
	proc_list *proc;
	int i;
	const char *ext;
	
	pargdef(def);

	puldefine(def->def_name, def->def.pr.prog_num);
	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
		if (tblflag) {
			f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",
				locase(def->def_name), vers->vers_num);
			f_print(fout, "extern %s_%s_nproc;\n",
				locase(def->def_name), vers->vers_num);
		}
		puldefine(vers->vers_name, vers->vers_num);

		/* 
		 * Print out 3 definitions, one for ANSI-C, another for C++, 
		 * a third for old style C 
		 */
		   
		for (i=0;i<3;i++) {
			if (i==0) {
				f_print(fout,"\n#ifdef __cplusplus\n");
				ext="extern \"C\" ";
			} 
			else if (i==1) {
				f_print(fout,"\n#elif __STDC__\n");
				ext="extern  "  ;
			} 
			else {
				f_print(fout,"\n#else /* Old Style C */ \n");
				ext="extern  ";
			}
			
			
			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,"%s",ext);
				pprocdef(proc, vers, "CLIENT *", 0,i);
				f_print(fout,"%s",ext);
				pprocdef(proc, vers, "struct svc_req *", 1,i);
				
			}

		}
		f_print(fout,"#endif /* Old Style C */ \n");
	}
}
示例#3
0
static void
pprogramdef(definition *def, int headeronly)
{
	version_list *vers;
	proc_list *proc;
	const char *ext;

	pargdef(def);

	puldefine(def->def_name, def->def.pr.prog_num);
	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
		if (tblflag) {
			f_print(fout,
				"extern struct rpcgen_table %s_%s_table[];\n",
				locase(def->def_name), vers->vers_num);
			f_print(fout,
				"extern %s_%s_nproc;\n",
				locase(def->def_name), vers->vers_num);
		}
		puldefine(vers->vers_name, vers->vers_num);

		f_print(fout, "\n");
		ext = "extern  ";
		if (headeronly) {
			f_print(fout, "%s", ext);
			pdispatch(def->def_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, "%s", ext);
			pprocdef(proc, vers, "CLIENT *", 0);
			f_print(fout, "%s", ext);
			pprocdef(proc, vers, "struct svc_req *", 1);
		}
		pfreeprocdef(def->def_name, vers->vers_num);
	}
}
示例#4
0
static void
pprogramdef(definition *def)
{
	version_list *vers;
	proc_list *proc;

	pargdef(def);

	puldefine(def->def_name, def->def.pr.prog_num);
	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
		if (tblflag) {
			f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",
			    locase(def->def_name), vers->vers_num);
			f_print(fout, "extern %s_%s_nproc;\n",
			    locase(def->def_name), vers->vers_num);
		}
		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);
			}
		}
	}

	/*
	 * Print out 3 definitions, one for ANSI-C, another for C++, a
	 * third for old style C
	 */
	f_print(fout, "\n");
	cplusplusstart();
	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
		for (proc = vers->procs; proc != NULL; proc = proc->next) {
			pprocdef(proc, vers, "CLIENT *", 0);
			pprocdef(proc, vers, "struct svc_req *", 1);
		}
	}
	cplusplusend();
}
static void
pprogramdef (definition *def)
{
  version_list *vers;
  proc_list *proc;
  int i;
  const char *ext;

  pargdef (def);

  pdefine (def->def_name, def->def.pr.prog_num);
  for (vers = def->def.pr.versions; vers != NULL; vers = vers->next)
    {
      if (tblflag)
	{
	  f_print (fout, "extern struct rpcgen_table %s_%s_table[];\n",
		   locase (def->def_name), vers->vers_num);
	  f_print (fout, "extern %s_%s_nproc;\n",
		   locase (def->def_name), vers->vers_num);
	}
      pdefine (vers->vers_name, vers->vers_num);

      /*
       * Print out 2 definitions, one for ANSI-C, another for
       * old K & R C
       */

      if(!Cflag)
	{
	  ext = "extern  ";
	  for (proc = vers->procs; proc != NULL;
	       proc = proc->next)
	    {
	      if (!define_printed(proc, def->def.pr.versions))
		{
		  pdefine (proc->proc_name, proc->proc_num);
		}
	      f_print (fout, "%s", ext);
	      pprocdef (proc, vers, NULL, 0, 2);

	      if (mtflag)
		{
		  f_print(fout, "%s", ext);
		  pprocdef (proc, vers, NULL, 1, 2);
		}
	    }
	  pfreeprocdef (def->def_name, vers->vers_num, 2);
	}
      else
	{
	  for (i = 1; i < 3; i++)
	    {
	      if (i == 1)
		{
		  f_print (fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n");
		  ext = "extern  ";
		}
	      else
		{
		  f_print (fout, "\n#else /* K&R C */\n");
		  ext = "extern  ";
		}

	      for (proc = vers->procs; proc != NULL; proc = proc->next)
		{
		  if (!define_printed(proc, def->def.pr.versions))
		    {
		      pdefine(proc->proc_name, proc->proc_num);
		    }
		  f_print (fout, "%s", ext);
		  pprocdef (proc, vers, "CLIENT *", 0, i);
		  f_print (fout, "%s", ext);
		  pprocdef (proc, vers, "struct svc_req *", 1, i);
		}
	      pfreeprocdef (def->def_name, vers->vers_num, i);
	    }
	  f_print (fout, "#endif /* K&R C */\n");
	}
    }
}