]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testlang.c
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"
30 * 'main()' - Load the specified language and show the strings for yes and no.
33 int /* O - Exit status */
34 main(int argc
, /* I - Number of command-line arguments */
35 char *argv
[]) /* I - Command-line arguments */
37 int i
; /* Looping var */
38 int errors
= 0; /* Number of errors */
39 cups_lang_t
*language
; /* Message catalog */
40 cups_lang_t
*language2
; /* Message catalog */
41 struct lconv
*loc
; /* Locale data */
42 char buffer
[1024]; /* String buffer */
43 double number
; /* Number */
44 static const char * const tests
[] = /* Test strings */
55 language
= cupsLangDefault();
56 language2
= cupsLangDefault();
60 language
= cupsLangGet(argv
[1]);
61 language2
= cupsLangGet(argv
[1]);
63 setenv("LANG", argv
[1], 1);
64 setenv("SOFTWARE", "CUPS/" CUPS_SVERSION
, 1);
69 if (language
!= language2
)
73 puts("**** ERROR: Language cache did not work! ****");
74 puts("First result from cupsLangGet:");
77 printf("Language = \"%s\"\n", language
->language
);
78 printf("Encoding = \"%s\"\n", _cupsEncodingName(language
->encoding
));
79 printf("No = \"%s\"\n", _cupsLangString(language
, "No"));
80 printf("Yes = \"%s\"\n", _cupsLangString(language
, "Yes"));
82 if (language
!= language2
)
84 puts("Second result from cupsLangGet:");
86 printf("Language = \"%s\"\n", language2
->language
);
87 printf("Encoding = \"%s\"\n", _cupsEncodingName(language2
->encoding
));
88 printf("No = \"%s\"\n", _cupsLangString(language2
, "No"));
89 printf("Yes = \"%s\"\n", _cupsLangString(language2
, "Yes"));
94 for (i
= 0; i
< (int)(sizeof(tests
) / sizeof(tests
[0])); i
++)
96 number
= _cupsStrScand(tests
[i
], NULL
, loc
);
98 printf("_cupsStrScand(\"%s\") number=%f\n", tests
[i
], number
);
100 _cupsStrFormatd(buffer
, buffer
+ sizeof(buffer
), number
, loc
);
102 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number
, buffer
);
104 if (strcmp(buffer
, tests
[i
]))
107 puts("**** ERROR: Bad formatted number! ****");
113 ppd_file_t
*ppd
; /* PPD file */
114 ppd_option_t
*option
; /* PageSize option */
115 ppd_choice_t
*choice
; /* PageSize/Letter choice */
117 if ((ppd
= ppdOpenFile(argv
[2])) == NULL
)
119 printf("Unable to open PPD file \"%s\".\n", argv
[2]);
126 if ((option
= ppdFindOption(ppd
, "PageSize")) == NULL
)
128 puts("No PageSize option.");
133 printf("PageSize: %s\n", option
->text
);
135 if ((choice
= ppdFindChoice(option
, "Letter")) == NULL
)
137 puts("No Letter PageSize choice.");
142 printf("Letter: %s\n", choice
->text
);