Fix compilation after merge

Still untetested
This commit is contained in:
Olivier Goffart 2013-08-18 18:55:32 +02:00
parent 4e04a2ccb0
commit 56d5359f5b
14 changed files with 48 additions and 66 deletions

View file

@ -29,6 +29,7 @@
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <inttypes.h>
#include <csync.h>
@ -224,15 +225,14 @@ static int parse_args(struct argument_s *csync_args, int argc, char **argv)
return optind;
}
static void _overall_callback(const char *file_name,
int file_no,
int file_cnt,
long long o1,
long long o2,
void *userdata)
static void _overall_callback(CSYNC_PROGRESS *progress, void *userdata)
{
(void) userdata;
printf("File #%2d/%2d: %s (%lld/%lld bytes)\n", file_no, file_cnt, file_name, o1, o2 );
if (progress->kind != CSYNC_NOTIFY_PROGRESS) {
printf("File #%2" PRId64 "/%2" PRId64 ": %s (%" PRId64 "/%" PRId64 " bytes)\n",
progress->current_file_no, progress->overall_file_count, progress->path,
progress->current_overall_bytes, progress->overall_transmission_size);
}
}
int main(int argc, char **argv) {
@ -331,8 +331,8 @@ int main(int argc, char **argv) {
}
if (arguments.verbose > 0) {
csync_set_overall_progress_callback(csync, _overall_callback);
csync_set_progress_callback(csync, _overall_callback);
}
if (arguments.exclude_file != NULL) {

View file

@ -1033,7 +1033,7 @@ static char*_lastDir = NULL;
* int unix_extensions - oC supports unix extensions.
* bool propagate_on_fd - oC supports the send_file method.
*/
static csync_vio_capabilities_t _owncloud_capabilities = { true, false, false, 0, true };
static csync_vio_capabilities_t _owncloud_capabilities = { true, false, false, 0, true, false, false };
static csync_vio_capabilities_t *owncloud_capabilities(void)
{
@ -1215,7 +1215,7 @@ static int _user_want_abort()
static void _log_callback(const char *func, const char *text)
{
csync_log(dav_session.csync_ctx, CSYNC_LOG_PRIORITY_TRACE, func, "%s", text);
csync_log(CSYNC_LOG_PRIORITY_TRACE, func, "%s", text);
}
static int owncloud_sendfile(csync_vio_method_handle_t *src, csync_vio_method_handle_t *hdl ) {
@ -1715,7 +1715,7 @@ static char *owncloud_error_string()
return dav_session.error_string;
}
static void owncloud_commit() {
static int owncloud_commit() {
SAFE_FREE( _lastDir );
@ -1730,6 +1730,7 @@ static void owncloud_commit() {
ne_sock_exit();
_connected = 0; /* triggers dav_connect to go through the whole neon setup */
return 0;
}

View file

@ -63,7 +63,7 @@
#include "csync_log.h"
#define DEBUG_WEBDAV(...) csync_log( dav_session.csync_ctx, 9, "oc_module", __VA_ARGS__);
#define DEBUG_WEBDAV(...) csync_log( 9, "oc_module", __VA_ARGS__);
enum resource_type {
resr_normal = 0,

View file

@ -337,7 +337,7 @@ retry_vio_init:
ctx->status = CSYNC_STATUS_INIT;
csync_lock_remove(ctx, lock);
csync_lock_remove(lock);
csync_set_module_property(ctx, "csync_context", ctx);
@ -371,7 +371,7 @@ int csync_update(CSYNC *ctx) {
return rc;
}
if (csync_lock(ctx, lock) < 0) {
if (csync_lock(lock) < 0) {
ctx->status_code = CSYNC_STATUS_NO_LOCK;
rc = -1;
return rc;
@ -389,7 +389,7 @@ int csync_update(CSYNC *ctx) {
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Journal: %s", ctx->statedb.file);
if (csync_statedb_load(ctx, ctx->statedb.file) < 0) {
if (csync_statedb_load(ctx, ctx->statedb.file, &ctx->statedb.db) < 0) {
ctx->status_code = CSYNC_STATUS_STATEDB_LOAD_ERROR;
rc = -1;
return rc;
@ -447,7 +447,6 @@ int csync_update(CSYNC *ctx) {
csync_memstat_check();
return -1;
}
}
ctx->status |= CSYNC_STATUS_UPDATE;

View file

@ -44,26 +44,6 @@
extern "C" {
#endif
#define CSYNC_STRINGIFY(s) CSYNC_TOSTRING(s)
#define CSYNC_TOSTRING(s) #s
/* csync version macros */
#define CSYNC_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
#define CSYNC_VERSION_DOT(a, b, c) a ##.## b ##.## c
#define CSYNC_VERSION(a, b, c) CSYNC_VERSION_DOT(a, b, c)
/* csync version */
#define LIBCSYNC_VERSION_MAJOR 0
#define LIBCSYNC_VERSION_MINOR 50
#define LIBCSYNC_VERSION_MICRO 0
#define LIBCSYNC_VERSION_INT CSYNC_VERSION_INT(LIBCSYNC_VERSION_MAJOR, \
LIBCSYNC_VERSION_MINOR, \
LIBCSYNC_VERSION_MICRO)
#define LIBCSYNC_VERSION CSYNC_VERSION(LIBCSYNC_VERSION_MAJOR, \
LIBCSYNC_VERSION_MINOR, \
LIBCSYNC_VERSION_MICRO)
/*
* csync file declarations
*/

View file

@ -20,7 +20,7 @@
#include "config.h"
#define _GNU_SOURCE
/* #define _GNU_SOURCE */
#include <stdio.h>
#include <ctype.h>
@ -328,7 +328,7 @@ int csync_config_parse_file(CSYNC *ctx, const char *config)
SAFE_FREE(home);
/* Still install the default one if nothing is there. */
if( ! c_isfile(config)) {
if (_csync_config_copy_default(ctx, config) < 0) {
if (_csync_config_copy_default(config) < 0) {
return -1;
}
}

View file

@ -201,7 +201,6 @@ int csync_lock(const char *lockfile) {
return _csync_lock_create(lockfile);
#else
(void) ctx;
(void) lockfile;
return 0;
#endif
@ -230,7 +229,6 @@ void csync_lock_remove(const char *lockfile) {
}
#endif
#else
(void) ctx;
(void) lockfile;
#endif

View file

@ -106,7 +106,7 @@ static void _csync_report_parent_error(CSYNC *ctx, csync_file_stat_t *st) {
*/
static void _csync_record_error(CSYNC *ctx, csync_file_stat_t *st, csync_progressinfo_t *pi)
{
_csync_file_stat_set_error(st, csync_get_error_string(ctx));
_csync_file_stat_set_error(st, csync_get_status_string(ctx));
_csync_report_parent_error(ctx, st);
if (pi) {
pi->error++;
@ -527,13 +527,13 @@ start_fd_based:
break;
}
/* fetch the error string from module. */
ctx->error_string = csync_vio_get_error_string(ctx);
ctx->error_string = csync_vio_get_status_string(ctx);
}
C_STRERROR(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"file: %s, command: sendfile, error: %s from errno %d",
suri, c_streq(errbuf, "") ? csync_vio_get_error_string(ctx): errbuf, errno);
suri, c_streq(errbuf, "") ? csync_vio_get_status_string(ctx): errbuf, errno);
if (_push_to_tmp_first(ctx)) {
csync_vio_file_stat_t* sb = csync_vio_file_stat_new();
@ -1104,7 +1104,7 @@ out:
/* set instruction for the statedb merger */
if (rc != 0) {
_csync_file_stat_set_error(st, csync_get_error_string(ctx));
_csync_file_stat_set_error(st, csync_get_status_string(ctx));
if (other) {
/* We set the instruction to UPDATED so next try we try to rename again */

View file

@ -102,7 +102,7 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
/* rename support only on the local replica because of inode needed. */
if(ctx->current == LOCAL_REPLICA ) {
/* use the old name to find the "other" node */
tmp = csync_statedb_get_stat_by_inode(ctx, cur->inode);
tmp = csync_statedb_get_stat_by_inode(ctx->statedb.db, cur->inode);
/* Find the opposite node. */
if( tmp ) {
/* We need to calculate the phash again because of the phash being stored as int in db. */

View file

@ -48,6 +48,7 @@
#include "csync_rename.h"
#define BUF_SIZE 16
#define HASH_QUERY "SELECT * FROM metadata WHERE phash=?1"
static sqlite3_stmt* _by_hash_stmt = NULL;
@ -106,6 +107,7 @@ static int _csync_statedb_check(const char *statedb) {
ssize_t r;
char buf[BUF_SIZE] = {0};
sqlite3 *db = NULL;
struct stat sb;
mbchar_t *wstatedb = c_utf8_to_locale(statedb);
@ -176,7 +178,7 @@ static int _csync_statedb_check(const char *statedb) {
_csync_win32_hide_file(statedb);
return 1;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "sqlite3_open failed: %s %s", sqlite3_errmsg(ctx->statedb.db), statedb);
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "sqlite3_open failed: %s %s", sqlite3_errmsg(db), statedb);
return -1;
}
@ -276,7 +278,7 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
csync_gettime(&start);
/* drop tables */
if (csync_statedb_drop_tables(dv) < 0) {
if (csync_statedb_drop_tables(db) < 0) {
recreate_db = true;
}
csync_gettime(&finish);
@ -296,7 +298,6 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
char *statedb_tmp;
mbchar_t *wstatedb_tmp = NULL;
int rc;
if (asprintf(&statedb_tmp, "%s.ctmp", ctx->statedb.file) < 0) {
return -1;
}
@ -347,6 +348,7 @@ int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten) {
char *statedb_tmp = NULL;
mbchar_t* wstatedb_tmp = NULL;
int rc = 0;
mbchar_t *mb_statedb = NULL;
@ -466,7 +468,7 @@ int csync_statedb_create_tables(sqlite3 *db) {
}
c_strlist_destroy(result);
result = csync_statedb_query(ctx,
result = csync_statedb_query(db,
"CREATE TABLE IF NOT EXISTS version("
"major INTEGER(8),"
"minor INTEGER(8),"
@ -477,7 +479,7 @@ int csync_statedb_create_tables(sqlite3 *db) {
}
c_strlist_destroy(result);
result = csync_statedb_query(ctx,
result = csync_statedb_query(db,
"CREATE TABLE IF NOT EXISTS progress("
"phash INTEGER(8),"
"modtime INTEGER(8),"
@ -500,7 +502,7 @@ int csync_statedb_create_tables(sqlite3 *db) {
stmt = sqlite3_mprintf( "INSERT INTO version (major, minor, patch) VALUES (%d, %d, %d);",
LIBCSYNC_VERSION_MAJOR, LIBCSYNC_VERSION_MINOR, LIBCSYNC_VERSION_MICRO );
rc = csync_statedb_insert(ctx, stmt);
rc = csync_statedb_insert(db, stmt);
if( rc < 0 ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Error: Failed to insert into version table.");
@ -647,7 +649,6 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
char buffer[] = "INSERT INTO metadata_temp VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)";
sqlite3_stmt* stmt;
int rc;
int result;
csync_gettime(&start);
@ -713,7 +714,7 @@ int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db) {
}
c_strlist_destroy(result);
result = csync_statedb_query(ctx,
result = csync_statedb_query(db,
"CREATE INDEX IF NOT EXISTS metadata_inode ON metadata(inode);");
if (result == NULL) {
return -1;
@ -749,7 +750,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
int rc;
if( _by_hash_stmt == NULL ) {
rc = sqlite3_prepare_v2(ctx->statedb.db, HASH_QUERY, strlen(HASH_QUERY), &_by_hash_stmt, NULL);
rc = sqlite3_prepare_v2(db, HASH_QUERY, strlen(HASH_QUERY), &_by_hash_stmt, NULL);
if( rc != SQLITE_OK ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for hash query.");
return NULL;
@ -806,7 +807,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
}
}
} else {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite hash query fail: %s", sqlite3_errmsg(ctx->statedb.db));
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite hash query fail: %s", sqlite3_errmsg(db));
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "No result record found for phash = %llu",
(long long unsigned int) phash);
SAFE_FREE(st);
@ -879,7 +880,7 @@ char *csync_statedb_get_uniqId( CSYNC *ctx, uint64_t jHash, csync_vio_file_stat_
stmt = sqlite3_mprintf("SELECT md5 FROM metadata WHERE phash='%lld'", jHash);
result = csync_statedb_query(ctx, stmt);
result = csync_statedb_query(ctx->statedb.db, stmt);
sqlite3_free(stmt);
if (result == NULL) {
return NULL;
@ -907,7 +908,7 @@ c_strlist_t *csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "SQL: %s", stmt);
list = csync_statedb_query( ctx, stmt );
list = csync_statedb_query( ctx->statedb.db, stmt );
sqlite3_free(stmt);
@ -1121,7 +1122,7 @@ csync_progressinfo_t* csync_statedb_get_progressinfo(CSYNC *ctx, uint64_t phash,
(long long unsigned int) phash, (long long signed int) modtime, md5);
if (!stmt) return ret;
result = csync_statedb_query(ctx, stmt);
result = csync_statedb_query(ctx->statedb.db, stmt);
sqlite3_free(stmt);
if (result == NULL) {
return NULL;
@ -1179,7 +1180,7 @@ int csync_statedb_write_progressinfo(CSYNC* ctx, csync_progressinfo_t* pi)
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "%s" , stmt);
rc = csync_statedb_insert(ctx, stmt);
rc = csync_statedb_insert(ctx->statedb.db, stmt);
sqlite3_free(stmt);
pi = pi->next;
}

View file

@ -165,7 +165,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
}
if (fs->mtime == 0) {
tmp = csync_statedb_get_stat_by_hash(ctx, h);
tmp = csync_statedb_get_stat_by_hash(ctx->statedb.db, h);
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - mtime is zero!", path);
if (tmp == NULL) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - not found in db, IGNORE!", path);
@ -198,7 +198,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
* does not change on rename.
*/
if (csync_get_statedb_exists(ctx)) {
tmp = csync_statedb_get_stat_by_hash(ctx, h);
tmp = csync_statedb_get_stat_by_hash(ctx->statedb.db, h);
#if 0
/* this code could possibly replace the one in csync_vio.c stat and would be more efficient */
if(tmp) {
@ -229,7 +229,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
} else {
/* check if it's a file and has been renamed */
if (ctx->current == LOCAL_REPLICA) {
tmp = csync_statedb_get_stat_by_inode(ctx, fs->inode);
tmp = csync_statedb_get_stat_by_inode(ctx->statedb.db, fs->inode);
if (tmp && tmp->inode == fs->inode && (tmp->modtime == fs->mtime || fs->type == CSYNC_VIO_FILE_TYPE_DIRECTORY)) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "inodes: %" PRId64 " <-> %" PRId64, (int64_t) tmp->inode, (int64_t) fs->inode);
/* inode found so the file has been renamed */
@ -331,7 +331,7 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs,
if( h == 0 ) {
return 0;
}
st = csync_statedb_get_stat_by_hash(ctx, h);
st = csync_statedb_get_stat_by_hash(ctx->statedb.db, h);
if( !st ) {
return 0;
}
@ -392,7 +392,7 @@ static int _check_read_from_db(CSYNC *ctx, const char *uri) {
/* search that folder in the db and check that the hash is the md5 (etag) is still the same */
if( csync_get_statedb_exists(ctx) ) {
tmp = csync_statedb_get_stat_by_hash(ctx, h);
tmp = csync_statedb_get_stat_by_hash(ctx->statedb.db, h);
if (tmp) {
md5_local = tmp->md5;
md5_remote = csync_vio_file_id(ctx, uri);

View file

@ -287,7 +287,7 @@ static int _fix_errors_visitor(void *obj, void *data) {
}
/* check if the file is new or has been synced */
tfs = csync_statedb_get_stat_by_hash(ctx, fs->phash);
tfs = csync_statedb_get_stat_by_hash(ctx->statedb.db, fs->phash);
if (tfs == NULL) {
rc = 0;
goto out;

View file

@ -104,6 +104,7 @@ typedef wchar_t mbchar_t;
#define _tseekdir _wseekdir
#define _tcreat _wcreat
#define _tstat _wstat
#define _tfstat _fstat64
#define _tunlink _wunlink
#define _tmkdir(X,Y) _wmkdir(X)
#define _trmdir _rmdir
@ -123,6 +124,7 @@ typedef char mbchar_t;
#define _tseekdir seekdir
#define _tcreat creat
#define _tstat stat
#define _tfstat fstat
#define _tunlink unlink
#define _tmkdir(X,Y) mkdir(X,Y)
#define _trmdir rmdir

View file

@ -27,6 +27,7 @@
#include "c_private.h"
#include "vio/csync_vio_handle.h"
#include "vio/csync_vio_file_stat.h"
#include "csync_private.h"
typedef struct fhandle_s {
int fd;