#include <stdio.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <functions.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/filehandler.h>
#include <exec/nodes.h>
#include <exec/lists.h>

#define NO_ERR    0
#define WIN_ERR   1
#define RQST_ERR  2
#define DISK_ERR  3
#define INTUI_ERR 4
#define DOS_ERR   5
#define MEM_ERR   6

char *errors[] =
{
  "No error",
  "Can't open Window",
  "Can't open Requester",
  "Disk error",
  "Can't open Intuition.library",
  "Can't open Dos.library",
  "No more free memory"
};

struct NewWindow MyNewWindow =
{
  0, 0, 280, 210, -1, -1, REQCLEAR | GADGETUP | GADGETDOWN,
  NOCAREREFRESH | SIMPLE_REFRESH | BORDERLESS | ACTIVATE, NULL, NULL, NULL,
  NULL, NULL, 0,0,0,0, CUSTOMSCREEN
};

struct Window *MyWindow;
struct IntuiMessage *IMessage;
ULONG MessageClass, MAddress;
USHORT MCode;
short int Count;
BOOL ReqChanged, Drive1 = FALSE, DriveH = FALSE;

struct Library *IntuitionBase;
struct DosLibrary *DOSBase;

char LeerString [] = "                              ";
char DisplayString [6][31];

struct Inhalt
{ 
  char Name [30];
  long Typ;
};
 
struct Inhalt *Daten;

struct IntuiText CancelGad_Title =
{
  0,31,JAM1,9,6,NULL,(UBYTE*)" CANCEL",(struct IntuiText*)NULL
};
struct IntuiText OkGad_Title =
{
  0,31,JAM1,9,6,NULL,(UBYTE*)"   OK",(struct IntuiText*)NULL
};

SHORT OkGad_Border_Data2 [] =
{
  0,0, 79,0, 79,19, 0,19, 0,0
};
struct Border OkGad_Border2 =
{
  0,0, 0,31, JAM1, 5, OkGad_Border_Data2, NULL
};
SHORT OkGad_Border_Data [] =
{
  -2,-2, 81,-2, 81,21, -2,21, -2,-2
};
struct Border OkGad_Border =
{
  0,0, 0,31, JAM1, 5, OkGad_Border_Data, &OkGad_Border2
};
struct Gadget OkGad =
{
  NULL, 190, 180, 80, 20,
  GADGHCOMP, RELVERIFY | ENDGADGET, BOOLGADGET | REQGADGET,
  (APTR)&OkGad_Border, NULL, &OkGad_Title, 0L, NULL, 100, NULL
};
struct Gadget CancelGad =
{
  &OkGad, 10, 180, 80, 20,
  GADGHCOMP, RELVERIFY | ENDGADGET, BOOLGADGET | REQGADGET,
  (APTR)&OkGad_Border, NULL, &CancelGad_Title, 0L, NULL, 101, NULL
};

struct IntuiText OpenGad_Text [16] =
{
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 0 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 1 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 2 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 3 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 4 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 5 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 6 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 7 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL /* 8 */
  },
  {
    0,31,JAM2,100,-10,NULL,(UBYTE*)"File Name",(struct IntuiText*)NULL /* 9 */
  },
  {
    0,31,JAM2,100,-10,NULL,(UBYTE*)"Path Name",(struct IntuiText*)NULL /* 10 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)"DF0:",(struct IntuiText*)NULL /* 11 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)"DF1:",(struct IntuiText*)NULL /* 12 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)"RAM:",(struct IntuiText*)NULL /* 13 */
  },
  {
    0,31,JAM2,1,1,NULL,(UBYTE*)"DH0:",(struct IntuiText*)NULL /* 14 */
  },
  {
    0,31,JAM2,3,1,NULL,(UBYTE*)"/ Parent",(struct IntuiText*)NULL /* 15 */
  }
};
  
USHORT OpenGad_6_Image_Data [] =
{
  0x0000, 0x7F80, 0x7380, 0x6180, 0x4080,
  0x7380, 0x7380, 0x7380, 0x7F80, 0x0000
};
struct Image OpenGad_6_Image =
{
  0, 0, 10, 10, 1, NULL, 1, 0, NULL
};
struct Image OpenGad_7_Image;
struct PropInfo OpenGad_7_Info;
USHORT OpenGad_8_Image_Data [] =
{
  0x0000, 0x7F80, 0x7380, 0x7380, 0x7380,
  0x4080, 0x6180, 0x7380, 0x7F80, 0x0000
};
struct Image OpenGad_8_Image =
{
  0, 0, 10, 10, 1, NULL, 1, 0, NULL
};
SHORT OG_9_Border_Data [] =
{
  -2,-12, 261,-12, 261, 11, -2, 11, -2,-12
};
struct Border OG_9_Border =
{
  0,0, 0, 31, JAM1, 5, OG_9_Border_Data, NULL
};
static UBYTE OG_9_Buf[33],OpenGad_9_Undo[33];
struct StringInfo OpenGad_9_Info =
{
  OG_9_Buf, OpenGad_9_Undo, 0, 33, 0, 0, 0, 0, 0, 0, NULL, 0L, NULL
};
static UBYTE OG_10_Buf[200] = "DF0:",OpenGad_10_Undo[200];
struct StringInfo OpenGad_10_Info =
{
  OG_10_Buf, OpenGad_10_Undo, 0, 200, 0, 0, 0, 0, 0, 0, NULL, 0L, NULL
};
SHORT OG_11_Border_Data [] =
{
  -2,-2, 33,-2, 33,11, -2,11, -2,-2
};
struct Border OG_11_Border =
{
  0,0, 0, 31, JAM1, 5, OG_11_Border_Data, NULL
};
SHORT OG_15_Border_Data [] =
{
  -2,-2, 77,-2, 77,11, -2,11, -2,-2
};
struct Border OG_15_Border =
{
  0,0, 0, 31, JAM1, 5, OG_15_Border_Data, NULL
};

struct Gadget OpenGad [16] =
{
  {
    &CancelGad, 10, 30, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[0], 0L, NULL, 0, NULL
  },
  {
    &OpenGad [0], 10, 40, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[1], 0L, NULL, 1, NULL
  },
  {
    &OpenGad [1], 10, 50, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[2], 0L, NULL, 2, NULL
  },
  {
    &OpenGad [2], 10, 60, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[3], 0L, NULL, 3, NULL
  },
  {
    &OpenGad [3], 10, 70, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[4], 0L, NULL, 4, NULL
  },
  {
    &OpenGad [4], 10, 80, 240, 10, GADGHCOMP, RELVERIFY, BOOLGADGET | REQGADGET,
    NULL, NULL, &OpenGad_Text[5], 0L, NULL, 5, NULL
  },  
  {
    &OpenGad [5], 260, 30, 10, 10, GADGHCOMP | GADGIMAGE, RELVERIFY,
    BOOLGADGET | REQGADGET, (APTR)&OpenGad_6_Image,
    NULL, NULL, 0L, NULL, 6, NULL
  },
  {
    &OpenGad [6], 260, 40, 10, 40, GADGHNONE,
    GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
    PROPGADGET | REQGADGET, (APTR)&OpenGad_7_Image, NULL, NULL, 0L,
    (APTR)&OpenGad_7_Info, 7, NULL
  },
  {
    &OpenGad [7], 260, 80, 10, 10, GADGHCOMP | GADGIMAGE, RELVERIFY,
    BOOLGADGET | REQGADGET, (APTR)&OpenGad_8_Image,
    NULL, NULL, 0L, NULL, 8, NULL
  },
  {
    &OpenGad [8], 10, 110, 260, 10, GADGHCOMP, RELVERIFY, STRGADGET | REQGADGET,
    (APTR)&OG_9_Border, NULL, &OpenGad_Text[9], 0L,
    (APTR)&OpenGad_9_Info, 9, NULL
  },
  {
    &OpenGad [9], 10, 140, 260, 10, GADGHCOMP, RELVERIFY, STRGADGET | REQGADGET,
    (APTR)&OG_9_Border, NULL, &OpenGad_Text[10], 0L,
    (APTR)&OpenGad_10_Info, 10, NULL
  },
  {
    &OpenGad [10], 10, 160, 32, 10, GADGHCOMP, RELVERIFY, 
    BOOLGADGET | REQGADGET,
    (APTR)&OG_11_Border, NULL, &OpenGad_Text[11], 0L, NULL, 11, NULL
  },
  {
    &OpenGad [11], 56, 160, 32, 10, GADGHCOMP, RELVERIFY, 
    BOOLGADGET | REQGADGET,
    (APTR)&OG_11_Border, NULL, &OpenGad_Text[12], 0L, NULL, 12, NULL
  },
  {
    &OpenGad [12], 102, 160, 32, 10, GADGHCOMP, RELVERIFY, 
    BOOLGADGET | REQGADGET,
    (APTR)&OG_11_Border, NULL, &OpenGad_Text[13], 0L, NULL, 13, NULL
  },
  {
    &OpenGad [13], 148, 160, 32, 10, GADGHCOMP, RELVERIFY, 
    BOOLGADGET | REQGADGET,
    (APTR)&OG_11_Border, NULL, &OpenGad_Text[14], 0L, NULL, 14, NULL
  },
  {
    &OpenGad [14], 194, 160, 76, 10, GADGHCOMP, RELVERIFY, 
    BOOLGADGET | REQGADGET,
    (APTR)&OG_15_Border, NULL, &OpenGad_Text[15], 0L, NULL, 15, NULL
  }
};

SHORT OpenBorder_1_Data [] =
{
  1,1, 278,1, 278,208, 1,208, 1,1
};
struct Border OpenBorder_1 =
{
  0,0, 0, 31, JAM1, 5, OpenBorder_1_Data, NULL
};
SHORT OpenBorder_2_Data [] =
{
  -2,-2, 241,-2, 241,61, -2,61, -2,-2
};
struct Border OpenBorder_2 =
{
  10,30, 0, 31, JAM1, 5, OpenBorder_2_Data, &OpenBorder_1
};
struct IntuiText OpenTitle = 
{
  0,31,JAM1,60,10,NULL,(UBYTE*)NULL,(struct IntuiText*)NULL
};
struct Requester Open_Rqst =
{
  NULL, 0, 0, 280, 210, 0, 0, &OpenGad [15], &OpenBorder_2, &OpenTitle,
  0, 31, NULL, NULL, NULL, NULL, NULL
};
