Fri, 12 Jul 2019 16:59:08 +0200
fix build on windows
dav/finfo.h | file | annotate | diff | comparison | revisions | |
dav/pwd.c | file | annotate | diff | comparison | revisions | |
dav/sync.c | file | annotate | diff | comparison | revisions | |
dav/sync.h | file | annotate | diff | comparison | revisions | |
dav/system.c | file | annotate | diff | comparison | revisions | |
dav/system.h | file | annotate | diff | comparison | revisions | |
mingw.mk | file | annotate | diff | comparison | revisions |
--- a/dav/finfo.h Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/finfo.h Fri Jul 12 16:59:08 2019 +0200 @@ -33,6 +33,8 @@ #include <inttypes.h> #include <sys/stat.h> +#include "system.h" + #ifdef __cplusplus extern "C" { #endif
--- a/dav/pwd.c Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/pwd.c Fri Jul 12 16:59:08 2019 +0200 @@ -29,14 +29,16 @@ #include <stdio.h> #include <stdlib.h> -#include <netinet/in.h> - #include "pwd.h" #include <ucx/buffer.h> #include <ucx/utils.h> - +#ifdef _WIN32 +#include <winsock.h> +#else +#include <netinet/in.h> +#endif PwdStore* pwdstore_open(const char *file) { FILE *in = fopen(file, "r");
--- a/dav/sync.c Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/sync.c Fri Jul 12 16:59:08 2019 +0200 @@ -737,7 +737,7 @@ UcxList *elm = res_new; UcxList *prev = NULL; UcxList *next = NULL; - struct stat s; + SYS_STAT s; for(;elm;elm=next) { DavResource *res = elm->data; prev = elm->prev; @@ -758,7 +758,7 @@ } char *local_path = util_concat_path(dir->path, local->path); - int staterr = stat(local_path, &s); + int staterr = sys_stat(local_path, &s); free(local_path); if(staterr) { // origin doesn't exist or is inaccessible @@ -845,8 +845,8 @@ fprintf(stderr, "Metadata update failed: %s\n", res->path); sync_error++; } else { - struct stat s; - if(stat(local_path, &s)) { + SYS_STAT s; + if(sys_stat(local_path, &s)) { fprintf(stderr, "Cannot stat file after update: %s\n", strerror(errno)); } sync_set_metadata_from_stat(local, &s); @@ -1066,7 +1066,7 @@ return ret; } -void sync_set_metadata_from_stat(LocalResource *local, struct stat *s) { +void sync_set_metadata_from_stat(LocalResource *local, SYS_STAT *s) { local->last_modified = s->st_mtime; local->mode = s->st_mode & 07777; local->uid = s->st_uid;
--- a/dav/sync.h Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/sync.h Fri Jul 12 16:59:08 2019 +0200 @@ -38,6 +38,7 @@ #include "scfg.h" #include "config.h" #include "sopt.h" +#include "system.h" #include "version.h" @@ -106,7 +107,7 @@ SyncDirectory *dir, SyncDatabase *db); -void sync_set_metadata_from_stat(LocalResource *local, struct stat *s); +void sync_set_metadata_from_stat(LocalResource *local, SYS_STAT *s); int sync_move_resource( CmdArgs *a, SyncDirectory *dir,
--- a/dav/system.c Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/system.c Fri Jul 12 16:59:08 2019 +0200 @@ -247,15 +247,7 @@ } int sys_lstat(const char *path, SYS_STAT *s) { - // TODO: fix - wchar_t *fpath = path2winpath(path, FALSE, NULL); - if(!fpath) { - fprintf(stderr, "Cannot convert path \"%s\" to UTF16\n", path); - return -1; - } - int ret = _wstat64(fpath, s); - free(fpath); - return ret; + return sys_stat(path, s); // unsupported on windows } int sys_rename(const char *oldpath, const char *newpath) {
--- a/dav/system.h Sat Jun 22 16:36:52 2019 +0200 +++ b/dav/system.h Fri Jul 12 16:59:08 2019 +0200 @@ -57,6 +57,11 @@ #define SYS_DIR struct WinDir* #define SYS_STAT struct __stat64 +#define S_ISLNK(s) 0 + +typedef int uid_t; +typedef int gid_t; + #else typedef struct SysDir {
--- a/mingw.mk Sat Jun 22 16:36:52 2019 +0200 +++ b/mingw.mk Fri Jul 12 16:59:08 2019 +0200 @@ -42,6 +42,6 @@ LIB_EXT = .a APP_EXT = .exe -DAV_CFLAGS = `xml2-config --cflags` -DAV_LDFLAGS = `xml2-config --libs` -lcurl -lssl -lcrypto -lws2_32 -lgdi32 -lregex +DAV_CFLAGS = `xml2-config --cflags` -I/mingw/include +DAV_LDFLAGS = `xml2-config --libs` -L/mingw/lib -lcurl -lssl -lcrypto -lws2_32 -lgdi32 -lgnurx