39 for (i = 0; i < 8 *
sizeof (val); i++)
59 if ((s == NULL) || (strlen(s) == 0))
62 if ((l = strspn(s,
"0123456789")) == 0)
65 if (l >= (
sizeof (strn)))
68 memset(strn, 0,
sizeof (strn));
73 n = strtol(strn, (
char **) NULL, 10);
74 if (errno == ERANGE || errno == EINVAL || n <= 0)
141 size_t xtra = (8 - sz % 8) % 8;
143 p = malloc(sz + xtra);
162 for (p = s; *p !=
'\0'; p++)
178 for (p = s; *p !=
'\0'; p++)
194 memset(dst, (
int) c, len);
237 for (i = 0; i < sz; i++, p++) {
267 while ((*p !=
'\0') && (size-- > 0)) {
268 if ((*p !=
' ') && (*p !=
'\t'))
291 for (n = strlen(s); n > 0; n--) {
293 if (
strchr(
" \t\r\n", *p) == NULL)
305 #if defined(REGCOMP_FLAGS) 309 #define REGCOMP_FLAGS (REG_ICASE | REG_EXTENDED) 324 if ((s == NULL) || (expr == NULL))
327 flags = REG_EXTENDED | (icase ? REG_ICASE : 0);
328 if ((rerror = regcomp(&re, expr, flags)) == 0) {
331 if (regexec(&re, s, 1, &pm, 0) == 0) {
342 if (regerror(rerror, &re, s,
sizeof (s)) > 0)
363 i = (len - strlen(org)) / 2;
364 for (p = dst; i > 0; i--)
404 if (s == NULL || argv == NULL || sz == 0)
409 for (i = 0; i < sz; i++)
411 for (p = strtok_r(s, sep, &ptr), i = 0;
412 p != NULL && i < sz - 1; p = strtok_r(NULL, sep, &ptr), i++) {
432 if (in == NULL || out == NULL)
435 if ((t = strdup(in)) == NULL)
438 if ((p =
strrchr(t,
'/')) != NULL && *(p + 1) ==
'\0')
441 if ((p =
strrchr(t,
'/')) != NULL) {
457 ssp_flock(fd, cmd, type)
464 memset(&lock, 0,
sizeof (lock));
466 lock.l_whence = SEEK_SET;
470 return fcntl(fd, cmd, &lock);
477 if (ssp_flock(fd, F_SETLKW, F_WRLCK) < 0) {
491 if (ssp_flock(fd, F_SETLK, F_UNLCK) < 0) {
514 if (stat(fname, &fstat) == 0)
515 return fstat.st_size;
537 if (fstat(fd, &st) == 0)
596 char fname[PATH_MAX];
599 if ((dir = opendir(dirname)) != NULL) {
600 while (r && (p = readdir(dir)) != NULL) {
601 if ((strcmp(p->d_name,
".") == 0) || (strcmp(p->d_name,
"..") == 0))
603 snprintf(fname,
sizeof (fname),
"%s/%s", dirname, p->d_name);
605 if (stat(fname, &st) == 0) {
606 if (S_ISDIR(st.st_mode))
621 if (r && rmdir(dirname) != 0) {
640 if ((r = stat(dir, &buf)) != 0) {
645 if (S_ISFIFO(buf.st_mode))
648 if (S_ISCHR(buf.st_mode))
651 if (S_ISDIR(buf.st_mode))
654 if (S_ISBLK(buf.st_mode))
658 if (S_ISSOCK(buf.st_mode))
662 if (S_ISREG(buf.st_mode))
681 while (path != NULL && strlen(path) > 0) {
void * jmalloc(size_t sz)
int str2tokens(char *s, int sz, char **argv, char *sep)
size_t get_fd_size(int fd)
char * str_clear_trailing_blanks(char *s)
bool remove_dir(char *dirname)
#define ZE_LogMsgInfo(level,...)
#define ZE_LogMsgError(level,...)
void center_string(char *dst, char *org, int len)
size_t strclean(char *s, size_t sz)
char * j_basename(char *out, char *in, size_t size)
char * strtolower(char *s)
char * path2filename(char *path)
bool strexpr(char *s, char *expr, long *pi, long *pf, bool icase)
#define ZE_MessageInfo(level,...)
int count_uint32bits(uint32_t val)
bool getdirinfo(char *dir)
#define ZE_LogSysError(...)
size_t get_file_size(char *fname)
char * strnoblanks(char *s, size_t size)
int nb_valid_pointer(char *a, char *b, char *c)
char * strset(char *dst, int c, int len)
void strchknull(char *s, int len)
char * strtoupper(char *s)
int readln(int fd, char *buf, size_t size)