]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testlang.c
6f0691e00841a44587eb76b9a10472f2ef01a50e
2 * Localization test program for CUPS.
4 * Copyright 2007-2015 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
17 * Include necessary headers...
20 #include "cups-private.h"
21 #include "ppd-private.h"
25 * 'main()' - Load the specified language and show the strings for yes and no.
28 int /* O - Exit status */
29 main(int argc
, /* I - Number of command-line arguments */
30 char *argv
[]) /* I - Command-line arguments */
32 int i
; /* Looping var */
33 int errors
= 0; /* Number of errors */
34 cups_lang_t
*language
; /* Message catalog */
35 cups_lang_t
*language2
; /* Message catalog */
36 struct lconv
*loc
; /* Locale data */
37 char buffer
[1024]; /* String buffer */
38 double number
; /* Number */
39 static const char * const tests
[] = /* Test strings */
50 language
= cupsLangDefault();
51 language2
= cupsLangDefault();
55 language
= cupsLangGet(argv
[1]);
56 language2
= cupsLangGet(argv
[1]);
58 setenv("LANG", argv
[1], 1);
59 setenv("SOFTWARE", "CUPS/" CUPS_SVERSION
, 1);
64 if (language
!= language2
)
68 puts("**** ERROR: Language cache did not work! ****");
69 puts("First result from cupsLangGet:");
72 printf("Language = \"%s\"\n", language
->language
);
73 printf("Encoding = \"%s\"\n", _cupsEncodingName(language
->encoding
));
74 printf("No = \"%s\"\n", _cupsLangString(language
, "No"));
75 printf("Yes = \"%s\"\n", _cupsLangString(language
, "Yes"));
77 if (language
!= language2
)
79 puts("Second result from cupsLangGet:");
81 printf("Language = \"%s\"\n", language2
->language
);
82 printf("Encoding = \"%s\"\n", _cupsEncodingName(language2
->encoding
));
83 printf("No = \"%s\"\n", _cupsLangString(language2
, "No"));
84 printf("Yes = \"%s\"\n", _cupsLangString(language2
, "Yes"));
89 for (i
= 0; i
< (int)(sizeof(tests
) / sizeof(tests
[0])); i
++)
91 number
= _cupsStrScand(tests
[i
], NULL
, loc
);
93 printf("_cupsStrScand(\"%s\") number=%f\n", tests
[i
], number
);
95 _cupsStrFormatd(buffer
, buffer
+ sizeof(buffer
), number
, loc
);
97 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number
, buffer
);
99 if (strcmp(buffer
, tests
[i
]))
102 puts("**** ERROR: Bad formatted number! ****");
108 ppd_file_t
*ppd
; /* PPD file */
109 ppd_option_t
*option
; /* PageSize option */
110 ppd_choice_t
*choice
; /* PageSize/Letter choice */
112 if ((ppd
= ppdOpenFile(argv
[2])) == NULL
)
114 printf("Unable to open PPD file \"%s\".\n", argv
[2]);
121 if ((option
= ppdFindOption(ppd
, "PageSize")) == NULL
)
123 puts("No PageSize option.");
128 printf("PageSize: %s\n", option
->text
);
130 if ((choice
= ppdFindChoice(option
, "Letter")) == NULL
)
132 puts("No Letter PageSize choice.");
137 printf("Letter: %s\n", choice
->text
);