5#include "tpcclibConfig.h"
35 if(nonprintable!=NULL) *nonprintable=0;
36 if(fp==NULL)
return(0);
40 while((c=fgetc(fp))!=EOF && n<SIZE_MAX-1 && bn<2) {
41 if(iscntrl(c) && c!=13 && c!=10 && c!=9 && c!=169) {
44 if(nonprintable!=NULL) *nonprintable=1;
51 if(nonprintable!=NULL && bn>1) *nonprintable=1;
67size_t asciiFileChrCount(
78 if(fp==NULL)
return(n);
79 if(s==NULL ||
strnlen(s, 1)==0)
return(n);
82 int single_quotation=0;
83 int double_quotation=0;
84 while((c=fgetc(fp))!=EOF && n<SIZE_MAX-1) {
86 if(iscntrl(c) && c!=13 && c!=10 && c!=9)
break;
89 if(single_quotation==0 && strchr(cptr+1,
'\'')!=NULL) single_quotation=1;
90 else single_quotation=0;
94 if(double_quotation==0 && strchr(cptr+1,
'\"')!=NULL) double_quotation=1;
95 else double_quotation=0;
98 if(single_quotation==1 || double_quotation==1)
continue;
102 for(j=0; j<strlen(s); j++)
if(c==(
int)s[j]) n++;
127 if(fp==NULL || maxlen<2)
return NULL;
130 if(data!=NULL) cptr=data;
else {
131 cptr=malloc(maxlen*
sizeof(
char));
if(cptr==NULL)
return NULL;
134 while((c=fgetc(fp))!=EOF && i<maxlen-1) cptr[i++]=(char)c;
135 cptr[i]=(char)0;
if(i==0) {
if(data==NULL) free(cptr); cptr=NULL;}
157 if(cont!=NULL) *cont=0;
158 if(line==NULL)
return 0;
159 char *cptr=(
char*)line;
160 int i=strspn(cptr,
" \t"); cptr+=i;
if(cont!=NULL) *cont=i;
161 if(*cptr!=
'#')
return 0;
162 if(cont==NULL)
return 1;
163 cptr++; i=strspn(cptr,
" \t"); *cont+=(i+1);
char * asciiFileRead(FILE *fp, char *data, size_t maxlen)
int asciiCommentLine(const char *line, int *cont)
size_t asciiFileSize(FILE *fp, int *nonprintable)
size_t strnlen(const char *s, size_t n)
Header file for library libtpcextensions.