67 fp = fopen(fname,
"r");
69 printf (
"! ParamFileRead: file %s not found\n", fname);
74 while ( fgets(sline, 512, fp) != NULL ) {
75 if (strlen(sline) > 0) {
107 if (words == NULL) words =
ARRAY_2D(128,128,
char);
108 for (k = 0; k < 127; k++) sprintf (words[k],
"\0");
110 for (k = 0; k <
nlines; k++) {
113 if (nwords > 0 && strcmp(words[0],label) == 0){
114 if (pos <= nwords)
return words[pos];
116 printf (
"! ParamFileGet: field # %d does not exist\n",pos);
122 printf (
"! ParamFileGet: label '%s' was not found\n",label);
143 if (words == NULL) words =
ARRAY_2D(128,128,
char);
145 for (k = 0; k <
nlines; k++) {
147 if (strcmp(words[0],label1) == 0){
148 for (nw = 1; nw < nwords; nw++){
149 if (words[nw][0] ==
'#')
break;
151 if (strcmp(words[nw], label2) == 0)
return 1;
168 char sline[512], *str;
169 const char delimiters[] =
" \t\r\f";
175 for (k = 0; k <
nlines; k++) {
176 sprintf (sline,
"%s",
fline[k]);
177 str = strtok(sline,delimiters);
178 if (strcmp(str,label) == 0)
return(1);
192 char *str, cstr[512];
193 const char delimiters[] =
" \t\r\f";
198 str = strtok(cstr,delimiters);
202 while (str != NULL && str[0] !=
'\n') {
203 strcpy(words[nwords],str);
204 str = strtok(NULL, delimiters);
210 for (nw = 0; nw < nwords; nw++){
211 strcpy (cstr, words[nw]);
212 sprintf (words[nw],
"%s",strtok(cstr,
"\n"));
static int ParamFileGetWords(char *line, char **)
int ParamExist(const char *label)
int ParamFileHasBoth(const char *label1, const char *label2)
static char ** fline
All of the lines (including empty ones) in the file.
static int nlines
The total number of lines (including empty ones) contained in the file.
int ParamFileRead(char *fname)
#define ARRAY_2D(nx, ny, type)
char * ParamFileGet(const char *label, int pos)
#define QUIT_PLUTO(e_code)