[comp.lang.postscript] ps2eexec BUG fixed

cnwietho@immd4.informatik.uni-erlangen.de (Carsten Wiethoff) (10/10/89)

I posted a quickie program to convert postscript to eexec format two weeks
ago. Unfortunately I mixed up the versions and included an old and 
incorrect version. Sorry for that.
(I always say programs are either trivial or incorrect, but mine was both..)
So here is the (hopefully) correct version:

----------------------- cut here -------------------------------------------
/* Quickie to convert postscript from stdin to eexec format on stdout */
/* Written by Carsten Wiethoff 1989 */
/* You may do with it what you want as long as this notice stays in it */

#include <stdio.h>

static unsigned short buffer = 0xd971;
static unsigned long startup = 0x00000000; /* or whatever you want */

main()
{
  unsigned char input;
  unsigned char output;
  int init = 4;
  int i;

  printf("%08x",startup);
  for (i=0;i<init;++i)
    {
      input = (startup >> ((3-i)*8));
      buffer = (input + buffer) * 0xce6d + 0x58bf;
    }  

  for(;;)
    {
      for (i=0;i<(32-init);++i)
	{
	  input = getchar();
	  if (input == EOF)
	    break;
	  output = (input ^ (buffer>>8));
	  buffer = (output + buffer) * 0xce6d + 0x58bf;
	  printf("%02x",output);
	}
      init = 0;
      printf("\n");
      if (input == EOF)
	break;
    }
}

				Carsten Wiethoff


Voice: +49/(0)9131/85-7908
E-mail: cnwietho@immd4.informatik.uni-erlangen.de