doc@j.cc.purdue.edu (10/05/86)
Reply-To: <ihnp4!mcnc!rti-sel!sas!walker@ee.ecn.purdue.edu> Here is the source for POPCLI II. I will follow it with the UUENCODED binary as soon as I unpack our copy of UUENCODE and figure out how to use it. #----CUT HERE---CUT HERE---CUT HERE---CUT HERE---CUT oh you know it by now. #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # This archive created: Thu Sep 25 17:41:27 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'popcli.doc'" '(5935 characters)' if test -f 'popcli.doc' then echo shar: over-writing existing file "'popcli.doc'" fi sed 's/^X//' << \SHAR_EOF > 'popcli.doc' /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* |_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 */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ POPCLI II by John Toebes ) 1986 The Software Distillery. All Rights Reserved 235 Trillingham Ln, Cary, NC 27511 Contributions to continue development of this and other fine products for the Amiga should be sent to the Software Distillery at the above address. Other Products produced by the Software Distillery are: BLINK - the Turbo-charged Alink replacement HACK - The Amiga port of the famous UNIX game MAKE - A software development tool one shouldn't be without KERMIT - The World renown file transfer protocol brought to the Amiga ICONEXEC, SETALTERNATE, SETWINDOW - Icon manipulation tools TSIZE - A short utility for determining directory sizes. All of these are available on our BBS. Permission is hereby granted to distribute this program provided both this documentation accompanies the executable and that no charge is made for its distribution. POPCLI is designed to solve two problems at once. First it provides a simple way of starting another CLI at any time without having to load workbench or exit whatever program you may be using. Second it has a builtin screen saver mode that automatically turns off the Amiga display when there has been no input for a given period of time. Once POPCLI is running, you can use it to get a new CLI from whatever program you are running by pressing Left Amiga and ESC at the same time. What this does is to bring the workbench screen to the front and then start up a new CLI window on the workbench screen. This is extremely handy when you start a program from CLI and then find you need to do a CLI command. The other function that POPCLI performs is to blank the screen for you. This saves on the wear of the monitor phospher. It will do this for you automatically any time that you have not pressed any key or moved the mouse for a given period of time regardless of what has been written to the screen. This is useful when you leave the Amiga on unattended so that you don't have to mess with the brightness control or worse yet tunr the monitor off putting wear and tear on its power supply. Furthermore it only takes a touch of the mouse or any key on the keyboard to bring it all back. To use POPCLI, you need to execute the command: RUN POPCLI <seconds> <command> Where <seconds> is any number of seconds after which the screen saver is to go into effect. If nothing is specified it defaults to turning off the screen after 300 seconds. (Five minutes) Note that it makes its decision to shut blank the screen solely upon the absence of any keyboard, gameport, or mouse input. Even if a program is printing to the screen it will shut down. This is not a problem, to unblank the screen merely move the mouse or touch any key (SHIFT or CTRL are excellent choices since they don't do anything). <command> is the command to be executed when the Left Amiga and ESC keys are pressed simaultaneously. By default the command is NEWCLI >NIL: to bring up a CLI window in the center of the screen. Note the >NIL: on the command to supress any output that the NEWCLI program may give. This is important because at the time the command is executed, the original window may be long gone. If you wish to have a CLI come up elsewhere on the screen you can put the window definition in the command such as: NEWCLI >NIL: CON:0/0/640/200/MYCLI Which will open a CLI to fill the entire screen. POPCLI does no parsing on the command, merely passing the ENTIRE string without any processing to AmigaDOS. If you wish to specify a command with POPCLI you must include the seconds value followed by one or more spaces. Some valid commands are: RUN POPCLI 200 RUN POPCLI 200 NEWCLI >NIL: CON:0/0/640/100/MYWINDOW RUN POPCLI 10 RUN POPCLI 180 NEWCLI >NIL: CON:0/10/640/120/POPUP To install a copy of POPCLI on your workbench, put a copy of POPCLI in your C directory and edit the Startup-Sequence file in the S directory to add a RUN POPCLI command of your own taste. Notes: 1) Once POPCLI is installed, the only way to get rid of it is to reboot. 2) POPCLI blanks the screen by creating a one bit-blane lo-res screen in front of all other screens and setting the background color to solid black. It then turns off the display freeing the cycles for any program that might be running. 3) Once the screen blanks, if the AMIGA is left undisturbed for 68.096 years the screen may briefly flash back on for the next 68.096 years. I have not taken the time to test this. If this turns out to be a problem, please let me know. Enhancements Provided under POPCLI II: * POPCLI now runs from WORKBENCH. An icon is provided for doing so. When run from workbench, the default command and default times will be used. * When run from CLI, the original window now goes away. In doing so, it also appears that incompatibilities with 1.2 have been removed. Please feel free to comment on potential future improvements. * The size of the screen used to blank the display has been reduced to reduce memory required to blank the screen. * POPCLI has been recompiled to take advantage of the latest features of 3.04 Lattice and BLINK. Although source is being distributed, it is not likely that a version of POPCLI could be reconstructed without these products. SHAR_EOF if test 5935 -ne "`wc -c 'popcli.doc'`" then echo shar: error transmitting "'popcli.doc'" '(should have been 5935 characters)' fi echo shar: extracting "'popcli.c'" '(9065 characters)' if test -f 'popcli.c' then echo shar: over-writing existing file "'popcli.c'" fi sed 's/^X//' << \SHAR_EOF > 'popcli.c' /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* |_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 FILES * * * * * * * * * * * */ #include <exec/types.h> #include <exec/nodes.h> #include <exec/lists.h> #include <exec/memory.h> #include <exec/interrupts.h> #include <exec/ports.h> #include <exec/libraries.h> #include <exec/io.h> #include <exec/tasks.h> #include <exec/execbase.h> #include <exec/devices.h> #include <devices/timer.h> #include <devices/input.h> #include <devices/inputevent.h> #include <intuition/intuition.h> #include <libraries/dos.h> #include <graphics/gfxmacros.h> #include <hardware/custom.h> #include <hardware/dmabits.h> /* * * * * * * * * * * CONSTANTS * * * * * * * * * * * * */ #define TIMEINTERVAL 1L /* in seconds */ #define DEFLIMIT 300 /* two minute timeout */ #define ESCAPEKEY 0x45 #define DEFCMD "NEWCLI >NIL: <NIL:" #define BANNER "0;33mPOPCLI II0m by John Toebes - Copyright ) 1986 The Software Distillery\n 235 Trillingham Ln, Cary NC 27511 BBS:(919)-471-6436\n" #define BANNER1 "Usage: 1mRUN POPCLI0m [secs [command]]\nsecs is number of seconds before blanking screen\ncommand is to be executed when Left Amiga-Escape is pressed\n" /* * * * * * * * * * * GLOBAL VARIABLES * * * * * * * * * */ typedef struct { struct task *buddy; ULONG createclisig; ULONG unblanksig; ULONG noevents; struct Screen *blankscreen; } GLOBAL_DATA; /************************************************************************/ /* the handler subroutine - called through the handler stub */ /************************************************************************/ struct InputEvent *myhandler(ev, gptr) struct InputEvent *ev; /* and a pointer to a list of events */ register GLOBAL_DATA *gptr; /* Everything we need to know about */ { register struct InputEvent *ep, *laste; /* run down the list of events to see if they pressed the magic button */ for (ep = ev, laste = NULL; ep != NULL; ep = ep->ie_NextEvent) { if ((ep->ie_Class == IECLASS_RAWKEY) && (ep->ie_Code == ESCAPEKEY) && (ep->ie_Qualifier & IEQUALIFIER_LCOMMAND)) { /* we can handle this event so take it off the chain */ if (laste == NULL) ev = ep->ie_NextEvent; else laste->ie_NextEvent = ep->ie_NextEvent; /* now tell him to create the new cli */ Signal(gptr->buddy, gptr->createclisig); } else laste = ep; if (ep->ie_Class != IECLASS_TIMER) { gptr->noevents = 0; if (gptr->blankscreen != NULL) Signal(gptr->buddy, gptr->unblanksig); } } /* pass on the pointer to the event */ return(ev); } /* * * * * * * * * * * EXTERNAL ROUTINES * * * * * * * * * */ struct IntuitionBase *IntuitionBase = NULL; struct GfxBase *GfxBase = NULL; long DOSBase = 0; extern struct Custom custom; struct NewScreen NewScreen = { 0, 0, 320, 30, 1, 0, 1, NULL, CUSTOMSCREEN, NULL, NULL, NULL, NULL }; extern APTR AllocMem(); extern struct MsgPort *CreatePort(); extern struct IOStdReq *CreateStdIO(); extern struct Screen *OpenScreen(); extern void HandlerInterface(); extern struct task *FindTask(); /************************************************************************/ /* Queue a timer to go off in a given number of seconds */ /************************************************************************/ void QueueTimer(tr,seconds) struct timerequest *tr; ULONG seconds; { tr->tr_node.io_Command = TR_ADDREQUEST; /* add a new timer request */ tr->tr_time.tv_secs = seconds; /* seconds */ tr->tr_time.tv_micro = 0; SendIO( tr ); } /************************************************************************/ /* the main program to do the popcli stuff */ /************************************************************************/ void _main(cmd) char *cmd; { long intlimit = 0, nullfh; ULONG sig, timersig; struct timerequest *timerreq; struct MsgPort *timerport; struct MsgPort *inputDevPort; struct IOStdReq *inputRequestBlock; struct Interrupt handlerStuff; GLOBAL_DATA global; global.blankscreen = NULL; global.buddy = FindTask(0); global.noevents = 0; if (cmd) { /* ugh we are reusing a variable here - so what - it saves bytes */ sig = Output(); Write(sig, BANNER, sizeof(BANNER)); /* skip over any leading spaces in the command line */ while(*cmd == ' ') cmd++; /* see if they specified a limit */ if (*cmd) { while ((*cmd >= '0') && (*cmd <= '9')) intlimit = ((short)intlimit*(short)10) + *cmd++ - '0'; } if (intlimit <= 0) { Write(sig, BANNER1, sizeof(BANNER1)); intlimit = DEFLIMIT; } /* now skip over any more leading spaces */ while(*cmd == ' ') cmd++; if (*cmd <= ' ') cmd = DEFCMD; if (sig != Input()) Close(Input()); Close(sig); } else { intlimit = DEFLIMIT; cmd = DEFCMD; } /* set the input and output streams to 0 so execute doen't complain */ nullfh = Open("NIL:", MODE_NEWFILE); SetTaskPri( global.buddy, 20); if ((inputDevPort = CreatePort(0,0)) == NULL) /* for input device */ goto abort0; if ((inputRequestBlock = CreateStdIO(inputDevPort)) == 0) goto abort1; if ((timerport = CreatePort(0,0)) == NULL) goto abort1; if ((timerreq = (struct timerequest *) AllocMem(sizeof(struct timerequest), MEMF_CLEAR | MEMF_PUBLIC)) == NULL) goto abort2; timerreq->tr_node.io_Message.mn_Node.ln_Type = NT_MESSAGE; timerreq->tr_node.io_Message.mn_Node.ln_Pri = 0; timerreq->tr_node.io_Message.mn_ReplyPort = timerport; if (OpenDevice(TIMERNAME, UNIT_VBLANK, timerreq, 0)) goto abort; timersig = (1 << timerport->mp_SigBit); if ((sig = AllocSignal(-1)) == -1) goto abort; global.createclisig = 1 << sig; if ((sig = AllocSignal(-1)) == -1) goto abort; global.unblanksig = 1 << sig; if ((GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0)) == NULL) goto abort; if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0)) == NULL) goto abort; handlerStuff.is_Data = (APTR)&global; handlerStuff.is_Code = HandlerInterface; handlerStuff.is_Node.ln_Pri = 51; if (OpenDevice("input.device",0,inputRequestBlock,0)) goto abort; inputRequestBlock->io_Command = IND_ADDHANDLER; inputRequestBlock->io_Data = (APTR)&handlerStuff; DoIO(inputRequestBlock); QueueTimer(timerreq, TIMEINTERVAL); for(;;) /* FOREVER */ { sig = Wait( global.createclisig | global.unblanksig | timersig ); if ((sig & global.unblanksig) && (global.blankscreen != NULL)) { (void) CloseScreen(global.blankscreen); ON_DISPLAY global.blankscreen = NULL; } if (sig & global.createclisig) { WBenchToFront(); (void)Execute(cmd,nullfh,nullfh); } if (sig & timersig) { /* get rid of the message */ (void)GetMsg(timerport); QueueTimer(timerreq, TIMEINTERVAL); if ((global.noevents++ >= intlimit) && (global.blankscreen == NULL)) { if ( (global.blankscreen = OpenScreen(&NewScreen)) != NULL) { SetRGB4(&(global.blankscreen->ViewPort), 0, 0, 0, 0); OFF_DISPLAY } } } } abort: CloseDevice(timerreq); abort3: /* timerreq->tr_node.io_Message.mn_Node.ln_Type = 0xff; * timerreq->tr_node.io_Device = (struct Device *) -1; * timerreq->tr_node.io_Unit = (struct Unit *) -1; */ FreeMem (timerreq, sizeof(struct timerequest)); abort2: DeletePort(timerport); abort1: if (IntuitionBase != NULL) CloseLibrary(IntuitionBase); if (GfxBase != NULL) CloseLibrary(GfxBase); DeletePort(inputDevPort); abort0: XCEXIT(-1); } SHAR_EOF if test 9065 -ne "`wc -c 'popcli.c'`" then echo shar: error transmitting "'popcli.c'" '(should have been 9065 characters)' fi echo shar: extracting "'wbc.a'" '(6909 characters)' if test -f 'wbc.a' then echo shar: over-writing existing file "'wbc.a'" fi sed 's/^X//' << \SHAR_EOF > 'wbc.a' section text,CODE * C initial startup procedure under AmigaDOS * * Requirements: INCLUDE "exec/types.i" INCLUDE "exec/alerts.i" INCLUDE "exec/nodes.i" INCLUDE "exec/lists.i" INCLUDE "exec/ports.i" INCLUDE "exec/libraries.i" INCLUDE "exec/tasks.i" INCLUDE "libraries/dos.i" INCLUDE "libraries/dosextens.i" INCLUDE "workbench/startup.i" ; some usefull macros: xlib macro xref _LVO\1 endm callsys macro CALLLIB _LVO\1 endm xdef _XCEXIT * exit(code) is standard way to leave C. xdef _HandlerInterface xref _LinkerDB * linker defined base value xref _Debug xref __main * Name of C program to start with. xref _MemCleanup xref _AbsExecBase xref _FindTask xref _DOSBase xref _MathBase xref _MathTransBase xref _myhandler xlib Alert xlib FindTask xlib Forbid xlib GetMsg xlib OpenLibrary xlib CloseLibrary xlib ReplyMsg xlib Wait xlib WaitPort xlib Open xlib Close xlib CurrentDir start: move.l d0,dosCmdLen move.l a0,dosCmdBuf move.l a7,d0 ; save old stack ptr movem.l d1-d6/a0-a6,-(a7) move.l d0,a5 move.l _AbsExecBase,a6 move.l a6,_SysBase move.l a7,__StackPtr * Save stack ptr clr.l _WBenchMsg ;------ get the address of our task suba.l a1,a1 callsys FindTask move.l d0,a4 ;------ are we running as a son of Workbench? move.l pr_CurrentDir(A4),_curdir tst.l pr_CLI(A4) beq fromWorkbench ;======================================================================= ;====== CLI Startup Code =============================================== ;======================================================================= fromCLI: move.l a5,D0 ; get top of stack sub.l 4(a5),D0 ; compute bottom move.l D0,__base ; save for stack checking ;------ attempt to open DOS library: bsr openDOS ;------ find command name: move.l #start,a0 clr.l -(sp) jsr _FindTask addq.l #4,sp move.l d0,a0 move.l pr_CLI(a0),a0 add.l a0,a0 ; bcpl pointer conversion add.l a0,a0 move.l cli_CommandName(a0),a1 add.l a1,a1 ; bcpl pointer conversion add.l a1,a1 ;------ collect parameters: move.l dosCmdLen,d0 ; get command line length move.l a1,__ProgramName addq.l #1,d0 ; allow for space after command clr.w -(A7) ; set null terminator for command line addq.l #1,D0 ; force to even number of bytes andi.w #$fffe,D0 ;(round up) sub.l D0,A7 ; make room on stack for command line subq.l #2,D0 clr.w 0(A7,D0) ;------ copy command line onto stack move.l dosCmdLen,d0 ; get command line length move.l dosCmdBuf,a0 move.l d0,d2 subq.l #1,d0 copy_line: move.b 0(A0,D0.W),0(A7,D2.W) ; copy command line to stack subq.l #1,d2 dbf d0,copy_line move.b #' ',0(a7,d2.w) ; add space between command and parms subq.l #1,d2 copy_cmd: move.l A7,A1 move.l A1,-(A7) ; push command line address bra goto_main * call C entrypoint ;======================================================================= ;====== Workbench Startup Code ========================================= ;======================================================================= fromWorkbench: move.l TC_SPLOWER(a4),__base ; set base of stack ;------ open the DOS library: bsr openDOS ;------ we are now set up. wait for a message from our starter bsr waitmsg move.l d0,_WBenchMsg move.l d0,-(SP) ; move.l d0,a2 ; get first argument move.l sm_ArgList(a2),d0 beq.s do_cons move.l _DOSBase,a6 move.l d0,a0 move.l wa_Lock(a0),d1 move.l d1,_curdir callsys CurrentDir do_cons: move.l sm_ToolWindow(a2),d1 ; get the window argument beq.s do_main move.l #MODE_OLDFILE,d2 callsys Open move.l d0,stdin beq.s do_main lsl.l #2,d0 move.l d0,a0 move.l fh_Type(a0),pr_ConsoleTask(A4) do_main: move.l _WBenchMsg,a0 ; get address of workbench message move.l sm_ArgList(a0),a0 ; get address of arguments move.l wa_Name(a0),__ProgramName ; get name of program moveq #0,d0 move.l d0,-(A7) goto_main: lea _LinkerDB,a6 ; load base register jsr __main * call C entrypoint moveq.l #0,d0 ; set successful status bra.s exit2 ; _XCEXIT: move.l 4(SP),d0 ; extract return code exit2: move.l d0,-(a7) move.l _SysBase,a6 move.l _DOSBase,a1 callsys CloseLibrary ; close Dos library done_1b: ;------ if we ran from CLI, skip workbench cleanup: tst.l _WBenchMsg beq.s exitToDOS move.l _console_dev,d1 beq.s done_2 callsys Close done_2: move.l stdin,d1 beq.s done_4 callsys Close done_4: ;------ return the startup message to our parent ; we forbid so workbench can't UnLoadSeg() us ; before we are done: move.l _AbsExecBase,A6 callsys Forbid move.l _WBenchMsg,a1 callsys ReplyMsg ;------ this rts sends us back to DOS: exitToDOS: MOVE.L (A7)+,D0 movea.l __StackPtr,SP * restore stack ptr movem.l (a7)+,d1-d6/a0-a6 rts * and exit ;----------------------------------------------------------------------- noDOS: ALERT (AG_OpenLib!AO_DOSLib) moveq.l #100,d0 bra exit2 ;----------------------------------------------------------------------- ; This routine gets the message that workbench will send to us ; called with task id in A4 waitmsg: lea pr_MsgPort(A4),a0 * our process base callsys WaitPort lea pr_MsgPort(A4),a0 * our process base callsys GetMsg rts ;----------------------------------------------------------------------- ; Open the DOS library: openDOS lea DOSName,A1 moveq.l #0,D0 callsys OpenLibrary move.l D0,_DOSBase beq noDOS rts ************************************************************************* * HandlerInterface() * * This code is needed to convert the calling sequence performed by * the input.task for the input stream management into something * that a C program can understand. * * This routine expects a pointer to an InputEvent in A0, a pointer * to a data area in A1. These values are transferred to the stack * in the order that a C program would need to find them. Since the * actual handler is written in C, this works out fine. * * Author: Rob Peck, 12/1/85 * _HandlerInterface: movem.L A0/A1,-(A7) jsr _myhandler addq.L #8,A7 rts section "__MERGED",DATA ; XDEF _NULL,_SysBase,_LoadAddress,_console_dev,_WBenchMsg XDEF _curdir,__mbase,__mnext,__msize,__tsize XDEF __oserr,__OSERR,__FPERR,__SIGFPE,__ONERR,__ONEXIT,__ONBREAK XDEF __SIGINT,__ECS XDEF __ProgramName,__StackPtr,__base ; _NULL dc.l 0 ; __base dc.l 0 ; base of stack __mbase dc.l 0 ; base of memory pool __mnext dc.l 0 ; next available memory location __msize dc.l 0 ; size of memory pool __tsize dc.l 0 ; total size? __oserr equ * __OSERR dc.l 0 __FPERR dc.l 0 __SIGFPE dc.l 0 __SIGINT dc.l 0 __ONERR dc.l 0 __ONEXIT dc.l 0 __ONBREAK dc.l 0 __ECS dc.l 0 ; extended character set flag _curdir dc.l 0 _console_dev dc.l 0 _SysBase dc.l 0 _LoadAddress dc.l 0 ; program load address _WBenchMsg dc.l 0 __StackPtr dc.l 0 dosCmdLen dc.l 0 dosCmdBuf dc.l 0 stdin dc.l 0 __ProgramName dc.l 0 DOSName DOSNAME END SHAR_EOF if test 6909 -ne "`wc -c 'wbc.a'`" then echo shar: error transmitting "'wbc.a'" '(should have been 6909 characters)' fi # End of shell archive exit 0