]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testpwg.c
4 * PWG test program for CUPS.
6 * Copyright 2009-2010 by Apple Inc.
8 * These coded instructions, statements, and computer programs are the
9 * property of Apple Inc. and are protected by Federal copyright
10 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
11 * which should have been included with this file. If this file is
12 * file is missing or damaged, see the license at "http://www.cups.org/".
14 * This file is subject to the Apple OS-Developed Software exception.
18 * main() - Main entry.
19 * test_pwg() - Test the PWG mapping functions.
23 * Include necessary headers...
26 #include "pwg-private.h"
33 static int test_pwg(_pwg_t
*pwg
);
37 * 'main()' - Main entry.
40 int /* O - Exit status */
41 main(int argc
, /* I - Number of command-line args */
42 char *argv
[]) /* I - Command-line arguments */
44 int status
; /* Status of tests (0 = success, 1 = fail) */
45 const char *ppdfile
; /* PPD filename */
46 ppd_file_t
*ppd
; /* PPD file */
47 _pwg_t
*pwg
; /* PWG mapping data */
48 _pwg_media_t
*pwgmedia
; /* PWG media size */
55 puts("Usage: ./testpwg filename.ppd");
61 printf("ppdOpenFile(%s): ", ppdfile
);
62 if ((ppd
= ppdOpenFile(ppdfile
)) == NULL
)
64 ppd_status_t err
; /* Last error in file */
65 int line
; /* Line number in file */
68 err
= ppdLastError(&line
);
70 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
77 fputs("_pwgCreateWithPPD(ppd): ", stdout
);
78 if ((pwg
= _pwgCreateWithPPD(ppd
)) == NULL
)
86 status
+= test_pwg(pwg
);
89 * _pwgDestroy should never fail...
92 fputs("_pwgDestroy(pwg): ", stdout
);
97 fputs("_pwgMediaForSize(29700, 42000): ", stdout
);
98 if ((pwgmedia
= _pwgMediaForSize(29700, 42000)) == NULL
)
100 puts("FAIL (not found)");
103 else if (strcmp(pwgmedia
->pwg
, "iso_a3_297x420mm"))
105 printf("FAIL (%s)\n", pwgmedia
->pwg
);
116 * 'test_pwg()' - Test the PWG mapping functions.
119 static int /* O - 1 on failure, 0 on success */
120 test_pwg(_pwg_t
*pwg
) /* I - PWG mapping data */
122 int i
, /* Looping var */
123 status
= 0; /* Return status */
124 _pwg_t
*pwg2
; /* Loaded data */
125 _pwg_size_t
*size
, /* Size from original */
126 *size2
; /* Size from saved */
127 _pwg_map_t
*map
, /* Map from original */
128 *map2
; /* Map from saved */
132 * Verify that we can write and read back the same data...
135 fputs("_pwgWriteFile(test.pwg): ", stdout
);
136 if (!_pwgWriteFile(pwg
, "test.pwg"))
144 fputs("_pwgCreateWithFile(test.pwg): ", stdout
);
145 if ((pwg2
= _pwgCreateWithFile("test.pwg")) == NULL
)
152 if (pwg2
->num_sizes
!= pwg
->num_sizes
)
157 printf(" SAVED num_sizes=%d, ORIG num_sizes=%d\n", pwg2
->num_sizes
,
164 for (i
= pwg
->num_sizes
, size
= pwg
->sizes
, size2
= pwg2
->sizes
;
166 i
--, size
++, size2
++)
168 if (strcmp(size2
->map
.pwg
, size
->map
.pwg
) ||
169 strcmp(size2
->map
.ppd
, size
->map
.ppd
) ||
170 size2
->width
!= size
->width
||
171 size2
->length
!= size
->length
||
172 size2
->left
!= size
->left
||
173 size2
->bottom
!= size
->bottom
||
174 size2
->right
!= size
->right
||
175 size2
->top
!= size
->top
)
180 if (strcmp(size
->map
.pwg
, size2
->map
.pwg
))
181 printf(" SAVED size->map.pwg=\"%s\", ORIG "
182 "size->map.pwg=\"%s\"\n", size2
->map
.pwg
, size
->map
.pwg
);
184 if (strcmp(size2
->map
.ppd
, size
->map
.ppd
))
185 printf(" SAVED size->map.ppd=\"%s\", ORIG "
186 "size->map.ppd=\"%s\"\n", size2
->map
.ppd
, size
->map
.ppd
);
188 if (size2
->width
!= size
->width
)
189 printf(" SAVED size->width=%d, ORIG size->width=%d\n",
190 size2
->width
, size
->width
);
192 if (size2
->length
!= size
->length
)
193 printf(" SAVED size->length=%d, ORIG size->length=%d\n",
194 size2
->length
, size
->length
);
196 if (size2
->left
!= size
->left
)
197 printf(" SAVED size->left=%d, ORIG size->left=%d\n",
198 size2
->left
, size
->left
);
200 if (size2
->bottom
!= size
->bottom
)
201 printf(" SAVED size->bottom=%d, ORIG size->bottom=%d\n",
202 size2
->bottom
, size
->bottom
);
204 if (size2
->right
!= size
->right
)
205 printf(" SAVED size->right=%d, ORIG size->right=%d\n",
206 size2
->right
, size
->right
);
208 if (size2
->top
!= size
->top
)
209 printf(" SAVED size->top=%d, ORIG size->top=%d\n",
210 size2
->top
, size
->top
);
217 for (i
= pwg
->num_sources
, map
= pwg
->sources
, map2
= pwg2
->sources
;
219 i
--, map
++, map2
++)
221 if (strcmp(map2
->pwg
, map
->pwg
) ||
222 strcmp(map2
->ppd
, map
->ppd
))
227 if (strcmp(map
->pwg
, map2
->pwg
))
228 printf(" SAVED source->pwg=\"%s\", ORIG source->pwg=\"%s\"\n",
229 map2
->pwg
, map
->pwg
);
231 if (strcmp(map2
->ppd
, map
->ppd
))
232 printf(" SAVED source->ppd=\"%s\", ORIG source->ppd=\"%s\"\n",
233 map2
->ppd
, map
->ppd
);
240 for (i
= pwg
->num_types
, map
= pwg
->types
, map2
= pwg2
->types
;
242 i
--, map
++, map2
++)
244 if (strcmp(map2
->pwg
, map
->pwg
) ||
245 strcmp(map2
->ppd
, map
->ppd
))
250 if (strcmp(map
->pwg
, map2
->pwg
))
251 printf(" SAVED type->pwg=\"%s\", ORIG type->pwg=\"%s\"\n",
252 map2
->pwg
, map
->pwg
);
254 if (strcmp(map2
->ppd
, map
->ppd
))
255 printf(" SAVED type->ppd=\"%s\", ORIG type->ppd=\"%s\"\n",
256 map2
->ppd
, map
->ppd
);