]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
b19ccc9e | 2 | * "$Id: cupsd.h 7928 2008-09-10 22:14:22Z mike $" |
ef416fc2 | 3 | * |
71e16022 | 4 | * Main header file for the CUPS scheduler. |
ef416fc2 | 5 | * |
0268488e | 6 | * Copyright 2007-2011 by Apple Inc. |
f899b121 | 7 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. |
ef416fc2 | 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" | |
ef416fc2 | 12 | * "LICENSE" which should have been included with this file. If this |
bc44d920 | 13 | * file is missing or damaged, see the license at "http://www.cups.org/". |
ef416fc2 | 14 | */ |
15 | ||
16 | ||
17 | /* | |
18 | * Include necessary headers. | |
19 | */ | |
20 | ||
71e16022 | 21 | #include <cups/cups-private.h> |
22c9029b | 22 | #include <cups/file-private.h> |
71e16022 | 23 | |
ef416fc2 | 24 | #include <limits.h> |
ef416fc2 | 25 | #include <time.h> |
26 | #include <signal.h> | |
27 | #include <fcntl.h> | |
28 | #include <math.h> | |
29 | #include <sys/types.h> | |
30 | #include <sys/time.h> | |
31 | #include <sys/stat.h> | |
32 | #include <sys/wait.h> | |
33 | ||
34 | #ifdef WIN32 | |
35 | # include <direct.h> | |
36 | #else | |
37 | # include <unistd.h> | |
38 | #endif /* WIN32 */ | |
39 | ||
ef416fc2 | 40 | #include "mime.h" |
ef416fc2 | 41 | |
42 | #if defined(HAVE_CDSASSL) | |
43 | # include <CoreFoundation/CoreFoundation.h> | |
44 | #endif /* HAVE_CDSASSL */ | |
45 | ||
46 | ||
47 | /* | |
48 | * Some OS's don't have hstrerror(), most notably Solaris... | |
49 | */ | |
50 | ||
51 | #ifndef HAVE_HSTRERROR | |
b423cd4c | 52 | # ifdef hstrerror |
53 | # undef hstrerror | |
54 | # endif /* hstrerror */ | |
ef416fc2 | 55 | # define hstrerror cups_hstrerror |
56 | ||
57 | extern const char *cups_hstrerror(int); | |
58 | #endif /* !HAVE_HSTRERROR */ | |
59 | ||
60 | ||
61 | /* | |
62 | * Common constants. | |
63 | */ | |
64 | ||
65 | #ifndef FALSE | |
66 | # define FALSE 0 | |
67 | # define TRUE (!FALSE) | |
68 | #endif /* !FALSE */ | |
69 | ||
70 | ||
71 | /* | |
72 | * Implementation limits... | |
73 | */ | |
74 | ||
e00b005a | 75 | #define MAX_ENV 100 /* Maximum number of environment strings */ |
ef416fc2 | 76 | #define MAX_USERPASS 33 /* Maximum size of username/password */ |
77 | #define MAX_FILTERS 20 /* Maximum number of filters */ | |
78 | #define MAX_SYSTEM_GROUPS 32 /* Maximum number of system groups */ | |
79 | ||
80 | ||
81 | /* | |
82 | * Defaults... | |
83 | */ | |
84 | ||
85 | #define DEFAULT_HISTORY 1 /* Preserve job history? */ | |
86 | #define DEFAULT_FILES 0 /* Preserve job files? */ | |
87 | #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */ | |
49d87452 | 88 | #define DEFAULT_KEEPALIVE 30 /* Timeout between requests */ |
ef416fc2 | 89 | #define DEFAULT_INTERVAL 30 /* Interval between browse updates */ |
90 | #define DEFAULT_CHARSET "utf-8" /* Default charset */ | |
91 | ||
92 | ||
93 | /* | |
94 | * Global variable macros... | |
95 | */ | |
96 | ||
97 | #ifdef _MAIN_C_ | |
98 | # define VAR | |
99 | # define VALUE(x) =x | |
100 | # define VALUE2(x,y) ={x,y} | |
101 | #else | |
102 | # define VAR extern | |
103 | # define VALUE(x) | |
104 | # define VALUE2(x,y) | |
105 | #endif /* _MAIN_C */ | |
106 | ||
107 | ||
108 | /* | |
109 | * Other stuff for the scheduler... | |
110 | */ | |
111 | ||
09ec0018 | 112 | #include "sysman.h" |
ef416fc2 | 113 | #include "statbuf.h" |
114 | #include "cert.h" | |
115 | #include "auth.h" | |
116 | #include "client.h" | |
117 | #include "policy.h" | |
118 | #include "printers.h" | |
119 | #include "classes.h" | |
120 | #include "job.h" | |
121 | #include "conf.h" | |
122 | #include "banners.h" | |
123 | #include "dirsvc.h" | |
124 | #include "network.h" | |
125 | #include "subscriptions.h" | |
126 | ||
127 | ||
128 | /* | |
129 | * Reload types... | |
130 | */ | |
131 | ||
132 | #define RELOAD_NONE 0 /* No reload needed */ | |
133 | #define RELOAD_ALL 1 /* Reload everything */ | |
134 | #define RELOAD_CUPSD 2 /* Reload only cupsd.conf */ | |
135 | ||
136 | ||
f7deaa1a | 137 | /* |
138 | * Select callback function type... | |
139 | */ | |
140 | ||
141 | typedef void (*cupsd_selfunc_t)(void *data); | |
142 | ||
3e7fe0ca MS |
143 | #ifdef HAVE_AVAHI |
144 | /* | |
145 | * Timeout callback function type... | |
146 | */ | |
147 | ||
148 | typedef struct _cupsd_timeout_s cupsd_timeout_t; | |
149 | typedef void (*cupsd_timeoutfunc_t)(cupsd_timeout_t *timeout, void *data); | |
150 | #endif /* HAVE_AVAHI */ | |
151 | ||
f7deaa1a | 152 | |
ef416fc2 | 153 | /* |
154 | * Globals... | |
155 | */ | |
156 | ||
1340db2d | 157 | VAR int TestConfigFile VALUE(0), |
2e4ff8af | 158 | /* Test the cupsd.conf file? */ |
1340db2d MS |
159 | UseProfiles VALUE(1); |
160 | /* Use security profiles for child procs? */ | |
ac884b6a MS |
161 | VAR int MaxFDs VALUE(0); |
162 | /* Maximum number of files */ | |
ef416fc2 | 163 | |
164 | VAR time_t ReloadTime VALUE(0); | |
165 | /* Time of reload request... */ | |
7cf5915e | 166 | VAR int NeedReload VALUE(RELOAD_ALL), |
ef416fc2 | 167 | /* Need to load configuration? */ |
7cf5915e MS |
168 | DoingShutdown VALUE(0); |
169 | /* Shutting down the scheduler? */ | |
a4924f6c MS |
170 | VAR void *DefaultProfile VALUE(0); |
171 | /* Default security profile */ | |
c24d2134 MS |
172 | |
173 | #ifdef HAVE_GSSAPI | |
0af14961 MS |
174 | VAR int KerberosInitialized VALUE(0); |
175 | /* Has Kerberos been initialized? */ | |
ac884b6a MS |
176 | VAR krb5_context KerberosContext VALUE(NULL); |
177 | /* Kerberos context for credentials */ | |
c24d2134 MS |
178 | #endif /* HAVE_GSSAPI */ |
179 | ||
4400e98d | 180 | #ifdef HAVE_LAUNCH_H |
181 | VAR int Launchd VALUE(0); | |
182 | /* Running from launchd */ | |
183 | #endif /* HAVE_LAUNCH_H */ | |
ef416fc2 | 184 | |
3e7fe0ca MS |
185 | #ifdef HAVE_AVAHI |
186 | VAR cups_array_t *Timeouts VALUE(NULL); | |
187 | /* Timed callbacks for main loop */ | |
188 | #endif /* HAVE_AVAHI */ | |
189 | ||
190 | ||
ef416fc2 | 191 | |
192 | /* | |
193 | * Prototypes... | |
194 | */ | |
195 | ||
321d8d57 MS |
196 | /* env.c */ |
197 | extern void cupsdInitEnv(void); | |
198 | extern int cupsdLoadEnv(char *envp[], int envmax); | |
199 | extern void cupsdSetEnv(const char *name, const char *value); | |
200 | extern void cupsdSetEnvf(const char *name, const char *value, ...) | |
85dda01c | 201 | __attribute__ ((__format__ (__printf__, 2, 3))); |
321d8d57 MS |
202 | extern void cupsdUpdateEnv(void); |
203 | ||
204 | /* file.c */ | |
205 | extern void cupsdCleanFiles(const char *path, const char *pattern); | |
206 | extern int cupsdCloseCreatedConfFile(cups_file_t *fp, | |
207 | const char *filename); | |
208 | extern void cupsdClosePipe(int *fds); | |
209 | extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode); | |
210 | extern cups_file_t *cupsdOpenConfFile(const char *filename); | |
211 | extern int cupsdOpenPipe(int *fds); | |
212 | extern int cupsdRemoveFile(const char *filename); | |
213 | ||
214 | /* main.c */ | |
215 | extern int cupsdAddString(cups_array_t **a, const char *s); | |
216 | extern void cupsdCheckProcess(void); | |
217 | extern void cupsdClearString(char **s); | |
218 | extern void cupsdFreeStrings(cups_array_t **a); | |
219 | extern void cupsdHoldSignals(void); | |
220 | extern char *cupsdMakeUUID(const char *name, int number, | |
221 | char *buffer, size_t bufsize); | |
222 | extern void cupsdReleaseSignals(void); | |
223 | extern void cupsdSetString(char **s, const char *v); | |
224 | extern void cupsdSetStringf(char **s, const char *f, ...) | |
85dda01c | 225 | __attribute__ ((__format__ (__printf__, 2, 3))); |
321d8d57 MS |
226 | |
227 | /* process.c */ | |
228 | extern void *cupsdCreateProfile(int job_id); | |
229 | extern void cupsdDestroyProfile(void *profile); | |
230 | extern int cupsdEndProcess(int pid, int force); | |
231 | extern const char *cupsdFinishProcess(int pid, char *name, int namelen, | |
232 | int *job_id); | |
233 | extern int cupsdStartProcess(const char *command, char *argv[], | |
234 | char *envp[], int infd, int outfd, | |
235 | int errfd, int backfd, int sidefd, | |
236 | int root, void *profile, | |
237 | cupsd_job_t *job, int *pid); | |
238 | ||
239 | /* select.c */ | |
240 | extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb, | |
241 | cupsd_selfunc_t write_cb, void *data); | |
242 | extern int cupsdDoSelect(long timeout); | |
f899b121 | 243 | #ifdef CUPSD_IS_SELECTING |
321d8d57 | 244 | extern int cupsdIsSelecting(int fd); |
f899b121 | 245 | #endif /* CUPSD_IS_SELECTING */ |
321d8d57 MS |
246 | extern void cupsdRemoveSelect(int fd); |
247 | extern void cupsdStartSelect(void); | |
248 | extern void cupsdStopSelect(void); | |
ef416fc2 | 249 | |
321d8d57 MS |
250 | /* server.c */ |
251 | extern void cupsdStartServer(void); | |
252 | extern void cupsdStopServer(void); | |
ef416fc2 | 253 | |
3e7fe0ca MS |
254 | #ifdef HAVE_AVAHI |
255 | extern cupsd_timeout_t *cupsdAddTimeout(const struct timeval *tv, | |
256 | cupsd_timeoutfunc_t cb, | |
257 | void *data); | |
258 | extern cupsd_timeout_t *cupsdNextTimeout(long *delay); | |
259 | extern void cupsdRemoveTimeout(cupsd_timeout_t *timeout); | |
260 | extern void cupsdRunTimeout(cupsd_timeout_t *timeout); | |
261 | extern void cupsdUpdateTimeout(cupsd_timeout_t *timeout, | |
262 | const struct timeval *tv); | |
263 | #endif /* HAVE_AVAHI */ | |
264 | ||
265 | extern int cupsdRemoveFile(const char *filename); | |
266 | ||
58dc1933 | 267 | |
ef416fc2 | 268 | /* |
b19ccc9e | 269 | * End of "$Id: cupsd.h 7928 2008-09-10 22:14:22Z mike $". |
ef416fc2 | 270 | */ |