home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
snpd9707.zip
/
NLCNVRT.C
< prev
next >
Wrap
Text File
|
1997-07-05
|
3KB
|
112 lines
.I 0 1
/* +++Date last modified: 05-Jul-1997 */
.D 1 1
.I 6 1
** Mac support by Norman Dodge and Bob Stout
.I 17 9
static void usage(void);
static void dos2unix(void);
static void dos2mac(void);
static void unix2dos(void);
static void unix2mac(void);
static void mac2dos(void);
static void mac2unix(void);
static void Cout(int ch, FILE *outfile);
static void Sout(char *str, FILE *outfile);
.D 18 6
.I 44 1
unix2dos();
.D 45 2
.I 48 4
case 'D':
mac2dos();
break;
.I 49 13
dos2unix();
break;
case 'U':
mac2unix();
break;
case 'm':
dos2mac();
break;
case 'M':
unix2mac();
.D 50 7
.I 77 7
puts("Usage: NLCNVRT -[d | u | m | D | U | M] infile [outfile]");
puts("Switches: -d Convert to DOS from Unix - converts LF => CRLF");
puts(" : -u Convert to Unix from DOS - converts CRLF => LF");
puts(" : -m Convert to Mac from DOS - converts CRLF => CR");
puts(" : -D Convert to DOS from Mac - converts CR => CRLF");
puts(" : -U Convert to Unix from Mac - converts CR => LF");
puts(" : -M Convert to Mac from Unix - converts LF => CR");
.D 78 4
.I 84 1
void unix2dos(void)
.D 85 1
.I 98 1
void dos2unix(void)
.D 99 1
.I 111 46
void mac2dos(void)
{
int ch, lastch = 0;
while (EOF != (ch = fgetc(infile)))
{
fputc(lastch = ch, outfile);
if ('\r' == ch)
fputc('\n', outfile);
}
if ('\r' != lastch)
fputs("\r\n", outfile);
}
static void dos2mac(void)
{
int ch, lastch = 0;
while (EOF != (ch = fgetc(infile)) && '\x1a' != ch)
{
if ('\r' != ch)
{
if ('\n' == ch)
ch = '\r';
fputc(lastch = ch, outfile);
}
}
if ('\r' != lastch)
fputc('\r', outfile);
}
static void unix2mac(void)
{
int ch, lastch = 0;
while (EOF != (ch = fgetc(infile)))
{
if ('\n' == ch)
ch = '\r';
fputc(lastch = ch, outfile);
}
if ('\r' != lastch)
fputc('\r', outfile);
}
static void mac2unix(void)
.D 112 1
.I 118 7
ch = '\n';
fputc(lastch = ch, outfile);
}
if ('\n' != lastch)
fputc('\n', outfile);
}
.D 119 7