]> arthur.barton.de Git - netatalk.git/blob - bin/ad/ad.h
Merge master
[netatalk.git] / bin / ad / ad.h
1 /* 
2    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
3    
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8  
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 */
14
15 #ifndef AD_H
16 #define AD_H
17
18 #if !defined(__FreeBSD__)
19 # define _XOPEN_SOURCE 600
20 #endif
21
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <signal.h>
25 #include <arpa/inet.h>
26
27 #include <atalk/ftw.h>
28 #include <atalk/volinfo.h>
29 #include <atalk/cnid.h>
30 #include <atalk/compat.h>
31
32 #define DIR_DOT_OR_DOTDOT(a) \
33         ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0))
34
35 #ifndef TIMESPEC_TO_TIMEVAL
36 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
37     (tv)->tv_sec = (ts)->tv_sec; \
38     (tv)->tv_usec = (ts)->tv_nsec / 1000; \
39     }
40 #endif
41
42 enum logtype {STD, DBG};
43
44 #define SLOG(...)                             \
45     _log(STD, __VA_ARGS__)
46
47 #define ERROR(...)                              \
48     do {                                        \
49         _log(STD, __VA_ARGS__);                 \
50         exit(1);                                \
51     } while (0)
52
53 typedef struct {
54     struct volinfo volinfo;
55     struct vol     volume;
56     char           db_stamp[ADEDLEN_PRIVSYN];
57 } afpvol_t;
58
59 extern int log_verbose;             /* Logging flag */
60 extern void _log(enum logtype lt, char *fmt, ...);
61
62 extern int ad_ls(int argc, char **argv);
63 extern int ad_cp(int argc, char **argv);
64 extern int ad_rm(int argc, char **argv);
65 extern int ad_mv(int argc, char **argv);
66 extern int ad_find(int argc, char **argv);
67
68 /* ad_util.c */
69 extern int openvol(const char *path, afpvol_t *vol);
70 extern void closevol(afpvol_t *vol);
71 extern cnid_t cnid_for_path(const afpvol_t *vol, const char *path, cnid_t *did);
72 extern cnid_t cnid_for_paths_parent(const afpvol_t *vol, const char *path, cnid_t *did);
73 extern char *utompath(const struct volinfo *volinfo, const char *upath);
74 extern int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path, size_t buflen);
75
76 typedef struct {
77     char *p_end;/* pointer to NULL at end of path */
78     char *target_end;/* pointer to end of target base */
79     char p_path[MAXPATHLEN + 2];/* pointer to the start of a path */
80 } PATH_T;
81
82 extern PATH_T to;
83 extern int fflag, iflag, lflag, nflag, pflag, vflag;
84
85 #endif /* AD_H */