Print this page
rpcgen should only produce ANSI code

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/rpcgen/rpc_main.c
          +++ new/usr/src/cmd/rpcgen/rpc_main.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 ↓ 96 lines elided ↑ open up ↑
 129  131  int inlinelen = INLINE;
 130  132  /*
 131  133   * Length at which to start doing an inline. INLINE = default
 132  134   * if 0, no xdr_inline code
 133  135   */
 134  136  
 135  137  int indefinitewait;     /* If started by port monitors, hang till it wants */
 136  138  int exitnow;            /* If started by port monitors, exit after the call */
 137  139  int timerflag;          /* TRUE if !indefinite && !exitnow */
 138  140  int newstyle;           /* newstyle of passing arguments (by value) */
 139      -int Cflag = 0;          /* ANSI C syntax */
 140  141  int CCflag = 0;         /* C++ files */
 141  142  static int allfiles;   /* generate all files */
 142  143  int tirpcflag = 1;    /* generating code for tirpc, by default */
 143  144  xdrfunc *xdrfunc_head = NULL; /* xdr function list */
 144  145  xdrfunc *xdrfunc_tail = NULL; /* xdr function list */
 145  146  pid_t childpid;
 146  147  
 147  148  
 148  149  int
 149  150  main(int argc, char *argv[])
↓ open down ↓ 358 lines elided ↑ open up ↑
 508  509  
 509  510  static void
 510  511  h_output(char *infile, char *define, int extend, char *outfile)
 511  512  {
 512  513          definition *def;
 513  514          char *outfilename;
 514  515          long tell;
 515  516          char *guard;
 516  517          list *l;
 517  518          xdrfunc *xdrfuncp;
 518      -        int i;
 519  519  
 520  520          open_input(infile, define);
 521  521          outfilename =  extend ? extendfile(infile, outfile) : outfile;
 522  522          open_output(infile, outfilename);
 523  523          add_warning();
 524  524          if (outfilename || infile)
 525  525                  guard = generate_guard(outfilename ? outfilename: infile);
 526  526          else
 527  527                  guard = "STDIN_";
 528  528  
↓ open down ↓ 2 lines elided ↑ open up ↑
 531  531          f_print(fout, "#include <rpc/rpc.h>\n");
 532  532  
 533  533          if (mtflag) {
 534  534                  f_print(fout, "#ifndef _KERNEL\n");
 535  535                  f_print(fout, "#include <synch.h>\n");
 536  536                  f_print(fout, "#include <thread.h>\n");
 537  537                  f_print(fout, "#endif /* !_KERNEL */\n");
 538  538          };
 539  539  
 540  540          /* put the C++ support */
 541      -        if (Cflag && !CCflag) {
      541 +        if (!CCflag) {
 542  542                  f_print(fout, "\n#ifdef __cplusplus\n");
 543  543                  f_print(fout, "extern \"C\" {\n");
 544  544                  f_print(fout, "#endif\n\n");
 545  545          }
 546  546  
 547      -        /* put in a typedef for quadprecision. Only with Cflag */
      547 +        /* put in a typedef for quadprecision. */
 548  548  
 549  549          /*
 550  550           * declaration of struct rpcgen_table must go before
 551  551           *  the definition of arrays like *_1_table[]
 552  552           */
 553  553          if (tblflag) {
 554  554                  f_print(fout, rpcgen_table_dcl1);
 555  555                  if (tirpcflag)
 556  556                          f_print(fout, rpcgen_table_proc);
 557  557                  else
↓ open down ↓ 17 lines elided ↑ open up ↑
 575  575          /* Now  print all xdr func declarations */
 576  576          if (xdrfunc_head != NULL) {
 577  577                  f_print(fout, "\n/* the xdr functions */\n");
 578  578  
 579  579                  if (CCflag) {
 580  580                          f_print(fout, "\n#ifdef __cplusplus\n");
 581  581                          f_print(fout, "extern \"C\" {\n");
 582  582                          f_print(fout, "#endif\n");
 583  583                  }
 584  584  
 585      -                if (!Cflag) {
 586      -                        xdrfuncp = xdrfunc_head;
 587      -                        while (xdrfuncp != NULL) {
 588      -                                print_xdr_func_def(xdrfuncp->name,
 589      -                                    xdrfuncp->pointerp, 2);
 590      -                                xdrfuncp = xdrfuncp->next;
 591      -                        }
 592      -                } else {
 593      -                        for (i = 1; i < 3; i++) {
 594      -                                if (i == 1)
 595      -                                        f_print(fout,
 596      -"\n#if defined(__STDC__) || defined(__cplusplus)\n");
 597      -                                else
 598      -                                        f_print(fout, "\n#else /* K&R C */\n");
      585 +                f_print(fout, "\n");
 599  586  
 600      -                                xdrfuncp = xdrfunc_head;
 601      -                                while (xdrfuncp != NULL) {
 602      -                                        print_xdr_func_def(xdrfuncp->name,
 603      -                                            xdrfuncp->pointerp, i);
 604      -                                        xdrfuncp = xdrfuncp->next;
 605      -                                }
 606      -                        }
 607      -                        f_print(fout, "\n#endif /* K&R C */\n");
      587 +                xdrfuncp = xdrfunc_head;
      588 +                while (xdrfuncp != NULL) {
      589 +                        print_xdr_func_def(xdrfuncp->name, xdrfuncp->pointerp);
      590 +                        xdrfuncp = xdrfuncp->next;
 608  591                  }
      592 +                f_print(fout, "\n");
 609  593          }
 610  594  
 611  595          if (extend && tell == ftell(fout)) {
 612  596                  (void) unlink(outfilename);
 613  597          }
 614  598  
 615      -        if (Cflag) {
 616      -                f_print(fout, "\n#ifdef __cplusplus\n");
 617      -                f_print(fout, "}\n");
 618      -                f_print(fout, "#endif\n");
 619      -        }
      599 +        f_print(fout, "\n#ifdef __cplusplus\n");
      600 +        f_print(fout, "}\n");
      601 +        f_print(fout, "#endif\n");
 620  602  
 621  603          f_print(fout, "\n#endif /* !_%s */\n", guard);
 622  604  }
 623  605  
 624  606  /*
 625  607   * Compile into an RPC service
 626  608   */
 627  609  static void
 628  610  s_output(int argc, char *argv[], char *infile, char *define, int extend,
 629  611                                          char *outfile, int nomain, int netflag)
↓ open down ↓ 10 lines elided ↑ open up ↑
 640  622          if (infile && (include = extendfile(infile, ".h"))) {
 641  623                  f_print(fout, "#include \"%s\"\n", include);
 642  624                  free(include);
 643  625          } else
 644  626                  f_print(fout, "#include <rpc/rpc.h>\n");
 645  627  
 646  628          f_print(fout, "#include <stdio.h>\n");
 647  629          f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
 648  630          f_print(fout, "#include <signal.h>\n");
 649  631  
 650      -        if (Cflag) {
 651      -                f_print(fout,
 652      -                "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
 653      -                f_print(fout, "#include <string.h> /* strcmp */\n");
 654      -        }
      632 +        f_print(fout,
      633 +        "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
      634 +        f_print(fout, "#include <string.h> /* strcmp */\n");
      635 +
 655  636          if (strcmp(svcclosetime, "-1") == 0)
 656  637                  indefinitewait = 1;
 657  638          else if (strcmp(svcclosetime, "0") == 0)
 658  639                  exitnow = 1;
 659  640          else if (inetdflag || pmflag)
 660  641                  timerflag = 1;
 661  642  
 662  643          if (!tirpcflag && inetdflag)
 663  644                  f_print(fout, "#include <sys/termios.h> /* TIOCNOTTY */\n");
 664      -        if (Cflag && (inetdflag || pmflag))
      645 +        if (inetdflag || pmflag)
 665  646                  if (tirpcflag)
 666  647                          f_print(fout, "#include <unistd.h> /* setsid */\n");
 667  648          if (tirpcflag)
 668  649                  f_print(fout, "#include <sys/types.h>\n");
 669  650  
 670      -        f_print(fout, "#include <memory.h>\n");
 671  651          f_print(fout, "#include <stropts.h>\n");
 672  652          if (inetdflag || !tirpcflag) {
 673  653                  f_print(fout, "#include <sys/socket.h>\n");
 674  654                  f_print(fout, "#include <netinet/in.h>\n");
 675  655                  f_print(fout, "#include <rpc/svc_soc.h>\n");
 676  656          }
 677  657  
 678  658          if ((netflag || pmflag) && tirpcflag && !nomain)
 679  659                  f_print(fout, "#include <netconfig.h>\n");
 680  660          if (tirpcflag)
 681  661                  f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
 682  662          if (logflag || inetdflag || pmflag)
 683  663                  f_print(fout, "#include <syslog.h>\n");
 684  664  
 685  665          /* for ANSI-C */
 686      -        if (Cflag)
 687      -                f_print(fout,
 688      -                    "\n#ifndef SIG_PF\n#define  SIG_PF void(*)\
 689      -(int)\n#endif\n");
      666 +        f_print(fout, "\n#ifndef SIG_PF\n"
      667 +            "#define    SIG_PF void(*)(int)\n#endif\n");
 690  668  
 691  669          f_print(fout, "\n#ifdef DEBUG\n#define  RPC_SVC_FG\n#endif\n");
 692  670          if (timerflag)
 693  671                  f_print(fout, "\n#define        _RPCSVC_CLOSEDOWN %s\n",
 694  672                      svcclosetime);
 695  673          while (def = get_definition())
 696  674                  foundprogram |= (def->def_kind == DEF_PROGRAM);
 697  675          if (extend && !foundprogram) {
 698  676                  (void) unlink(outfilename);
 699  677                  return;
↓ open down ↓ 17 lines elided ↑ open up ↑
 717  695  {
 718  696          char *include;
 719  697          definition *def;
 720  698          int foundprogram = 0;
 721  699          char *outfilename;
 722  700  
 723  701          open_input(infile, define);
 724  702          outfilename = extend ? extendfile(infile, outfile) : outfile;
 725  703          open_output(infile, outfilename);
 726  704          add_warning();
 727      -        if (Cflag)
 728      -                f_print(fout, "#include <memory.h> /* for memset */\n");
      705 +        f_print(fout, "#include <memory.h> /* for memset */\n");
 729  706          if (infile && (include = extendfile(infile, ".h"))) {
 730  707                  f_print(fout, "#include \"%s\"\n", include);
 731  708                  free(include);
 732  709          } else
 733  710                  f_print(fout, "#include <rpc/rpc.h>\n");
 734  711  
 735  712          f_print(fout, "#ifndef _KERNEL\n");
 736  713          f_print(fout, "#include <stdio.h>\n");
 737  714          f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
 738  715          f_print(fout, "#endif /* !_KERNEL */\n");
↓ open down ↓ 356 lines elided ↑ open up ↑
1095 1072                                                  ch = 'C';
1096 1073                                          else if (ch == 'm')
1097 1074                                                  ch = 'M';
1098 1075                                          else
1099 1076                                                  return (0);
1100 1077  
1101 1078                                          if (flag[ch])
1102 1079                                                  return (0);
1103 1080                                          flag[ch] = 1;
1104 1081                                          break;
1105      -                                case 'C': /* ANSI C syntax */
1106      -                                        Cflag = 1;
     1082 +                                case 'C': /* ANSI C syntax (default) */
1107 1083                                          ch = argv[i][j+1]; /* get next char */
1108 1084  
1109 1085                                          if (ch != 'C')
1110 1086                                                  break;
     1087 +                                        /* Undocumented C++ mode */
1111 1088                                          CCflag = 1;
1112 1089                                          break;
1113 1090                                  case 'b':
1114 1091                                          /*
1115 1092                                           *  Turn TIRPC flag off for
1116 1093                                           *  generating backward compatible
1117 1094                                           *  code
1118 1095                                           */
1119 1096                                          tirpcflag = 0;
1120 1097                                          break;
↓ open down ↓ 192 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX