vmsgetargs.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* VMS version of getargs; Uses DCL command parsing.
  2. Copyright (C) 1989, 1992 Free Software Foundation, Inc.
  3. Modified (1992) from bison-1.19 by
  4. Wilfred J. Hansen (wjh+@cmu.edu)
  5. Andrew Consortium, Carnegie Mellon University
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  17. #include <ctype.h>
  18. #include <stdio.h>
  19. #include "files.h"
  20. /*
  21. * VMS version of getargs(): Uses DCL command parsing
  22. * (argc and argv are ignored)
  23. */
  24. int verboseflag;
  25. int definesflag;
  26. int debugflag;
  27. int nolinesflag;
  28. extern int noparserflag;
  29. extern int toknumflag;
  30. extern int rawtoknumflag;
  31. extern int fixed_outfiles;
  32. extern char * version_string;
  33. /* Allocate storgate and initialize, since bison uses them elsewhere. */
  34. char *spec_name_prefix;
  35. char *spec_file_prefix;
  36. getargs(argc,argv)
  37. int argc;
  38. char *argv[];
  39. {
  40. register char *cp;
  41. static char Input_File[256];
  42. static char output_spec[256], name_prefix_spec[256], file_prefix_spec[256];
  43. extern char *infile;
  44. verboseflag = 0;
  45. definesflag = 0;
  46. debugflag = 0;
  47. fixed_outfiles = 0;
  48. nolinesflag = 0;
  49. noparserflag = 0;
  50. toknumflag = 0;
  51. rawtoknumflag = 0;
  52. /*
  53. * Check for /VERBOSE qualifier
  54. */
  55. if (cli_present("BISON$VERBOSE")) verboseflag = 1;
  56. /*
  57. * Check for /DEFINES qualifier
  58. */
  59. if (cli_present("BISON$DEFINES")) definesflag = 1;
  60. /*
  61. * Check for /FIXED_OUTFILES qualifier
  62. */
  63. if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1;
  64. if (cli_present("BISON$YACC")) fixed_outfiles = 1;
  65. /*
  66. * Check for /VERSION qualifier
  67. */
  68. if (cli_present("BISON$VERSION")) printf("%s",version_string);
  69. /*
  70. * Check for /NOLINES qualifier
  71. */
  72. if (cli_present("BISON$NOLINES")) nolinesflag = 1;
  73. /*
  74. * Check for /NOPARSER qualifier
  75. */
  76. if (cli_present("BISON$NOPARSER")) noparserflag = 1;
  77. /*
  78. * Check for /RAW qualifier
  79. */
  80. if (cli_present("BISON$RAW")) rawtoknumflag = 1;
  81. /*
  82. * Check for /TOKEN_TABLE qualifier
  83. */
  84. if (cli_present("BISON$TOKEN_TABLE")) toknumflag = 1;
  85. /*
  86. * Check for /DEBUG qualifier
  87. */
  88. if (cli_present("BISON$DEBUG")) debugflag = 1;
  89. /*
  90. * Get the filename
  91. */
  92. cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File));
  93. /*
  94. * Lowercaseify the input filename
  95. */
  96. cp = Input_File;
  97. while(*cp)
  98. {
  99. if (isupper(*cp)) *cp = tolower(*cp);
  100. cp++;
  101. }
  102. infile = Input_File;
  103. /*
  104. * Get the output file
  105. */
  106. if (cli_present("BISON$OUTPUT"))
  107. {
  108. cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec));
  109. for (cp = spec_outfile = output_spec; *cp; cp++)
  110. if (isupper(*cp))
  111. *cp = tolower(*cp);
  112. }
  113. /*
  114. * Get the output file
  115. */
  116. if (cli_present("BISON$FILE_PREFIX"))
  117. {
  118. cli_get_value("BISON$FILE_PREFIX", file_prefix_spec,
  119. sizeof(file_prefix_spec));
  120. for (cp = spec_file_prefix = file_prefix_spec; *cp; cp++)
  121. if (isupper(*cp))
  122. *cp = tolower(*cp);
  123. }
  124. /*
  125. * Get the output file
  126. */
  127. if (cli_present("BISON$NAME_PREFIX"))
  128. {
  129. cli_get_value("BISON$NAME_PREFIX", name_prefix_spec,
  130. sizeof(name_prefix_spec));
  131. for (cp = spec_name_prefix = name_prefix_spec; *cp; cp++)
  132. if (isupper(*cp))
  133. *cp = tolower(*cp);
  134. }
  135. }
  136. /************ DCL PARSING ROUTINES **********/
  137. /*
  138. * See if "NAME" is present
  139. */
  140. int
  141. cli_present(Name)
  142. char *Name;
  143. {
  144. struct {int Size; char *Ptr;} Descr;
  145. Descr.Ptr = Name;
  146. Descr.Size = strlen(Name);
  147. return((cli$present(&Descr) & 1) ? 1 : 0);
  148. }
  149. /*
  150. * Get value of "NAME"
  151. */
  152. int
  153. cli_get_value(Name,Buffer,Size)
  154. char *Name;
  155. char *Buffer;
  156. {
  157. struct {int Size; char *Ptr;} Descr1,Descr2;
  158. Descr1.Ptr = Name;
  159. Descr1.Size = strlen(Name);
  160. Descr2.Ptr = Buffer;
  161. Descr2.Size = Size-1;
  162. if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) {
  163. Buffer[Descr2.Size] = 0;
  164. return(1);
  165. }
  166. return(0);
  167. }