#ifndef AFS_NT40_ENV
#include <unistd.h>
#endif
+#ifdef HAVE_POSIX_REGEX /* use POSIX regexp library */
+#include <regex.h>
+#endif
extern int smallMem;
extern extent_mod;
int pollcount = 0;
int namematchRWBK, namematchRO, thismatch, matchtype;
char volumename[VL_MAXNAMELEN];
+#ifdef HAVE_POSIX_REGEX
+ regex_t re;
+ int need_regfree = 0;
+#endif
COUNT_REQ(VLLISTATTRIBUTESN2);
vldbentries->nbulkentries_val = 0;
findflag = ((attributes->Mask & VLLIST_FLAG) ? 1 : 0);
if (name && (strcmp(name, ".*") != 0) && (strcmp(name, "") != 0)) {
sprintf(volumename, "^%s$", name);
+#ifdef HAVE_POSIX_REGEX
+ if (regcomp(&re, volumename, REG_BASIC | REG_NOSUB) != 0) {
+ errorcode = VL_BADNAME;
+ goto done;
+ }
+ need_regfree = 1;
+#else
t = (char *)re_comp(volumename);
if (t) {
errorcode = VL_BADNAME;
goto done;
}
+#endif
findname = 1;
}
if (tentry.flags & VLF_RWEXISTS) {
if (findname) {
sprintf(volumename, "%s", tentry.name);
+#ifdef HAVE_POSIX_REGEX
+ if (regexec(&re, volumename, 0, NULL, 0) == 0) {
+ thismatch = VLSF_RWVOL;
+ }
+#else
if (re_exec(volumename)) {
thismatch = VLSF_RWVOL;
}
+#endif
} else {
thismatch = VLSF_RWVOL;
}
if (!thismatch && (tentry.flags & VLF_BACKEXISTS)) {
if (findname) {
sprintf(volumename, "%s.backup", tentry.name);
+#ifdef HAVE_POSIX_REGEX
+ if (regexec(&re, volumename, 0, NULL, 0) == 0) {
+ thismatch = VLSF_BACKVOL;
+ }
+#else
if (re_exec(volumename)) {
thismatch = VLSF_BACKVOL;
}
+#endif
} else {
thismatch = VLSF_BACKVOL;
}
} else {
sprintf(volumename, "%s.readonly",
tentry.name);
+#ifdef HAVE_POSIX_REGEX
+ if (regexec(&re, volumename, 0, NULL, 0) == 0) {
+ thismatch = VLSF_ROVOL;
+ }
+#else
if (re_exec(volumename))
thismatch = VLSF_ROVOL;
+#endif
}
} else {
thismatch = VLSF_ROVOL;
}
done:
+#ifdef HAVE_POSIX_REGEX
+ if (need_regfree)
+ regfree(&re);
+#endif
+
if (errorcode) {
COUNT_ABO;
ubik_AbortTrans(trans);