Subversion Repositories SvarDOS

Rev

Rev 1730 | Rev 1822 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1730 Rev 1797
Line 222... Line 222...
222
  if (argvlist) argvlist[argc] = NULL;
222
  if (argvlist) argvlist[argc] = NULL;
223
  return(argc);
223
  return(argc);
224
}
224
}
225
 
225
 
226
 
226
 
-
 
227
/* asks DOS to change the current default drive, returns the current drive
-
 
228
 * (should be the same as d on success) */
-
 
229
static unsigned char _changedosdrive(unsigned char d);
-
 
230
#pragma aux _changedosdrive = \
-
 
231
"mov ah, 0x0e"   /* DOS 1+ - SELECT DRIVE (DL=drive, 00h=A:, 01h=B:, etc) */ \
-
 
232
"int 0x21" \
-
 
233
"mov ah, 0x19"     /* DOS 1+ - GET CURRENT DRIVE (drive in al) */ \
-
 
234
"int 0x21" \
-
 
235
parm [dl] \
-
 
236
modify [ah] \
-
 
237
value [al]
-
 
238
 
-
 
239
 
-
 
240
/* asks DOS to del a file, returns 0 on success */
-
 
241
static unsigned short _dosdelfile(const char near *f);
-
 
242
#pragma aux _dosdelfile = \
-
 
243
"mov ah, 0x41"  /* delete a file ; DS:DX = filename to delete */ \
-
 
244
"int 0x21" \
-
 
245
"jc DONE" \
-
 
246
"xor ax, ax" \
-
 
247
"DONE:" \
-
 
248
parm [dx] \
-
 
249
value [ax]
-
 
250
 
-
 
251
 
227
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) {
252
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) {
228
  const struct CMD_ID *cmdptr;
253
  const struct CMD_ID *cmdptr;
229
  unsigned short argoffset;
254
  unsigned short argoffset;
230
  enum cmd_result cmdres;
255
  enum cmd_result cmdres;
231
  struct cmd_funcparam *p = (void *)BUFFER;
256
  struct cmd_funcparam *p = (void *)BUFFER;
Line 233... Line 258...
233
 
258
 
234
  /* special case: is this a drive change? (like "E:") */
259
  /* special case: is this a drive change? (like "E:") */
235
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
260
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
236
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
261
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
237
      unsigned char drive = cmdline[0];
262
      unsigned char drive = cmdline[0];
238
      unsigned char curdrive = 0;
263
      unsigned char curdrive;
239
      if (drive >= 'a') {
264
      if (drive >= 'a') {
240
        drive -= 'a';
265
        drive -= 'a';
241
      } else {
266
      } else {
242
        drive -= 'A';
267
        drive -= 'A';
243
      }
268
      }
244
      _asm {
-
 
245
        push ax
-
 
246
        push dx
-
 
247
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
-
 
248
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
-
 
249
        int 0x21
-
 
250
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
-
 
251
        int 0x21
-
 
252
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
269
      curdrive = _changedosdrive(drive);
253
        pop dx
-
 
254
        pop ax
-
 
255
      }
-
 
256
      if (curdrive == drive) return(CMD_OK);
270
      if (curdrive == drive) return(CMD_OK);
257
      nls_outputnl_doserr(0x0f);
271
      nls_outputnl_doserr(0x0f);
258
      return(CMD_FAIL);
272
      return(CMD_FAIL);
259
    }
273
    }
260
  }
274
  }
Line 280... Line 294...
280
  /* cancel redirections */
294
  /* cancel redirections */
281
  redir_revert();
295
  redir_revert();
282
 
296
 
283
  /* delete stdin temporary file */
297
  /* delete stdin temporary file */
284
  if (delstdin) {
298
  if (delstdin) {
285
    const char *fname = redir->stdinfile;
299
    unsigned short doserr = _dosdelfile(redir->stdinfile);
286
    unsigned short doserr = 0;
-
 
287
    _asm {
-
 
288
      push ax
-
 
289
      push dx
-
 
290
      mov ah, 0x41  /* delete a file */
-
 
291
      mov dx, fname /* DS:DX - filename to delete */
-
 
292
      int 0x21
-
 
293
      jnc DONE
-
 
294
      mov doserr, ax
-
 
295
      DONE:
-
 
296
      pop dx
-
 
297
      pop ax
-
 
298
    }
-
 
299
    if (doserr) {
300
    if (doserr) {
300
      output(fname);
301
      output(redir->stdinfile);
301
      output(": ");
302
      output(": ");
302
      nls_outputnl_doserr(doserr);
303
      nls_outputnl_doserr(doserr);
303
    }
304
    }
304
  }
305
  }
305
 
306