Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdahl!pacbell!sactoh0!bkbarret From: bkbarret@sactoh0.UUCP (Brent K. Barrett) Newsgroups: comp.sys.ibm.pc Subject: Re: Text file conversion between UNIX and MSDOS Summary: Adding CRs, C source code Message-ID: <688@sactoh0.UUCP> Date: 10 Feb 89 22:10:50 GMT References: <89Feb9.123853est.2662@godzilla.eecg.toronto.edu> Distribution: na Organization: Sacramento Public Access, Ca. USA Lines: 90 In article <89Feb9.123853est.2662@godzilla.eecg.toronto.edu>, noworol@eecg.toronto.edu (Mark Noworolski) writes: > Can somebody send me a program to do this? Ok, you didn't say what language is was to be in, or what form, so here's a C program to do it for you. ---- /* * addcr.c * Copyright 1989 by Brent Barrett */ #define VERSION "1.0" #include "stdio.h" #include "io.h" #include "fcntl.h" #include "sys\stat.h" void can_not_open(char *fn); main(argc, argv) int argc; char *argv[]; { int in, ou; int j, l, i; unsigned long bytes_in = 0l, bytes_out = 0l; char in_buf[2048], ou_buf[3064]; if (argc < 3) { printf("\n Usage: C>addcr \n"); exit(0); } printf("ADDCR version %s\nCopyright 1989 by Brent Barrett\n", VERSION); if ((in=open(argv[1], O_RDONLY|O_BINARY)) == -1) can_not_open(argv[1]); if ((ou=open(argv[2], O_WRONLY|O_CREAT|O_BINARY, S_IREAD|S_IWRITE)) == -1) can_not_open(argv[2]); printf("\nWorking..."); while((l=_read(in, in_buf, 2048))) { bytes_in += l; for (i=0, j=0; i