]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testoptions.c
4 * Option test program for CUPS.
6 * Copyright 2008-2010 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...
25 #include "cups-private.h"
29 * 'main()' - Test option processing functions.
32 int /* O - Exit status */
33 main(int argc
, /* I - Number of command-line arguments */
34 char *argv
[]) /* I - Command-line arguments */
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 */
48 fputs("cupsParseOptions: ", stdout
);
50 num_options
= cupsParseOptions("foo=1234 "
51 "bar=\"One Fish\",\"Two Fish\",\"Red Fish\","
53 "baz={param1=1 param2=2} "
56 "barfoo=\"\'BAR FOO\'\"", 0, &options
);
60 printf("FAIL (num_options=%d, expected 5)\n", num_options
);
63 else if ((value
= cupsGetOption("foo", num_options
, options
)) == NULL
||
64 strcmp(value
, "1234"))
66 printf("FAIL (foo=\"%s\", expected \"1234\")\n", value
);
69 else if ((value
= cupsGetOption("bar", num_options
, options
)) == NULL
||
70 strcmp(value
, "One Fish,Two Fish,Red Fish,Blue Fish"))
72 printf("FAIL (bar=\"%s\", expected \"One Fish,Two Fish,Red Fish,Blue "
76 else if ((value
= cupsGetOption("baz", num_options
, options
)) == NULL
||
77 strcmp(value
, "{param1=1 param2=2}"))
79 printf("FAIL (baz=\"%s\", expected \"{param1=1 param2=2}\")\n", value
);
82 else if ((value
= cupsGetOption("foobar", num_options
, options
)) == NULL
||
83 strcmp(value
, "FOO BAR"))
85 printf("FAIL (foobar=\"%s\", expected \"FOO BAR\")\n", value
);
88 else if ((value
= cupsGetOption("barfoo", num_options
, options
)) == NULL
||
89 strcmp(value
, "\'BAR FOO\'"))
91 printf("FAIL (barfoo=\"%s\", expected \"\'BAR FOO\'\")\n", value
);
99 int i
; /* Looping var */
100 cups_option_t
*option
; /* Current option */
103 num_options
= cupsParseOptions(argv
[1], 0, &options
);
105 for (i
= 0, option
= options
; i
< num_options
; i
++, option
++)
106 printf("options[%d].name=\"%s\", value=\"%s\"\n", i
, option
->name
,