VMSGETAR.C 3.8 KB

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