🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #15816

Cure for Kermit Blues

#15816
From: farren
Date: Sat, 14 Feb 1987 20:47
61 lines
2293 bytes
Late last night, I finished transferring 650K worth of files using good 'ol
ckermit, rm'd all of the files, and then went to my PC to decompress 'em
and put 'em away.  Of course, it was only then that I found out that I hadn't
"set file type bin", so the files were not usable.  After mucho moaning and
groaning, I wrote the following utility.  It transforms all occurances of
0x0d followed by 0x0a (the CR/LF pair ckermit translates LF's into) into
a single 0x0a.  Of course, this doesn't work will ALL files - sooner or
later you are going to run into a 0x0d 0x0a pair that belongs there - but it
did work on about 600K of the 650K.  Only one file was still messed up, and
even then, most of the data was O.K.  I hope this will be of some help to
other late night communicators.

--------

/* striplf.c - strips extraneous carriage returns from falsely transmitted
   files */

#include <stdio.h>

main(argc, argv)
int argc;
char *argv[];
{
  FILE *infile,*outfile;
  int a,b;

  infile = fopen(argv[1], "rb");
  if(infile==NULL) {
    perror("Input file open error ");
    exit(20);
  }
  outfile = fopen(argv[2], "wb");
  if(outfile==NULL) {
    perror("Output file open error ");
    exit(20);
  }

  while((a = fgetc(infile))!=EOF) {
    if(a == 0x0d) {
      if((b = fgetc(infile))!=EOF) {
	if(b==0x0a) fputc(b, outfile);
	else {
	  fputc(a, outfile);
	  fputc(b, outfile);
	}
      }
    }
    else fputc(a, outfile);
  }
  fclose(infile);
  fclose(outfile);
}

-------

A simple program, but useful.  Hope it can help some of you.
-- 
----------------
                 "... if the church put in half the time on covetousness
Mike Farren      that it does on lust, this would be a better world ..."
hoptoad!farren       Garrison Keillor, "Lake Wobegon Days"
Technical Details
Message-ID: <1812@hoptoad.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!lll-crg!hoptoad!farren

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!lll-crg!hoptoad!farren
From: farren@hoptoad.UUCP
Newsgroups: comp.sys.ibm.pc
Subject: Cure for Kermit Blues
Message-ID: <1812@hoptoad.uucp>
Date: Sat, 14-Feb-87 15:47:00 EST
Article-I.D.: hoptoad.1812
Posted: Sat Feb 14 15:47:00 1987
Date-Received: Sun, 15-Feb-87 05:40:53 EST
Organization: Nebula Consultants in San Francisco
Lines: 61