Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/csync
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2015-01-23 19:09:48 +0300
committerOlivier Goffart <ogoffart@woboq.com>2015-01-23 19:11:34 +0300
commitfe51ada1e8a4fe3741b6ab696812629892412e1a (patch)
tree5fb877717a4c4ff928ffc35f2d4c7458048a0c00 /csync
parent6708c959d9ac632a3f86044765a135394a67b18c (diff)
Don't require NEON with Qt 5.4
Diffstat (limited to 'csync')
-rw-r--r--csync/src/CMakeLists.txt12
-rw-r--r--csync/src/csync.c15
-rw-r--r--csync/src/csync_owncloud_util.c86
-rw-r--r--csync/src/csync_util.c85
-rw-r--r--csync/src/vio/csync_vio.c5
5 files changed, 114 insertions, 89 deletions
diff --git a/csync/src/CMakeLists.txt b/csync/src/CMakeLists.txt
index d5ec9b974..e94b32c70 100644
--- a/csync/src/CMakeLists.txt
+++ b/csync/src/CMakeLists.txt
@@ -60,11 +60,17 @@ set(csync_SRCS
vio/csync_vio.c
vio/csync_vio_file_stat.c
vio/csync_vio_local.c
-
- csync_owncloud.c
- csync_owncloud_util.c
)
+if(USE_NEON)
+ list(APPEND csync_SRCS
+ csync_owncloud.c
+ csync_owncloud_util.c
+ )
+ add_definitions(-DUSE_NEON)
+endif(USE_NEON)
+
+
configure_file(csync_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/csync_version.h)
set(csync_HDRS
diff --git a/csync/src/csync.c b/csync/src/csync.c
index 4f4123306..65fe9c93e 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -59,8 +59,10 @@
#include "c_jhash.h"
+#ifdef USE_NEON
// Breaking the abstraction for fun and profit.
#include "csync_owncloud.h"
+#endif
static int _key_cmp(const void *key, const void *data) {
uint64_t a;
@@ -160,7 +162,9 @@ int csync_init(CSYNC *ctx) {
ctx->local.type = LOCAL_REPLICA;
+#ifdef USE_NEON
owncloud_init(ctx);
+#endif
ctx->remote.type = REMOTE_REPLICA;
if (c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp) < 0) {
@@ -220,11 +224,13 @@ int csync_update(CSYNC *ctx) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "No exclude file loaded or defined!");
}
+#ifdef USE_NEON
/* This is not actually connecting, just setting the info for neon. The legacy propagator can use it.. */
if (dav_connect( ctx, ctx->remote.uri ) < 0) {
ctx->status_code = CSYNC_STATUS_CONNECT_ERROR;
return -1;
}
+#endif
/* update detection for local replica */
csync_gettime(&start);
@@ -577,12 +583,14 @@ int csync_commit(CSYNC *ctx) {
}
ctx->statedb.db = NULL;
+#ifdef USE_NEON
rc = owncloud_commit(ctx);
if (rc < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "commit failed: %s",
ctx->error_string ? ctx->error_string : "");
goto out;
}
+#endif
_csync_clean_ctx(ctx);
@@ -638,7 +646,9 @@ int csync_destroy(CSYNC *ctx) {
SAFE_FREE(ctx->remote.uri);
SAFE_FREE(ctx->error_string);
+#ifdef USE_NEON
owncloud_destroy(ctx);
+#endif
#ifdef WITH_ICONV
c_close_iconv();
@@ -783,7 +793,12 @@ void csync_file_stat_free(csync_file_stat_t *st)
int csync_set_module_property(CSYNC* ctx, const char* key, void* value)
{
+#ifdef USE_NEON
return owncloud_set_property(ctx, key, value);
+#else
+ (void)ctx, (void)key, (void)value;
+ return 0;
+#endif
}
diff --git a/csync/src/csync_owncloud_util.c b/csync/src/csync_owncloud_util.c
index 3ce39d5bd..ca71b60a8 100644
--- a/csync/src/csync_owncloud_util.c
+++ b/csync/src/csync_owncloud_util.c
@@ -99,92 +99,6 @@ void set_errno_from_http_errcode( int err ) {
errno = new_errno;
}
-
-#ifndef HAVE_TIMEGM
-#ifdef _WIN32
-static int is_leap(unsigned y) {
- y += 1900;
- return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
-}
-
-static time_t timegm(struct tm *tm) {
- static const unsigned ndays[2][12] = {
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} };
-
- time_t res = 0;
- int i;
-
- for (i = 70; i < tm->tm_year; ++i)
- res += is_leap(i) ? 366 : 365;
-
- for (i = 0; i < tm->tm_mon; ++i)
- res += ndays[is_leap(tm->tm_year)][i];
- res += tm->tm_mday - 1;
- res *= 24;
- res += tm->tm_hour;
- res *= 60;
- res += tm->tm_min;
- res *= 60;
- res += tm->tm_sec;
- return res;
-}
-#else
-/* A hopefully portable version of timegm */
-static time_t timegm(struct tm *tm ) {
- time_t ret;
- char *tz;
-
- tz = getenv("TZ");
- setenv("TZ", "", 1);
- tzset();
- ret = mktime(tm);
- if (tz)
- setenv("TZ", tz, 1);
- else
- unsetenv("TZ");
- tzset();
- return ret;
-}
-#endif /* Platform switch */
-#endif /* HAVE_TIMEGM */
-
-#define RFC1123_FORMAT "%3s, %02d %3s %4d %02d:%02d:%02d GMT"
-static const char short_months[12][4] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-/*
- * This function is borrowed from libneon's ne_httpdate_parse.
- * Unfortunately that one converts to local time but here UTC is
- * needed.
- * This one uses timegm instead, which returns UTC.
- */
-time_t oc_httpdate_parse( const char *date ) {
- struct tm gmt;
- char wkday[4], mon[4];
- int n;
- time_t result = 0;
-
- memset(&gmt, 0, sizeof(struct tm));
-
- /* it goes: Sun, 06 Nov 1994 08:49:37 GMT */
- n = sscanf(date, RFC1123_FORMAT,
- wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour,
- &gmt.tm_min, &gmt.tm_sec);
- /* Is it portable to check n==7 here? */
- gmt.tm_year -= 1900;
- for (n=0; n<12; n++)
- if (strcmp(mon, short_months[n]) == 0)
- break;
- /* tm_mon comes out as 12 if the month is corrupt, which is desired,
- * since the mktime will then fail */
- gmt.tm_mon = n;
- gmt.tm_isdst = -1;
- result = timegm(&gmt);
- return result;
-}
-
// as per http://sourceforge.net/p/predef/wiki/OperatingSystems/
// extend as required
const char* csync_owncloud_get_platform() {
diff --git a/csync/src/csync_util.c b/csync/src/csync_util.c
index c73538ac2..76273b639 100644
--- a/csync/src/csync_util.c
+++ b/csync/src/csync_util.c
@@ -148,3 +148,88 @@ bool csync_file_locked_or_open( const char *dir, const char *fname) {
SAFE_FREE(tmp_uri);
return ret;
}
+
+#ifndef HAVE_TIMEGM
+#ifdef _WIN32
+static int is_leap(unsigned y) {
+ y += 1900;
+ return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
+}
+
+static time_t timegm(struct tm *tm) {
+ static const unsigned ndays[2][12] = {
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} };
+
+ time_t res = 0;
+ int i;
+
+ for (i = 70; i < tm->tm_year; ++i)
+ res += is_leap(i) ? 366 : 365;
+
+ for (i = 0; i < tm->tm_mon; ++i)
+ res += ndays[is_leap(tm->tm_year)][i];
+ res += tm->tm_mday - 1;
+ res *= 24;
+ res += tm->tm_hour;
+ res *= 60;
+ res += tm->tm_min;
+ res *= 60;
+ res += tm->tm_sec;
+ return res;
+}
+#else
+/* A hopefully portable version of timegm */
+static time_t timegm(struct tm *tm ) {
+ time_t ret;
+ char *tz;
+
+ tz = getenv("TZ");
+ setenv("TZ", "", 1);
+ tzset();
+ ret = mktime(tm);
+ if (tz)
+ setenv("TZ", tz, 1);
+ else
+ unsetenv("TZ");
+ tzset();
+ return ret;
+}
+#endif /* Platform switch */
+#endif /* HAVE_TIMEGM */
+
+#define RFC1123_FORMAT "%3s, %02d %3s %4d %02d:%02d:%02d GMT"
+static const char short_months[12][4] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+/*
+ * This function is borrowed from libneon's ne_httpdate_parse.
+ * Unfortunately that one converts to local time but here UTC is
+ * needed.
+ * This one uses timegm instead, which returns UTC.
+ */
+time_t oc_httpdate_parse( const char *date ) {
+ struct tm gmt;
+ char wkday[4], mon[4];
+ int n;
+ time_t result = 0;
+
+ memset(&gmt, 0, sizeof(struct tm));
+
+ /* it goes: Sun, 06 Nov 1994 08:49:37 GMT */
+ n = sscanf(date, RFC1123_FORMAT,
+ wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour,
+ &gmt.tm_min, &gmt.tm_sec);
+ /* Is it portable to check n==7 here? */
+ gmt.tm_year -= 1900;
+ for (n=0; n<12; n++)
+ if (strcmp(mon, short_months[n]) == 0)
+ break;
+ /* tm_mon comes out as 12 if the month is corrupt, which is desired,
+ * since the mktime will then fail */
+ gmt.tm_mon = n;
+ gmt.tm_isdst = -1;
+ result = timegm(&gmt);
+ return result;
+}
diff --git a/csync/src/vio/csync_vio.c b/csync/src/vio/csync_vio.c
index 9dc81d082..c32ef4d09 100644
--- a/csync/src/vio/csync_vio.c
+++ b/csync/src/vio/csync_vio.c
@@ -36,7 +36,9 @@
#define CSYNC_LOG_CATEGORY_NAME "csync.vio.main"
#include "csync_log.h"
+#if USE_NEON
#include "csync_owncloud.h"
+#endif
csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) {
switch(ctx->replica) {
@@ -130,5 +132,8 @@ char *csync_vio_get_status_string(CSYNC *ctx) {
if(ctx->error_string) {
return ctx->error_string;
}
+#ifdef USE_NEON
return owncloud_error_string(ctx);
+#endif
+ return 0;
}