home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.5 / Examples / AsynchIO / asyncio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-30  |  2.6 KB  |  94 lines

  1. /*
  2.  * COPYRIGHT:
  3.  *
  4.  *   Unless otherwise noted, all files are Copyright (c) 1999 Amiga, Inc.
  5.  *   All rights reserved.
  6.  *
  7.  * DISCLAIMER:
  8.  *
  9.  *   This software is provided "as is". No representations or warranties
  10.  *   are made with respect to the accuracy, reliability, performance,
  11.  *   currentness, or operation of this software, and all use is at your
  12.  *   own risk. Neither Amiga nor the authors assume any responsibility
  13.  *   or liability whatsoever with respect to your use of this software.
  14.  */
  15.  
  16. #ifndef __ASYNCIO_H
  17. #define __ASYNCIO_H
  18.  
  19.  
  20. /*****************************************************************************/
  21.  
  22.  
  23. #ifndef EXEC_TYPES_H
  24. #include <exec/types.h>
  25. #endif
  26.  
  27. #ifndef EXEC_PORTS_H
  28. #include <exec/ports.h>
  29. #endif
  30.  
  31. #ifndef DOS_DOSEXTENS_H
  32. #include <dos/dosextens.h>
  33. #endif
  34.  
  35.  
  36. /*****************************************************************************/
  37.  
  38.  
  39. /* This structure is public only by necessity, don't muck with it yourself, or
  40.  * you're looking for trouble
  41.  */
  42. typedef struct AsyncFile
  43. {
  44.     BPTR                  af_File;
  45.     ULONG                 af_BlockSize;
  46.     struct MsgPort       *af_Handler;
  47.     APTR                  af_Offset;
  48.     LONG                  af_BytesLeft;
  49.     ULONG                 af_BufferSize;
  50.     APTR                  af_Buffers[2];
  51.     struct StandardPacket af_Packet;
  52.     struct MsgPort        af_PacketPort;
  53.     ULONG                 af_CurrentBuf;
  54.     ULONG                 af_SeekOffset;
  55.     UBYTE                 af_PacketPending;
  56.     UBYTE                 af_ReadMode;
  57. } AsyncFile;
  58.  
  59.  
  60. /*****************************************************************************/
  61.  
  62.  
  63. typedef enum OpenModes
  64. {
  65.     MODE_READ,      /* read an existing file                             */
  66.     MODE_WRITE,     /* create a new file, delete existing file if needed */
  67.     MODE_APPEND     /* append to end of existing file, or create new     */
  68. } OpenModes;
  69.  
  70. typedef enum SeekModes
  71. {
  72.     MODE_START = -1,   /* relative to start of file         */
  73.     MODE_CURRENT,      /* relative to current file position */
  74.     MODE_END           /* relative to end of file           */
  75. } SeekModes;
  76.  
  77.  
  78. /*****************************************************************************/
  79.  
  80.  
  81. AsyncFile *OpenAsync(const STRPTR fileName, OpenModes mode, LONG bufferSize);
  82. LONG CloseAsync(AsyncFile *file);
  83. LONG ReadAsync(AsyncFile *file, APTR buffer, LONG numBytes);
  84. LONG ReadCharAsync(AsyncFile *file);
  85. LONG WriteAsync(AsyncFile *file, APTR buffer, LONG numBytes);
  86. LONG WriteCharAsync(AsyncFile *file, UBYTE ch);
  87. LONG SeekAsync(AsyncFile *file, LONG position, SeekModes mode);
  88.  
  89.  
  90. /*****************************************************************************/
  91.  
  92.  
  93. #endif /* __ASYNCIO_H */
  94.