netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
nad.h
Go to the documentation of this file.
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 <arpa/inet.h>
19#include <signal.h>
20#include <sys/stat.h>
21#include <sys/types.h>
22
23#include <atalk/globals.h>
24#include <atalk/cnid.h>
25#include <atalk/compat.h>
26#include <atalk/volume.h>
27
28#define DIR_DOT_OR_DOTDOT(a) \
29 ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0))
30
31#define ADVOL_V2_OR_EA(ad) ((ad) == AD_VERSION2 || (ad) == AD_VERSION_EA)
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 vol *vol;
46 char db_stamp[ADEDLEN_PRIVSYN];
47 bool owns_cdb;
48} afpvol_t;
49
50 extern int log_verbose;
51 extern volatile sig_atomic_t alarmed;
52 extern void _log(enum logtype lt, char *fmt, ...);
53 extern void set_signal(void);
54
55 extern int nad_ls(int argc, char **argv, AFPObj *obj);
56 extern int nad_cp(int argc, char **argv, AFPObj *obj);
57 extern int nad_rm(int argc, char **argv, AFPObj *obj);
58 extern int nad_mv(int argc, char **argv, AFPObj *obj);
59 extern int nad_set(int argc, char **argv, AFPObj *obj);
60 extern int nad_find(int argc, char **argv, AFPObj *obj);
61 extern int nad_mkdir(int argc, char **argv, AFPObj *obj);
62 extern int nad_rmdir(int argc, char **argv, AFPObj *obj);
63
64/* ad_util.c */
65 extern int openvol(AFPObj *obj, const char *path, afpvol_t *vol);
66 extern int openvol_optional(AFPObj *obj, const char *path, afpvol_t *vol);
67 extern void closevol(afpvol_t *vol);
68 extern cnid_t cnid_for_paths_parent(const afpvol_t *vol, const char *path,
69 cnid_t *did);
70 extern char *utompath(const struct vol *, const char *);
71 extern int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol,
72 char *path);
73
74 typedef struct {
75 char *p_end;
76 char *target_end;
77 char p_path[MAXPATHLEN + 2];
78} PATH_T;
79
80 extern int fflag, iflag, lflag, nflag, pflag, vflag;
81
82#endif /* AD_H */
ADEDLEN_PRIVSYN
#define ADEDLEN_PRIVSYN
Definition adouble.h:112
cnid_t
uint32_t cnid_t
Definition adouble.h:156
alarmed
volatile sig_atomic_t alarmed
Definition cmd_dbd.c:40
logtype
logtype
Definition cmd_dbd.h:9
cnid.h
compat.h
globals.h
volume.h
log_verbose
int log_verbose
Definition nad_util.c:77
vflag
int vflag
Definition nad.h:80
_log
void _log(enum logtype lt, char *fmt,...)
Definition nad_util.c:118
openvol
int openvol(AFPObj *obj, const char *path, afpvol_t *vol)
Load volinfo and initialize struct vol.
Definition nad_util.c:210
nad_ls
int nad_ls(int argc, char **argv, AFPObj *obj)
Definition nad_ls.c:803
convert_dots_encoding
int convert_dots_encoding(const afpvol_t *svol, const afpvol_t *dvol, char *path)
Convert dot encoding of basename in place.
Definition nad_util.c:249
utompath
char * utompath(const struct vol *, const char *)
DBG
@ DBG
Definition nad.h:33
STD
@ STD
Definition nad.h:33
pflag
int pflag
Definition nad.h:80
nflag
int nflag
Definition nad.h:80
nad_mkdir
int nad_mkdir(int argc, char **argv, AFPObj *obj)
lflag
int lflag
Definition nad.h:80
nad_rm
int nad_rm(int argc, char **argv, AFPObj *obj)
closevol
void closevol(afpvol_t *vol)
Definition nad_util.c:225
nad_cp
int nad_cp(int argc, char **argv, AFPObj *obj)
cnid_for_paths_parent
cnid_t cnid_for_paths_parent(const afpvol_t *vol, const char *path, cnid_t *did)
Resolves CNID of a given paths parent directory.
Definition nad_util.c:305
fflag
int fflag
Definition nad_cp.c:90
nad_rmdir
int nad_rmdir(int argc, char **argv, AFPObj *obj)
openvol_optional
int openvol_optional(AFPObj *obj, const char *path, afpvol_t *vol)
Open an AFP volume, or return a stub for non-AFP paths.
Definition nad_util.c:153
nad_set
int nad_set(int argc, char **argv, AFPObj *obj)
Definition nad_set.c:314
set_signal
void set_signal(void)
Definition nad_util.c:86
iflag
int iflag
Definition nad.h:80
nad_mv
int nad_mv(int argc, char **argv, AFPObj *obj)
nad_find
int nad_find(int argc, char **argv, AFPObj *obj)
Definition nad_find.c:153
did
cnid_t did
Definition nad_cp.c:93
obj
static AFPObj obj
Definition netatalk.c:69
AFPObj
Definition globals.h:166
PATH_T
Definition nad.h:74
PATH_T::p_end
char * p_end
Definition nad.h:75
PATH_T::target_end
char * target_end
Definition nad.h:76
PATH_T::p_path
char p_path[MAXPATHLEN+2]
Definition nad.h:77
afpvol_t
Definition nad.h:44
afpvol_t::db_stamp
char db_stamp[ADEDLEN_PRIVSYN]
Definition nad.h:46
afpvol_t::vol
struct vol * vol
Definition nad.h:45
afpvol_t::owns_cdb
bool owns_cdb
Definition nad.h:47
path
Definition include/atalk/directory.h:123
vol
Definition include/atalk/volume.h:33