2 * "$Id: server.c 11576 2014-02-11 15:06:01Z msweet $"
4 * Server start/stop routines for the CUPS scheduler.
6 * Copyright 2007-2012 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
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 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdStartServer() - Start the server.
18 * cupsdStopServer() - Stop the server.
22 * Include necessary headers...
25 #include <cups/http-private.h>
30 #endif /* HAVE_NOTIFY_H */
37 static int started
= 0; /* Did we start the server already? */
41 * 'cupsdStartServer()' - Start the server.
45 cupsdStartServer(void)
48 * Start color management (as needed)...
54 * Create the default security profile...
57 DefaultProfile
= cupsdCreateProfile(0, 1);
60 * Startup all the networking stuff...
63 cupsdStartListening();
67 * Create a pipe for CGI processes...
70 if (cupsdOpenPipe(CGIPipes
))
71 cupsdLogMessage(CUPSD_LOG_ERROR
,
72 "cupsdStartServer: Unable to create pipes for CGI status!");
75 CGIStatusBuffer
= cupsdStatBufNew(CGIPipes
[0], "[CGI]");
77 cupsdAddSelect(CGIPipes
[0], (cupsd_selfunc_t
)cupsdUpdateCGI
, NULL
, NULL
);
81 * Mark that the server has started and printers and jobs may be changed...
84 LastEvent
= CUPSD_EVENT_PRINTER_CHANGED
| CUPSD_EVENT_JOB_STATE_CHANGED
|
85 CUPSD_EVENT_SERVER_STARTED
;
93 * 'cupsdStopServer()' - Stop the server.
103 * Stop color management (as needed)...
109 * Close all network clients...
112 cupsdCloseAllClients();
113 cupsdStopListening();
115 cupsdStopAllNotifiers();
116 cupsdDeleteAllCerts();
120 cupsArrayDelete(Clients
);
125 * Close the pipe for CGI processes...
128 if (CGIPipes
[0] >= 0)
130 cupsdRemoveSelect(CGIPipes
[0]);
132 cupsdStatBufDelete(CGIStatusBuffer
);
140 * Close all log files...
143 if (AccessFile
!= NULL
)
145 cupsFileClose(AccessFile
);
150 if (ErrorFile
!= NULL
)
152 cupsFileClose(ErrorFile
);
157 if (PageFile
!= NULL
)
159 cupsFileClose(PageFile
);
165 * Delete the default security profile...
168 cupsdDestroyProfile(DefaultProfile
);
169 DefaultProfile
= NULL
;
172 * Write out any dirty files...
183 * End of "$Id: server.c 11576 2014-02-11 15:06:01Z msweet $".