Subject: Re: [netatalk-admins] PhotoShop printing garbage

From: Brian Bothwell <[email-masked]>
Date: Sun, 31 May 1998 15:23:25 -0500 (EST)

On Thu, 28 May 1998, Antoine Reid wrote:

> On Fri, 15 May 1998, Brian Bothwell wrote:
> 
> > Yup.  Got the filter installed now, and all seems to be working fine.
> > 
> > Thanx,
> > 
> > -brian
> > 
> > 
> > PS If anyone else need the filter source code, email me.
> 
> I think it could be of some use for many netatalk users... could you post
> the source in the netatalk mailing list please?  It especially will be 
> good if it goes into the archives...
> 
> TIA
> tonio
> 

Here it is.  Thanx to Andras Kadinger <[email-masked]> for
orginally sending this to me, and Michael Hojnowski
<[email-masked]> for the original posting w/ the code (the source
come from Lexmark tech support)

-brian

--------------------------snip here-------------------------------

/* 
   bin2tbcp.c   -  Convert file to Tagged Binary Communications Protocol.
*/

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

void main(argc,argv) 
int argc;
char *argv[];
{
	FILE *infp,*outfp;
	long CH;
	char inputfile[80],outputfile[80];

	if (argc == 3) {
	    strcpy(inputfile, argv[1]);
	    strcpy(outputfile, argv[2]);
	    if ( (infp = fopen(inputfile,"r")) == NULL ) {
		printf("\nERROR : Unable to open input file: %s\n",inputfile);
		exit(1);
	    }
	    if ( (outfp = fopen(outputfile,"w")) == NULL ) {
		printf("\nERROR : Unable to open output file: %s\n",outputfile);
		exit(1);
	    }
	}
	else if (argc == 2) {
	    strcpy(inputfile, argv[1]);
	    outfp = stdout;
	    if ( (infp = fopen(inputfile,"r")) == NULL ) {
		printf("\nERROR : Unable to open input file: %s\n",inputfile);
		exit(1);
	    }
	}
	else {
	    infp=stdin;
	    outfp=stdout;
	}

	fprintf(outfp,"%cM",(unsigned char)(0x01));
	while ((CH = fgetc(infp)) != EOF) {
	    switch (CH) {
	    case (unsigned char) 0x01:  /* ^A */
	    case (unsigned char) 0x03:  /* ^C */
	    case (unsigned char) 0x04:  /* ^D */
	    case (unsigned char) 0x05:  /* ^E */
	    case (unsigned char) 0x11:  /* ^Q */
	    case (unsigned char) 0x13:  /* ^S */
	    case (unsigned char) 0x14:  /* ^T */
	    case (unsigned char) 0x1c:  /* ^\ */
	    case (unsigned char) 0x1b:  /* ^[ */
		fputc((unsigned char) 0x01,outfp);
		fputc((unsigned char)(CH ^ 0x40),outfp); 
		break;
	    default:
		fputc(CH,outfp);
	    }

	}

	fprintf(outfp,"%c%%-12345X",(unsigned char)(0x1b));
	fclose(outfp);
	fclose(infp);
    }

---------------------------------------end-------------------------------