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