]>
Commit | Line | Data |
---|---|---|
89db771d | 1 | /* |
997fbfa7 | 2 | * "$Id: server.c,v 1.5 2002/12/17 19:00:18 swdev Exp $" |
89db771d | 3 | * |
4 | * Server start/stop routines for the Common UNIX Printing System (CUPS). | |
5 | * | |
997fbfa7 | 6 | * Copyright 1997-2003 by Easy Software Products, all rights reserved. |
89db771d | 7 | * |
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 | |
13 | * at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636-3111 USA | |
19 | * | |
20 | * Voice: (301) 373-9603 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * Contents: | |
25 | * | |
26 | * StartServer() - Start the server. | |
27 | * StopServer() - Stop the server. | |
28 | */ | |
29 | ||
30 | /* | |
31 | * Include necessary headers... | |
32 | */ | |
33 | ||
34 | #include "cupsd.h" | |
35 | ||
7a91f14b | 36 | #include <grp.h> |
37 | ||
89db771d | 38 | #ifdef HAVE_LIBSSL |
39 | # include <openssl/ssl.h> | |
40 | # include <openssl/rand.h> | |
41 | #endif /* HAVE_LIBSSL */ | |
42 | ||
43 | ||
44 | /* | |
45 | * 'StartServer()' - Start the server. | |
46 | */ | |
47 | ||
48 | void | |
49 | StartServer(void) | |
50 | { | |
51 | #ifdef HAVE_LIBSSL | |
52 | int i; /* Looping var */ | |
53 | struct timeval curtime; /* Current time in microseconds */ | |
54 | unsigned char data[1024]; /* Seed data */ | |
55 | #endif /* HAVE_LIBSSL */ | |
56 | ||
57 | ||
58 | #ifdef HAVE_LIBSSL | |
59 | /* | |
60 | * Initialize the encryption libraries... | |
61 | */ | |
62 | ||
63 | SSL_library_init(); | |
64 | SSL_load_error_strings(); | |
65 | ||
66 | /* | |
67 | * Using the current time is a dubious random seed, but on some systems | |
68 | * it is the best we can do (on others, this seed isn't even used...) | |
69 | */ | |
70 | ||
71 | gettimeofday(&curtime, NULL); | |
72 | srand(curtime.tv_sec + curtime.tv_usec); | |
73 | ||
74 | for (i = 0; i < sizeof(data); i ++) | |
75 | data[i] = rand(); /* Yes, this is a poor source of random data... */ | |
76 | ||
77 | RAND_seed(&data, sizeof(data)); | |
78 | #endif /* HAVE_LIBSSL */ | |
79 | ||
80 | /* | |
81 | * Startup all the networking stuff... | |
82 | */ | |
83 | ||
84 | StartListening(); | |
85 | StartBrowsing(); | |
86 | StartPolling(); | |
89db771d | 87 | } |
88 | ||
89 | ||
90 | /* | |
91 | * 'StopServer()' - Stop the server. | |
92 | */ | |
93 | ||
94 | void | |
95 | StopServer(void) | |
96 | { | |
97 | /* | |
98 | * Close all network clients and stop all jobs... | |
99 | */ | |
100 | ||
101 | CloseAllClients(); | |
102 | StopListening(); | |
103 | StopPolling(); | |
104 | StopBrowsing(); | |
105 | ||
106 | if (Clients != NULL) | |
107 | { | |
108 | free(Clients); | |
109 | Clients = NULL; | |
110 | } | |
111 | ||
112 | StopAllJobs(); | |
113 | ||
114 | /* | |
115 | * Close all log files... | |
116 | */ | |
117 | ||
118 | if (AccessFile != NULL) | |
119 | { | |
120 | fclose(AccessFile); | |
121 | ||
122 | AccessFile = NULL; | |
123 | } | |
124 | ||
125 | if (ErrorFile != NULL) | |
126 | { | |
127 | fclose(ErrorFile); | |
128 | ||
129 | ErrorFile = NULL; | |
130 | } | |
131 | ||
132 | if (PageFile != NULL) | |
133 | { | |
134 | fclose(PageFile); | |
135 | ||
136 | PageFile = NULL; | |
137 | } | |
138 | ||
139 | /* | |
140 | * Clear the input and output sets... | |
141 | */ | |
142 | ||
143 | FD_ZERO(&InputSet); | |
144 | FD_ZERO(&OutputSet); | |
145 | } | |
146 | ||
147 | ||
148 | /* | |
997fbfa7 | 149 | * End of "$Id: server.c,v 1.5 2002/12/17 19:00:18 swdev Exp $". |
89db771d | 150 | */ |