/*
** ScanHTML.h - Defines, Includes & other stuff
*/

/// Includes

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <proto/exec.h>
#include <exec/execbase.h>
#include <exec/lists.h>
#include <exec/nodes.h>
#include <exec/memory.h>
#include <proto/dos.h>
#include <dos/stdio.h>
#include <proto/rexxsyslib.h>
#include <rexx/storage.h>
#include <proto/utility.h>
///

/// Prototypes

#include "ScanHTML_protos.h"
///

/// Defines

// Options (ReadArgs)

#define OPT_T   "I=IN/A,O=OUT/A,A=APPEND/S,B=BASE/K,P=PATTERN/K," \
                "P2=PATTERN2/K,NOBG/S,NOF#=NOFIRST#/S,NOHREF/S," \
                "NOSRC/S,NQ=NOQUERY/S,STRIP#/s"
#define OPT_IN          0
#define OPT_OUT         1
#define OPT_APPEND      2
#define OPT_BASE        3
#define OPT_PATTERN     4
#define OPT_PATTERN2    5
#define OPT_NOBG        6
#define OPT_NOFN        7
#define OPT_NOHREF      8
#define OPT_NOSRC       9
#define OPT_NOQUERY     10
#define OPT_STRIPN      11
#define OPT_CNT         12

// CTRL-C Handling

#define SIGMASK     SIGBREAKF_CTRL_C
#define GOT_BREAK   5L
#define CHKBRK      if (CheckSignal(SIGMASK)) { Printf("***Break\n"); EndAll(GOT_BREAK, a);}

// Fixed Buffers/defaults

#define IN_B_SIZE   (8*1024)    /* Input File Buffering */
#define OUT_B_SIZE  (4*1024)    /* Output File Buffering */
#define S_SIZE      (4*1024)    /* Max size of chars between "<" & ">" */
#define U_SIZE      (1024)      /* Max size of URL found/completed */
#define B_SIZE      (1024)      /* Max size of BASE given on arg-line */
///

/// Struct/type defs

struct Global
{
    LONG            opts[OPT_CNT];
    BPTR            fhin;           /* Input FH */
    BPTR            fhout;          /* Output FH */
    struct RDArgs   *rdargs;
    TEXT            str[S_SIZE];    /* A string between "<" & ">" */
    TEXT            url[U_SIZE];    /* Url found */
    TEXT            *tok;           /* Tokenized pattern */
    LONG            toklen;         /* Length of tok pattern */
    TEXT            *tok2;          /* Tokenized pattern */
    LONG            tok2len;        /* Length of tok pattern */
    TEXT            base[B_SIZE];   /* Current URL ending with a DIRECTORY */
};
///


