Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / filesystem / DllLibAfp.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2011-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "DynamicDll.h"
24
25 //libafpclient includes
26 #ifdef __cplusplus
27 extern "C" {
28 #endif   
29 #include <afpfs-ng/libafpclient.h>
30 #include <afpfs-ng/map_def.h>
31 #include <afpfs-ng/midlevel.h>
32 #ifdef __cplusplus
33 }
34 #endif
35
36
37 //#define USE_CVS_AFPFS
38 #ifdef USE_CVS_AFPFS
39 #define afp_wrap_open                 afp_ml_open
40 #define afp_wrap_close                afp_ml_close
41 #define afp_wrap_read                 afp_ml_read
42 #define afp_wrap_write                afp_ml_write
43 #define afp_wrap_getattr              afp_ml_getattr
44 #define afp_wrap_server_full_connect  afp_server_full_connect
45 #define afp_wrap_unlink               afp_ml_unlink
46 #define afp_wrap_rename               afp_ml_rename
47 #define afp_wrap_creat                afp_ml_creat
48 #define afp_wrap_readdir              afp_ml_readdir
49 #define afp_wrap_readlink             afp_ml_readlink
50 #define afp_wrap_mkdir                afp_ml_mkdir
51 #define afp_wrap_rmdir                afp_ml_rmdir
52 #else
53 #define afp_wrap_open                 ml_open
54 #define afp_wrap_close                ml_close
55 #define afp_wrap_read                 ml_read
56 #define afp_wrap_write                ml_write
57 #define afp_wrap_getattr              ml_getattr
58 #define afp_wrap_server_full_connect  afp_server_full_connect
59 #define afp_wrap_unlink               ml_unlink
60 #define afp_wrap_rename               ml_rename
61 #define afp_wrap_creat                ml_creat
62 #define afp_wrap_readdir              ml_readdir
63 #define afp_wrap_readlink             ml_readlink
64 #define afp_wrap_mkdir                ml_mkdir
65 #define afp_wrap_rmdir                ml_rmdir
66 #endif
67
68
69 class DllLibAfpInterface
70 {
71 public:
72   virtual ~DllLibAfpInterface() {}
73
74   virtual void libafpclient_register(struct libafpclient * tmpclient)=0;
75   virtual int init_uams(void)=0;
76   virtual int afp_main_quick_startup(pthread_t * thread)=0;
77   virtual int afp_unmount_all_volumes(struct afp_server * server)=0;
78   virtual int afp_unmount_volume(struct afp_volume * volume)=0;
79   virtual struct afp_volume * find_volume_by_name(struct afp_server * server, const char * volname)=0;
80   virtual int afp_connect_volume(struct afp_volume * volume, struct afp_server * server, char * mesg, unsigned int * l, unsigned int max)=0;
81   virtual int afp_parse_url(struct afp_url * url, const char * toparse, int verbose)=0;
82   virtual unsigned int find_uam_by_name(const char * name)=0;
83   virtual unsigned int default_uams_mask(void)=0;
84   virtual char * uam_bitmap_to_string(unsigned int bitmap)=0;
85   virtual void afp_default_url(struct afp_url *url)=0;
86   virtual char * get_uam_names_list(void)=0;
87   virtual void afp_ml_filebase_free(struct afp_file_info **filebase)=0;
88   
89 #ifdef USE_CVS_AFPFS  
90   virtual struct afp_server * afp_server_full_connect(void * priv, struct afp_connection_request * req, int * error)=0;
91   virtual int afp_ml_open(struct afp_volume * volume, const char *path, int flags, struct afp_file_info **newfp)=0;
92   virtual int afp_ml_close(struct afp_volume * volume, const char * path, struct afp_file_info * fp)=0;
93   virtual int afp_ml_read(struct afp_volume * volume, const char *path, char *buf, size_t size, off_t offset, struct afp_file_info *fp, int * eof)=0;
94   virtual int afp_ml_write(struct afp_volume * volume, const char * path, const char *data, size_t size, off_t offset, struct afp_file_info * fp, uid_t uid, gid_t gid)=0;
95   virtual int afp_ml_getattr(struct afp_volume * volume, const char *path, struct stat *stbuf)=0;
96   virtual int afp_ml_unlink(struct afp_volume * vol, const char *path)=0;
97   virtual int afp_ml_rename(struct afp_volume * vol, const char * path_from, const char * path_to)=0;
98   virtual int afp_ml_creat(struct afp_volume * volume, const char *path, mode_t mode)=0;
99   virtual int afp_ml_readdir(struct afp_volume * volume, const char *path, struct afp_file_info **base)=0;
100   virtual int afp_ml_readlink(struct afp_volume * vol, const char * path, char *buf, size_t size)=0;  
101   virtual int afp_ml_mkdir(struct afp_volume * vol, const char * path, mode_t mode)=0;
102   virtual int afp_ml_rmdir(struct afp_volume * vol, const char *path)=0;
103
104 #else
105   virtual struct afp_server * afp_server_full_connect(void * priv, struct afp_connection_request * req)=0;
106   virtual int ml_open(struct afp_volume * volume, const char *path, int flags, struct afp_file_info **newfp)=0;
107   virtual int ml_close(struct afp_volume * volume, const char * path, struct afp_file_info * fp)=0;
108   virtual int ml_read(struct afp_volume * volume, const char *path, char *buf, size_t size, off_t offset, struct afp_file_info *fp, int * eof)=0;
109   virtual int ml_write(struct afp_volume * volume, const char * path, const char *data, size_t size, off_t offset, struct afp_file_info * fp, uid_t uid, gid_t gid)=0;
110   virtual int ml_getattr(struct afp_volume * volume, const char *path, struct stat *stbuf)=0;
111   virtual int ml_unlink(struct afp_volume * vol, const char *path)=0;
112   virtual int ml_rename(struct afp_volume * vol, const char * path_from, const char * path_to)=0;
113   virtual int ml_creat(struct afp_volume * volume, const char *path, mode_t mode)=0;
114   virtual int ml_readdir(struct afp_volume * volume, const char *path, struct afp_file_info **base)=0;
115   virtual int ml_readlink(struct afp_volume * vol, const char * path, char *buf, size_t size)=0;
116   virtual int ml_mkdir(struct afp_volume * vol, const char * path, mode_t mode)=0;
117   virtual int ml_rmdir(struct afp_volume * vol, const char *path)=0;
118
119 #endif
120
121 };
122
123 class DllLibAfp : public DllDynamic, DllLibAfpInterface
124 {
125   DECLARE_DLL_WRAPPER(DllLibAfp, DLL_PATH_LIBAFP)
126   DEFINE_METHOD0(int,                   init_uams)  
127   DEFINE_METHOD0(unsigned int,          default_uams_mask)    
128   DEFINE_METHOD0(char *,                get_uam_names_list)      
129
130   DEFINE_METHOD1(void,                  libafpclient_register,            (struct libafpclient *p1))
131   DEFINE_METHOD1(int,                   afp_main_quick_startup,           (pthread_t *p1))  
132   DEFINE_METHOD1(int,                   afp_unmount_all_volumes,          (struct afp_server *p1))    
133   DEFINE_METHOD1(int,                   afp_unmount_volume,               (struct afp_volume *p1))
134   DEFINE_METHOD1(unsigned int,          find_uam_by_name,                 (const char *p1))      
135   DEFINE_METHOD1(char *,                uam_bitmap_to_string,             (unsigned int p1))        
136   DEFINE_METHOD1(void,                  afp_default_url,                  (struct afp_url *p1))  
137   DEFINE_METHOD1(void,                  afp_ml_filebase_free,             (struct afp_file_info **p1))
138
139 #ifdef USE_CVS_AFPFS
140   DEFINE_METHOD3(struct afp_server *,   afp_wrap_server_full_connect,     (void *p1, struct afp_connection_request *p2, int *p3))        
141 #else
142   DEFINE_METHOD2(struct afp_server *,   afp_wrap_server_full_connect,     (void *p1, struct afp_connection_request *p2))        
143 #endif
144
145   DEFINE_METHOD2(struct afp_volume *,   find_volume_by_name,              (struct afp_server *p1, const char *p2))      
146   DEFINE_METHOD2(int,                   afp_wrap_unlink,                  (struct afp_volume *p1, const char *p2))          
147   DEFINE_METHOD2(int,                   afp_wrap_rmdir,                   (struct afp_volume *p1, const char *p2))            
148  
149   DEFINE_METHOD3(int,                   afp_parse_url,                    (struct afp_url *p1, const char *p2, int p3))      
150   DEFINE_METHOD3(int,                   afp_wrap_close,                   (struct afp_volume *p1, const char *p2, struct afp_file_info *p3))        
151   DEFINE_METHOD3(int,                   afp_wrap_getattr,                 (struct afp_volume *p1, const char *p2, struct stat *p3))          
152   DEFINE_METHOD3(int,                   afp_wrap_rename,                  (struct afp_volume *p1, const char *p2, const char *p3))            
153   DEFINE_METHOD3(int,                   afp_wrap_creat,                   (struct afp_volume *p1, const char *p2, mode_t p3))              
154   DEFINE_METHOD3(int,                   afp_wrap_readdir,                 (struct afp_volume *p1, const char *p2, struct afp_file_info **p3))                 
155   DEFINE_METHOD3(int,                   afp_wrap_mkdir,                   (struct afp_volume *p1, const char *p2, mode_t p3))                  
156
157   DEFINE_METHOD4(int,                   afp_wrap_open,                    (struct afp_volume *p1, const char *p2, int p3, struct afp_file_info **p4))        
158   DEFINE_METHOD4(int,                   afp_wrap_readlink,                (struct afp_volume *p1, const char *p2, char *p3, size_t p4))
159   
160   DEFINE_METHOD5(int,                   afp_connect_volume,               (struct afp_volume *p1, struct afp_server *p2, char *p3, unsigned int *p4, unsigned int p5))        
161   
162   DEFINE_METHOD7(int,                   afp_wrap_read,                    (struct afp_volume *p1, const char *p2, char *p3, size_t p4, off_t p5, struct afp_file_info *p6, int *p7))
163   
164   DEFINE_METHOD8(int,                   afp_wrap_write,                   (struct afp_volume *p1, const char *p2, const char *p3, size_t p4, off_t p5, struct afp_file_info *p6, uid_t p7, gid_t p8))
165
166
167
168   BEGIN_METHOD_RESOLVE()
169     RESOLVE_METHOD_RENAME(init_uams,init_uams)
170     RESOLVE_METHOD_RENAME(libafpclient_register, libafpclient_register)
171     RESOLVE_METHOD_RENAME(afp_main_quick_startup, afp_main_quick_startup)
172     RESOLVE_METHOD_RENAME(afp_unmount_all_volumes, afp_unmount_all_volumes)        
173     RESOLVE_METHOD_RENAME(afp_unmount_all_volumes, afp_unmount_all_volumes)
174     RESOLVE_METHOD_RENAME(find_volume_by_name, find_volume_by_name)    
175     RESOLVE_METHOD_RENAME(afp_connect_volume, afp_connect_volume)        
176     RESOLVE_METHOD_RENAME(afp_parse_url, afp_parse_url)            
177     RESOLVE_METHOD_RENAME(find_uam_by_name, find_uam_by_name)                
178     RESOLVE_METHOD_RENAME(default_uams_mask, default_uams_mask) 
179     RESOLVE_METHOD_RENAME(uam_bitmap_to_string, uam_bitmap_to_string)     
180     RESOLVE_METHOD_RENAME(afp_default_url, afp_default_url)         
181     RESOLVE_METHOD_RENAME(get_uam_names_list, get_uam_names_list)
182     RESOLVE_METHOD_RENAME(afp_ml_filebase_free, afp_ml_filebase_free)
183
184 #ifdef USE_CVS_AFPFS                       
185     RESOLVE_METHOD_RENAME(afp_server_full_connect, afp_server_full_connect)                        
186     RESOLVE_METHOD_RENAME(afp_ml_open, afp_ml_open)                            
187     RESOLVE_METHOD_RENAME(afp_ml_close, afp_ml_close)                                
188     RESOLVE_METHOD_RENAME(afp_ml_read, afp_ml_read)                                    
189     RESOLVE_METHOD_RENAME(afp_ml_write, afp_ml_write)                                        
190     RESOLVE_METHOD_RENAME(afp_ml_getattr, afp_ml_getattr)                                            
191     RESOLVE_METHOD_RENAME(afp_ml_unlink, afp_ml_unlink)                                                
192     RESOLVE_METHOD_RENAME(afp_ml_rename, afp_ml_rename)                                                    
193     RESOLVE_METHOD_RENAME(afp_ml_creat, afp_ml_creat)                                                        
194     RESOLVE_METHOD_RENAME(afp_ml_readdir, afp_ml_readdir)
195     RESOLVE_METHOD_RENAME(afp_ml_readlink, afp_ml_readlink)    
196     RESOLVE_METHOD_RENAME(afp_ml_mkdir, afp_ml_mkdir)                                                                
197     RESOLVE_METHOD_RENAME(afp_ml_rmdir, afp_ml_rmdir)  
198 #else
199     RESOLVE_METHOD_RENAME(afp_server_full_connect, afp_server_full_connect)                        
200     RESOLVE_METHOD_RENAME(ml_open, ml_open)                            
201     RESOLVE_METHOD_RENAME(ml_close, ml_close)                                
202     RESOLVE_METHOD_RENAME(ml_read, ml_read)                                    
203     RESOLVE_METHOD_RENAME(ml_write, ml_write)                                        
204     RESOLVE_METHOD_RENAME(ml_getattr, ml_getattr)                                            
205     RESOLVE_METHOD_RENAME(ml_unlink, ml_unlink)                                                
206     RESOLVE_METHOD_RENAME(ml_rename, ml_rename)                                                    
207     RESOLVE_METHOD_RENAME(ml_creat, ml_creat)                                                        
208     RESOLVE_METHOD_RENAME(ml_readdir, ml_readdir)
209     RESOLVE_METHOD_RENAME(ml_readlink, ml_readlink)
210     RESOLVE_METHOD_RENAME(ml_mkdir, ml_mkdir)                                                                
211     RESOLVE_METHOD_RENAME(ml_rmdir, ml_rmdir) 
212 #endif
213   END_METHOD_RESOLVE()
214 };