2 * Server start/stop routines for the CUPS scheduler.
4 * Copyright 2007-2012 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
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 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * Include necessary headers...
18 #include <cups/http-private.h>
23 #endif /* HAVE_NOTIFY_H */
30 static int started
= 0; /* Did we start the server already? */
34 * 'cupsdStartServer()' - Start the server.
38 cupsdStartServer(void)
41 * Start color management (as needed)...
47 * Create the default security profile...
50 DefaultProfile
= cupsdCreateProfile(0, 1);
53 * Startup all the networking stuff...
56 cupsdStartListening();
60 * Create a pipe for CGI processes...
63 if (cupsdOpenPipe(CGIPipes
))
64 cupsdLogMessage(CUPSD_LOG_ERROR
,
65 "cupsdStartServer: Unable to create pipes for CGI status!");
68 CGIStatusBuffer
= cupsdStatBufNew(CGIPipes
[0], "[CGI]");
70 cupsdAddSelect(CGIPipes
[0], (cupsd_selfunc_t
)cupsdUpdateCGI
, NULL
, NULL
);
74 * Mark that the server has started and printers and jobs may be changed...
77 LastEvent
= CUPSD_EVENT_PRINTER_CHANGED
| CUPSD_EVENT_JOB_STATE_CHANGED
|
78 CUPSD_EVENT_SERVER_STARTED
;
86 * 'cupsdStopServer()' - Stop the server.
96 * Stop color management (as needed)...
102 * Close all network clients...
105 cupsdCloseAllClients();
106 cupsdStopListening();
108 cupsdStopAllNotifiers();
109 cupsdDeleteAllCerts();
113 cupsArrayDelete(Clients
);
118 * Close the pipe for CGI processes...
121 if (CGIPipes
[0] >= 0)
123 cupsdRemoveSelect(CGIPipes
[0]);
125 cupsdStatBufDelete(CGIStatusBuffer
);
133 * Close all log files...
136 if (AccessFile
!= NULL
)
138 if (AccessFile
!= LogStderr
)
139 cupsFileClose(AccessFile
);
144 if (ErrorFile
!= NULL
)
146 if (ErrorFile
!= LogStderr
)
147 cupsFileClose(ErrorFile
);
152 if (PageFile
!= NULL
)
154 if (PageFile
!= LogStderr
)
155 cupsFileClose(PageFile
);
161 * Delete the default security profile...
164 cupsdDestroyProfile(DefaultProfile
);
165 DefaultProfile
= NULL
;
168 * Write out any dirty files...