]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/cupsd.h
aaf9b13c01d3e40f32946c374374174cc8a9ce0e
[thirdparty/cups.git] / scheduler / cupsd.h
1 /*
2 * "$Id: cupsd.h 7928 2008-09-10 22:14:22Z mike $"
3 *
4 * Main header file for the CUPS scheduler.
5 *
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
8 *
9 * These coded instructions, statements, and computer programs are the
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 * "LICENSE" which should have been included with this file. If this
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 */
15
16
17 /*
18 * Include necessary headers.
19 */
20
21 #include <cups/cups-private.h>
22 #include <cups/file-private.h>
23
24 #include <limits.h>
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
40 #include "mime.h"
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
52 # ifdef hstrerror
53 # undef hstrerror
54 # endif /* hstrerror */
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
75 #define MAX_ENV 100 /* Maximum number of environment strings */
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 INT_MAX /* Preserve job history? */
86 #define DEFAULT_FILES 86400 /* Preserve job files? */
87 #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */
88 #define DEFAULT_KEEPALIVE 30 /* Timeout between requests */
89
90
91 /*
92 * Global variable macros...
93 */
94
95 #ifdef _MAIN_C_
96 # define VAR
97 # define VALUE(x) =x
98 # define VALUE2(x,y) ={x,y}
99 #else
100 # define VAR extern
101 # define VALUE(x)
102 # define VALUE2(x,y)
103 #endif /* _MAIN_C */
104
105
106 /*
107 * Other stuff for the scheduler...
108 */
109
110 #include "sysman.h"
111 #include "statbuf.h"
112 #include "cert.h"
113 #include "auth.h"
114 #include "client.h"
115 #include "policy.h"
116 #include "printers.h"
117 #include "classes.h"
118 #include "job.h"
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
135 /*
136 * Select callback function type...
137 */
138
139 typedef void (*cupsd_selfunc_t)(void *data);
140
141
142 /*
143 * Globals...
144 */
145
146 VAR int TestConfigFile VALUE(0),
147 /* Test the cupsd.conf file? */
148 UseProfiles VALUE(1);
149 /* Use security profiles for child procs? */
150 VAR int MaxFDs VALUE(0);
151 /* Maximum number of files */
152
153 VAR time_t ReloadTime VALUE(0);
154 /* Time of reload request... */
155 VAR int NeedReload VALUE(RELOAD_ALL),
156 /* Need to load configuration? */
157 DoingShutdown VALUE(0);
158 /* Shutting down the scheduler? */
159 VAR void *DefaultProfile VALUE(0);
160 /* Default security profile */
161
162 #ifdef HAVE_GSSAPI
163 VAR int KerberosInitialized VALUE(0);
164 /* Has Kerberos been initialized? */
165 VAR krb5_context KerberosContext VALUE(NULL);
166 /* Kerberos context for credentials */
167 #endif /* HAVE_GSSAPI */
168
169 #ifdef HAVE_LAUNCH_H
170 VAR int Launchd VALUE(0);
171 /* Running from launchd */
172 #endif /* HAVE_LAUNCH_H */
173
174
175 /*
176 * Prototypes...
177 */
178
179 /* env.c */
180 extern void cupsdInitEnv(void);
181 extern int cupsdLoadEnv(char *envp[], int envmax);
182 extern void cupsdSetEnv(const char *name, const char *value);
183 extern void cupsdSetEnvf(const char *name, const char *value, ...)
184 __attribute__ ((__format__ (__printf__, 2, 3)));
185 extern void cupsdUpdateEnv(void);
186
187 /* file.c */
188 extern void cupsdCleanFiles(const char *path, const char *pattern);
189 extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
190 const char *filename);
191 extern void cupsdClosePipe(int *fds);
192 extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
193 extern cups_file_t *cupsdOpenConfFile(const char *filename);
194 extern int cupsdOpenPipe(int *fds);
195 extern int cupsdRemoveFile(const char *filename);
196
197 /* main.c */
198 extern int cupsdAddString(cups_array_t **a, const char *s);
199 extern void cupsdCheckProcess(void);
200 extern void cupsdClearString(char **s);
201 extern void cupsdFreeStrings(cups_array_t **a);
202 extern void cupsdHoldSignals(void);
203 extern char *cupsdMakeUUID(const char *name, int number,
204 char *buffer, size_t bufsize);
205 extern void cupsdReleaseSignals(void);
206 extern void cupsdSetString(char **s, const char *v);
207 extern void cupsdSetStringf(char **s, const char *f, ...)
208 __attribute__ ((__format__ (__printf__, 2, 3)));
209
210 /* process.c */
211 extern void *cupsdCreateProfile(int job_id);
212 extern void cupsdDestroyProfile(void *profile);
213 extern int cupsdEndProcess(int pid, int force);
214 extern const char *cupsdFinishProcess(int pid, char *name, int namelen,
215 int *job_id);
216 extern int cupsdStartProcess(const char *command, char *argv[],
217 char *envp[], int infd, int outfd,
218 int errfd, int backfd, int sidefd,
219 int root, void *profile,
220 cupsd_job_t *job, int *pid);
221
222 /* select.c */
223 extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
224 cupsd_selfunc_t write_cb, void *data);
225 extern int cupsdDoSelect(long timeout);
226 #ifdef CUPSD_IS_SELECTING
227 extern int cupsdIsSelecting(int fd);
228 #endif /* CUPSD_IS_SELECTING */
229 extern void cupsdRemoveSelect(int fd);
230 extern void cupsdStartSelect(void);
231 extern void cupsdStopSelect(void);
232
233 /* server.c */
234 extern void cupsdStartServer(void);
235 extern void cupsdStopServer(void);
236
237
238 /*
239 * End of "$Id: cupsd.h 7928 2008-09-10 22:14:22Z mike $".
240 */