]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/testlang.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / testlang.c
CommitLineData
ef416fc2 1/*
7594b224 2 * "$Id: testlang.c 6345 2007-03-17 18:00:04Z mike $"
ef416fc2 3 *
4 * Localization test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 by Easy Software Products.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 *
26 * Contents:
27 *
28 * main() - Load the specified language and show the strings for yes and no.
29 */
30
31/*
32 * Include necessary headers...
33 */
34
35#include <stdio.h>
36#include "i18n.h"
7594b224 37#include "string.h"
ef416fc2 38
39
40/*
41 * 'main()' - Load the specified language and show the strings for yes and no.
42 */
43
44int /* O - Exit status */
45main(int argc, /* I - Number of command-line arguments */
46 char *argv[]) /* I - Command-line arguments */
47{
7594b224 48 int i; /* Looping var */
49 int errors = 0; /* Number of errors */
ef416fc2 50 cups_lang_t *language; /* Message catalog */
51 cups_lang_t *language2; /* Message catalog */
7594b224 52 struct lconv *loc; /* Locale data */
53 char buffer[1024]; /* String buffer */
54 double number; /* Number */
55 static const char * const tests[] = /* Test strings */
56 {
57 "1",
58 "-1",
59 "3",
60 "5.125"
61 };
62
ef416fc2 63
7594b224 64 _cupsSetLocale(argv);
ef416fc2 65
66 if (argc == 1)
67 {
68 language = cupsLangDefault();
69 language2 = cupsLangDefault();
70 }
71 else
72 {
73 language = cupsLangGet(argv[1]);
74 language2 = cupsLangGet(argv[1]);
75 }
76
77 if (language != language2)
78 {
7594b224 79 errors ++;
80
ef416fc2 81 puts("**** ERROR: Language cache did not work! ****");
82 puts("First result from cupsLangGet:");
83 }
84
85 printf("Language = \"%s\"\n", language->language);
86 printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding));
87 printf("No = \"%s\"\n", _cupsLangString(language, "No"));
88 printf("Yes = \"%s\"\n", _cupsLangString(language, "Yes"));
89
90 if (language != language2)
91 {
92 puts("Second result from cupsLangGet:");
93
94 printf("Language = \"%s\"\n", language2->language);
95 printf("Encoding = \"%s\"\n", _cupsEncodingName(language2->encoding));
96 printf("No = \"%s\"\n", _cupsLangString(language2, "No"));
97 printf("Yes = \"%s\"\n", _cupsLangString(language2, "Yes"));
98 }
99
7594b224 100 loc = localeconv();
101
102 for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
103 {
104 number = _cupsStrScand(tests[i], NULL, loc);
105
106 printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number);
107
108 _cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
109
110 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer);
111
112 if (strcmp(buffer, tests[i]))
113 {
114 errors ++;
115 puts("**** ERROR: Bad formatted number! ****");
116 }
117 }
118
119 return (errors > 0);
ef416fc2 120}
121
122
123/*
7594b224 124 * End of "$Id: testlang.c 6345 2007-03-17 18:00:04Z mike $".
ef416fc2 125 */