#include "cups-private.h"
#include "ppd-private.h"
int
main(int argc,
char *argv[])
{
int i;
int errors = 0;
cups_lang_t *language;
cups_lang_t *language2;
struct lconv *loc;
char buffer[1024];
double number;
static const char * const tests[] =
{
"1",
"-1",
"3",
"5.125"
};
if (argc == 1)
{
language = cupsLangDefault();
language2 = cupsLangDefault();
}
else
{
language = cupsLangGet(argv[1]);
language2 = cupsLangGet(argv[1]);
setenv("LANG", argv[1], 1);
setenv("SOFTWARE", "CUPS/" CUPS_SVERSION, 1);
}
_cupsSetLocale(argv);
if (language != language2)
{
errors ++;
puts("**** ERROR: Language cache did not work! ****");
puts("First result from cupsLangGet:");
}
printf("Language = \"%s\"\n", language->language);
printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding));
printf("No = \"%s\"\n", _cupsLangString(language, "No"));
printf("Yes = \"%s\"\n", _cupsLangString(language, "Yes"));
if (language != language2)
{
puts("Second result from cupsLangGet:");
printf("Language = \"%s\"\n", language2->language);
printf("Encoding = \"%s\"\n", _cupsEncodingName(language2->encoding));
printf("No = \"%s\"\n", _cupsLangString(language2, "No"));
printf("Yes = \"%s\"\n", _cupsLangString(language2, "Yes"));
}
loc = localeconv();
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
{
number = _cupsStrScand(tests[i], NULL, loc);
printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number);
_cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer);
if (strcmp(buffer, tests[i]))
{
errors ++;
puts("**** ERROR: Bad formatted number! ****");
}
}
if (argc == 3)
{
ppd_file_t *ppd;
ppd_option_t *option;
ppd_choice_t *choice;
if ((ppd = ppdOpenFile(argv[2])) == NULL)
{
printf("Unable to open PPD file \"%s\".\n", argv[2]);
errors ++;
}
else
{
ppdLocalize(ppd);
if ((option = ppdFindOption(ppd, "PageSize")) == NULL)
{
puts("No PageSize option.");
errors ++;
}
else
{
printf("PageSize: %s\n", option->text);
if ((choice = ppdFindChoice(option, "Letter")) == NULL)
{
puts("No Letter PageSize choice.");
errors ++;
}
else
{
printf("Letter: %s\n", choice->text);
}
}
ppdClose(ppd);
}
}
return (errors > 0);
}