2 * "$Id: testadmin.c 10996 2013-05-29 11:51:34Z msweet $"
4 * Admin function test program for CUPS.
6 * Copyright 2007-2013 by Apple Inc.
7 * Copyright 2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Main entry.
20 * show_settings() - Show settings in the array...
24 * Include necessary headers...
27 #include "adminutil.h"
28 #include "string-private.h"
35 static void show_settings(int num_settings, cups_option_t *settings);
39 * 'main()' - Main entry.
42 int /* O - Exit status */
43 main(int argc, /* I - Number of command-line args */
44 char *argv[]) /* I - Command-line arguments */
46 int i, /* Looping var */
47 num_settings; /* Number of settings */
48 cups_option_t *settings; /* Settings */
49 http_t *http; /* Connection to server */
53 * Connect to the server using the defaults...
56 http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
57 cupsEncryption(), 1, 30000, NULL);
60 * Set the current configuration if we have anything on the command-line...
65 for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++)
66 num_settings = cupsParseOptions(argv[i], num_settings, &settings);
68 if (cupsAdminSetServerSettings(http, num_settings, settings))
70 puts("New server settings:");
71 cupsFreeOptions(num_settings, settings);
75 printf("Server settings not changed: %s\n", cupsLastErrorString());
80 puts("Current server settings:");
83 * Get the current configuration...
86 if (cupsAdminGetServerSettings(http, &num_settings, &settings))
88 show_settings(num_settings, settings);
89 cupsFreeOptions(num_settings, settings);
94 printf(" %s\n", cupsLastErrorString());
101 * 'show_settings()' - Show settings in the array...
106 int num_settings, /* I - Number of settings */
107 cups_option_t *settings) /* I - Settings */
109 while (num_settings > 0)
111 printf(" %s=%s\n", settings->name, settings->value);
120 * End of "$Id: testadmin.c 10996 2013-05-29 11:51:34Z msweet $".