]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testoptions.c
4 * Option test program for the Common UNIX Printing System (CUPS).
6 * Copyright 2008 by Apple Inc.
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/".
14 * This file is subject to the Apple OS-Developed Software exception.
18 * main() - Test option processing functions.
22 * Include necessary headers...
30 * 'main()' - Test option processing functions.
33 int /* O - Exit status */
34 main(int argc
, /* I - Number of command-line arguments */
35 char *argv
[]) /* I - Command-line arguments */
37 int status
= 0, /* Exit status */
38 num_options
; /* Number of options */
39 cups_option_t
*options
; /* Options */
40 const char *value
; /* Value of an option */
49 fputs("cupsParseOptions: ", stdout
);
51 num_options
= cupsParseOptions("foo=1234 "
52 "bar=\"One Fish\",\"Two Fish\",\"Red Fish\","
54 "baz={param1=1 param2=2} "
57 "barfoo=\"\'BAR FOO\'\"", 0, &options
);
61 printf("FAIL (num_options=%d, expected 5)\n", num_options
);
64 else if ((value
= cupsGetOption("foo", num_options
, options
)) == NULL
||
65 strcmp(value
, "1234"))
67 printf("FAIL (foo=\"%s\", expected \"1234\")\n", value
);
70 else if ((value
= cupsGetOption("bar", num_options
, options
)) == NULL
||
71 strcmp(value
, "One Fish,Two Fish,Red Fish,Blue Fish"))
73 printf("FAIL (bar=\"%s\", expected \"One Fish,Two Fish,Red Fish,Blue "
77 else if ((value
= cupsGetOption("baz", num_options
, options
)) == NULL
||
78 strcmp(value
, "{param1=1 param2=2}"))
80 printf("FAIL (baz=\"%s\", expected \"{param1=1 param2=2}\")\n", value
);
83 else if ((value
= cupsGetOption("foobar", num_options
, options
)) == NULL
||
84 strcmp(value
, "FOO BAR"))
86 printf("FAIL (foobar=\"%s\", expected \"FOO BAR\")\n", value
);
89 else if ((value
= cupsGetOption("barfoo", num_options
, options
)) == NULL
||
90 strcmp(value
, "\'BAR FOO\'"))
92 printf("FAIL (barfoo=\"%s\", expected \"\'BAR FOO\'\")\n", value
);
100 int i
; /* Looping var */
101 cups_option_t
*option
; /* Current option */
104 num_options
= cupsParseOptions(argv
[1], 0, &options
);
106 for (i
= 0, option
= options
; i
< num_options
; i
++, option
++)
107 printf("options[%d].name=\"%s\", value=\"%s\"\n", i
, option
->name
,