Print this page
rpcgen should only produce ANSI code

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/rpcgen/rpc_sample.c
          +++ new/usr/src/cmd/rpcgen/rpc_sample.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
       23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
       24 + *
  23   25   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   26   * Use is subject to license terms.
  25   27   */
  26   28  /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27   29  /* All Rights Reserved */
  28   30  /*
  29   31   * University Copyright- Copyright (c) 1982, 1986, 1988
  30   32   * The Regents of the University of California
  31   33   * All Rights Reserved
  32   34   *
↓ open down ↓ 47 lines elided ↑ open up ↑
  80   82  
  81   83  static void
  82   84  write_sample_client(char *program_name, version_list *vp)
  83   85  {
  84   86          proc_list *proc;
  85   87          int i;
  86   88          decl_list *l;
  87   89  
  88   90          f_print(fout, "\n\nvoid\n");
  89   91          pvname(program_name, vp->vers_num);
  90      -        if (Cflag)
  91      -                f_print(fout, "(char *host)\n{\n");
  92      -        else
  93      -                f_print(fout, "(host)\n\tchar *host;\n{\n");
       92 +        f_print(fout, "(char *host)\n{\n");
  94   93          f_print(fout, "\tCLIENT *clnt;\n");
  95   94  
  96   95          i = 0;
  97   96          for (proc = vp->procs; proc != NULL; proc = proc->next) {
  98   97                  f_print(fout, "\t");
  99   98                  if (mtflag) {
 100   99                          f_print(fout, "enum clnt_stat retval_%d;\n", ++i);
 101  100                          if (!streq(proc->res_type, "oneway")) {
 102  101                                  f_print(fout, "\t");
 103  102                                  if (!streq(proc->res_type, "void"))
↓ open down ↓ 111 lines elided ↑ open up ↑
 215  214  
 216  215          for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
 217  216                  for (proc = vp->procs; proc != NULL; proc = proc->next) {
 218  217                          f_print(fout, "\n");
 219  218                          if (!mtflag) {
 220  219                                  return_type(proc);
 221  220                                  f_print(fout, "*\n");
 222  221                          } else {
 223  222                                  f_print(fout, "bool_t\n");
 224  223                          }
 225      -                        if (Cflag || mtflag)
 226      -                                pvname_svc(proc->proc_name, vp->vers_num);
 227      -                        else
 228      -                                pvname(proc->proc_name, vp->vers_num);
      224 +                        pvname_svc(proc->proc_name, vp->vers_num);
 229  225                          printarglist(proc, "result", RQSTP, "struct svc_req *");
 230  226  
 231  227                          f_print(fout, "{\n");
 232  228  
 233  229                          if (!mtflag) {
 234  230                                  f_print(fout, "\tstatic ");
 235  231                                  if ((!streq(proc->res_type, "void")) &&
 236  232                                      (!streq(proc->res_type, "oneway")))
 237  233                                          return_type(proc);
 238  234                                  else
↓ open down ↓ 12 lines elided ↑ open up ↑
 251  247                                  else /* cast back to void * */
 252  248                                          f_print(fout, "\treturn((void *) "
 253  249                                              "&result);\n}\n");
 254  250                          else
 255  251                                  f_print(fout, "\treturn (retval);\n}\n");
 256  252                  }
 257  253                  /* put in sample freeing routine */
 258  254                  if (mtflag) {
 259  255                          f_print(fout, "\nint\n");
 260  256                          pvname(def->def_name, vp->vers_num);
 261      -                        if (Cflag)
 262      -                                f_print(fout, "_freeresult(SVCXPRT *transp,"
 263      -                                    " xdrproc_t xdr_result,"
 264      -                                    " caddr_t result)\n");
 265      -                        else {
 266      -                                f_print(fout, "_freeresult(transp, xdr_result,"
 267      -                                    " result)\n");
 268      -                                f_print(fout, "\tSVCXPRT *transp;\n");
 269      -                                f_print(fout, "\txdrproc_t xdr_result;\n");
 270      -                                f_print(fout, "\tcaddr_t result;\n");
 271      -                        }
      257 +                        f_print(fout, "_freeresult(SVCXPRT *transp,"
      258 +                            " xdrproc_t xdr_result,"
      259 +                            " caddr_t result)\n");
 272  260                          f_print(fout, "{\n"
 273  261                              "\t(void) xdr_free(xdr_result, result);\n"
 274  262                              "\n\t/*\n\t * Insert additional freeing"
 275  263                              " code here, if needed\n\t */\n"
 276  264                              "\n\n\treturn (TRUE);\n}\n");
 277  265                  }
 278  266          }
 279  267  }
 280  268  
 281  269  static void
↓ open down ↓ 13 lines elided ↑ open up ↑
 295  283  }
 296  284  
 297  285  void
 298  286  write_sample_clnt_main(void)
 299  287  {
 300  288          list *l;
 301  289          definition *def;
 302  290          version_list *vp;
 303  291  
 304  292          f_print(fout, "\n\n");
 305      -        if (Cflag)
 306      -                f_print(fout, "int\nmain(int argc, char *argv[])\n{\n");
 307      -        else
 308      -                f_print(fout, "int\nmain(argc, argv)\n\tint argc;\n"
 309      -                    "\tchar *argv[];\n{\n");
      293 +        f_print(fout, "int\nmain(int argc, char *argv[])\n{\n");
 310  294  
 311  295          f_print(fout, "\tchar *host;");
 312  296          f_print(fout, "\n\n\tif (argc < 2) {");
 313  297          f_print(fout, "\n\t\tprintf(\"usage:  %%s server_host\\n\","
 314  298              " argv[0]);\n");
 315  299          f_print(fout, "\t\texit(1);\n\t}");
 316  300          f_print(fout, "\n\thost = argv[1];\n");
 317  301  
 318  302          for (l = defined; l != NULL; l = l->next) {
 319  303                  def = l->val;
 320  304                  if (def->def_kind != DEF_PROGRAM)
 321  305                          continue;
 322  306                  for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
 323  307                          f_print(fout, "\t");
 324  308                          pvname(def->def_name, vp->vers_num);
 325  309                          f_print(fout, "(host);\n");
 326  310                  }
 327  311          }
 328  312          f_print(fout, "}\n");
 329  313  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX