#include <string.h>
#include <exec/types.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <exec/semaphores.h>
#include <exec/libraries.h>
#include <dos/dos.h>
#include <dos/rdargs.h>
#include <intuition/intuitionbase.h>

#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>

#define LibCall    __geta4 __regargs
#define Prototype  extern

#include "golded:developer/api/include/apilib.h"
#include "golded:developer/include/editor.h"

/* prototypes */

#include "o/lib-protos.h"

/* private defines */

#define MAX_PATHLEN 512

/* dictionary root */

struct Dictionary {

    struct Node                Node;                 /* it's a linked list */
    UBYTE                      File[MAX_PATHLEN];    /* dictionary file */
    UBYTE                     *Data;                 /* dictionary data */
    struct List                Entries;              /* dictionary entries */
    struct Template           *Hash[256];            /* simple hash index */
};

/* dictionary entry */

struct Template {

    struct Node                Node;                 /* it's a linked list */
    UWORD                      Len;                  /* keyword length */
    UBYTE                     *Keyword;              /* keyword string */
    UBYTE                     *Info;                 /* help text */
};

/* we allocate a PlugInContext for each plug-in instance */

struct PlugInContext {

    struct APIClient           APIClient;            /* API handle (exposed to host) */
    struct APIArea             APIArea;              /* area request */
    struct Dictionary         *Dictionary;           /* dictionary root */
    BOOL                       Attached;             /* attached to a container ? */
    UBYTE                     *Text;                 /* text in display */
    BOOL                       Status;               /* use status line for messages ? */
};

/* globals */

extern const char              LibName[];
extern const char              LibId[];

extern struct SignalSemaphore  QuickInfoSemaphore;   /* used to serialize functions */
extern struct List             DictionaryList;       /* root of dictionaries */

/* libraries */

extern struct Library         *IntuitionBase;
extern struct Library         *DiskfontBase;
extern struct Library         *SysBase;
extern struct GfxBase         *GfxBase;

/* arrays */

extern BOOL                    IsSPC     [256];
extern BOOL                    IsBOUNDARY[256];
