/****************************************************************************
  This is an example application to test the C "complex.library". Make the
  glue code with LibTool (-c option).

Manx 3.6

cc +p ComplexCApp.c
LibTool -cho glue.asm ComplexC.fd
as -cd glue.asm
ln -o ram:TestProgram ComplexCApp.o glue.o -lcl32

Lattice 5.0

lc -b0 ComplexCApp.c
LibTool -cho glue.asm ComplexC.fd
assemble glue.asm
blink lib:c.o ComplexCApp.o glue.o LIB lib:lcnb.lib TO ram:TestProgram

****************************************************************************/

#ifdef AZTEC_C
#define NARGS
#define NO_PRAGMAS
#endif

#ifdef AZTEC_C
#include "functions.h"
#else
#include "proto/all.h"
#endif

#include <exec/types.h>
#include <exec/io.h>
#include <intuition/intuition.h>

/* LibTool made this include file */
#include ComplexC.h

ULONG  argcount;  /* Saves argc from main(). argcount==0, then run from WB. */

#ifdef NARGS
VOID exit_program();
#else
VOID exit_program( char, ULONG );
long main( long, char ** );
#endif

VOID exit_program( error_words, error_code )	/* All exits through here. */
char  error_words;
ULONG error_code;
{
	if( argcount && error_words ) puts( error_words );
	CloseComplexBase();
	exit( error_code );
}


/************************ MAIN ROUTINE *****************************/

VOID main(argc, argv)
LONG argc;
char **argv;
{
register struct Window *myWind;

	argcount = argc;

	/* open complex.library */
	if (! (OpenComplexBase()) )
		exit_program("Can't open complex library.\n", 10L);

	/* open a window by calling complex lib's MakeWindow() */
	if ( !( myWind = MakeWindow() ) )
		exit_program("Can't open window.\n", 11L);

	/* Print text to the window and wait for CLOSEWINDOW */
	PrintMsg(10L, 20L, myWind, "Close window to exit");

	/* Close the window */
	RemWindow(myWind);

	exit_program(0L,0L);
}
