Put up error messages (on 25th line) in dos environment.
[unix-history] / usr / src / usr.bin / tn3270 / distribution / sys_dos / system.c
CommitLineData
190c655a
GM
1#include <stdio.h>
2
f478095f 3#include "../general/general.h"
4718d085 4#include "../ctlr/api.h"
190c655a
GM
5#include "spint.h"
6
9563b3d1
GM
7#include "../general/globals.h"
8
9
10static Spint spinted;
11static char command[256];
12static int need_to_start = 0;
13
14/*
15 * shell_continue() actually runs the command, and looks for API
16 * requests coming back in.
17 *
18 * We are called from the main loop in telnet.c.
19 */
20
21int
22shell_continue()
23{
24 /*
25 * spint_start() returns when either the command has finished, or when
26 * the required interrupt comes in. In the latter case, the appropriate
27 * thing to do is to process the interrupt, and then return to
28 * the interrupt issuer by calling spint_continue().
29 */
30 if (need_to_start) {
31 need_to_start = 0;
32 spint_start(command, &spinted);
33 }
34
35 if (spinted.done == 0) {
36 /* Process request */
37 handle_api(&spinted.regs, &spinted.sregs);
38 spint_continue(&spinted);
39 } else {
40 if (spinted.rc != 0) {
41 fprintf(stderr, "Process generated a return code of 0x%x.\n",
42 spinted.rc);
43 }
44 shell_active = 0;
45 }
46 return shell_active;
47}
190c655a
GM
48
49
50/*
51 * Called from telnet.c to fork a lower command.com. We
52 * use the spint... routines so that we can pick up
53 * interrupts generated by application programs.
54 */
55
56
57int
58shell(argc,argv)
59int argc;
60char *argv[];
61{
190c655a
GM
62
63 ClearElement(spinted);
64 spinted.int_no = API_INTERRUPT_NUMBER;
65 if (argc == 1) {
66 command[0] = 0;
67 } else {
68 char *cmdptr;
69 int length;
70
71 argc--;
72 argv++;
73 strcpy(command, " /c");
74 cmdptr = command+strlen(command);
75 while (argc) {
76 if ((cmdptr+strlen(*argv)) >= (command+sizeof command)) {
77 fprintf(stderr, "Argument list too long at argument *%s*.\n",
78 *argv);
79 return 0;
80 }
81 *cmdptr++ = ' '; /* Blank separators */
82 strcpy(cmdptr, *argv);
83 cmdptr += strlen(cmdptr);
84 argc--;
85 argv++;
86 }
87 length = strlen(command)-1;
88 if (length < 0) {
89 length = 0;
90 }
91 command[0] = length;
92 }
9563b3d1
GM
93 need_to_start = 1;
94 shell_active = 1;
95 return 1; /* Go back to main loop */
190c655a 96}