]>
git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/server.c
2 * "$Id: server.c 4830 2005-11-12 03:27:16Z mike $"
4 * Server start/stop routines for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * cupsdStartServer() - Start the server.
27 * cupsdStopServer() - Stop the server.
31 * Include necessary headers...
34 #include <cups/http-private.h>
43 static int started
= 0;
47 * 'cupsdStartServer()' - Start the server.
51 cupsdStartServer(void)
54 int i
; /* Looping var */
55 struct timeval curtime
; /* Current time in microseconds */
56 unsigned char data
[1024]; /* Seed data */
57 #endif /* HAVE_LIBSSL */
62 * Initialize the encryption libraries...
66 SSL_load_error_strings();
69 * Using the current time is a dubious random seed, but on some systems
70 * it is the best we can do (on others, this seed isn't even used...)
73 gettimeofday(&curtime
, NULL
);
74 srand(curtime
.tv_sec
+ curtime
.tv_usec
);
76 for (i
= 0; i
< sizeof(data
); i
++)
77 data
[i
] = rand(); /* Yes, this is a poor source of random data... */
79 RAND_seed(&data
, sizeof(data
));
80 #elif defined(HAVE_GNUTLS)
82 * Initialize the encryption libraries...
86 #endif /* HAVE_LIBSSL */
89 * Startup all the networking stuff...
92 cupsdStartListening();
97 * Create a pipe for CGI processes...
100 if (cupsdOpenPipe(CGIPipes
))
101 cupsdLogMessage(CUPSD_LOG_ERROR
,
102 "cupsdStartServer: Unable to create pipes for CGI status!");
105 CGIStatusBuffer
= cupsdStatBufNew(CGIPipes
[0], "[CGI]");
107 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
108 "cupsdStartServer: Adding fd %d to InputSet...",
110 FD_SET(CGIPipes
[0], InputSet
);
118 * 'cupsdStopServer()' - Stop the server.
122 cupsdStopServer(void)
128 * Close all network clients and stop all jobs...
131 cupsdCloseAllClients();
132 cupsdStopListening();
135 cupsdStopAllNotifiers();
136 cupsdSaveRemoteCache();
144 #if defined(HAVE_SSL) && defined(HAVE_CDSASSL)
146 * Free all of the certificates...
149 if (ServerCertificatesArray
)
151 CFRelease(ServerCertificatesArray
);
152 ServerCertificatesArray
= NULL
;
154 #endif /* HAVE_SSL && HAVE_CDSASSL */
157 * Close the pipe for CGI processes...
160 if (CGIPipes
[0] >= 0)
162 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
163 "cupsdStopServer: Removing fd %d from InputSet...",
166 FD_CLR(CGIPipes
[0], InputSet
);
168 cupsdStatBufDelete(CGIStatusBuffer
);
176 * Close all log files...
179 if (AccessFile
!= NULL
)
181 cupsFileClose(AccessFile
);
186 if (ErrorFile
!= NULL
)
188 cupsFileClose(ErrorFile
);
193 if (PageFile
!= NULL
)
195 cupsFileClose(PageFile
);
205 * End of "$Id: server.c 4830 2005-11-12 03:27:16Z mike $".