home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / checkenv.lzh / checkenv.c < prev    next >
C/C++ Source or Header  |  1992-02-22  |  1KB  |  49 lines

  1. #include <stdio.h>
  2. #include <sgstat.h>
  3. #include <termcap.h>
  4. /*
  5. This program allows the user to check the environment list, to
  6. check if a given variable has a particular setting
  7. The most common use would be in a .login file to set up the 
  8. correct TERM variable; thus:
  9.           -nx
  10.           checkenv PORT /term ; setenv TERM st
  11.           checkenv PORT /t1   ; setenv TERM dr
  12.           -x
  13.  
  14. This program is copyright (1988) by Cowen Software Ltd
  15. of 21/23 Bristol Ave, Manchester, England, GB-M19 3NU
  16. It is made available for any OS9/68K user freely,
  17. but may not be sold for profit, other than a reasonable 
  18. handling charge
  19. */
  20. main (argc,argv)
  21. int argc;
  22. char *argv[];
  23. {
  24.  char *ep;
  25.  if ( (argc < 2) | (argc > 3) ) help ();
  26.  if (*argv[1] == '-') help ();
  27.  
  28.  ep = getenv( argv[1]);
  29.  
  30.  if ( ep == NULL )
  31.    { if ( argc == 2 ) _exit(0); else _exit(1); }
  32.  
  33.  if ( argc == 2 ) _exit(1);
  34.  
  35.  if ( strcmp(argv[2], getenv( argv[1]) ) ) _exit(1);
  36.      
  37.  _exit(0);
  38. }
  39.  
  40. help()
  41.     { fprintf (stderr,"\nSyntax: checkenv <eparam> , <evalue>");
  42.       fprintf (stderr,"\nFunction: check environment variable value");
  43.       fprintf (stderr,"\n  errors if <evalue> not = SETENV value");
  44.       fprintf (stderr,"\n  if <evalue> null, checks <eparam> does not exist");
  45.       _exit(0);
  46.     }
  47.  
  48.  
  49.