X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Fatalk%2Futil.h;h=1664c8c992fccd11c45a139e267e3308827a39e7;hb=2fdd522410f80afcd055d7333f491ee6c0b4b9fa;hp=999f14daac86349e508be888df10e0a40a987123;hpb=ce40a87753e2529265da0f37808d7d41a9a7efdc;p=netatalk.git diff --git a/include/atalk/util.h b/include/atalk/util.h index 999f14da..1664c8c9 100644 --- a/include/atalk/util.h +++ b/include/atalk/util.h @@ -11,13 +11,10 @@ #ifndef _ATALK_UTIL_H #define _ATALK_UTIL_H 1 -#include #include -#ifdef HAVE_UNISTD_H +#include #include -#endif /* HAVE_UNISTD_H */ #include -#include #include #include @@ -46,7 +43,26 @@ #define AFP_ASSERT(b) #endif /* NDEBUG */ +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + #define STRCMP(a,b,c) (strcmp(a,c) b 0) +#define ZERO_STRUCT(a) memset(&(a), 0, sizeof(a)) +#define ZERO_STRUCTP(a) memset((a), 0, sizeof(a)) + +#if BYTE_ORDER == BIG_ENDIAN +#define hton64(x) (x) +#define ntoh64(x) (x) +#else /* BYTE_ORDER == BIG_ENDIAN */ +#define hton64(x) ((uint64_t) (htonl(((x) >> 32) & 0xffffffffLL)) | \ + (uint64_t) ((htonl(x) & 0xffffffffLL) << 32)) +#define ntoh64(x) (hton64(x)) +#endif /* BYTE_ORDER == BIG_ENDIAN */ #ifdef WITH_SENDFILE extern ssize_t sys_sendfile (int __out_fd, int __in_fd, off_t *__offset,size_t __count); @@ -59,28 +75,16 @@ extern void freeifacelist(char **); #define diatolower(x) _dialowermap[(unsigned char) (x)] #define diatoupper(x) _diacasemap[(unsigned char) (x)] -extern int atalk_aton (char *, struct at_addr *); extern void bprint (char *, int); extern int strdiacasecmp (const char *, const char *); extern int strndiacasecmp (const char *, const char *, size_t); extern pid_t server_lock (char * /*program*/, char * /*file*/, int /*debug*/); +extern int check_lockfile (const char *program, const char *pidfile); +extern int create_lockfile(const char *program, const char *pidfile); extern void fault_setup (void (*fn)(void *)); extern void netatalk_panic(const char *why); #define server_unlock(x) (unlink(x)) -/* strlcpy and strlcat are used by pam modules */ -#ifndef UAM_MODULE_EXPORT -#define UAM_MODULE_EXPORT -#endif - -#ifndef HAVE_STRLCPY -UAM_MODULE_EXPORT size_t strlcpy (char *, const char *, size_t); -#endif - -#ifndef HAVE_STRLCAT -UAM_MODULE_EXPORT size_t strlcat (char *, const char *, size_t); -#endif - #ifndef HAVE_DLFCN_H extern void *mod_open (const char *); extern void *mod_symbol (void *, const char *); @@ -138,14 +142,15 @@ extern void apply_ip_mask(struct sockaddr *ai, int maskbits); extern int compare_ip(const struct sockaddr *sa1, const struct sockaddr *sa2); /* Structures and functions dealing with dynamic pollfd arrays */ -enum fdtype {IPC_FD, LISTEN_FD}; +enum fdtype {IPC_FD, LISTEN_FD, DISASOCIATED_IPC_FD}; struct polldata { enum fdtype fdtype; /* IPC fd or listening socket fd */ void *data; /* pointer to AFPconfig for listening socket and * * pointer to afp_child_t for IPC fd */ }; -extern void fdset_add_fd(struct pollfd **fdsetp, +extern void fdset_add_fd(int maxconns, + struct pollfd **fdsetp, struct polldata **polldatap, int *fdset_usedp, int *fdset_sizep, @@ -164,14 +169,17 @@ extern int recv_fd(int fd, int nonblocking); * unix.c *****************************************************************/ +extern const char *abspath(const char *name); extern const char *getcwdpath(void); extern char *stripped_slashes_basename(char *p); extern int lchdir(const char *dir); extern void randombytes(void *buf, int n); -#endif /* _ATALK_UTIL_H */ +extern int daemonize(int nochdir, int noclose); /****************************************************************** * cnid.c *****************************************************************/ extern bstring rel_path_in_vol(const char *path, const char *volpath); + +#endif /* _ATALK_UTIL_H */