]> arthur.barton.de Git - netatalk.git/blob - include/atalk/util.h
11074d3fa745ce4bbd05c07945e56e3b98cf6b79
[netatalk.git] / include / atalk / util.h
1 /*
2  * $Id: util.h,v 1.7.10.6 2004-05-04 15:38:26 didg Exp $
3  */
4
5 #ifndef _ATALK_UTIL_H
6 #define _ATALK_UTIL_H 1
7
8 #include <sys/cdefs.h>
9 #include <sys/types.h>
10 #ifdef HAVE_UNISTD_H
11 #include <unistd.h>
12 #endif /* HAVE_UNISTD_H */
13 #include <netatalk/at.h>
14
15 /* exit error codes */
16 #define EXITERR_CLNT 1  /* client related error */
17 #define EXITERR_CONF 2  /* error in config files/cmd line parameters */
18 #define EXITERR_SYS  3  /* local system error */
19
20
21 extern int     sys_ftruncate __P((int fd, off_t length));
22
23 #ifdef WITH_SENDFILE
24 extern ssize_t sys_sendfile __P((int __out_fd, int __in_fd, off_t *__offset,size_t __count));
25 #endif
26
27 extern const int _diacasemap[], _dialowermap[];
28
29 extern char **getifacelist(void);
30 extern void freeifacelist(char **);
31
32 #define diatolower(x)     _dialowermap[(unsigned char) (x)]
33 #define diatoupper(x)     _diacasemap[(unsigned char) (x)]
34 extern int atalk_aton     __P((char *, struct at_addr *));
35 extern void bprint        __P((char *, int));
36 extern int strdiacasecmp  __P((const char *, const char *));
37 extern int strndiacasecmp __P((const char *, const char *, size_t));
38 extern pid_t server_lock  __P((char * /*program*/, char * /*file*/, 
39                                int /*debug*/));
40 extern void fault_setup   __P((void (*fn)(void *)));
41 #define server_unlock(x)  (unlink(x))
42
43 #ifndef HAVE_STRLCPY
44 size_t strlcpy __P((char *, const char *, size_t));
45 #endif
46  
47 #ifndef HAVE_STRLCAT
48 size_t strlcat __P((char *, const char *, size_t));
49 #endif
50
51 #ifndef HAVE_DLFCN_H
52 extern void *mod_open    __P((const char *));
53 extern void *mod_symbol  __P((void *, const char *));
54 extern void mod_close    __P((void *));
55 #define mod_error()      ""
56 #else /* ! HAVE_DLFCN_H */
57 #include <dlfcn.h>
58
59 #ifndef RTLD_NOW
60 #define RTLD_NOW 1
61 #endif /* ! RTLD_NOW */
62
63 /* NetBSD doesn't like RTLD_NOW for dlopen (it fails). Use RTLD_LAZY.
64  * OpenBSD currently does not use the second arg for dlopen(). For
65  * future compatibility we define DL_LAZY */
66 #ifdef __NetBSD__
67 #define mod_open(a)      dlopen(a, RTLD_LAZY)
68 #elif defined(__OpenBSD__)
69 #define mod_open(a)      dlopen(a, DL_LAZY)
70 #else /* ! __NetBSD__ && ! __OpenBSD__ */
71 #define mod_open(a)      dlopen(a, RTLD_NOW)
72 #endif /* __NetBSD__ */
73
74 #ifndef DLSYM_PREPEND_UNDERSCORE
75 #define mod_symbol(a, b) dlsym(a, b)
76 #else /* ! DLSYM_PREPEND_UNDERSCORE */
77 extern void *mod_symbol  __P((void *, const char *));
78 #endif /* ! DLSYM_PREPEND_UNDERSCORE */
79 #define mod_error()      dlerror()
80 #define mod_close(a)     dlclose(a)
81 #endif /* ! HAVE_DLFCN_H */
82
83 #endif