X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=include%2Fatalk%2Futil.h;h=38e1e7b2dd4f36a115c4ca2a73ba5b0d8b60d326;hb=ae7f70b27d3f366a7b744981643e28fba8cc6b0d;hp=811c0ee661a6af7316b51a045034fd654b464447;hpb=154c130f7a3a407e686eda99a6658773e137b05f;p=netatalk.git diff --git a/include/atalk/util.h b/include/atalk/util.h index 811c0ee6..38e1e7b2 100644 --- a/include/atalk/util.h +++ b/include/atalk/util.h @@ -11,21 +11,21 @@ #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 #include +#include /* exit error codes */ #define EXITERR_CLNT 1 /* client related error */ #define EXITERR_CONF 2 /* error in config files/cmd line parameters */ #define EXITERR_SYS 3 /* local system error */ +#define EXITERR_CLOSED 4 /* connection was immediately closed after TCP handshake */ /* Print a SBT and exit */ #define AFP_PANIC(why) \ @@ -46,16 +46,32 @@ #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)) +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? a : b) +#endif +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? a : b) +#endif -#if BYTE_ORDER == BIG_ENDIAN +#ifdef WORDS_BIGENDIAN #define hton64(x) (x) #define ntoh64(x) (x) -#else /* BYTE_ORDER == BIG_ENDIAN */ +#else #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 */ +#endif #ifdef WITH_SENDFILE extern ssize_t sys_sendfile (int __out_fd, int __in_fd, off_t *__offset,size_t __count); @@ -68,28 +84,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 *); @@ -145,6 +149,7 @@ extern const char *getip_string(const struct sockaddr *sa); extern unsigned int getip_port(const struct sockaddr *sa); extern void apply_ip_mask(struct sockaddr *ai, int maskbits); extern int compare_ip(const struct sockaddr *sa1, const struct sockaddr *sa2); +extern int tokenize_ip_port(const char *ipurl, char **address, char **port); /* Structures and functions dealing with dynamic pollfd arrays */ enum fdtype {IPC_FD, LISTEN_FD}; @@ -154,7 +159,8 @@ struct polldata { * 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, @@ -174,13 +180,33 @@ extern int recv_fd(int fd, int nonblocking); *****************************************************************/ extern const char *getcwdpath(void); +extern const char *fullpathname(const char *); 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); +extern int run_cmd(const char *cmd, char **cmd_argv); +extern char *realpath_safe(const char *path); +extern const char *basename_safe(const char *path); +extern char *strtok_quote (char *s, const char *delim); + +extern int ochdir(const char *dir, int options); +extern int ostat(const char *path, struct stat *buf, int options); +extern int ostatat(int dirfd, const char *path, struct stat *st, int options); +extern int ochown(const char *path, uid_t owner, gid_t group, int options); +extern int ochmod(char *path, mode_t mode, const struct stat *st, int options); /****************************************************************** * cnid.c *****************************************************************/ extern bstring rel_path_in_vol(const char *path, const char *volpath); +extern cnid_t cnid_for_path(struct _cnid_db *cdb, const char *volpath, const char *path, cnid_t *did); + +/****************************************************************** + * cnid.c + *****************************************************************/ + +extern void initline (int, char *); +extern int parseline (int, char *); + +#endif /* _ATALK_UTIL_H */