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