2 This file is part of PolyLib.
4 PolyLib is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 PolyLib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
22 #include <polylib/polylib.h>
24 /****************************************************/
25 /* Read_ParamNames() : */
26 /* Reads FILE *in for the parameter names */
27 /* if in==NULL or not enough parameters on input, */
28 /* use default names */
29 /* returns an n-array of strings */
30 /****************************************************/
31 const char **Read_ParamNames(FILE *in
,int m
)
35 char s
[1024],param
[32];
41 f
= (fgets(s
, 1024, in
)!=NULL
);
42 while (f
&& (*s
=='#' || *s
=='\n'));
44 param_name
= (char **)malloc(m
*sizeof(char *));
57 if(s
[c
]=='\n' || s
[c
]==0)
62 /* Not enough parameters on input, end */
66 param_name
[i
] = (char *)malloc( (j
+1)*sizeof(char) );
67 strcpy(param_name
[i
],param
);
71 /* Not enough parameters on input : use default names */
74 param_name
[i
] = (char *) malloc(2*sizeof(char));
75 sprintf(param_name
[i
], "%c", PCHAR
+i
+1);
78 return (const char**)param_name
;
79 } /* Read_ParamNames */
81 void Free_ParamNames(const char **params
, int m
)
84 free((char *)params
[m
]);