home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
16
/
FREEDOS.ZIP
/
FD_A4PRE.ZIP
/
SOURCE
/
MICROC.ZIP
/
UNIX2DOS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-14
|
2KB
|
98 lines
/*
UNIX2DOS cr -> cr/lf filter for converting UNIX text files to DOS.
Author: James Hall, ported to MICRO-C by M. Hannibal Toal
*/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include "freedos.h"
#include "getopt.c"
void usage (void);
int trch (FILE * p, char ch1, char ch2);
main (int argc, char **argv)
{
int i;
FILE *pFile;
/* Scan the command line */
while ((i = getopt (argc, argv, "", "")) != EOF)
{
switch (i)
{
default:
usage ();
break;
}
}
/* Convert the files */
if ((argc - optind) < 1)
{
trch (stdin, UNIX_NL, DOS_NL);
exit (0);
}
for (i = optind; i < argc; i++)
{
if ((pFile = fopen (argv[i], "r")) != NULL)
{
trch (pFile, UNIX_NL, DOS_NL);
fclose (pFile);
}
else
fprintf (stderr, "Cannot open file %s\n", argv[i]);
}
exit (0);
}
int trch (FILE * p, char ch1, char ch2)
{
char chBuf;
/* Convert characters in the input stream */
while ((chBuf = fgetc (p)) != EOF)
{
if (chBuf == ch1)
{
putchar (ch2);
}
else
putchar (chBuf);
}
return (0);
}
void usage (void)
{
printp ("UNIX2DOS", "Converts a file from the UNIX newline format to DOS.");
printu ("UNIX2DOS", "[file..]");
exit (1);
}