/****************************************************************/
/* MenuPatch.c							*/
/****************************************************************/
/* Workbench 1.3 called by "LoadWB -debug" installs a Menu	*/
/* without title with the items "debug" and "flushlibs".	*/
/* Gee, this looks ugly! If you have 6 Bytes of continuos	*/
/* memory left somewhere, this is a workaround.			*/
/* Just put MenuPatch somewhere into your Startup-Sequence	*/
/* *after* the LoadWB command and the hidden menu isn't hidden	*/
/* any longer.							*/
/****************************************************************/
/* Legal stuff:							*/
/* This program is written by					*/
/*		Michael Böhnisch,      (billy@uni-paderborn.de)	*/
/*		Löher Str. 2,					*/
/*		D-4790 Paderborn (Germany)			*/
/* It is completely public domain. Do with it whatever you want	*/
/* including sale it for an unreasonal high price, put in any	*/
/* commercial product, rip my name off the title text or	*/
/* delete it from your HD...					*/
/*				Have fun!			*/
/****************************************************************/
/* Compiles nicely with Lattice/SAS C 5.10. Just copy the	*/
/* contents of the "starter_project" drawer into this one,	*/
/* click on "build" and here we go.				*/
/* Haven't tried but should compile with Aztec C5.0 without any	*/
/* problems.							*/
/* No problems with 16 bit ints either.				*/
/****************************************************************/

#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>

#ifdef AZTEC_C
#include <pragmas.h>
#endif

#ifdef LATTICE
#include <proto/exec.h>
#endif

#include <string.h>
#include <stdlib.h>

struct IntuitionBase	*IntuitionBase;

void main(int argc, char *argv[])
{
	struct Screen		*s;
	struct Window		*w;
	struct Menu		*m;
	BYTE			*t;

	IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L);
	if ( ! IntuitionBase ) exit(0);

	s = IntuitionBase -> FirstScreen;
	while ( s && strcmp((char *) s->Title, "Workbench Screen") ) {
		s = s -> NextScreen;
	}

	if ( s ) {
		w = s -> FirstWindow;
		while ( w && strcmp((char *) w->Title, "Workbench") ) {
			w = w -> NextWindow;
		}
		if ( w ) {
			m = w -> MenuStrip;
			while ( m && strcmp((char *) m->MenuName, "     ") ) {
				m = m -> NextMenu;
			}
			if ( m ) {
				t = AllocMem(6L, MEMF_PUBLIC);
				strcpy((char *) t, "Debug");
				m -> MenuName = t;
			}
		}
	}

	CloseLibrary((struct Library *) IntuitionBase);
}
