/** showicon.c  v1.0  azteccv5.0  (c)1994 Dalibor S.Kezele **/

/* shortification to make code readable on 80colon' display */

#include <stdio.h>
#include <workbench/workbench.h>
#include <workbench/icon.h>
#include <intuition/intuition.h>

struct Library *IconBase;
struct IntuitionBase *IntuitionBase;

struct DiskObject *DO;
struct Gadget *GD;
struct NewWindow NW = { 0, 11, 640, 245, 0, 1, CLOSEWINDOW|VANILLAKEY,
	WINDOWDRAG|WINDOWCLOSE|WINDOWDEPTH|ACTIVATE|RMBTRAP|NOCAREREFRESH,
	NULL, NULL, (UBYTE *)"ShowIcon", NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN };
struct Window *WD;
struct IntuiMessage *IM = NULL;

void main(int argc, char **argv)
{
if((argc!=2)||((argc==2)&&(*(*(argv+1))=='?'))) {
	puts("\033[33mShowIcon\033[31m v1.0 by Dalibor S.Kezele");
	puts("Usage: ShowIcon <filename> or <?> !");
	exit(1);
	}
if(IconBase = (struct Library *)OpenLibrary(ICONNAME, 0L))
	if(DO = (struct DiskObject *)GetDiskObject(*(argv+1))) {
		if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L))
			GD = (struct Gadget *)&DO -> do_Gadget;
			NW.FirstGadget = GD;
			if(WD = (struct Window *) OpenWindow(&NW)) {
				while((IM -> Class != CLOSEWINDOW)&&( IM -> Class != VANILLAKEY))
					IM = (struct IntuiMessage *)GetMsg(WD -> UserPort);
				ReplyMsg(IM);
				CloseWindow(WD);
				FreeDiskObject(DO);
				CloseLibrary(IconBase);
				CloseLibrary(IntuitionBase);
				}
			}
}
