Subversion Repositories SvarDOS

Rev

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

Rev 483 Rev 484
Line 525... Line 525...
525
}
525
}
526
 
526
 
527
 
527
 
528
/* fetches a line from batch file and write it to buff (NULL-terminated),
528
/* fetches a line from batch file and write it to buff (NULL-terminated),
529
 * increments rmod counter and returns 0 on success. */
529
 * increments rmod counter and returns 0 on success. */
530
static int getbatcmd(char *buff, struct rmod_props far *rmod) {
530
static int getbatcmd(char *buff, unsigned char buffmaxlen, struct rmod_props far *rmod) {
531
  unsigned short i;
531
  unsigned short i;
532
  unsigned short batname_seg = FP_SEG(rmod->batfile);
532
  unsigned short batname_seg = FP_SEG(rmod->batfile);
533
  unsigned short batname_off = FP_OFF(rmod->batfile);
533
  unsigned short batname_off = FP_OFF(rmod->batfile);
534
  unsigned short filepos_cx = rmod->batnextline >> 16;
534
  unsigned short filepos_cx = rmod->batnextline >> 16;
535
  unsigned short filepos_dx = rmod->batnextline & 0xffff;
535
  unsigned short filepos_dx = rmod->batnextline & 0xffff;
Line 561... Line 561...
561
    int 0x21  /* CF clear on success, DX:AX set to cur pos */
561
    int 0x21  /* CF clear on success, DX:AX set to cur pos */
562
    jc CLOSEANDQUIT
562
    jc CLOSEANDQUIT
563
 
563
 
564
    /* read the line into buff */
564
    /* read the line into buff */
565
    mov ah, 0x3f
565
    mov ah, 0x3f
566
    mov cx, 255
566
    xor ch, ch
-
 
567
    mov cl, buffmaxlen
567
    mov dx, buff
568
    mov dx, buff
568
    int 0x21 /* CF clear on success, AX=number of bytes read */
569
    int 0x21 /* CF clear on success, AX=number of bytes read */
569
    jc CLOSEANDQUIT
570
    jc CLOSEANDQUIT
570
    mov blen, al
571
    mov blen, al
571
 
572
 
Line 604... Line 605...
604
  rmod->batnextline = 0;
605
  rmod->batnextline = 0;
605
  return(-1);
606
  return(-1);
606
}
607
}
607
 
608
 
608
 
609
 
-
 
610
/* max length of the cmdline storage (bytes) - includes also max length of
-
 
611
 * line loaded from a BAT file (no more than 255 bytes!) */
-
 
612
#define CMDLINE_MAXLEN 255
-
 
613
 
609
int main(void) {
614
int main(void) {
610
  static struct config cfg;
615
  static struct config cfg;
611
  static unsigned short far *rmod_envseg;
616
  static unsigned short far *rmod_envseg;
612
  static unsigned short far *lastexitcode;
617
  static unsigned short far *lastexitcode;
613
  static struct rmod_props far *rmod;
618
  static struct rmod_props far *rmod;
Line 660... Line 665...
660
 
665
 
661
    /* cancel any redirections that may have been set up before */
666
    /* cancel any redirections that may have been set up before */
662
    redir_revert();
667
    redir_revert();
663
 
668
 
664
    /* preset cmdline to point at the end of my general-purpose buffer */
669
    /* preset cmdline to point at the end of my general-purpose buffer */
665
    cmdline = BUFFER + sizeof(BUFFER) - 130;
670
    cmdline = BUFFER + sizeof(BUFFER) - (CMDLINE_MAXLEN + 1);
666
 
671
 
667
    /* (re)load translation strings if needed */
672
    /* (re)load translation strings if needed */
668
    nls_langreload(BUFFER, *rmod_envseg);
673
    nls_langreload(BUFFER, *rmod_envseg);
669
 
674
 
670
    /* skip user input if I have a command to exec (/C or /K) */
675
    /* skip user input if I have a command to exec (/C or /K) */
Line 674... Line 679...
674
      goto EXEC_CMDLINE;
679
      goto EXEC_CMDLINE;
675
    }
680
    }
676
 
681
 
677
    /* if batch file is being executed -> fetch next line */
682
    /* if batch file is being executed -> fetch next line */
678
    if (rmod->batfile[0] != 0) {
683
    if (rmod->batfile[0] != 0) {
679
      if (getbatcmd(cmdline, rmod) != 0) { /* end of batch */
684
      if (getbatcmd(cmdline, CMDLINE_MAXLEN, rmod) != 0) { /* end of batch */
680
        /* restore echo flag as it was before running the bat file */
685
        /* restore echo flag as it was before running the bat file */
681
        rmod->flags &= ~FLAG_ECHOFLAG;
686
        rmod->flags &= ~FLAG_ECHOFLAG;
682
        if (rmod->flags & FLAG_ECHO_BEFORE_BAT) rmod->flags |= FLAG_ECHOFLAG;
687
        if (rmod->flags & FLAG_ECHO_BEFORE_BAT) rmod->flags |= FLAG_ECHOFLAG;
683
        continue;
688
        continue;
684
      }
689
      }