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">
6 <!-- Generated by Doxygen 1.2.15 -->
8 <a class=
"qindex" href=
"main.html">Main Page
</a> <a class=
"qindex" href=
"annotated.html">Compound List
</a> <a class=
"qindex" href=
"files.html">File List
</a> <a class=
"qindex" href=
"functions.html">Compound Members
</a> <a class=
"qindex" href=
"globals.html">File Members
</a> </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
<stdio.h
></font>
10 00002 <font class=
"preprocessor">#include
<string.h
></font>
12 00004 <font class=
"preprocessor">#include
<polylib/polylib.h
></font>
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) {
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];
27 00019 <font class=
"keywordflow">if
</font>(!in)
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>)
&& f);
34 00026 param_name = (
<font class=
"keywordtype">char
</font> **)malloc(m*
<font class=
"keyword">sizeof
</font>(
<font class=
"keywordtype">char
</font> *));
36 00028 <font class=
"keywordflow">if
</font>(f) {
38 00030 <font class=
"keywordflow">for
</font>(;i
<m;++i) {
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>;
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];
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>;
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);
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
<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);
68 00060 <font class=
"keywordflow">return
</font>(param_name);
69 00061 }
<font class=
"comment">/* Read_ParamNames */
</font>
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>