]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/testadmin.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / cups / testadmin.c
CommitLineData
757d2cad 1/*
503b54c9 2 * Admin function test program for CUPS.
757d2cad 3 *
503b54c9
MS
4 * Copyright 2007-2013 by Apple Inc.
5 * Copyright 2006 by Easy Software Products.
757d2cad 6 *
503b54c9
MS
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 * file is missing or damaged, see the license at "http://www.cups.org/".
757d2cad 12 *
503b54c9 13 * This file is subject to the Apple OS-Developed Software exception.
757d2cad 14 */
15
16/*
17 * Include necessary headers...
18 */
19
20#include "adminutil.h"
71e16022 21#include "string-private.h"
757d2cad 22
23
24/*
25 * Local functions...
26 */
27
28static void show_settings(int num_settings, cups_option_t *settings);
29
30
31/*
32 * 'main()' - Main entry.
33 */
34
35int /* O - Exit status */
36main(int argc, /* I - Number of command-line args */
37 char *argv[]) /* I - Command-line arguments */
38{
39 int i, /* Looping var */
40 num_settings; /* Number of settings */
41 cups_option_t *settings; /* Settings */
42 http_t *http; /* Connection to server */
43
44
45 /*
46 * Connect to the server using the defaults...
47 */
48
cb7f98ee
MS
49 http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
50 cupsEncryption(), 1, 30000, NULL);
757d2cad 51
52 /*
53 * Set the current configuration if we have anything on the command-line...
54 */
55
56 if (argc > 1)
57 {
1f0275e3 58 for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++)
757d2cad 59 num_settings = cupsParseOptions(argv[i], num_settings, &settings);
60
f899b121 61 if (cupsAdminSetServerSettings(http, num_settings, settings))
757d2cad 62 {
63 puts("New server settings:");
64 cupsFreeOptions(num_settings, settings);
65 }
66 else
67 {
68 printf("Server settings not changed: %s\n", cupsLastErrorString());
69 return (1);
70 }
71 }
72 else
73 puts("Current server settings:");
74
75 /*
76 * Get the current configuration...
77 */
78
f899b121 79 if (cupsAdminGetServerSettings(http, &num_settings, &settings))
757d2cad 80 {
81 show_settings(num_settings, settings);
82 cupsFreeOptions(num_settings, settings);
83 return (0);
84 }
85 else
86 {
87 printf(" %s\n", cupsLastErrorString());
88 return (1);
89 }
90}
91
92
93/*
94 * 'show_settings()' - Show settings in the array...
95 */
96
97static void
98show_settings(
99 int num_settings, /* I - Number of settings */
100 cups_option_t *settings) /* I - Settings */
101{
102 while (num_settings > 0)
103 {
104 printf(" %s=%s\n", settings->name, settings->value);
105
106 settings ++;
107 num_settings --;
108 }
109}