Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / filesystem / DllLibNfs.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 #ifdef __cplusplus
26 extern "C" {
27 #endif  
28 #include <nfsc/libnfs.h>
29 #ifdef __cplusplus
30 }
31 #endif
32
33 #if defined(TARGET_WINDOWS)
34 struct __stat64;
35 #define NFSSTAT struct __stat64
36 #else
37 #define NFSSTAT struct stat
38 #endif
39
40 class DllLibNfsInterface
41 {
42 public:
43   virtual ~DllLibNfsInterface() {}
44
45 //  virtual struct rpc_context *rpc_init_context(void)=0;
46 //  virtual void rpc_destroy_context(struct rpc_context *rpc)=0;
47   virtual void mount_free_export_list(struct exportnode *exports)=0;
48   virtual struct exportnode *mount_getexports(const char *server)=0;
49   virtual struct nfs_server_list *nfs_find_local_servers(void)=0;
50   virtual void   free_nfs_srvr_list(struct nfs_server_list *srv)=0;
51   virtual struct nfs_context *nfs_init_context(void)=0;
52   virtual void nfs_destroy_context(struct nfs_context *nfs)=0;  
53   virtual uint64_t nfs_get_readmax(struct nfs_context *nfs)=0;  
54   virtual uint64_t nfs_get_writemax(struct nfs_context *nfs)=0;
55   virtual char *nfs_get_error(struct nfs_context *nfs)=0;  
56   virtual int nfs_close(struct nfs_context *nfs,     struct nfsfh *nfsfh)=0;
57   virtual int nfs_fsync(struct nfs_context *nfs,     struct nfsfh *nfsfh)=0;  
58   virtual int nfs_mkdir(struct nfs_context *nfs,     const char *path)=0;
59   virtual int nfs_rmdir(struct nfs_context *nfs,     const char *path)=0;
60   virtual int nfs_unlink(struct nfs_context *nfs,    const char *path)=0;
61   virtual void nfs_closedir(struct nfs_context *nfs,      struct nfsdir *nfsdir)=0;      
62   virtual struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir)=0;  
63   virtual int nfs_mount(struct nfs_context *nfs,     const char *server,   const char *exportname)=0;
64   virtual int nfs_stat(struct nfs_context *nfs,      const char *path,     NFSSTAT *st)=0;
65   virtual int nfs_fstat(struct nfs_context *nfs,     struct nfsfh *nfsfh,  NFSSTAT *st)=0;
66   virtual int nfs_truncate(struct nfs_context *nfs,  const char *path,     uint64_t length)=0;
67   virtual int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh,  uint64_t length)=0;
68   virtual int nfs_opendir(struct nfs_context *nfs,   const char *path,     struct nfsdir **nfsdir)=0;
69   virtual int nfs_statvfs(struct nfs_context *nfs,   const char *path,     struct statvfs *svfs)=0;
70   virtual int nfs_chmod(struct nfs_context *nfs,     const char *path,     int mode)=0;
71   virtual int nfs_fchmod(struct nfs_context *nfs,    struct nfsfh *nfsfh,  int mode)=0;
72   virtual int nfs_access(struct nfs_context *nfs,    const char *path,     int mode)=0;
73   virtual int nfs_utimes(struct nfs_context *nfs,    const char *path,     struct timeval *times)=0;
74   virtual int nfs_utime(struct nfs_context *nfs,     const char *path,     struct utimbuf *times)=0;
75   virtual int nfs_symlink(struct nfs_context *nfs,   const char *oldpath,  const char *newpath)=0;
76   virtual int nfs_rename(struct nfs_context *nfs,    const char *oldpath,  const char *newpath)=0;
77   virtual int nfs_link(struct nfs_context *nfs,      const char *oldpath,  const char *newpath)=0;  
78   virtual int nfs_readlink(struct nfs_context *nfs,  const char *path,     char *buf,    int bufsize)=0;
79   virtual int nfs_chown(struct nfs_context *nfs,     const char *path,     int uid,      int gid)=0;
80   virtual int nfs_fchown(struct nfs_context *nfs,    struct nfsfh *nfsfh,  int uid,      int gid)=0;
81   virtual int nfs_open(struct nfs_context *nfs,      const char *path,     int mode,     struct nfsfh **nfsfh)=0;  
82   virtual int nfs_read(struct nfs_context *nfs,      struct nfsfh *nfsfh,  uint64_t count, char *buf)=0;  
83   virtual int nfs_write(struct nfs_context *nfs,     struct nfsfh *nfsfh,  uint64_t count, char *buf)=0;
84   virtual int nfs_creat(struct nfs_context *nfs,     const char *path,     int mode,     struct nfsfh **nfsfh)=0;  
85   virtual int nfs_pread(struct nfs_context *nfs,     struct nfsfh *nfsfh,  uint64_t offset, uint64_t count, char *buf)=0;
86   virtual int nfs_pwrite(struct nfs_context *nfs,    struct nfsfh *nfsfh,  uint64_t offset, uint64_t count, char *buf)=0;
87   virtual int nfs_lseek(struct nfs_context *nfs,     struct nfsfh *nfsfh,  uint64_t offset, int whence,   uint64_t *current_offset)=0;
88 };
89
90 class DllLibNfs : public DllDynamic, DllLibNfsInterface
91 {
92   DECLARE_DLL_WRAPPER(DllLibNfs, DLL_PATH_LIBNFS)
93   DEFINE_METHOD0(struct   nfs_context *, nfs_init_context)
94   DEFINE_METHOD0(struct nfs_server_list *, nfs_find_local_servers)
95   DEFINE_METHOD1(void, free_nfs_srvr_list, (struct nfs_server_list *p1))
96   DEFINE_METHOD1(struct exportnode *, mount_getexports,     (const char *p1))
97   DEFINE_METHOD1(void,    mount_free_export_list,           (struct exportnode *p1))
98   DEFINE_METHOD1(void,    nfs_destroy_context,              (struct nfs_context *p1))
99   DEFINE_METHOD1(uint64_t,  nfs_get_readmax,                  (struct nfs_context *p1))
100   DEFINE_METHOD1(uint64_t,  nfs_get_writemax,                 (struct nfs_context *p1)) 
101   DEFINE_METHOD1(char *,  nfs_get_error,                    (struct nfs_context *p1))    
102   DEFINE_METHOD2(struct nfsdirent *, nfs_readdir,           (struct nfs_context *p1, struct nfsdir *p2))
103   DEFINE_METHOD2(int, nfs_fsync,     (struct nfs_context *p1, struct nfsfh *p2))
104   DEFINE_METHOD2(int, nfs_mkdir,     (struct nfs_context *p1, const char *p2))
105   DEFINE_METHOD2(int, nfs_rmdir,     (struct nfs_context *p1, const char *p2))
106   DEFINE_METHOD2(int, nfs_unlink,    (struct nfs_context *p1, const char *p2))
107   DEFINE_METHOD2(void,nfs_closedir,  (struct nfs_context *p1, struct nfsdir *p2))        
108   DEFINE_METHOD2(int, nfs_close,     (struct nfs_context *p1, struct nfsfh *p2)) 
109   DEFINE_METHOD3(int, nfs_mount,     (struct nfs_context *p1, const char *p2,    const char *p3))
110   DEFINE_METHOD3(int, nfs_stat,      (struct nfs_context *p1, const char *p2,    NFSSTAT *p3))
111   DEFINE_METHOD3(int, nfs_fstat,     (struct nfs_context *p1, struct nfsfh *p2,  NFSSTAT *p3))
112   DEFINE_METHOD3(int, nfs_truncate,  (struct nfs_context *p1, const char *p2,    uint64_t p3))
113   DEFINE_METHOD3(int, nfs_ftruncate, (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3))
114   DEFINE_METHOD3(int, nfs_opendir,   (struct nfs_context *p1, const char *p2,    struct nfsdir **p3))
115   DEFINE_METHOD3(int, nfs_statvfs,   (struct nfs_context *p1, const char *p2,    struct statvfs *p3))
116   DEFINE_METHOD3(int, nfs_chmod,     (struct nfs_context *p1, const char *p2,    int p3))
117   DEFINE_METHOD3(int, nfs_fchmod,    (struct nfs_context *p1, struct nfsfh *p2,  int p3))
118   DEFINE_METHOD3(int, nfs_utimes,    (struct nfs_context *p1, const char *p2,    struct timeval *p3))
119   DEFINE_METHOD3(int, nfs_utime,     (struct nfs_context *p1, const char *p2,    struct utimbuf *p3))
120   DEFINE_METHOD3(int, nfs_access,    (struct nfs_context *p1, const char *p2,    int p3))
121   DEFINE_METHOD3(int, nfs_symlink,   (struct nfs_context *p1, const char *p2,    const char *p3))
122   DEFINE_METHOD3(int, nfs_rename,    (struct nfs_context *p1, const char *p2,    const char *p3))
123   DEFINE_METHOD3(int, nfs_link,      (struct nfs_context *p1, const char *p2,    const char *p3))  
124   DEFINE_METHOD4(int, nfs_open,      (struct nfs_context *p1, const char *p2,    int p3,     struct nfsfh **p4))
125   DEFINE_METHOD4(int, nfs_read,      (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3,  char *p4))
126   DEFINE_METHOD4(int, nfs_write,     (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3,  char *p4))
127   DEFINE_METHOD4(int, nfs_creat,     (struct nfs_context *p1, const char *p2,    int p3,     struct nfsfh **p4))
128   DEFINE_METHOD4(int, nfs_readlink,  (struct nfs_context *p1, const char *p2,    char *p3,   int p4))
129   DEFINE_METHOD4(int, nfs_chown,     (struct nfs_context *p1, const char *p2,    int p3,     int p4))
130   DEFINE_METHOD4(int, nfs_fchown,    (struct nfs_context *p1, struct nfsfh *p2,  int p3,     int p4))
131   DEFINE_METHOD5(int, nfs_pread,     (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3,   uint64_t p4,  char *p5))
132   DEFINE_METHOD5(int, nfs_pwrite,    (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3,   uint64_t p4,  char *p5))
133   DEFINE_METHOD5(int, nfs_lseek,     (struct nfs_context *p1, struct nfsfh *p2,  uint64_t p3,   int p4,     uint64_t *p5))
134
135
136
137   BEGIN_METHOD_RESOLVE()
138     RESOLVE_METHOD_RENAME(mount_free_export_list, mount_free_export_list)
139     RESOLVE_METHOD_RENAME(mount_getexports, mount_getexports)
140     RESOLVE_METHOD_RENAME(nfs_find_local_servers, nfs_find_local_servers)
141     RESOLVE_METHOD_RENAME(free_nfs_srvr_list, free_nfs_srvr_list)        
142     RESOLVE_METHOD_RENAME(nfs_init_context,   nfs_init_context)
143     RESOLVE_METHOD_RENAME(nfs_destroy_context,nfs_destroy_context)
144     RESOLVE_METHOD_RENAME(nfs_get_readmax,    nfs_get_readmax)
145     RESOLVE_METHOD_RENAME(nfs_get_writemax,   nfs_get_writemax)   
146     RESOLVE_METHOD_RENAME(nfs_get_error,      nfs_get_error)
147     RESOLVE_METHOD_RENAME(nfs_readdir,        nfs_readdir)    
148     RESOLVE_METHOD_RENAME(nfs_closedir,       nfs_closedir)  
149     RESOLVE_METHOD_RENAME(nfs_mount,     nfs_mount)
150     RESOLVE_METHOD_RENAME(nfs_stat,      nfs_stat)
151     RESOLVE_METHOD_RENAME(nfs_fstat,     nfs_fstat)
152     RESOLVE_METHOD_RENAME(nfs_open,      nfs_open)
153     RESOLVE_METHOD_RENAME(nfs_close,     nfs_close)
154     RESOLVE_METHOD_RENAME(nfs_pread,     nfs_pread)
155     RESOLVE_METHOD_RENAME(nfs_read,      nfs_read)
156     RESOLVE_METHOD_RENAME(nfs_pwrite,    nfs_pwrite)
157     RESOLVE_METHOD_RENAME(nfs_write,     nfs_write)
158     RESOLVE_METHOD_RENAME(nfs_lseek,     nfs_lseek)
159     RESOLVE_METHOD_RENAME(nfs_fsync,     nfs_fsync)
160     RESOLVE_METHOD_RENAME(nfs_truncate,  nfs_truncate)
161     RESOLVE_METHOD_RENAME(nfs_ftruncate, nfs_ftruncate)
162     RESOLVE_METHOD_RENAME(nfs_mkdir,     nfs_mkdir)
163     RESOLVE_METHOD_RENAME(nfs_rmdir,     nfs_rmdir)
164     RESOLVE_METHOD_RENAME(nfs_creat,     nfs_creat)
165     RESOLVE_METHOD_RENAME(nfs_unlink,    nfs_unlink)
166     RESOLVE_METHOD_RENAME(nfs_opendir,   nfs_opendir)
167     RESOLVE_METHOD_RENAME(nfs_statvfs,   nfs_statvfs)
168     RESOLVE_METHOD_RENAME(nfs_readlink,  nfs_readlink)
169     RESOLVE_METHOD_RENAME(nfs_chmod,     nfs_chmod)
170     RESOLVE_METHOD_RENAME(nfs_fchmod,    nfs_fchmod)
171     RESOLVE_METHOD_RENAME(nfs_chown,     nfs_chown)
172     RESOLVE_METHOD_RENAME(nfs_fchown,    nfs_fchown)
173     RESOLVE_METHOD_RENAME(nfs_utimes,    nfs_utimes)
174     RESOLVE_METHOD_RENAME(nfs_utime,     nfs_utime)
175     RESOLVE_METHOD_RENAME(nfs_access,    nfs_access)
176     RESOLVE_METHOD_RENAME(nfs_symlink,   nfs_symlink)
177     RESOLVE_METHOD_RENAME(nfs_rename,    nfs_rename)
178     RESOLVE_METHOD_RENAME(nfs_link,      nfs_link)      
179   END_METHOD_RESOLVE()
180 };
181