1 #include <stdio.h> 2 3 #include "../api/api.h" 4 #include "spint.h" 5 6 7 8 /* 9 * Called from telnet.c to fork a lower command.com. We 10 * use the spint... routines so that we can pick up 11 * interrupts generated by application programs. 12 */ 13 14 15 int 16 shell(argc,argv) 17 int argc; 18 char *argv[]; 19 { 20 Spint spinted; 21 char command[256]; 22 23 ClearElement(spinted); 24 spinted.int_no = API_INTERRUPT_NUMBER; 25 if (argc == 1) { 26 command[0] = 0; 27 } else { 28 char *cmdptr; 29 int length; 30 31 argc--; 32 argv++; 33 strcpy(command, " /c"); 34 cmdptr = command+strlen(command); 35 while (argc) { 36 if ((cmdptr+strlen(*argv)) >= (command+sizeof command)) { 37 fprintf(stderr, "Argument list too long at argument *%s*.\n", 38 *argv); 39 return 0; 40 } 41 *cmdptr++ = ' '; /* Blank separators */ 42 strcpy(cmdptr, *argv); 43 cmdptr += strlen(cmdptr); 44 argc--; 45 argv++; 46 } 47 length = strlen(command)-1; 48 if (length < 0) { 49 length = 0; 50 } 51 command[0] = length; 52 } 53 54 /* 55 * spint_start() returns when either the command has finished, or when 56 * the required interrupt comes in. In the latter case, the appropriate 57 * thing to do is to process the interrupt, and then return to 58 * the interrupt issuer by calling spint_continue(). 59 */ 60 spint_start(command, &spinted); 61 while (spinted.done == 0) { 62 /* Process request */ 63 handle_api(&spinted.regs, &spinted.sregs); 64 spint_continue(&spinted); 65 } 66 if (spinted.rc != 0) { 67 fprintf(stderr, "Process generated a return code of 0x%x.\n", 68 spinted.rc); 69 } 70 return 0; 71 } 72