]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/cupsd.h
The scheduler did not return non-shared printers to local clients unless
[thirdparty/cups.git] / scheduler / cupsd.h
1 /*
2 * "$Id$"
3 *
4 * Main header file for the CUPS scheduler.
5 *
6 * Copyright 2007-2014 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 #include <cups/ppd-private.h>
24
25 #include <limits.h>
26 #include <time.h>
27 #include <signal.h>
28 #include <fcntl.h>
29 #include <math.h>
30 #include <sys/types.h>
31 #include <sys/time.h>
32 #include <sys/stat.h>
33 #include <sys/wait.h>
34
35 #ifdef WIN32
36 # include <direct.h>
37 #else
38 # include <unistd.h>
39 #endif /* WIN32 */
40
41 #include "mime.h"
42
43 #if defined(HAVE_CDSASSL)
44 # include <CoreFoundation/CoreFoundation.h>
45 #endif /* HAVE_CDSASSL */
46
47
48 /*
49 * Some OS's don't have hstrerror(), most notably Solaris...
50 */
51
52 #ifndef HAVE_HSTRERROR
53 # ifdef hstrerror
54 # undef hstrerror
55 # endif /* hstrerror */
56 # define hstrerror cups_hstrerror
57
58 extern const char *cups_hstrerror(int);
59 #endif /* !HAVE_HSTRERROR */
60
61
62 /*
63 * Common constants.
64 */
65
66 #ifndef FALSE
67 # define FALSE 0
68 # define TRUE (!FALSE)
69 #endif /* !FALSE */
70
71
72 /*
73 * Implementation limits...
74 */
75
76 #define MAX_ENV 100 /* Maximum number of environment strings */
77 #define MAX_USERPASS 33 /* Maximum size of username/password */
78 #define MAX_FILTERS 20 /* Maximum number of filters */
79 #define MAX_SYSTEM_GROUPS 32 /* Maximum number of system groups */
80
81
82 /*
83 * Defaults...
84 */
85
86 #define DEFAULT_HISTORY INT_MAX /* Preserve job history? */
87 #define DEFAULT_FILES 86400 /* Preserve job files? */
88 #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */
89 #define DEFAULT_KEEPALIVE 30 /* Timeout between requests */
90
91
92 /*
93 * Global variable macros...
94 */
95
96 #ifdef _MAIN_C_
97 # define VAR
98 # define VALUE(x) =x
99 # define VALUE2(x,y) ={x,y}
100 #else
101 # define VAR extern
102 # define VALUE(x)
103 # define VALUE2(x,y)
104 #endif /* _MAIN_C */
105
106
107 /*
108 * Other stuff for the scheduler...
109 */
110
111 #include "sysman.h"
112 #include "statbuf.h"
113 #include "cert.h"
114 #include "auth.h"
115 #include "client.h"
116 #include "policy.h"
117 #include "printers.h"
118 #include "classes.h"
119 #include "job.h"
120 #include "colorman.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
137 /*
138 * Select callback function type...
139 */
140
141 typedef void (*cupsd_selfunc_t)(void *data);
142
143
144 /*
145 * Globals...
146 */
147
148 VAR int TestConfigFile VALUE(0);
149 /* Test the cupsd.conf file? */
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 #if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
163 VAR int OnDemand VALUE(0);
164 /* Launched on demand */
165 #endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
166
167
168 /*
169 * Prototypes...
170 */
171
172 /* env.c */
173 extern void cupsdInitEnv(void);
174 extern int cupsdLoadEnv(char *envp[], int envmax);
175 extern void cupsdSetEnv(const char *name, const char *value);
176 extern void cupsdSetEnvf(const char *name, const char *value, ...)
177 __attribute__ ((__format__ (__printf__, 2, 3)));
178 extern void cupsdUpdateEnv(void);
179
180 /* file.c */
181 extern void cupsdCleanFiles(const char *path, const char *pattern);
182 extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
183 const char *filename);
184 extern void cupsdClosePipe(int *fds);
185 extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
186 extern cups_file_t *cupsdOpenConfFile(const char *filename);
187 extern int cupsdOpenPipe(int *fds);
188 extern int cupsdRemoveFile(const char *filename);
189 extern int cupsdUnlinkOrRemoveFile(const char *filename);
190
191 /* main.c */
192 extern int cupsdAddString(cups_array_t **a, const char *s);
193 extern void cupsdCheckProcess(void);
194 extern void cupsdClearString(char **s);
195 extern void cupsdFreeStrings(cups_array_t **a);
196 extern void cupsdHoldSignals(void);
197 extern char *cupsdMakeUUID(const char *name, int number,
198 char *buffer, size_t bufsize);
199 extern void cupsdReleaseSignals(void);
200 extern void cupsdSetString(char **s, const char *v);
201 extern void cupsdSetStringf(char **s, const char *f, ...)
202 __attribute__ ((__format__ (__printf__, 2, 3)));
203
204 /* process.c */
205 extern void *cupsdCreateProfile(int job_id, int allow_networking);
206 extern void cupsdDestroyProfile(void *profile);
207 extern int cupsdEndProcess(int pid, int force);
208 extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id);
209 extern int cupsdStartProcess(const char *command, char *argv[],
210 char *envp[], int infd, int outfd,
211 int errfd, int backfd, int sidefd,
212 int root, void *profile,
213 cupsd_job_t *job, int *pid);
214
215 /* select.c */
216 extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
217 cupsd_selfunc_t write_cb, void *data);
218 extern int cupsdDoSelect(long timeout);
219 #ifdef CUPSD_IS_SELECTING
220 extern int cupsdIsSelecting(int fd);
221 #endif /* CUPSD_IS_SELECTING */
222 extern void cupsdRemoveSelect(int fd);
223 extern void cupsdStartSelect(void);
224 extern void cupsdStopSelect(void);
225
226 /* server.c */
227 extern void cupsdStartServer(void);
228 extern void cupsdStopServer(void);
229
230
231 /*
232 * End of "$Id$".
233 */