Subversion Repositories SvarDOS

Rev

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

Rev 1045 Rev 1090
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 cmd_funcparam {
52
struct cmd_funcparam {
53
  int argc;                 /* number of arguments */
53
  int argc;                 /* number of arguments */
54
  const char *argv[128];    /* pointers to each argument */
54
  const char *argv[128];    /* pointers to each argument */
55
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
55
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
56
  unsigned short env_seg;   /* segment of environment block */
56
  unsigned short env_seg;   /* segment of environment block */
57
  struct rmod_props far *rmod; /* rmod settings */
57
  struct rmod_props far *rmod; /* rmod settings */
58
  unsigned short argoffset; /* offset of cmdline where first argument starts */
58
  unsigned short argoffset; /* offset of cmdline where first argument starts */
59
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
59
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
60
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
60
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
61
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
61
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
62
};
62
};
63
 
63
 
64
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
64
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
65
static int cmd_ishlp(const struct cmd_funcparam *p) {
65
static int cmd_ishlp(const struct cmd_funcparam *p) {
66
  int i;
66
  int i;
67
  for (i = 0; i < p->argc; i++) {
67
  for (i = 0; i < p->argc; i++) {
68
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
68
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
69
  }
69
  }
70
  return(0);
70
  return(0);
71
}
71
}
72
 
72
 
73
#include "cmd/_notimpl.c"
-
 
74
#include "cmd/break.c"
73
#include "cmd/break.c"
75
#include "cmd/call.c"
74
#include "cmd/call.c"
76
#include "cmd/cd.c"
75
#include "cmd/cd.c"
77
#include "cmd/chcp.c"
76
#include "cmd/chcp.c"
78
#include "cmd/cls.c"
77
#include "cmd/cls.c"
79
#include "cmd/copy.c"
78
#include "cmd/copy.c"
-
 
79
#include "cmd/ctty.c"
80
#include "cmd/date.c"
80
#include "cmd/date.c"
81
#include "cmd/del.c"
81
#include "cmd/del.c"
82
#include "cmd/for.c"
82
#include "cmd/for.c"
83
#include "cmd/goto.c"
83
#include "cmd/goto.c"
84
#include "cmd/if.c"
84
#include "cmd/if.c"
85
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
85
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
86
#include "cmd/dir.c"
86
#include "cmd/dir.c"
87
#include "cmd/echo.c"
87
#include "cmd/echo.c"
88
#include "cmd/exit.c"
88
#include "cmd/exit.c"
-
 
89
#include "cmd/loadhigh.c"
89
#include "cmd/ln.c"
90
#include "cmd/ln.c"
90
#include "cmd/mkdir.c"
91
#include "cmd/mkdir.c"
91
#include "cmd/path.c"
92
#include "cmd/path.c"
92
#include "cmd/pause.c"
93
#include "cmd/pause.c"
93
#include "cmd/prompt.c"
94
#include "cmd/prompt.c"
94
#include "cmd/rem.c"
95
#include "cmd/rem.c"
95
#include "cmd/rename.c"
96
#include "cmd/rename.c"
96
#include "cmd/rmdir.c"
97
#include "cmd/rmdir.c"
97
#include "cmd/set.c"
98
#include "cmd/set.c"
98
#include "cmd/shift.c"
99
#include "cmd/shift.c"
99
#include "cmd/time.c"
100
#include "cmd/time.c"
100
#include "cmd/truename.c"
101
#include "cmd/truename.c"
101
#include "cmd/type.c"
102
#include "cmd/type.c"
102
#include "cmd/ver.c"
103
#include "cmd/ver.c"
103
#include "cmd/verify.c"
104
#include "cmd/verify.c"
104
 
105
 
105
 
106
 
106
struct CMD_ID {
107
struct CMD_ID {
107
  const char *cmd;
108
  const char *cmd;
108
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
109
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
109
};
110
};
110
 
111
 
111
const struct CMD_ID INTERNAL_CMDS[] = {
112
const struct CMD_ID INTERNAL_CMDS[] = {
112
  {"BREAK",   cmd_break},
113
  {"BREAK",   cmd_break},
113
  {"CALL",    cmd_call},
114
  {"CALL",    cmd_call},
114
  {"CD",      cmd_cd},
115
  {"CD",      cmd_cd},
115
  {"CHCP",    cmd_chcp},
116
  {"CHCP",    cmd_chcp},
116
  {"CHDIR",   cmd_cd},
117
  {"CHDIR",   cmd_cd},
117
  {"CLS",     cmd_cls},
118
  {"CLS",     cmd_cls},
118
  {"COPY",    cmd_copy},
119
  {"COPY",    cmd_copy},
119
  {"CTTY",    cmd_notimpl},
120
  {"CTTY",    cmd_ctty},
120
  {"DATE",    cmd_date},
121
  {"DATE",    cmd_date},
121
  {"DEL",     cmd_del},
122
  {"DEL",     cmd_del},
122
  {"DIR",     cmd_dir},
123
  {"DIR",     cmd_dir},
123
  {"ECHO",    cmd_echo},
124
  {"ECHO",    cmd_echo},
124
  {"ERASE",   cmd_del},
125
  {"ERASE",   cmd_del},
125
  {"EXIT",    cmd_exit},
126
  {"EXIT",    cmd_exit},
126
  {"FOR",     cmd_for},
127
  {"FOR",     cmd_for},
127
  {"GOTO",    cmd_goto},
128
  {"GOTO",    cmd_goto},
128
  {"IF",      cmd_if},
129
  {"IF",      cmd_if},
129
  {"LH",      cmd_notimpl},
130
  {"LH",      cmd_loadhigh},
130
  {"LN",      cmd_ln},
131
  {"LN",      cmd_ln},
131
  {"LOADHIGH",cmd_notimpl},
132
  {"LOADHIGH",cmd_loadhigh},
132
  {"MD",      cmd_mkdir},
133
  {"MD",      cmd_mkdir},
133
  {"MKDIR",   cmd_mkdir},
134
  {"MKDIR",   cmd_mkdir},
134
  {"PAUSE",   cmd_pause},
135
  {"PAUSE",   cmd_pause},
135
  {"PATH",    cmd_path},
136
  {"PATH",    cmd_path},
136
  {"PROMPT",  cmd_prompt},
137
  {"PROMPT",  cmd_prompt},
137
  {"RD",      cmd_rmdir},
138
  {"RD",      cmd_rmdir},
138
  {"REM",     cmd_rem},
139
  {"REM",     cmd_rem},
139
  {"REN",     cmd_rename},
140
  {"REN",     cmd_rename},
140
  {"RENAME",  cmd_rename},
141
  {"RENAME",  cmd_rename},
141
  {"RMDIR",   cmd_rmdir},
142
  {"RMDIR",   cmd_rmdir},
142
  {"SET",     cmd_set},
143
  {"SET",     cmd_set},
143
  {"SHIFT",   cmd_shift},
144
  {"SHIFT",   cmd_shift},
144
  {"TIME",    cmd_time},
145
  {"TIME",    cmd_time},
145
  {"TRUENAME",cmd_truename},
146
  {"TRUENAME",cmd_truename},
146
  {"TYPE",    cmd_type},
147
  {"TYPE",    cmd_type},
147
  {"VER",     cmd_ver},
148
  {"VER",     cmd_ver},
148
  {"VERIFY",  cmd_verify},
149
  {"VERIFY",  cmd_verify},
149
  {"VOL",     cmd_vol},
150
  {"VOL",     cmd_vol},
150
  {NULL,      NULL}
151
  {NULL,      NULL}
151
};
152
};
152
 
153
 
153
 
154
 
154
/* NULL if cmdline is not matching an internal command, otherwise returns a
155
/* NULL if cmdline is not matching an internal command, otherwise returns a
155
 * pointer to a CMD_ID struct */
156
 * pointer to a CMD_ID struct */
156
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
157
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
157
  unsigned short i;
158
  unsigned short i;
158
  char buff[10];
159
  char buff[10];
159
 
160
 
160
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
161
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
161
  for (i = 0; i < 9; i++) {
162
  for (i = 0; i < 9; i++) {
162
    if (cmdline[i] == ' ') break;
163
    if (cmdline[i] == ' ') break;
163
    if (cmdline[i] == 0) break;
164
    if (cmdline[i] == 0) break;
164
    if (cmdline[i] == '\t') break;
165
    if (cmdline[i] == '\t') break;
165
    if (cmdline[i] == '\r') break;
166
    if (cmdline[i] == '\r') break;
166
    if (cmdline[i] == '.') break;
167
    if (cmdline[i] == '.') break;
167
    if (cmdline[i] == '/') break;
168
    if (cmdline[i] == '/') break;
168
    if (cmdline[i] == '\\') break;
169
    if (cmdline[i] == '\\') break;
169
    buff[i] = cmdline[i];
170
    buff[i] = cmdline[i];
170
  }
171
  }
171
  buff[i] = 0;
172
  buff[i] = 0;
172
 
173
 
173
  /* advance to nearest non-space to find where arguments start */
174
  /* advance to nearest non-space to find where arguments start */
174
  while (cmdline[i] == ' ') i++;
175
  while (cmdline[i] == ' ') i++;
175
  *argoffset = i;
176
  *argoffset = i;
176
 
177
 
177
  /* try matching an internal command */
178
  /* try matching an internal command */
178
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
179
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
179
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
180
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
180
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
181
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
181
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
182
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
182
      return(&(INTERNAL_CMDS[i]));
183
      return(&(INTERNAL_CMDS[i]));
183
    }
184
    }
184
  }
185
  }
185
 
186
 
186
  return(NULL); /* command is not recognized as internal */
187
  return(NULL); /* command is not recognized as internal */
187
}
188
}
188
 
189
 
189
 
190
 
190
/* explodes a command into an array of arguments where last arg is NULL.
191
/* explodes a command into an array of arguments where last arg is NULL.
191
 * if argvlist is not NULL, it will be filled with pointers that point to buff
192
 * if argvlist is not NULL, it will be filled with pointers that point to buff
192
 * locations. buff is filled with all the arguments, each argument being
193
 * locations. buff is filled with all the arguments, each argument being
193
 * zero-separated. buff is terminated with an empty argument to mark the end
194
 * zero-separated. buff is terminated with an empty argument to mark the end
194
 * of arguments.
195
 * of arguments.
195
 * returns number of args */
196
 * returns number of args */
196
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
197
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
197
  int si = 0, argc = 0, i = 0;
198
  int si = 0, argc = 0, i = 0;
198
  for (;;) {
199
  for (;;) {
199
    /* skip to next non-space character */
200
    /* skip to next non-space character */
200
    while (s[si] == ' ') si++;
201
    while (s[si] == ' ') si++;
201
    /* end of string? */
202
    /* end of string? */
202
    if (s[si] == 0) break;
203
    if (s[si] == 0) break;
203
    /* set argv ptr */
204
    /* set argv ptr */
204
    if (argvlist) argvlist[argc] = buff + i;
205
    if (argvlist) argvlist[argc] = buff + i;
205
    argc++;
206
    argc++;
206
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
207
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
207
    do {
208
    do {
208
      buff[i++] = s[si++];
209
      buff[i++] = s[si++];
209
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
210
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
210
    buff[i++] = 0;
211
    buff[i++] = 0;
211
    /* is this end of string? */
212
    /* is this end of string? */
212
    if (s[si] == 0) break;
213
    if (s[si] == 0) break;
213
  }
214
  }
214
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
215
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
215
  if (argvlist) argvlist[argc] = NULL;
216
  if (argvlist) argvlist[argc] = NULL;
216
  return(argc);
217
  return(argc);
217
}
218
}
218
 
219
 
219
 
220
 
220
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) {
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) {
221
  const struct CMD_ID *cmdptr;
222
  const struct CMD_ID *cmdptr;
222
  unsigned short argoffset;
223
  unsigned short argoffset;
223
  enum cmd_result cmdres;
224
  enum cmd_result cmdres;
224
  struct cmd_funcparam *p = (void *)BUFFER;
225
  struct cmd_funcparam *p = (void *)BUFFER;
225
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
226
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
226
 
227
 
227
  /* special case: is this a drive change? (like "E:") */
228
  /* special case: is this a drive change? (like "E:") */
228
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
229
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
229
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
230
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
230
      unsigned char drive = cmdline[0];
231
      unsigned char drive = cmdline[0];
231
      unsigned char curdrive = 0;
232
      unsigned char curdrive = 0;
232
      if (drive >= 'a') {
233
      if (drive >= 'a') {
233
        drive -= 'a';
234
        drive -= 'a';
234
      } else {
235
      } else {
235
        drive -= 'A';
236
        drive -= 'A';
236
      }
237
      }
237
      _asm {
238
      _asm {
238
        push ax
239
        push ax
239
        push dx
240
        push dx
240
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
241
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
241
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
242
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
242
        int 0x21
243
        int 0x21
243
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
244
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
244
        int 0x21
245
        int 0x21
245
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
246
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
246
        pop dx
247
        pop dx
247
        pop ax
248
        pop ax
248
      }
249
      }
249
      if (curdrive == drive) return(CMD_OK);
250
      if (curdrive == drive) return(CMD_OK);
250
      nls_outputnl_doserr(0x0f);
251
      nls_outputnl_doserr(0x0f);
251
      return(CMD_FAIL);
252
      return(CMD_FAIL);
252
    }
253
    }
253
  }
254
  }
254
 
255
 
255
  /* try matching an internal command */
256
  /* try matching an internal command */
256
  cmdptr = cmd_match(cmdline, &argoffset);
257
  cmdptr = cmd_match(cmdline, &argoffset);
257
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
258
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
258
 
259
 
259
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
260
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
260
 
261
 
261
  /* apply redirections (if any) */
262
  /* apply redirections (if any) */
262
  if (redir_apply(redir) != 0) return(CMD_FAIL);
263
  if (redir_apply(redir) != 0) return(CMD_FAIL);
263
 
264
 
264
  /* prepare function parameters and feed it to the cmd handling function */
265
  /* prepare function parameters and feed it to the cmd handling function */
265
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
266
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
266
  p->env_seg = env_seg;
267
  p->env_seg = env_seg;
267
  p->rmod = rmod;
268
  p->rmod = rmod;
268
  p->argoffset = argoffset;
269
  p->argoffset = argoffset;
269
  p->cmdline = cmdline;
270
  p->cmdline = cmdline;
270
 
271
 
271
  cmdres = (cmdptr->func_ptr)(p);
272
  cmdres = (cmdptr->func_ptr)(p);
272
 
273
 
273
  /* cancel redirections */
274
  /* cancel redirections */
274
  redir_revert();
275
  redir_revert();
275
 
276
 
276
  /* delete stdin temporary file */
277
  /* delete stdin temporary file */
277
  if (delstdin) {
278
  if (delstdin) {
278
    const char *fname = redir->stdinfile;
279
    const char *fname = redir->stdinfile;
279
    unsigned short doserr = 0;
280
    unsigned short doserr = 0;
280
    _asm {
281
    _asm {
281
      push ax
282
      push ax
282
      push dx
283
      push dx
283
      mov ah, 0x41  /* delete a file */
284
      mov ah, 0x41  /* delete a file */
284
      mov dx, fname /* DS:DX - filename to delete */
285
      mov dx, fname /* DS:DX - filename to delete */
285
      int 0x21
286
      int 0x21
286
      jnc DONE
287
      jnc DONE
287
      mov doserr, ax
288
      mov doserr, ax
288
      DONE:
289
      DONE:
289
      pop dx
290
      pop dx
290
      pop ax
291
      pop ax
291
    }
292
    }
292
    if (doserr) {
293
    if (doserr) {
293
      output(fname);
294
      output(fname);
294
      output(": ");
295
      output(": ");
295
      nls_outputnl_doserr(doserr);
296
      nls_outputnl_doserr(doserr);
296
    }
297
    }
297
  }
298
  }
298
 
299
 
299
  return(cmdres);
300
  return(cmdres);
300
}
301
}
301
 
302