VMSGETAR.C 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 1, 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. getargs(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {
  30. register char *cp;
  31. static char Input_File[256];
  32. static char output_spec[256];
  33. extern char *infile;
  34. verboseflag = 0;
  35. definesflag = 0;
  36. debugflag = 0;
  37. fixed_outfiles = 0;
  38. nolinesflag = 0;
  39. /*
  40. * Check for /VERBOSE qualifier
  41. */
  42. if (cli_present("BISON$VERBOSE")) verboseflag = 1;
  43. /*
  44. * Check for /DEFINES qualifier
  45. */
  46. if (cli_present("BISON$DEFINES")) definesflag = 1;
  47. /*
  48. * Check for /FIXED_OUTFILES qualifier
  49. */
  50. if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1;
  51. /*
  52. * Check for /NOLINES qualifier
  53. */
  54. if (cli_present("BISON$NOLINES")) nolinesflag = 1;
  55. /*
  56. * Check for /DEBUG qualifier
  57. */
  58. if (cli_present("BISON$DEBUG")) debugflag = 1;
  59. /*
  60. * Get the filename
  61. */
  62. cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File));
  63. /*
  64. * Lowercaseify the input filename
  65. */
  66. cp = Input_File;
  67. while(*cp)
  68. {
  69. if (isupper(*cp)) *cp = tolower(*cp);
  70. cp++;
  71. }
  72. infile = Input_File;
  73. /*
  74. * Get the output file
  75. */
  76. if (cli_present("BISON$OUTPUT"))
  77. {
  78. cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec));
  79. for (cp = spec_outfile = output_spec; *cp; cp++)
  80. if (isupper(*cp))
  81. *cp = tolower(*cp);
  82. }
  83. }
  84. /************ DCL PARSING ROUTINES **********/
  85. /*
  86. * See if "NAME" is present
  87. */
  88. int
  89. cli_present(Name)
  90. char *Name;
  91. {
  92. struct {int Size; char *Ptr;} Descr;
  93. Descr.Ptr = Name;
  94. Descr.Size = strlen(Name);
  95. return((cli$present(&Descr) & 1) ? 1 : 0);
  96. }
  97. /*
  98. * Get value of "NAME"
  99. */
  100. int
  101. cli_get_value(Name,Buffer,Size)
  102. char *Name;
  103. char *Buffer;
  104. {
  105. struct {int Size; char *Ptr;} Descr1,Descr2;
  106. Descr1.Ptr = Name;
  107. Descr1.Size = strlen(Name);
  108. Descr2.Ptr = Buffer;
  109. Descr2.Size = Size-1;
  110. if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) {
  111. Buffer[Descr2.Size] = 0;
  112. return(1);
  113. }
  114. return(0);
  115. }