]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testadmin.c
2 * Admin function test program for CUPS.
4 * Copyright 2007-2013 by Apple Inc.
5 * Copyright 2006 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
17 * Include necessary headers...
20 #include "adminutil.h"
21 #include "string-private.h"
28 static void show_settings(int num_settings
, cups_option_t
*settings
);
32 * 'main()' - Main entry.
35 int /* O - Exit status */
36 main(int argc
, /* I - Number of command-line args */
37 char *argv
[]) /* I - Command-line arguments */
39 int i
, /* Looping var */
40 num_settings
; /* Number of settings */
41 cups_option_t
*settings
; /* Settings */
42 http_t
*http
; /* Connection to server */
46 * Connect to the server using the defaults...
49 http
= httpConnect2(cupsServer(), ippPort(), NULL
, AF_UNSPEC
,
50 cupsEncryption(), 1, 30000, NULL
);
53 * Set the current configuration if we have anything on the command-line...
58 for (i
= 1, num_settings
= 0, settings
= NULL
; i
< argc
; i
++)
59 num_settings
= cupsParseOptions(argv
[i
], num_settings
, &settings
);
61 if (cupsAdminSetServerSettings(http
, num_settings
, settings
))
63 puts("New server settings:");
64 cupsFreeOptions(num_settings
, settings
);
68 printf("Server settings not changed: %s\n", cupsLastErrorString());
73 puts("Current server settings:");
76 * Get the current configuration...
79 if (cupsAdminGetServerSettings(http
, &num_settings
, &settings
))
81 show_settings(num_settings
, settings
);
82 cupsFreeOptions(num_settings
, settings
);
87 printf(" %s\n", cupsLastErrorString());
94 * 'show_settings()' - Show settings in the array...
99 int num_settings
, /* I - Number of settings */
100 cups_option_t
*settings
) /* I - Settings */
102 while (num_settings
> 0)
104 printf(" %s=%s\n", settings
->name
, settings
->value
);