]> arthur.barton.de Git - netatalk.git/blob - include/atalk/util.h
bb5bed2b4e6540e1aa425e992f20f3263e02b86f
[netatalk.git] / include / atalk / util.h
1 /*
2  * $Id: util.h,v 1.9 2009-04-28 13:01:24 franklahm 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 #include <atalk/unicode.h>
15
16 /* exit error codes */
17 #define EXITERR_CLNT 1  /* client related error */
18 #define EXITERR_CONF 2  /* error in config files/cmd line parameters */
19 #define EXITERR_SYS  3  /* local system error */
20
21
22 extern int     sys_ftruncate __P((int fd, off_t length));
23
24 #ifdef WITH_SENDFILE
25 extern ssize_t sys_sendfile __P((int __out_fd, int __in_fd, off_t *__offset,size_t __count));
26 #endif
27
28 extern const int _diacasemap[], _dialowermap[];
29
30 extern char **getifacelist(void);
31 extern void freeifacelist(char **);
32
33 #define diatolower(x)     _dialowermap[(unsigned char) (x)]
34 #define diatoupper(x)     _diacasemap[(unsigned char) (x)]
35 extern int atalk_aton     __P((char *, struct at_addr *));
36 extern void bprint        __P((char *, int));
37 extern int strdiacasecmp  __P((const char *, const char *));
38 extern int strndiacasecmp __P((const char *, const char *, size_t));
39 extern pid_t server_lock  __P((char * /*program*/, char * /*file*/, 
40                                int /*debug*/));
41 extern void fault_setup   __P((void (*fn)(void *)));
42 #define server_unlock(x)  (unlink(x))
43
44 #ifndef HAVE_STRLCPY
45 size_t strlcpy __P((char *, const char *, size_t));
46 #endif
47  
48 #ifndef HAVE_STRLCAT
49 size_t strlcat __P((char *, const char *, size_t));
50 #endif
51
52 #ifndef HAVE_DLFCN_H
53 extern void *mod_open    __P((const char *));
54 extern void *mod_symbol  __P((void *, const char *));
55 extern void mod_close    __P((void *));
56 #define mod_error()      ""
57 #else /* ! HAVE_DLFCN_H */
58 #include <dlfcn.h>
59
60 #ifndef RTLD_NOW
61 #define RTLD_NOW 1
62 #endif /* ! RTLD_NOW */
63
64 /* NetBSD doesn't like RTLD_NOW for dlopen (it fails). Use RTLD_LAZY.
65  * OpenBSD currently does not use the second arg for dlopen(). For
66  * future compatibility we define DL_LAZY */
67 #ifdef __NetBSD__
68 #define mod_open(a)      dlopen(a, RTLD_LAZY)
69 #elif defined(__OpenBSD__)
70 #define mod_open(a)      dlopen(a, DL_LAZY)
71 #else /* ! __NetBSD__ && ! __OpenBSD__ */
72 #define mod_open(a)      dlopen(a, RTLD_NOW)
73 #endif /* __NetBSD__ */
74
75 #ifndef DLSYM_PREPEND_UNDERSCORE
76 #define mod_symbol(a, b) dlsym(a, b)
77 #else /* ! DLSYM_PREPEND_UNDERSCORE */
78 extern void *mod_symbol  __P((void *, const char *));
79 #endif /* ! DLSYM_PREPEND_UNDERSCORE */
80 #define mod_error()      dlerror()
81 #define mod_close(a)     dlclose(a)
82 #endif /* ! HAVE_DLFCN_H */
83
84 #if 0
85 /* volinfo for shell utilities */
86 #define VOLINFOFILE ".volinfo"
87
88 struct volinfo {
89     char                *v_name;
90     char                *v_path;
91     int                 v_flags;
92     int                 v_casefold;
93     char                *v_cnidscheme;
94     char                *v_dbpath;
95     char                *v_volcodepage;
96     charset_t           v_volcharset;
97     char                *v_maccodepage;
98     charset_t           v_maccharset;
99     int                 v_adouble;  /* default adouble format */
100     char                *(*ad_path)(const char *, int);
101     char                *v_dbd_host;
102     int                 v_dbd_port;
103 };
104
105 extern int loadvolinfo __P((char *path, struct volinfo *vol));
106 extern int vol_load_charsets __P(( struct volinfo *vol));
107 #endif /* 0 */
108
109 #endif