Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- shellstack.c
- Amiga User-Shell for command execution,
- with customizable stack
- Micha B. 2023
- sc ICONS shellstack.c LINK TO shellstack
- */
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <dos/dos.h>
- #include <dos/dostags.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/intuition.h>
- #include <proto/utility.h>
- /* our function error codes for user shell functions */
- #define SYSTEMFAIL (-1L)
- #define WINDOWFAIL (-2L)
- /* --- global vars --- */
- UBYTE *autocon="VNC:60/94/640/150/Micha B.'s Shell (executing STACK)/SHELL/AUTO/CLOSE/WAIT/ICONIFY";
- /* --- Function prototypes --- */
- LONG beginCommand(UBYTE *command);
- /*
- * ASYNCH User Shell for command execution
- */
- LONG beginCommand(UBYTE *command)
- {
- struct TagItem stags[8];
- BPTR file;
- if(file = Open(autocon, MODE_OLDFILE))
- {
- stags[0].ti_Tag = SYS_Input; // what to execute?
- stags[0].ti_Data = file; // command to be executed
- stags[1].ti_Tag = SYS_Output;
- stags[1].ti_Data = NULL;
- stags[2].ti_Tag = SYS_Asynch; // asynchronous I/O
- stags[2].ti_Data = TRUE;
- stags[3].ti_Tag = SYS_UserShell; // spawn own Shell
- stags[3].ti_Data = TRUE;
- stags[4].ti_Tag = NP_StackSize; // inform to set own stacksize
- stags[4].ti_Data = 32000L; // own stack size for command execution
- stags[7].ti_Tag = TAG_END;
- return SystemTagList(command, stags); // ...now execute given command or script!
- }
- else return(WINDOWFAIL);
- }
- int main(void)
- {
- UBYTE *command;
- long error;
- extern struct DosLibrary *DOSBase;
- /* open intuition.library */
- if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 47L)))
- {
- Printf("This example requires intuition.library V47 or higher\n");
- return RETURN_FAIL;
- }
- Printf("I am a test program\nSo what?!...\n\n");
- Printf("\n*** SystemTest: Asynchronous startup of 'Stack':\n");
- command = "Stack";
- error = beginCommand(command);
- Printf("error = %ld\n", error);
- /* close intuition.library */
- CloseLibrary((struct Library *)IntuitionBase);
- return(RETURN_OK);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement