]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/cupsd.h
Do some code reorganization so that all of the PPD code is separate from the rest.
[thirdparty/cups.git] / scheduler / cupsd.h
CommitLineData
ef416fc2 1/*
f2d18633 2 * "$Id$"
ef416fc2 3 *
8fe0183a 4 * Main header file for the CUPS scheduler.
ef416fc2 5 *
8fe0183a
MS
6 * Copyright 2007-2014 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8 *
8fe0183a
MS
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/".
ef416fc2 14 */
15
16
17/*
18 * Include necessary headers.
19 */
20
71e16022 21#include <cups/cups-private.h>
22c9029b 22#include <cups/file-private.h>
f787e1e3 23#include <cups/ppd-private.h>
71e16022 24
ef416fc2 25#include <limits.h>
ef416fc2 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
ef416fc2 41#include "mime.h"
ef416fc2 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
b423cd4c 53# ifdef hstrerror
54# undef hstrerror
55# endif /* hstrerror */
ef416fc2 56# define hstrerror cups_hstrerror
57
58extern 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
e00b005a 76#define MAX_ENV 100 /* Maximum number of environment strings */
ef416fc2 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
82cc1f9a
MS
86#define DEFAULT_HISTORY INT_MAX /* Preserve job history? */
87#define DEFAULT_FILES 86400 /* Preserve job files? */
ef416fc2 88#define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */
49d87452 89#define DEFAULT_KEEPALIVE 30 /* Timeout between requests */
ef416fc2 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
09ec0018 111#include "sysman.h"
ef416fc2 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"
a29fd7dd 120#include "colorman.h"
ef416fc2 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
f7deaa1a 137/*
138 * Select callback function type...
139 */
140
141typedef void (*cupsd_selfunc_t)(void *data);
142
143
ef416fc2 144/*
145 * Globals...
146 */
147
8fe0183a 148VAR int TestConfigFile VALUE(0);
2e4ff8af 149 /* Test the cupsd.conf file? */
ac884b6a
MS
150VAR int MaxFDs VALUE(0);
151 /* Maximum number of files */
ef416fc2 152
153VAR time_t ReloadTime VALUE(0);
154 /* Time of reload request... */
7cf5915e 155VAR int NeedReload VALUE(RELOAD_ALL),
ef416fc2 156 /* Need to load configuration? */
7cf5915e
MS
157 DoingShutdown VALUE(0);
158 /* Shutting down the scheduler? */
a4924f6c
MS
159VAR void *DefaultProfile VALUE(0);
160 /* Default security profile */
c24d2134 161
1720786e
MS
162#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
163VAR int OnDemand VALUE(0);
164 /* Launched on demand */
165#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
ef416fc2 166
167
168/*
169 * Prototypes...
170 */
171
321d8d57
MS
172/* env.c */
173extern void cupsdInitEnv(void);
174extern int cupsdLoadEnv(char *envp[], int envmax);
175extern void cupsdSetEnv(const char *name, const char *value);
176extern void cupsdSetEnvf(const char *name, const char *value, ...)
85dda01c 177 __attribute__ ((__format__ (__printf__, 2, 3)));
321d8d57
MS
178extern void cupsdUpdateEnv(void);
179
180/* file.c */
181extern void cupsdCleanFiles(const char *path, const char *pattern);
182extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
183 const char *filename);
184extern void cupsdClosePipe(int *fds);
185extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
186extern cups_file_t *cupsdOpenConfFile(const char *filename);
187extern int cupsdOpenPipe(int *fds);
188extern int cupsdRemoveFile(const char *filename);
cb7f98ee 189extern int cupsdUnlinkOrRemoveFile(const char *filename);
321d8d57
MS
190
191/* main.c */
192extern int cupsdAddString(cups_array_t **a, const char *s);
193extern void cupsdCheckProcess(void);
194extern void cupsdClearString(char **s);
195extern void cupsdFreeStrings(cups_array_t **a);
196extern void cupsdHoldSignals(void);
197extern char *cupsdMakeUUID(const char *name, int number,
198 char *buffer, size_t bufsize);
199extern void cupsdReleaseSignals(void);
200extern void cupsdSetString(char **s, const char *v);
201extern void cupsdSetStringf(char **s, const char *f, ...)
85dda01c 202 __attribute__ ((__format__ (__printf__, 2, 3)));
321d8d57
MS
203
204/* process.c */
8fe0183a 205extern void *cupsdCreateProfile(int job_id, int allow_networking);
321d8d57
MS
206extern void cupsdDestroyProfile(void *profile);
207extern int cupsdEndProcess(int pid, int force);
07623986 208extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id);
321d8d57
MS
209extern 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 */
216extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
217 cupsd_selfunc_t write_cb, void *data);
218extern int cupsdDoSelect(long timeout);
f899b121 219#ifdef CUPSD_IS_SELECTING
321d8d57 220extern int cupsdIsSelecting(int fd);
f899b121 221#endif /* CUPSD_IS_SELECTING */
321d8d57
MS
222extern void cupsdRemoveSelect(int fd);
223extern void cupsdStartSelect(void);
224extern void cupsdStopSelect(void);
ef416fc2 225
321d8d57
MS
226/* server.c */
227extern void cupsdStartServer(void);
228extern void cupsdStopServer(void);
ef416fc2 229
58dc1933 230
ef416fc2 231/*
f2d18633 232 * End of "$Id$".
ef416fc2 233 */