/* ---------------------------------------------------------------------- */
/* Online Commander v0.3.Test                       2:5045/37.18@Fidonet  */
/* Copyright (c)1998-99 by Alex Carcass                  carcass@chat.ru  */
/* ---------------------------------------------------------------------- */

? print "þ Transfer section...\n"

byte BATCH_ADD()        // [ds:]ax = #buf; out: = 1 if ok
{ BX = DS;
$ PUSHA
  $ PUSH CS; $ POP  DS
  DX = DS; $ PUSH DX
  DI = #s; $ PUSH DI
  MOVE(mnt_head,mnt_curr+MNT_INFO,80); // (...,DS,#s)
  $ POP BX; $ POP AX; CX = BX;
  $ PUSHA; GETRPART(); $ POPA
  $ PUSHA; CX = #s1;   GETLPART(); $ POPA       // s1 = alias
  $ PUSHA; GETRPART();
  $ POPA;  GETLPART();                          // s = path
$ POPA
  DS = BX; CX = AX;
$ PUSH BX
  BX = #s;
$ PUSH BX; STRAPPEND(CS);     // (.....[,CX])
$ PUSH CS; $ POP  DS
  AH = FindFirst>>8;
$ POP  DX; @_21H(,,faOrdinary);  // DX <- BX = #s
$ POP  BX
  IF(NOTCARRYFLAG)
  { $ PUSH BX; DI = #s; AX = DS;
      $ PUSHA; MOVE(,ffBufHead+ffName,13,DS);
      $ POPA;  BX><DI;
      $ PUSHA; STRAPPEND(,," ");        // (DS,#s,.....
      $ POPA;  CX = #s1;
      $ PUSHA; STRAPPEND();             // (DS,#s,#s1)      alias
      $ POPA;  AX><CX;
      $ PUSHA; GET_PROMPT(,CFG_BATCH);  // (#s1,.....
      $ POPA;  AX><BX; FAPPENDSTR();    // (#s,#s1)
        GETLPART(DS,#s,#buf);
        GET_PROMPT(#s1,LOG_FMARK);
        STRAPPEND(DS,#s1,#buf);
        LOG_APPEND(#s1);
    $ POP  BX; AL = 1;
  } ELSE AL = 0;
  DS = BX;
}

void update_batch()
{ AX = DS; BX = #buf;
$ PUSHA;   GETRPART(,,#s);  $ POPA
$ PUSHA;   GETLPART(,,#s1); $ POPA
$ PUSH BX; MNT_LOOKUP(#s);  $ POP  BX
  IF(AX!=0xFFFF)
  { $ PUSH BX; MNT_GETPATH();
    $ POP  BX; STRAPPEND(DS,,#s1);
    GET_PROMPT(#s,CFG_SZSND);
    AX = DS; BX = 0x80; CX = BX; DX = AX; DI = #s1;
    $ PUSHA; MOVE(); FAPPENDSTR(#buf,#s); $ POPA;
    BX><DI;  MOVE(); wVar1++;
  }
$ CLC
}

word DOWNLOAD()
{ wVar1=0;
  GET_PROMPT(#buf,CFG_SZSND);
  AH = FileCreate>>8; @_21H(,,,#buf); AX><BX;
  AH = FileClose>>8;  @_21H();
  GET_PROMPT(#buf,CFG_BATCH);
  FREADTEXT(#buf,#update_batch,128,#buf);
  IF(wVar1>0)
  { AX = #buf;
  $ PUSH AX; GET_PROMPT(,LOG_FDWNL);
  $ POP  AX; LOG_APPEND();
    DOOR_SPAWN("sz");
  }
}
