#include #include "../api/api.h" #include "spint.h" /* * Called from telnet.c to fork a lower command.com. We * use the spint... routines so that we can pick up * interrupts generated by application programs. */ int shell(argc,argv) int argc; char *argv[]; { Spint spinted; char command[256]; ClearElement(spinted); spinted.int_no = API_INTERRUPT_NUMBER; if (argc == 1) { command[0] = 0; } else { char *cmdptr; int length; argc--; argv++; strcpy(command, " /c"); cmdptr = command+strlen(command); while (argc) { if ((cmdptr+strlen(*argv)) >= (command+sizeof command)) { fprintf(stderr, "Argument list too long at argument *%s*.\n", *argv); return 0; } *cmdptr++ = ' '; /* Blank separators */ strcpy(cmdptr, *argv); cmdptr += strlen(cmdptr); argc--; argv++; } length = strlen(command)-1; if (length < 0) { length = 0; } command[0] = length; } /* * spint_start() returns when either the command has finished, or when * the required interrupt comes in. In the latter case, the appropriate * thing to do is to process the interrupt, and then return to * the interrupt issuer by calling spint_continue(). */ spint_start(command, &spinted); while (spinted.done == 0) { /* Process request */ handle_api(&spinted.regs, &spinted.sregs); spint_continue(&spinted); } if (spinted.rc != 0) { fprintf(stderr, "Process generated a return code of 0x%x.\n", spinted.rc); } return 0; }