home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / cpmsim / srccpm / format.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-11  |  1.1 KB  |  51 lines

  1. /*
  2.  * CP/M 2.2 Formats a simulated Disk Drive
  3.  *
  4.  * Copyright (C) 1988-93 by Udo Munk
  5.  *
  6.  * History:
  7.  * 29-APR-88 Development on TARGON/35 with AT&T Unix System V.3
  8.  * 11-MAR-93 comments in english
  9.  */
  10.  
  11. #include <stdio.h>
  12. #ifndef COHERENT
  13. #include <memory.h>
  14. #endif
  15.  
  16. #define TRACK   77
  17. #define SECTOR  26
  18.  
  19. /*
  20.  *      This program is able to format the following disk formats:
  21.  *
  22.  *              drive A:        8" IBM SS,SD
  23.  *              drive B:        8" IBM SS,SD
  24.  *              drive C:        8" IBM SS,SD
  25.  *              drive D:        8" IBM SS,SD
  26.  */
  27. main(argc, argv)
  28. int argc;
  29. char *argv[];
  30. {
  31.     void exit();
  32.     register int i;
  33.     register int fd;
  34.     static unsigned char sector[128];
  35.     static char fn[] = "../disks/drive?.cpm";
  36.     static char usage[] = "usage: format a | b | c | d";
  37.  
  38.     i = *argv[1];
  39.     if (argc != 2 || (i != 'a' && i != 'b' && i != 'c' && i != 'd')) {
  40.         puts(usage);
  41.         exit(1);
  42.     }
  43.     fn[14] = (char) i;
  44.     memset((char *) sector, 0xe5, 128);
  45.     fd = creat(fn, 0644);
  46.     for (i = 0; i < TRACK * SECTOR; i++)
  47.         write(fd, (char *) sector, 128);
  48.     close(fd);
  49.     exit(0);
  50. }
  51.