2 * Server start/stop routines for the CUPS scheduler.
4 * Copyright 2007-2017 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include <cups/http-private.h>
19 #endif /* HAVE_NOTIFY_H */
26 static int started
= 0; /* Did we start the server already? */
30 * 'cupsdStartServer()' - Start the server.
34 cupsdStartServer(void)
37 * Start color management (as needed)...
43 * Create the default security profile...
46 DefaultProfile
= cupsdCreateProfile(0, 1);
49 * Startup all the networking stuff...
52 cupsdStartListening();
56 * Create a pipe for CGI processes...
59 if (cupsdOpenPipe(CGIPipes
))
60 cupsdLogMessage(CUPSD_LOG_ERROR
,
61 "cupsdStartServer: Unable to create pipes for CGI status!");
64 CGIStatusBuffer
= cupsdStatBufNew(CGIPipes
[0], "[CGI]");
66 cupsdAddSelect(CGIPipes
[0], (cupsd_selfunc_t
)cupsdUpdateCGI
, NULL
, NULL
);
70 * Mark that the server has started and printers and jobs may be changed...
73 LastEvent
= CUPSD_EVENT_PRINTER_CHANGED
| CUPSD_EVENT_JOB_STATE_CHANGED
|
74 CUPSD_EVENT_SERVER_STARTED
;
82 * 'cupsdStopServer()' - Stop the server.
92 * Stop color management (as needed)...
98 * Close all network clients...
101 cupsdCloseAllClients();
102 cupsdStopListening();
104 cupsdStopAllNotifiers();
105 cupsdDeleteAllCerts();
109 cupsArrayDelete(Clients
);
114 * Close the pipe for CGI processes...
117 if (CGIPipes
[0] >= 0)
119 cupsdRemoveSelect(CGIPipes
[0]);
121 cupsdStatBufDelete(CGIStatusBuffer
);
129 * Close all log files...
132 if (AccessFile
!= NULL
)
134 if (AccessFile
!= LogStderr
)
135 cupsFileClose(AccessFile
);
140 if (ErrorFile
!= NULL
)
142 if (ErrorFile
!= LogStderr
)
143 cupsFileClose(ErrorFile
);
148 if (PageFile
!= NULL
)
150 if (PageFile
!= LogStderr
)
151 cupsFileClose(PageFile
);
157 * Delete the default security profile...
160 cupsdDestroyProfile(DefaultProfile
);
161 DefaultProfile
= NULL
;
164 * Write out any dirty files...