home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / GLEN / IS.ZIP / IS.C < prev    next >
C/C++ Source or Header  |  1988-10-26  |  2KB  |  78 lines

  1. /*
  2. BYTE_MAGIC SOFTWARE                IS - Batch File Utility
  3. 9850 Meadowglen Lane #35
  4. Houston, Tx.   77042
  5. (713) 975-9033
  6.  
  7. Author:    Greg Messer
  8. Date:      10-26-88
  9. System:    Compiled with the Microsoft Optimizing C Compiler v5.00
  10.            under MS-DOS v3.10 for IBM-PCs and compatibles.
  11. Prep:      make is.mak
  12.  
  13. Purpose:   Provide conditional abilities within batch files
  14. Syntax:    is function1 condition function2
  15. Returns:   ERRORLEVEL 0 if expression is true, 1 if false
  16. Comments:  
  17. */
  18.  
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include "is.h"
  23.  
  24. int main(unsigned int argc, char *argv[], char *envp[])
  25. {
  26.    extern int is_fun(char *, char * *, char *);
  27.    extern int is_cond(char *, char *);
  28.    extern int is_comp(char *, char *, char *);
  29.    extern int is_error(char *, char *, int);
  30.  
  31.    char ret_str1[129], ret_str2[129], cond[4];
  32.    int ret;
  33.    char drive[3], dir[40], ext[4];
  34.    char pgm[9];
  35.  
  36.    /* get program name for error messages  */
  37.    if(_osmajor < 3)
  38.        strcpy(pgm, "IS\0");
  39.    else
  40.        _splitpath(argv[0], drive, dir, pgm, ext);
  41.  
  42.    /* 
  43.    ** if not enough arguments, print usage message and exit
  44.    ** otherwise process each function, validate condition, 
  45.    ** do the comparison and return errorlevel to DOS
  46.    */
  47.  
  48.    if(argc < 3)
  49.    {
  50.        printf("\nUsage:  %s function1 condition function2\n", pgm);
  51.        ret = 10;                               /* bad number of args = 10  */
  52.    }
  53.    else
  54.    {
  55.        ret = is_fun(argv[1], envp, ret_str1);      /* return first string  */
  56.        if(ret == OK)
  57.        {
  58.            ret = is_fun(argv[3], envp, ret_str2);  /* return second string */
  59.            if(ret == OK)
  60.            {
  61.                ret = is_cond(argv[2], cond);       /* validate condition   */
  62.                if(ret == OK)
  63.                {
  64.                    ret = is_comp(ret_str1, cond, ret_str2);    /* compare  */
  65.                }
  66.                else
  67.                    ret = is_error(pgm, argv[2], 13);   /* bad cond. = 13   */
  68.            }
  69.            else
  70.                ret = is_error(pgm, argv[3], 12);   /* bad 2nd fun. = 12    */
  71.        }
  72.        else
  73.            ret = is_error(pgm, argv[1], 11);       /* bad 1st fun. = 11    */
  74.    }
  75.    exit(ret);                                      /* exit with ERRORLEVEL */
  76. }
  77.  
  78.