]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/cupsd.h
Don't stop a printer after a job is canceled/aborted (Issue #5517)
[thirdparty/cups.git] / scheduler / cupsd.h
1 /*
2 * Main header file for the CUPS scheduler.
3 *
4 * Copyright 2007-2018 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
6 *
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/".
12 */
13
14
15 /*
16 * Include necessary headers.
17 */
18
19 #include <cups/cups-private.h>
20 #include <cups/file-private.h>
21 #include <cups/ppd-private.h>
22
23 #include <limits.h>
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
39 #include "mime.h"
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
51 # ifdef hstrerror
52 # undef hstrerror
53 # endif /* hstrerror */
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
74 #define MAX_ENV 100 /* Maximum number of environment strings */
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
84 #define DEFAULT_HISTORY INT_MAX /* Preserve job history? */
85 #define DEFAULT_FILES 86400 /* Preserve job files? */
86 #define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */
87 #define DEFAULT_KEEPALIVE 30 /* Timeout between requests */
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
109 #include "sysman.h"
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"
118 #include "colorman.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 VAR int MaxFDs VALUE(0);
149 /* Maximum number of files */
150
151 VAR time_t ReloadTime VALUE(0);
152 /* Time of reload request... */
153 VAR int NeedReload VALUE(RELOAD_ALL),
154 /* Need to load configuration? */
155 DoingShutdown VALUE(0);
156 /* Shutting down the scheduler? */
157 VAR void *DefaultProfile VALUE(0);
158 /* Default security profile */
159
160 #ifdef HAVE_ONDEMAND
161 VAR int OnDemand VALUE(0);
162 /* Launched on demand */
163 #endif /* HAVE_ONDEMAND */
164
165
166 /*
167 * Prototypes...
168 */
169
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, ...) _CUPS_FORMAT(2, 3);
175 extern void cupsdUpdateEnv(void);
176
177 /* file.c */
178 extern void cupsdCleanFiles(const char *path, const char *pattern);
179 extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
180 const char *filename);
181 extern void cupsdClosePipe(int *fds);
182 extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
183 extern cups_file_t *cupsdOpenConfFile(const char *filename);
184 extern int cupsdOpenPipe(int *fds);
185 extern int cupsdRemoveFile(const char *filename);
186 extern int cupsdUnlinkOrRemoveFile(const char *filename);
187
188 /* main.c */
189 extern int cupsdAddString(cups_array_t **a, const char *s);
190 extern void cupsdCheckProcess(void);
191 extern void cupsdClearString(char **s);
192 extern void cupsdFreeStrings(cups_array_t **a);
193 extern void cupsdHoldSignals(void);
194 extern char *cupsdMakeUUID(const char *name, int number,
195 char *buffer, size_t bufsize);
196 extern void cupsdReleaseSignals(void);
197 extern void cupsdSetString(char **s, const char *v);
198 extern void cupsdSetStringf(char **s, const char *f, ...) _CUPS_FORMAT(2, 3);
199
200 /* process.c */
201 extern void *cupsdCreateProfile(int job_id, int allow_networking);
202 extern void cupsdDestroyProfile(void *profile);
203 extern int cupsdEndProcess(int pid, int force);
204 extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id);
205 extern int cupsdStartProcess(const char *command, char *argv[],
206 char *envp[], int infd, int outfd,
207 int errfd, int backfd, int sidefd,
208 int root, void *profile,
209 cupsd_job_t *job, int *pid);
210
211 /* select.c */
212 extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
213 cupsd_selfunc_t write_cb, void *data);
214 extern int cupsdDoSelect(long timeout);
215 #ifdef CUPSD_IS_SELECTING
216 extern int cupsdIsSelecting(int fd);
217 #endif /* CUPSD_IS_SELECTING */
218 extern void cupsdRemoveSelect(int fd);
219 extern void cupsdStartSelect(void);
220 extern void cupsdStopSelect(void);
221
222 /* server.c */
223 extern void cupsdStartServer(void);
224 extern void cupsdStopServer(void);