// get current dos directory
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "daemon.h"
#include "client.h"
#include <stdlib.h>

int main(int argc, char **argv) {
  if (server_init() < 0) {
    exit(-1);
  }
  char drive;
  HI(ax) = 0x47;
  if (argc ==1) {
    HI(ax) = 0x19;
    Daemon_int86(0x21);
    drive = (char)toupper(LO(ax) + 'a');
    LO(dx) = 0;
  }
  else {
    drive = (char)toupper (argv[1][0]);
    LO(dx) = tolower(drive) - 'a' + 1;
  }
  daemon_comms & dcom = server->daemon_comm;
  bzero (dcom.buf, 64);
  DOS_SI = dcom.off + offsetof(daemon_comms, buf);
  Daemon_int86(0x21);
  
  if (LWORD(eflags) & 0x1) {
    cerr << "carry set!! DOS error: " << DOS_AX << endl;
  }
  else {
    
    cout << "CWD: " << drive << ":\\" << dcom.buf << endl;
  }
  server_exit();
}
