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

int main(int argc, char **argv)
{
   RGB *pcxdata;
   int w, h;

   if (argc == 1) {
       fprintf(stderr, "usage: pcx2ppm file\n");
       exit(1);
   }

   if (! (pcxdata = read_pcx(argv[1], &w, &h)))
       exit(1);

   printf("P6\n%d %d\n255\n", w, h);
   fwrite(pcxdata, 1, w * sizeof(RGB) * h, stdout);
}