home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / pas_sdk1 / pas / cdromapp / cdstatus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-21  |  1.9 KB  |  114 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4.  
  5. #define OKAY 0
  6.  
  7. #include "cdmaster.h"
  8.  
  9. char *syntax= "Syntax: cdstatus [drive #].\n";
  10. char *nodrives= "No CDROM drives attached.\n";
  11. char *nomscdex= "MSCDEX is not installed.\n";
  12.  
  13. int SPECIFIEDIT;
  14. char cdu[26];
  15.  
  16. main(int argc, char **argv)
  17. {
  18.     int numcdroms= 0;
  19.     int ourdrive= 0;
  20.     struct cdtable *cdt;
  21.  
  22.     if (!ismscdex())
  23.         {
  24.         fprintf(stderr, nomscdex);
  25.         return(1);
  26.         }
  27.  
  28.     if (!(numcdroms= getnumcdroms()))
  29.         {
  30.         fprintf(stderr, nodrives);
  31.         return(2);
  32.         }
  33.  
  34.     getcdromunits(cdu);
  35.  
  36.     switch (argc)
  37.         {
  38.         case 2:
  39.             SPECIFIEDIT= 1;
  40.             if (!(ourdrive= atoi(argv[1])))
  41.                 {
  42.                 fprintf(stderr, syntax);
  43.                 return(3);
  44.                 }
  45.             break;
  46.  
  47.         case 1:
  48.             if (!(ourdrive= getfirstcdrom()))
  49.                 {
  50.                 fprintf(stderr, nodrives);
  51.                 return(4);
  52.                 }
  53.             break;
  54.  
  55.         default:
  56.             fprintf(stderr, syntax);
  57.             return(5);
  58.         }
  59.  
  60.     if (SPECIFIEDIT)
  61.         {
  62.         printf("status drive: %2d ", ourdrive);
  63.  
  64.         if (cdt= createaudiotoc(ourdrive))
  65.             {
  66.             int status= cdstatus(ourdrive);
  67.             if (!status)
  68.                 printf("nonexistent.\n");
  69.             else
  70.                 printf("= %X: Playing: %s, Paused: %s.\n",
  71.                     status,
  72.                     status& CDISPLAYING ? "yes" : "no",
  73.                     status& CDISPAUSED ? "yes" : "no");
  74.             destroyaudiotoc(ourdrive);
  75.             }
  76.         else
  77.             printf("failed, no initialization.\n");
  78.         return(OKAY);
  79.         }
  80.  
  81.         {
  82.         int i;
  83.  
  84.         for (i= 0; i < 26; i++)
  85.             {
  86.             if (cdu[i])
  87.                 {
  88.                 ourdrive= (int) cdu[i];
  89.                 printf("status drive: %2d ", ourdrive);
  90.  
  91.                 if (cdt= createaudiotoc(ourdrive))
  92.                     {
  93.                     int status= cdstatus(ourdrive);
  94.                     if (!status)
  95.                         printf("nonexistent.\n");
  96.                     else
  97.                         printf("= %X: Playing: %s, Paused: %s.\n",
  98.                             status,
  99.                             status& CDISPLAYING ? "yes" : "no",
  100.                             status& CDISPAUSED ? "yes" : "no");
  101.                     destroyaudiotoc(ourdrive);
  102.                     }
  103.                 else
  104.                     printf("failed, no initialization.\n");
  105.                 }
  106.             }
  107.         }
  108.  
  109.     
  110.  
  111.     return(OKAY);
  112. }
  113.  
  114.