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