/*
 *  FILE
 *	funcs.h
 *
 *  DESCRIPTION
 *	This file is the headerfile for the funcs.c file.
 *	It contains includes, structure definitions, definitions
 *	and forward references.
 */

	/* Headerfiles */
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>

#include <string.h>

#define  ARP_PRIVATE
#include <libraries/arpbase.h>

#include <proto/exec.h>

#include "globals.h"		/* All global definitions */

/*
 *  STRUCTURE
 *	valuebuf
 *
 *  DESCRIPTION
 *	Store the value of the variable temporary.
 *
 *	When this strucure is used for reading, the vb_buf points
 *	to an internal buffer containing the value. The vb_pos
 *	is the read pointer and the vb_end is size of the buffer.
 *
 *	During writing, the vb_buf points to a writing buffer,
 *	vb_pos is the write pointer, and vb_end is the size of
 *	the write. If the buffer is to small ReAlloc is called.
 *	The filename is stored in vb_name.
 */

struct valuebuf {
    char * vb_buf;
    long   vb_end;
    long   vb_pos;
    long   vb_flags;
    char * vb_name;
};


/*
 *  STRUCTURE
 *	myFileLock
 *
 *  DESCRIPTION
 *	This is a standard `FileLock' structure, but with the fl_Key
 *	field changed to fl_Name.
 */

struct myFileLock {
    BPTR	     fl_Link;
    char	   * fl_Name;		/* Used to be `LONG fl_Key' */
    LONG	     fl_Access;
    struct MsgPort * fl_Task;
    BPTR	     fl_Volume;
};


/*
 *  DEFINTIONS
 */

#define BTOC(x)		((void *) ( ((LONG)(x)) << 2 ) )
#define CTOB(x)		((BPTR)   ( ((LONG)(x)) >> 2 ) )

#define DOS_FALSE	(0)
#define DOS_TRUE	(-1)

#define NAMESIZE	(256)	/* Size of a buffer for storing names	*/

#define BUFSTEP		(128)	/* Additional allocation during writes	*/

#define FIRST_KEY	(1)

	/* Flags to be stored in vb_flags */
#define ENVB_READ	(0)                
#define ENVB_WRITE	(1)

#define ENVF_READ	(1<<ENVB_READ)
#define ENVF_WRITE	(1<<ENVB_WRITE)

#define MAX(x,y)	((x)>(y)?(x):(y))

	/* Forward References */
extern char		* mygetenv	(register char *);
extern char		* getnextenv    (register struct FileInfoBlock * fib,
					 register struct DosPacket * pkt);
extern char		* getenvname	(register char *);
extern void		* ReAlloc	(void *, long, long, long);

