/*  fixhpgl.c - removes blank characters from a file.  Used to fix HPGL plot
                files produced by plotsys calls so that they can be imported
                into WordPerfect and possibly other word processors.

                written by Jeff Phillips 7/94
*/
#include <stdio.h>

main(argc,argv)
int argc;
char **argv;
{
    char c;
    FILE *f1,*f2,*fopen();

    if(argc != 2)
    {
        puts("\n Usage: fixhpgl plot_file_name");
        exit(0);
    }
    f1=fopen(argv[1],"rb");
    if(!f1)
    {
        printf("Could not open '%s'\n",argv[1]);
        exit(0);
    }
    f2=fopen("fixhpgl.tmp","wb");
    if(!f2)
    {
        printf("Could not open fixhpgl.tmp\n");
        exit(0);
    }
    while((c = getc(f1)) != EOF)
    {
        if(c != 32) fputc(c,f2);
    }
    fclose(f1);
    fclose(f2);
    if(remove(argv[1]) == -1)
        printf("Could not overwrite '%s'\n",argv[1]);
    if(rename("fixhpgl.tmp",argv[1]) != 0)
        printf("Could not rename fixhpgl.tmp\n");
}
