portability: add support for Illumos

This still won't work on older Solaris systems, but modern Illumos
at least should build and run now.
This commit is contained in:
Justin Maggard
2014-05-14 17:53:25 -07:00
parent 361bc34f93
commit 34cb08928c
10 changed files with 58 additions and 30 deletions

17
utils.h
View File

@ -25,6 +25,7 @@
#define __UTILS_H__
#include <stdarg.h>
#include <dirent.h>
#include <sys/param.h>
#include "minidlnatypes.h"
@ -55,6 +56,22 @@ static inline void strncpyt(char *dst, const char *src, size_t len)
strncpy(dst, src, len);
dst[len-1] = '\0';
}
static inline int is_reg(const struct dirent *d)
{
#if HAVE_STRUCT_DIRENT_D_TYPE
return (d->d_type == DT_REG);
#else
return -1;
#endif
}
static inline int is_dir(const struct dirent *d)
{
#if HAVE_STRUCT_DIRENT_D_TYPE
return (d->d_type == DT_DIR);
#else
return -1;
#endif
}
int xasprintf(char **strp, char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
int ends_with(const char * haystack, const char * needle);
char *trim(char *str);