]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testlang.c
cc7b4f699e8191a56832af8d02ce92bd9e65562d
4 * Localization test program for CUPS.
6 * Copyright 2007-2015 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Load the specified language and show the strings for yes and no.
23 * Include necessary headers...
26 #include "cups-private.h"
27 #include "ppd-private.h"
31 * 'main()' - Load the specified language and show the strings for yes and no.
34 int /* O - Exit status */
35 main(int argc
, /* I - Number of command-line arguments */
36 char *argv
[]) /* I - Command-line arguments */
38 int i
; /* Looping var */
39 int errors
= 0; /* Number of errors */
40 cups_lang_t
*language
; /* Message catalog */
41 cups_lang_t
*language2
; /* Message catalog */
42 struct lconv
*loc
; /* Locale data */
43 char buffer
[1024]; /* String buffer */
44 double number
; /* Number */
45 static const char * const tests
[] = /* Test strings */
56 language
= cupsLangDefault();
57 language2
= cupsLangDefault();
61 language
= cupsLangGet(argv
[1]);
62 language2
= cupsLangGet(argv
[1]);
64 setenv("LANG", argv
[1], 1);
65 setenv("SOFTWARE", "CUPS/" CUPS_SVERSION
, 1);
70 if (language
!= language2
)
74 puts("**** ERROR: Language cache did not work! ****");
75 puts("First result from cupsLangGet:");
78 printf("Language = \"%s\"\n", language
->language
);
79 printf("Encoding = \"%s\"\n", _cupsEncodingName(language
->encoding
));
80 printf("No = \"%s\"\n", _cupsLangString(language
, "No"));
81 printf("Yes = \"%s\"\n", _cupsLangString(language
, "Yes"));
83 if (language
!= language2
)
85 puts("Second result from cupsLangGet:");
87 printf("Language = \"%s\"\n", language2
->language
);
88 printf("Encoding = \"%s\"\n", _cupsEncodingName(language2
->encoding
));
89 printf("No = \"%s\"\n", _cupsLangString(language2
, "No"));
90 printf("Yes = \"%s\"\n", _cupsLangString(language2
, "Yes"));
95 for (i
= 0; i
< (int)(sizeof(tests
) / sizeof(tests
[0])); i
++)
97 number
= _cupsStrScand(tests
[i
], NULL
, loc
);
99 printf("_cupsStrScand(\"%s\") number=%f\n", tests
[i
], number
);
101 _cupsStrFormatd(buffer
, buffer
+ sizeof(buffer
), number
, loc
);
103 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number
, buffer
);
105 if (strcmp(buffer
, tests
[i
]))
108 puts("**** ERROR: Bad formatted number! ****");
114 ppd_file_t
*ppd
; /* PPD file */
115 ppd_option_t
*option
; /* PageSize option */
116 ppd_choice_t
*choice
; /* PageSize/Letter choice */
118 if ((ppd
= ppdOpenFile(argv
[2])) == NULL
)
120 printf("Unable to open PPD file \"%s\".\n", argv
[2]);
127 if ((option
= ppdFindOption(ppd
, "PageSize")) == NULL
)
129 puts("No PageSize option.");
134 printf("PageSize: %s\n", option
->text
);
136 if ((choice
= ppdFindChoice(option
, "Letter")) == NULL
)
138 puts("No Letter PageSize choice.");
143 printf("Letter: %s\n", choice
->text
);