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 24#include <atalk/ftw.h> 25#include <atalk/volinfo.h> 26#include <atalk/cnid.h> 27 28#define DIR_DOT_OR_DOTDOT(a) \ 29 ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0)) 30 31#ifndef TIMESPEC_TO_TIMEVAL 32#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 33 (tv)->tv_sec = (ts)->tv_sec; \ 34 (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 35 } 36#endif 37 38enum logtype {STD, DBG}; 39 40#define SLOG(...) \ 41 _log(STD, __VA_ARGS__) 42 43#define ERROR(...) \ 44 do { \ 45 _log(STD, __VA_ARGS__); \ 46 exit(1); \ 47 } while (0) 48 49typedef struct { 50 struct volinfo volinfo; 51 struct vol volume; 52 char db_stamp[ADEDLEN_PRIVSYN]; 53} afpvol_t; 54 55extern int log_verbose; /* Logging flag */ 56extern void _log(enum logtype lt, char *fmt, ...); 57 58extern int ad_ls(int argc, char **argv); 59extern int ad_cp(int argc, char **argv); 60extern int ad_rm(int argc, char **argv); 61extern int ad_mv(int argc, char **argv); 62extern int ad_find(int argc, char **argv); 63 64/* ad_util.c */ 65extern int openvol(const char *path, afpvol_t *vol); 66extern void closevol(afpvol_t *vol); 67extern cnid_t cnid_for_path(const afpvol_t *vol, const char *path, cnid_t *did); 68extern cnid_t cnid_for_paths_parent(const afpvol_t *vol, const char *path, cnid_t *did); 69extern char *utompath(const struct volinfo *volinfo, const char *upath); 70extern int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path, size_t buflen); 71 72typedef struct { 73 char *p_end;/* pointer to NULL at end of path */ 74 char *target_end;/* pointer to end of target base */ 75 char p_path[MAXPATHLEN + 2];/* pointer to the start of a path */ 76} PATH_T; 77 78extern PATH_T to; 79extern int fflag, iflag, lflag, nflag, pflag, vflag; 80 81#endif /* AD_H */ 82