#include #include double atof(); /* #define DEBUG */ #define TOKEN 40 #define NVAR 50 #define COMMENTSIZE 2430 #define SEPARATOR " ,=\t\n" char names[NVAR][TOKEN]; char values[NVAR][TOKEN]; char attr[NVAR][TOKEN]; int map[NVAR]; int nheader, ndata; FILE *fl; int maxlev,newlev; int eofflag=0; char str[1025],*strp; char tabcomments[COMMENTSIZE]; err(s,t) char *s,*t; { char tmp[80]; printf("&x error - %s%t\r\n",s,t); ioclose_(); exit(1); } int fg(str) char *str; { *str = 0; while(*str == 0){ if(fgets(str,1024,fl) == NULL) return 1; if(strspn(str,SEPARATOR)==strlen(str))*str = 0; }; return 0; } int readdata(flag) int flag; { int state,nn,i; char *pstr; state=1; if(*str == 0) if(fg(str))return -1; if (str[0] == '#'){ *tabcomments=0; while (str[0] == '#') { strcat(tabcomments,str+1); if (fg(str)) return -1; }; }; if(flag<=1) while(strchr(str,'=')==NULL) if(fg(str))return -1; while(strchr(str,'=')){ state=2; strp=strtok(str,SEPARATOR); while(strp){ if(flag==0){ if(pstr=strchr(strp,'[')){ *(pstr+strlen(pstr)-1)=0; strcpy(attr[nheader],pstr+1); *pstr=0; } else attr[nheader][0]=0; strcpy(names[nheader],strp); nn=nheader++; } else { if(pstr=strchr(strp,'['))*pstr=0; for(nn=0;nn0){newlev=3;return 1;}; newlev=2;return 0; } ioname_(vn,s) int *vn; char *s; { strcpy(s,names[*vn]); } int iovarlevel_(vn) int *vn; { if(*vn