34 #ifndef CF_MXE_CROSS_COMPILE
35 #include <sys/param.h>
72 char *tempname = NULL;
76 const int maxretry = 10;
79 for (i = 0; i < maxretry; i++) {
80 tempname = tempnam(dir, pfx);
88 LOG(
llevError,
"Created file detected in tempnam_secure. Someone hoping for a race condition?\n");
95 file = fdopen(fd,
"w+");
97 LOG(
llevError,
"fdopen() failed in tempnam_secure()!\n");
119 char buf[strlen(
path) +
sizeof(dirent::d_name) + 1];
131 if (de->d_name[0] ==
'.')
137 status = stat(de->d_name, &statbuf);
138 if ((
status != -1) && (S_ISDIR(statbuf.st_mode))) {
139 snprintf(
buf,
sizeof(
buf),
"%s/%s",
path, de->d_name);
143 snprintf(
buf,
sizeof(
buf),
"%s/%s",
path, de->d_name);
172 while ((cp = strchr(cp+1, (
int)
'/'))) {
174 if (stat(
buf, &statbuf) || !S_ISDIR(statbuf.st_mode)) {
203 assert(curlen != NULL);
204 assert(*curlen < maxlen);
206 *curlen = strlcat(
dest, orig, maxlen);
208 if (*curlen == (maxlen-1))
210 strncpy(
dest+*curlen, orig, maxlen-*curlen-1);
212 *curlen += strlen(orig);
214 if (*curlen > (maxlen-1))
222 size_t strlcpy(
char *dst,
const char *src,
size_t size) {
223 strncpy(dst, src, size - 1);
224 dst[size - 1] =
'\0';
232 const char *
strcasestr(
const char *s,
const char *find)
237 if ((
c = *find++) != 0) {
242 if ((sc = *s++) == 0)
245 while ((
char)
tolower((
unsigned char) sc) !=
c);
247 while (strncasecmp(s, find, len) != 0);