X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Fatalk%2Futil.h;h=0106db2fa48d5e9712af71f77d9135d74c20fe73;hb=5f5a1a34ccb8e8a74cb4f74e4b1a95cb4b22182b;hp=dee55d59b6f9acb36c47ed45341dfad36d725e3b;hpb=6c1f3cff882955229cb9e0b94eca5e725817633b;p=netatalk.git diff --git a/include/atalk/util.h b/include/atalk/util.h index dee55d59..0106db2f 100644 --- a/include/atalk/util.h +++ b/include/atalk/util.h @@ -1,5 +1,15 @@ /* - * $Id: util.h,v 1.3 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: util.h,v 1.20 2010-02-28 17:02:49 didg Exp $ + */ + +/*! + * @file + * Netatalk utility functions + * + * Utility functions for these areas: \n + * * sockets \n + * * locking \n + * * misc UNIX function wrappers, eg for getcwd */ #ifndef _ATALK_UTIL_H @@ -11,27 +21,52 @@ #include #endif /* HAVE_UNISTD_H */ #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 */ -extern unsigned const char _diacasemap[], _dialowermap[]; + +#ifdef WITH_SENDFILE +extern ssize_t sys_sendfile (int __out_fd, int __in_fd, off_t *__offset,size_t __count); +#endif + +extern const int _diacasemap[], _dialowermap[]; extern char **getifacelist(void); extern void freeifacelist(char **); -#define diatolower(x) _dialowermap[(x)] -#define diatoupper(x) _diacasemap[(x)] -extern int atalk_aton __P((char *, struct at_addr *)); -extern void bprint __P((char *, int)); -extern int strdiacasecmp __P((const unsigned char *, const unsigned char *)); -extern int strndiacasecmp __P((const unsigned char *, const unsigned char *, - int)); -extern pid_t server_lock __P((char * /*program*/, char * /*file*/, - int /*debug*/)); +#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 void fault_setup (void (*fn)(void *)); #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 __P((const char *)); -extern void *mod_symbol __P((void *, const char *)); -extern void mod_close __P((void *)); +extern void *mod_open (const char *); +extern void *mod_symbol (void *, const char *); +extern void mod_close (void *); #define mod_error() "" #else /* ! HAVE_DLFCN_H */ #include @@ -40,15 +75,53 @@ extern void mod_close __P((void *)); #define RTLD_NOW 1 #endif /* ! RTLD_NOW */ +/* NetBSD doesn't like RTLD_NOW for dlopen (it fails). Use RTLD_LAZY. + * OpenBSD currently does not use the second arg for dlopen(). For + * future compatibility we define DL_LAZY */ +#ifdef __NetBSD__ +#define mod_open(a) dlopen(a, RTLD_LAZY) +#elif defined(__OpenBSD__) +#define mod_open(a) dlopen(a, DL_LAZY) +#else /* ! __NetBSD__ && ! __OpenBSD__ */ #define mod_open(a) dlopen(a, RTLD_NOW) +#endif /* __NetBSD__ */ #ifndef DLSYM_PREPEND_UNDERSCORE #define mod_symbol(a, b) dlsym(a, b) #else /* ! DLSYM_PREPEND_UNDERSCORE */ -extern void *mod_symbol __P((void *, const char *)); +extern void *mod_symbol (void *, const char *); #endif /* ! DLSYM_PREPEND_UNDERSCORE */ #define mod_error() dlerror() #define mod_close(a) dlclose(a) #endif /* ! HAVE_DLFCN_H */ -#endif +/****************************************************************** + * locking.c + ******************************************************************/ + +extern int lock_reg(int fd, int cmd, int type, off_t offest, int whence, off_t len); +#define read_lock(fd, offset, whence, len) \ + lock_reg((fd), F_SETLK, F_RDLCK, (offset), (whence), (len)) +#define write_lock(fd, offset, whence, len) \ + lock_reg((fd), F_SETLK, F_WRLCK, (offset), (whence), (len)) +#define unlock(fd, offset, whence, len) \ + lock_reg((fd), F_SETLK, F_UNLCK, (offset), (whence), (len)) + +/****************************************************************** + * socket.c + ******************************************************************/ + +extern int setnonblock(int fd, int cmd); +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); + +/****************************************************************** + * unix.c + *****************************************************************/ + +extern const char *getcwdpath(void); +extern int lchdir(struct vol *vol, const char *dir); + +#endif /* _ATALK_UTIL_H */