Subject: end-of-line and Gaussian for Linux

From: polumrak <polumrak:at:gmail.com>
Date: Mon, 14 Feb 2005 21:05:10 +0300

Hello guys!

We've start using Gaussian only 6 month ago and...
Well, that's a common problem - input files, created with GaussView
for Windows comes in windows end-of-line format, which is not
acceptable for UNIX Gaussian.
Yes, you can convert them with something like Openoffice.org, Kate...
or any another X editor... But who need that?
So Mr. Svetlichny wrote the tiny utility, which we call Converter.
It simply deletes wrong EOLs from files which you gives them.
I know that people can easily do that with one line Perl or Python
script, but... who cares? :)))

That's ANSI C source code. If you want to use converter, save it to
file, (name it "converter.c" for example), then just compile it with
your favorite compiler.
On Linux you can make so:
gcc -o converter converter.c
then run binary converter: ./converter
You will see its output. Of course you need gcc installed.
You can do that under Windows with your favorite C compiler.

So now just type in something like that:
./converter lalala.gjf lalala.com
under Linux, or
converter.exe lalala.gjf lalala.com
And you will get your desired input for UNIX Gaussian :)

Okay, that's it: 

/*   delete 0d from string   */

#include "stdio.h"
#include "string.h"
#include <stdlib.h>

int main(int argc, char * argv[])
{

	char szBin[50], szHex[50];
	char iData;
        FILE *fpBin, *fpHex;

	if (argc<2)
		{
		printf("\Deletes 0x0d at the end of every string \n");
		printf("Usage: convert inputfile.ext outputfile.ext \n");
		printf("14 feb 2005 by V.Svetlychny\n");
        	printf("\n");
		exit(0);
		};

	/* make filenames */
	strcpy(szBin, argv[1]);
        strcpy(szHex, argv[2]);
	fpBin = fopen(szBin,"rb");
	if (fpBin==NULL)
		{
		printf("Cannot open %s\n",szBin);
		exit(1);
		}

	fpHex = fopen(szHex,"wb");
	if (fpHex==NULL)
		{
		printf("Cannot open %s\n",szHex);
		exit(1);
		}

	/* read and write */
	putchar('\n');
	printf("Writing to %s:\n",szHex);
	putchar('\n');
	putchar('\n');

        while (1) {
              iData=fgetc(fpBin);
              if(iData==EOF) break;
              putchar(iData);
              if(iData != 0x0d) fputc(iData, fpHex);
        };
	fclose(fpBin);
	fclose(fpHex);
	putchar('\n');
	putchar('\n');
	putchar('\n');
        printf("End of file\n");

        return 0;

}