~ubuntu-branches/ubuntu/quantal/foo2zjs/quantal

« back to all changes in this revision

Viewing changes to foo2xqx.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-28 00:35:00 UTC
  • mfrom: (1.2.7 upstream) (3.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110728003500-qntxlz7lb03by46o
Tags: 20110722dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Depends on the mscompress package.
  - Depends on cup and cups-client and does not only recommend them. Ubuntu
    supports only CUPS as printing system (more investigation needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
*/
50
50
 
51
 
static char Version[] = "$Id: foo2xqx.c,v 1.24 2010/06/19 21:40:00 rick Exp $";
 
51
static char Version[] = "$Id: foo2xqx.c,v 1.25 2011/06/09 13:50:09 rick Exp $";
52
52
 
53
53
#include <stdio.h>
54
54
#include <stdlib.h>
336
336
    chunk.type = be32(type);
337
337
    chunk.items = be32(items);
338
338
    rc = fwrite(&chunk, 1, sizeof(XQX_HEADER), fp);
 
339
    if (rc == 0) error(1, "fwrite(1): rc == 0!\n");
339
340
}
340
341
 
341
342
static void
348
349
    item_uint32.header.size = be32(sizeof(DWORD));
349
350
    item_uint32.value = be32(value);
350
351
    rc = fwrite(&item_uint32, 1, sizeof(XQX_ITEM_UINT32), fp);
 
352
    if (rc == 0) error(1, "fwrite(2): rc == 0!\n");
351
353
}
352
354
 
353
355
static void
359
361
    header.type = be32(item);
360
362
    header.size = be32(len);
361
363
    rc = fwrite(&header, 1, sizeof(XQX_ITEM_HEADER), fp);
 
364
    if (rc == 0) error(1, "fwrite(3): rc == 0!\n");
362
365
    rc = fwrite(buf, 1, len, fp);
 
366
    if (rc == 0) error(1, "fwrite(4): rc == 0!\n");
363
367
}
364
368
 
365
369
/*
389
393
write_plane(int planeNum, BIE_CHAIN **root, FILE *fp)
390
394
{
391
395
    BIE_CHAIN   *current = *root;
392
 
    BIE_CHAIN   *next;
 
396
    //BIE_CHAIN *next;
393
397
    int         len;
394
398
    int         first;
395
399
    BYTE        *bih;
415
419
        else
416
420
        {
417
421
            len = current->len;
418
 
            next = current->next;
 
422
            //next = current->next;
419
423
 
420
424
            chunk_write(XQX_START_PLANE, 4, fp);
421
425
            item_uint32_write(0x80000000, first ? 64 : 48, fp);
427
431
            item_uint32_write(XQXI_END, 0xdeadbeef, fp);
428
432
 
429
433
            chunk_write(XQX_JBIG, len, fp);
430
 
            rc = fwrite(current->data, 1, len, fp);
 
434
            if (len)
 
435
            {
 
436
                rc = fwrite(current->data, 1, len, fp);
 
437
                if (rc == 0) error(1, "fwrite(5): rc == 0!\n");
 
438
            }
431
439
 
432
440
            chunk_write(XQX_END_PLANE, 0, fp);
433
441
            first = 0;
604
612
    time_t      now;
605
613
    struct tm   *tmp;
606
614
    char        datetime[14+1];
607
 
    int         rc;
608
615
 
609
616
    now = time(NULL);
610
617
    tmp = localtime(&now);
623
630
    fprintf(fp, "@PJL SET JOBATTR=\"JobAttr4=%s\"", datetime);
624
631
    fputc(0, fp);
625
632
    fprintf(fp, "\033%%-12345X");
626
 
    rc = fwrite(header, 1, sizeof(header), fp);
 
633
    fwrite(header, 1, sizeof(header), fp);
627
634
 
628
635
    nitems = 7;
629
636
 
760
767
        {
761
768
            FILE *dfp;
762
769
            char fname[256];
763
 
            int rc;
 
770
 
764
771
            sprintf(fname, "xxxplane%d", i);
765
772
            dfp = fopen(fname, "w");
766
773
            if (dfp)
767
774
            {
768
 
                rc = fwrite(plane[i], bpl*h, 1, dfp);
 
775
                fwrite(plane[i], bpl*h, 1, dfp);
769
776
                fclose(dfp);
770
777
            }
771
778
        }
1011
1018
getint(FILE *fp)
1012
1019
{
1013
1020
    int c;
1014
 
    unsigned long i;
 
1021
    unsigned long i = 0;
1015
1022
    int rc;
1016
1023
 
1017
1024
    while ((c = getc(fp)) != EOF && !isdigit(c))
1021
1028
    {
1022
1029
        ungetc(c, fp);
1023
1030
        rc = fscanf(fp, "%lu", &i);
 
1031
        if (rc != 1) error(1, "fscanf: rc == 0!\n");
1024
1032
    }
1025
1033
    return i;
1026
1034
}
1139
1147
            {
1140
1148
                FILE *dfp;
1141
1149
                char fname[256];
1142
 
                int rc;
 
1150
 
1143
1151
                sprintf(fname, "xxxplane%d", i);
1144
1152
                dfp = fopen(fname, "w");
1145
1153
                if (dfp)
1146
1154
                {
1147
 
                    rc = fwrite(plane[i], bpl*h, 1, dfp);
 
1155
                    fwrite(plane[i], bpl*h, 1, dfp);
1148
1156
                    fclose(dfp);
1149
1157
                }
1150
1158
            }
1490
1498
            else
1491
1499
                pause = be32(3);
1492
1500
            rc = fwrite(&pause, 1, sizeof(DWORD), EvenPages);
 
1501
            if (rc == 0) error(1, "fwrite(10): rc == 0!\n");
1493
1502
 
1494
1503
            fseek(EvenPages, SeekRec[i].b, 0L);
1495
1504
            for (j = 0; j < (SeekRec[i].e - SeekRec[i].b); ++j)