Subversion Repositories SvarDOS

Rev

Rev 1090 | Rev 1730 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1090 Rev 1129
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021-2022 Mateusz Viste
4
 * Copyright (C) 2021-2022 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
12
 *
13
 * The above copyright notice and this permission notice shall be included in
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
14
 * all copies or substantial portions of the Software.
15
 *
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
/* entry point for internal commands, it matches internal commands and
25
/* entry point for internal commands, it matches internal commands and
26
 * executes them.
26
 * executes them.
27
 *
27
 *
28
 * returns one of the following values:
28
 * returns one of the following values:
29
 *   CMD_OK               command executed successfully
29
 *   CMD_OK               command executed successfully
30
 *   CMD_FAIL             command ended in error
30
 *   CMD_FAIL             command ended in error
31
 *   CMD_CHANGED          command-line has been modified (used by IF)
31
 *   CMD_CHANGED          command-line has been modified (used by IF)
32
 *   CMD_CHANGED_BY_CALL  command-line has been modified by CALL
32
 *   CMD_CHANGED_BY_CALL  command-line has been modified by CALL
33
 *   CMD_NOTFOUND         command unrecognized
33
 *   CMD_NOTFOUND         command unrecognized
34
 */
34
 */
35
 
35
 
36
#include <i86.h>
36
#include <i86.h>
37
#include <stdio.h>
37
#include <stdio.h>
38
#include <stdlib.h>
38
#include <stdlib.h>
39
#include <string.h>
39
#include <string.h>
40
 
40
 
41
#include "svarlang.lib/svarlang.h"
41
#include "svarlang.lib/svarlang.h"
42
 
42
 
43
#include "env.h"
43
#include "env.h"
44
#include "helpers.h"
44
#include "helpers.h"
45
#include "redir.h"
45
#include "redir.h"
46
#include "rmodinit.h"
46
#include "rmodinit.h"
47
#include "sayonara.h"
47
#include "sayonara.h"
48
 
48
 
49
#include "cmd.h"
49
#include "cmd.h"
50
 
50
 
51
 
51
 
-
 
52
/* struct used to pass all necessary information to the sub-commands */
52
struct cmd_funcparam {
53
struct cmd_funcparam {
53
  int argc;                 /* number of arguments */
54
  int argc;                 /* number of arguments */
54
  const char *argv[128];    /* pointers to each argument */
55
  const char *argv[128];    /* pointers to each argument */
55
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
56
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
56
  unsigned short env_seg;   /* segment of environment block */
57
  unsigned short env_seg;   /* segment of environment block */
57
  struct rmod_props far *rmod; /* rmod settings */
58
  struct rmod_props far *rmod; /* rmod settings */
58
  unsigned short argoffset; /* offset of cmdline where first argument starts */
59
  unsigned short argoffset; /* offset of cmdline where first argument starts */
59
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
60
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
60
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
61
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
61
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
62
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
62
};
63
};
63
 
64
 
-
 
65
 
64
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
66
/* scans argv for the presence of a "/?" parameter.
-
 
67
 * returns 1 if found, 0 otherwise
-
 
68
 * this is used by most sub-commands to detect /? invocations */
65
static int cmd_ishlp(const struct cmd_funcparam *p) {
69
static int cmd_ishlp(const struct cmd_funcparam *p) {
66
  int i;
70
  int i;
67
  for (i = 0; i < p->argc; i++) {
71
  for (i = 0; i < p->argc; i++) {
68
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
72
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
69
  }
73
  }
70
  return(0);
74
  return(0);
71
}
75
}
72
 
76
 
73
#include "cmd/break.c"
77
#include "cmd/break.c"
74
#include "cmd/call.c"
78
#include "cmd/call.c"
75
#include "cmd/cd.c"
79
#include "cmd/cd.c"
76
#include "cmd/chcp.c"
80
#include "cmd/chcp.c"
77
#include "cmd/cls.c"
81
#include "cmd/cls.c"
78
#include "cmd/copy.c"
82
#include "cmd/copy.c"
79
#include "cmd/ctty.c"
83
#include "cmd/ctty.c"
80
#include "cmd/date.c"
84
#include "cmd/date.c"
81
#include "cmd/del.c"
85
#include "cmd/del.c"
82
#include "cmd/for.c"
86
#include "cmd/for.c"
83
#include "cmd/goto.c"
87
#include "cmd/goto.c"
84
#include "cmd/if.c"
88
#include "cmd/if.c"
85
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
89
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
86
#include "cmd/dir.c"
90
#include "cmd/dir.c"
87
#include "cmd/echo.c"
91
#include "cmd/echo.c"
88
#include "cmd/exit.c"
92
#include "cmd/exit.c"
89
#include "cmd/loadhigh.c"
93
#include "cmd/loadhigh.c"
90
#include "cmd/ln.c"
94
#include "cmd/ln.c"
91
#include "cmd/mkdir.c"
95
#include "cmd/mkdir.c"
92
#include "cmd/path.c"
96
#include "cmd/path.c"
93
#include "cmd/pause.c"
97
#include "cmd/pause.c"
94
#include "cmd/prompt.c"
98
#include "cmd/prompt.c"
95
#include "cmd/rem.c"
99
#include "cmd/rem.c"
96
#include "cmd/rename.c"
100
#include "cmd/rename.c"
97
#include "cmd/rmdir.c"
101
#include "cmd/rmdir.c"
98
#include "cmd/set.c"
102
#include "cmd/set.c"
99
#include "cmd/shift.c"
103
#include "cmd/shift.c"
100
#include "cmd/time.c"
104
#include "cmd/time.c"
101
#include "cmd/truename.c"
105
#include "cmd/truename.c"
102
#include "cmd/type.c"
106
#include "cmd/type.c"
103
#include "cmd/ver.c"
107
#include "cmd/ver.c"
104
#include "cmd/verify.c"
108
#include "cmd/verify.c"
105
 
109
 
106
 
110
 
107
struct CMD_ID {
111
struct CMD_ID {
108
  const char *cmd;
112
  const char *cmd;
109
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
113
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
110
};
114
};
111
 
115
 
112
const struct CMD_ID INTERNAL_CMDS[] = {
116
const struct CMD_ID INTERNAL_CMDS[] = {
113
  {"BREAK",   cmd_break},
117
  {"BREAK",   cmd_break},
114
  {"CALL",    cmd_call},
118
  {"CALL",    cmd_call},
115
  {"CD",      cmd_cd},
119
  {"CD",      cmd_cd},
116
  {"CHCP",    cmd_chcp},
120
  {"CHCP",    cmd_chcp},
117
  {"CHDIR",   cmd_cd},
121
  {"CHDIR",   cmd_cd},
118
  {"CLS",     cmd_cls},
122
  {"CLS",     cmd_cls},
119
  {"COPY",    cmd_copy},
123
  {"COPY",    cmd_copy},
120
  {"CTTY",    cmd_ctty},
124
  {"CTTY",    cmd_ctty},
121
  {"DATE",    cmd_date},
125
  {"DATE",    cmd_date},
122
  {"DEL",     cmd_del},
126
  {"DEL",     cmd_del},
123
  {"DIR",     cmd_dir},
127
  {"DIR",     cmd_dir},
124
  {"ECHO",    cmd_echo},
128
  {"ECHO",    cmd_echo},
125
  {"ERASE",   cmd_del},
129
  {"ERASE",   cmd_del},
126
  {"EXIT",    cmd_exit},
130
  {"EXIT",    cmd_exit},
127
  {"FOR",     cmd_for},
131
  {"FOR",     cmd_for},
128
  {"GOTO",    cmd_goto},
132
  {"GOTO",    cmd_goto},
129
  {"IF",      cmd_if},
133
  {"IF",      cmd_if},
130
  {"LH",      cmd_loadhigh},
134
  {"LH",      cmd_loadhigh},
131
  {"LN",      cmd_ln},
135
  {"LN",      cmd_ln},
132
  {"LOADHIGH",cmd_loadhigh},
136
  {"LOADHIGH",cmd_loadhigh},
133
  {"MD",      cmd_mkdir},
137
  {"MD",      cmd_mkdir},
134
  {"MKDIR",   cmd_mkdir},
138
  {"MKDIR",   cmd_mkdir},
135
  {"PAUSE",   cmd_pause},
139
  {"PAUSE",   cmd_pause},
136
  {"PATH",    cmd_path},
140
  {"PATH",    cmd_path},
137
  {"PROMPT",  cmd_prompt},
141
  {"PROMPT",  cmd_prompt},
138
  {"RD",      cmd_rmdir},
142
  {"RD",      cmd_rmdir},
139
  {"REM",     cmd_rem},
143
  {"REM",     cmd_rem},
140
  {"REN",     cmd_rename},
144
  {"REN",     cmd_rename},
141
  {"RENAME",  cmd_rename},
145
  {"RENAME",  cmd_rename},
142
  {"RMDIR",   cmd_rmdir},
146
  {"RMDIR",   cmd_rmdir},
143
  {"SET",     cmd_set},
147
  {"SET",     cmd_set},
144
  {"SHIFT",   cmd_shift},
148
  {"SHIFT",   cmd_shift},
145
  {"TIME",    cmd_time},
149
  {"TIME",    cmd_time},
146
  {"TRUENAME",cmd_truename},
150
  {"TRUENAME",cmd_truename},
147
  {"TYPE",    cmd_type},
151
  {"TYPE",    cmd_type},
148
  {"VER",     cmd_ver},
152
  {"VER",     cmd_ver},
149
  {"VERIFY",  cmd_verify},
153
  {"VERIFY",  cmd_verify},
150
  {"VOL",     cmd_vol},
154
  {"VOL",     cmd_vol},
151
  {NULL,      NULL}
155
  {NULL,      NULL}
152
};
156
};
153
 
157
 
154
 
158
 
155
/* NULL if cmdline is not matching an internal command, otherwise returns a
159
/* NULL if cmdline is not matching an internal command, otherwise returns a
156
 * pointer to a CMD_ID struct */
160
 * pointer to a CMD_ID struct */
157
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
161
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
158
  unsigned short i;
162
  unsigned short i;
159
  char buff[10];
163
  char buff[10];
160
 
164
 
161
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
165
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
162
  for (i = 0; i < 9; i++) {
166
  for (i = 0; i < 9; i++) {
163
    if (cmdline[i] == ' ') break;
167
    if (cmdline[i] == ' ') break;
164
    if (cmdline[i] == 0) break;
168
    if (cmdline[i] == 0) break;
165
    if (cmdline[i] == '\t') break;
169
    if (cmdline[i] == '\t') break;
166
    if (cmdline[i] == '\r') break;
170
    if (cmdline[i] == '\r') break;
167
    if (cmdline[i] == '.') break;
171
    if (cmdline[i] == '.') break;
168
    if (cmdline[i] == '/') break;
172
    if (cmdline[i] == '/') break;
169
    if (cmdline[i] == '\\') break;
173
    if (cmdline[i] == '\\') break;
170
    buff[i] = cmdline[i];
174
    buff[i] = cmdline[i];
171
  }
175
  }
172
  buff[i] = 0;
176
  buff[i] = 0;
173
 
177
 
174
  /* advance to nearest non-space to find where arguments start */
178
  /* advance to nearest non-space to find where arguments start */
175
  while (cmdline[i] == ' ') i++;
179
  while (cmdline[i] == ' ') i++;
176
  *argoffset = i;
180
  *argoffset = i;
177
 
181
 
178
  /* try matching an internal command */
182
  /* try matching an internal command */
179
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
183
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
180
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
184
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
181
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
185
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
182
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
186
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
183
      return(&(INTERNAL_CMDS[i]));
187
      return(&(INTERNAL_CMDS[i]));
184
    }
188
    }
185
  }
189
  }
186
 
190
 
187
  return(NULL); /* command is not recognized as internal */
191
  return(NULL); /* command is not recognized as internal */
188
}
192
}
189
 
193
 
190
 
194
 
191
/* explodes a command into an array of arguments where last arg is NULL.
195
/* explodes a command into an array of arguments where last arg is NULL.
192
 * if argvlist is not NULL, it will be filled with pointers that point to buff
196
 * if argvlist is not NULL, it will be filled with pointers that point to buff
193
 * locations. buff is filled with all the arguments, each argument being
197
 * locations. buff is filled with all the arguments, each argument being
194
 * zero-separated. buff is terminated with an empty argument to mark the end
198
 * zero-separated. buff is terminated with an empty argument to mark the end
195
 * of arguments.
199
 * of arguments.
196
 * returns number of args */
200
 * returns number of args */
197
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
201
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
198
  int si = 0, argc = 0, i = 0;
202
  int si = 0, argc = 0, i = 0;
199
  for (;;) {
203
  for (;;) {
200
    /* skip to next non-space character */
204
    /* skip to next non-space character */
201
    while (s[si] == ' ') si++;
205
    while (s[si] == ' ') si++;
202
    /* end of string? */
206
    /* end of string? */
203
    if (s[si] == 0) break;
207
    if (s[si] == 0) break;
204
    /* set argv ptr */
208
    /* set argv ptr */
205
    if (argvlist) argvlist[argc] = buff + i;
209
    if (argvlist) argvlist[argc] = buff + i;
206
    argc++;
210
    argc++;
207
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
211
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
208
    do {
212
    do {
209
      buff[i++] = s[si++];
213
      buff[i++] = s[si++];
210
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
214
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
211
    buff[i++] = 0;
215
    buff[i++] = 0;
212
    /* is this end of string? */
216
    /* is this end of string? */
213
    if (s[si] == 0) break;
217
    if (s[si] == 0) break;
214
  }
218
  }
215
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
219
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
216
  if (argvlist) argvlist[argc] = NULL;
220
  if (argvlist) argvlist[argc] = NULL;
217
  return(argc);
221
  return(argc);
218
}
222
}
219
 
223
 
220
 
224
 
221
enum cmd_result cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *redir, unsigned char delstdin) {
225
enum cmd_result cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *redir, unsigned char delstdin) {
222
  const struct CMD_ID *cmdptr;
226
  const struct CMD_ID *cmdptr;
223
  unsigned short argoffset;
227
  unsigned short argoffset;
224
  enum cmd_result cmdres;
228
  enum cmd_result cmdres;
225
  struct cmd_funcparam *p = (void *)BUFFER;
229
  struct cmd_funcparam *p = (void *)BUFFER;
226
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
230
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
227
 
231
 
228
  /* special case: is this a drive change? (like "E:") */
232
  /* special case: is this a drive change? (like "E:") */
229
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
233
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
230
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
234
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
231
      unsigned char drive = cmdline[0];
235
      unsigned char drive = cmdline[0];
232
      unsigned char curdrive = 0;
236
      unsigned char curdrive = 0;
233
      if (drive >= 'a') {
237
      if (drive >= 'a') {
234
        drive -= 'a';
238
        drive -= 'a';
235
      } else {
239
      } else {
236
        drive -= 'A';
240
        drive -= 'A';
237
      }
241
      }
238
      _asm {
242
      _asm {
239
        push ax
243
        push ax
240
        push dx
244
        push dx
241
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
245
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
242
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
246
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
243
        int 0x21
247
        int 0x21
244
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
248
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
245
        int 0x21
249
        int 0x21
246
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
250
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
247
        pop dx
251
        pop dx
248
        pop ax
252
        pop ax
249
      }
253
      }
250
      if (curdrive == drive) return(CMD_OK);
254
      if (curdrive == drive) return(CMD_OK);
251
      nls_outputnl_doserr(0x0f);
255
      nls_outputnl_doserr(0x0f);
252
      return(CMD_FAIL);
256
      return(CMD_FAIL);
253
    }
257
    }
254
  }
258
  }
255
 
259
 
256
  /* try matching an internal command */
260
  /* try matching an internal command */
257
  cmdptr = cmd_match(cmdline, &argoffset);
261
  cmdptr = cmd_match(cmdline, &argoffset);
258
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
262
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
259
 
263
 
260
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
264
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
261
 
265
 
262
  /* apply redirections (if any) */
266
  /* apply redirections (if any) */
263
  if (redir_apply(redir) != 0) return(CMD_FAIL);
267
  if (redir_apply(redir) != 0) return(CMD_FAIL);
264
 
268
 
265
  /* prepare function parameters and feed it to the cmd handling function */
269
  /* prepare function parameters and feed it to the cmd handling function */
266
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
270
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
267
  p->env_seg = env_seg;
271
  p->env_seg = env_seg;
268
  p->rmod = rmod;
272
  p->rmod = rmod;
269
  p->argoffset = argoffset;
273
  p->argoffset = argoffset;
270
  p->cmdline = cmdline;
274
  p->cmdline = cmdline;
271
 
275
 
272
  cmdres = (cmdptr->func_ptr)(p);
276
  cmdres = (cmdptr->func_ptr)(p);
273
 
277
 
274
  /* cancel redirections */
278
  /* cancel redirections */
275
  redir_revert();
279
  redir_revert();
276
 
280
 
277
  /* delete stdin temporary file */
281
  /* delete stdin temporary file */
278
  if (delstdin) {
282
  if (delstdin) {
279
    const char *fname = redir->stdinfile;
283
    const char *fname = redir->stdinfile;
280
    unsigned short doserr = 0;
284
    unsigned short doserr = 0;
281
    _asm {
285
    _asm {
282
      push ax
286
      push ax
283
      push dx
287
      push dx
284
      mov ah, 0x41  /* delete a file */
288
      mov ah, 0x41  /* delete a file */
285
      mov dx, fname /* DS:DX - filename to delete */
289
      mov dx, fname /* DS:DX - filename to delete */
286
      int 0x21
290
      int 0x21
287
      jnc DONE
291
      jnc DONE
288
      mov doserr, ax
292
      mov doserr, ax
289
      DONE:
293
      DONE:
290
      pop dx
294
      pop dx
291
      pop ax
295
      pop ax
292
    }
296
    }
293
    if (doserr) {
297
    if (doserr) {
294
      output(fname);
298
      output(fname);
295
      output(": ");
299
      output(": ");
296
      nls_outputnl_doserr(doserr);
300
      nls_outputnl_doserr(doserr);
297
    }
301
    }
298
  }
302
  }
299
 
303
 
300
  return(cmdres);
304
  return(cmdres);
301
}
305
}
302
 
306