handleCmdLine_8c-source.html 8.22 KB
<!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: system/handleCmdLine.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&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>system/handleCmdLine.c</h1><a href="handleCmdLine_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 &lt;unistd.h&gt;</span>     <span class="comment">/* for getopt */</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#include "../include/appConfig.h"</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="keywordtype">int</span>
<a name="l00010"></a><a class="code" href="handleCmdLine_8c.html#3755d793d10d6e5793ed5086a0b22964">00010</a> <a class="code" href="appConfig_8h.html#3755d793d10d6e5793ed5086a0b22964">handleCmdLine</a>(<a class="code" href="structtAppConfig.html">tAppConfig</a> * config, <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00011"></a>00011 {
<a name="l00012"></a>00012     <span class="keywordtype">int</span> opt;
<a name="l00013"></a>00013 
<a name="l00014"></a>00014     <span class="keywordflow">while</span> ((opt = getopt(argc, argv, <span class="stringliteral">"Dvp:l:n:b:"</span>)) != -1) {
<a name="l00015"></a>00015         <span class="keywordflow">switch</span> (opt) {
<a name="l00016"></a>00016             <span class="keywordflow">case</span> <span class="charliteral">'p'</span>:
<a name="l00017"></a>00017                 <span class="comment">/* port */</span>
<a name="l00018"></a>00018                 config-&gt;<a class="code" href="structtAppConfig.html#3e4960a8eb8e1eac506bd651453faecc">port</a> = atoi(optarg);
<a name="l00019"></a>00019                 <span class="keywordflow">break</span>;
<a name="l00020"></a>00020 
<a name="l00021"></a>00021             <span class="keywordflow">case</span> <span class="charliteral">'l'</span>:
<a name="l00022"></a>00022                 <span class="comment">/* logPath */</span>
<a name="l00023"></a>00023                 strncpy(config-&gt;<a class="code" href="structtAppConfig.html#1b87fb5e17055c70a233387374d8342e">logPath</a>, optarg, <span class="keyword">sizeof</span>(config-&gt;<a class="code" href="structtAppConfig.html#1b87fb5e17055c70a233387374d8342e">logPath</a>)-1);
<a name="l00024"></a>00024                 <span class="keywordflow">break</span>;
<a name="l00025"></a>00025 
<a name="l00026"></a>00026             <span class="keywordflow">case</span> <span class="charliteral">'n'</span>:
<a name="l00027"></a>00027                 <span class="comment">/* logNamePattern */</span>
<a name="l00028"></a>00028                 strncpy(config-&gt;<a class="code" href="structtAppConfig.html#58b889074da91d9de3ef14aa34f97795">namePat</a>, optarg, <span class="keyword">sizeof</span>(config-&gt;<a class="code" href="structtAppConfig.html#58b889074da91d9de3ef14aa34f97795">namePat</a>)-1);
<a name="l00029"></a>00029                 <span class="keywordflow">break</span>;
<a name="l00030"></a>00030 
<a name="l00031"></a>00031             <span class="keywordflow">case</span> <span class="charliteral">'b'</span>:
<a name="l00032"></a>00032                 <span class="comment">/* maxPending (connection backlog) */</span>
<a name="l00033"></a>00033                 config-&gt;<a class="code" href="structtAppConfig.html#1bef5de806f77de1c307062e9fa84e4f">maxPending</a> = atoi(optarg);
<a name="l00034"></a>00034                 <span class="keywordflow">break</span>;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036             <span class="keywordflow">case</span> <span class="charliteral">'v'</span>:
<a name="l00037"></a>00037                 <span class="comment">/* verbose */</span>
<a name="l00038"></a>00038                 config-&gt;<a class="code" href="structtAppConfig.html#9a20fbb501c68675f88764f1dcb42684">verbose</a> = 1;
<a name="l00039"></a>00039                 <span class="keywordflow">break</span>;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041             <span class="keywordflow">case</span> <span class="charliteral">'D'</span>:
<a name="l00042"></a>00042                 <span class="comment">/* verbose */</span>
<a name="l00043"></a>00043                 config-&gt;<a class="code" href="structtAppConfig.html#d5d5f9bd2f4f0dd2cd259e50c4d149bf">doDaemon</a> = 1;
<a name="l00044"></a>00044                 <span class="keywordflow">break</span>;
<a name="l00045"></a>00045 
<a name="l00046"></a>00046             <span class="keywordflow">default</span>:
<a name="l00047"></a>00047                 <span class="comment">/* '?' */</span>
<a name="l00048"></a>00048                 fprintf(
<a name="l00049"></a>00049                         stderr,
<a name="l00050"></a>00050                         <span class="stringliteral">"Usage: %s [-p port] [-l logPath] [-n logNamePattern] [-c maxClient] [-b backlog] [-v] [-D]\n"</span>
<a name="l00051"></a>00051                         <span class="stringliteral">"Defaults:\n"</span>
<a name="l00052"></a>00052                         <span class="stringliteral">"\t%-20s: port this service will use [%d]\n"</span>
<a name="l00053"></a>00053                         <span class="stringliteral">"\t%-20s: path where the logfiles will be stored [%s/]\n"</span>
<a name="l00054"></a>00054                         <span class="stringliteral">"\t%-20s: patten used by strftime to create the log filename [%s]\n"</span>
<a name="l00055"></a>00055                         <span class="stringliteral">"\t%-20s: maximum connection backlog [%d]\n"</span>
<a name="l00056"></a>00056                         <span class="stringliteral">"\t%-20s: be more verbose in syslog [off]\n"</span>
<a name="l00057"></a>00057                         <span class="stringliteral">"\t%-20s: deamonize me\n"</span>,
<a name="l00058"></a>00058                         argv[0],
<a name="l00059"></a>00059                         <span class="stringliteral">"-p port"</span>, <a class="code" href="appConfig_8h.html#3db4dba8d56385b62759b89c98cae447">DEFAULTPORT</a>,
<a name="l00060"></a>00060                         <span class="stringliteral">"-l logPath"</span>, <a class="code" href="appConfig_8h.html#0672e2d34f3bbe2f6cdad6f307b9d1cf">DEFAULTPATH</a>,
<a name="l00061"></a>00061                         <span class="stringliteral">"-n logNamePattern"</span>, <a class="code" href="appConfig_8h.html#9a98b2d0f973e357020c1274ec5b56c0">LOGNAMEPATTERN</a>,
<a name="l00062"></a>00062                         <span class="stringliteral">"-b backlog"</span>, <a class="code" href="appConfig_8h.html#f77ed3e65a7b1a9341603d152a1404df">MAXPENDING</a>,
<a name="l00063"></a>00063                         <span class="stringliteral">"-v"</span>,
<a name="l00064"></a>00064                         <span class="stringliteral">"-D"</span>);
<a name="l00065"></a>00065                 exit(EXIT_FAILURE);
<a name="l00066"></a>00066         }
<a name="l00067"></a>00067     }
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     <span class="keywordflow">return</span> 0;
<a name="l00070"></a>00070 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Oct 10 01:24:35 2010 for xmlrpc by&nbsp;
<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>