[win32] - make it compile on win32

libnfs-4.0.0-vitalif
Memphiz 2011-09-01 21:35:54 +02:00 committed by Ronnie Sahlberg
parent 4b1097cde2
commit a8a1b85846
13 changed files with 93 additions and 55 deletions

View File

@ -17,7 +17,14 @@
/* Example program using the highlevel async interface.
*/
#ifdef WIN32
#include "win32_compat.h"
#else
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
#endif
#define SERVER "10.1.1.27"
#define EXPORT "/VIRTUAL"
#define NFSFILE "/BOOKS/Classics/Dracula.djvu"
@ -27,10 +34,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"

View File

@ -19,13 +19,17 @@
* This allow accurate control of the exact commands that are being used.
*/
#ifdef WIN32
#include "win32_compat.h"
#else
#include <poll.h>
#endif
#define SERVER "10.1.1.27"
#define EXPORT "/shared"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <poll.h>
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"

View File

@ -17,7 +17,14 @@
/* Example program using the highlevel sync interface
*/
#ifdef WIN32
#include "win32_compat.h"
#else
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#endif
#define SERVER "10.1.1.27"
#define EXPORT "/VIRTUAL"
#define NFSFILE "/BOOKS/Classics/Dracula.djvu.truncated"
@ -28,8 +35,6 @@
#define _GNU_SOURCE
#if defined(WIN32)
#include <winsock2.h>
typedef int off_t;
#pragma comment(lib, "ws2_32.lib")
WSADATA wsaData;
#else

View File

@ -12,14 +12,13 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#if defined(WIN32)
#include <winsock2.h>
#ifdef WIN32
#include "win32_compat.h"
#else
#include <unistd.h>
#include <strings.h>
#endif
#endif/*WIN32*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>

View File

@ -17,9 +17,8 @@
/*
* High level api to nfs filesystems
*/
#if defined (WIN32)
#include <winsock2.h>
#ifdef WIN32
#include "win32_compat.h"
#define DllExport
#else
#include <strings.h>
@ -43,9 +42,13 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include "libnfs.h"
#include "libnfs-raw.h"
#include "libnfs-raw-mount.h"
@ -713,8 +716,11 @@ static void statvfs_cb(int status, struct nfs_context *nfs, void *data, void *pr
nfs_set_error(nfs, "statvfs call failed with \"%s\"", (char *)data);
return;
}
#ifndef WIN32
memcpy(cb_data->return_data, data, sizeof(struct statvfs));
#else
cb_data->return_data=NULL;
#endif/**/
}
int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs)
@ -1254,6 +1260,7 @@ void callit_cb(struct rpc_context *rpc, int status, void *data _U_, void *privat
srv_data->srvrs = srvr;
}
#ifndef WIN32
static int send_nfsd_probes(struct rpc_context *rpc, struct ifconf *ifc, struct nfs_list_data *data)
{
char *ptr;
@ -1305,11 +1312,13 @@ static int send_nfsd_probes(struct rpc_context *rpc, struct ifconf *ifc, struct
return 0;
}
#endif/*WIN32 TODO implement this with win32api FIXME*/
struct nfs_server_list *nfs_find_local_servers(void)
{
struct rpc_context *rpc;
struct nfs_list_data data = {0, NULL};
#ifndef WIN32
struct timeval tv_start, tv_current;
struct ifconf ifc;
int size, loop;
@ -1386,7 +1395,7 @@ struct nfs_server_list *nfs_find_local_servers(void)
free_nfs_srvr_list(data.srvrs);
return NULL;
}
#endif/*WIN32 - FIXME redef it when send_nfsd_probes is implemented for win32*/
return data.srvrs;
}
#endif

View File

@ -17,21 +17,17 @@
/*
* High level api to nfs filesystems
*/
#define _GNU_SOURCE
#if defined(WIN32)
#include <winsock2.h>
#ifdef WIN32
#include "win32_compat.h"
#define DllExport
#define O_SYNC 0
typedef int uid_t;
typedef int gid_t;
#else
#include <strings.h>
#include <sys/statvfs.h>
#include <utime.h>
#include <unistd.h>
#endif
#endif/*WIN32*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>
@ -681,10 +677,10 @@ static void nfs_stat_1_cb(struct rpc_context *rpc _U_, int status, void *command
st.st_gid = res->GETATTR3res_u.resok.obj_attributes.gid;
st.st_rdev = 0;
st.st_size = res->GETATTR3res_u.resok.obj_attributes.size;
#if !defined(WIN32)
#ifndef WIN32
st.st_blksize = 4096;
st.st_blocks = res->GETATTR3res_u.resok.obj_attributes.size / 4096;
#endif
#endif//WIN32
st.st_atime = res->GETATTR3res_u.resok.obj_attributes.atime.seconds;
st.st_mtime = res->GETATTR3res_u.resok.obj_attributes.mtime.seconds;
st.st_ctime = res->GETATTR3res_u.resok.obj_attributes.ctime.seconds;
@ -1900,7 +1896,9 @@ static void nfs_statvfs_1_cb(struct rpc_context *rpc _U_, int status, void *comm
FSSTAT3res *res;
struct nfs_cb_data *data = private_data;
struct nfs_context *nfs = data->nfs;
#ifndef WIN32
struct statvfs svfs;
#endif/*WIN32*/
if (status == RPC_STATUS_ERROR) {
data->cb(-EFAULT, nfs, command_data, data->private_data);
@ -1921,6 +1919,7 @@ static void nfs_statvfs_1_cb(struct rpc_context *rpc _U_, int status, void *comm
return;
}
#ifndef WIN32
svfs.f_bsize = 4096;
svfs.f_frsize = 4096;
svfs.f_blocks = res->FSSTAT3res_u.resok.tbytes/4096;
@ -1934,6 +1933,9 @@ static void nfs_statvfs_1_cb(struct rpc_context *rpc _U_, int status, void *comm
svfs.f_namemax = 256;
data->cb(0, nfs, &svfs, data->private_data);
#else
data->cb(0, nfs,NULL, data->private_data);
#endif/*WIN32*/
free_nfs_cb_data(data);
}
@ -2918,7 +2920,7 @@ void nfs_set_error(struct nfs_context *nfs, char *error_string, ...)
free(nfs->rpc->error_string);
}
nfs->rpc->error_string = str;
va_end(ap);
va_end(ap);
}

View File

@ -14,13 +14,14 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#include <winsock2.h>
#ifdef WIN32
#include "win32_compat.h"
#ifndef MSG_DONTWAIT
#define MSG_DONTWAIT 0
#endif
#else
#include <strings.h>
#endif
#endif/*WIN32*/
#include <stdio.h>
#include <stdlib.h>

View File

@ -14,6 +14,16 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef WIN32
#include "win32_compat.h"
#else
#include <unistd.h>
#include <poll.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netdb.h>
#endif/*WIN32*/
#if defined(WIN32)
#include <winsock2.h>
@ -61,7 +71,7 @@ static void set_nonblocking(int fd)
unsigned v;
v = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, v | O_NONBLOCK);
#endif
#endif //FIXME
}
int rpc_get_fd(struct rpc_context *rpc)
@ -140,6 +150,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
rpc_set_error(rpc, "Ioctl FIONREAD returned error : %d. Closing socket.", errno);
return -1;
}
if (available == 0) {
rpc_set_error(rpc, "Socket has been closed");
return -1;
@ -254,7 +265,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
int rpc_service(struct rpc_context *rpc, int revents)
{
if (revents & POLLERR) {
int err = 0;
char err = 0;
socklen_t err_size = sizeof(err);
if (getsockopt(rpc->fd, SOL_SOCKET, SO_ERROR,

View File

@ -15,9 +15,9 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#include <winsock2.h>
#endif
#ifdef WIN32
#include "win32_compat.h"
#endif/*WIN32*/
#include <stdio.h>
#include <errno.h>
@ -28,7 +28,6 @@
#include "libnfs-private.h"
#include "libnfs-raw-mount.h"
int rpc_mount_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;

View File

@ -15,22 +15,14 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#include <winsock2.h>
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
#endif
#ifdef WIN32
#include "win32_compat.h"
#else
#include <sys/stat.h>
#endif/*WIN32*/
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
@ -39,7 +31,9 @@
#include "libnfs-private.h"
#include "libnfs-raw-nfs.h"
#ifdef WIN32
#define bzero(a,b) memset((a),(0),(b))
#endif/*WIN32*/
char *nfsstat3_to_str(int error)
{

View File

@ -14,6 +14,11 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef WIN32
#include "win32_compat.h"
#else
#include <sys/stat.h>
#endif/*WIN32*/
#if defined(WIN32)
#include <winsock2.h>
@ -21,7 +26,6 @@
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>

View File

@ -14,6 +14,9 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef WIN32
#include "win32_compat.h"
#endif/*WIN32*/
#if defined(WIN32)
#include <winsock2.h>

View File

@ -14,6 +14,9 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef WIN32
#include "win32_compat.h"
#endif/*WIN32*/
#if defined(WIN32)
#include <winsock2.h>