home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 230.lha / FileIO_II / fileio.h < prev    next >
C/C++ Source or Header  |  1989-04-05  |  7KB  |  192 lines

  1.  
  2. #ifndef FILEIO_H
  3. #define FILEIO_H
  4.  
  5. /* *** fileio.h *************************************************************
  6.  *
  7.  * Amiga Programmers' Suite  --  File IO Include File
  8.  *     from Book 1 of the Amiga Programmers' Suite by RJ Mical
  9.  *
  10.  * Copyright (C) 1986, =Robert J. Mical=
  11.  * All Rights Reserved.
  12.  *
  13.  * Created for Amiga developers.
  14.  * Any or all of this code can be used in any program as long as this
  15.  * entire notice is retained, ok?  Thanks.
  16.  *
  17.  * The Amiga Programmer's Suite Book 1 is copyrighted but freely distributable.
  18.  * All copyright notices and all file headers must be retained intact.
  19.  * The Amiga Programmer's Suite Book 1 may be compiled and assembled, and the 
  20.  * resultant object code may be included in any software product.  However, no 
  21.  * portion of the source listings or documentation of the Amiga Programmer's 
  22.  * Suite Book 1 may be distributed or sold for profit or in a for-profit 
  23.  * product without the written authorization of the author, RJ Mical.
  24.  * 
  25.  * HISTORY      NAME            DESCRIPTION
  26.  * -----------  --------------  --------------------------------------------
  27.  * 20 Oct 87    - RJ            Added RENAME_RAMDISK to fix what seems to 
  28.  *                              be a bug in AmigaDOS.
  29.  * 27 Sep 87    RJ              Removed reference to alerts.h, brought 
  30.  *                              declarations into this file
  31.  * 12 Aug 86    RJ              Prepare (clean house) for release
  32.  * 14 Feb 86    =RJ Mical=      Created this file.
  33.  *
  34.  * 26 Sept 88   Jeff Glatt      Converted C code to optimized assembly and
  35.  *                              created a library.
  36.  * *********************************************************************** */
  37.  
  38.  
  39. #define MAX_NAME_LENGTH 30
  40. #define MAX_DRAWER_LENGTH 132
  41. #define SetFlag(v,f)      ((v)|=(f))
  42. #define ClearFlag(v,f)    ((v)&=~(f))
  43. #define ToggleFlag(v,f)   ((v)^=(f))
  44. #define FlagIsSet(v,f)    ((BOOL)(((v)&(f))!=0))
  45.  
  46. struct HandlerBlock {
  47.    APTR  StartUpCode;
  48.    APTR  DiskInsertedCode;
  49.    APTR  GadgetCode;
  50.    APTR  KeyCode;
  51.    APTR  MouseMoveCode;
  52.    };
  53.  
  54. /* === FileIO Structure ========================================== */
  55.  
  56. struct FileIO {
  57.    USHORT Flags;
  58.    /* After a successful call to DoFileIO(), these fields will have
  59.     * the names selected by the user.  You should never have to initialize
  60.     * these fields, only read from them, though initializing them won't hurt.
  61.     */
  62.    UBYTE FileName[MAX_NAME_LENGTH];
  63.    UBYTE Drawer[MAX_DRAWER_LENGTH];
  64.    UBYTE Disk[MAX_NAME_LENGTH];
  65.  
  66.    /* If a Lock on a disk/dir was obtained, it can be found here. */
  67.    struct DOSLock *Lock;
  68.  
  69.    USHORT NameCount;
  70.    USHORT NameStart;
  71.    SHORT  CurrPick;
  72.    struct Remember *FileList;
  73.  
  74.    USHORT VolIndex;
  75.    USHORT VolCount;
  76.    struct Remember *VolList;
  77.  
  78.    SHORT MatchType;  /* DiskObject Type */
  79.    UBYTE *ToolTypes;
  80.  
  81.    UBYTE *Extension;
  82.    USHORT ExtSize; /* Don't count the terminating NULL */
  83.  
  84.    struct HandlerBlock *Custom;
  85.  
  86.    USHORT X;
  87.    USHORT Y;
  88.  
  89.    ULONG  FreeBytes;
  90.    ULONG  FileSize;
  91.  
  92.    UBYTE  *Title;
  93.    UBYTE  *Buffer;
  94.  
  95.    APTR   RawCode;
  96.    struct DOSLock  *OriginalLock;
  97.    BYTE   Errno;
  98.    UBYTE  DrawMode;
  99.    UBYTE  PenA;
  100.    UBYTE  PenB;
  101.    };
  102.  
  103. /* === User FileIO Flag Definitions === */
  104. #define NO_CARE_REDRAW     0x0001  /* Clear if reconstructing display */
  105. #define USE_DEVICE_NAMES   0x0002  /* Set for device instead of volume names */
  106. #define EXTENSION_MATCH    0x0004  /* Only display those that end with
  107.                                       a specified string */
  108. #define DOUBLECLICK_OFF    0x0008  /* Inhibit double-clicking if set */
  109. #define WBENCH_MATCH       0x0010  /* If set check .info files only */
  110. #define MATCH_OBJECTTYPE   0x0020  /* If set with .info also check ObjectType */
  111. #define MATCH_TOOLTYPE     0x0040  /* If set with .info also check ToolType */
  112. #define INFO_SUPPRESS      0x0080  /* No info files listed */
  113. #define CUSTOM_HANDLERS    0x0200  /* Implement custom handlers */
  114.  
  115. /* === System FileIO Flag Definitions === */
  116. #define ALLOCATED_FILEIO   0x0100  /* Not a pre-initialized FileIO struct */
  117. #define WINDOW_OPENED      0x0400  /* DoFileIOWindow() was called */
  118. #define TITLE_CHANGED      0x0800  /* SetTitle() called without ResetTitle()
  119.                                    */
  120. #define DISK_HAS_CHANGED   0x2000  /* Disk changed during DoFileIO() */
  121.  
  122. /*  FileRequester GadgetIDs - Do not use these IDs for your own gadgets */
  123. #define FILEIO_CANCEL      0x7FA0
  124. #define FILEIO_OK          0x7FA1
  125. #define FILEIO_NAMETEXT    0x7FA2
  126. #define FILEIO_DRAWERTEXT  0x7FA3
  127. #define FILEIO_DISKTEXT    0x7FA4
  128. #define FILEIO_SELECTNAME  0x7FA5
  129. #define FILEIO_UPGADGET    0x7FA6
  130. #define FILEIO_DOWNGADGET  0x7FA7
  131. #define FILEIO_PROPGADGET  0x7FA8
  132. #define FILEIO_NEXTDISK    0x7FA9
  133. #define FILEIO_BACKDROP    0x7FAA
  134.  
  135. #define NAME_ENTRY_COUNT   7   /* These many names in the SelectName box */
  136.  
  137. #define REQTITLE_HEIGHT    8
  138.  
  139. #define REQ_LEFT          8
  140. #define REQ_TOP           15
  141. #define REQ_WIDTH         286
  142. #define REQ_HEIGHT        (110 + REQTITLE_HEIGHT)
  143. #define REQ_LINEHEIGHT    8
  144.  
  145. #define SELECTNAMES_LEFT    8
  146. #define SELECTNAMES_TOP     (15 + REQTITLE_HEIGHT)
  147. #define SELECTNAMES_WIDTH   122
  148. #define SELECTNAMES_HEIGHT  60
  149.  
  150.  
  151.  /* ======= ERRNO numbers returned in FileIO error field ========= */
  152.  
  153. #define ERR_MANUAL  1   /* the path was entered manually via the title bar
  154.                            with no errors or cancellation. */
  155. #define ERR_SUCCESS 0   /* everything went OK */
  156. #define ERR_CANCEL  -1  /* the filename procedure was CANCELED by the user */
  157. #define ERR_WINDOW  -2  /* the window couldn't open (in DoFileIOWindow()) */
  158. #define ERR_APPGADG -3  /* the requester was CANCELED by an application gadget
  159.                            (via an installed CUSTOM gadget handler returning TRUE) */
  160.  
  161. /* === AutoFileMessage() Numbers ================================= */
  162. #define ALERT_OUTOFMEM            0
  163. #define ALERT_BAD_DIRECTORY       1
  164. #define READ_WRITE_ERROR          2 /* Error in reading or writing file */
  165.  /* The next 3 display "YES" and "NO" prompts,
  166.     returning d0=1 for yes, 0 for no */
  167. #define FILE_EXISTS               3 /* File already exists. Overwrite? */
  168. #define SAVE_CHANGES              4 /* Changes have been made. Save them? */
  169. #define REALLY_QUIT               5 /* Do you really want to quit? */
  170.  
  171. /* === Requester Library Function Declarations ===================== */
  172.  
  173. extern struct FileIO *GetFileIO();
  174. extern UBYTE  *DoFileIO();
  175. extern UBYTE  *DoFileIOWindow();  /* address = DoFileIOWindow(myFileIO, myScreen);
  176.                                   If myScreen is NULL, then use WB screen */
  177. extern BOOL   AutoFileMessage(); /* result = AutoFileMessage(3L, myWindow); */
  178. extern BOOL   AutoMessage(), AutoMessageLen(), AutoPrompt3();
  179. extern void   ReleaseFileIO();
  180. extern void   SetWaitPointer();  /* SetWaitPointer( myWindow ); */
  181. extern void   ResetBuffer();     /* ResetBuffer( StringInfo, nullFlag ); resets the
  182.                              cursor back to the first char in the stringinfo's
  183.                              buffer. If nullFlag is TRUE, then NULLS the buffer
  184.                              as well. */
  185. extern UBYTE  *ParseString();
  186. extern UBYTE  *TypeFileName();
  187. extern UBYTE  *PromptUserEntry(), *UserEntry();
  188. extern void   SetTitle(), ResetTitle();
  189. extern UWORD  GetRawkey(), DecodeRawkey();
  190.  
  191. #endif /* of FILEIO_H */
  192.