home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / SNPD9404.ZIP / SETVOL.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  2KB  |  107 lines

  1. .I 10 1
  2. #include <ctype.h>
  3. .I 12 1
  4. #include "portable.h"         /* Also in SNIPPETS     */
  5. .I 18 1
  6.  #include <io.h>
  7. .D 19 3
  8. .I 22 1
  9.  #define _far far
  10. .D 23 6
  11. .D 35 8
  12. .I 67 2
  13. **  NOTE: The following use functions in four other SNIPPETS files,
  14. **        ABSDISK.ASM, ABSDISKC.C, DRVALID.C, and PUSHDIR.C
  15. .D 68 2
  16. .I 73 3
  17. int getdrv(void);
  18. int PushDir(char *);
  19. int PopDir(void);
  20. .D 113 1
  21. .I 114 5
  22.       struct xfcb buf;
  23.       union REGS regs;
  24.       struct SREGS sregs;
  25.       const char pattern[] = "????????";
  26.       char _far *dta;
  27. .D 115 2
  28. .I 119 3
  29.       */
  30.       
  31.       PushDir("\\");
  32. .D 120 6
  33. .I 128 32
  34.       segread(&sregs);
  35.       regs.h.ah = 0x2f;
  36.       intdosx(®s, ®s, &sregs);
  37.       dta = MK_FP(sregs.es, regs.x.bx);
  38.       
  39.       buf.xfcb_flag = 0xff;
  40.       buf.xfcb_attr = _A_VOLID;
  41.       buf.xfcb_fcb.fcb_drive = 0;
  42.       memcpy(buf.xfcb_fcb.fcb_name, pattern, 8);
  43.       memcpy(buf.xfcb_fcb.fcb_ext, pattern, 3);
  44.  
  45.       regs.h.ah = 0x11;
  46.       regs.x.dx = (unsigned)&buf;
  47.       intdos(®s, ®s);
  48.  
  49.       if (0 == regs.h.al)
  50.       {
  51.             int i;
  52.             char oldlabel[13], _far *p, *q;
  53.  
  54.             for (i = 0, p = dta + 8, q =oldlabel; i < 8; ++i, ++p, ++q)
  55.             {
  56.                   *q = *p;
  57.             }
  58.             *q++ = '.';
  59.             for (i = 0, p = dta + 16; i < 3; ++i, ++p, ++q)
  60.             {
  61.                   *q = *p;
  62.             }
  63.             vol_kill(oldlabel);
  64.       }
  65.  
  66. .D 129 9
  67. .I 144 26
  68.       /* Parse the filename into an FCB               */
  69.  
  70.       segread(&sregs);
  71.       regs.h.ah = 0x29;
  72.       regs.h.al = 0;
  73.       regs.x.si = (unsigned)new_label;
  74.       regs.x.di = (unsigned)&buf.xfcb_fcb;
  75.       sregs.es  = sregs.ds;
  76.       intdosx(®s, ®s, &sregs);
  77.  
  78.       /* Volume labels require extended FCB's         */
  79.  
  80.       buf.xfcb_flag = 0xff;
  81.       buf.xfcb_attr = _A_VOLID;
  82.  
  83.       /* Create the new label                         */
  84.  
  85.       regs.h.ah = 0x16;
  86.       regs.x.dx = (unsigned)&buf;
  87.       intdos(®s, ®s);
  88.  
  89.       /* Close the new label                          */
  90.  
  91.       regs.h.ah = 0x10;
  92.       regs.x.dx = (unsigned)&buf;
  93.       intdos(®s, ®s);
  94. .D 145 2
  95. .I 153 1
  96.             int index, drive = getdrv();
  97. .D 154 1
  98. .I 156 1
  99.             AbsDiskRead(drive, 1, 0, &boot_record);
  100. .D 157 1
  101. .I 167 1
  102.                   AbsDiskWrite(drive, 1, 0, &boot_record);
  103. .D 168 1
  104. .I 170 1
  105.       PopDir();
  106. .D 171 3
  107.