home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / rawfile.h < prev    next >
C/C++ Source or Header  |  1994-08-06  |  7KB  |  245 lines

  1. /*      RAWFILE.H
  2.  *
  3.  * Raw file I/O for MIDAS Sound System
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. */
  13.  
  14.  
  15. #ifndef __RAWFILE_H
  16. #define __RAWFILE_H
  17.  
  18.  
  19. #ifndef FILE
  20. #include <stdio.h>
  21. #endif
  22.  
  23.  
  24. /****************************************************************************\
  25. *       struct rfFile
  26. *       -------------
  27. * Description:  File state structure
  28. \****************************************************************************/
  29.  
  30. typedef struct
  31. {
  32.     FILE        *f;
  33. } rfFile;
  34.  
  35.  
  36.  
  37.  
  38. /****************************************************************************\
  39. *       typedef rfHandle;
  40. *       -----------------
  41. * Description: Raw file I/O file handle
  42. \****************************************************************************/
  43.  
  44. typedef rfFile* rfHandle;
  45.  
  46.  
  47.  
  48. /****************************************************************************\
  49. *       enum rfOpenMode
  50. *       ---------------
  51. * Description:  File opening mode. Used by rfOpen()
  52. \****************************************************************************/
  53.  
  54. enum rfOpenMode
  55. {
  56.     rfOpenRead = 1,                     /* open file for reading */
  57.     rfOpenWrite = 2,                    /* open file for writing */
  58.     rfOpenReadWrite = 3                 /* open file for both reading and
  59.                                            writing */
  60. };
  61.  
  62.  
  63.  
  64. /****************************************************************************\
  65. *       enum rfSeekMode
  66. *       ---------------
  67. * Description:  File seeking mode. Used by rfSeek()
  68. \****************************************************************************/
  69.  
  70. enum rfSeekMode
  71. {
  72.     rfSeekAbsolute = 1,                 /* seek to an absolute position from
  73.                                            the beginning of the file */
  74.     rfSeekRelative = 2,                 /* seek to a position relative to
  75.                                            current position */
  76.     rfSeekEnd = 3                       /* relative to the end of file */
  77. };
  78.  
  79.  
  80.  
  81. #ifdef __cplusplus
  82. extern "C" {
  83. #endif
  84.  
  85.  
  86. /****************************************************************************\
  87. *
  88. * Function:     int rfOpen(char *fileName, int openMode, rfHandle *file);
  89. *
  90. * Description:  Opens a file for reading or writing
  91. *
  92. * Input:        char *fileName          name of file
  93. *               int openMode            file opening mode, see enum rfOpenMode
  94. *               rfHandle *file          pointer to file handle
  95. *
  96. * Returns:      MIDAS error code.
  97. *               File handle is stored in *file.
  98. *
  99. \****************************************************************************/
  100.  
  101. int CALLING rfOpen(char *fileName, int openMode, rfHandle *file);
  102.  
  103.  
  104.  
  105.  
  106. /****************************************************************************\
  107. *
  108. * Function:     int rfClose(rfHandle file);
  109. *
  110. * Description:  Closes a file opened with rfOpen().
  111. *
  112. * Input:        rfHandle file           handle of an open file
  113. *
  114. * Returns:      MIDAS error code
  115. *
  116. \****************************************************************************/
  117.  
  118. int CALLING rfClose(rfHandle file);
  119.  
  120.  
  121.  
  122.  
  123. /****************************************************************************\
  124. *
  125. * Function:     int rfGetSize(rfHandle file, long *fileSize);
  126. *
  127. * Description:  Get the size of a file
  128. *
  129. * Input:        rfHandle file           handle of an open file
  130. *               ulong *fileSize         pointer to file size
  131. *
  132. * Returns:      MIDAS error code.
  133. *               File size is stored in *fileSize.
  134. *
  135. \****************************************************************************/
  136.  
  137. int CALLING rfGetSize(rfHandle file, long *fileSize);
  138.  
  139.  
  140.  
  141.  
  142. /****************************************************************************\
  143. *
  144. * Function:     int rfRead(rfHandle file, void *buffer, ulong numBytes);
  145. *
  146. * Description:  Reads binary data from a file
  147. *
  148. * Input:        rfHandle file           file handle
  149. *               void *buffer            reading buffer
  150. *               ulong numBytes          number of bytes to read
  151. *
  152. * Returns:      MIDAS error code.
  153. *               Read data is stored in *buffer, which must be large enough
  154. *               for it.
  155. *
  156. \****************************************************************************/
  157.  
  158. int CALLING rfRead(rfHandle file, void *buffer, ulong numBytes);
  159.  
  160.  
  161.  
  162.  
  163. /****************************************************************************\
  164. *
  165. * Function:     int rfWrite(rfHandle file, void *buffer, ulong numBytes);
  166. *
  167. * Description:  Writes binary data to a file
  168. *
  169. * Input:        rfHandle file           file handle
  170. *               void *buffer            pointer to data to be written
  171. *               ulong numBytes          number of bytes to write
  172. *
  173. * Returns:      MIDAS error code
  174. *
  175. \****************************************************************************/
  176.  
  177. int CALLING rfWrite(rfHandle file, void *buffer, ulong numBytes);
  178.  
  179.  
  180.  
  181.  
  182. /****************************************************************************\
  183. *
  184. * Function:     int rfSeek(rfHandle file, long newPosition, int seekMode);
  185. *
  186. * Description:  Seeks to a new position in file. Subsequent reads and writes
  187. *               go to the new position.
  188. *
  189. * Input:        rfHandle file           file handle
  190. *               long newPosition        new file position
  191. *               int seekMode            file seek mode, see enum rfSeekMode
  192. *
  193. * Returns:      MIDAS error code
  194. *
  195. \****************************************************************************/
  196.  
  197. int CALLING rfSeek(rfHandle file, long newPosition, int seekMode);
  198.  
  199.  
  200.  
  201.  
  202. /****************************************************************************\
  203. *
  204. * Function:     int rfGetPosition(rfHandle file, long *position);
  205. *
  206. * Description:  Reads the current position in a file
  207. *
  208. * Input:        rfHandle file           file handle
  209. *               long *position          pointer to file position
  210. *
  211. * Returns:      MIDAS error code.
  212. *               Current file position is stored in *position.
  213. *
  214. \****************************************************************************/
  215.  
  216. int CALLING rfGetPosition(rfHandle file, long *position);
  217.  
  218.  
  219.  
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223.  
  224.  
  225.  
  226. /****************************************************************************\
  227. *       enum rfFunctIDs
  228. *       ---------------
  229. * Description:  ID numbers for raw file I/O functions
  230. \****************************************************************************/
  231.  
  232. enum rfFunctIDs
  233. {
  234.     ID_rfOpen = ID_rf,
  235.     ID_rfClose,
  236.     ID_rfGetSize,
  237.     ID_rfRead,
  238.     ID_rfWrite,
  239.     ID_rfSeek,
  240.     ID_rfGetPosition
  241. };
  242.  
  243.  
  244. #endif
  245.