DOS 2.0 Utilities Disk 1 (Sep 1991) : KickReboot / KickReboot.c

/* Adds KickReboot Menu to Tools Menu on Workbench 2.0                   */
/* to give a choice to boot a different KickStart without powering       */
/* down the system on A3000 machines who loads Kickstart from Harddisk   */
/* This time there is no way to remove it (but why ??)                   */
/* This code is released to the Public Domain, do with it what you want  */
/* Author Joachim Bremer, West Germany, I can be reached at Bix: bremer  */
/* MacNet: prismaqt, attn Joachim Bremer                                 */

/* compile with : lc -v -O KickReboot                                    */
/* assemble with: asm -iinclude: KickBoot.a                              */
/* link with    : blink lib:cback.o+KickReboot.o+KickBoot.o to KickMenu
			lib:lc.lib+lib:amiga.lib                         */

/* for use without pragmas you must have at least access to workbench.h  */
/* and amiga.lib from 1.4 alpha or higher.                               */


#include "exec/types.h"
#include "exec/ports.h"
#include "workbench/workbench.h"
#include "stdio.h"
#include "proto/exec.h"

long _BackGroundIO = 0;
long _stack = 4000;
char *_procname = "RebootWbMenu";
long _priority = -20;

CPTR WorkbenchBase;

extern void KickReboot();

/* not used if include 1.4 alpha or newer is available */

struct AppMenuItem {
        struct Node ami_Node;
        void *ami_Ptr;
        struct MsgPort *ami_MsgPort;
        ULONG ami_UserData;
        ULONG ami_ID;
};



#pragma libcall WorkbenchBase AddAppMenuItem 48 981004
#pragma libcall WorkbenchBase RemoveAppMenuItem 4e 801

VOID
_main(void)
{
    struct AppMenuItem *app;
    struct AppMenuItem *AddAppMenuItem(ULONG,ULONG,char *,struct MsgPort *);
    struct MsgPort *port;
    struct IntuiMessage *msg;
    WorkbenchBase = OpenLibrary("workbench.library",36);
    if (!WorkbenchBase) {
	exit(9);
	}
    if (!(port = CreatePort("KickReboot",0L))) {
	CloseLibrary(WorkbenchBase); exit(9); }
    app = AddAppMenuItem(0,0,"KickReboot",port);
    for (;;) {
    WaitPort(port);
    if(msg = (struct IntuiMeassage *) GetMsg(port)) break;
    }
    ReplyMsg((struct msg *) msg);
    Delay (50);
    KickReboot();
/* only for sake of a good programmer ..... code never reaches here */
    DeletePort(port);
    RemoveAppMenuItem(app);
    CloseLibrary(WorkbenchBase);
}