Subversion Repositories SvarDOS

Rev

Rev 449 | Rev 457 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 449 Rev 450
Line 321... Line 321...
321
  /* printf("EXEPATH: '%s'\r\n", buff); */
321
  /* printf("EXEPATH: '%s'\r\n", buff); */
322
  env_setvar(envseg, buff);
322
  env_setvar(envseg, buff);
323
}
323
}
324
 
324
 
325
 
325
 
-
 
326
/* wait for user input */
-
 
327
static void cmdline_getinput(unsigned short inpseg, unsigned short inpoff) {
-
 
328
  _asm {
-
 
329
    push ax
-
 
330
    push bx
-
 
331
    push cx
-
 
332
    push dx
-
 
333
    push ds
-
 
334
 
-
 
335
    /* is DOSKEY support present? (INT 2Fh, AX=4800h, returns non-zero in AL if present) */
-
 
336
    mov ax, 0x4800
-
 
337
    int 0x2f
-
 
338
    mov bl, al /* save doskey status in BL */
-
 
339
 
-
 
340
    /* set up buffered input to inpseg:inpoff */
-
 
341
    mov ax, inpseg
-
 
342
    push ax
-
 
343
    pop ds
-
 
344
    mov dx, inpoff
-
 
345
 
-
 
346
    /* execute either DOS input or DOSKEY */
-
 
347
    test bl, bl /* zf set if no DOSKEY present */
-
 
348
    jnz DOSKEY
-
 
349
 
-
 
350
    mov ah, 0x0a
-
 
351
    int 0x21
-
 
352
    jmp short DONE
-
 
353
 
-
 
354
    DOSKEY:
-
 
355
    mov ax, 0x4810
-
 
356
    int 0x2f
-
 
357
 
-
 
358
    DONE:
-
 
359
    /* terminate command with a CR/LF */
-
 
360
    mov ah, 0x02 /* display character in dl */
-
 
361
    mov dl, 0x0d
-
 
362
    int 0x21
-
 
363
    mov dl, 0x0a
-
 
364
    int 0x21
-
 
365
 
-
 
366
    pop ds
-
 
367
    pop dx
-
 
368
    pop cx
-
 
369
    pop bx
-
 
370
    pop ax
-
 
371
  }
-
 
372
}
-
 
373
 
-
 
374
 
326
int main(void) {
375
int main(void) {
327
  static struct config cfg;
376
  static struct config cfg;
328
  static unsigned short rmod_seg;
377
  static unsigned short rmod_seg;
329
  static unsigned short far *rmod_envseg;
378
  static unsigned short far *rmod_envseg;
330
  static unsigned short far *lastexitcode;
379
  static unsigned short far *lastexitcode;
Line 361... Line 410...
361
    envsiz *= 16;
410
    envsiz *= 16;
362
    printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod_seg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz);
411
    printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod_seg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz);
363
  }*/
412
  }*/
364
 
413
 
365
  do {
414
  do {
366
    char far *cmdline = MK_FP(rmod_seg, RMOD_OFFSET_INPBUFF + 2);
415
    char far *cmdline = rmod->inputbuf + 2;
367
    unsigned char far *echostatus = MK_FP(rmod_seg, RMOD_OFFSET_ECHOFLAG);
-
 
368
 
416
 
369
    /* (re)load translation strings if needed */
417
    /* (re)load translation strings if needed */
370
    nls_langreload(BUFFER, *rmod_envseg);
418
    nls_langreload(BUFFER, *rmod_envseg);
371
 
419
 
372
    /* skip user input if I have a command to exec (/C or /K) */
420
    /* skip user input if I have a command to exec (/C or /K) */
Line 374... Line 422...
374
      cmdline = cfg.execcmd;
422
      cmdline = cfg.execcmd;
375
      cfg.execcmd = NULL;
423
      cfg.execcmd = NULL;
376
      goto EXEC_CMDLINE;
424
      goto EXEC_CMDLINE;
377
    }
425
    }
378
 
426
 
379
    if (*echostatus != 0) outputnl(""); /* terminate the previous command with a CR/LF */
427
    if (rmod->echoflag != 0) outputnl(""); /* terminate the previous command with a CR/LF */
380
 
428
 
381
    SKIP_NEWLINE:
429
    SKIP_NEWLINE:
382
 
430
 
383
    /* print shell prompt (only if ECHO is enabled) */
431
    /* print shell prompt (only if ECHO is enabled) */
384
    if (*echostatus != 0) {
432
    if (rmod->echoflag != 0) {
385
      char *promptptr = BUFFER;
433
      char *promptptr = BUFFER;
386
      buildprompt(promptptr, *rmod_envseg);
434
      buildprompt(promptptr, *rmod_envseg);
387
      _asm {
435
      _asm {
388
        push ax
436
        push ax
389
        push dx
437
        push dx
Line 398... Line 446...
398
    /* revert input history terminator to \r */
446
    /* revert input history terminator to \r */
399
    if (cmdline[-1] != 0) {
447
    if (cmdline[-1] != 0) {
400
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
448
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
401
    }
449
    }
402
 
450
 
403
    /* wait for user input */
451
    /* wait for user command line */
404
    _asm {
-
 
405
      push ax
-
 
406
      push bx
-
 
407
      push cx
-
 
408
      push dx
-
 
409
      push ds
-
 
410
 
-
 
411
      /* is DOSKEY support present? (INT 2Fh, AX=4800h, returns non-zero in AL if present) */
-
 
412
      mov ax, 0x4800
-
 
413
      int 0x2f
-
 
414
      mov bl, al /* save doskey status in BL */
-
 
415
 
-
 
416
      /* set up buffered input */
-
 
417
      mov ax, rmod_seg
-
 
418
      push ax
-
 
419
      pop ds
-
 
420
      mov dx, RMOD_OFFSET_INPBUFF
-
 
421
 
-
 
422
      /* execute either DOS input or DOSKEY */
452
    cmdline_getinput(FP_SEG(rmod->inputbuf), FP_OFF(rmod->inputbuf));
423
      test bl, bl /* zf set if no DOSKEY present */
-
 
424
      jnz DOSKEY
-
 
425
 
-
 
426
      mov ah, 0x0a
-
 
427
      int 0x21
-
 
428
      jmp short DONE
-
 
429
 
-
 
430
      DOSKEY:
-
 
431
      mov ax, 0x4810
-
 
432
      int 0x2f
-
 
433
 
-
 
434
      DONE:
-
 
435
      /* terminate command with a CR/LF */
-
 
436
      mov ah, 0x02 /* display character in dl */
-
 
437
      mov dl, 0x0d
-
 
438
      int 0x21
-
 
439
      mov dl, 0x0a
-
 
440
      int 0x21
-
 
441
 
-
 
442
      pop ds
-
 
443
      pop dx
-
 
444
      pop cx
-
 
445
      pop bx
-
 
446
      pop ax
-
 
447
    }
-
 
448
 
453
 
449
    /* if nothing entered, loop again (but without appending an extra CR/LF) */
454
    /* if nothing entered, loop again (but without appending an extra CR/LF) */
450
    if (cmdline[-1] == 0) goto SKIP_NEWLINE;
455
    if (cmdline[-1] == 0) goto SKIP_NEWLINE;
451
 
456
 
452
    /* replace \r by a zero terminator */
457
    /* replace \r by a zero terminator */