]>
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 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include "adminutil.h"
15 #include "string-private.h"
22 static void show_settings(int num_settings
, cups_option_t
*settings
);
26 * 'main()' - Main entry.
29 int /* O - Exit status */
30 main(int argc
, /* I - Number of command-line args */
31 char *argv
[]) /* I - Command-line arguments */
33 int i
, /* Looping var */
34 num_settings
; /* Number of settings */
35 cups_option_t
*settings
; /* Settings */
36 http_t
*http
; /* Connection to server */
40 * Connect to the server using the defaults...
43 http
= httpConnect2(cupsServer(), ippPort(), NULL
, AF_UNSPEC
,
44 cupsEncryption(), 1, 30000, NULL
);
47 * Set the current configuration if we have anything on the command-line...
52 for (i
= 1, num_settings
= 0, settings
= NULL
; i
< argc
; i
++)
53 num_settings
= cupsParseOptions(argv
[i
], num_settings
, &settings
);
55 if (cupsAdminSetServerSettings(http
, num_settings
, settings
))
57 puts("New server settings:");
58 cupsFreeOptions(num_settings
, settings
);
62 printf("Server settings not changed: %s\n", cupsLastErrorString());
67 puts("Current server settings:");
70 * Get the current configuration...
73 if (cupsAdminGetServerSettings(http
, &num_settings
, &settings
))
75 show_settings(num_settings
, settings
);
76 cupsFreeOptions(num_settings
, settings
);
81 printf(" %s\n", cupsLastErrorString());
88 * 'show_settings()' - Show settings in the array...
93 int num_settings
, /* I - Number of settings */
94 cups_option_t
*settings
) /* I - Settings */
96 while (num_settings
> 0)
98 printf(" %s=%s\n", settings
->name
, settings
->value
);