]> git.ipfire.org Git - thirdparty/cups.git/blame_incremental - scheduler/cupsd.h
Fix time_at_xxx substitutions in jobs template (Issue #4041)
[thirdparty/cups.git] / scheduler / cupsd.h
... / ...
CommitLineData
1/*
2 * Main header file for the CUPS scheduler.
3 *
4 * Copyright 2007-2014 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
56extern 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
139typedef void (*cupsd_selfunc_t)(void *data);
140
141
142/*
143 * Globals...
144 */
145
146VAR int TestConfigFile VALUE(0);
147 /* Test the cupsd.conf file? */
148VAR int MaxFDs VALUE(0);
149 /* Maximum number of files */
150
151VAR time_t ReloadTime VALUE(0);
152 /* Time of reload request... */
153VAR int NeedReload VALUE(RELOAD_ALL),
154 /* Need to load configuration? */
155 DoingShutdown VALUE(0);
156 /* Shutting down the scheduler? */
157VAR void *DefaultProfile VALUE(0);
158 /* Default security profile */
159
160#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
161VAR int OnDemand VALUE(0);
162 /* Launched on demand */
163#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
164
165
166/*
167 * Prototypes...
168 */
169
170/* env.c */
171extern void cupsdInitEnv(void);
172extern int cupsdLoadEnv(char *envp[], int envmax);
173extern void cupsdSetEnv(const char *name, const char *value);
174extern void cupsdSetEnvf(const char *name, const char *value, ...)
175 __attribute__ ((__format__ (__printf__, 2, 3)));
176extern void cupsdUpdateEnv(void);
177
178/* file.c */
179extern void cupsdCleanFiles(const char *path, const char *pattern);
180extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
181 const char *filename);
182extern void cupsdClosePipe(int *fds);
183extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
184extern cups_file_t *cupsdOpenConfFile(const char *filename);
185extern int cupsdOpenPipe(int *fds);
186extern int cupsdRemoveFile(const char *filename);
187extern int cupsdUnlinkOrRemoveFile(const char *filename);
188
189/* main.c */
190extern int cupsdAddString(cups_array_t **a, const char *s);
191extern void cupsdCheckProcess(void);
192extern void cupsdClearString(char **s);
193extern void cupsdFreeStrings(cups_array_t **a);
194extern void cupsdHoldSignals(void);
195extern char *cupsdMakeUUID(const char *name, int number,
196 char *buffer, size_t bufsize);
197extern void cupsdReleaseSignals(void);
198extern void cupsdSetString(char **s, const char *v);
199extern void cupsdSetStringf(char **s, const char *f, ...)
200 __attribute__ ((__format__ (__printf__, 2, 3)));
201
202/* process.c */
203extern void *cupsdCreateProfile(int job_id, int allow_networking);
204extern void cupsdDestroyProfile(void *profile);
205extern int cupsdEndProcess(int pid, int force);
206extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id);
207extern 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 */
214extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
215 cupsd_selfunc_t write_cb, void *data);
216extern int cupsdDoSelect(long timeout);
217#ifdef CUPSD_IS_SELECTING
218extern int cupsdIsSelecting(int fd);
219#endif /* CUPSD_IS_SELECTING */
220extern void cupsdRemoveSelect(int fd);
221extern void cupsdStartSelect(void);
222extern void cupsdStopSelect(void);
223
224/* server.c */
225extern void cupsdStartServer(void);
226extern void cupsdStopServer(void);