fixed a small bug in eval ehrhart
[polylib.git] / doc / codeDoc / html / param_8c-source.html
blobb06a6cbda67eb8f507108952eba8d1470f70ad2f
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>param.c Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.2.15 -->
7 <center>
8 <a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
9 <hr><h1>param.c</h1><a href="param_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
10 00002 <font class="preprocessor">#include &lt;string.h&gt;</font>
11 00003
12 00004 <font class="preprocessor">#include &lt;polylib/polylib.h&gt;</font>
13 00005
14 00006 <font class="comment">/****************************************************/</font>
15 00007 <font class="comment">/* Read_ParamNames() : */</font>
16 00008 <font class="comment">/* Reads FILE *in for the parameter names */</font>
17 00009 <font class="comment">/* if in==NULL or not enough parameters on input, */</font>
18 00010 <font class="comment">/* use default names */</font>
19 00011 <font class="comment">/* returns an n-array of strings */</font>
20 00012 <font class="comment">/****************************************************/</font>
21 <a name="l00013"></a><a class="code" href="param_8c.html#a0">00013</a> <font class="keywordtype">char</font> **<a class="code" href="param_8c.html#a0">Read_ParamNames</a>(FILE *in,<font class="keywordtype">int</font> m) {
22 00014
23 00015 <font class="keywordtype">char</font> **param_name;
24 00016 <font class="keywordtype">int</font> c, i, j, f;
25 00017 <font class="keywordtype">char</font> s[1024],param[32];
26 00018
27 00019 <font class="keywordflow">if</font>(!in)
28 00020 f = 0;
29 00021 <font class="keywordflow">else</font>
30 00022 <font class="keywordflow">do</font>
31 00023 f = (fgets(s, 1024, in)!=NULL);
32 00024 <font class="keywordflow">while</font> ((*s==<font class="charliteral">'#'</font> || *s==<font class="charliteral">'\n'</font>) &amp;&amp; f);
33 00025
34 00026 param_name = (<font class="keywordtype">char</font> **)malloc(m*<font class="keyword">sizeof</font>(<font class="keywordtype">char</font> *));
35 00027 i = 0;
36 00028 <font class="keywordflow">if</font>(f) {
37 00029 c = 0;
38 00030 <font class="keywordflow">for</font>(;i&lt;m;++i) {
39 00031 j=0;
40 00032 <font class="keywordflow">for</font>(;;++c) {
41 00033 <font class="keywordflow">if</font>(s[c]==<font class="charliteral">' '</font>) {
42 00034 <font class="keywordflow">if</font>(j==0)
43 00035 <font class="keywordflow">continue</font>;
44 00036 <font class="keywordflow">else</font>
45 00037 <font class="keywordflow">break</font>;
46 00038 }
47 00039 <font class="keywordflow">if</font>(s[c]==<font class="charliteral">'\n'</font> || s[c]==0)
48 00040 <font class="keywordflow">break</font>;
49 00041 param[j++] = s[c];
50 00042 }
51 00043
52 00044 <font class="comment">/* Not enough parameters on input, end */</font>
53 00045 <font class="keywordflow">if</font>(j==0)
54 00046 <font class="keywordflow">break</font>;
55 00047 param[j] = 0;
56 00048 param_name[i] = (<font class="keywordtype">char</font> *)malloc( j*<font class="keyword">sizeof</font>(<font class="keywordtype">char</font>) );
57 00049 strcpy(param_name[i],param);
58 00050 }
59 00051 }
60 00052
61 00053 <font class="comment">/* Not enough parameters on input : use default names */</font>
62 00054 <font class="keywordflow">if</font>(!f || i!=m) {
63 00055 <font class="keywordflow">for</font>(;i&lt;m;++i) {
64 00056 param_name[i] = (<font class="keywordtype">char</font> *) malloc(2*<font class="keyword">sizeof</font>(<font class="keywordtype">char</font>));
65 00057 sprintf(param_name[i], <font class="stringliteral">"%c"</font>, PCHAR+i+1);
66 00058 }
67 00059 }
68 00060 <font class="keywordflow">return</font>(param_name);
69 00061 } <font class="comment">/* Read_ParamNames */</font>
70 00062
71 </pre></div><hr><address align="right"><small>Generated on Fri Nov 8 12:10:06 2002 for Polylib by
72 <a href="http://www.doxygen.org/index.html">
73 <img src="doxygen.png" alt="doxygen" align="middle" border=0
74 width=110 height=53></a>1.2.15 </small></address>
75 </body>
76 </html>