home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff257.lzh / FileIO / FileIO.h < prev    next >
C/C++ Source or Header  |  1989-10-19  |  8KB  |  207 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.  * 26 Sept 87   Jeff Glatt      Converted C code to optimized assembly and
  34.  *                              created a library.
  35.  * *********************************************************************** */
  36.  
  37.  
  38. #define MAX_NAME_LENGTH 30
  39. #define MAX_DRAWER_LENGTH 132
  40. #define SetFlag(v,f)      ((v)|=(f))
  41. #define ClearFlag(v,f)    ((v)&=~(f))
  42. #define ToggleFlag(v,f)   ((v)^=(f))
  43. #define FlagIsSet(v,f)    ((BOOL)(((v)&(f))!=0))
  44.  
  45. struct HandlerBlock {
  46.    APTR  StartUpCode;
  47.    APTR  DiskInsertedCode;
  48.    APTR  GadgetCode;
  49.    APTR  KeyCode;
  50.    APTR  MouseMoveCode;
  51.    };
  52.  
  53. /* === FileIO Structure ========================================== */
  54.  
  55. struct FileIO {
  56.    USHORT Flags;
  57.    /* After a successful call to DoFileIO(), these fields will have
  58.     * the names selected by the user.  You should never have to initialize
  59.     * these fields, only read from them, though initializing them won't hurt.
  60.     */
  61.    UBYTE FileName[MAX_NAME_LENGTH];
  62.    UBYTE Drawer[MAX_DRAWER_LENGTH];
  63.    UBYTE Disk[MAX_NAME_LENGTH];
  64.  
  65.    /* If a Lock on a disk/dir was obtained, it can be found here. */
  66.    struct DOSLock *Lock;
  67.  
  68.    USHORT NameCount;
  69.    USHORT NameStart;
  70.    SHORT  CurrPick;
  71.    struct Remember *FileList;
  72.  
  73.    UBYTE *FileIOText;             /* for SPECIAL_REQ */
  74.    APTR FileIORoutine;            /* for SPECIAL_REQ */
  75.  
  76.    SHORT MatchType;  /* DiskObject Type */
  77.    UBYTE *ToolTypes;
  78.  
  79.    UBYTE *Extension;
  80.    USHORT ExtSize; /* Don't count the terminating NULL */
  81.  
  82.    struct HandlerBlock *Custom;
  83.  
  84.    USHORT X;
  85.    USHORT Y;
  86.  
  87.    ULONG  FreeBytes;
  88.    ULONG  FileSize;
  89.  
  90.    UBYTE  *Title;
  91.    UBYTE  *Buffer;
  92.  
  93.    APTR   RawCode;
  94.    struct DOSLock  *OriginalLock;
  95.    BYTE   Errno;
  96.    UBYTE  DrawMode;
  97.    UBYTE  PenA;
  98.    UBYTE  PenB;
  99.    };
  100.  
  101. /* === User FileIO Flag Definitions === */
  102. #define NO_CARE_REDRAW     0x0001  /* Clear if reconstructing display */
  103. #define USE_DEVICE_NAMES   0x0002  /* Set for device instead of volume names */
  104. #define EXTENSION_MATCH    0x0004  /* Only display those that end with
  105.                                       a specified string */
  106. #define DOUBLECLICK_OFF    0x0008  /* Inhibit double-clicking if set */
  107. #define WBENCH_MATCH       0x0010  /* If set check .info files only */
  108. #define MATCH_OBJECTTYPE   0x0020  /* If set with .info also check ObjectType */
  109. #define MATCH_TOOLTYPE     0x0040  /* If set with .info also check ToolType */
  110. #define INFO_SUPPRESS      0x0080  /* No info files listed */
  111. #define CUSTOM_HANDLERS    0x0200  /* Implement custom handlers */
  112. #define SHOW_DISK_NAMES      0x4000  /* Show disk names instead of filenames */
  113. #define SPECIAL_REQ        0x8000  /* For displaying lists of strings */
  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. /* ====================== Entry Structure ====================== */
  172. /* Don't use sizeof on this structure. The library makes this for you when
  173.    you call AddEntry. The 3rd field is a variable length string. This struc-
  174.    ture has been defined simply so that you can get access to the EntryID
  175.    and the EntryString. This structure is used for SPECIAL_REQ. */
  176.  
  177. struct Entry {
  178.    LONG  EntryID;
  179.    UBYTE EntryFlags;
  180.    UBYTE EntryString[1]; /* size is actually length of null-terminated
  181.                          string */
  182.    };
  183.  
  184. /* === Requester Library Function Declarations ===================== */
  185.  
  186. extern struct FileIO *GetFileIO();
  187. extern UBYTE  *DoFileIO();
  188. extern UBYTE  *DoFileIOWindow();  /* address = DoFileIOWindow(myFileIO, myScreen);
  189.                                   If myScreen is NULL, then use WB screen */
  190. extern BOOL   AutoFileMessage(); /* result = AutoFileMessage(3L, myWindow); */
  191. extern BOOL   AutoMessage(), AutoMessageLen(), AutoPrompt3();
  192. extern void   ReleaseFileIO();
  193. extern void   SetWaitPointer();  /* SetWaitPointer( myWindow ); */
  194. extern void   ResetBuffer();     /* ResetBuffer( StringInfo, nullFlag ); resets the
  195.                              cursor back to the first char in the stringinfo's
  196.                              buffer. If nullFlag is TRUE, then NULLS the buffer
  197.                              as well. */
  198. extern UBYTE  *ParseString();
  199. extern UBYTE  *TypeFilename();
  200. extern UBYTE  *PromptUserEntry(), *UserEntry();
  201. extern void   SetTitle(), ResetTitle();
  202. extern UWORD  GetRawkey(), DecodeRawkey();
  203.  
  204. extern WORD   NewEntryList(), AddEntry(), IsEntryThere();
  205.  
  206. #endif /* of FILEIO_H */
  207.