]>
Commit | Line | Data |
---|---|---|
20fbc903 MS |
1 | /* |
2 | * "$Id$" | |
3 | * | |
71e16022 | 4 | * Option test program for CUPS. |
20fbc903 | 5 | * |
71e16022 | 6 | * Copyright 2008-2010 by Apple Inc. |
20fbc903 MS |
7 | * |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Apple Inc. and are protected by Federal copyright | |
10 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
11 | * which should have been included with this file. If this file is | |
12 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
13 | * | |
14 | * This file is subject to the Apple OS-Developed Software exception. | |
15 | * | |
16 | * Contents: | |
17 | * | |
18 | * main() - Test option processing functions. | |
19 | */ | |
20 | ||
21 | /* | |
22 | * Include necessary headers... | |
23 | */ | |
24 | ||
71e16022 | 25 | #include "cups-private.h" |
20fbc903 MS |
26 | |
27 | ||
28 | /* | |
29 | * 'main()' - Test option processing functions. | |
30 | */ | |
31 | ||
32 | int /* O - Exit status */ | |
33 | main(int argc, /* I - Number of command-line arguments */ | |
34 | char *argv[]) /* I - Command-line arguments */ | |
35 | { | |
36 | int status = 0, /* Exit status */ | |
37 | num_options; /* Number of options */ | |
38 | cups_option_t *options; /* Options */ | |
39 | const char *value; /* Value of an option */ | |
40 | ||
41 | ||
42 | if (argc == 1) | |
43 | { | |
44 | /* | |
45 | * cupsParseOptions() | |
46 | */ | |
47 | ||
48 | fputs("cupsParseOptions: ", stdout); | |
49 | ||
50 | num_options = cupsParseOptions("foo=1234 " | |
51 | "bar=\"One Fish\",\"Two Fish\",\"Red Fish\"," | |
52 | "\"Blue Fish\" " | |
53 | "baz={param1=1 param2=2} " | |
54 | "foobar=FOO\\ BAR " | |
55 | "barfoo=barfoo " | |
56 | "barfoo=\"\'BAR FOO\'\"", 0, &options); | |
57 | ||
58 | if (num_options != 5) | |
59 | { | |
60 | printf("FAIL (num_options=%d, expected 5)\n", num_options); | |
61 | status ++; | |
62 | } | |
63 | else if ((value = cupsGetOption("foo", num_options, options)) == NULL || | |
64 | strcmp(value, "1234")) | |
65 | { | |
66 | printf("FAIL (foo=\"%s\", expected \"1234\")\n", value); | |
67 | status ++; | |
68 | } | |
69 | else if ((value = cupsGetOption("bar", num_options, options)) == NULL || | |
70 | strcmp(value, "One Fish,Two Fish,Red Fish,Blue Fish")) | |
71 | { | |
72 | printf("FAIL (bar=\"%s\", expected \"One Fish,Two Fish,Red Fish,Blue " | |
73 | "Fish\")\n", value); | |
74 | status ++; | |
75 | } | |
76 | else if ((value = cupsGetOption("baz", num_options, options)) == NULL || | |
77 | strcmp(value, "{param1=1 param2=2}")) | |
78 | { | |
79 | printf("FAIL (baz=\"%s\", expected \"{param1=1 param2=2}\")\n", value); | |
80 | status ++; | |
81 | } | |
82 | else if ((value = cupsGetOption("foobar", num_options, options)) == NULL || | |
83 | strcmp(value, "FOO BAR")) | |
84 | { | |
85 | printf("FAIL (foobar=\"%s\", expected \"FOO BAR\")\n", value); | |
86 | status ++; | |
87 | } | |
88 | else if ((value = cupsGetOption("barfoo", num_options, options)) == NULL || | |
89 | strcmp(value, "\'BAR FOO\'")) | |
90 | { | |
91 | printf("FAIL (barfoo=\"%s\", expected \"\'BAR FOO\'\")\n", value); | |
92 | status ++; | |
93 | } | |
94 | else | |
95 | puts("PASS"); | |
96 | } | |
97 | else | |
98 | { | |
99 | int i; /* Looping var */ | |
100 | cups_option_t *option; /* Current option */ | |
101 | ||
102 | ||
103 | num_options = cupsParseOptions(argv[1], 0, &options); | |
104 | ||
105 | for (i = 0, option = options; i < num_options; i ++, option ++) | |
106 | printf("options[%d].name=\"%s\", value=\"%s\"\n", i, option->name, | |
107 | option->value); | |
108 | } | |
109 | ||
110 | exit (status); | |
111 | } | |
112 | ||
113 | ||
114 | /* | |
115 | * End of "$Id$". | |
116 | */ |