31 int (*)(
void *,
void *));
33 static void strClearBlanks(
char *);
48 int (*func) (
void *,
void *);
53 char *beg_tag, *end_tag;
58 beg_tag = end_tag = NULL;
60 if (fname != NULL && strlen(fname) > 0) {
62 static time_t tlast = (time_t) 0;
64 if ((fin = fopen(fname,
"r")) == NULL) {
84 if (tag != NULL && strlen(tag) > 0) {
85 size_t sz = strlen(tag) + 8;
92 if (beg_tag == NULL || end_tag == NULL)
95 snprintf(beg_tag, sz,
"<%s>", tag);
96 snprintf(end_tag, sz,
"</%s>", tag);
99 memset(s, 0,
sizeof (s));
100 while (fgets(s,
BSIZE, fin) == s) {
101 char *pk = NULL, *pv = NULL;
105 if ((pk =
strchr(s,
'\n')) != NULL)
110 if (strncasecmp(beg_tag, s, strlen(beg_tag)) == 0)
114 if (strncasecmp(end_tag, s, strlen(end_tag)) == 0) {
122 pk += strspn(pk,
" \t");
123 if ((strlen(pk) == 0) || (*pk ==
'#'))
125 q = pk + strlen(pk) - 1;
126 while ((q != pk) && (*q ==
' ' || *q ==
'\t'))
130 pv = pk + strcspn(pk,
" \t");
133 pv += strspn(pv,
" \t");
145 if (strlen(pk) > 0) {
148 if ((res = func(pk, pv)) != 0) {
167 memset(s, 0,
sizeof (s));
194 char *beg_tag, *end_tag;
199 beg_tag = end_tag = NULL;
201 if (fname != NULL && strlen(fname) > 0) {
202 static int nberr = 0;
203 static time_t tlast = (time_t) 0;
205 if ((fin = fopen(fname,
"r")) == NULL) {
225 if (tag != NULL && strlen(tag) > 0) {
226 size_t sz = strlen(tag) + 8;
231 beg_tag = malloc(sz);
232 end_tag = malloc(sz);
233 if (beg_tag == NULL || end_tag == NULL)
236 snprintf(beg_tag, sz,
"^<%s>", tag);
237 snprintf(end_tag, sz,
"^</%s>", tag);
240 memset(s, 0,
sizeof (s));
241 while (fgets(s,
BSIZE, fin) == s) {
246 if ((q =
strchr(s,
'\n')) != NULL)
270 if ((res = func(s, arg)) != 0) {
289 memset(s, 0,
sizeof (s));
312 if (s == NULL || strlen(s) == 0)
315 p = s + strlen(s) - 1;
316 while ((p != s) && ((*p ==
' ') || (*p ==
'\t')))
int zm_RdFile(char *fname, char *tag, RDFILE_F func, void *arg)
bool zeStrRegex(char *, char *, long *, long *, bool)
int(* RDFILE_F)(void *, void *)
#define ZE_LogSysError(...)
int zm_RdTextFile(char *, int, int, char *, int(*)(void *, void *))