23 #include <sys/types.h> 25 #ifndef REGEXP_WORKAROUND 43 #ifdef REGEXP_WORKAROUND 59 if (fieldname == NULL || basefieldname == NULL ||
60 ndim == NULL || dimlist == NULL)
67 baseptr = (
char *)calloc(
MAXSTR,
sizeof(
char));
70 dimptr = (
int *)calloc(
MAXDIMS,
sizeof(
int));
78 strcpy(buf,fieldname);
81 #ifdef REGEXP_WORKAROUND 82 bufptr = strchr(bufptr,
'[');
83 while (bufptr != NULL && i <
MAXDIMS) {
84 dimptr[i++] = (int)strtol(bufptr + 1, &endptr, 0);
85 if (bufptr + 1 == endptr || *endptr !=
']') {
89 bufptr = strchr(endptr,
'[');
94 reg_status =
regexec(&preg, bufptr, 1, &pm, 0);
95 while (reg_status == 0 && i <
MAXDIMS) {
96 dimptr[i++] = (int)strtol(bufptr + pm.
rm_so + 1, NULL, 0);
110 l = strcspn(fieldname, c);
111 strncpy(baseptr, fieldname, l);
118 if (strcasestr(baseptr,
"raw ") != NULL)
119 memmove(baseptr, &baseptr[4], strlen(baseptr)-4+1);
121 else if (strcasestr(baseptr,
"flag ") != NULL)
122 memmove(baseptr, &baseptr[5], strlen(baseptr)-5+1);
124 else if ((ptr = strcasestr(baseptr,
" Radiance")) != NULL)
125 strcpy(ptr,
" Radiance/RDQI");
127 else if ((ptr = strcasestr(baseptr,
" RDQI")) != NULL)
128 strcpy(ptr,
" Radiance/RDQI");
130 else if ((ptr = strcasestr(baseptr,
" DN")) != NULL)
131 strcpy(ptr,
" Radiance/RDQI");
133 else if ((ptr = strcasestr(baseptr,
" Equivalent Reflectance")) != NULL)
134 strcpy(ptr,
" Radiance/RDQI");
136 else if ((ptr = strcasestr(baseptr,
" Brf")) != NULL)
137 strcpy(ptr,
" Radiance/RDQI");
139 *basefieldname = baseptr;
143 if (baseptr != NULL) free(baseptr);
144 if (dimptr != NULL) free(dimptr);
MTKt_status MtkParseFieldname(const char *fieldname, char **basefieldname, int *ndim, int **dimlist)
Parses extra dimensions from fieldnames.
#define MTK_ERR_CODE_JUMP(code)
LIBTRE_DLL_IMPEXP void regfree(regex_t *preg)
LIBTRE_DLL_IMPEXP int regcomp(regex_t *preg, const char *regex, int cflags)
HDFFCLIBAPI intf ptr[][4]
LIBTRE_DLL_IMPEXP int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)