2 * "$Id: server.c 7927 2008-09-10 22:05:29Z mike $"
4 * Server start/stop routines for the CUPS scheduler.
6 * Copyright 2007-2010 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 * Create the default security profile...
51 DefaultProfile
= cupsdCreateProfile(0);
54 * Startup all the networking stuff...
57 cupsdStartListening();
61 * Create a pipe for CGI processes...
64 if (cupsdOpenPipe(CGIPipes
))
65 cupsdLogMessage(CUPSD_LOG_ERROR
,
66 "cupsdStartServer: Unable to create pipes for CGI status!");
69 CGIStatusBuffer
= cupsdStatBufNew(CGIPipes
[0], "[CGI]");
71 cupsdAddSelect(CGIPipes
[0], (cupsd_selfunc_t
)cupsdUpdateCGI
, NULL
, NULL
);
75 * Mark that the server has started and printers and jobs may be changed...
78 LastEvent
= CUPSD_EVENT_PRINTER_CHANGED
| CUPSD_EVENT_JOB_STATE_CHANGED
|
79 CUPSD_EVENT_SERVER_STARTED
;
87 * 'cupsdStopServer()' - Stop the server.
97 * Close all network clients and stop all jobs...
100 cupsdCloseAllClients();
101 cupsdStopListening();
103 cupsdStopAllNotifiers();
104 cupsdDeleteAllCerts();
108 cupsArrayDelete(Clients
);
113 * Close the pipe for CGI processes...
116 if (CGIPipes
[0] >= 0)
118 cupsdRemoveSelect(CGIPipes
[0]);
120 cupsdStatBufDelete(CGIStatusBuffer
);
127 #ifdef HAVE_NOTIFY_POST
129 * Send one last notification as the server shuts down.
132 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
133 "notify_post(\"com.apple.printerListChange\") last");
134 notify_post("com.apple.printerListChange");
135 #endif /* HAVE_NOTIFY_POST */
138 * Close all log files...
141 if (AccessFile
!= NULL
)
143 cupsFileClose(AccessFile
);
148 if (ErrorFile
!= NULL
)
150 cupsFileClose(ErrorFile
);
155 if (PageFile
!= NULL
)
157 cupsFileClose(PageFile
);
163 * Delete the default security profile...
166 cupsdDestroyProfile(DefaultProfile
);
167 DefaultProfile
= NULL
;
170 * Write out any dirty files...
181 * End of "$Id: server.c 7927 2008-09-10 22:05:29Z mike $".