]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
8fe0183a | 2 | * Main header file for the CUPS scheduler. |
ef416fc2 | 3 | * |
be3b49a3 | 4 | * Copyright © 2007-2018 by Apple Inc. |
53f8d64f | 5 | * Copyright © 1997-2007 by Easy Software Products, all rights reserved. |
ef416fc2 | 6 | * |
53f8d64f MS |
7 | * Licensed under Apache License v2.0. See the file "LICENSE" for more |
8 | * information. | |
ef416fc2 | 9 | */ |
10 | ||
11 | ||
12 | /* | |
13 | * Include necessary headers. | |
14 | */ | |
15 | ||
71e16022 | 16 | #include <cups/cups-private.h> |
22c9029b | 17 | #include <cups/file-private.h> |
f787e1e3 | 18 | #include <cups/ppd-private.h> |
71e16022 | 19 | |
ef416fc2 | 20 | #include <limits.h> |
ef416fc2 | 21 | #include <time.h> |
22 | #include <signal.h> | |
23 | #include <fcntl.h> | |
24 | #include <math.h> | |
25 | #include <sys/types.h> | |
26 | #include <sys/time.h> | |
27 | #include <sys/stat.h> | |
28 | #include <sys/wait.h> | |
29 | ||
24a06ed3 | 30 | #ifdef _WIN32 |
ef416fc2 | 31 | # include <direct.h> |
32 | #else | |
33 | # include <unistd.h> | |
24a06ed3 | 34 | #endif /* _WIN32 */ |
ef416fc2 | 35 | |
ef416fc2 | 36 | #include "mime.h" |
ef416fc2 | 37 | |
38 | #if defined(HAVE_CDSASSL) | |
39 | # include <CoreFoundation/CoreFoundation.h> | |
40 | #endif /* HAVE_CDSASSL */ | |
41 | ||
42 | ||
43 | /* | |
44 | * Some OS's don't have hstrerror(), most notably Solaris... | |
45 | */ | |
46 | ||
47 | #ifndef HAVE_HSTRERROR | |
b423cd4c | 48 | # ifdef hstrerror |
49 | # undef hstrerror | |
50 | # endif /* hstrerror */ | |
ef416fc2 | 51 | # define hstrerror cups_hstrerror |
52 | ||
53 | extern const char *cups_hstrerror(int); | |
54 | #endif /* !HAVE_HSTRERROR */ | |
55 | ||
56 | ||
57 | /* | |
58 | * Common constants. | |
59 | */ | |
60 | ||
61 | #ifndef FALSE | |
62 | # define FALSE 0 | |
63 | # define TRUE (!FALSE) | |
64 | #endif /* !FALSE */ | |
65 | ||
66 | ||
67 | /* | |
68 | * Implementation limits... | |
69 | */ | |
70 | ||
e00b005a | 71 | #define MAX_ENV 100 /* Maximum number of environment strings */ |
ef416fc2 | 72 | #define MAX_USERPASS 33 /* Maximum size of username/password */ |
73 | #define MAX_FILTERS 20 /* Maximum number of filters */ | |
74 | #define MAX_SYSTEM_GROUPS 32 /* Maximum number of system groups */ | |
75 | ||
76 | ||
77 | /* | |
78 | * Defaults... | |
79 | */ | |
80 | ||
82cc1f9a MS |
81 | #define DEFAULT_HISTORY INT_MAX /* Preserve job history? */ |
82 | #define DEFAULT_FILES 86400 /* Preserve job files? */ | |
ef416fc2 | 83 | #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */ |
49d87452 | 84 | #define DEFAULT_KEEPALIVE 30 /* Timeout between requests */ |
ef416fc2 | 85 | |
86 | ||
87 | /* | |
88 | * Global variable macros... | |
89 | */ | |
90 | ||
91 | #ifdef _MAIN_C_ | |
92 | # define VAR | |
93 | # define VALUE(x) =x | |
94 | # define VALUE2(x,y) ={x,y} | |
95 | #else | |
96 | # define VAR extern | |
97 | # define VALUE(x) | |
98 | # define VALUE2(x,y) | |
99 | #endif /* _MAIN_C */ | |
100 | ||
101 | ||
102 | /* | |
103 | * Other stuff for the scheduler... | |
104 | */ | |
105 | ||
09ec0018 | 106 | #include "sysman.h" |
ef416fc2 | 107 | #include "statbuf.h" |
108 | #include "cert.h" | |
109 | #include "auth.h" | |
110 | #include "client.h" | |
111 | #include "policy.h" | |
112 | #include "printers.h" | |
113 | #include "classes.h" | |
114 | #include "job.h" | |
a29fd7dd | 115 | #include "colorman.h" |
ef416fc2 | 116 | #include "conf.h" |
117 | #include "banners.h" | |
118 | #include "dirsvc.h" | |
119 | #include "network.h" | |
120 | #include "subscriptions.h" | |
121 | ||
122 | ||
123 | /* | |
124 | * Reload types... | |
125 | */ | |
126 | ||
127 | #define RELOAD_NONE 0 /* No reload needed */ | |
128 | #define RELOAD_ALL 1 /* Reload everything */ | |
129 | #define RELOAD_CUPSD 2 /* Reload only cupsd.conf */ | |
130 | ||
131 | ||
f7deaa1a | 132 | /* |
133 | * Select callback function type... | |
134 | */ | |
135 | ||
136 | typedef void (*cupsd_selfunc_t)(void *data); | |
137 | ||
138 | ||
ef416fc2 | 139 | /* |
140 | * Globals... | |
141 | */ | |
142 | ||
8fe0183a | 143 | VAR int TestConfigFile VALUE(0); |
2e4ff8af | 144 | /* Test the cupsd.conf file? */ |
ac884b6a MS |
145 | VAR int MaxFDs VALUE(0); |
146 | /* Maximum number of files */ | |
ef416fc2 | 147 | |
148 | VAR time_t ReloadTime VALUE(0); | |
149 | /* Time of reload request... */ | |
7cf5915e | 150 | VAR int NeedReload VALUE(RELOAD_ALL), |
ef416fc2 | 151 | /* Need to load configuration? */ |
7cf5915e MS |
152 | DoingShutdown VALUE(0); |
153 | /* Shutting down the scheduler? */ | |
a4924f6c MS |
154 | VAR void *DefaultProfile VALUE(0); |
155 | /* Default security profile */ | |
c24d2134 | 156 | |
1166bf58 | 157 | #ifdef HAVE_ONDEMAND |
1720786e MS |
158 | VAR int OnDemand VALUE(0); |
159 | /* Launched on demand */ | |
c187d9ab | 160 | #endif /* HAVE_ONDEMAND */ |
ef416fc2 | 161 | |
162 | ||
163 | /* | |
164 | * Prototypes... | |
165 | */ | |
166 | ||
321d8d57 MS |
167 | /* env.c */ |
168 | extern void cupsdInitEnv(void); | |
169 | extern int cupsdLoadEnv(char *envp[], int envmax); | |
170 | extern void cupsdSetEnv(const char *name, const char *value); | |
be3b49a3 | 171 | extern void cupsdSetEnvf(const char *name, const char *value, ...) _CUPS_FORMAT(2, 3); |
321d8d57 MS |
172 | extern void cupsdUpdateEnv(void); |
173 | ||
174 | /* file.c */ | |
175 | extern void cupsdCleanFiles(const char *path, const char *pattern); | |
176 | extern int cupsdCloseCreatedConfFile(cups_file_t *fp, | |
177 | const char *filename); | |
178 | extern void cupsdClosePipe(int *fds); | |
179 | extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode); | |
180 | extern cups_file_t *cupsdOpenConfFile(const char *filename); | |
181 | extern int cupsdOpenPipe(int *fds); | |
182 | extern int cupsdRemoveFile(const char *filename); | |
cb7f98ee | 183 | extern int cupsdUnlinkOrRemoveFile(const char *filename); |
321d8d57 MS |
184 | |
185 | /* main.c */ | |
186 | extern int cupsdAddString(cups_array_t **a, const char *s); | |
187 | extern void cupsdCheckProcess(void); | |
188 | extern void cupsdClearString(char **s); | |
189 | extern void cupsdFreeStrings(cups_array_t **a); | |
190 | extern void cupsdHoldSignals(void); | |
191 | extern char *cupsdMakeUUID(const char *name, int number, | |
192 | char *buffer, size_t bufsize); | |
193 | extern void cupsdReleaseSignals(void); | |
194 | extern void cupsdSetString(char **s, const char *v); | |
195 | extern void cupsdSetStringf(char **s, const char *f, ...) | |
85dda01c | 196 | __attribute__ ((__format__ (__printf__, 2, 3))); |
321d8d57 MS |
197 | |
198 | /* process.c */ | |
8fe0183a | 199 | extern void *cupsdCreateProfile(int job_id, int allow_networking); |
321d8d57 MS |
200 | extern void cupsdDestroyProfile(void *profile); |
201 | extern int cupsdEndProcess(int pid, int force); | |
07623986 | 202 | extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id); |
321d8d57 MS |
203 | extern int cupsdStartProcess(const char *command, char *argv[], |
204 | char *envp[], int infd, int outfd, | |
205 | int errfd, int backfd, int sidefd, | |
206 | int root, void *profile, | |
207 | cupsd_job_t *job, int *pid); | |
208 | ||
209 | /* select.c */ | |
210 | extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb, | |
211 | cupsd_selfunc_t write_cb, void *data); | |
212 | extern int cupsdDoSelect(long timeout); | |
f899b121 | 213 | #ifdef CUPSD_IS_SELECTING |
321d8d57 | 214 | extern int cupsdIsSelecting(int fd); |
f899b121 | 215 | #endif /* CUPSD_IS_SELECTING */ |
321d8d57 MS |
216 | extern void cupsdRemoveSelect(int fd); |
217 | extern void cupsdStartSelect(void); | |
218 | extern void cupsdStopSelect(void); | |
ef416fc2 | 219 | |
321d8d57 MS |
220 | /* server.c */ |
221 | extern void cupsdStartServer(void); | |
222 | extern void cupsdStopServer(void); |