home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the DOOM Programming Gurus / Tricks_of_the_Doom_Programming_Gurus.iso / bonus / utils / doomchk / source / dmcheck.cpp next >
Encoding:
C/C++ Source or Header  |  1995-03-19  |  75.3 KB  |  1,698 lines

  1. #include "\apps\bc\doom\dmcheck.hpp"
  2. FILE *stream;
  3. unsigned a_date,a_time;
  4. struct text_info cur_mode;
  5. int err_code = 0;
  6. int quiet = FALSE;
  7. int list_ver = FALSE;
  8. int get_help = FALSE;
  9. int debug_on = FALSE;
  10. int min_switch = FALSE;
  11. int move_up = FALSE;
  12. int do_bells = TRUE;
  13. int i,j,k,l;
  14. long wadsize,exesize = 0;
  15. long today,creation;
  16. int days_old;
  17. char *waddate,*exedate = "00/00/00";
  18. char *wadtime,*exetime = "00:00:00";
  19. int wadnum,exenum = 0;
  20. int more_than_one = 0;
  21. char c,d,e;
  22. char *p,*q,*s,*t,*u;
  23. int argc;
  24. int hour,minute,second,year,month,day;
  25. char *argpass[20];
  26. struct find_t aDir[5];
  27. struct dfree aFreeSpace;
  28. struct dosdate_t current_date;
  29. long filesize = 0;
  30. char *filedate = "";
  31. char *filetime = "";
  32.  
  33. /*************************************************************************
  34. *** r_error terminates program displays message with returned          ***
  35. *** errorlevel code and exits program to DOS                           ***
  36. *************************************************************************/
  37.  
  38. void r_error()
  39. {
  40.     if (debug_on)
  41.         printf("\nReturning ERRORLEVEL code of %i.",err_code);
  42.     _setcursortype(_NORMALCURSOR);
  43.     if (quiet || min_switch) printf("\n");
  44.     exit(err_code);
  45. }
  46.  
  47.  
  48.  
  49.  
  50. /*************************************************************************
  51. *** error_messsage displays an error and exits.                        ***
  52. *************************************************************************/
  53.  
  54. void error_message(char *str)
  55. {
  56.     err_code = 255;
  57.     s = "this is only a long string to hold the string passed to this function";
  58.     strcpy(s,str);
  59.     str[0] = strlwr(s)[0];
  60.     if (!quiet) printf("\n\n*** ERROR, %s! ***",str);
  61.     if (do_bells) printf("\a");
  62.     r_error();
  63. }
  64.  
  65.  
  66.  
  67. /*************************************************************************
  68. *** prnt_mess displays the initial information lines about DMCHECK.    ***
  69. *************************************************************************/
  70.  
  71. void prnt_mess()
  72. {
  73.     if (!min_switch)
  74.     {
  75.         printf("DMCHECK ver %s %s by Jean-Serge Gagnon <az589@freenet.carleton.ca>",
  76.             VERSION_NUM,VERSION_DATE);
  77.         printf("\nCheck DOOM version, disk space, change/check file date/time & ask question.");
  78.     }
  79.     return;
  80. }
  81.  
  82. /*************************************************************************
  83. *** prnt_usage will inform the user of the usage when type /h alone    ***
  84. *** or no parameters at all.                                           ***
  85. *************************************************************************/
  86.  
  87. void prnt_usage()
  88. {
  89.     printf("\n\nUsage is as follows:\n\n");
  90.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] [[function [parameters]] | /L]\n\n");
  91.     printf("function is Ask, Date, File, Space, Version or Which as below:\n\n");
  92.     printf("DMCHECK [/H] [/D] [/B] [/M] [/U] /L\n");
  93.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] A[sk] [[question] replies]]\n");
  94.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] D[ate] filename [[NOW] | [date time]]\n");
  95.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] F[ile] filename [size [date [time]]]\n");
  96.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] S[pace] [Drive] NeededSpace\n");
  97.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] V[ersion] DOOMversion\n");
  98.     printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] W[hich]");
  99.     return;
  100. }
  101.  
  102.  
  103. /*************************************************************************
  104. *** usage tells user of the usage and exits.                           ***
  105. *************************************************************************/
  106.  
  107. void usage()
  108. {
  109.     min_switch = FALSE;
  110.     if (quiet) prnt_mess();
  111.     prnt_usage();
  112.     printf("\n\nUse \"DMCHECK /H\" for general help.");
  113.     err_code = 0;
  114.     r_error();
  115. }
  116.  
  117.  
  118. /*************************************************************************
  119. *** strcommas retunrs a string with commas in the thousands and        ***
  120. *** millions position of a long integer.                               ***
  121. *************************************************************************/
  122.  
  123. char *strcommas(long value)
  124. {
  125.     s = "123456789123456789";
  126.     s = ltoa(value,s,10);
  127.     i = strlen(s);
  128.     if (i < 4) return s;
  129.     s[i+1] = s[i];
  130.     s[i] = s[i-1];
  131.     s[i-1] = s[i-2];
  132.     s[i-2] = s[i-3];
  133.     s[i-3] = ',';
  134.     if (i < 7) return s;
  135.     s[i+2] = s[i+1];
  136.     s[i+1] = s[i];
  137.     s[i] = s[i-1];
  138.     s[i-1] = s[i-2];
  139.     s[i-2] = s[i-3];
  140.     s[i-3] = s[i-4];
  141.     s[i-4] = s[i-5];
  142.     s[i-5] = s[i-6];
  143.     s[i-6] = ',';
  144.     if (i < 10) return s;
  145.     s[i+3] = s[i+2];
  146.     s[i+2] = s[i+1];
  147.     s[i+1] = s[i];
  148.     s[i] = s[i-1];
  149.     s[i-1] = s[i-2];
  150.     s[i-2] = s[i-3];
  151.     s[i-3] = s[i-4];
  152.     s[i-4] = s[i-5];
  153.     s[i-5] = s[i-6];
  154.     s[i-6] = s[i-7];
  155.     s[i-7] = s[i-8];
  156.     s[i-8] = s[i-9];
  157.     s[i-9] = ',';
  158.     if (i < 13) return s;
  159.     s[i+4] = s[i+3];
  160.     s[i+3] = s[i+2];
  161.     s[i+2] = s[i+1];
  162.     s[i+1] = s[i];
  163.     s[i] = s[i-1];
  164.     s[i-1] = s[i-2];
  165.     s[i-2] = s[i-3];
  166.     s[i-3] = s[i-4];
  167.     s[i-4] = s[i-5];
  168.     s[i-5] = s[i-6];
  169.     s[i-6] = s[i-7];
  170.     s[i-7] = s[i-8];
  171.     s[i-8] = s[i-9];
  172.     s[i+9] = s[i+10];
  173.     s[i+10] = s[i+11];
  174.     s[i+11] = s[i+12];
  175.     s[i+12] = ',';
  176.     return s;
  177. }
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. /*************************************************************************
  186. *** strdosdate returns a string containing a date in format 'MM-DD-YY' ***
  187. *** and requires a dos file stream to get it.                          ***
  188. *************************************************************************/
  189.  
  190. char *strdosdate(unsigned dosdate)
  191. {
  192.     s = "00-00-00";
  193.     sprintf(s,"%#02u-%#02u-%#02u",(_DOSMONTHBITS & dosdate)/32,(_DOSDAYBITS & dosdate),
  194.         (_DOSYEARBITS & dosdate)/512+80);
  195.     return s;
  196. }
  197.  
  198.  
  199. /*************************************************************************
  200. *** strdostime returns a string containing a date in format 'HH:MM:DD' ***
  201. *** and requires a dos file stream to get it.                          ***
  202. *************************************************************************/
  203.  
  204. char *strdostime(unsigned dostime)
  205. {
  206.     s = "00:00:00";
  207.     sprintf(s,"%#02u:%#02u:%#02u",(_DOSHOURBITS & dostime)/2048,
  208.         (_DOSMINUTEBITS & dostime)/32,(_DOSSECONDBITS & dostime)*2);
  209.     return s;
  210. }
  211.  
  212.  
  213.  
  214.  
  215. /*************************************************************************
  216. *** todosdate returns an unsigned integer representing the date based  ***
  217. *** on the DOS format.                                                 ***
  218. *************************************************************************/
  219.  
  220. unsigned todosdate(char *str)
  221. {
  222.     return ((unsigned) (atoi(str+6)-80)*512 + (unsigned) atoi(str)*32 +
  223.         (unsigned) atoi(str+3));
  224. }
  225.  
  226.  
  227.  
  228. /*************************************************************************
  229. *** todostime returns an unsigned integer representing the time based  ***
  230. *** on the DOS format.                                                 ***
  231. *************************************************************************/
  232.  
  233. unsigned todostime(char *str)
  234. {
  235.     return ((unsigned) atoi(str)*2048 + (unsigned) atoi(str+3)*32 +
  236.         (unsigned) atoi(str+6)/2);
  237. }
  238.  
  239.  
  240.  
  241.  
  242.  
  243. /*************************************************************************
  244. *** show_where simply displays where a new version of DMCHECK can be   ***
  245. *** found.                                                             ***
  246. *************************************************************************/
  247.  
  248. void show_where()
  249. {
  250.     if (days_old>120 && !quiet)
  251.     {
  252.         printf("\n\nSince this version of DMCHECK is older than 120 days, you may want to check\n");
  253.         printf("for a more recent version of DMCHECK on the DOOM  utility FTP archive site\n");
  254.         printf("\"ftp.cdrom.com\" (or any  of it's mirrors) or check the  offical\n");
  255.         printf("BBS for DMCHECK; Synapse at (819) 246-2344.");
  256.     }
  257.     return;
  258. }
  259.  
  260.  
  261.  
  262. /*************************************************************************
  263. *** wrong_paramter informs user of a faulty parameter in the           ***
  264. *** invocation of the program and exits.                               ***
  265. *************************************************************************/
  266.  
  267. void wrong_parameter(char *str)
  268. {
  269.     if (quiet) prnt_mess();
  270.     min_switch = FALSE;
  271.     s = "this is only a long string to hold the string passed to this function";
  272.     strcpy(s,str);
  273.     str[0] = strupr(s)[0];
  274.     printf("\n\n*** ERROR *** Invalid Parameter! %s! ",str);
  275.     if (strlen(s) > 23 && !quiet) printf("\n");
  276.     printf("Use /H alone for help!");
  277.     if (do_bells) printf("\a");
  278.     err_code = 255;
  279.     r_error();
  280. }
  281.  
  282.  
  283. /*************************************************************************
  284. *** Ver_listing displays all the DOOM versions data.                   ***
  285. *************************************************************************/
  286.  
  287. void ver_listing()
  288. {
  289.     int i;
  290.     if (quiet)
  291.     {
  292.         prnt_mess();
  293.         wrong_parameter("Don't use /Q with /L");
  294.     }
  295.     if (argpass[1][0] != '\0') wrong_parameter("Use \"/L\" alone");
  296.     printf("\n\n      DOOM                  DOOM.WAD                  DOOM.EXE      returned\n");
  297.     printf("    version          size     date     time     size    date     time     error\n");
  298.     printf(" 1.0 shareware     ");
  299.     printf("%10s %s %s",strcommas(D10SHA_WADSIZE),D10SHA_WADDATE,D10SHA_WADTIME);
  300.     printf("%8s %s %s  1\n",strcommas(D10SHA_EXESIZE),D10SHA_EXEDATE,D10SHA_EXETIME);
  301.     printf(" 1.1 shareware     ");
  302.     printf("%10s %s %s",strcommas(D11SHA_WADSIZE),D11SHA_WADDATE,D11SHA_WADTIME);
  303.     printf("%8s %s %s  2\n",strcommas(D11SHA_EXESIZE),D11SHA_EXEDATE,D11SHA_EXETIME);
  304.     printf(" 1.1 registered    ");
  305.     printf("%10s %s %s",strcommas(D11REG_WADSIZE),D11REG_WADDATE,D11REG_WADTIME);
  306.     printf("%8s %s %s  2\n",strcommas(D11REG_EXESIZE),D11REG_EXEDATE,D11REG_EXETIME);
  307.     printf(" 1.2 shareware     ");
  308.     printf("%10s %s %s",strcommas(D12SHA_WADSIZE),D12SHA_WADDATE,D12SHA_WADTIME);
  309.     printf("%8s %s %s  3\n",strcommas(D12SHA_EXESIZE),D12SHA_EXEDATE,D12SHA_EXETIME);
  310.     printf(" 1.2 registered    ");
  311.     printf("%10s %s %s",strcommas(D12REG_WADSIZE),D12REG_WADDATE,D12REG_WADTIME);
  312.     printf("%8s %s %s  3\n",strcommas(D12REG_EXESIZE),D12REG_EXEDATE,D12REG_EXETIME);
  313.     printf(" 1.2 ZONE          ");
  314.     printf("%10s %s %s",strcommas(DPCZON_WADSIZE),DPCZON_WADDATE,DPCZON_WADTIME);
  315.     printf("%8s %s %s 30\n",strcommas(DPCZON_EXESIZE),DPCZON_EXEDATE,DPCZON_EXETIME);
  316.     printf(" 1.25 Sybex        ");
  317.     printf("%10s %s %s",strcommas(DSYBEX_WADSIZE),DSYBEX_WADDATE,DSYBEX_WADTIME);
  318.     printf("%8s %s %s 31\n",strcommas(DSYBEX_EXESIZE),DSYBEX_EXEDATE,DSYBEX_EXETIME);
  319.     printf(" 1.4 beta shar.    ");
  320.     printf("%10s %s %s",strcommas(D14BET_WADSIZE),D14BET_WADDATE,D14BET_WADTIME);
  321.     printf("%8s %s %s  4\n",strcommas(D14BET_EXESIZE),D14BET_EXEDATE,D14BET_EXETIME);
  322.     printf(" 1.5 beta shar.    ");
  323.     printf("%10s %s %s",strcommas(D15BET_WADSIZE),D15BET_WADDATE,D15BET_WADTIME);
  324.     printf("%8s %s %s  5\n",strcommas(D15BET_EXESIZE),D15BET_EXEDATE,D15BET_EXETIME);
  325.     printf(" 1.6 beta shar.    ");
  326.     printf("%10s %s %s",strcommas(D16BET_WADSIZE),D16BET_WADDATE,D16BET_WADTIME);
  327.     printf("%8s %s %s  6\n",strcommas(D16BET_EXESIZE),D16BET_EXEDATE,D16BET_EXETIME);
  328.     printf(" 1.666 shareware   ");
  329.     printf("%10s %s %s",strcommas(D166SH_WADSIZE),D166SH_WADDATE,D166SH_WADTIME);
  330.     printf("%8s %s %s  7\n",strcommas(D166SH_EXESIZE),D166SH_EXEDATE,D166SH_EXETIME);
  331.     printf(" 1.666 registered  ");
  332.     printf("%10s %s %s",strcommas(D166RE_WADSIZE),D166RE_WADDATE,D166RE_WADTIME);
  333.     printf("%8s %s %s  7\n",strcommas(D166RE_EXESIZE),D166RE_EXEDATE,D166RE_EXETIME);
  334.     printf(" 1.7 shareware     ");
  335.     printf("(Data unavailable for now. Let me know if you have it!)\n");
  336. /*
  337.     printf("%10s %s %s",strcommas(D17SHA_WADSIZE),D17SHA_WADDATE,D17SHA_WADTIME);
  338.     printf("%8s %s %s  8\n",strcommas(D17SHA_EXESIZE),D17SHA_EXEDATE,D17SHA_EXETIME);
  339. */
  340.     printf(" 1.7 registered    ");
  341.     printf("(Data unavailable for now. Let me know if you have it!)\n");
  342. /*
  343.     printf("%10s %s %s",strcommas(D17REG_WADSIZE),D17REG_WADDATE,D17REG_WADTIME);
  344.     printf("%8s %s %s  8\n",strcommas(D17REG_EXESIZE),D17REG_EXEDATE,D17REG_EXETIME);
  345. */
  346.     printf(" 1.7a shareware    ");
  347.     printf("%10s %s %s",strcommas(D17ASH_WADSIZE),D17ASH_WADDATE,D17ASH_WADTIME);
  348.     printf("%8s %s %s  9\n",strcommas(D17ASH_EXESIZE),D17ASH_EXEDATE,D17ASH_EXETIME);
  349.     printf(" 1.7a registered   ");
  350.     printf("%10s %s %s",strcommas(D17ARE_WADSIZE),D17ARE_WADDATE,D17ARE_WADTIME);
  351.     printf("%8s %s %s  9\n",strcommas(D17ARE_EXESIZE),D17ARE_EXEDATE,D17ARE_EXETIME);
  352.     printf(" 1.8 shareware     ");
  353.     printf("%10s %s %s",strcommas(D18SHA_WADSIZE),D18SHA_WADDATE,D18SHA_WADTIME);
  354.     printf("%8s %s %s 10\n",strcommas(D18SHA_EXESIZE),D18SHA_EXEDATE,D18SHA_EXETIME);
  355.     printf(" 1.8 registered    ");
  356.     printf("%10s %s %s",strcommas(D18REG_WADSIZE),D18REG_WADDATE,D18REG_WADTIME);
  357.     printf("%8s %s %s 10\n",strcommas(D18REG_EXESIZE),D18REG_EXEDATE,D18REG_EXETIME);
  358.     if (cur_mode.screenheight < 26)
  359.     {
  360.         printf("(-More-)");
  361.         while (i!=13 && i!='Y' && i!='y' && i!='Q'
  362.             && i!='q' && i!='N' &&i!='n' && i!=' ')
  363.             i = getch();
  364.         printf("\n");
  365.     }
  366.     else
  367.         i = 'Y';
  368.     if (i!='n' && i!='N' && i!='q' && i!='Q')
  369.     {
  370.         printf(" 1.9 shareware     ");
  371.         printf("%10s %s %s",strcommas(D19SHA_WADSIZE),D19SHA_WADDATE,D19SHA_WADTIME);
  372.         printf("%8s %s %s 11\n",strcommas(D19SHA_EXESIZE),D19SHA_EXEDATE,D19SHA_EXETIME);
  373.         printf(" 1.9 registered    ");
  374.         printf("%10s %s %s",strcommas(D19REG_WADSIZE),D19REG_WADDATE,D19REG_WADTIME);
  375.         printf("%8s %s %s 11\n",strcommas(D19REG_EXESIZE),D19REG_EXEDATE,D19REG_EXETIME);
  376.         printf(" ][ pirate copy    ");
  377.         printf("%10s %s %s",strcommas(D2_PIR_WADSIZE),D2_PIR_WADDATE,D2_PIR_WADTIME);
  378.         printf("%8s %s %s 19\n",strcommas(D2_PIR_EXESIZE),D2_PIR_EXEDATE,D2_PIR_EXETIME);
  379.         printf(" ][ v1.666         ");
  380.         printf("%10s %s %s",strcommas(D2_166_WADSIZE),D2_166_WADDATE,D2_166_WADTIME);
  381.         printf("%8s %s %s 20\n",strcommas(D2_166_EXESIZE),D2_166_EXEDATE,D2_166_EXETIME);
  382.         printf(" ][ v1.7           ");
  383.         printf("%10s %s %s",strcommas(D2_17C_WADSIZE),D2_17C_WADDATE,D2_17C_WADTIME);
  384.         printf("%8s %s %s 21\n",strcommas(D2_17C_EXESIZE),D2_17C_EXEDATE,D2_17C_EXETIME);
  385.         printf(" ][ v1.7a          ");
  386.         printf("%10s %s %s",strcommas(D2_17A_WADSIZE),D2_17A_WADDATE,D2_17A_WADTIME);
  387.         printf("%8s %s %s 22\n",strcommas(D2_17A_EXESIZE),D2_17A_EXEDATE,D2_17A_EXETIME);
  388.         printf(" ][ v1.8           ");
  389.         printf("%10s %s %s",strcommas(D2_18C_WADSIZE),D2_18C_WADDATE,D2_18C_WADTIME);
  390.         printf("%8s %s %s 23\n",strcommas(D2_18C_EXESIZE),D2_18C_EXEDATE,D2_18C_EXETIME);
  391.         printf(" ][ v1.9           ");
  392.         printf("%10s %s %s",strcommas(D2_19C_WADSIZE),D2_19C_WADDATE,D2_19C_WADTIME);
  393.         printf("%8s %s %s 24",strcommas(D2_19C_EXESIZE),D2_19C_EXEDATE,D2_19C_EXETIME);
  394.     }
  395.     err_code = 0;
  396.     r_error();
  397. }
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404. /*************************************************************************
  405. *** help_screen displays any help the user wants to see.               ***
  406. *************************************************************************/
  407.  
  408. void help_screen()
  409. {
  410.     i = strlen(argpass[1]);
  411.     err_code = 0;
  412.     if (((quiet || list_ver) && i != 0) || (quiet && list_ver))
  413.         wrong_parameter("Too many parameters");
  414.     if (quiet) prnt_mess();
  415.     if (min_switch)
  416.     {
  417.         min_switch = FALSE;
  418.         prnt_mess();
  419.         min_switch = TRUE;
  420.     }
  421.     argpass[1] = strupr(argpass[1]);
  422.     if (debug_on && i == 0 && !list_ver && !quiet && !move_up && !min_switch
  423.         && do_bells)
  424.     {
  425.         printf("\n\nDMCHECK /D [...]\n\n");
  426.         printf("    Debug switch is used to display certain  information like the ERRORLEVEL\n");
  427.         printf("    code being  returned. It has  no really useful  reason for  being except\n");
  428.         printf("    maybe for me.");
  429.     } else
  430.     {
  431.         if ((move_up && min_switch) || (move_up && !do_bells) ||
  432.             (move_up && list_ver) || (!do_bells && list_ver) || 
  433.             (list_ver && min_switch))
  434.             wrong_parameter("You want help on what");
  435.         if (move_up)
  436.         {
  437.             printf("\n\nDMCHECK /U [...]\n\n");
  438.             printf("    This switch  will simply make DMCHECK not print a blank line after running\n");
  439.             printf("    itself. This is normally caused by DOS, so in a batch file there will be a\n");
  440.             printf("    blank line between each commands unless you use this switch.");
  441.         } else
  442.         {
  443.             if (min_switch)
  444.             {
  445.                 printf("\n\nDMCHECK /M [/H] [/D]\n\n");
  446.                 printf("    The Minimum  switch is used to suppress some information from the output\n");
  447.                 printf("    that DMCHECK would normally  generate. It is similar  to Quiet, but some\n");
  448.                 printf("    of  the  information is  diplayed. It  is  most usefull  for  the  WHICH\n");
  449.                 printf("    function so  that  the batch  file  can actually  display  the installed\n");
  450.                 printf("    without having to test the ERRORLEVEL code returned by it.");
  451.             } else
  452.                 {
  453.                 if (list_ver)
  454.                 {
  455.                     printf("\n\nDMCHECK /L [/H] [/D]\n\n");
  456.                     printf("    Is used to display all  of the data  relating to  the different versions\n");
  457.                     printf("    of DOOM. Use it to know the  exact size of all the DOOM.WAD and DOOM.EXE\n");
  458.                     printf("    files as well as their date and time of creation for all the versions of\n");
  459.                     printf("    DOOM that DMCHECK can test for.");
  460.                 } else
  461.                 {
  462.                   if (!do_bells)
  463.                   {
  464.                     printf("\n\nDMCHECK /B [...]\n\n");
  465.                     printf("    This switch  will simply prevent the  bell to  be ringed when  an error is\n");
  466.                     printf("    encountered.\n");
  467.                   } else
  468.                   {
  469.                     if (quiet)
  470.                     {
  471.                         printf("\n\nDMCHECK /Q [...]\n\n");
  472.                         printf("    This  parameter is simply used  to suppress  the output  of the  DMCHECK\n");
  473.                         printf("    command when it is used within batch files.");
  474.                     } else
  475.                     {
  476.                       if (i == 0)
  477.                       {
  478.                           printf("\n\n");
  479.                           if (days_old < 120)
  480.                           {
  481.                             printf("Get the latest version of DMCHECK from the Synapse BBS at (819)246-2344\n");
  482.                             printf("    or from the offical DOOM FTP site; ftp.cdrom.com\n\n");
  483.                         }
  484.                         printf("DMCHECK [/H | /Q] [/D] [/B] [/M] [/U] [[function [parameters]] | /L]\n\n");
  485.                         printf("[none]  Use no parameters to get complete usage message.\n");
  486.                         printf("/Q      Do not display output (except for help and syntax errors).\n");
  487.                         printf("/H      Display this help screen or additional help on any other\n");
  488.                         printf("        function if used at the same time as that function.\n");
  489.                         printf("/D      Debugging that permits certain messages.\n");
  490.                         printf("/L      List all data used by DMCHECK of all DOOM versions.\n\n");
  491.                         printf("/B      The bell switch disables the speaker for errors.\n");
  492.                         printf("/M      The Minimum switch displays less information.\n");
  493.                         printf("/U      Move up command prevents DOS from adding a blank line.\n");
  494.                         printf("Ask     Display a question and wait for a key press.\n");
  495.                         printf("Date    Change or display date and time of one or more files.\n");
  496.                         printf("File    Permits testing file size, date and time.\n");
  497.                         printf("Space   Check if there is enough free bytes on a drive.\n");
  498.                         printf("Version Test for existance of a particular version of DOOM.\n");
  499.                         printf("Which   Returns the DOOM version as an ERRORLEVEL code.");
  500.                     } else
  501.                     {
  502.                       if ((i == 1 && !strcmp(argpass[1],"S")) || !strcmp(argpass[1],"SPACE"))
  503.                       {
  504.                           printf("\n\nDMCHECK [/Q | /H] [/D] S[pace] [Drive] NeededSpace\n\n");
  505.                           printf("    Used to determins if there is  enough free disk space on  a specified or\n");
  506.                           printf("    on the  current  drive. \"DMCHECK S 1000\" will  tell  you if there  is at\n");
  507.                           printf("    least 1000 bytes free on the current drive or \"DMCHECK S L: 10,000\" will\n");
  508.                           printf("    test drive L:  instead. Additionally, you  may have noticed  that commas\n");
  509.                           printf("    are permited in the [NeededSpace] field. When using batch files, DMCHECK\n");
  510.                           printf("    will return an ERRORLEVEL of 1 if there is less than [NeededSpace] bytes\n");
  511.                           printf("    on the specified (or current) drive or 0 if there is  at least that much\n");
  512.                           printf("    free space. In the case of an error accessing the drive, the  ERRORLEVEL\n");
  513.                           printf("    code returned will be 255.");
  514.                       } else
  515.                       {
  516.                         if ((i == 1 && !strcmp(argpass[1],"V")) || !strcmp(argpass[1],"VERSION"))
  517.                         {
  518.                             printf("\n\nDMCHECK [/Q | /H] [/D] V[ersion] DOOMversion\n\n");
  519.                             printf("    This will permit  you to  test if  the  installed  copy of  DOOM is  the\n");
  520.                             printf("    version you need. You can also use this feature to test for a registered\n");
  521.                             printf("    or a shareware version. You may  test for these  version: 1.0, 1.1, 1.2,\n");
  522.                             printf("    1.2ZONE  (from the  PC-ZONE  magazine CD),  1.4Beta,  1.5Beta,  1.6Beta,\n");
  523.                             printf("    1.666 or  a version of DOOM ][  using the same versions  but with the ][\n");
  524.                             printf("    in front. For example,  by using \"DMCHECK V 1.666\"  an  ERRORLEVEL  of 0\n");
  525.                             printf("    would be returned if the installed version of DOOM was 1.666, 1 if it is\n");
  526.                             printf("    a not 1.666, or 2 if it is only the  shareware version of 1.666. On  the\n");
  527.                             printf("    other  hand, if there is no  valid  DOOM.WAD  file, then the  ERRORLEVEL\n");
  528.                             printf("    code returned would be 255.");
  529.                         } else
  530.                         {
  531.                           if ((i == 1 && !strcmp(argpass[1],"D")) || !strcmp(argpass[1],"DATE"))
  532.                           {
  533.                               printf("\n\nDMCHECK [/Q | /H] [/D] D[ate] filename [NOW | [date time]]\n\n");
  534.                               printf("    This can be used to display the date and time of any file, but is mostly\n");
  535.                               printf("    useful to  change the  date and time  of a file. It can  be used on  any\n");
  536.                               printf("    file, but  it's  main use  would  be to  reset the date  and time of the\n");
  537.                               printf("    DOOM.EXE or DOOM.WAD file to their original when a patch would otherwise\n");
  538.                               printf("    have changed the date and time of those files. An ERRORLEVEL code of 255\n");
  539.                               printf("    is returned if  the function  was unsuccessful. The  NOW parameter  will\n");
  540.                               printf("    permit  you to  set the  date and  time of  the selected  file(s) to the\n");
  541.                               printf("    current system date and time.");
  542.                           } else
  543.                           {
  544.                             if ((i == 1 && !strcmp(argpass[1],"W")) || !strcmp(argpass[1],"WHAT") || !strcmp(argpass[1],"WHICH"))
  545.                             {
  546.                                 printf("\n\nDMCHECK [/Q | /H] [/D] W[hich]\n\n");
  547.                                 printf("    If you need to know what version is installed  and don't want to use the\n");
  548.                                 printf("    V[ersion] function, then you can use  this. It's mostly useful  to check\n");
  549.                                 printf("    the existance of a version independantly of the fact that it is a regis-\n");
  550.                                 printf("    tered version. It  would mostly be  useful  if  you want to  run DMCHECK\n");
  551.                                 printf("    only once and then have a  bunch of \"IF\"s in your batch  file instead of\n");
  552.                                 printf("    running DMCHECK with  the V[ersion]  function many  times, which is more\n");
  553.                                 printf("    time consuming.  Please note  that if more than one version  of DOOM are\n");
  554.                                 printf("    installed in the  same directory, DMCHECK  will return  the code for the\n");
  555.                                 printf("    registered  version of DOOM 1.x,  then the shareware version of DOOM 1.x\n");
  556.                                 printf("    before reporting on the version of DOOM 2.x\n\n");
  557.                                 printf("    Ver 1.0       -> 1    Ver 1.1       -> 2    Ver 1.2       -> 3\n");
  558.                                 printf("    Ver 1.4Beta   -> 4    Ver 1.5Beta   -> 5    Ver 1.6Beta   -> 6\n");
  559.                                 printf("    Ver 1.666     -> 7\n");
  560.                                 printf("    DOOM ][ pirated copy   -> 19        PC-ZONE 1.2 CD-ROM    -> 30\n");
  561.                                 printf("    DOOM ][ first release  -> 20        SYBEX 1.25            -> 31\n");
  562.                                 printf("    DOOM ][ second release -> 21\n");
  563.                                 printf("    No valid DOOM[1 | 2].WAD and/or DOOM[2].EXE file present  ->255");
  564.                             } else
  565.                             {
  566.                               if ((i == 1 && !strcmp(argpass[1],"A")) || !strcmp(argpass[1],"ASK"))
  567.                               {
  568.                                   printf("\n\nDMCHECK [/Q | /H] [/D] A[sk] [ [question] replies]\n\n");
  569.                                   printf("    This is very similar to many other batch file enhancers and was included\n");
  570.                                   printf("    for functionality. You may use it to prompt the user for a question like\n");
  571.                                   printf("    \"Do you wish to keep a backup of DOOM.WAD?\" and wait for a Yes/No answer\n");
  572.                                   printf("    and continue the batch  file accordingly. It may also be  used to create\n");
  573.                                   printf("    simple menus  by  preceeding the  DMCHECK  command with  multiple \"ECHO\"\n");
  574.                                   printf("    statements  and  then  having the  DMCHECK command  with more  than  two\n");
  575.                                   printf("    replies possible, you may  create a quick and simple menu  system. It is\n");
  576.                                   printf("    also  possible  for the  user to  press  the [ESC] key.  The  ERRORLEVEL\n");
  577.                                   printf("    returned will be 255  for [ESC] or the position of  the character in the\n");
  578.                                   printf("    [replies] parameter.\n\n");
  579.                                   printf("    DON'T FORGET TO USE DOUBLE QUOTES (\") FOR THE QUESTION DELIMITER!");
  580.                               } else
  581.                               {
  582.                                 if ((i == 1 && !strcmp(argpass[1],"F")) || !strcmp(argpass[1],"FILE"))
  583.                                 {
  584.                                   printf("\n\nDMCHECK [/Q | /H] [/D] F[ile] filename [size [date [time]]]\n\n");
  585.                                   printf("    This function is used to verify if a file matches  a series of criteria.\n");
  586.                                   printf("    You may test only for  the file size, both  the size and date or for the\n");
  587.                                     printf("    size, date and time of  a single  file. The ERRORLEVEL  returned will be\n");
  588.                                     printf("    0 if there is a match, 1 if there isn't a match and 255 if the  file was\n");
  589.                                     printf("    not available or non existant.");
  590.                                   } else
  591.                                   {
  592.                                     printf("\n\n*** ERROR *** I don't understand this help request, please use \"DMCHECK /H\"\n");
  593.                                     printf("              for general help or \"DMCHECK\" for a general usage message.");
  594.                                     if (do_bells) printf("\a");
  595.                                     prnt_usage();
  596.                                     err_code = 255;
  597.                                   }
  598.                                 }
  599.                               }
  600.                             }
  601.                           }
  602.                         }
  603.                       }
  604.                    }
  605.                 }
  606.               }
  607.            }
  608.         }
  609.     }
  610. r_error();
  611. }
  612.  
  613.  
  614.  
  615.  
  616. /*************************************************************************
  617. *** get_version returns a possible version string based on exe and wad ***
  618. *** file sizes.                                                        ***
  619. *************************************************************************/
  620.  
  621. char *get_version()
  622. {
  623.     char *ver_str = " ERROR";
  624.     if (wadsize == D2_PIR_WADSIZE && exesize == D2_PIR_EXESIZE)
  625.         return "][P";
  626.     if (wadsize == D2_166_WADSIZE && exesize == D2_166_EXESIZE)
  627.         return "][1.666";
  628.     if (wadsize == D2_17A_WADSIZE && exesize == D2_17A_EXESIZE)
  629.         return "][1.7A";
  630.     if (wadsize == D2_17C_WADSIZE && exesize == D2_17C_EXESIZE)
  631.         return "][1.7";
  632.     if (wadsize == D2_18C_WADSIZE && exesize == D2_18C_EXESIZE)
  633.         return "][1.8";
  634.     if (wadsize == D2_19C_WADSIZE && exesize == D2_19C_EXESIZE)
  635.         return "][1.9";
  636.     if (wadsize == DSYBEX_WADSIZE && exesize == DSYBEX_EXESIZE)
  637.         return "1.25";
  638.     if (wadsize == DPCZON_WADSIZE && exesize == DPCZON_EXESIZE)
  639.         return "1.2Z";
  640.     if ((wadsize == D19SHA_WADSIZE || wadsize == D19REG_WADSIZE ||
  641.         exesize == D19SHA_EXESIZE || exesize == D19REG_EXESIZE) &&
  642.         strcmp(waddate,D19SHA_WADDATE) == 0)
  643.         return "1.9";
  644.     if ((wadsize == D18SHA_WADSIZE || wadsize == D18REG_WADSIZE ||
  645.         exesize == D18SHA_EXESIZE || exesize == D18REG_EXESIZE) &&
  646.         strcmp(waddate,D18SHA_WADDATE) == 0)
  647.         return "1.8";
  648.     if ((wadsize == D17ASH_WADSIZE || wadsize == D17ARE_WADSIZE ||
  649.         exesize == D17ASH_EXESIZE || exesize == D17ARE_EXESIZE) &&
  650.         strcmp(waddate,D17ASH_WADDATE) == 0)
  651.         return "1.7A";
  652.     if ((wadsize == D17SHA_WADSIZE || wadsize == D17REG_WADSIZE ||
  653.         exesize == D17SHA_EXESIZE || exesize == D17REG_EXESIZE) &&
  654.         strcmp(waddate,D17SHA_WADDATE) == 0)
  655.         return "1.7";
  656.     if ((wadsize == D166SH_WADSIZE || wadsize == D166RE_WADSIZE ||
  657.         exesize == D166SH_EXESIZE || exesize == D166RE_EXESIZE) &&
  658.         strcmp(waddate,D166SH_WADDATE) == 0)
  659.         return "1.666";
  660.     if (wadsize == D16BET_WADSIZE || exesize == D16BET_EXESIZE)
  661.         return "1.6";
  662.     if (wadsize == D15BET_WADSIZE || exesize == D15BET_EXESIZE)
  663.         return "1.5";
  664.     if (wadsize == D14BET_WADSIZE || exesize == D14BET_EXESIZE)
  665.         return "1.4";
  666.     if (wadsize == D12SHA_WADSIZE || wadsize == D12REG_WADSIZE ||
  667.         exesize == D12SHA_EXESIZE || exesize == D12REG_EXESIZE)
  668.         return "1.2";
  669.     if (wadsize == D11SHA_WADSIZE || wadsize == D11REG_WADSIZE ||
  670.         exesize == D11SHA_EXESIZE || exesize == D11REG_EXESIZE)
  671.         return "1.1";
  672.     if (wadsize == D10SHA_WADSIZE || exesize == D10SHA_EXESIZE)
  673.         return "1.0";
  674.     if (wadsize == 0) return "NOWAD";
  675.     if (exesize == 0) return "NOEXE";
  676.     return ver_str;
  677. }
  678.  
  679.  
  680.  
  681.  
  682. /*************************************************************************
  683. *** valid_version simply verifies the validity on the version string.  ***
  684. *************************************************************************/
  685.  
  686. int valid_version(char *str)
  687. {
  688.     str = strupr(str);
  689.     if (strcmp(str,"1.4BETA") == 0 || strcmp(str,"1.4B") == 0 ||
  690.         strcmp(str,"1.4BT") == 0)
  691.         str = "1.4";
  692.     if (strcmp(str,"1.5BETA") == 0 || strcmp(str,"1.5B") == 0 ||
  693.         strcmp(str,"1.5BT") == 0)
  694.         str = "1.5";
  695.     if (strcmp(str,"1.6BETA") == 0 || strcmp(str,"1.6B") == 0 ||
  696.         strcmp(str,"1.6BT") == 0)
  697.         str = "1.6";
  698.     if (strcmp(str,"][S") == 0     || strcmp(str,"2S") == 0 ||
  699.         strcmp(str,"2S") == 0      || strcmp(str,"2SECOND")==0 ||
  700.         strcmp(str,"2.0S") == 0)
  701.         str = "][1.666";
  702.     if (strcmp(str,"][P") == 0     || strcmp(str,"2P") == 0 ||
  703.         strcmp(str,"2PIR") == 0    || strcmp(str,"2PIRATE")==0 ||
  704.         strcmp(str,"2.0P") == 0)
  705.         str = "][P";
  706.     if (strcmp(str,"1.2ZONE") == 0 || strcmp(str,"PCZONE") == 0 ||
  707.         strcmp(str,"ZONE") == 0    || strcmp(str,"1.2PCZONE") == 0)
  708.         str = "1.2Z";
  709.     if (strcmp(str,"0.9") == 0) str = "1.0";
  710.     if (strcmp(str,"1.0") == 0 || strcmp(str,"1.1") == 0 ||
  711.         strcmp(str,"1.2") == 0 || strcmp(str,"1.4") == 0 ||
  712.         strcmp(str,"1.5") == 0 || strcmp(str,"1.6") == 0 ||
  713.         strcmp(str,"1.666") == 0 || strcmp(str,"1.7") == 0 ||
  714.         strcmp(str,"1.7A") == 0 || strcmp(str,"1.8") == 0 ||
  715.         strcmp(str,"1.9") == 0 || strcmp(str,"][P") == 0 ||
  716.         strcmp(str,"][1.666") == 0 || strcmp(str,"][1.7") == 0 ||
  717.         strcmp(str,"][1.7A") == 0 || strcmp(str,"][1.8") == 0 ||
  718.         strcmp(str,"][1.9") == 0 || strcmp(str,"1.25") == 0 ||
  719.         strcmp(str,"1.2Z") == 0)
  720.         return TRUE;
  721.     else
  722.         return FALSE;
  723. }
  724.  
  725.  
  726.  
  727.  
  728.  
  729. /*************************************************************************
  730. ***  isitver will return a booleen based on the check of the actual    ***
  731. ***  version installed.                                                ***
  732. *************************************************************************/
  733.  
  734. int isitver(char *str)
  735. {
  736.     str = strupr(str);
  737.     if (strcmp(str,"1.0") == 0)
  738.         if (wadsize==D10SHA_WADSIZE && exesize==D10SHA_EXESIZE &&
  739.             strcmp(waddate,D10SHA_WADDATE) == 0 &&
  740.             strcmp(exedate,D10SHA_EXEDATE) == 0 &&
  741.             strcmp(wadtime,D10SHA_WADTIME) == 0 &&
  742.             strcmp(exetime,D10SHA_EXETIME) == 0)
  743.             return TRUE;
  744.     if (strcmp(str,"1.1") == 0)
  745.         if ((wadsize==D11SHA_WADSIZE || wadsize==D11REG_WADSIZE) &&
  746.             (exesize==D11SHA_EXESIZE || exesize==D11REG_EXESIZE) &&
  747.             (strcmp(waddate,D11SHA_WADDATE) == 0 || strcmp(waddate,D11REG_WADDATE) == 0) &&
  748.             (strcmp(exedate,D11SHA_EXEDATE) == 0 || strcmp(exedate,D11REG_EXEDATE) == 0) &&
  749.             (strcmp(wadtime,D11SHA_WADTIME) == 0 || strcmp(wadtime,D11REG_WADTIME) == 0) &&
  750.             (strcmp(exetime,D11SHA_EXETIME) == 0 || strcmp(exetime,D11REG_EXETIME) == 0))
  751.             return TRUE;
  752.     if (strcmp(str,"1.2") == 0)
  753.         if ((wadsize==D12SHA_WADSIZE || wadsize==D12REG_WADSIZE) &&
  754.             (exesize==D12SHA_EXESIZE || exesize==D12REG_EXESIZE) &&
  755.             (strcmp(waddate,D12SHA_WADDATE) == 0 || strcmp(waddate,D12REG_WADDATE) == 0) &&
  756.             (strcmp(exedate,D12SHA_EXEDATE) == 0 || strcmp(exedate,D12REG_EXEDATE) == 0) &&
  757.             (strcmp(wadtime,D12SHA_WADTIME) == 0 || strcmp(wadtime,D12REG_WADTIME) == 0) &&
  758.             (strcmp(exetime,D12SHA_EXETIME) == 0 || strcmp(exetime,D12REG_EXETIME) == 0))
  759.             return TRUE;
  760.     if (strcmp(str,"1.25") == 0)
  761.         if (wadsize==DSYBEX_WADSIZE && exesize==DSYBEX_EXESIZE &&
  762.             strcmp(waddate,DSYBEX_WADDATE) == 0 && strcmp(exedate,DSYBEX_EXEDATE) == 0 &&
  763.             strcmp(wadtime,DSYBEX_WADTIME) == 0 && strcmp(exetime,DSYBEX_EXETIME) == 0)
  764.             return TRUE;
  765.     if (strcmp(str,"1.2Z") == 0)
  766.         if (wadsize==DPCZON_WADSIZE && exesize==DPCZON_EXESIZE &&
  767.             strcmp(waddate,DPCZON_WADDATE) == 0 && strcmp(exedate,DPCZON_EXEDATE) == 0 &&
  768.             strcmp(wadtime,DPCZON_WADTIME) == 0 && strcmp(exetime,DPCZON_EXETIME) == 0)
  769.             return TRUE;
  770.     if (strcmp(str,"1.4") == 0)
  771.         if (wadsize==D14BET_WADSIZE && exesize==D14BET_EXESIZE &&
  772.             strcmp(waddate,D14BET_WADDATE) == 0 && strcmp(exedate,D14BET_EXEDATE) == 0 &&
  773.             strcmp(wadtime,D14BET_WADTIME) == 0 && strcmp(exetime,D14BET_EXETIME) == 0)
  774.             return TRUE;
  775.     if (strcmp(str,"1.5") == 0)
  776.         if (wadsize==D15BET_WADSIZE && exesize==D15BET_EXESIZE &&
  777.             strcmp(waddate,D15BET_WADDATE) == 0 && strcmp(exedate,D15BET_EXEDATE) == 0 &&
  778.             strcmp(wadtime,D15BET_WADTIME) == 0 && strcmp(exetime,D15BET_EXETIME) == 0)
  779.             return TRUE;
  780.     if (strcmp(str,"1.6") == 0)
  781.         if (wadsize==D16BET_WADSIZE && exesize==D16BET_EXESIZE &&
  782.             strcmp(waddate,D16BET_WADDATE) == 0 && strcmp(exedate,D16BET_EXEDATE) == 0 &&
  783.             strcmp(wadtime,D16BET_WADTIME) == 0 && strcmp(exetime,D16BET_EXETIME) == 0)
  784.             return TRUE;
  785.     if (strcmp(str,"1.666") == 0)
  786.         if ((wadsize==D166SH_WADSIZE || wadsize==D166RE_WADSIZE || wadsize==D166S2_WADSIZE) &&
  787.             (exesize==D166SH_EXESIZE || exesize==D166RE_EXESIZE || exesize==D166S2_EXESIZE) &&
  788.             (strcmp(waddate,D166SH_WADDATE) == 0 || strcmp(waddate,D166RE_WADDATE) == 0 ||
  789.              strcmp(waddate,D166S2_WADDATE) == 0) &&
  790.             (strcmp(exedate,D166SH_EXEDATE) == 0 || strcmp(exedate,D166RE_EXEDATE) == 0 ||
  791.              strcmp(exedate,D166S2_EXEDATE) == 0) &&
  792.             (strcmp(wadtime,D166SH_WADTIME) == 0 || strcmp(wadtime,D166RE_WADTIME) == 0 ||
  793.              strcmp(wadtime,D166S2_WADTIME) == 0) &&
  794.             (strcmp(exetime,D166SH_EXETIME) == 0 || strcmp(exetime,D166RE_EXETIME) == 0 ||
  795.              strcmp(exetime,D166S2_EXETIME) == 0))
  796.             return TRUE;
  797.     if (strcmp(str,"1.7") == 0)
  798.         if ((wadsize==D17SHA_WADSIZE || wadsize==D17REG_WADSIZE) &&
  799.             (exesize==D17SHA_EXESIZE || exesize==D17REG_EXESIZE) &&
  800.             (strcmp(waddate,D17SHA_WADDATE) == 0 || strcmp(waddate,D17REG_WADDATE) == 0) &&
  801.             (strcmp(exedate,D17SHA_EXEDATE) == 0 || strcmp(exedate,D17REG_EXEDATE) == 0) &&
  802.             (strcmp(wadtime,D17SHA_WADTIME) == 0 || strcmp(wadtime,D17REG_WADTIME) == 0) &&
  803.             (strcmp(exetime,D17SHA_EXETIME) == 0 || strcmp(exetime,D17REG_EXETIME) == 0))
  804.             return TRUE;
  805.     if (strcmp(str,"1.7A") == 0)
  806.         if ((wadsize==D17ASH_WADSIZE || wadsize==D17ARE_WADSIZE) &&
  807.             (exesize==D17ASH_EXESIZE || exesize==D17ARE_EXESIZE) &&
  808.             (strcmp(waddate,D17ASH_WADDATE) == 0 || strcmp(waddate,D17ARE_WADDATE) == 0) &&
  809.             (strcmp(exedate,D17ASH_EXEDATE) == 0 || strcmp(exedate,D17ARE_EXEDATE) == 0) &&
  810.             (strcmp(wadtime,D17ASH_WADTIME) == 0 || strcmp(wadtime,D17ARE_WADTIME) == 0) &&
  811.             (strcmp(exetime,D17ASH_EXETIME) == 0 || strcmp(exetime,D17ARE_EXETIME) == 0))
  812.             return TRUE;
  813.     if (strcmp(str,"1.8") == 0)
  814.         if ((wadsize==D18SHA_WADSIZE || wadsize==D18REG_WADSIZE) &&
  815.             (exesize==D18SHA_EXESIZE || exesize==D18REG_EXESIZE) &&
  816.             (strcmp(waddate,D18SHA_WADDATE) == 0 || strcmp(waddate,D18REG_WADDATE) == 0) &&
  817.             (strcmp(exedate,D18SHA_EXEDATE) == 0 || strcmp(exedate,D18REG_EXEDATE) == 0) &&
  818.             (strcmp(wadtime,D18SHA_WADTIME) == 0 || strcmp(wadtime,D18REG_WADTIME) == 0) &&
  819.             (strcmp(exetime,D18SHA_EXETIME) == 0 || strcmp(exetime,D18REG_EXETIME) == 0))
  820.             return TRUE;
  821.     if (strcmp(str,"1.9") == 0)
  822.         if ((wadsize==D19SHA_WADSIZE || wadsize==D19REG_WADSIZE) &&
  823.             (exesize==D19SHA_EXESIZE || exesize==D19REG_EXESIZE) &&
  824.             (strcmp(waddate,D19SHA_WADDATE) == 0 || strcmp(waddate,D19REG_WADDATE) == 0) &&
  825.             (strcmp(exedate,D19SHA_EXEDATE) == 0 || strcmp(exedate,D19REG_EXEDATE) == 0) &&
  826.             (strcmp(wadtime,D19SHA_WADTIME) == 0 || strcmp(wadtime,D19REG_WADTIME) == 0) &&
  827.             (strcmp(exetime,D19SHA_EXETIME) == 0 || strcmp(exetime,D19REG_EXETIME) == 0))
  828.             return TRUE;
  829.     if (strcmp(str,"][P") == 0 || strcmp(str,"2.0P") == 0)
  830.         if (wadsize==D2_PIR_WADSIZE && exesize==D2_PIR_EXESIZE &&
  831.             strcmp(waddate,D2_PIR_WADDATE) == 0 && strcmp(exedate,D2_PIR_EXEDATE) == 0 &&
  832.             strcmp(wadtime,D2_PIR_WADTIME) == 0 && strcmp(exetime,D2_PIR_EXETIME) == 0)
  833.             return TRUE;
  834.     if (strcmp(str,"][1.666") == 0 || strcmp(str,"2.0S") == 0)
  835.         if (wadsize==D2_166_WADSIZE && exesize==D2_166_EXESIZE &&
  836.             strcmp(waddate,D2_166_WADDATE) == 0 && strcmp(exedate,D2_166_EXEDATE) == 0 &&
  837.             strcmp(wadtime,D2_166_WADTIME) == 0 && strcmp(exetime,D2_166_EXETIME) == 0)
  838.             return TRUE;
  839.     if (strcmp(str,"][1.7") == 0)
  840.         if (wadsize==D2_17C_WADSIZE && exesize==D2_17C_EXESIZE &&
  841.             strcmp(waddate,D2_17C_WADDATE) == 0 && strcmp(exedate,D2_17C_EXEDATE) == 0 &&
  842.             strcmp(wadtime,D2_17C_WADTIME) == 0 && strcmp(exetime,D2_17C_EXETIME) == 0)
  843.             return TRUE;
  844.     if (strcmp(str,"][1.7A") == 0)
  845.         if (wadsize==D2_17A_WADSIZE && exesize==D2_17A_EXESIZE &&
  846.             strcmp(waddate,D2_17A_WADDATE) == 0 && strcmp(exedate,D2_17A_EXEDATE) == 0 &&
  847.             strcmp(wadtime,D2_17A_WADTIME) == 0 && strcmp(exetime,D2_17A_EXETIME) == 0)
  848.             return TRUE;
  849.     if (strcmp(str,"][1.8") == 0)
  850.         if (wadsize==D2_18C_WADSIZE && exesize==D2_18C_EXESIZE &&
  851.             strcmp(waddate,D2_18C_WADDATE) == 0 && strcmp(exedate,D2_18C_EXEDATE) == 0 &&
  852.             strcmp(wadtime,D2_18C_WADTIME) == 0 && strcmp(exetime,D2_18C_EXETIME) == 0)
  853.             return TRUE;
  854.     if (strcmp(str,"][1.9") == 0)
  855.         if (wadsize==D2_19C_WADSIZE && exesize==D2_19C_EXESIZE &&
  856.             strcmp(waddate,D2_19C_WADDATE) == 0 && strcmp(exedate,D2_19C_EXEDATE) == 0 &&
  857.             strcmp(wadtime,D2_19C_WADTIME) == 0 && strcmp(exetime,D2_19C_EXETIME) == 0)
  858.             return TRUE;
  859.     return FALSE;
  860. }
  861.  
  862.  
  863.  
  864.  
  865. /*************************************************************************
  866. ***                               Main                                 ***
  867. *************************************************************************/
  868.  
  869. void main(int argc, char *argv[])
  870. {
  871.     int done;
  872.     int drive;
  873.     long avail;
  874.     long NeededSpace;
  875.     static char command[128];
  876.     char far *cp;
  877.     char *today_date = "01-01-94";
  878.     char *today_time = "10:10:10";
  879.     _setcursortype(_NOCURSOR);
  880.     _dos_getdate(¤t_date);
  881.     today = ((long) (current_date.year-1980)*365 +
  882.              (long) current_date.month*31 +
  883.              (long) current_date.day);
  884.     today_date = _strdate(today_date);
  885.     today_time = _strtime(today_time);
  886.     s = "  ";
  887.     s[0] = VERSION_DATE[0];
  888.     s[1] = VERSION_DATE[1];
  889.     t = "  ";
  890.     t[0] = VERSION_DATE[3];
  891.     t[1] = VERSION_DATE[4];
  892.     u = "  ";
  893.     u[0] = VERSION_DATE[6];
  894.     u[1] = VERSION_DATE[7];
  895.     creation = ((long) (atoi(s)-80)*365 +
  896.                 (long) atoi(t)*31 + (long) atoi(u));
  897.     days_old = today - creation;
  898.     cp = (char _seg *) _psp + (char near *) 0x80;
  899.     j = cp[0];
  900.     for (i=0; i < j; i++)
  901.         command[i] = cp[i+1];
  902.     i = 1;
  903.     while (i < argc)
  904.     {
  905.         argpass[i] = argv[i];
  906.         if (strlen(argpass[i]) == 0) strcpy(argpass[i],"");
  907.         i++;
  908.     }
  909.     while (i < 10)
  910.     {
  911.         argpass[i] = "";
  912.         i++;
  913.     }
  914.     i = 1;
  915.     k = 0;
  916.     while (i < argc)
  917.     {
  918.         if (argpass[i][0] == '?')
  919.         {
  920.             argpass[i][0] = '\0';
  921.             get_help = TRUE;
  922.         }
  923.         if (strchr(argpass[i],' ') == NULL)
  924.         {
  925.             s = strchr(argpass[i]+k,'/');
  926.             if (s == NULL)
  927.                 s = strchr(argpass[i]+k,'-');
  928.             if (s != NULL)
  929.             {
  930.                 j = s - (argpass[i]+k);
  931.                 if (strupr(argpass[i])[j+1+k] == 'H' || argpass[i][j+1+k] == '?')
  932.                 {
  933.                     get_help = TRUE;
  934.                     argpass[i][j+k] = '\0';
  935.                 }
  936.                 if (strupr(argpass[i])[j+1+k] == 'D')
  937.                 {
  938.                     debug_on = TRUE;
  939.                     argpass[i][j+k] = '\0';
  940.                 }
  941.                 if (strupr(argpass[i])[j+1+k] == 'L')
  942.                 {
  943.                     list_ver = TRUE;
  944.                     argpass[i][j+k] = '\0';
  945.                 }
  946.                 if (strupr(argpass[i])[j+1+k] == 'U')
  947.                 {
  948.                     move_up = TRUE;
  949.                     argpass[i][j+k] = '\0';
  950.                 }
  951.                 if (strupr(argpass[i])[j+1+k] == 'Q')
  952.                 {
  953.  
  954.                     quiet = TRUE;
  955.                     argpass[i][j+k] = '\0';
  956.                 }
  957.                 if (strupr(argpass[i])[j+1+k] == 'B')
  958.                 {
  959.  
  960.                     do_bells = FALSE;
  961.                     argpass[i][j+k] = '\0';
  962.                 }
  963.                 if (strupr(argpass[i])[j+1+k] == 'M')
  964.                 {
  965.                     min_switch = TRUE;
  966.                     argpass[i][j+k] = '\0';
  967.                 }
  968.                 k = k + j + 1;
  969.             } else
  970.             {
  971.                 i++;
  972.                 k = 0;
  973.             }
  974.         } else
  975.         {
  976.             i++;
  977.             k = 0;
  978.         }
  979.     }
  980.     k = 1;
  981.     while (k < 10)
  982.     {
  983.     i = 1;
  984.         while (i < argc)
  985.         {
  986.             if (strlen(argpass[i]) == 0)
  987.             {
  988.                 j = i;
  989.                 while (j < argc - 1)
  990.                 {
  991.                     argpass[j] = argpass[j+1];
  992.                     j++;
  993.                 }
  994.                 argpass[j] = "";
  995.             }
  996.             i++;
  997.         }
  998.         k++;
  999.     }
  1000.     if (move_up) gotoxy(wherex(),wherey()-1);
  1001.     if (debug_on) printf("\nDMCHECK%s\n\n",command);
  1002.     if (!quiet) prnt_mess();
  1003.     show_where();
  1004.     if (get_help) help_screen();
  1005.     if (debug_on && quiet) wrong_parameter("can't use /Q with /D");
  1006.     if (quiet && list_ver) wrong_parameter("can't use /Q with /L");
  1007.     if (argpass[1][0] == '\0' && quiet) wrong_parameter("don't use /Q alone");
  1008.     if (list_ver) ver_listing();
  1009.     if (strlen(argpass[1]) == 0) usage();
  1010.     _dos_findfirst("DOOM.WAD",_ATTRIBUTES_,&aDir[DOOMWAD]);
  1011.     _dos_findfirst("DOOM.EXE",_ATTRIBUTES_,&aDir[DOOMEXE]);
  1012.     _dos_findfirst("DOOM1.WAD",_ATTRIBUTES_,&aDir[DOOM1WAD]);
  1013.     _dos_findfirst("DOOM2.EXE",_ATTRIBUTES_,&aDir[DOOM2EXE]);
  1014.     _dos_findfirst("DOOM2.WAD",_ATTRIBUTES_,&aDir[DOOM2WAD]);
  1015.     more_than_one = FALSE;
  1016.     i = 0;
  1017.     while (i < 5)
  1018.     {
  1019.         s = aDir[i].name;
  1020.         if (strcmp("DOOM.WAD",s)==0 || strcmp("DOOM1.WAD",s)==0 ||
  1021.             strcmp("DOOM2.WAD",s)==0)
  1022.         {
  1023.             if (wadsize > 0)
  1024.                 more_than_one = TRUE;
  1025.             else
  1026.             {
  1027.                 wadsize = aDir[i].size;
  1028.                 waddate = strdosdate(aDir[i].wr_date);
  1029.                 wadtime = strdostime(aDir[i].wr_time);
  1030.                 wadnum = i;
  1031.             }
  1032.         }
  1033.         if (strcmp("DOOM.EXE",s)==0 || strcmp("DOOM2.EXE",s)==0)
  1034.         {
  1035.             if (exesize > 0)
  1036.                 more_than_one = TRUE;
  1037.             else
  1038.             {
  1039.                 exesize = aDir[i].size;
  1040.                 exedate = strdosdate(aDir[i].wr_date);
  1041.                 exetime = strdostime(aDir[i].wr_time);
  1042.                 exenum = i;
  1043.             }
  1044.         }
  1045.         i++;
  1046.     }
  1047.     argpass[1] = strupr(argpass[1]);
  1048.     s = argpass[1];
  1049.     i = s[0];
  1050.     if (strlen(s)>1 && strcmp(s,"ASK")!=0 && strcmp(s,"SPACE")!=0 &&
  1051.         strcmp(s,"DATE")!=0 && strcmp(s,"WHAT")!=0 && strcmp(s,"WHICH")!=0 &&
  1052.         strcmp(s,"VERSION")!=0 && strcmp(s,"FILE")!=0)
  1053.         wrong_parameter(strcat("Unknown function ",s));
  1054.     switch (i)
  1055.     {
  1056.         case 'S':
  1057.             i = 2;
  1058.             while (i < 4)
  1059.             {
  1060.                 p = strchr(argpass[i],',');
  1061.                 if (p==0)
  1062.                     j = 0;
  1063.                 else
  1064.                     j = p - argpass[i];
  1065.                 while (j > 0)
  1066.                 {
  1067.                     s = strncpy(argpass[i],argpass[i],j);
  1068.                     s[j] = '\0';
  1069.                     argpass[i] = strcat(s,argpass[i]+j+1);
  1070.                     p = strchr(argpass[i],',');
  1071.                     if (p==0)
  1072.                         j = 0;
  1073.                     else
  1074.                         j = p - argpass[i];
  1075.                 }
  1076.                 i++;
  1077.             }
  1078.             if (strlen(argpass[3]) == 0)
  1079.             {
  1080.                 drive = getdisk();
  1081.                 s = argpass[2];
  1082.             } else
  1083.             {
  1084.                 drive = strupr(argpass[2])[0]-'A';
  1085.                 s = argpass[3];
  1086.                 if ((strlen(argpass[2]) > 2) || (drive < 0 || drive > 25)
  1087.                     || (argpass[2][1] != ':' && argpass[2][1] != '\0'))
  1088.                     wrong_parameter("Check drive");
  1089.             }
  1090.             NeededSpace = strtol(s,&t,0);
  1091.             if (NeededSpace < 0) wrong_parameter("Can't check negative bytes");
  1092.             if (NeededSpace == 0) wrong_parameter("Check NeededSpace");
  1093.             getdfree(drive+1,&aFreeSpace);
  1094.             if (aFreeSpace.df_sclus == 0xFFFF)
  1095.             {
  1096.                 s = " :";
  1097.                 s[0] = 'A'+drive;
  1098.                 error_message(strcat("couldn't access drive ",s));
  1099.             } else
  1100.             {
  1101.                 avail = (long) aFreeSpace.df_avail * (long) aFreeSpace.df_bsec
  1102.                     * (long) aFreeSpace.df_sclus;
  1103.                 if (!quiet) printf("\n");
  1104.                 if (debug_on)
  1105.                     printf("\nFree space on drive %c: is %s bytes.",drive+'A',strcommas(avail));
  1106.                 if (NeededSpace < avail)
  1107.                 {
  1108.                     err_code = 0;
  1109.                     if (!quiet)
  1110.                         printf("\nThere is at least %s bytes free on drive %c:.",
  1111.                             strcommas(NeededSpace),drive+'A');
  1112.                 } else
  1113.                 {
  1114.                     err_code = 1;
  1115.                     if (!quiet)
  1116.                         printf("\nThere is less than %s bytes free on drive %c:.",
  1117.                             strcommas(NeededSpace),drive+'A');
  1118.                 }
  1119.             }
  1120.             break;
  1121.         case 'A':
  1122.             s = strchr(argpass[3],' ');
  1123.             if (s != 0)
  1124.             {
  1125.                 i = s - argpass[3];
  1126.                 s = strrchr(argpass[3],' ');
  1127.                 if (s != 0)
  1128.                 {
  1129.                     j = s - argpass[3];
  1130.                     if (j > i) wrong_parameter("Can't use only question");
  1131.                 }
  1132.             }
  1133.             if (strlen(argpass[3]) == 0)
  1134.             {
  1135.                 argpass[3] = argpass[2];
  1136.                 if (strlen(argpass[3]) != 0)
  1137.                 {
  1138.                     char *s1;
  1139.                     s1 = "Press a key? [                                    ";
  1140.                     i = 0;
  1141.                     while (i < strlen(argpass[3]))
  1142.                     {
  1143.                         s1[i+14] = strupr(argpass[3])[i];
  1144.                         i++;
  1145.                     }
  1146.                     s1[i+14] = ']';
  1147.                     s1[i+15] = '\0';
  1148.                     argpass[2] = s1;
  1149.                 } else
  1150.                 {
  1151.                     argpass[2] = "Press any key to continue";
  1152.                 }
  1153.             }
  1154.             _setcursortype(_NOCURSOR);
  1155.             if (strlen(argpass[2]) > 0)
  1156.             {
  1157.                 _setcursortype(_NORMALCURSOR);
  1158.                 if (!quiet) printf("\n");
  1159.                 printf("\n%s",argpass[2]);
  1160.             }
  1161.             if (strlen(argpass[3]) == 0)
  1162.             {
  1163.                 j = getch();
  1164.                 while (j == 0)
  1165.                     j = getch();
  1166.                 err_code = 0;
  1167.             } else
  1168.             {
  1169.                 s = strupr(argpass[3]);
  1170.                 s = strcat(s,"\x1b");
  1171.                 i = 0;
  1172.                 u = "12345";
  1173.                 while (i == 0)
  1174.                 {
  1175.                     j = getch();
  1176.                     u[0] = j;
  1177.                     u[1] = '\0';
  1178.                     u = strupr(u);
  1179.                     j = u[0];
  1180.                     t = strchr(s,j);
  1181.                     if (t != NULL) i = t - s + 1;
  1182.                     if (i==0 && do_bells) printf("\a");
  1183.                 }
  1184.                 err_code = i;
  1185.             }
  1186.             if (j == 27) err_code = 255;
  1187.             if (j > ' ' && strlen(argpass[2]) != 0) printf("%c",j);
  1188.             if (strlen(argpass[2]) > 0 && quiet) printf("\n");
  1189.             if (debug_on)
  1190.             {
  1191.                 printf("\n\nThe key pressed was code %i",j);
  1192.                 if (j > 32 && j < 128) printf(" or text \"%c\".",j);
  1193.                 else printf(".");
  1194.             }
  1195.             _setcursortype(_NOCURSOR);
  1196.             break;
  1197.         case 'W':
  1198.             char *ver_str = get_version();
  1199.             if (strcmp(ver_str,"NOWAD") == 0)
  1200.             {
  1201.               if (aDir[DOOM2EXE].size == 0)
  1202.                   error_message("no DOOM.WAD or DOOM1.WAD file");
  1203.               else
  1204.                   error_message("no DOOM2.WAD file");
  1205.             }
  1206.             else
  1207.             {
  1208.               if (strcmp(ver_str,"NOEXE") == 0)
  1209.               {
  1210.                 if (aDir[DOOM2WAD].size == 0)
  1211.                   error_message("no DOOM.EXE file");
  1212.                 else
  1213.                   error_message("no DOOM2.EXE file");
  1214.               }
  1215.               else
  1216.               {
  1217.                 int is_it = isitver(ver_str);
  1218.                 if (!is_it && more_than_one)
  1219.                 {
  1220.                   if (strlen(aDir[DOOM1WAD].name) != 0)
  1221.                   {
  1222.                     if (debug_on)
  1223.                     {
  1224.                       if (ver_str[0] != ' ')
  1225.                       {
  1226.                         printf("\n\nYou have a DOOM.WAD and a DOOM1.WAD! You don't have an un-modified copy of\n");
  1227.                         printf("the registered version %s of DOOM, so I am now checking if it is a copy of\n",ver_str);
  1228.                         printf("the shareware version...");
  1229.                       } else
  1230.                       {
  1231.                         printf("\n\nYou have a DOOM.WAD and a DOOM1.WAD! The DOOM.WAD doesn't seam to be a\n");
  1232.                         printf("valid DOOM version, so I will check if the DOOM1.WAD is...");
  1233.                       }
  1234.                     }
  1235.                     wadsize = aDir[DOOM1WAD].size;
  1236.                     waddate = strdosdate(aDir[DOOM1WAD].wr_date);
  1237.                     wadtime = strdostime(aDir[DOOM1WAD].wr_time);
  1238.                   } else
  1239.                   {
  1240.                     if (debug_on)
  1241.                     {
  1242.                       if (ver_str[0] != ' ')
  1243.                       {
  1244.                         printf("\n\nYou have a copy of DOOM 1 and a copy of DOOM ][! You don't have an un-modified copy of\n");
  1245.                         printf("the registered version %s of DOOM, so I am now checking if it is a copy of\n",ver_str);
  1246.                         printf("the DOOM ][...");
  1247.                       } else
  1248.                       {
  1249.                         printf("\n\nYou have a copy of DOOM 1 and a copy of DOOM ][! Since the copy of DOOM 1\n");
  1250.                         printf("isn't any valid version, I will check if DOOM ][ is...");
  1251.                       }
  1252.                     }
  1253.                     wadsize = aDir[DOOM2WAD].size;
  1254.                     waddate = strdosdate(aDir[DOOM2WAD].wr_date);
  1255.                     wadtime = strdostime(aDir[DOOM2WAD].wr_time);
  1256.                     exesize = aDir[DOOM2EXE].size;
  1257.                     exedate = strdosdate(aDir[DOOM2EXE].wr_date);
  1258.                     exetime = strdostime(aDir[DOOM2EXE].wr_time);
  1259.                   }
  1260.                   ver_str = get_version();
  1261.                   is_it = isitver(ver_str);
  1262.                 }
  1263.                 if ((is_it && wadsize < 6000000L &&
  1264.                   aDir[DOOMWAD].size != 0) ||
  1265.                   (is_it && wadsize > 6000000L &&
  1266.                   aDir[DOOMWAD].size == 0L && aDir[DOOM2WAD].size == 0L))
  1267.                   is_it = FALSE;
  1268.                 if (!is_it)
  1269.                 {
  1270.                   if (!quiet)
  1271.                   {
  1272.                     if (ver_str[0] != ' ')
  1273.                     {
  1274.                       if (ver_str[0] == ']')
  1275.                       {
  1276.                         printf("\n\nYou appear to have a modified ");
  1277.                         printf("version %s of DOOM ][!",ver_str+3);
  1278.                       } else
  1279.                       {
  1280.                         printf("\n\nYou appear to have a modified ");
  1281.                         if (wadsize > 6000000) printf("registered ");
  1282.                         else printf("shareware ");
  1283.                         printf("version %s of DOOM!",ver_str);
  1284.                       }
  1285.                     } else
  1286.                     {
  1287.                       if (!min_switch) printf("\n\nYou have a");
  1288.                       else printf("\nA");
  1289.                       printf("n unrecognized DOOM version!");
  1290.                     }
  1291.                     if (wadsize < 6000000L && aDir[DOOM1WAD].size == 0L &&
  1292.                       aDir[DOOM2WAD].size == 0L)
  1293.                       error_message("The WAD file should be DOOM1.WAD");
  1294.                     if (wadsize > 6000000L && aDir[DOOMWAD].size == 0L &&
  1295.                       aDir[DOOM2WAD].size == 0L)
  1296.                       error_message("The WAD file should be DOOM.WAD");
  1297.                   }
  1298.                   err_code = 255;
  1299.                 } else
  1300.                 {
  1301.                   if (strcmp(ver_str,"1.0") == 0) err_code = 1;
  1302.                   if (strcmp(ver_str,"1.1") == 0) err_code = 2;
  1303.                   if (strcmp(ver_str,"1.2") == 0) err_code = 3;
  1304.                   if (strcmp(ver_str,"1.4") == 0) err_code = 4;
  1305.                   if (strcmp(ver_str,"1.5") == 0) err_code = 5;
  1306.                   if (strcmp(ver_str,"1.6") == 0) err_code = 6;
  1307.                   if (strcmp(ver_str,"1.666") == 0) err_code = 7;
  1308.                   if (strcmp(ver_str,"1.7") == 0) err_code = 8;
  1309.                   if (strcmp(ver_str,"1.7A") == 0) err_code = 9;
  1310.                   if (strcmp(ver_str,"1.8") == 0) err_code = 10;
  1311.                   if (strcmp(ver_str,"1.9") == 0) err_code = 11;
  1312.                   if (strcmp(ver_str,"1.25") == 0) err_code = 31;
  1313.                   if (strcmp(ver_str,"1.2Z") == 0) err_code = 30;
  1314.                   if (strcmp(ver_str,"][P") == 0) err_code = 19;
  1315.                   if (strcmp(ver_str,"][1.666") == 0) err_code = 21;
  1316.                   if (strcmp(ver_str,"][1.7") == 0) err_code = 22;
  1317.                   if (strcmp(ver_str,"][1.7A") == 0) err_code = 23;
  1318.                   if (strcmp(ver_str,"][1.8") == 0) err_code = 24;
  1319.                   if (strcmp(ver_str,"][1.9") == 0) err_code = 25;
  1320.                   if (!quiet)
  1321.                   {
  1322.                     if (ver_str[0] == '1')
  1323.                     {
  1324.                       if (!min_switch) printf("\n\nYou have t");
  1325.                       else printf("\nT");
  1326.                       printf("he ");
  1327.                       if (wadsize > 6000000) printf("registered");
  1328.                       else printf("shareware");
  1329.                       printf(" version %s of DOOM.",ver_str);
  1330.                     } else
  1331.                     {
  1332.                       if (!min_switch) printf("\n\nYou have v");
  1333.                       else printf("\nV");
  1334.                       if (ver_str[2] == 'P' || ver_str[2] == 'p')
  1335.                           printf("ersion 1.666 of DOOM ][ pirated!");
  1336.                       else
  1337.                           printf("ersion %s of DOOM ][.",ver_str+2);
  1338.                     }
  1339.                   }
  1340.                 }
  1341.               }
  1342.             }
  1343.             break;
  1344.         case 'V':
  1345.             argpass[2] = strupr(argpass[2]);
  1346.             if (!valid_version(argpass[2]))
  1347.             {
  1348.                 if (!quiet)
  1349.                 {
  1350.                     printf("\n\n*** ERROR, Please use one of the following for the DOOMVersion number:");
  1351.                     printf("\n***        1.0, 1.1, 1.2, 1.4, 1.5, 1.6, 1.666, 1.7, 1.7a, 1.8, 1.9");
  1352.                     printf("\n***        ][P, ][1.666, ][1.7, ][1.7a, ][1.8, ][1.9, 1.25, or 1.2Z!");
  1353.                     if (do_bells) printf("\a");
  1354.                     err_code = 255;
  1355.                     r_error();
  1356.                 }
  1357.             }
  1358.             if (argpass[2][0] == ']' || argpass[2][0] == '2')
  1359.             {
  1360.                 wadsize = aDir[DOOM2WAD].size;
  1361.                 waddate = strdosdate(aDir[DOOM2WAD].wr_date);
  1362.                 wadtime = strdostime(aDir[DOOM2WAD].wr_time);
  1363.                 wadnum = DOOM2WAD;
  1364.                 exesize = aDir[DOOM2EXE].size;
  1365.                 exedate = strdosdate(aDir[DOOM2EXE].wr_date);
  1366.                 exetime = strdostime(aDir[DOOM2EXE].wr_time);
  1367.                 exenum = DOOM2EXE;
  1368.                 if (wadsize == 0) error_message("no DOOM2.WAD file");
  1369.                 if (exesize == 0) error_message("no DOOM2.EXE file");
  1370.             } else
  1371.             {
  1372.                 if (more_than_one && wadsize == 0)
  1373.                 {
  1374.                     wadsize = aDir[DOOM1WAD].size;
  1375.                     waddate = strdosdate(aDir[DOOM1WAD].wr_date);
  1376.                     wadtime = strdostime(aDir[DOOM1WAD].wr_time);
  1377.                     wadnum = DOOM1WAD;
  1378.                 }
  1379.                 if (wadsize == 0) error_message("no DOOM[1].WAD file");
  1380.                 if (exesize == 0) error_message("no DOOM.EXE file");
  1381.             }
  1382.             int is_it = isitver(argpass[2]);
  1383.             if (!is_it && more_than_one && argpass[2][0]=='1' &&
  1384.                 aDir[DOOM1WAD].size > 0)
  1385.             {
  1386.                 if (debug_on)
  1387.                 {
  1388.                     printf("\n\nThere is a DOOM.WAD and a DOOM1.WAD! Since it isn't the registered version");
  1389.                     printf("\nof %s, I will now check the shareware version.",argpass[2]);
  1390.                 }
  1391.                 wadsize = aDir[DOOM1WAD].size;
  1392.                 waddate = strdosdate(aDir[DOOM1WAD].wr_date);
  1393.                 wadtime = strdostime(aDir[DOOM1WAD].wr_time);
  1394.                 wadnum = DOOM1WAD;
  1395.                 is_it = isitver(argpass[2]);
  1396.             }
  1397.             t = argpass[2];
  1398.             if (is_it)
  1399.             {
  1400.                 if (!quiet)
  1401.                 {
  1402.                     if (t[0] == ']')
  1403.                     {
  1404.                         if (t[2] == 'P')
  1405.                             printf("\n\nIt is the pirate copy of DOOM ][");
  1406.                         else
  1407.                             printf("\n\nIt is DOOM ][ version %s",t+2);
  1408.                     }
  1409.                     else
  1410.                         printf("\n\nIt is DOOM 1 version %s",t);
  1411.                 }
  1412.                 if (wadsize < 6000000L) err_code = 2;
  1413.             } else
  1414.             {
  1415.                 if (!quiet)
  1416.                 {
  1417.                     if (t[0] == ']')
  1418.                     {
  1419.                         if (t[2] == 'P')
  1420.                             printf("\n\nIt isn't the pirate copy of DOOM ][");
  1421.                         else
  1422.                             printf("\n\nIt isn't DOOM ][ version %s",t+2);
  1423.                     }
  1424.                     else
  1425.                         printf("\n\nIt isn't DOOM 1 version %s",t);
  1426.                 }
  1427.                 err_code = 255;
  1428.             }
  1429.             if (!quiet)
  1430.             {
  1431.                 if (argpass[2][0] != ']')
  1432.                 {
  1433.                     if (wadsize > 6000000L)
  1434.                         printf(" registered.");
  1435.                     else
  1436.                         printf(" shareware.");
  1437.                 } else
  1438.                     printf(".");
  1439.             }
  1440.             break;
  1441.         case 'D':
  1442.             err_code = 0;
  1443.             if (strlen(argpass[2]) == 0) wrong_parameter("No file name given");
  1444.             s = argpass[3];
  1445.             if (stricmp(s,"NOW")==0)
  1446.             {
  1447.                 if (debug_on) printf("\n\nSetting date to %s and time to %s...",
  1448.                     today_date,today_time);
  1449.                 argpass[3] = today_date;
  1450.                 argpass[3][2] = '-';
  1451.                 argpass[3][5] = '-';
  1452.                 if ((today_time[7]/2)*2 != today_time[7])
  1453.                 {
  1454.                     today_time[7] = today_time[7]+1;
  1455.                     if (today_time[7]>'9')
  1456.                         today_time[7] = '8';
  1457.                     if (debug_on) printf(
  1458.                         "\nSeconds were odd, ressetting time to %s...",
  1459.                         today_time);
  1460.                 }
  1461.                 argpass[4] = today_time;
  1462.             }
  1463.             if (strlen(argpass[4]) == 0 && strlen(argpass[3]) != 0)
  1464.                 wrong_parameter("No time given");
  1465.             if (atoi(argpass[4]) == 0 && argpass[4][2] != ':' &&
  1466.                 strlen(argpass[3]) != 0)
  1467.                 wrong_parameter("Time must be in HH:MM:SS format");
  1468.             if (atoi(argpass[3]) == 0 && strlen(argpass[4]) != 0)
  1469.                 wrong_parameter("Date must be in MM-DD-YY format");
  1470.             struct find_t files;
  1471.             int found_file = (_dos_findfirst(argpass[2],_ATTRIBUTES_,&files) == 0);
  1472.             char *last_file = "filename.ext";
  1473.             strcpy(last_file,files.name);
  1474.             if (!found_file) error_message(strcat("couldn't find file(s) matching ",argpass[2]));
  1475.             int first_line = TRUE;
  1476.             int cant_change = FALSE;
  1477.             int cant_open = FALSE;
  1478.             char *new_date = argpass[3];
  1479.             char *new_time = argpass[4];
  1480.             struct ftime ftd;
  1481.             while (found_file)
  1482.             {
  1483.                 stream = fopen(last_file,"r");
  1484.                 if (stream == NULL)
  1485.                 {
  1486.                     cant_change = TRUE;
  1487.                     cant_open = TRUE;
  1488.                     err_code = 255;
  1489.                 } else
  1490.                 {
  1491.                     stream = fopen(last_file,"r+b");
  1492.                     if (stream == NULL)
  1493.                         cant_change = TRUE;
  1494.                 }
  1495.                 if (strlen(argpass[3]) == 0)
  1496.                 {
  1497.                     if (cant_open)
  1498.                     {
  1499.                         new_date = "01/01/94";
  1500.                         new_time = "00:00:00";
  1501.                     } else
  1502.                     {
  1503.                         new_date = strdosdate(files.wr_date);
  1504.                         new_time = strdostime(files.wr_time);
  1505.                     }
  1506.                 } else
  1507.                 {
  1508.                     new_date = argpass[3];
  1509.                     new_time = argpass[4];
  1510.                 }
  1511.                 if (((new_date[2] != '-' && new_date[2] != '/') ||
  1512.                     (new_date[5] != '-' && new_date[5] != '/')) &&
  1513.                     !cant_change)
  1514.                     error_message("invalid date, use MM-DD-YY");
  1515.                 if ((new_time[2] != ':' || new_time[5] != ':') &&
  1516.                     !cant_change)
  1517.                     error_message("invalid time, use HH:MM:SS");
  1518.                 month = atoi(new_date);
  1519.                 day = atoi(new_date+3);
  1520.                 year = atoi(new_date+6);
  1521.                 hour = atoi(new_time);
  1522.                 minute = atoi(new_time+3);
  1523.                 second = atoi(new_time+6);
  1524.                 if ((!isdigit(new_date[0]) || !isdigit(new_date[1]) ||
  1525.                     !isdigit(new_date[3]) || !isdigit(new_date[4]) ||
  1526.                     !isdigit(new_date[6]) || !isdigit(new_date[7]) ||
  1527.                     strlen(new_date)!=8) && !cant_change)
  1528.                     error_message("invalid date, use MM-DD-YY");
  1529.                 if ((!isdigit(new_time[0]) || !isdigit(new_time[1]) ||
  1530.                     !isdigit(new_time[3]) || !isdigit(new_time[4]) ||
  1531.                     !isdigit(new_time[6]) || !isdigit(new_time[7]) ||
  1532.                     strlen(new_time)!=8) && !cant_change)
  1533.                     error_message("invalid time, use HH:MM:SS");
  1534.                 s = strdosdate(files.wr_date);
  1535.                 if ((month < 1 || month >12) && !cant_change)
  1536.                     error_message("invalid month");
  1537.                 if ((day < 1 || day > 31) && !cant_change)
  1538.                     error_message("invalid day");
  1539.                 if ((hour < 0 || hour > 23) && !cant_change)
  1540.                     error_message("invalid hours");
  1541.                 if ((minute < 0 || minute > 59) && !cant_change)
  1542.                     error_message("invalid minutes");
  1543.                 if ((second < 0 || second > 59) && !cant_change)
  1544.                     error_message("invalid seconds");
  1545.                 if (second != (second/2)*2)
  1546.                     error_message("can't set time to odd seconds");
  1547.                 if (!quiet && first_line)
  1548.                 {
  1549.                     printf("\n");
  1550.                     first_line = FALSE;
  1551.                 }
  1552.                 if (!quiet) printf("\nFile:%12s   ",files.name);
  1553.                 if ((strcmp(s,new_date) != 0) ||
  1554.                     strcmp(strdostime(files.wr_time),new_time) != 0)
  1555.                 {
  1556.                     if (!cant_change)
  1557.                         _dos_setftime(fileno(stream),todosdate(new_date),
  1558.                         todostime(new_time));
  1559.                 }
  1560.                 if (!quiet)
  1561.                 {
  1562.                     if (cant_change && !cant_open &&
  1563.                         (strcmp(strdosdate(files.wr_date),new_date) != 0 ||
  1564.                         strcmp(strdostime(files.wr_time),new_time) != 0))
  1565.                     {
  1566.                         printf("date:%s *Read only!* time:%s *Can't change!*",
  1567.                             strdosdate(files.wr_date),strdostime(files.wr_time));
  1568.                         err_code = 255;
  1569.                     } else if (!cant_open)
  1570.                     {
  1571.                         if (strcmp(strdosdate(files.wr_date),new_date))
  1572.                             printf("date:%s->%s    time:",strdosdate(files.wr_date),new_date);
  1573.                         else
  1574.                             printf("date:%s              time:",new_date);
  1575.                         if (strcmp(strdostime(files.wr_time),new_time))
  1576.                         {
  1577.                             printf("%s->%s.",strdostime(files.wr_time),new_time);
  1578.                         }
  1579.                         else
  1580.                             printf("%s.",new_time);
  1581.                     } else
  1582.                     {
  1583.                         printf("date: *Can't open file!*   time: *Unknown!*");
  1584.                     }
  1585.                 }
  1586.                 fcloseall();
  1587.                 found_file = (_dos_findnext(&files) == 0);
  1588.                 strcpy(last_file,files.name);
  1589.                 s = files.name;
  1590.                 cant_change = FALSE;
  1591.                 cant_open = FALSE;
  1592.             }
  1593.             break;
  1594.         case 'F':
  1595.             if (strlen(argpass[2]) == 0) wrong_parameter("no filename given");
  1596.             stream = fopen(argpass[2],"r");
  1597.             fcloseall();
  1598.             if (stream == NULL)
  1599.                 error_message(strcat("problem accessing file ",argpass[2]));
  1600.             struct find_t fileblock;
  1601.             _dos_findfirst(argpass[2],_ATTRIBUTES_,&fileblock);
  1602.             if (strlen(argpass[3]) != 0)
  1603.             {
  1604.                 p = strchr(argpass[3],',');
  1605.                 if (p==0)
  1606.                     j = 0;
  1607.                 else
  1608.                     j = p - argpass[3];
  1609.                 while (j > 0)
  1610.                 {
  1611.                     s = strncpy(argpass[3],argpass[3],j);
  1612.                     s[j] = '\0';
  1613.                     argpass[3] = strcat(s,argpass[3]+j+1);
  1614.                     p = strchr(argpass[3],',');
  1615.                     if (p==0)
  1616.                         j = 0;
  1617.                     else
  1618.                         j = p - argpass[3];
  1619.                 }
  1620.                 filesize = atol(argpass[3]);
  1621.                 s = "12345678901234567890";
  1622.                 if (strlen(argpass[3]) != sprintf(s,"%li",filesize))
  1623.                     wrong_parameter("invalid file size");
  1624.             }
  1625.             filedate = argpass[4];
  1626.             filetime = argpass[5];
  1627.             if (filesize < 0) wrong_parameter("can't check negative bytes");
  1628.             if (strlen(filedate) == 0)
  1629.                 filedate = strdosdate(fileblock.wr_date);
  1630.             if (strlen(filetime) == 0)
  1631.                 filetime = strdostime(fileblock.wr_time);
  1632.             if (filesize == 0)
  1633.                 filesize = fileblock.size;
  1634.             if ((filedate[2] != '-' && filedate[2] != '/') ||
  1635.                 (filedate[5] != '-' && filedate[5] != '/'))
  1636.                 error_message("invalid date, use MM-DD-YY");
  1637.             if (filetime[2] != ':' || filetime[5] != ':')
  1638.                 error_message("invalid time, use HH:MM:SS");
  1639.             month = atoi(filedate);
  1640.             day = atoi(filedate+3);
  1641.             year = atoi(filedate+6);
  1642.             hour = atoi(filetime);
  1643.             minute = atoi(filetime+3);
  1644.             second = atoi(filetime+6);
  1645.             if (!isdigit(filedate[0]) || !isdigit(filedate[1]) ||
  1646.                 !isdigit(filedate[3]) || !isdigit(filedate[4]) ||
  1647.                 !isdigit(filedate[6]) || !isdigit(filedate[7]) ||
  1648.                 strlen(filedate)!=8)
  1649.                 error_message("invalid date, use MM-DD-YY");
  1650.             if (!isdigit(filetime[0]) || !isdigit(filetime[1]) ||
  1651.                 !isdigit(filetime[3]) || !isdigit(filetime[4]) ||
  1652.                 !isdigit(filetime[6]) || !isdigit(filetime[7]) ||
  1653.                 strlen(filetime)!=8)
  1654.                 error_message("invalid time, use HH:MM:SS");
  1655.             if (month < 1 || month >12)
  1656.                 error_message("invalid month");
  1657.             if (day < 1 || day > 31)
  1658.                 error_message("invalid day");
  1659.             if (hour < 0 || hour > 23)
  1660.                 error_message("invalid hours");
  1661.             if (minute < 0 || minute > 59)
  1662.                 error_message("invalid minutes");
  1663.             if (second < 0 || second > 59)
  1664.                 error_message("invalid seconds");
  1665.             if (second != (second/2)*2)
  1666.                 error_message("files can't have odd seconds");
  1667.             if (debug_on)
  1668.                 printf("\n\nFile:%13s   size:%s   date:%s   time:%s",
  1669.                     fileblock.name,
  1670.                     strcommas(fileblock.size),
  1671.                     strdosdate(fileblock.wr_date),
  1672.                     strdostime(fileblock.wr_time));
  1673.             else
  1674.             {
  1675.                 if (!quiet)
  1676.                     printf("\n");
  1677.             }
  1678.             if (filesize == fileblock.size &&
  1679.                 strcmp(filedate,strdosdate(fileblock.wr_date)) == 0 &&
  1680.                 strcmp(filetime,strdostime(fileblock.wr_time)) == 0)
  1681.             {
  1682.                 if (!quiet) printf("\nFile %s matches criteria.",argpass[2]);
  1683.                 err_code = 0;
  1684.             }
  1685.             else
  1686.             {
  1687.                 if (!quiet) printf("\nFile %s does not match criteria!",argpass[2]);
  1688.                 err_code = 1;
  1689.             }
  1690.             break;
  1691.         default:
  1692.             s = " ";
  1693.             s[0] = i;
  1694.             wrong_parameter(strcat("Unknown function ",s));
  1695.     }
  1696.     r_error();
  1697. }
  1698.