/*
***************************************************************************
*
* Datei:
*    RSys.h
*
* Inhalt:
*
* Bemerkungen:
*    Die Haupt-Include-Datei von RSys mit allen globalen Vereinbarungen.
*    (Wird vorkompiliert zu einem preinclude file!)
* Erstellungsdatum:
*    07-Jul-93    Rolf Böhme
*
* Änderungen:
*    07-Jul-93    Rolf Böhme    Erstellung
*    01-Jul-93    Einige Umstellung der EntryAttr-Struktur und
*                 Einführung sogenannter Fields, Standard-Einträge
*                 von RSys
*
***************************************************************************
*/

#include <clib/icon_protos.h>
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/expansion_protos.h>
#include <clib/asl_protos.h>
#include <clib/commodities_protos.h>
#include <clib/wb_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/utility_protos.h>
#include <clib/translator_protos.h>
#include <clib/iffparse_protos.h>
#include <clib/macros.h>

#include <pragmas/icon_lib.h>
#include <pragmas/exec_lib.h>
#include <pragmas/gadtools_lib.h>
#include <pragmas/graphics_lib.h>
#include <pragmas/intuition_lib.h>
#include <pragmas/dos_lib.h>
#include <pragmas/expansion_lib.h>
#include <pragmas/asl_lib.h>
#include <pragmas/commodities_lib.h>
#include <pragmas/wb_lib.h>
#include <pragmas/diskfont_lib.h>
#include <pragmas/utility_lib.h>
#include <pragmas/translator_lib.h>

#include <devices/audio.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <devices/timer.h>
#include <devices/trackdisk.h>
#include <devices/narrator.h>
#include <devices/prtbase.h>
#include <devices/printer.h>

#include <dos/exall.h>
#include <dos/rdargs.h>
#include <dos/dostags.h>
#include <dos/filehandler.h>

#include <exec/alerts.h>
#include <exec/devices.h>
#include <exec/execbase.h>
#include <exec/interrupts.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <exec/types.h>

#include <graphics/displayinfo.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/text.h>

#include <hardware/cia.h>
#include <hardware/intbits.h>
#include <hardware/custom.h>

#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/gadgetclass.h>
#include <intuition/imageclass.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <intuition/preferences.h>

#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/expansionbase.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include <libraries/commodities.h>
#include <libraries/diskfont.h>
#include <libraries/translator.h>
#include <libraries/iffparse.h>

#include <workbench/startup.h>
#include <workbench/workbench.h>

#include <limits.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <ctype.h>

#include <libraries/amigaguide.h>
#include <clib/amigaguide_protos.h>
#include <pragmas/amigaguide_pragma.h>

#define NAME      "RSys"
#define VERSION   "1.21"
#define DATE      __DATE__
#define TIME      __TIME__
#define COPYRIGHT "(c) by Rolf Boehme (GiftWare and PD)"

#define UNSETLVPOS            -1
#define NO_CASE               0
#define CASE                  1
#define HOTKEYS               7
#define MAXSHOW               10
#define SYSTEMINFO            12
#define TITLELEN              15
#define PWDLEN                20
#define ENVLEN                20
#define PARTSIZE              20
#define MAXSTRLEN             30
#define BUFSIZE               47
#define PATTERNLEN            50
#define SEC                   50
#define HELPLINESIZE          50
#define PATHPARTWIDTH         80
#define PARSEPATLEN           102
#define MAXFULLNAME           108
#define MAXLINESIZE           150
#define MAXWRITESIZE          200
#define CRCTABSIZE            256
#define MAXLARGEMEM           512
#define FRAC                  8192
#define FULL                  65536

#define NOSCREENTITLECHANGE   ((UBYTE *)(-1))

#define R13                   TRUE
#define CRY                   FALSE

#define ESC                   '\33'

#define ACTION_TOKEN          "#"

#define COUNT_FLAGS           (GD_HandlerInpGad+1)
#define KEY_RELEASE           0x80
#define KEY_HELP              0x5F
#define KEY_q                 0x10
#define KEY_ESC               0x45

#define custom                (*(struct Custom *)0xDFF000)

#define EVT_HOTKEY            1L

#define CNTMASK               LDF_DEVICES
#define MASK                  (CNTMASK|LDF_READ)
#define B2C(x)                ((VOID *)(((LONG)(x))<<2))

#define ID_PORT_NAME          (UBYTE *)"RSys-ID-Port"

#define STRINGEND             '\0'

#define KILL                  TRUE
#define NO_KILL               FALSE

#define YES                   TRUE
#define NO                    FALSE

#define SORT                  TRUE
#define NO_SORT               FALSE

#define SPEAK                 TRUE
#define NO_SPEAK              FALSE

#define ErrorHandle(nr1,nr2,kill) ErrorHandleFull(nr1,nr2,kill,__FILE__,__FUNC__,__LINE__)

enum {
   GD_TasksGad,            /*  0  */
   GD_LibrariesGad,        /*  1  */
   GD_MemoryGad,           /*  2  */
   GD_PortsGad,            /*  3  */
   GD_VolumesGad,          /*  4  */
   GD_AssignsGad,          /*  5  */
   GD_FontsGad,            /*  6  */
   GD_ResourcesGad,        /*  7  */
   GD_InterruptsGad,       /*  8  */
   GD_WindowsGad,          /*  9  */
   GD_ScreensGad,          /*  10 */
   GD_HandlerInpGad,       /*  11 */
   GD_SystemGad,           /*  12 */
   GD_HardwareGad,         /*  13 */
   GD_SaveListGad,         /*  14 */
   GD_JumpGad,             /*  15 */
   GD_ListeLV,             /*  16 */
   GD_TextHeader,          /*  17 */
   GD_InfoMsgGad           /*  18 */
};

enum {
   GD_FileTypeTGad,        /*  0  */
   GD_ActionLV,            /*  1  */
   GD_FInfo,               /*  2  */
   GD_NextEntryGad         /*  3  */
};

enum {
   TYPE_DIR,               /*  0  */
   TYPE_FILE,              /*  1  */
   TYPE_ICON,              /*  2  */
   TYPE_TEXT,              /*  3  */
   TYPE_C,                 /*  4  */
   TYPE_H,                 /*  5  */
   TYPE_ASM,               /*  6  */
   TYPE_I,                 /*  7  */
   TYPE_MOD,               /*  8  */
   TYPE_REXX,              /*  9  */
   TYPE_BASIC,             /*  10 */
   TYPE_TEX,               /*  11 */
   TYPE_METAFONT,          /*  12 */
   TYPE_GF,                /*  13 */
   TYPE_TEXFONT,           /*  14 */
   TYPE_TEXDVI,            /*  15 */
   TYPE_FLIB,              /*  16 */
   TYPE_OLDMANX,           /*  17 */
   TYPE_NEWMANX,           /*  18 */
   TYPE_OLDMANXLIB,        /*  19 */
   TYPE_NEWMANXLIB,        /*  20 */
   TYPE_OBJECT,            /*  21 */
   TYPE_LIB,               /*  22 */
   TYPE_EXECUTABLE,        /*  23 */
   TYPE_LIBRARY,           /*  24 */
   TYPE_DEVICE,            /*  25 */
   TYPE_FILESYS,           /*  26 */
   TYPE_HANDLER,           /*  27 */
   TYPE_GIF,               /*  28 */
   TYPE_ILBM,              /*  29 */
   TYPE_ANIM,              /*  30 */
   TYPE_8SVX,              /*  31 */
   TYPE_SMUS,              /*  32 */
   TYPE_FTXT,              /*  33 */
   TYPE_PREFS,             /*  34 */
   TYPE_TERM,              /*  35 */
   TYPE_IMPLODER,          /*  36 */
   TYPE_POWERPACKER,       /*  37 */
   TYPE_ARC,               /*  38 */
   TYPE_LHARC,             /*  39 */
   TYPE_ZOO,               /*  30 */
   TYPE_ZIP,               /*  41 */
   TYPE_DMS,               /*  42 */
   TYPE_WARP,              /*  43 */
   TYPE_ZOOM,              /*  44 */
   TYPE_WORDPERFECT        /*  45 */
};

enum ListTypes {
   TASKS,                  /*  0  */
   LIBRARIES,              /*  1  */
   MEMORY,                 /*  2  */
   PORTS,                  /*  3  */
   VOLUMES,                /*  4  */
   ASSIGNS,                /*  5  */
   FONTS,                  /*  6  */
   RESOURCES,              /*  7  */
   INTERRUPTS,             /*  8  */
   WINDOWS,                /*  9  */
   SCREENS,                /*  10 */
   INPUTHDL,               /*  11 */
   SYSINFO,                /*  12 */
   HARDWARE,               /*  13 */
   HELP,                   /*  14 */
   PREFS,                  /*  15 */
   DEVS,                   /*  16 */
   ALLFONTS,               /*  17 */
   ENVVARS,                /*  18 */
   CLI,                    /*  19 */
   RESIDENTS,              /*  20 */
   SEMAPHORES,             /*  21 */
   SYSVECTORS,             /*  22 */
   SYSSOFTDEV,             /*  23 */
   SYSPUBSCR,              /*  24 */
   BLITTERWAIT,            /*  25 */
   TOFWAIT,                /*  26 */
   COMMODITIES,            /*  27 */
   PRINTERDATA,            /*  28 */
   LIBRARYOFFS,            /*  29 */
   DISPLAYMODES,           /*  30 */
   VOLLOCKS,               /*  31 */
   AGUIDEXREF,             /*  32 */
   ALLGADGETS              /*  33 */
};

enum err_objects {
   BROKER_ERR,
   PORT_ERR,
   FILE_ERR,
   SCREEN_ERR,
   WINDOW_ERR,
   LIBRARY_ERR,
   DEVICE_ERR,
   ICON_ERR,
   GADGET_MENU_ERR,
   ENV_ERR,
   DOS_EXALL_ERR,
   FONT_ERR,
   LIST_NODE_ERR,
   MEMORY_ERR,
   TASK_ERR,
   CLIPBOARD_ERR,
   MISC_ERR
};

enum err_actions {
   DUPLICATE_FAIL,
   CREATE_FAIL,
   FIND_FAIL,
   KILL_FAIL,
   OPEN_FAIL,
   READ_FAIL,
   WRITE_FAIL,
   EXALL_FAIL,
   SIZE_FAIL,
   SAVED_FAIL,
   WRONG_FAIL,
   INFO_FAIL,
   EXIST_FAIL,
   TYPE_FAIL,
   ALLOC_FAIL
};

enum _field {
   NO_FIELD,
   NO_LIB_ID,
   NO_FLAGS,
   NO_TASK,
   NO_NODE,
   WRONG_TYPE_FMT,
   NO_TYPE,
   NO_TITLE,
   NO_BAUD,
   NO_PARITY,
   NO_HANDSHK,
   NO_HANDLER,
   NO_FILE,
   NO_LOCK,
   BLANK_FIELD
};

extern char *str_err_objects[], *str_err_actions[];

extern int wb_start;

extern struct Screen        *Scr;
extern APTR                  VisualInfo;
extern struct Window        *SysWnd;
extern struct Gadget        *SysGList;
extern struct Menu          *SysMenus;
extern UWORD                 SysZoom[];
extern struct Gadget        *SysGadgets[];
extern UWORD                 SysLeft;
extern UWORD                 SysTop;
extern UWORD                 SysWidth;
extern UWORD                 SysHeight;
extern UBYTE                *SysWdt;
extern struct TextAttr      *Font;
extern UWORD                 FontX, FontY;
extern UWORD                 OffX, OffY;
extern struct TextAttr       Topaz80;
extern struct NewMenu        SysNewMenu[];
extern struct List           ListeLVList;

/*
typedef struct {
   char ea_type[BUFSIZE];
   char ea_header[BUFSIZE];
   char ea_dataformat[BUFSIZE];
   void (*ea_func)(void);
   unsigned ea_counted : 1;
} EntryAttribute;
*/

typedef struct {
   char *ea_type;
   char *ea_header;
   char *ea_dataformat;
   void (*ea_func)(void);
   unsigned ea_counted : 1;
} EntryAttribute;

extern EntryAttribute EntryAttr[];

struct objectid {
   char fullname[MAXFULLNAME];
   APTR address;
};

typedef struct SE {
   struct Node       se_Node;
   char              se_Entry[BUFSIZE];
   struct objectid   se_obj_id;
} ScrollEntry;

typedef struct SysMessage {
   struct Message sm_message;
   int            sm_newtype;
} SysMsg;

extern struct MsgPort *SysIdPort;

extern ScrollEntry *Entries;

extern struct Library *AslBase;
extern struct Library *GadToolsBase;
extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;
extern struct ExecBase *SysBase;
extern struct ExpansionBase    *ExpansionBase;
extern struct Library *CxBase;
extern struct WorkbenchBase *WorkbenchBase;
extern struct Library *DiskfontBase;
extern struct Library *UtilityBase;
extern struct Library *IFFParseBase;
extern struct AmigaGuideBase *AmigaGuideBase;

extern UBYTE   namebuffer[];
extern int topentry,countentries;
extern int quit_flag;
extern int LastID;
extern char *mess[];
extern const char *field[];

extern struct AppIcon *appicon;
extern  UWORD AppIcon1IData[];
extern struct Image    AppIconI1;
extern UWORD AppIconI2Data[];
extern struct Image    AppIconI2;

extern struct MsgPort *broker_mp;
extern CxObj *broker;
extern struct NewBroker newbroker;

struct _acts {
   struct Node act_Node;
   int         act_filetype;
   char        act_listviewheader[20];
   char        act_name[30];
   char        act_command[255];
};

extern struct _acts *Actions;

struct _flags {
   unsigned fastmode    : 1;
   unsigned sortmode    : 1;
   unsigned workingbar  : 1;
   unsigned speakmode   : 1;
   unsigned autofront   : 1;
   unsigned mousewindow : 1;
   unsigned sysfont     : 1;
   unsigned saveasking  : 1;
   unsigned appicon     : 1;

/* RSys private */
   unsigned wb_start    : 1;
   unsigned quit_clip   : 1;
   unsigned quit_sw     : 1;
   unsigned quit_crc    : 1;
   unsigned quit_flag   : 1;
   unsigned quit_cp     : 1;
   unsigned quit_action_flag     : 1;
   unsigned quit_cr     : 1;
   unsigned quit_ff     : 1;
   unsigned quit_fd     : 1;
   unsigned quit_tree   : 1;
   unsigned quit_hunk   : 1;
   unsigned quit_iconify: 1;
};

extern struct _flags Flags;

extern char hotkey[][];
extern char *RSysName;

extern char _fullpath[];

/*
struct _funcproc
{
   struct MinNode    fp_node;
   struct Process   *fp_process;
   char              fp_name[MAXSTRLEN];
};

extern struct _funcproc *funcproc;
extern struct MinList proclist;
*/
