home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / bison / bison1~1.zoo / vmsgetargs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-25  |  2.9 KB  |  130 lines

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