#ifndef CC_EXPORT_H
#define CC_EXPORT_H
//
// export.h
//
// The classdefinitions for the export of data from ResGrep.
//
// 23.03.1992 Andre    written.
//

extern "C" {
#include <stdio.h>
#include "list.h"
};

#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (~FALSE)
#endif

typedef enum boolean
{
   false=FALSE, true=TRUE
} bool;

enum send
{
   Clipboard, File
};

class convert;

typedef int (convert::*exportfunc)(FILE *, unsigned long);

class convert :  public node
{
   // The type is placed in node::pack, the conversion name in node::name.
   char  *command;   // The command (or the ARexx skript) to be executed.
   bool   isARexx;   // True is Command is an ARexx skript. (The skript is
		     // directly send to the ARexx-Host.)
   send   sendto;
   char  *filename;  // The filename the data is written to. (Only set if
		     // 'sendto' is equal 'File'.)
   bool   builtin;   // True if function is builtin (can't be removed).
   int	  funcnum;   // Number of Function
 public:
   convert(unsigned long theType,
	   int thefuncnum,
	   char *theName="raw data",
	   char *theCommand=NULL, bool theIsARexx=true,
	   send theSendTo=Clipboard, char *theFilename=NULL,
	   bool thebuiltin=true);
   ~convert(void);

   // exportfunc export;
   void docommand(void);
   void ReadText(void);

   int getfuncnum(void);

   // 'export()' is one of:

							 // Number
   int rawdata(FILE *fp, unsigned long DataOffset);      // 0
   int text2ascii(FILE *fp, unsigned long DataOffset);   // 1
   int text2ftxt(FILE *fp, unsigned long DataOffset);    // 2
   int snd28svx(FILE *fp, unsigned long DataOffset);     // 3
   int ICNd2ilbm(FILE *fp, unsigned long DataOffset);    // 4
   int icl42ilbm(FILE *fp, unsigned long DataOffset);    // 5
   int icl82ilbm(FILE *fp, unsigned long DataOffset);    // 6
   int icsd2ilbm(FILE *fp, unsigned long DataOffset);    // 7
   int ics42ilbm(FILE *fp, unsigned long DataOffset);    // 8
   int ics82ilbm(FILE *fp, unsigned long DataOffset);    // 9

   // Hilfsfunktionen

   int icons2ilbm(FILE *fp, unsigned long DataOffset,
			unsigned long x, unsigned long y,
			unsigned long ftiefe);



   friend void editconv(void);
   friend void UpdateWindow(node *,int );
   friend void savesettings(void);
   friend int exportres(unsigned long theType, FILE *fp, unsigned long DataOffset);
};

void initexport(void);
void editconv(void);

#define NUM_EXPORTFUNC	4
extern exportfunc exportfunctions[];

// Funktionen aus settings.cc
void savesettings(void);
void savesettingsas(void);
void loadsettings(void);
void freeconvert(list *c);

// Funktionen aus Output.cc
void ResError(char *text);
void ResWarning(char *text);
void ResMessage(char *text);
int  ResAsk(char *text, char *wahl);


// Errors from export functions
#define ERR_NO		      0
#define ERR_NO_CONVERS	      1
#define ERR_FILE_CORRUPTED    2
#define ERR_NO_MEMORY	      3
#define ERR_FILE_OPEN	      4
#define ERR_WRITE	      5
#define ERR_NO_CLIPBOARD      6
#define ERR_NO_FILE	      7
#define ERR_OPENIFF	      8

#endif
