]> arthur.barton.de Git - netatalk.git/blob - bin/ad/ad.h
Rename cfrombstring to cfrombstr and msic
[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
27 #define STRCMP(a,b,c) (strcmp(a,c) b 0)
28
29 #define DIR_DOT_OR_DOTDOT(a) \
30         ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0))
31
32 enum logtype {STD, DBG};
33
34 #define SLOG(...)                             \
35     _log(STD, __VA_ARGS__)
36
37 #define ERROR(...)                              \
38     do {                                        \
39         _log(STD, __VA_ARGS__);                 \
40         exit(1);                                \
41     } while (0)
42
43 typedef struct {
44     struct volinfo volinfo;
45 //    char *basename;
46 } afpvol_t;
47
48 extern int log_verbose;             /* Logging flag */
49 extern void _log(enum logtype lt, char *fmt, ...);
50
51 extern struct volinfo svolinfo, dvolinfo;
52 extern struct vol svolume, dvolume;
53
54 extern int ad_ls(int argc, char **argv);
55 extern int ad_cp(int argc, char **argv);
56
57 /* ad_util.c */
58 extern int newvol(const char *path, afpvol_t *vol);
59 extern void freevol(afpvol_t *vol);
60 extern cnid_t cnid_for_path(const struct volinfo *vi, const struct vol *vol, const char *path);
61 extern char *utompath(const struct volinfo *volinfo, char *upath);
62
63 struct FTWELEM {
64     const struct FTW  *ftw;
65     const char        *ftw_path;
66     int               ftw_base_off;
67     int               ftw_tflag;
68     const struct stat *ftw_statp;
69 };
70
71 typedef struct {
72     char *p_end;/* pointer to NULL at end of path */
73     char *target_end;/* pointer to end of target base */
74     char p_path[PATH_MAX];/* pointer to the start of a path */
75 } PATH_T;
76
77 extern PATH_T to;
78 extern int fflag, iflag, lflag, nflag, pflag, vflag;
79 extern volatile sig_atomic_t info;
80
81 extern int ftw_copy_file(const struct FTW *, const char *, const struct stat *, int);
82 extern int copy_link(const struct FTW *, const char *, const struct stat *, int);
83 extern int setfile(const struct stat *, int);
84 extern int preserve_dir_acls(const struct stat *, char *, char *);
85 extern int preserve_fd_acls(int, int);
86
87 #endif /* AD_H */