/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* |_o_o|\\ Copyright (c) 1986 The Software Distillery.  All Rights Reserved */
/* |. o.| || This program may not be distributed without the permission of   */
/* | .  | || the authors.                                                    */
/* | o  | ||    Dave Baker     Ed Burnette  Stan Chow    Jay Denebeim        */
/* |  . |//     Gordon Keener  Jack Rouse   John Toebes  Doug Walker         */
/* ======          BBS:(919)-471-6436      VOICE:(919)-469-4210              */ 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
 * VERY loosely based on the input.device example by Rob Peck, 12/1/85
 */

#include "popcli.h"
#include "popbug.h"


#ifdef BUGMACROS
BPTR __BugWindow;
#endif

/************************************************************************/
/* the main program to do the popcli stuff                              */
/************************************************************************/

#undef global   /* Since it really is local in this routine */

void _main()
   {
   GLOBAL_DATA         global;
   struct OURMSG       pmsg;   /* for AREXX message parsing */

   int rc;

   memset( (char *)&global, 0, sizeof(global) );
   
   DOSBase = (struct DosBase *)OpenLibrary("dos.library",0);

   global.stdout = Open("*",MODE_OLDFILE);

   rc = popparse( &global, "quit", &pmsg );
   rc = popparse( &global, "add 0x00 cmd run lse", &pmsg );
   rc = popparse( &global, "free 0x02", &pmsg );
   rc = popparse( &global, "30", &pmsg );
   rc = popparse( &global, "blank", &pmsg );
   rc = popparse( &global, "add f7 minchip 50000 nowb cmd run lse", &pmsg );

   if (DOSBase)
      CloseLibrary( (struct Library *)DOSBase );
}

#ifdef BUGMACROS
int     myprintf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
char	*fmt;
long	a1, a2, a3, a4, a5, a6, a7, a8, a9;
{
	int	bytes, fmtlen;
	char	buff[512];

	if (__BugWindow <= 0) return(0);

	fmtlen = strlen(fmt);
	if (fmtlen > 70)
	{
		bytes = sprintf(buff, "BUGMSG: 0x%x, length %d\n", fmt, fmtlen);
		Write(__BugWindow, buff, bytes);
		return(0);
	}
	else
	{
		bytes = sprintf(buff, "BUG(%s)\n", fmt);
		Write(__BugWindow, buff, bytes);
	}

	bytes = sprintf(buff, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);

	if (bytes < sizeof(buff))
		Write(__BugWindow, buff, bytes);
	else
		Write(__BugWindow, "!!! msg too big - prepare to die\n",
			    strlen("!!! msg too big - prepare to die\n"));
	return(0);
}
#endif
