_PORTING UNIX APPLICATIONS TO DOS_ by David N. Glass Figure 1: Macros to handle text and binary files in DOS. #ifdef DOS # define READ_BIN "rb" # define READ_TXT "r" # define WRITE_BIN "wb" # define WRITE_TXT "w" #else /* the unix way */ # define READ_BIN "r" # define READ_TXT "r" # define WRITE_BIN "w" # define WRITE_TXT #endif /* DOS */ Figure 2: Mapping the UNIX SIGALRM to a DOS user-defined signal. #ifdef DOS # define SIGALRM SIGUSR1 #endif /*DOS*/ Figure 3. Writing files using a specified file handle. write_files(fp, buffer, bytes) int fp; char *buffer; int bytes; { if (bytes > 0) write(fp, buffer, bytes); } Figure 4: Mapping WRIT_TTY to either DOS or UNIX I/O calls. #ifdef DOS # define WRITE_TTY write_port #else /* unix */ # define WRITE_TTY write #endif /* DOS */