Back to index

glibc  2.9
Functions
proto.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void write_stubs (void)
void printarglist (proc_list *proc, const char *result, const char *addargname, const char *addargtype)
void emit (definition *def)
void print_datadef (definition *def)
void print_funcdef (definition *def)
void pxdrfuncdecl (const char *name, int pointerp)
void pprocdef (proc_list *proc, version_list *vp, const char *addargtype, int server_p, int mode)
void pdeclaration (const char *name, declaration *dec, int tab, const char *separator)
void print_xdr_func_def (char *name, int pointerp, int i)
definition * get_definition (void)
void write_sample_svc (definition *def)
int write_sample_clnt (definition *def)
void add_sample_msg (void)
void write_sample_clnt_main (void)
int nullproc (const proc_list *proc)
void write_svc_aux (int nomain)
void write_msg_out (void)
void write_tables (void)
void reinitialize (void)
int streq (const char *a, const char *b)
void error (const char *msg) __attribute__((noreturn))
void crash (void) __attribute__((noreturn))
void tabify (FILE *f, int tab)
char * make_argname (const char *pname, const char *vname)
void add_type (int len, const char *type)

Function Documentation

void add_sample_msg ( void  )

Definition at line 295 of file rpc_sample.c.

{
  f_print (fout, "/*\n");
  f_print (fout, " * This is sample code generated by rpcgen.\n");
  f_print (fout, " * These are only templates and you can use them\n");
  f_print (fout, " * as a guideline for developing your own functions.\n");
  f_print (fout, " */\n\n");
}

Here is the caller graph for this function:

void add_type ( int  len,
const char *  type 
)

Definition at line 481 of file rpc_util.c.

{
  bas_type *ptr;


  if ((ptr = malloc (sizeof (bas_type))) == NULL)
    {
      fprintf (stderr, "failed in malloc");
      exit (1);
    }

  ptr->name = type;
  ptr->length = len;
  ptr->next = NULL;
  if (typ_list_t == NULL)
    {

      typ_list_t = ptr;
      typ_list_h = ptr;
    }
  else
    {

      typ_list_t->next = ptr;
      typ_list_t = ptr;
    }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void crash ( void  )

Definition at line 288 of file rpc_util.c.

{
  int i;

  for (i = 0; i < nfiles; i++)
    {
      unlink (outfiles[i]);
    }
  exit (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void emit ( definition *  def)

Definition at line 72 of file rpc_cout.c.

{
  if (def->def_kind == DEF_CONST)
    {
      return;
    }
  if (def->def_kind == DEF_PROGRAM)
    {
      emit_program (def);
      return;
    }
  if (def->def_kind == DEF_TYPEDEF)
    {
      /* now we need to handle declarations like
         struct typedef foo foo;
         since we don't want this to be expanded
         into 2 calls to xdr_foo */

      if (strcmp (def->def.ty.old_type, def->def_name) == 0)
       return;
    };

  print_header (def);
  switch (def->def_kind)
    {
    case DEF_UNION:
      emit_union (def);
      break;
    case DEF_ENUM:
      emit_enum (def);
      break;
    case DEF_STRUCT:
      emit_struct (def);
      break;
    case DEF_TYPEDEF:
      emit_typedef (def);
      break;
    default:
      /* can't happen */
      break;
    }
  print_trailer ();
}

Here is the caller graph for this function:

void error ( const char *  msg)

Definition at line 275 of file rpc_util.c.

{
  printwhere ();
  f_print (stderr, "%s, line %d: ", infilename, linenum);
  f_print (stderr, "%s\n", msg);
  crash ();
}
definition* get_definition ( void  )

Definition at line 66 of file rpc_parse.c.

{
  definition *defp;
  token tok;

  defp = ALLOC (definition);
  get_token (&tok);
  switch (tok.kind)
    {
    case TOK_STRUCT:
      def_struct (defp);
      break;
    case TOK_UNION:
      def_union (defp);
      break;
    case TOK_TYPEDEF:
      def_typedef (defp);
      break;
    case TOK_ENUM:
      def_enum (defp);
      break;
    case TOK_PROGRAM:
      def_program (defp);
      break;
    case TOK_CONST:
      def_const (defp);
      break;
    case TOK_EOF:
      free (defp);
      return (NULL);
    default:
      error ("definition keyword expected");
    }
  scan (TOK_SEMICOLON, &tok);
  isdefined (defp);
  return (defp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* make_argname ( const char *  pname,
const char *  vname 
)

Definition at line 463 of file rpc_util.c.

{
  char *name;

  name = malloc (strlen (pname) + strlen (vname) + strlen (ARGEXT) + 3);
  if (!name)
    {
      fprintf (stderr, "failed in malloc");
      exit (1);
    }
  sprintf (name, "%s_%s_%s", locase (pname), vname, ARGEXT);
  return name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nullproc ( const proc_list *  proc)

Definition at line 662 of file rpc_svcout.c.

{
  for (; proc != NULL; proc = proc->next)
    {
      if (streq (proc->proc_num, "0"))
       {
         return 1;
       }
    }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdeclaration ( const char *  name,
declaration *  dec,
int  tab,
const char *  separator 
)

Definition at line 521 of file rpc_hout.c.

{
  char buf[8];                     /* enough to hold "struct ", include NUL */
  const char *prefix;
  const char *type;

  if (streq (dec->type, "void"))
    {
      return;
    }
  tabify (fout, tab);
  if (streq (dec->type, name) && !dec->prefix)
    {
      f_print (fout, "struct ");
    }
  if (streq (dec->type, "string"))
    {
      f_print (fout, "char *%s", dec->name);
    }
  else
    {
      prefix = "";
      if (streq (dec->type, "bool"))
       {
         type = "bool_t";
       }
      else if (streq (dec->type, "opaque"))
       {
         type = "char";
       }
      else
       {
         if (dec->prefix)
           {
             s_print (buf, "%s ", dec->prefix);
             prefix = buf;
           }
         type = dec->type;
       }
      switch (dec->rel)
       {
       case REL_ALIAS:
         f_print (fout, "%s%s %s", prefix, type, dec->name);
         break;
       case REL_VECTOR:
         f_print (fout, "%s%s %s[%s]", prefix, type, dec->name,
                 dec->array_max);
         break;
       case REL_POINTER:
         f_print (fout, "%s%s *%s", prefix, type, dec->name);
         break;
       case REL_ARRAY:
         f_print (fout, "struct {\n");
         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;
       }
    }
  f_print (fout, separator);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pprocdef ( proc_list *  proc,
version_list *  vp,
const char *  addargtype,
int  server_p,
int  mode 
)

Definition at line 369 of file rpc_hout.c.

{
  if (mtflag)
    {/* Print MT style stubs */
      if (server_p)
       f_print (fout, "bool_t ");
      else
       f_print (fout, "enum clnt_stat ");
    }
  else
    {
      ptype (proc->res_prefix, proc->res_type, 1);
      f_print (fout, "* ");
    }
  if (server_p)
    pvname_svc (proc->proc_name, vp->vers_num);
  else
    pvname (proc->proc_name, vp->vers_num);

  /*
   * mode  1 = ANSI-C, mode 2 = K&R C
   */
  if (mode == 1)
    parglist (proc, addargtype);
  else
    f_print (fout, "();\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print_datadef ( definition *  def)

Definition at line 86 of file rpc_hout.c.

{

  if (def->def_kind == DEF_PROGRAM)       /* handle data only */
    return;

  if (def->def_kind != DEF_CONST)
    {
      f_print (fout, "\n");
    }
  switch (def->def_kind)
    {
    case DEF_STRUCT:
      pstructdef (def);
      break;
    case DEF_UNION:
      puniondef (def);
      break;
    case DEF_ENUM:
      penumdef (def);
      break;
    case DEF_TYPEDEF:
      ptypedef (def);
      break;
    case DEF_PROGRAM:
      pprogramdef (def);
      break;
    case DEF_CONST:
      pconstdef (def);
      break;
    }
  if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST)
    {
      storexdrfuncdecl(def->def_name,
                     def->def_kind != DEF_TYPEDEF ||
                     !isvectordef(def->def.ty.old_type,
                                def->def.ty.rel));
    }
}

Here is the caller graph for this function:

void print_funcdef ( definition *  def)

Definition at line 128 of file rpc_hout.c.

{
  switch (def->def_kind)
    {
    case DEF_PROGRAM:
      f_print (fout, "\n");
      pprogramdef (def);
      break;
    default:
      break;
      /* ?... shouldn't happen I guess */
    }
}

Here is the caller graph for this function:

void print_xdr_func_def ( char *  name,
int  pointerp,
int  i 
)

Definition at line 143 of file rpc_hout.c.

{
  if (i == 2)
    {
      f_print (fout, "extern bool_t xdr_%s ();\n", name);
      return;
    }
  else
    f_print(fout, "extern  bool_t xdr_%s (XDR *, %s%s);\n", name,
           name, pointerp ? "*" : "");
}

Here is the caller graph for this function:

void printarglist ( proc_list *  proc,
const char *  result,
const char *  addargname,
const char *  addargtype 
)

Definition at line 114 of file rpc_clntout.c.

{

  decl_list *l;

  if (!newstyle)
    { /* old style: always pass argument by reference */
      if (Cflag)
       {                    /* C++ style heading */
         fprintf (fout, "(");
         ptype (proc->args.decls->decl.prefix,
               proc->args.decls->decl.type, 1);

         if (mtflag)
           {/* Generate result field */
             fprintf (fout, "*argp, ");
             ptype(proc->res_prefix, proc->res_type, 1);
             fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname);
           }
         else
           fprintf (fout, "*argp, %s%s)\n", addargtype, addargname);
       }
      else
       {
         if (!mtflag)
           fprintf (fout, "(argp, %s)\n", addargname);
         else
           fprintf (fout, "(argp, %s, %s)\n", result, addargname);
         fprintf (fout, "\t");
         ptype (proc->args.decls->decl.prefix,
               proc->args.decls->decl.type, 1);
         fprintf (fout, "*argp;\n");
         if (mtflag)
           {
             fprintf (fout, "\t");
             ptype (proc->res_prefix, proc->res_type, 1);
             fprintf (fout, "*%s;\n", result);
           }
       }
    }
  else if (streq (proc->args.decls->decl.type, "void"))
    {
      /* newstyle, 0 argument */
      if (mtflag)
       {
         fprintf (fout, "(");
         if (Cflag)
           {
             ptype(proc->res_prefix, proc->res_type, 1);
             fprintf (fout, "*%s, %s%s)\n", result, addargtype, addargname);
           }
         else
           fprintf (fout, "(%s)\n", addargname);
       }
      else if (Cflag)
       fprintf (fout, "(%s%s)\n", addargtype, addargname);
      else
       fprintf (fout, "(%s)\n", addargname);
    }
  else
    {
      /* new style, 1 or multiple arguments */
      if (!Cflag)
       {
         fprintf (fout, "(");
         for (l = proc->args.decls; l != NULL; l = l->next)
           fprintf (fout, "%s, ", l->decl.name);
         if (mtflag)
           fprintf (fout, "%s, ", result);
         fprintf (fout, "%s)\n", addargname);
         for (l = proc->args.decls; l != NULL; l = l->next)
           {
             pdeclaration (proc->args.argname, &l->decl, 1, ";\n");
           }
         if (mtflag)
           {
             fprintf (fout, "\t");
             ptype (proc->res_prefix, proc->res_type, 1);
             fprintf (fout, "*%s;\n", result);
           }
       }
      else
       {                    /* C++ style header */
         fprintf (fout, "(");
         for (l = proc->args.decls; l != NULL; l = l->next)
           {
             pdeclaration (proc->args.argname, &l->decl, 0, ", ");
           }
         if (mtflag)
           {
             ptype (proc->res_prefix, proc->res_type, 1);
             fprintf (fout, "*%s, ", result);
           }
         fprintf (fout, " %s%s)\n", addargtype, addargname);
       }
    }

  if (!Cflag)
    fprintf (fout, "\t%s%s;\n", addargtype, addargname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pxdrfuncdecl ( const char *  name,
int  pointerp 
)
void reinitialize ( void  )

Definition at line 75 of file rpc_util.c.

Here is the caller graph for this function:

int streq ( const char *  a,
const char *  b 
)

Definition at line 87 of file rpc_util.c.

{
  return strcmp (a, b) == 0;
}

Here is the caller graph for this function:

void tabify ( FILE f,
int  tab 
)

Definition at line 352 of file rpc_util.c.

{
  while (tab--)
    {
      (void) fputc ('\t', f);
    }
}

Here is the caller graph for this function:

void write_msg_out ( void  )

Definition at line 775 of file rpc_svcout.c.

{
  f_print (fout, "\n");
  f_print (fout, "static\n");
  if (!Cflag)
    {
      f_print (fout, "void _msgout (msg)\n");
      f_print (fout, "\tchar *msg;\n");
    }
  else
    {
      f_print (fout, "void _msgout (char* msg)\n");
    }
  f_print (fout, "{\n");
  f_print (fout, "#ifdef RPC_SVC_FG\n");
  if (inetdflag || pmflag)
    f_print (fout, "\tif (_rpcpmstart)\n");
  f_print (fout, "\t\tsyslog (LOG_ERR, \"%%s\", msg);\n");
  f_print (fout, "\telse\n");
  f_print (fout, "\t\tfprintf (stderr, \"%%s\\n\", msg);\n");
  f_print (fout, "#else\n");
  f_print (fout, "\tsyslog (LOG_ERR, \"%%s\", msg);\n");
  f_print (fout, "#endif\n");
  f_print (fout, "}\n");
}

Here is the caller graph for this function:

int write_sample_clnt ( definition *  def)

Definition at line 64 of file rpc_sample.c.

{
  version_list *vp;
  int count = 0;

  if (def->def_kind != DEF_PROGRAM)
    return 0;
  /* generate sample code for each version */
  for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
    {
      write_sample_client (def->def_name, vp);
      ++count;
    }
  return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void write_sample_clnt_main ( void  )

Definition at line 305 of file rpc_sample.c.

{
  list *l;
  definition *def;
  version_list *vp;

  f_print (fout, "\n\n");
  if (Cflag)
    f_print (fout, "int\nmain (int argc, char *argv[])\n{\n");
  else
    f_print (fout, "int\nmain (argc, argv)\nint argc;\nchar *argv[];\n{\n");

  f_print (fout, "\tchar *host;");
  f_print (fout, "\n\n\tif (argc < 2) {");
  f_print (fout, "\n\t\tprintf (\"usage: %%s server_host\\n\", argv[0]);\n");
  f_print (fout, "\t\texit (1);\n\t}");
  f_print (fout, "\n\thost = argv[1];\n");

  for (l = defined; l != NULL; l = l->next)
    {
      def = l->val;
      if (def->def_kind != DEF_PROGRAM)
       {
         continue;
       }
      for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
       {
         f_print (fout, "\t");
         pvname (def->def_name, vp->vers_num);
         f_print (fout, " (host);\n");
       }
    }
  f_print (fout, "exit (0);\n}\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void write_sample_svc ( definition *  def)

Definition at line 54 of file rpc_sample.c.

{

  if (def->def_kind != DEF_PROGRAM)
    return;
  write_sample_server (def);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void write_stubs ( void  )

Definition at line 56 of file rpc_clntout.c.

{
  list *l;
  definition *def;

  fprintf (fout,
          "\n/* Default timeout can be changed using clnt_control() */\n");
  fprintf (fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
          DEFAULT_TIMEOUT);
  for (l = defined; l != NULL; l = l->next)
    {
      def = (definition *) l->val;
      if (def->def_kind == DEF_PROGRAM)
       {
         write_program (def);
       }
    }
}

Here is the caller graph for this function:

void write_svc_aux ( int  nomain)

Definition at line 762 of file rpc_svcout.c.

{
  if (!logflag)
    write_msg_out ();
  if (!nomain)
    write_timeout_func ();
}

Here is the caller graph for this function:

void write_tables ( void  )

Definition at line 64 of file rpc_tblout.c.

{
  list *l;
  definition *def;

  f_print (fout, "\n");
  for (l = defined; l != NULL; l = l->next)
    {
      def = (definition *) l->val;
      if (def->def_kind == DEF_PROGRAM)
       {
         write_table (def);
       }
    }
}

Here is the caller graph for this function: