/*
 * muiffr.h © by Martin Steppler
 *
 * $Id: muiffr.h 1.2 1994/04/16 15:58:23 steppler Exp $
 *
 * $Log: muiffr.h $
 * Revision 1.2  1994/04/16  15:58:23  steppler
 * official release
 *
 * Revision 1.1.1.1  1994/04/10  16:34:48  steppler
 * struct NodeList, struct RequestList and struct Application
 * extended due to new gadgets
 *
 * Revision 1.1  1994/02/26  21:46:17  steppler
 * Initial revision
 *
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <libraries/mui.h>
#include <clib/muimaster_protos.h>

#include <dos/dos.h>
#include <dos/dostags.h>
#include <clib/dos_protos.h>

#include <graphics/gfxmacros.h>
#include <clib/graphics_protos.h>

#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <clib/intuition_protos.h>

#include <exec/exec.h>
#include <clib/exec_protos.h>

#include <libraries/locale.h>
#include <clib/locale_protos.h>

#include <libraries/iffparse.h>
#include <clib/iffparse_protos.h>

#include <workbench/workbench.h>
#include <libraries/gadtools.h>

#include <clib/alib_protos.h>
#include <clib/asl_protos.h>
#include <clib/icon_protos.h>
#include <clib/diskfont_protos.h>

#include <libraries/xpk.h>

#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif

#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

#define EOS '\0'
#define PATHSIZE 200
#define ALIASSIZE 120
#define NODESIZE 24
#define SMALLSIZE 12
#define STANDARDSIZE 120
#define MAX_FILENAMEPOS 10
#define MAX_BYTESPOS 10
#define STREAM_BUF_SIZE 100000
#define BUF_SIZE 1024

#define NODELIST_APPEND  0
#define NODELIST_REPLACE 1

#define DONT_BE_SILENT 0
#define BE_SILENT 1

enum
{
    NODE_BUF_NUM, LIST_BUF_NUM, FONT_BUF_NUM, PHONE_BUF_NUM, PASSWORD_BUF_NUM,
    SPEED_BUF_NUM, TIME_BUF_NUM, CHARGES_BUF_NUM
};

extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;
extern struct LocaleBase *LocaleBase;
extern struct DosLibrary *DosBase;
extern struct Library *MUIMasterBase;
extern struct Library *DiskfontBase;
extern struct Library *XpkBase;
extern struct Library *IconBase;

struct NodeList
{
    struct NodeList *nl_Next;
    UBYTE *nl_Alias;
    UBYTE *nl_Node;
    UBYTE *nl_List;
    UBYTE *nl_Font;
    UBYTE *nl_Phone;
    UBYTE *nl_Password;
    UBYTE *nl_Speed;
    UBYTE *nl_Charges;
    UBYTE *nl_Time;
};

struct RequestList
{
    struct RequestList *rl_Next;
    UBYTE *rl_Buffer;
    LONG rl_Bytes;
};

#define APP_FIND_CHANGED       0x00000001
#define APP_CYA_CONF_TERM_CRLF 0x00000002

enum
{
    CYA_CONF_TERM_LF, CYA_CONF_TERM_CRLF
};

enum
{
    PLUS, MINUS, RESET
};

struct Application
{
    struct Catalog *app_Catalog;
    APTR app_Muiffr, app_wi_Main,
         app_lv_Main_List,
         app_lv_Main_RequestList, app_st_Main_Request,
         app_tx_Main_Bytes, app_tx_Main_Time, app_tx_Main_Charges,
         app_bt_Main_Aliases, app_st_Main_Aliases,
         app_bt_Main_Configuration,
         app_bt_Main_Password, app_st_Main_Password,
         app_st_Main_Find,
         app_bt_Main_FindNext, app_bt_Main_FindPrev,
         app_bt_Main_Insert, app_bt_Main_Delete,
         app_bt_Main_Load,
         app_bt_Main_Save,
         app_bt_Main_Download;
    APTR app_wi_Configuration,
         app_lv_Conf_NodeList,
         app_st_Conf_Alias, app_st_Conf_Node,
         app_st_Conf_List, app_pa_Conf_List, app_im_Conf_List,
         app_st_Conf_Font, app_pa_Conf_Font, app_im_Conf_Font,
         app_st_Conf_Phone, app_st_Conf_Password,
         app_st_Conf_Speed, app_st_Conf_Charges, app_st_Conf_Time,
         app_bt_Conf_NewNode, app_bt_Conf_DeleteNode,
         app_rg_Conf,
         app_st_Conf_Outbound, app_pa_Conf_Outbound, app_im_Conf_Outbound,
         app_st_Conf_ViaNumber, app_st_Conf_ViaNode,
         app_st_Conf_NodeList, app_pa_Conf_NodeList, app_im_Conf_NodeList,
         app_cy_Conf_Termination, app_sl_Conf_FileNamePos,
         app_bt_Conf_LoadConfig, app_bt_Conf_SaveConfig,
         app_sl_Conf_BytesPos;
    APTR app_wi_Alias,
         app_lv_Ali_NodeList;
    struct NewMenu *app_NewMenu, *app_Conf_NewMenu;
    struct DiskObject *app_DiskObject;
    UBYTE app_Conf_ListBuf[PATHSIZE],
          app_Conf_OutboundBuf[PATHSIZE],
          app_Conf_AliasBuf[ALIASSIZE],
          app_Conf_NodeBuf[NODESIZE],
          app_Conf_FontBuf[PATHSIZE],
          app_Conf_PhoneBuf[STANDARDSIZE],
          app_Conf_PasswordBuf[STANDARDSIZE],
          app_Conf_SpeedBuf[SMALLSIZE],
          app_Conf_ChargesBuf[SMALLSIZE],
          app_Conf_TimeBuf[SMALLSIZE],
          app_Conf_ViaNumberBuf[PATHSIZE],
          app_Conf_ViaNodeBuf[PATHSIZE],
          app_Conf_NodeListBuf[PATHSIZE],
          app_Main_AliasesBuf[ALIASSIZE],
          app_Main_PasswordBuf[STANDARDSIZE],
          app_Main_FindBuf[STANDARDSIZE],
          app_Main_RequestBuf[PATHSIZE],
          app_ReqFile[PATHSIZE];
    UBYTE *app_cya_Conf_Termination[3];
    UBYTE *app_rgp_Conf[3];
    UBYTE **app_List;
    struct RequestList *app_RequestList;
    struct NodeList *app_NodeList;
    struct TextFont *app_Font;
    UBYTE app_LastFontBuf[PATHSIZE];
    int app_Skip[256];
    ULONG app_Flags;
    LONG app_Bytes, app_Time, app_Charges;
};

extern struct Application *app;

// protos

// muiffr.c
extern int main(int argc, char *argv[]);
extern UBYTE *GetCatStr(ULONG gad_id);
extern UBYTE GetCatHotKey(ULONG gad_id);
extern void DispError(int msg_id, UBYTE *buf);
extern int AddListEntry(UBYTE *filenamebuf, UBYTE *bytesbuf, int quiet);
extern void DeleteListEntry(void);
extern int ReadList(int quiet);
extern int SaveReqFile(void);

// clipftxt.c
extern int CopyClip(void);
extern int CutClip(void);
extern int PasteClip(void);

// config.c
extern int ConfAliasReady(void);
extern int AddNodeListEntryInteractively(void);
extern int AddNodeListEntry(struct NodeList *node_list, int quiet, int mode);
extern void ClearNodeList(void);
extern void DeleteNodeListEntry(void);
extern void NodeListDoubleClick(void);
extern int UpdateNodelist(int buf_num);
extern void SaveConfig(void);
extern int LoadConfig(int quiet);
extern void Download(void);

