serverInit_8c-source.html
6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xmlrpc: server/serverInit.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>server/serverInit.c</h1><a href="serverInit_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include <sys/select.h></span> <span class="comment">/* for select system call and related */</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include <string.h></span> <span class="comment">/* for memset and stuff */</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include <stdlib.h></span> <span class="comment">/* for getopt */</span>
<a name="l00004"></a>00004
<a name="l00005"></a>00005 <span class="preprocessor">#include "../include/server.h"</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include "../include/socket.h"</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include "../include/monitor.h"</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include "../include/logRotate.h"</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="keywordtype">void</span>
<a name="l00011"></a><a class="code" href="serverInit_8c.html#68050069ed3a2e05cb02440090c89a1f">00011</a> <a class="code" href="server_8h.html#68050069ed3a2e05cb02440090c89a1f">serverInit</a>(
<a name="l00012"></a>00012 <a class="code" href="structtServer.html">tServer</a> * server,
<a name="l00013"></a>00013 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> port,
<a name="l00014"></a>00014 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pending,
<a name="l00015"></a>00015 <span class="keyword">const</span> <span class="keywordtype">char</span> * logPath,
<a name="l00016"></a>00016 <span class="keyword">const</span> <span class="keywordtype">char</span> * namePat)
<a name="l00017"></a>00017 {
<a name="l00018"></a>00018 FD_ZERO(&(server-><a class="code" href="structtServer.html#f1e1c8e11bd347994ebc641bcac4c0fb">socks</a>));
<a name="l00019"></a>00019
<a name="l00020"></a>00020 server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a> = <a class="code" href="socket_8h.html#44dc8ffaedb1d6f7d4663f5cecaf4e70">initServerSocket</a>(port, pending);
<a name="l00021"></a>00021 server-><a class="code" href="structtServer.html#145a672dfaec08ce54c02dbc9f3b11ae">maxFd</a> = server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>;
<a name="l00022"></a>00022 FD_SET(server-><a class="code" href="structtServer.html#0f35110b14ced93ae0c47173e37d707d">servSock</a>, &(server-><a class="code" href="structtServer.html#f1e1c8e11bd347994ebc641bcac4c0fb">socks</a>));
<a name="l00023"></a>00023
<a name="l00024"></a>00024 strncpy(server-><a class="code" href="structtServer.html#17180f100090e101569a3a95934c38aa">logPath</a>, logPath, <span class="keyword">sizeof</span>(server-><a class="code" href="structtServer.html#17180f100090e101569a3a95934c38aa">logPath</a>)-1);
<a name="l00025"></a>00025 strncpy(server-><a class="code" href="structtServer.html#c932a28b0613bb0276c1ceb6b3fee454">namePat</a>, namePat, <span class="keyword">sizeof</span>(server-><a class="code" href="structtServer.html#c932a28b0613bb0276c1ceb6b3fee454">namePat</a>)-1);
<a name="l00026"></a>00026
<a name="l00027"></a>00027 memset(server-><a class="code" href="structtServer.html#1c13c660dcf97444bdeee1f52bace303">clients</a>, 0, <span class="keyword">sizeof</span>(server-><a class="code" href="structtServer.html#1c13c660dcf97444bdeee1f52bace303">clients</a>));
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="comment">/*</span>
<a name="l00030"></a>00030 <span class="comment"> * try to open file (firstrun)</span>
<a name="l00031"></a>00031 <span class="comment"> */</span>
<a name="l00032"></a>00032 <span class="keywordflow">if</span> (NULL == server-><a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>) {
<a name="l00033"></a>00033 <a class="code" href="logRotate_8h.html#82df920a9975d5484d681c6f9009da38">logRotate</a>(&(server-><a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>), server-><a class="code" href="structtServer.html#17180f100090e101569a3a95934c38aa">logPath</a>, server-><a class="code" href="structtServer.html#c932a28b0613bb0276c1ceb6b3fee454">namePat</a>);
<a name="l00034"></a>00034 <span class="keywordflow">if</span> (NULL == server-><a class="code" href="structtServer.html#8fc3e5e54d17d86d21874d5987a080af">wHandle</a>) {
<a name="l00035"></a>00035 <a class="code" href="monitor_8h.html#5d332cf84a9d6dd9c77382a74960cccf">syslogMonitor</a>(LOG_ERR, <a class="code" href="monitor_8h.html#d702c7f3311c0b76ee05d7efd27c87b2">MON_INFO</a>, <span class="stringliteral">"logfile.rotate"</span>,
<a name="l00036"></a>00036 <span class="stringliteral">"no valid handle for logfile - service terminated"</span>);
<a name="l00037"></a>00037 exit(EXIT_FAILURE);
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 }
<a name="l00040"></a>00040 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Oct 10 01:24:35 2010 for xmlrpc by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>