home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / fst03f.zip / diskio.h < prev    next >
C/C++ Source or Header  |  1996-01-09  |  4KB  |  121 lines

  1. /* diskio.h -- Header file for diskio.c
  2.    Copyright (c) 1995-1996 by Eberhard Mattes
  3.  
  4. This file is part of fst.
  5.  
  6. fst is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. fst is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with fst; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* Bits for diskio_open()'s FLAG argument and diskio_type()'s return
  23.    value. */
  24.  
  25. #define DIO_DISK        0x01    /* Direct disk access */
  26. #define DIO_SNAPSHOT    0x02    /* Snapshot file */
  27. #define DIO_CRC         0x04    /* CRC file */
  28.  
  29. /* Hide the implementation of DISKIO. */
  30.  
  31. struct diskio;
  32. typedef struct diskio DISKIO;
  33.  
  34. /* Type of the save file. */
  35.  
  36. enum save_type
  37. {
  38.   SAVE_RAW,
  39.   SAVE_SNAPSHOT,
  40.   SAVE_CRC
  41. };
  42.  
  43. /* Method for accessing the disk. */
  44.  
  45. enum access_type
  46. {
  47.   ACCESS_DASD,                  /* DosRead, DosWrite */
  48.   ACCESS_LOG_TRACK              /* Logical: DSK_READTRACK, DSK_WRITETRACK */
  49. };
  50.  
  51. /* Magic numbers for various file types. */
  52.  
  53. #define CRC_MAGIC               0xac994df4
  54. #define SNAPSHOT_MAGIC          0xaf974803
  55.  
  56. /* XOR the first 32-bit word of a save file with this value. */
  57.  
  58. #define SNAPSHOT_SCRAMBLE       0x551234af
  59.  
  60.  
  61. /* This header is used for snapshot files and CRC files. */
  62.  
  63. typedef union
  64. {
  65.   BYTE raw[512];                /* Force the header size to 512 bytes */
  66.   ULONG magic;                  /* Magic number */
  67.   struct
  68.     {
  69.       ULONG magic;              /* Magic number */
  70.       ULONG sector_count;       /* Number of sectors in the snapshot */
  71.       ULONG map_pos;            /* Relative byte address of the sector table */
  72.       ULONG version;            /* Format version number */
  73.     } s;                        /* Header for snapshot file */
  74.   struct
  75.     {
  76.       ULONG magic;              /* Magic number */
  77.       ULONG sector_count;       /* Number of sectors (CRCs) in the snapshot */
  78.       ULONG version;            /* Format version number */
  79.     } c;                        /* Header for CRC file */
  80. } header;
  81.  
  82. typedef struct
  83. {
  84.   ULONG cyl;
  85.   ULONG head;
  86.   ULONG sec;
  87. } cyl_head_sec;
  88.  
  89. /* See diskio.c */
  90. extern enum access_type diskio_access;
  91. extern char write_enable;
  92. extern char removable_allowed;
  93. extern char ignore_lock_error;
  94. extern char dont_lock;
  95.  
  96. extern enum save_type save_type;
  97. extern FILE *save_file;
  98. extern const char *save_fname;
  99. extern ULONG save_sector_count;
  100. extern ULONG save_sector_alloc;
  101. extern ULONG *save_sector_map;
  102.  
  103.  
  104. /* See diskio.c */
  105. DISKIO *diskio_open (PCSZ fname, unsigned flags, int for_write);
  106. void diskio_close (DISKIO *d);
  107. unsigned diskio_type (DISKIO *d);
  108. ULONG diskio_total_sectors (DISKIO *d);
  109. ULONG diskio_snapshot_sectors (DISKIO *d);
  110. ULONG *diskio_snapshot_sort (DISKIO *d);
  111. void diskio_crc_load (DISKIO *d);
  112. int diskio_cyl_head_sec (DISKIO *d, cyl_head_sec *dst, ULONG secno);
  113. void save_sec (const void *src, ULONG sec, ULONG count);
  114. void save_create (const char *avoid_fname, enum save_type type);
  115. void save_error (void);
  116. void save_close (void);
  117. ULONG find_sec_in_snapshot (DISKIO *d, ULONG n);
  118. void read_sec (DISKIO *d, void *dst, ULONG sec, ULONG count, int save);
  119. int crc_sec (DISKIO *d, crc_t *pcrc, ULONG secno);
  120. int write_sec (DISKIO *d, const void *src, ULONG sec);
  121.