]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
f2d18633 | 2 | * "$Id$" |
ef416fc2 | 3 | * |
71e16022 | 4 | * Localization test program for CUPS. |
ef416fc2 | 5 | * |
36474350 | 6 | * Copyright 2007-2015 by Apple Inc. |
ef416fc2 | 7 | * Copyright 1997-2006 by Easy Software Products. |
8 | * | |
9 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 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/". | |
ef416fc2 | 14 | * |
15 | * This file is subject to the Apple OS-Developed Software exception. | |
16 | * | |
17 | * Contents: | |
18 | * | |
19 | * main() - Load the specified language and show the strings for yes and no. | |
20 | */ | |
21 | ||
22 | /* | |
23 | * Include necessary headers... | |
24 | */ | |
25 | ||
71e16022 | 26 | #include "cups-private.h" |
ef416fc2 | 27 | |
28 | ||
29 | /* | |
30 | * 'main()' - Load the specified language and show the strings for yes and no. | |
31 | */ | |
32 | ||
33 | int /* O - Exit status */ | |
34 | main(int argc, /* I - Number of command-line arguments */ | |
35 | char *argv[]) /* I - Command-line arguments */ | |
36 | { | |
7594b224 | 37 | int i; /* Looping var */ |
38 | int errors = 0; /* Number of errors */ | |
ef416fc2 | 39 | cups_lang_t *language; /* Message catalog */ |
40 | cups_lang_t *language2; /* Message catalog */ | |
7594b224 | 41 | struct lconv *loc; /* Locale data */ |
42 | char buffer[1024]; /* String buffer */ | |
43 | double number; /* Number */ | |
44 | static const char * const tests[] = /* Test strings */ | |
45 | { | |
46 | "1", | |
47 | "-1", | |
48 | "3", | |
49 | "5.125" | |
50 | }; | |
51 | ||
ef416fc2 | 52 | |
ef416fc2 | 53 | if (argc == 1) |
54 | { | |
55 | language = cupsLangDefault(); | |
56 | language2 = cupsLangDefault(); | |
57 | } | |
58 | else | |
59 | { | |
60 | language = cupsLangGet(argv[1]); | |
61 | language2 = cupsLangGet(argv[1]); | |
36474350 MS |
62 | |
63 | setenv("LANG", argv[1], 1); | |
64 | setenv("SOFTWARE", "CUPS/" CUPS_SVERSION, 1); | |
ef416fc2 | 65 | } |
66 | ||
36474350 MS |
67 | _cupsSetLocale(argv); |
68 | ||
ef416fc2 | 69 | if (language != language2) |
70 | { | |
7594b224 | 71 | errors ++; |
72 | ||
ef416fc2 | 73 | puts("**** ERROR: Language cache did not work! ****"); |
74 | puts("First result from cupsLangGet:"); | |
75 | } | |
76 | ||
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")); | |
81 | ||
82 | if (language != language2) | |
83 | { | |
84 | puts("Second result from cupsLangGet:"); | |
85 | ||
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")); | |
90 | } | |
91 | ||
7594b224 | 92 | loc = localeconv(); |
93 | ||
94 | for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++) | |
95 | { | |
96 | number = _cupsStrScand(tests[i], NULL, loc); | |
97 | ||
98 | printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number); | |
99 | ||
100 | _cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc); | |
101 | ||
102 | printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer); | |
103 | ||
104 | if (strcmp(buffer, tests[i])) | |
105 | { | |
106 | errors ++; | |
107 | puts("**** ERROR: Bad formatted number! ****"); | |
108 | } | |
109 | } | |
110 | ||
36474350 MS |
111 | if (argc == 3) |
112 | { | |
113 | ppd_file_t *ppd; /* PPD file */ | |
114 | ppd_option_t *option; /* PageSize option */ | |
115 | ppd_choice_t *choice; /* PageSize/Letter choice */ | |
116 | ||
117 | if ((ppd = ppdOpenFile(argv[2])) == NULL) | |
118 | { | |
119 | printf("Unable to open PPD file \"%s\".\n", argv[2]); | |
120 | errors ++; | |
121 | } | |
122 | else | |
123 | { | |
124 | ppdLocalize(ppd); | |
125 | ||
126 | if ((option = ppdFindOption(ppd, "PageSize")) == NULL) | |
127 | { | |
128 | puts("No PageSize option."); | |
129 | errors ++; | |
130 | } | |
131 | else | |
132 | { | |
133 | printf("PageSize: %s\n", option->text); | |
134 | ||
135 | if ((choice = ppdFindChoice(option, "Letter")) == NULL) | |
136 | { | |
137 | puts("No Letter PageSize choice."); | |
138 | errors ++; | |
139 | } | |
140 | else | |
141 | { | |
142 | printf("Letter: %s\n", choice->text); | |
143 | } | |
144 | } | |
145 | ||
146 | ppdClose(ppd); | |
147 | } | |
148 | } | |
149 | ||
7594b224 | 150 | return (errors > 0); |
ef416fc2 | 151 | } |
152 | ||
153 | ||
154 | /* | |
f2d18633 | 155 | * End of "$Id$". |
ef416fc2 | 156 | */ |