]> arthur.barton.de Git - netatalk.git/blobdiff - include/atalk/util.h
lchdir: use chdir + getcwd
[netatalk.git] / include / atalk / util.h
index 736fab22cd5fb1823e6e8b903001eca9c687ed3c..0106db2fa48d5e9712af71f77d9135d74c20fe73 100644 (file)
@@ -1,5 +1,15 @@
 /*
- * $Id: util.h,v 1.11 2009-10-13 22:55:37 didg 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
@@ -12,6 +22,7 @@
 #endif /* HAVE_UNISTD_H */
 #include <netatalk/at.h>
 #include <atalk/unicode.h>
+#include <atalk/volume.h>
 
 /* exit error codes */
 #define EXITERR_CLNT 1  /* client related error */
@@ -19,8 +30,6 @@
 #define EXITERR_SYS  3  /* local system error */
 
 
-extern int     sys_ftruncate (int fd, off_t length);
-
 #ifdef WITH_SENDFILE
 extern ssize_t sys_sendfile (int __out_fd, int __in_fd, off_t *__offset,size_t __count);
 #endif
@@ -41,12 +50,17 @@ extern pid_t server_lock  (char * /*program*/, char * /*file*/,
 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
-size_t strlcpy (char *, const char *, size_t);
+UAM_MODULE_EXPORT size_t strlcpy (char *, const char *, size_t);
 #endif
  
 #ifndef HAVE_STRLCAT
-size_t strlcat (char *, const char *, size_t);
+UAM_MODULE_EXPORT size_t strlcat (char *, const char *, size_t);
 #endif
 
 #ifndef HAVE_DLFCN_H
@@ -81,74 +95,11 @@ extern void *mod_symbol  (void *, const char *);
 #define mod_close(a)     dlclose(a)
 #endif /* ! HAVE_DLFCN_H */
 
-#if 0
-/* volinfo for shell utilities */
-#define VOLINFOFILE ".volinfo"
-
-struct volinfo {
-    char                *v_name;
-    char                *v_path;
-    int                 v_flags;
-    int                 v_casefold;
-    char                *v_cnidscheme;
-    char                *v_dbpath;
-    char                *v_volcodepage;
-    charset_t           v_volcharset;
-    char                *v_maccodepage;
-    charset_t           v_maccharset;
-    int                 v_adouble;  /* default adouble format */
-    char                *(*ad_path)(const char *, int);
-    char                *v_dbd_host;
-    int                 v_dbd_port;
-};
-
-extern int loadvolinfo (char *path, struct volinfo *vol);
-extern int vol_load_charsets ( struct volinfo *vol);
-#endif /* 0 */
+/******************************************************************
+ * locking.c
+ ******************************************************************/
 
-/*
- * Function: lock_reg
- *
- * Purpose: lock a file with fctnl
- *
- * Arguments:
- *
- *    fd         (r) File descriptor
- *    cmd        (r) cmd to fcntl, only F_SETLK is usable here
- *    type       (r) F_RDLCK, F_WRLCK, F_UNLCK
- *    offset     (r) byte offset relative to l_whence
- *    whence     (r) SEEK_SET, SEEK_CUR, SEEK_END
- *    len        (r) no. of bytes (0 means to EOF)
- *
- * Returns: 0 on success, -1 on failure
- *          fcntl return value and errno
- *
- * Effects:
- *
- * Function called by macros to ease locking.
- */
 extern int lock_reg(int fd, int cmd, int type, off_t offest, int whence, off_t len);
-
-/*
- * Macros: read_lock, write_lock, un_lock
- *
- * Purpose: lock and unlock files
- *
- * Arguments:
- *
- *    fd         (r) File descriptor
- *    offset     (r) byte offset relative to l_whence
- *    whence     (r) SEEK_SET, SEEK_CUR, SEEK_END
- *    len        (r) no. of bytes (0 means to EOF)
- *
- * Returns: 0 on success, -1 on failure
- *          fcntl return value and errno
- *
- * Effects:
- *
- * Nice locking macros.
- */
-
 #define read_lock(fd, offset, whence, len) \
     lock_reg((fd), F_SETLK, F_RDLCK, (offset), (whence), (len))
 #define write_lock(fd, offset, whence, len) \
@@ -156,4 +107,21 @@ extern int lock_reg(int fd, int cmd, int type, off_t offest, int whence, off_t l
 #define unlock(fd, offset, whence, len) \
     lock_reg((fd), F_SETLK, F_UNLCK, (offset), (whence), (len))
 
-#endif
+/******************************************************************
+ * 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 */