]>
git.ipfire.org Git - thirdparty/cups.git/blob - examples/testppdx.c
2 * "$Id: testppdx.c 3833 2012-05-23 22:51:18Z msweet $"
4 * Test program for PPD data encoding example code.
8 * gcc -o testppdx -D_PPD_DEPRECATED="" -g testppdx.c ppdx.c -lcups -lz
10 * Copyright 2012 by Apple Inc.
12 * These coded instructions, statements, and computer programs are the
13 * property of Apple Inc. and are protected by Federal copyright
14 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
15 * which should have been included with this file. If this file is
16 * file is missing or damaged, see the license at "http://www.cups.org/".
18 * This file is subject to the Apple OS-Developed Software exception.
22 * main() - Read data from a test PPD file and write out new chunks.
26 * Include necessary headers...
35 * 'main()' - Read data from a test PPD file and write out new chunks.
38 int /* O - Exit status */
41 int status
= 0; /* Exit status */
42 FILE *fp
; /* File to read */
43 char contents
[8193], /* Contents of file */
44 *data
; /* Data from PPD */
45 size_t contsize
, /* File size */
46 datasize
; /* Data size */
47 ppd_file_t
*ppd
; /* Test PPD */
51 * Open the PPD and get the data from it...
54 ppd
= ppdOpenFile("testppdx.ppd");
55 data
= ppdxReadData(ppd
, "EXData", &datasize
);
58 * Open this source file and read it...
61 fp
= fopen("testppdx.c", "r");
64 contsize
= fread(contents
, 1, sizeof(contents
) - 1, fp
);
66 contents
[contsize
] = '\0';
80 if (contsize
!= datasize
)
82 fprintf(stderr
, "ERROR: PPD has %ld bytes, test file is %ld bytes.\n",
83 (long)datasize
, (long)contsize
);
86 else if (strcmp(contents
, data
))
88 fputs("ERROR: PPD and test file are not the same.\n", stderr
);
94 if ((fp
= fopen("testppdx.dat", "wb")) != NULL
)
96 fwrite(data
, 1, datasize
, fp
);
98 fputs("ERROR: See testppdx.dat for data from PPD.\n", stderr
);
101 perror("Unable to open 'testppdx.dat'");
107 printf("Encoding %ld bytes for PPD...\n", (long)contsize
);
109 ppdxWriteData("EXData", contents
, contsize
);
116 * End of "$Id: testppdx.c 3833 2012-05-23 22:51:18Z msweet $".