]>
Commit | Line | Data |
---|---|---|
757d2cad | 1 | /* |
f7faf1f5 | 2 | * "$Id: testadmin.c 5240 2006-03-07 21:55:29Z mike $" |
757d2cad | 3 | * |
4 | * Admin function test program for the Common UNIX Printing System (CUPS). | |
5 | * | |
6 | * Copyright 2006 by Easy Software Products. | |
7 | * | |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Easy Software Products and are protected by Federal | |
10 | * copyright law. Distribution and use rights are outlined in the file | |
11 | * "LICENSE.txt" which should have been included with this file. If this | |
12 | * file is missing or damaged please contact Easy Software Products | |
13 | * at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636 USA | |
19 | * | |
20 | * Voice: (301) 373-9600 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * This file is subject to the Apple OS-Developed Software exception. | |
25 | * | |
26 | * Contents: | |
27 | * | |
28 | * main() - Main entry. | |
29 | * show_settings() - Show settings in the array... | |
30 | */ | |
31 | ||
32 | /* | |
33 | * Include necessary headers... | |
34 | */ | |
35 | ||
36 | #include "adminutil.h" | |
37 | #include "string.h" | |
38 | ||
39 | ||
40 | /* | |
41 | * Local functions... | |
42 | */ | |
43 | ||
44 | static void show_settings(int num_settings, cups_option_t *settings); | |
45 | ||
46 | ||
47 | /* | |
48 | * 'main()' - Main entry. | |
49 | */ | |
50 | ||
51 | int /* O - Exit status */ | |
52 | main(int argc, /* I - Number of command-line args */ | |
53 | char *argv[]) /* I - Command-line arguments */ | |
54 | { | |
55 | int i, /* Looping var */ | |
56 | num_settings; /* Number of settings */ | |
57 | cups_option_t *settings; /* Settings */ | |
58 | http_t *http; /* Connection to server */ | |
59 | ||
60 | ||
61 | /* | |
62 | * Connect to the server using the defaults... | |
63 | */ | |
64 | ||
65 | http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); | |
66 | ||
67 | /* | |
68 | * Set the current configuration if we have anything on the command-line... | |
69 | */ | |
70 | ||
71 | if (argc > 1) | |
72 | { | |
73 | for (i = 1, num_settings = 0; i < argc; i ++) | |
74 | num_settings = cupsParseOptions(argv[i], num_settings, &settings); | |
75 | ||
76 | if (_cupsAdminSetServerSettings(http, num_settings, settings)) | |
77 | { | |
78 | puts("New server settings:"); | |
79 | cupsFreeOptions(num_settings, settings); | |
80 | } | |
81 | else | |
82 | { | |
83 | printf("Server settings not changed: %s\n", cupsLastErrorString()); | |
84 | return (1); | |
85 | } | |
86 | } | |
87 | else | |
88 | puts("Current server settings:"); | |
89 | ||
90 | /* | |
91 | * Get the current configuration... | |
92 | */ | |
93 | ||
94 | if (_cupsAdminGetServerSettings(http, &num_settings, &settings)) | |
95 | { | |
96 | show_settings(num_settings, settings); | |
97 | cupsFreeOptions(num_settings, settings); | |
98 | return (0); | |
99 | } | |
100 | else | |
101 | { | |
102 | printf(" %s\n", cupsLastErrorString()); | |
103 | return (1); | |
104 | } | |
105 | } | |
106 | ||
107 | ||
108 | /* | |
109 | * 'show_settings()' - Show settings in the array... | |
110 | */ | |
111 | ||
112 | static void | |
113 | show_settings( | |
114 | int num_settings, /* I - Number of settings */ | |
115 | cups_option_t *settings) /* I - Settings */ | |
116 | { | |
117 | while (num_settings > 0) | |
118 | { | |
119 | printf(" %s=%s\n", settings->name, settings->value); | |
120 | ||
121 | settings ++; | |
122 | num_settings --; | |
123 | } | |
124 | } | |
125 | ||
126 | ||
127 | /* | |
f7faf1f5 | 128 | * End of "$Id: testadmin.c 5240 2006-03-07 21:55:29Z mike $". |
757d2cad | 129 | */ |