/*
 *	File:					Alert.c
 *	Description:	Displays given parameter in an standard system-alert.
 *	Version:			1.1
 *	Author:				Ketil Hunn
 *	Mail:					hunn@dhmolde.no
 *
 *	Copyright © 1993 Ketil Hunn.
 *
 *	In order to list the source-files included in this package properly,
 *	the TAB size should be set at 2.
 *
 *	To compile and link:
 *	sc link optimize nostandardio smallcode smalldata Alert.c
 */

#include <stdlib.h>
#include <string.h>
#include <intuition/intuition.h>
#include <clib/intuition_protos.h>
#include <clib/exec_protos.h>
#include "Includes/MyAlert.h"
#include "ENV:current_date.h"

#define PROGRAM "Alert"
#define VERSION "V1.1"
char const *version = "$VER: " PROGRAM " " VERSION " (" CURRENT_DATE ")";

struct IntuitionBase	*IntuitionBase;

main(int argc, char *argv[]) {
	if(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",33))
	{
		if(argc<2 || !(strcmp(argv[1],"?")))
			MyAlert(RECOVERY_ALERT,
							PROGRAM " " VERSION "  © 1993 Ketil Hunn\n"
							"Usage: Alert TEXTLINE/M\n\n"
							"Each given parameter will appear as one line of text "
							"in the alert.");
		else
		{
			int i=0;
			char	*text;

			if(text=malloc(2400))
			{
				strcpy(text,argv[1]);
				for(i=2; i<argc; ++i)
				{
					strcat(text,"\n");
					strcat(text,argv[i]);
				}
				MyAlert(RECOVERY_ALERT,text);
				free(text);

			}
			else 
				MyAlert(RECOVERY_ALERT,"Out of memory!");
		}
		CloseLibrary((struct Library *)IntuitionBase);
	}
	exit(0);
}
