/* unsea.h - Part of the unsea program.
 *   Copyright 1992 by David W. Rankin, Jr.
 * 
 * See "unsea.txt" for full copyright information applying 
 * to all text in this package. 
 *
 *
 * Header file for the rest of unsea. */

#include <stdio.h>

#include <stdlib.h>

#include <stddef.h>

#include <string.h>

/* USER DEFINABLE FLAGS 
 * The flags in this area can be changed by the user to customize
 * the way unsea works. */

#undef UNIX_DELETE
	/* If this is defined, unlink() is used instead of remove().
	 * For compiler libraries that aren't 100% ANSI compatable */

/* End of user definable flags
 * You SHOULD NOT change any of the statements below this line */
 
/* required define statements */
#undef TRUE
#define TRUE	1

#undef FALSE
#define FALSE	0

/* The next 2 defines are for use with exit(), to show explicitely
 * whether the exit was successful or not. These should be defined
 * in the C libraries, but I have grown not to trust the libraries
 * a lot in things like this... */

#ifndef EXIT_FAILURE
#	define EXIT_FAILURE 1
#endif

#ifndef EXIT_SUCCESS
#	define EXIT_SUCCESS 0
#endif

#ifndef FILENAME_MAX
#	define FILENAME_MAX 63
/* This is for the drain-bramaged compilers that refuse to 
 * define all the constants. */
#endif /* FILENAME_MAX */

#ifdef THINK_C /* This is true for THINK C compilers, usually */
#	define MACINTOSH
#	include <console.h>
#endif  /* THINK_C */

#define ERROR(ARGUMENT1, ARGUMENT2) fprintf(stderr,ARGUMENT1, ARGUMENT2);\
fclose(oldfilep)
#define ERROR3(ARGUMENT1, ARGUMENT2,ARGUMENT3) fprintf(stderr,ARGUMENT1,\
ARGUMENT2,ARGUMENT3);fclose(oldfilep);fclose(newfilep)

	/* WARNING: This routine is unsea_mb specific!!! *
	   ERROR() allows the program to neatly deal with errors, by simply *
	   stating it in the code, and then the preprocessor comes along later *
	   and adds the rest. */

#ifdef UNIX_DELETE
#	define DELETE_FILE(arg) unlink(arg)
/* Use the UNIX standard delete file routine */
#else
#	define DELETE_FILE(arg) remove(arg)
/* Use the ANSI C standard delete file routine. The recommended 
 * macro */
#endif /*UNIX_DELETE */

/* end of definitions */

/* start of struct definitions */

struct starting_flags
		{
		char there,
				/* This is TRUE if there are flags in the first place */

			name_given,
				/* This flag is true if each file has a "child" file name */

			ignore_sitd_seas,
				/* Used to record status of StuffIt SEAs, as decided on
				 * the command line. */

			ignore_cpt_seas,
				/* Same as ignore_sitd_seas, except for Compact Pro SEAs. */

			ignore_dd_seas,
				/* At this time, unsea will not convert DiskDoubler SEAs. When
				 * it does, this will be the boolean for allowing or preventing
				 * conversion. */

			less_talk,
				/* when the 'b'rief mode is selected, unsea will refrain
				 * from printing out a detailed analysis of the SEA being
				 * converted. */

			overwrite;
				/* When selected, unsea will overwrite when it finds
				 * a file with the same name as the new file to be
				 * generated. */

		int sea_mode;
			/* This int will hold the type of SEA that the file is. */

		}; /* end of struct starting_flags */

/*  function declarations */

void main(int argc, char *argv[]);

void startupmesg(void);

void help(void);

void restypecopy(unsigned char block[], const int startint, char s[]);

int unsea_mb(char *oldfilename, char *newfilename);

int getfileblock(FILE *fp, unsigned char block[], const int blocksize);

int convert_file_name(char *oldfilename, char *newfilename, const int convert_all);

int check_mb_sea(unsigned char block[]);

void convert_mb_header(unsigned char block[]);

int sendfileblock(FILE *fp, unsigned char block[], const int blocksize);

unsigned long int getforksize(unsigned char block[]);

unsigned long int getblocksize(unsigned long int bytes);

unsigned short updatecrc(unsigned char c, unsigned short crc);

int check_startup_flags(char *argv);

/* end of function prototypes */
