]> arthur.barton.de Git - netatalk.git/blob - bin/ad/ad.h
Fix typo
[netatalk.git] / bin / ad / ad.h
1 /* 
2    Copyright (c) 2009,2011 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 #include <atalk/standards.h>
19
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <signal.h>
23 #include <arpa/inet.h>
24
25 #include <atalk/globals.h>
26 #include <atalk/ftw.h>
27 #include <atalk/cnid.h>
28 #include <atalk/compat.h>
29 #include <atalk/volume.h>
30
31 #define DIR_DOT_OR_DOTDOT(a) \
32         ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0))
33
34 #ifndef TIMESPEC_TO_TIMEVAL
35 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
36     (tv)->tv_sec = (ts)->tv_sec; \
37     (tv)->tv_usec = (ts)->tv_nsec / 1000; \
38     }
39 #endif
40
41 #define ADVOL_V2_OR_EA(ad) ((ad) == AD_VERSION2 || (ad) == AD_VERSION_EA)
42
43 enum logtype {STD, DBG};
44
45 #define SLOG(...)                             \
46     _log(STD, __VA_ARGS__)
47
48 #define ERROR(...)                              \
49     do {                                        \
50         _log(STD, __VA_ARGS__);                 \
51         exit(1);                                \
52     } while (0)
53
54 typedef struct {
55     struct vol     *vol;
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, AFPObj *obj);
63 extern int ad_cp(int argc, char **argv, AFPObj *obj);
64 extern int ad_rm(int argc, char **argv, AFPObj *obj);
65 extern int ad_mv(int argc, char **argv, AFPObj *obj);
66 extern int ad_set(int argc, char **argv, AFPObj *obj);
67 extern int ad_find(int argc, char **argv, AFPObj *obj);
68
69 /* ad_util.c */
70 extern int openvol(AFPObj *obj, const char *path, afpvol_t *vol);
71 extern void closevol(afpvol_t *vol);
72 extern cnid_t cnid_for_path(const afpvol_t *vol, const char *path, cnid_t *did);
73 extern cnid_t cnid_for_paths_parent(const afpvol_t *vol, const char *path, cnid_t *did);
74 extern char *utompath(const struct vol *, const char *);
75 extern int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path, size_t buflen);
76
77 typedef struct {
78     char *p_end;/* pointer to NULL at end of path */
79     char *target_end;/* pointer to end of target base */
80     char p_path[MAXPATHLEN + 2];/* pointer to the start of a path */
81 } PATH_T;
82
83 extern PATH_T to;
84 extern int fflag, iflag, lflag, nflag, pflag, vflag;
85
86 #endif /* AD_H */