Merge branch 'win32' into win32-3
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 3 Sep 2011 00:57:42 +0000 (10:57 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 3 Sep 2011 00:57:42 +0000 (10:57 +1000)
15 files changed:
examples/nfsclient-sync.c
include/libnfs-private.h
include/libnfs.h
lib/init.c
lib/libnfs-sync.c
lib/libnfs.c
lib/libnfs.def [new file with mode: 0644]
lib/pdu.c
lib/socket.c
mount/mount.c
nfs/nfs.c
nfs/nfsacl.c
portmap/portmap.c
rquota/rquota.c
win32build.bat [new file with mode: 0755]

index 322bfa28676eef526760c11b2b54e300a2a04863..00e4c88042eba4a3e50553acb8e79460eb11c03d 100644 (file)
 #define NFSDIR "/BOOKS/Classics/"
 
 #define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+typedef int off_t;
+#pragma comment(lib, "ws2_32.lib")
+WSADATA wsaData;
+#else
+#include <sys/statvfs.h>
+#include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include "libnfs.h"
 #include <rpc/rpc.h>            /* for authunix_create() */
@@ -53,18 +62,25 @@ int main(int argc _U_, char *argv[] _U_)
 {
        struct nfs_context *nfs;
        int i, ret;
+       off_t offset;
        struct client client;
        struct stat st;
        struct nfsfh  *nfsfh;
        struct nfsdir *nfsdir;
        struct nfsdirent *nfsdirent;
-       client.server = SERVER;
-       client.export = EXPORT;
-       client.is_finished = 0;
-       off_t offset;
        struct statvfs svfs;
        exports export, tmp;
 
+#if defined(WIN32)
+       if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
+               printf("Failed to start Winsock2\n");
+               exit(10);
+       }
+#endif
+
+       client.server = SERVER;
+       client.export = EXPORT;
+       client.is_finished = 0;
        export = mount_getexports(SERVER);
        if (export != NULL) {
                printf("exports on server %s\n", SERVER);
@@ -198,11 +214,10 @@ int main(int argc _U_, char *argv[] _U_)
                exit(10);
        }
        while((nfsdirent = nfs_readdir(nfs, nfsdir)) != NULL) {
-               char *filename = NULL;
+         char filename[1024];
                printf("Inode:%d Name:%s ", (int)nfsdirent->inode, nfsdirent->name);
-               asprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
+               sprintf(&filename, "%s/%s", NFSDIR, nfsdirent->name);
                ret = nfs_open(nfs, filename, O_RDONLY, &nfsfh);
-               free(filename);
                if (ret != 0) {
                        printf("Failed to open(%s) %s\n", filename, nfs_get_error(nfs));
                        exit(10);
index c6a8820f6bcae2b5e10e00f4c56fc7bf3e1194e0..4c8594c72452a2c7903cd4070b7863af12801dc7 100644 (file)
@@ -14,6 +14,7 @@
    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/>.
 */
+#include <rpc/xdr.h>
 #include <rpc/auth.h>
 
 struct rpc_context {
index 3a8304a00f9187f782d951d1fa0ae9996d2c9e0e..dd63f9623816f8b4a3d67b28ed89555e7af5048e 100644 (file)
 struct nfs_context;
 struct rpc_context;
 
+#if defined(WIN32)
+#define EXTERN __declspec( dllexport )
+#else
+#define EXTERN 
+#endif
+
+#if defined(WIN32)
+struct statvfs {
+       uint32_t        f_bsize;
+       uint32_t        f_frsize;
+       uint64_t        f_blocks;
+       uint64_t        f_bfree;
+       uint64_t        f_bavail;
+       uint32_t        f_files;
+       uint32_t        f_ffree;
+       uint32_t        f_favail;
+       uint32_t        f_fsid; 
+       uint32_t        f_flag;
+       uint32_t        f_namemax;
+};
+struct utimbuf {
+       time_t actime;
+       time_t modtime;
+};
+#define R_OK   4
+#define W_OK   2
+#define X_OK   1
+#endif
+
 /*
  * Used for interfacing the async version of the api into an external eventsystem
  */
-int nfs_get_fd(struct nfs_context *nfs);
-int nfs_which_events(struct nfs_context *nfs);
-int nfs_service(struct nfs_context *nfs, int revents);
+EXTERN int nfs_get_fd(struct nfs_context *nfs);
+EXTERN int nfs_which_events(struct nfs_context *nfs);
+EXTERN int nfs_service(struct nfs_context *nfs, int revents);
 
 /*
  * Used if you need different credentials than the default for the current user.
  */
 struct AUTH;
-void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
+EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
 
 
 /*
  * When an operation failed, this function can extract a detailed error string.
  */
-char *nfs_get_error(struct nfs_context *nfs);
+EXTERN char *nfs_get_error(struct nfs_context *nfs);
 
 
 /*
@@ -63,11 +92,11 @@ typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *pr
  *  NULL : Failed to create a context.
  *  *nfs : A pointer to an nfs context.
  */
-struct nfs_context *nfs_init_context(void);
+EXTERN struct nfs_context *nfs_init_context(void);
 /*
  * Destroy an nfs context.
  */
-void nfs_destroy_context(struct nfs_context *nfs);
+EXTERN void nfs_destroy_context(struct nfs_context *nfs);
 
 
 struct nfsfh;
@@ -75,12 +104,12 @@ struct nfsfh;
 /*
  * Get the maximum supported READ3 size by the server
  */
-size_t nfs_get_readmax(struct nfs_context *nfs);
+EXTERN size_t nfs_get_readmax(struct nfs_context *nfs);
 
 /*
  * Get the maximum supported WRITE3 size by the server
  */
-size_t nfs_get_writemax(struct nfs_context *nfs);
+EXTERN size_t nfs_get_writemax(struct nfs_context *nfs);
 
 
 /*
@@ -98,14 +127,14 @@ size_t nfs_get_writemax(struct nfs_context *nfs);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
+EXTERN int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
 /*
  * Sync nfs mount.
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
+EXTERN int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
 
 
 
@@ -126,14 +155,14 @@ int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportnam
  *          data is the error string.
  */
 struct stat;
-int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync stat(<filename>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
+EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
 
 
 /*
@@ -151,14 +180,14 @@ int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
+EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
 /*
  * Sync fstat(nfsfh *)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
+EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
 
 
 
@@ -181,14 +210,14 @@ int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
+EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
 /*
  * Sync stat(<filename>)
  * Function returns
  *      0 : The operation was successfull. *nfsfh is filled in.
  * -errno : The command failed.
  */
-int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
+EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
 
 
 
@@ -209,14 +238,14 @@ int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh *
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
+EXTERN int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
 /*
  * Sync close(nfsfh)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
+EXTERN int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
 
 
 /*
@@ -236,14 +265,14 @@ int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, nfs_cb cb, void *private_data);
+EXTERN int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, nfs_cb cb, void *private_data);
 /*
  * Sync pread()
  * Function returns
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
+EXTERN int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
 
 
 
@@ -264,14 +293,14 @@ int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, nfs_cb cb, void *private_data);
+EXTERN int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, nfs_cb cb, void *private_data);
 /*
  * Sync read()
  * Function returns
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
+EXTERN int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
 
 
 
@@ -292,14 +321,14 @@ int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *b
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf, nfs_cb cb, void *private_data);
+EXTERN int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf, nfs_cb cb, void *private_data);
 /*
  * Sync pwrite()
  * Function returns
  *    >=0 : numer of bytes written.
  * -errno : An error occured.
  */
-int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
+EXTERN int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
 
 
 /*
@@ -318,14 +347,14 @@ int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf, nfs_cb cb, void *private_data);
+EXTERN int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf, nfs_cb cb, void *private_data);
 /*
  * Sync write()
  * Function returns
  *    >=0 : numer of bytes written.
  * -errno : An error occured.
  */
-int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
+EXTERN int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
 
 
 /*
@@ -344,14 +373,14 @@ int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, nfs_cb cb, void *private_data);
+EXTERN int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, nfs_cb cb, void *private_data);
 /*
  * Sync lseek()
  * Function returns
  *    >=0 : numer of bytes read.
  * -errno : An error occured.
  */
-int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset);
+EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset);
 
 
 /*
@@ -369,14 +398,14 @@ int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int wh
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
+EXTERN int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
 /*
  * Sync fsync()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
+EXTERN int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
 
 
 
@@ -395,14 +424,14 @@ int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_truncate_async(struct nfs_context *nfs, const char *path, off_t length, nfs_cb cb, void *private_data);
+EXTERN int nfs_truncate_async(struct nfs_context *nfs, const char *path, off_t length, nfs_cb cb, void *private_data);
 /*
  * Sync truncate()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length);
+EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length);
 
 
 
@@ -421,14 +450,14 @@ int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length, nfs_cb cb, void *private_data);
+EXTERN int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length, nfs_cb cb, void *private_data);
 /*
  * Sync ftruncate()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
+EXTERN int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
 
 
 
@@ -450,14 +479,14 @@ int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync mkdir()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_mkdir(struct nfs_context *nfs, const char *path);
+EXTERN int nfs_mkdir(struct nfs_context *nfs, const char *path);
 
 
 
@@ -476,14 +505,14 @@ int nfs_mkdir(struct nfs_context *nfs, const char *path);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync rmdir()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_rmdir(struct nfs_context *nfs, const char *path);
+EXTERN int nfs_rmdir(struct nfs_context *nfs, const char *path);
 
 
 
@@ -504,14 +533,14 @@ int nfs_rmdir(struct nfs_context *nfs, const char *path);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
+EXTERN int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
 /*
  * Sync creat()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
+EXTERN int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
 
 
 
@@ -533,14 +562,14 @@ int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync unlink()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_unlink(struct nfs_context *nfs, const char *path);
+EXTERN int nfs_unlink(struct nfs_context *nfs, const char *path);
 
 
 
@@ -564,14 +593,14 @@ struct nfsdir;
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync opendir()
  * Function returns
  *      0 : Success
  * -errno : An error occured.
  */
-int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
+EXTERN int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
 
 
 
@@ -594,7 +623,7 @@ struct nfsdirent  {
 /*
  * nfs_readdir() never blocks, so no special sync/async versions are available
  */
-struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
+EXTERN struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
 
 
 
@@ -604,7 +633,7 @@ struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
 /*
  * nfs_closedir() never blocks, so no special sync/async versions are available
  */
-void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
+EXTERN void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
 
 
 
@@ -624,14 +653,14 @@ void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
  *          data is the error string.
  */
 struct statvfs;
-int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync statvfs(<dirname>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
+EXTERN int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
 
 
 /*
@@ -651,14 +680,14 @@ int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs)
  *          data is the error string.
  */
 struct statvfs;
-int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
+EXTERN int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
 /*
  * Sync readlink(<name>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
+EXTERN int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
 
 
 
@@ -677,14 +706,14 @@ int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsi
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
+EXTERN int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
 /*
  * Sync chmod(<name>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
+EXTERN int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
 
 
 
@@ -703,14 +732,14 @@ int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
+EXTERN int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
 /*
  * Sync fchmod(<handle>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
+EXTERN int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
 
 
 
@@ -729,14 +758,14 @@ int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
+EXTERN int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
 /*
  * Sync chown(<name>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
+EXTERN int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
 
 
 
@@ -755,14 +784,14 @@ int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
+EXTERN int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
 /*
  * Sync fchown(<handle>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
+EXTERN int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
 
 
 
@@ -782,14 +811,14 @@ int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
+EXTERN int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
 /*
  * Sync utimes(<path>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
+EXTERN int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
 
 
 /*
@@ -808,14 +837,14 @@ int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times)
  *          data is the error string.
  */
 struct utimbuf;
-int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
+EXTERN int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
 /*
  * Sync utime(<path>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
+EXTERN int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
 
 
 
@@ -835,14 +864,14 @@ int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
+EXTERN int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
 /*
  * Sync access(<path>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_access(struct nfs_context *nfs, const char *path, int mode);
+EXTERN int nfs_access(struct nfs_context *nfs, const char *path, int mode);
 
 
 
@@ -862,14 +891,14 @@ int nfs_access(struct nfs_context *nfs, const char *path, int mode);
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
+EXTERN int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
 /*
  * Sync symlink(<path>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+EXTERN int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
 /*
@@ -887,14 +916,14 @@ int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpat
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
+EXTERN int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
 /*
  * Sync rename(<oldpath>, <newpath>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+EXTERN int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
 
@@ -913,14 +942,14 @@ int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath
  * -errno : An error occured.
  *          data is the error string.
  */
-int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
+EXTERN int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
 /*
  * Sync link(<oldpath>, <newpath>)
  * Function returns
  *      0 : The operation was successfull.
  * -errno : The command failed.
  */
-int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
+EXTERN int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
 
 
 /*
@@ -944,7 +973,7 @@ int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
  * -errno : An error occured.
  *          data is the error string.
  */
-int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
+EXTERN int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
 /*
  * Sync getexports(<server>)
  * Function returns
@@ -953,9 +982,9 @@ int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb c
  * 
  * returned data must be freed by calling mount_free_export_list(exportnode);
  */
-struct exportnode *mount_getexports(const char *server);
+EXTERN struct exportnode *mount_getexports(const char *server);
 
-void mount_free_export_list(struct exportnode *exports);
+EXTERN void mount_free_export_list(struct exportnode *exports);
 
 
 //qqq replace later with lseek(cur, 0)
index 5663f250123ef1b6bccf24b0b84feae768083961..d421797f2c398ecec47fd4f5441042a5526e83a7 100644 (file)
@@ -1,10 +1,7 @@
 /*
    Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2.1 of the License, or
-   (at your option) any later version.
+
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 */
 
 #define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.h>
+#else
+#include <unistd.h>
+#include <strings.h>
+#endif
+
 #include <stdio.h>
 #include <stdarg.h>
-#include <unistd.h>
 #include <string.h>
-#include <strings.h>
 #include <stdlib.h>
 #include <rpc/rpc.h>
 #include <rpc/xdr.h>
@@ -46,7 +49,11 @@ struct rpc_context *rpc_init_context(void)
                return NULL;
        }
 
-       rpc->auth = authunix_create_default();
+#if defined(WIN32)
+       rpc->auth = authunix_create("LibNFS", 65535, 65535, 0, NULL);
+#else
+       rpc->auth = authunix_create_default();
+#endif
        if (rpc->auth == NULL) {
                free(rpc->encodebuf);
                free(rpc);
@@ -83,14 +90,13 @@ void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth)
 void rpc_set_error(struct rpc_context *rpc, char *error_string, ...)
 {
         va_list ap;
-       char *str;
 
        if (rpc->error_string != NULL) {
                free(rpc->error_string);
        }
         va_start(ap, error_string);
-       vasprintf(&str, error_string, ap);
-       rpc->error_string = str;
+       rpc->error_string = malloc(1024);
+       vsnprintf(rpc->error_string, 1024, error_string, ap);
         va_end(ap);
 }
 
@@ -135,7 +141,11 @@ void rpc_destroy_context(struct rpc_context *rpc)
        rpc->auth =NULL;
 
        if (rpc->fd != -1) {
-               close(rpc->fd);
+#if defined(WIN32)
+               closesocket(rpc->fd);
+#else
+               close(rpc->fd);
+#endif
        }
 
        if (rpc->encodebuf != NULL) {
index 510772fa1efe6f7e889ac7af2e7b1277157475a7..cfeb5759989ae3835172001e6719efca138758e0 100644 (file)
  * High level api to nfs filesystems
  */
 
+#if defined (WIN32)
+#include <winsock2.h>
+#define DllExport
+#else
+#include <strings.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <poll.h>
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#endif
+
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <poll.h>
@@ -1174,7 +1187,7 @@ void mount_free_export_list(struct exportnode *exports)
 
 
 
-
+#if !defined(WIN32)
 void free_nfs_srvr_list(struct nfs_server_list *srv)
 {
        while (srv != NULL) {
@@ -1380,3 +1393,4 @@ struct nfs_server_list *nfs_find_local_servers(void)
 
        return data.srvrs;
 }
+#endif
index 75372359f261b6f7dc7b07b0c1ce78e1e4a8f2ee..eee5d5a6dbb8e4b6c8f755f7adbe2129289d35e6 100644 (file)
  */
 
 #define _GNU_SOURCE
+
+#if defined(WIN32)
+#include <winsock2.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
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <utime.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include "libnfs.h"
 #include "libnfs-raw.h"
@@ -671,8 +681,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)
         st.st_blksize = 4096;
         st.st_blocks  = res->GETATTR3res_u.resok.obj_attributes.size / 4096;
+#endif
         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;
@@ -1654,7 +1666,7 @@ static void nfs_opendir_cb(struct rpc_context *rpc _U_, int status, void *comman
        READDIRPLUS3res *res;
        struct nfs_cb_data *data = private_data;
        struct nfs_context *nfs = data->nfs;
-       struct nfsdir *nfsdir = data->continue_data;;
+       struct nfsdir *nfsdir = data->continue_data;
        struct entryplus3 *entry;
        uint64_t cookie;
 
@@ -2900,7 +2912,8 @@ void nfs_set_error(struct nfs_context *nfs, char *error_string, ...)
        char *str = NULL;
 
         va_start(ap, error_string);
-       vasprintf(&str, error_string, ap);
+       str = malloc(1024);
+       vsnprintf(str, 1024, error_string, ap);
        if (nfs->rpc->error_string != NULL) {
                free(nfs->rpc->error_string);
        }
@@ -3082,3 +3095,36 @@ const char *nfs_get_server(struct nfs_context *nfs) {
 const char *nfs_get_export(struct nfs_context *nfs) {
        return nfs->export;
 }
+
+
+#if defined(WIN32)
+int poll(struct pollfd *fds, int nfsd, int timeout)
+{
+       fd_set rfds, wfds, efds;
+       int ret;
+
+       FD_ZERO(&rfds);
+       FD_ZERO(&wfds);
+       FD_ZERO(&efds);
+       if (fds->events & POLLIN) {
+               FD_SET(fds->fd, &rfds);
+       }
+       if (fds->events & POLLOUT) {
+               FD_SET(fds->fd, &wfds);
+       }
+       FD_SET(fds->fd, &efds);
+       select(fds->fd + 1, &rfds, &wfds, &efds, NULL);
+       fds->revents = 0;
+       if (FD_ISSET(fds->fd, &rfds)) {
+               fds->revents |= POLLIN;
+       }
+       if (FD_ISSET(fds->fd, &wfds)) {
+               fds->revents |= POLLOUT;
+       }
+       if (FD_ISSET(fds->fd, &efds)) {
+               fds->revents |= POLLHUP;
+       }
+       return 1;
+}
+#endif
+
diff --git a/lib/libnfs.def b/lib/libnfs.def
new file mode 100644 (file)
index 0000000..e758a35
--- /dev/null
@@ -0,0 +1,76 @@
+LIBRARY libnfs
+EXPORTS
+mount_free_export_list
+mount_getexports
+mount_getexports_async
+nfs_access
+nfs_access_async
+nfs_chmod
+nfs_chmod_async
+nfs_chown
+nfs_chown_async
+nfs_close
+nfs_close_async
+nfs_closedir
+nfs_creat
+nfs_creat_async
+nfs_destroy_context
+nfs_fchmod
+nfs_fchmod_async
+nfs_fchown
+nfs_fchown_async
+nfs_fstat
+nfs_fstat_async
+nfs_fsync
+nfs_fsync_async
+nfs_ftruncate
+nfs_ftruncate_async
+nfs_get_error
+nfs_get_fd
+nfs_get_readmax
+nfs_get_writemax
+nfs_init_context
+nfs_link
+nfs_link_async
+nfs_lseek
+nfs_lseek_async
+nfs_mkdir
+nfs_mkdir_async
+nfs_mount
+nfs_mount_async
+nfs_open
+nfs_open_async
+nfs_opendir
+nfs_opendir_async
+nfs_pread
+nfs_pread_async
+nfs_pwrite
+nfs_pwrite_async
+nfs_read
+nfs_read_async
+nfs_readdir
+nfs_readlink
+nfs_readlink_async
+nfs_rename
+nfs_rename_async
+nfs_rmdir
+nfs_rmdir_async
+nfs_service
+nfs_set_auth
+nfs_stat
+nfs_stat_async
+nfs_statvfs
+nfs_statvfs_async
+nfs_symlink
+nfs_symlink_async
+nfs_truncate
+nfs_truncate_async
+nfs_unlink
+nfs_unlink_async
+nfs_utime
+nfs_utime_async
+nfs_utimes
+nfs_utimes_async
+nfs_which_events
+nfs_write
+nfs_write_async
index d6e823201e99393efa9d1bd3df0988da44c27ef2..6cb85ae8028e436e1eed5dda5f3ff89586dfdf79 100644 (file)
--- a/lib/pdu.c
+++ b/lib/pdu.c
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <stdio.h>
+#if defined(WIN32)
+#include <winsock2.h>
+#define MSG_DONTWAIT 0
+#else
 #include <strings.h>
+#endif
+
+#include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <rpc/rpc.h>
index e96636ae7fa4198774ee14e5b2ac8c4e53d703b5..e9c103e55b0cd124ce04baaeef1721fb43d5e5fd 100644 (file)
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#if defined(WIN32)
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <basetsd.h>
+#define ssize_t SSIZE_T
+#define MSG_DONTWAIT 0
+#else
+#include <unistd.h>
+#include <poll.h>
+#include <arpa/inet.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <fcntl.h>
-#include <poll.h>
 #include <string.h>
 #include <errno.h>
 #include <rpc/rpc.h>
 #include <rpc/xdr.h>
-#include <arpa/inet.h>
 #ifdef HAVE_SYS_FILIO_H
 #include <sys/filio.h>
 #endif
 #ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
 #endif
-#include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
 #include "libnfs.h"
 #include "libnfs-raw.h"
 #include "libnfs-private.h"
@@ -47,9 +56,12 @@ static int rpc_disconnect_requeue(struct rpc_context *rpc);
 
 static void set_nonblocking(int fd)
 {
+#if defined(WIN32)
+#else
        unsigned v;
        v = fcntl(fd, F_GETFL, 0);
         fcntl(fd, F_SETFL, v | O_NONBLOCK);
+#endif
 }
 
 int rpc_get_fd(struct rpc_context *rpc)
@@ -89,7 +101,11 @@ static int rpc_write_to_socket(struct rpc_context *rpc)
 
                total = rpc->outqueue->outdata.size;
 
+#if defined(WIN32)
+               count = send(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written, 0);
+#else
                count = write(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written);
+#endif
                if (count == -1) {
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                                return 0;
@@ -116,7 +132,11 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
        int pdu_size;
        ssize_t count;
 
+#if defined(WIN32)
+       if (ioctlsocket(rpc->fd, FIONREAD, &available) != 0) {
+#else
        if (ioctl(rpc->fd, FIONREAD, &available) != 0) {
+#endif
                rpc_set_error(rpc, "Ioctl FIONREAD returned error : %d. Closing socket.", errno);
                return -1;
        }
@@ -160,7 +180,11 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
        if (rpc->inpos < 4) {
                size = 4 - rpc->inpos;
 
+#if defined(WIN32)
+               count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
+#else
                count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
+#endif
                if (count == -1) {
                        if (errno == EINTR) {
                                return 0;
@@ -196,7 +220,11 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
                size = rpc->insize - rpc->inpos;
        }
 
+#if defined(WIN32)
+       count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
+#else
        count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
+#endif
        if (count == -1) {
                if (errno == EINTR) {
                        return 0;
@@ -319,7 +347,7 @@ int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc
 #ifdef HAVE_SOCKADDR_LEN
                sin->sin_len = socksize;
 #endif
-               rpc->fd = socket(AF_INET, SOCK_STREAM, 0);
+               rpc->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                break;
        }
 
@@ -344,7 +372,11 @@ int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc
 int rpc_disconnect(struct rpc_context *rpc, char *error)
 {
        if (rpc->fd != -1) {
+#if defined(WIN32)
+               closesocket(rpc->fd);
+#else
                close(rpc->fd);
+#endif
        }
        rpc->fd  = -1;
 
@@ -361,7 +393,11 @@ static int rpc_disconnect_requeue(struct rpc_context *rpc)
        struct rpc_pdu *pdu;
 
        if (rpc->fd != -1) {
+#if defined(WIN32)
+               closesocket(rpc->fd);
+#else
                close(rpc->fd);
+#endif
        }
        rpc->fd  = -1;
 
@@ -389,7 +425,7 @@ int rpc_bind_udp(struct rpc_context *rpc, char *addr, int port)
                return -1;
        }
 
-       snprintf(service, 6, "%d", port);
+       sprintf(service, "%d", port);
        if (getaddrinfo(addr, service, NULL, &ai) != 0) {
                rpc_set_error(rpc, "Invalid address:%s. "
                        "Can not resolv into IPv4/v6 structure.");
@@ -432,7 +468,7 @@ int rpc_set_udp_destination(struct rpc_context *rpc, char *addr, int port, int i
                return -1;
        }
 
-       snprintf(service, 6, "%d", port);
+       sprintf(service, "%d", port);
        if (getaddrinfo(addr, service, NULL, &ai) != 0) {
                rpc_set_error(rpc, "Invalid address:%s. "
                        "Can not resolv into IPv4/v6 structure.");
index 525c8526a5fd12e94e80da5d463c9b2e88105570..6b6bf743252f93347bc7f4075a97c0f9abbee402 100644 (file)
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
 #include <stdio.h>
 #include <errno.h>
 #include <rpc/rpc.h>
index 5b655cb3369e2aeea6f2a4f55f4ca1be320132a7..0c8ff79857f84670e2f9dc48891d4f03c7f88c8b 100644 (file)
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
    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
+
 #include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
index 797745c1f514b5a7e33964700df1d5359d723293..01e26c302d1a0f2d386c02fd28eced2dc63b26ea 100644 (file)
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
 #include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
index 07aa91276ea07ce06c9653cd56f851c4b22ee4d1..431fb1560b9e0d94a636f779bfc07b24d447cab6 100644 (file)
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
 #include <stdio.h>
 #include <rpc/rpc.h>
 #include <rpc/xdr.h>
index 30abc679ee017ee32d3a2ec613212b90c91ac661..55919d54eb035215a8f7d5416cd17648097bc2e0 100644 (file)
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#if defined(WIN32)
+#include <winsock2.h>
+#endif
+
 #include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
diff --git a/win32build.bat b/win32build.bat
new file mode 100755 (executable)
index 0000000..628e47c
--- /dev/null
@@ -0,0 +1,87 @@
+rem build script for win32\r
+rem set the \r
+rem\r
+\r
+rem EDIT THESE\r
+set RPCINCLUDE="C:\...where my rpc includes live...\include"\r
+set RPCDLL="C:\...where my rpc DLL can be found...\rpc.dll"\r
+set RPCLIB="C:\...where my rpc link library can be found...\rpc.lib"\r
+set RPCGEN="C:\...where my rpcgen executable lives...\rpcgen.exe"\r
+\r
+\r
+\r
+rem generate NFS from .x\r
+rem\r
+copy nfs\nfs.x nfs\libnfs-raw-nfs.x\r
+%RPCGEN% -h nfs\libnfs-raw-nfs.x > nfs\libnfs-raw-nfs.h\r
+%RPCGEN% -c nfs\libnfs-raw-nfs.x > nfs\libnfs-raw-nfs.c\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\libnfs-raw-nfs.c -Fonfs\libnfs-raw-nfs.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfs.c -Fonfs\nfs.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd nfs\nfsacl.c -Fonfs\nfsacl.obj\r
+\r
+\r
+\r
+rem\r
+rem generate RQUOTA from .x\r
+rem\r
+copy rquota\rquota.x rquota\libnfs-raw-rquota.x\r
+%RPCGEN% -h rquota\libnfs-raw-rquota.x > rquota\libnfs-raw-rquota.h\r
+%RPCGEN% -c rquota\libnfs-raw-rquota.x > rquota\libnfs-raw-rquota.c\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\libnfs-raw-rquota.c -Forquota\libnfs-raw-rquota.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd rquota\rquota.c -Forquota\rquota.obj\r
+\r
+\r
+\r
+rem\r
+rem generate PORTMAP from .x\r
+rem\r
+copy portmap\portmap.x portmap\libnfs-raw-portmap.x\r
+%RPCGEN% -h portmap\libnfs-raw-portmap.x > portmap\libnfs-raw-portmap.h\r
+%RPCGEN% -c portmap\libnfs-raw-portmap.x > portmap\libnfs-raw-portmap.c\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\libnfs-raw-portmap.c -Foportmap\libnfs-raw-portmap.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd portmap\portmap.c -Foportmap\portmap.obj\r
+\r
+\r
+rem\r
+rem generate MOUNT from .x\r
+rem\r
+copy mount\mount.x mount\libnfs-raw-mount.x\r
+%RPCGEN% -h mount\libnfs-raw-mount.x > mount\libnfs-raw-mount.h\r
+%RPCGEN% -c mount\libnfs-raw-mount.x > mount\libnfs-raw-mount.c\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\libnfs-raw-mount.c -Fomount\libnfs-raw-mount.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd mount\mount.c -Fomount\mount.obj\r
+\r
+\r
+\r
+rem\r
+rem generate core part of library\r
+rem\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd lib\init.c -Folib\init.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\pdu.c -Folib\pdu.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\socket.c -Folib\socket.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs.c -Folib\libnfs.obj\r
+cl /I. /Iinclude /I%RPCINCLUDE% /Imount /Infs -Zi -Od -c -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" lib\libnfs-sync.c -Folib\libnfs-sync.obj\r
+\r
+\r
+\r
+rem\r
+rem create a linklibrary/dll\r
+rem\r
+lib /out:lib\libnfs.lib /def:lib\libnfs.def nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj\r
+\r
+link /DLL /out:lib\libnfs.dll /DEBUG /DEBUGTYPE:cv lib\libnfs.exp nfs\nfs.obj nfs\nfsacl.obj nfs\libnfs-raw-nfs.obj rquota\rquota.obj rquota\libnfs-raw-rquota.obj mount\mount.obj mount\libnfs-raw-mount.obj portmap\portmap.obj portmap\libnfs-raw-portmap.obj lib\init.obj lib\pdu.obj lib\socket.obj lib\libnfs.obj lib\libnfs-sync.obj %RPCLIB% ws2_32.lib\r
+\r
+\r
+\r
+rem\r
+rem build a test application\r
+rem\r
+cl /I. /Iinclude /I%RPCINCLUDE% /Imount /Infs -Zi -Od -DWIN32 -D_WIN32_WINNT=0x0600 -MDd -D_U_="" examples\nfsclient-sync.c lib\libnfs.lib %RPCLIB% WS2_32.lib kernel32.lib mswsock.lib advapi32.lib wsock32.lib advapi32.lib\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r