]> arthur.barton.de Git - netatalk.git/blob - bin/ad/ad.h
CNID fixes
[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 #define _XOPEN_SOURCE 600
19
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <signal.h>
23
24 #include <atalk/ftw.h>
25 #include <atalk/volinfo.h>
26 #include <atalk/cnid.h>
27
28 #define STRCMP(a,b,c) (strcmp(a,c) b 0)
29
30 #define DIR_DOT_OR_DOTDOT(a) \
31         ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0))
32
33 enum logtype {STD, DBG};
34
35 #define SLOG(...)                             \
36     _log(STD, __VA_ARGS__)
37
38 #define ERROR(...)                              \
39     do {                                        \
40         _log(STD, __VA_ARGS__);                 \
41         exit(1);                                \
42     } while (0)
43
44 typedef struct {
45     struct volinfo volinfo;
46     struct vol     volume;
47     char           db_stamp[ADEDLEN_PRIVSYN];
48 } afpvol_t;
49
50 extern int log_verbose;             /* Logging flag */
51 extern void _log(enum logtype lt, char *fmt, ...);
52
53 extern int ad_ls(int argc, char **argv);
54 extern int ad_cp(int argc, char **argv);
55
56 /* ad_util.c */
57 extern int openvol(const char *path, afpvol_t *vol);
58 extern void closevol(afpvol_t *vol);
59 extern cnid_t cnid_for_path(const struct volinfo *vi, const struct vol *vol, const char *path);
60 extern char *utompath(const struct volinfo *volinfo, char *upath);
61
62 struct FTWELEM {
63     const struct FTW  *ftw;
64     const char        *ftw_path;
65     int               ftw_base_off;
66     int               ftw_tflag;
67     const struct stat *ftw_statp;
68 };
69
70 typedef struct {
71     char *p_end;/* pointer to NULL at end of path */
72     char *target_end;/* pointer to end of target base */
73     char p_path[PATH_MAX];/* pointer to the start of a path */
74 } PATH_T;
75
76 extern PATH_T to;
77 extern int fflag, iflag, lflag, nflag, pflag, vflag;
78
79 #endif /* AD_H */