💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › C › u2a.c captured on 2024-07-09 at 01:42:06.
View Raw
More Information
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Newsgroups: comp.sys.apple2
Path: news.weeg.uiowa.edu!news.uiowa.edu!uunet!nevada.edu!jimi!news.cs.unlv.edu!sknkwrks
From: sknkwrks@sonny-boy.cs.unlv.edu (Scott Alfter)
Subject: Re: How to convert LF's to CR's in UNIX?
In-Reply-To: sbdocker@acs.ucalgary.ca's message of Sun, 29 Aug 1993 19:16:51 GMT
Message-ID: <SKNKWRKS.93Aug30114435@sonny-boy.cs.unlv.edu>
Sender: news@unlv.edu (News User)
Organization: UNLV
References: <CCG2zn.JyC@pacifier.rain.com>
Date: 30 Aug 1993 18:44:34 GMT
Lines: 96
In article <CCG2zn.JyC@pacifier.rain.com> kenh@pacifier.rain.com (Ken Hoffmann) writes:
>Hello net brethren, I remeber seeing a c-shell script that would take
>a UNIX text file and convert it to a Apple readable format, anyone
>know where that went? And if someone has it, please mail it to me.
Hmm...don't know about shell scripts, but here are a couple of C
programs that I use for converting from UNIX newlines to either Apple
newlines or DOS newlines. Compile these with gcc (or some other ANSI
C) and drop them into your ~/bin directory (you do have one, right?).
Syntax: u2a infile outfile (UNIX-to-Apple)
u2d infile outfile (UNIX-to-DOS)
-------------------------------------u2a.c-------------------------------------
/*
UNIX-to-Apple newline converter
25 Jul 93
#include <stdio.h>
int main (int argc, char *argv[])
{
FILE *in_hndl, *out_hndl; /* file handles */
char c;
if (argc!=3)
{
fprintf (stderr, "Usage: %s infile outfile\n", argv[0]);
return 1;
}
if ((in_hndl=fopen (argv[1], "r"))==NULL) /* open input file */
{
fprintf (stderr, "%s: can't open %s\n", argv[0], argv[1]);
return 1;
}
if ((out_hndl=fopen (argv[2], "w"))==NULL) /* open output file */
{
fprintf (stderr, "%s: can't open %s\n", argv[0], argv[2]);
return 1;
}
while ((c=getc (in_hndl))!=EOF) /* copy files */
if (c!='\n')
putc (c, out_hndl);
else
putc ('\015', out_hndl);
fclose (in_hndl); /* close files */
fclose (out_hndl);
return 0;
}
-------------------------------------u2d.c-------------------------------------
/*
UNIX-to-DOS newline converter
15 Jul 93
#include <stdio.h>
int main (int argc, char *argv[])
{
FILE *in_hndl, *out_hndl; /* file handles */
char c;
if (argc!=3)
{
fprintf (stderr, "Usage: %s infile outfile\n", argv[0]);
return 1;
}
if ((in_hndl=fopen (argv[1], "r"))==NULL) /* open input file */
{
fprintf (stderr, "%s: can't open %s\n", argv[0], argv[1]);
return 1;
}
if ((out_hndl=fopen (argv[2], "w"))==NULL) /* open output file */
{
fprintf (stderr, "%s: can't open %s\n", argv[0], argv[2]);
return 1;
}
while ((c=getc (in_hndl))!=EOF) /* copy files */
if (c!='\n')
putc (c, out_hndl);
else
{
putc ('\015', out_hndl);
putc (c, out_hndl);
}
fclose (in_hndl); /* close files */
fclose (out_hndl);
return 0;
}
--------------------------------------end--------------------------------------
_/_ Scott Alfter (sknkwrks@cs.unlv.edu) Ask me about SoftDAC--digital
/ v \ Call the Skunk Works BBS today! audio for your Apple IIe/IIc!
(IIGS( (702) 894-9619 300-14400 V.32bis 1:209/263 Apple II, IBM, Trek, & more!
\_^_/ --==## "Apple II Forever" is a trademark of Apple Computer, Inc. ##==--