#ifndef LIBRARIES_ASCII_H
#define LIBRARIES_ASCII_H 1

/*-- AutoRev header do NOT edit!
*
*   Program         :   ascii.h
*   Copyright       :   © 1991 Jaba Development
*   Author          :   Jan van den Baard
*   Creation Date   :   12-Aug-91
*   Current version :   1.2
*   Translator      :   Several.
*
*   REVISION HISTORY
*
*   Date          Version         Comment
*   ---------     -------         ------------------------------------------
*   12-Aug-91     1.2             Added "FindFrom" proto.
*   23-Apr-91     1.1             Removed some useless data in structures.
*   16-Apr-91     1.0             Initial version!
*
*-- REV_END --*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_LISTS_H
#include <exec/lists.h>
#endif

#ifndef LIBRARIES_DOS_H
#include <libraries/dos.h>
#endif

#ifndef LIBRARIES_NOFRAG_H
#include <libraries/nofrag.h>
#endif

/*
 * Line bit/flags definitions.
 */
#define LNB_Split       0
#define LNF_Split       1<<LNB_Split

/*
 * AsciiText bit/flags definitions.
 */
#define ATB_SkipEsc     0
#define ATF_SkipEsc     1<<ATB_SkipEsc
#define ATB_TabConvert  1
#define ATF_TabConvert  1<<ATB_TabConvert

/*
 * Some miscellanious definitions.
 */
#define MAXLINE         256
#define ANSITAB         8
#define MINTAB          2
#define MAXTAB          16

/*
 * Possible errors.
 */
#define ASE_OK           0
#define ASE_EOF         -1
#define ASE_NOMEM       -2
#define ASE_READ        -3
#define ASE_WRITE       -4
#define ASE_NOFILE      -5
#define ASE_FILETYPE    -6

struct Line {
    struct Line         *Next;
    struct Line         *Prev;
    UBYTE               *Text;
    UWORD                Size;
    UWORD                Flags;
};

struct AsciiText {
    struct Line         *First;
    struct Line         *End;
    struct Line         *Last;
    UWORD                NumLines;
    UWORD                NumSplit;
    ULONG                NumBytes;
    UWORD                TabJump;
    UWORD                MaxChars;
    UWORD                Flags;
    struct MemoryChain  *MemoryUsed;
};

struct StringScan {
    struct AsciiText    *Text;
    struct Line         *Line;
    UBYTE               *String;
    UWORD                StringSize;
    UWORD                TextOffset;
    UBYTE               *Address;
};

struct BuffIO {
    BPTR                 Handle;
    ULONG                FileMode;
    UBYTE                Buffer[1024];
    UBYTE                Line[MAXLINE];
    UBYTE               *Pointer;
    UWORD                BytesLeft;
    ULONG                BytesDone;
    WORD                 Error;
};

#ifndef __STKARGS__ /* #define this if used with DICE it's "__regargs" */
#define __STARG
#else
#define __STARG     __stkargs
#endif

__STARG struct BuffIO   *BOpen( char *, long );
__STARG long BClose( struct BuffIO * );
__STARG long BGetC( struct BuffIO * );
__STARG long BPutC( struct BuffIO *, long );
__STARG long BIoErr( struct BuffIO * );
__STARG struct Line *BGetS( struct BuffIO *, struct AsciiText * );
__STARG long BPutS( struct BuffIO *, struct Line * );
__STARG struct AsciiText *AllocAscii( long, long, long );
__STARG void FreeAscii( struct AsciiText * );
__STARG long FirstOccurrence( struct AsciiText *, UBYTE *, struct StringScan *, long );
__STARG long NextOccurrence( struct StringScan *, long );
__STARG long PreviousOccurrence( struct StringScan *, long );
__STARG long FindFrom( struct AsciiText *, UBYTE *, struct StringScan *, struct Line *, long );
#endif    /* LIBRARIES_ASCII_I */
