home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1991 / 02 / tricks / gdi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-06  |  4.1 KB  |  128 lines

  1. /* ------------------------------------------------------ */
  2. /*                      GDI.C                             */
  3. /*                 Diskinformation                        */
  4. /*         (C) 1991  Michael Gruteser & TOOLBOX           */
  5. /* ------------------------------------------------------ */
  6. #include <stdio.h>
  7. #include <ctype.h>
  8. #include <dir.h>
  9. #include <dos.h>
  10. #include <errno.h>
  11. #include "lwinfo.h"
  12.  
  13. bootsec_info_t  lwinfo;
  14. struct fatinfo  fat;
  15. media_t         mdinfo;
  16.  
  17. main(int argc, char **argv) {
  18.  
  19. int  error;
  20. int  count;
  21. int  lw;
  22. int  nimmdisk();
  23. void ausgabe();
  24.  
  25.   printf ("Disketten Information ");
  26.   switch (argc) {
  27.     case 1  : lw = getdisk();
  28.               break;
  29.     case 2  : lw = nimmdisk(argv[1]);
  30.               break;
  31.     default : printf("Falsche Anzahl von Argumenten.\n");
  32.               exit(1);
  33.   }
  34.   count = 20;
  35.   do {
  36.     count--;
  37.     error = get_bootsecinfo(lw, &lwinfo);
  38.   }
  39.   while ((error != 0) && (count > 0));
  40.   if (error != EZERO) {
  41.     switch (errno) {
  42.       case EACCES  : printf("Zugriff verweigert.\n");
  43.                      break;
  44.       case EINVDRV : printf("Laufwerk nicht gültig.\n");
  45.                      break;
  46.       default      : printf("Allgemeiner Fehler.\n");
  47.     }
  48.     exit(1);
  49.   }
  50.   getfat (lw+1, &fat);
  51.   ausgabe(lw);
  52.   return 0;
  53. }
  54.  
  55. int nimmdisk(char *str) {
  56.  
  57. int error;
  58. int lw;
  59.  
  60.   error = 0;
  61.   if (strlen(str) != 2)
  62.     error = 1;
  63.   if (str[1] != ':')
  64.     error = 1;
  65.   if (error == 1) {
  66.     printf("Syntax-Error");
  67.     exit(1);
  68.   }
  69.   lw = toupper(str[0]) - 0x41;
  70.   return(lw);
  71. }
  72.  
  73. void  ausgabe(int lw) {
  74.  
  75.   printf("Informationen über das Laufwerk Nr.: %d   ");
  76.   printf("Bezeichnung : %c:\n", lw, lw+0x41);
  77.   printf("Information                              ");
  78.   printf("von DOS              vom BIOS\n");
  79.   printf("=========================================");
  80.   printf("===================================\n");
  81.   printf("System Identifikation                    ")
  82.   printf("                     %s\n", lwinfo.hersteller);
  83.   printf("Media Descriptor                         ");
  84.   printf("                     %x\n");
  85.   printf(lwinfo.mediadescriptor & 0xff));
  86.   printf("Bytes pro Sektor                         %-6d");
  87.   printf("               %-6d\n", fat.fi_bysec);
  88.   printf("lwinfo.bytes_pro_sektor);
  89.   printf("Sektoren pro Cluster                     %d");
  90.   printf("                    %d\n", fat.fi_sclus);
  91.   printf("lwinfo.sektoren_pro_cluster);
  92.   printf("Anzahl der FATs                            ");
  93.   printf("                   %d\n", lwinfo.fat_anzahl);
  94.   printf("Anzahl der Einträge H.-Verzeichnis         ");
  95.   printf("                   %-6d\n");
  96.   printf(lwinfo.root_dir_eintraege);
  97.   printf("Sektoren pro Fat                           ");
  98.   printf("                   %d\n",lwinfo.sektoren_pro_fat);
  99.   printf("Anzahl der Cluster                       %-6u\n");
  100.   printf(fat.fi_nclus);
  101.   printf("Anzahl der Sektoren                        ");
  102.   printf("                   %-6u\n",lwinfo.sektorenanzahl);
  103.   printf("Offset der Fat                             ");
  104.   printf("                   %d\n");
  105.   printf(lwinfo.reservierte_sektoren);
  106.   printf("Offset des H.-Verzeichnisses             %-6d\n",
  107.          lwinfo.reservierte_sektoren + lwinfo.fat_anzahl *
  108.          lwinfo.sektoren_pro_fat);
  109.   printf("Offset zu den Daten                      %-6d\n",
  110.       1+
  111.       32*lwinfo.root_dir_eintraege/lwinfo.bytes_pro_sektor+
  112.       lwinfo.sektoren_pro_fat *
  113.       lwinfo.fat_anzahl);
  114.   printf("Sektoren pro Spur                              ");
  115.   printf("               %-6d\n", lwinfo.sektoren_pro_spur);
  116.   printf("Anzahl der Seiten                              ");
  117.   printf("               %d\n", lwinfo.seiten);
  118.   printf("Versteckte Sektoren                            ");
  119.   printf("               %d\n", lwinfo.versteckte_sektoren);
  120.   printf("Fatgröße in Bit                                ");
  121.   printf("               %d\n");
  122.   printf(((lwinfo.sektorenanzahl/8) < 4086) ? 12 : 16);
  123.   printf("\n");
  124. }
  125.  
  126. /* ------------------------------------------------------ */
  127. /*                  Ende von GDI.C                        */
  128.