/* MPMorph - Amiga Morphing program */
/* Copyright (C) © 1996 Mark John Paddock */

/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* any later version. */

/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
/* GNU General Public License for more details. */

/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */

/* mark@topic.demon.co.uk */

#ifndef __UNIX_H
#define __UNIX_H

#ifndef _AMIGA
#define __MPCLI
#endif

#ifdef __MPCLI
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#ifndef BOOL
#define BOOL int
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define UBYTE unsigned char
#define ULONG unsigned long
#define WORD short
#define UWORD unsigned short
#define LONG long
#define USHORT unsigned short
#define APTR void *
#define MEMF_CLEAR 1

struct MPImage {
	UBYTE *Red;
	UBYTE *Green;
	UBYTE *Blue;
	UWORD Width;
	UWORD Height;
	BOOL GreyScale;
};

struct List {
   struct  Node *lh_Head;
   struct  Node *lh_Tail;
   struct  Node *lh_TailPred;
};

struct Node {
    struct Node *mln_Succ;
    struct Node *mln_Pred;
};
#define MinNode Node
extern void Remove (struct Node *node);
extern void AddTail(struct List *list,struct Node *node);
extern void NewList(struct List *list);
#ifndef min
#define min(a,b) (a<b)?(a):(b)
#endif
#ifndef max
#define max(a,b) (a>b)?(a):(b)
#endif
/* Open a GUI */
extern int OpenUnixInterface(void);
/* Close a GUI */
extern void CloseUnixInterface(void);
/* Disable GUI */
extern void DisableWindow(void);
/* Enable GUI */
extern void EnableWindow(void);
/* Check to quit 0 = quit */
extern int HandleProgressIDCMP(void);
/* Frame and Line Processes */
extern void SetMaxFrame(int a);
extern void SetFrame(int a);
extern void SetMaxLine(int a);
extern void SetLine(int a);

#define Error(a,b,c,d) UnixError(a,c)
#define LoadMPImage(a,b,c) UnixLoadImage(a)

extern void FreeMPImage(struct MPImage *mpi);
extern char *MPImageErrorMessage(void);
extern void UnixError(char *message,char *extra);
extern void AddMessage(char *Message);
extern struct MPImage *UnixLoadImage(char *filename);
extern BOOL RescaleMPImage(struct MPImage *mpi,int width,int height);
extern BOOL SaveMPImage(char *filename,UBYTE *r,UBYTE *g,UBYTE *b,int width,int height);

extern char *ArgString(char **ArgArray,char *check,char *def);
extern unsigned char *MyArgString(unsigned char *check,unsigned char *def,int ignore);
extern unsigned long MyArgInt(unsigned char *check,long def,int ignore);
extern BOOL MatchToolValue(char *a,char *b);

#endif
