~ubuntu-branches/ubuntu/quantal/gutenprint/quantal

« back to all changes in this revision

Viewing changes to test/pixma_parse.c

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2012-06-19 17:12:48 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20120619171248-cbil10m2dqnc71rr
Tags: 5.2.8-0ubuntu1
* New upstream release
   - Added support for Canon PIXMA DS700, DS810, 50i, 80i, 450i, 455i, 470PD,
     475PD, 550i, 560i, 850i, 860i, 865R, 900PD, 950i, 960i, 990i, 6100i,
     6500i, 9100i, 9900i, i450X, i455X, i475D, i550X, i560X, i905D, i965,
     i990, i9950, iP90, iP90v, iP100, iP6320D, MP260, MX320, MX370, MX430,
     MX510, MX710, MX890, E500, E600, PIXUS iP2700, iP3100, iP4100,
     EPSON Stylus NX420, SX420, TX420
   - CD printing on many Canon printers.
   - Non-working Canon's removed.
   - More Japanese models supported.
   - Printer modes for most printer models are now determined by the
     media, based on information from the corresponding Windows
     driver. If an incompatible mode is selected by the user, a
     suitable mode is substituted, based on the other active
     parameters and quality setting. Modes are also substituted
     based on cartridge selection and duplex selection. Inktype is
     then automatically adjusted.
   - Added support for 8-bit inks to Canon backend, and modes using
     them.
   - Adjusted margins and page sizes of Canon printers.
   - Added borderless functionality to most Canon printers.
   - A problem whereby printing did not work at all on some Linux
     distributions has been fixed.
   - Printing on the Epson Stylus NX200, SX200, and SX205 is believed
     to be corrected.
* debian/patches/0002-genppd-don-t-write-color-profile-information-with-br.patch,
  debian/patches/0003-upgrade-getopt.patch,
  debian/patches/0004-no-data-dumper-needed.patch,
  debian/patches/0005-use-dnointerpolate-in-ghostscript-command-lines.patch:
  Removed, change applied upstream.
* debian/rules: Touch ppd-updater file(s) so that they have the time stamp
  of the build of this package The time stamp of the ppd-updater files tells
  CUPS' trigger script whether they come from different package versions or
  not (LP: #932882).

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#define MAX_COLORS 36  /* was: 8 maximum number of Colors: CMYKcmyk */
28
28
 
 
29
#define DEBUG 0 /* 1 for debugging only */
 
30
 
29
31
#include "pixma_parse.h"
30
32
 
31
33
/*TODO: 
66
68
                    /* start: */
67
69
                    startxml=680;
68
70
                    xmldata=fread(buf,1,679,infile); /* 1 less than 680 */
69
 
                    printf("nextcmd: read starting XML %d %d\n", *xml_read, startxml);
 
71
                    fprintf(stderr,"nextcmd: read starting XML %d %d\n", *xml_read, startxml);
70
72
                    *xml_read=1;
71
73
                  }else if (*xml_read==1) {
72
74
                    /* end */
73
75
                    endxml=263;
74
76
                    xmldata=fread(buf,1,262,infile); /* 1 less than 263*/
75
 
                    printf("nextcmd: read ending XML %d %d\n", *xml_read, endxml);
 
77
                    fprintf(stderr,"nextcmd: read ending XML %d %d\n", *xml_read, endxml);
76
78
                    *xml_read=2;
77
79
                  }
78
80
                  /* no alternatives yet */
90
92
                                if (*cnt){  /* read arguments */
91
93
                                        unsigned int read;
92
94
                                        if((read=fread(buf,1,*cnt,infile)) != *cnt){
93
 
                                                printf("nextcmd: read error - not enough data %d %d\n", read, *cnt);
 
95
                                                fprintf(stderr,"nextcmd: read error - not enough data %d %d\n", read, *cnt);
94
96
                                                return -1;
95
97
                                        }
96
98
                                }
97
99
                                return 0;
98
100
                        }else if(c2 == '@'){ /* ESC@ */
99
 
                                printf("ESC @ Return to neutral mode\n");
 
101
                                fprintf(stderr,"ESC @ Return to neutral mode\n");
100
102
                        } else {
101
 
                                printf("unknown byte following ESC %x \n",c2);
 
103
                                fprintf(stderr,"unknown byte following ESC %x \n",c2);
102
104
                        }
103
105
                }else if(c1==0x0c){ /* Form Feed */
104
 
                        printf("-->Form Feed\n");
 
106
                        fprintf(stderr,"-->Form Feed\n");
105
107
                }else{
106
 
                        printf("UNKNOWN BYTE 0x%x @ %lu\n",c1,ftell(infile));
 
108
                        fprintf(stderr,"UNKNOWN BYTE 0x%x @ %lu\n",c1,ftell(infile));
107
109
                }
108
110
        }
109
111
        return -1;
137
139
        for(i=0;i<sizeof(valid_colors) / sizeof(valid_colors[0]);i++)
138
140
                if(valid_colors[i] == color)
139
141
                        return 1;
140
 
        printf(" [valid_color] unknown color 0x%x\n",color);
 
142
        fprintf(stderr," [valid_color] unknown color 0x%x\n",color);
141
143
        return 0;
142
144
}
143
145
 
166
168
        int cur_line=0; /* line relative to block begin */
167
169
        unsigned char* dst=malloc(len*256); /* the destination buffer */
168
170
        unsigned char* dstr=dst;
169
 
        if(!color){
170
 
          printf("no matching color for %c (0x%x, %i) in the database => ignoring %i bytes\n",color_name,color_name,color_name, len);
 
171
        /* if(!color){
 
172
           printf("no matching color for %c (0x%x, %i) in the database => ignoring %i bytes\n",color_name,color_name,color_name, len); 
 
173
           } */
 
174
        if (DEBUG) {
 
175
          fprintf(stderr,"DEBUG enter Raster len=%i,color=%c\n",len,color_name);
171
176
        }
172
 
        /*printf("DEBUG enter Raster len=%i,color=%c\n",len,color_name);*/
173
177
 
174
178
        /* decode pack bits */
175
179
        while( len > 0){ /* why does this not work: because unsigned integer wraps! */
344
348
                    /*if (img->color[i].value != 0)
345
349
                      printf("what pixel values for color %d: %x\n",i,img->color[i].value);*/
346
350
                    if (i>7){
347
 
                      printf("getting pixel values for color %d\n",i);/* only going 0 1 2 4 5 --- missing i>7 bugger! */
 
351
                      fprintf(stderr,"getting pixel values for color %d\n",i);/* only going 0 1 2 4 5 --- missing i>7 bugger! */
348
352
                      /*img->color[i].value = 1;*/
349
 
                      printf("color %c has value %d\n",img->color[i].name,img->color[i].value);
 
353
                      fprintf(stderr,"color %c has value %d\n",img->color[i].name,img->color[i].value);
350
354
                    }
351
355
                    /* add 0x80 to colors where 0x80 is seen added in inkset */
352
356
                  }
406
410
        }
407
411
 
408
412
        /* output line */
409
 
        if((written = fwrite(line,img->width,3,fp)) != 3)
410
 
                printf("fwrite failed %u vs %u\n",written,img->width*3);
 
413
        if((written = fwrite(line,img->width,3,fp)) != 3) {
 
414
                fprintf(stderr,"fwrite failed %u vs %u\n",written,img->width*3);
 
415
        }
411
416
        free(line);
412
417
}
413
418
 
488
493
        unsigned int xml_read;
489
494
        xml_read=0;
490
495
 
491
 
        printf("------- parsing the printjob -------\n");
 
496
        fprintf(stderr,"------- parsing the printjob -------\n");
492
497
        while(!returnv && !feof(in)){
493
498
                unsigned char cmd;
494
499
                unsigned int cnt = 0;
496
501
                        break;
497
502
                switch(cmd){
498
503
                        case 'c':
499
 
                                printf("ESC (c set media (len=%i):\n",cnt);
500
 
                                printf(" model id %x bw %x",buf[0]>> 4,buf[0]&0xf);
501
 
                                printf(" media %x",buf[1]);
502
 
                                printf(" direction %x quality %x\n",(buf[2]>>4)&3 ,buf[2]&0xf);
 
504
                                fprintf(stderr,"ESC (c set media (len=%i):\n",cnt);
 
505
                                fprintf(stderr," model id %x bw %x",buf[0]>> 4,buf[0]&0xf);
 
506
                                fprintf(stderr," media %x",buf[1]);
 
507
                                fprintf(stderr," direction %x quality %x\n",(buf[2]>>4)&3 ,buf[2]&0xf);
503
508
                                break;
504
509
                        case 'K':
505
510
                                if(buf[1]==0x1f){
506
 
                                        printf("ESC [K go to command mode\n");
 
511
                                  fprintf(stderr,"ESC [K go to command mode\n");
507
512
                                        do{
508
513
                                                fgets((char*)buf,0xFFFF,in);
509
 
                                                printf(" %s",buf);
 
514
                                                fprintf(stderr," %s",buf);
510
515
                                        }while(strcmp((char*)buf,"BJLEND\n"));
511
516
                                }else if(cnt == 2 && buf[1]==0x0f){
512
 
                                        printf("ESC [K reset printer\n");
 
517
                                        fprintf(stderr,"ESC [K reset printer\n");
513
518
                                        img->width=0;
514
519
                                        img->height=0;
515
 
                                }else
516
 
                                        printf("ESC [K unsupported param (len=%i): %x\n",cnt,buf[1]);
 
520
                                }else{
 
521
                                        fprintf(stderr,"ESC [K unsupported param (len=%i): %x\n",cnt,buf[1]);
 
522
                                }
517
523
                                break;
518
524
                        case 'b':
519
 
                                printf("ESC (b set data compression (len=%i): %x\n",cnt,buf[0]);
 
525
                                fprintf(stderr,"ESC (b set data compression (len=%i): %x\n",cnt,buf[0]);
520
526
                                break;
521
527
                        case 'I':
522
 
                                printf("ESC (I select data transmission (len=%i): ",cnt);
523
 
                                if(buf[0]==0)printf("default");
524
 
                                else if(buf[0]==1)printf("multi raster");
525
 
                                else printf("unknown 0x%x %i",buf[0],buf[0]);
526
 
                                printf("\n");
 
528
                                fprintf(stderr,"ESC (I select data transmission (len=%i): ",cnt);
 
529
                                if(buf[0]==0)fprintf(stderr,"default");
 
530
                                else if(buf[0]==1)fprintf(stderr,"multi raster");
 
531
                                else fprintf(stderr,"unknown 0x%x %i",buf[0],buf[0]);
 
532
                                fprintf(stderr,"\n");
527
533
                                break;
528
534
                        case 'l':
529
 
                                printf("ESC (l select paper loading (len=%i):\n",cnt);
530
 
                                printf(" model id 0x%x ",buf[0]>>4);
531
 
                                printf(" source 0x%x",buf[0]&15);
532
 
                                printf(" media: %x",buf[1]);
533
 
                                printf(" paper gap: %x\n",buf[2]);
 
535
                                fprintf(stderr,"ESC (l select paper loading (len=%i):\n",cnt);
 
536
                                fprintf(stderr," model id 0x%x ",buf[0]>>4);
 
537
                                fprintf(stderr," source 0x%x",buf[0]&15);
 
538
                                if ( cnt == 3 ) {
 
539
                                  fprintf(stderr," media: %x",buf[1]);
 
540
                                  fprintf(stderr," paper gap: %x\n",buf[2]);
 
541
                                } else
 
542
                                  fprintf(stderr," media: %x\n",buf[1]);
534
543
                                break;
535
544
                        case 'd':
536
545
                                img->xres = (buf[0]<<8)|buf[1];
537
546
                                img->yres = (buf[2]<<8)|buf[3];
538
 
                                printf("ESC (d set raster resolution (len=%i): %i x %i\n",cnt,img->xres,img->yres);
 
547
                                fprintf(stderr,"ESC (d set raster resolution (len=%i): %i x %i\n",cnt,img->xres,img->yres);
539
548
                                break;
540
549
                        case 't':
541
 
                                printf("ESC (t set image cnt %i\n",cnt);
 
550
                          fprintf(stderr,"ESC (t set image cnt %i\n",cnt);
542
551
                                if(buf[0]>>7){
543
552
                                        /* usual order */
544
553
                                        /*char order[]="CMYKcmykHRGABDEFIJLMNOPQSTUVWXZabdef";*/
545
554
                                        /* iP3500 test */
546
 
                                        /*char order[]="CMYKcmykHRGBCMYcmykabd";*/
547
 
                                          char order[]="CMYKcmykHpnoPQRSTykabd";
 
555
                                        char order[]="CMYKcmykHRGBCMYcmykabd";
 
556
                                        /*char order[]="CMYKcmykHpnoPQRSTykabd";*/
 
557
                                        /*char order[]="KCMYkcmyHpnoPQRSTykabd";*/
548
558
                                        /* MP960 photo modes: k instead of K */
549
559
                                        /* char order[]="CMYkcmyKHRGABDEFIJLMNOPQSTUVWXZabdef";*/
550
560
                                        /* T-shirt transfer mode: y changed to k --- no y, no K */
555
565
                                        /* char order[]="KCcMmYykRHGABDEFIJLMNOPQSTUVWXZabdef"; */
556
566
                                        int black_found = 0;
557
567
                                        int num_colors = (cnt - 3)/3;
558
 
                                        printf(" bit_info: using detailed color settings for max %i colors\n",num_colors);
 
568
                                        fprintf(stderr," bit_info: using detailed color settings for max %i colors\n",num_colors);
559
569
                                        if(buf[1]==0x80)
560
 
                                                printf(" format: BJ indexed color image format\n");
 
570
                                          fprintf(stderr," format: BJ indexed color image format\n");
561
571
                                        else if(buf[1]==0x00)
562
 
                                                printf(" format: iP8500 flag set, BJ indexed color image format\n");
 
572
                                                fprintf(stderr," format: iP8500 flag set, BJ indexed color image format\n");
563
573
                                        else if(buf[1]==0x90)
564
 
                                                printf(" format: Pro9500 flag set, BJ indexed color image format\n");
 
574
                                                fprintf(stderr," format: Pro9500 flag set, BJ indexed color image format\n");
565
575
                                        else{
566
 
                                                printf(" format: settings not supported 0x%x\n",buf[1]);
 
576
                                                fprintf(stderr," format: settings not supported 0x%x\n",buf[1]);
567
577
                                                /* returnv = -2; */
568
578
                                        }
569
579
                                        if(buf[2]==0x1)
570
 
                                                printf(" ink: BJ indexed setting, also for iP8500 flag\n");
 
580
                                                fprintf(stderr," ink: BJ indexed setting, also for iP8500 flag\n");
571
581
                                        else if(buf[2]==0x4)
572
 
                                                printf(" ink: Pro series setting \n");
 
582
                                                fprintf(stderr," ink: Pro series setting \n");
573
583
                                        else{
574
 
                                                printf(" ink: settings not supported 0x%x\n",buf[2]);
 
584
                                                fprintf(stderr," ink: settings not supported 0x%x\n",buf[2]);
575
585
                                                /* returnv = -2; */
576
586
                                        }
577
587
 
605
615
                                              img->color[i].density = 128; /*128+96;*/ /* try to add 0x80 to sub-channels for MP450 hi-quality mode */
606
616
                                            if((order[i] == 'K' || order[i] == 'k') && img->color[i].bpp)
607
617
                                              black_found = 1;
 
618
                                            /*
608
619
                                            if(order[i] == 'y' && !black_found && img->color[i].level){
609
620
                                              printf("iP6700 hack: treating color definition at the y position as k\n");
610
621
                                              img->color[i].name = 'k';
612
623
                                              order[i+1] = 'y';
613
624
                                              black_found = 1;
614
625
                                              img->color[i].density = 255;
615
 
                                            } /* %c*/
616
 
                                            printf(" Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
 
626
                                            } 
 
627
                                            */
 
628
                                            /* %c*/
 
629
                                            fprintf(stderr," Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
617
630
                                                   img->color[i].compression,img->color[i].bpp,img->color[i].level);
618
631
                                          }else{
619
 
                                            printf(" Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
 
632
                                            fprintf(stderr," Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
620
633
                                                   img->color[i].compression,img->color[i].bpp,img->color[i].level);
621
634
                                            /*printf(" Color ignoring setting %x %x %x\n",buf[3+i*3],buf[3+i*3+1],buf[3+i*3+2]);*/
622
635
                                          }
625
638
                                        
626
639
                                        
627
640
                                }else if(buf[0]==0x1 && buf[1]==0x0 && buf[2]==0x1){
628
 
                                        printf(" 1bit-per pixel\n");
 
641
                                        fprintf(stderr," 1bit-per pixel\n");
629
642
                                        int num_colors = cnt*3; /*no idea yet! 3 for iP4000 */
630
643
                                        /*num_colors=9;*/
631
644
                                        /*for(i=0;i<MAX_COLORS;i++){*/
643
656
                                                img->color[i].level=2;
644
657
                                                img->color[i].density = 255;
645
658
                                                /*add color printout for this type also %c */
646
 
                                                printf(" Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
 
659
                                                fprintf(stderr," Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
647
660
                                                       img->color[i].compression,img->color[i].bpp,img->color[i].level);
648
661
                                          }else{
649
 
                                            printf(" Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
 
662
                                            fprintf(stderr," Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
650
663
                                                       img->color[i].compression,img->color[i].bpp,img->color[i].level);
651
664
                                                /*printf(" Color ignoring setting %x %x %x\n",buf[3+i*3],buf[3+i*3+1],buf[3+i*3+2]);*/
652
665
                                          }
653
666
                                        }
654
667
                                }else{
655
 
                                        printf(" bit_info: unknown settings 0x%x 0x%x 0x%x\n",buf[0],buf[1],buf[2]);
 
668
                                        fprintf(stderr," bit_info: unknown settings 0x%x 0x%x 0x%x\n",buf[0],buf[1],buf[2]);
656
669
                                        /* returnv=-2; */
657
670
                                }
658
671
                                break;
659
672
                        case 'L':
660
 
                                printf("ESC (L set component order for F raster command (len=%i): ",cnt);
 
673
                                fprintf(stderr,"ESC (L set component order for F raster command (len=%i): ",cnt);
661
674
                                img->color_order=calloc(1,cnt+1);
662
675
                                /* check if the colors are sane => the iP4000 driver appends invalid bytes in the highest resolution mode */
663
676
                                for(i=0;i<cnt;i++){
669
682
                                    /*}*/
670
683
                                    /*else {*/
671
684
                                      buf[i]=buf[i]-0x60;
672
 
                                      printf("subtracting 0x60 to give [corrected]: %c\n", buf[i]);
 
685
                                      fprintf(stderr,"subtracting 0x60 to give [corrected]: %c\n", buf[i]);
673
686
                                    }
674
687
                                  else
675
 
                                    printf("found valid color char: %c\n",buf[i]);
 
688
                                    fprintf(stderr,"found valid color char: %c\n",buf[i]);
676
689
                                }
677
690
                                cnt = i;
678
691
                                memcpy(img->color_order,buf,cnt);
679
 
                                printf("%s\n",img->color_order);
 
692
                                fprintf(stderr,"%s\n",img->color_order);
680
693
                                img->num_colors = cnt;
681
694
                                img->cur_color=0;
682
695
                                break;
683
696
                        case 'p':
684
 
                                printf("ESC (p set extended margin (len=%i):\n",cnt);
685
 
                                printf(" printed length %i left %i\n",((buf[0]<<8 )+buf[1]) *6 / 5,(buf[2]<<8) + buf[3]);
686
 
                                printf(" printed width %i top %i\n",((buf[4]<<8 )+buf[5]) * 6 / 5,(buf[6]<<8) + buf[7]);
 
697
                                fprintf(stderr,"ESC (p set extended margin (len=%i):\n",cnt);
 
698
                                fprintf(stderr," printed length %i left %i\n",((buf[0]<<8 )+buf[1]) *6 / 5,(buf[2]<<8) + buf[3]);
 
699
                                fprintf(stderr," printed width %i top %i\n",((buf[4]<<8 )+buf[5]) * 6 / 5,(buf[6]<<8) + buf[7]);
687
700
 
688
701
                                if(cnt > 8){
689
702
                                        int unit = (buf[12] << 8)| buf[13];
695
708
                                        int paper_top = read_uint32(buf+34);
696
709
                                        unsigned int paper_width = read_uint32(buf+38);
697
710
                                        unsigned int paper_length = read_uint32(buf+42);
698
 
                                        printf(" unknown %i\n",read_uint32(buf+8));
699
 
                                        printf(" unit %i [1/in]\n",unit);
700
 
                                        printf(" area_right %i %.1f mm\n",area_right,area_right * 25.4 / unit);
701
 
                                        printf(" area_top %i %.1f mm\n",area_top,area_top * 25.4 / unit);
702
 
                                        printf(" area_width %u %.1f mm\n",area_width, area_width * 25.4 / unit);
703
 
                                        printf(" area_length %u %.1f mm\n",area_length,area_length * 25.4 / unit);
704
 
                                        printf(" paper_right %i %.1f mm\n",paper_right,paper_right * 25.4 / unit);
705
 
                                        printf(" paper_top %i %.1f mm\n",paper_top,paper_top * 25.4 / unit);
706
 
                                        printf(" paper_width %u %.1f mm\n",paper_width,paper_width * 25.4 / unit);
707
 
                                        printf(" paper_length %u %.1f mm\n",paper_length,paper_length * 25.4 / unit);
 
711
                                        fprintf(stderr," unknown %i\n",read_uint32(buf+8));
 
712
                                        fprintf(stderr," unit %i [1/in]\n",unit);
 
713
                                        fprintf(stderr," area_right %i %.1f mm\n",area_right,area_right * 25.4 / unit);
 
714
                                        fprintf(stderr," area_top %i %.1f mm\n",area_top,area_top * 25.4 / unit);
 
715
                                        fprintf(stderr," area_width %u %.1f mm\n",area_width, area_width * 25.4 / unit);
 
716
                                        fprintf(stderr," area_length %u %.1f mm\n",area_length,area_length * 25.4 / unit);
 
717
                                        fprintf(stderr," paper_right %i %.1f mm\n",paper_right,paper_right * 25.4 / unit);
 
718
                                        fprintf(stderr," paper_top %i %.1f mm\n",paper_top,paper_top * 25.4 / unit);
 
719
                                        fprintf(stderr," paper_width %u %.1f mm\n",paper_width,paper_width * 25.4 / unit);
 
720
                                        fprintf(stderr," paper_length %u %.1f mm\n",paper_length,paper_length * 25.4 / unit);
708
721
                                        img->top = (float)area_top / unit;
709
722
                                        img->left = (float)area_top / unit;
710
723
                                }
711
724
                                break;
712
725
                        case '$':
713
 
                                printf("ESC ($ set duplex (len=%i)\n",cnt);
 
726
                                fprintf(stderr,"ESC ($ set duplex (len=%i)\n",cnt);
714
727
                                break;
715
728
                        case 'J':
716
 
                                printf("ESC (J select number of raster lines per block (len=%i): %i\n",cnt,buf[0]);
 
729
                                fprintf(stderr,"ESC (J select number of raster lines per block (len=%i): %i\n",cnt,buf[0]);
717
730
                                img->lines_per_block=buf[0];
718
731
                                break;
719
732
                        case 'F':
720
733
                                if(verbose)
721
 
                                        printf("ESC (F raster block (len=%i):\n",cnt);
 
734
                                        fprintf(stderr,"ESC (F raster block (len=%i):\n",cnt);
722
735
                                if((returnv = Raster(img,buf,cnt,img->color_order[img->cur_color],maxw)))
723
736
                                        break;
724
737
                                ++img->cur_color;
728
741
                                }
729
742
                                break;
730
743
                        case 'q':
731
 
                                printf("ESC (q set page id (len=%i):%i\n",cnt,buf[0]);
 
744
                                fprintf(stderr,"ESC (q set page id (len=%i):%i\n",cnt,buf[0]);
732
745
                                break;
733
746
                        case 'r':
734
 
                                printf("ESC (r printer specific command (len=%i): ",cnt);
 
747
                                fprintf(stderr,"ESC (r printer specific command (len=%i): ",cnt);
735
748
                                for(i=0;i<cnt;i++)
736
 
                                        printf("0x%x ",buf[i]);
737
 
                                printf("\n");
 
749
                                        fprintf(stderr,"0x%x ",buf[i]);
 
750
                                fprintf(stderr,"\n");
738
751
                                break;
739
752
                        case 'A':
740
753
                                if(verbose)
741
 
                                        printf("ESC (A raster line (len=%i): color %c\n",cnt,buf[0]);
 
754
                                        fprintf(stderr,"ESC (A raster line (len=%i): color %c\n",cnt,buf[0]);
742
755
                                /* the single line rasters are not terminated by 0x80 => do it here
743
756
                                 * instead of 0x80 every raster A command is followed by a 0x0d byte
744
757
                                 * the selected color is stored in the first byte
746
759
                                buf[cnt]=0x80;
747
760
                                returnv = Raster(img,buf+1,cnt,buf[0],maxw);
748
761
                                if (fgetc(in)!=0x0d){
749
 
                                        printf("Raster A not terminated by 0x0d\n");
 
762
                                        fprintf(stderr,"Raster A not terminated by 0x0d\n");
750
763
                                        returnv=-4;
751
764
                                }
752
765
                                break;
753
766
                        case 'e': /* Raster skip */
754
767
                                if(verbose)
755
 
                                        printf("ESC (e advance (len=%i): %i\n",cnt,buf[0]*256+buf[1]);
 
768
                                        fprintf(stderr,"ESC (e advance (len=%i): %i\n",cnt,buf[0]*256+buf[1]);
756
769
                                if(img->lines_per_block){
757
770
                                        img->height += (buf[0]*256+buf[1])*img->lines_per_block;
758
771
                                        img->cur_color=0;
760
773
                                        img->height += (buf[0]*256+buf[1]);
761
774
                                break;
762
775
                        default: /* Last but not least completely unknown commands */
763
 
                                printf("ESC (%c UNKNOWN (len=%i)\n",cmd,cnt);
 
776
                                fprintf(stderr,"ESC (%c UNKNOWN (len=%i)\n",cmd,cnt);
764
777
                                for(i=0;i<cnt;i++)
765
 
                                        printf(" 0x%x",buf[i]);
766
 
                                printf("\n");
 
778
                                        fprintf(stderr," 0x%x",buf[i]);
 
779
                                fprintf(stderr,"\n");
767
780
 
768
781
                }
769
782
        }
770
783
 
771
 
        printf("-------- finished parsing   --------\n");
 
784
        fprintf(stderr,"-------- finished parsing   --------\n");
772
785
        if(returnv < -2){ /* was < 0 :  work around to see what we get */
773
 
                printf("error: parsing the printjob failed error %i\n",returnv);
 
786
                fprintf(stderr,"error: parsing the printjob failed error %i\n",returnv);
774
787
        } else {
775
788
        
776
 
                printf("created bit image with width %i height %i\n",img->width,img->height);
 
789
                fprintf(stderr,"created bit image with width %i height %i\n",img->width,img->height);
777
790
                if(maxh > 0){
778
 
                        printf("limiting height to %u\n",maxh);
 
791
                        fprintf(stderr,"limiting height to %u\n",maxh);
779
792
                        img->height=maxh;
780
793
                }
781
794
 
784
797
                */
785
798
                if(out)
786
799
                        write_ppm(img,out);
787
 
                printf("dots: %u\n",img->dots);
 
800
                fprintf(stderr,"dots: %u\n",img->dots);
788
801
 
789
802
        }
790
803
        /* deallocate resources */
826
839
        char* filename_in=NULL,*filename_out=NULL;
827
840
        FILE *in,*out=NULL;
828
841
        int i;
829
 
        printf("pixma_parse - parser for Canon BJL printjobs (c) 2005-2007 Sascha Sommer <saschasommer@freenet.de>\n");
 
842
        printf("pixma_parse - parser for Canon BJL printjobs (c) 2005-2007 Sascha Sommer <saschasommer@freenet.de>\nPlease note parse output now goes to stderr.\n");
830
843
 
831
844
        /* parse args */
832
845
        for(i=1;i<argc;i++){
853
866
                                        return 1;
854
867
                                }
855
868
                        }else {
856
 
                                printf("unknown parameter %s\n",argv[i]);
 
869
                          printf("unknown parameter %s\n",argv[i]);
857
870
                                return 1;
858
871
                        }
859
872
                }else if(!filename_in){
872
885
 
873
886
        /* open input file */
874
887
        if(!(in=fopen(filename_in,"rb"))){
875
 
                printf("unable to open input file %s\n",filename_in);
 
888
          printf("unable to open input file %s\n",filename_in);
876
889
                return 1;
877
890
        }
878
891
 
879
892
        /* open output file */
880
893
        if(filename_out && !(out=fopen(filename_out,"wb"))){
881
 
                printf("can't create the output file %s\n",filename_out);
 
894
          printf("can't create the output file %s\n",filename_out);
882
895
                fclose(in);
883
896
                return 1;
884
897
        }