2008-02-27 20:56:47 +03:00
|
|
|
/*
|
2013-07-23 19:31:55 +04:00
|
|
|
* cynapses libc functions
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
|
|
|
|
* Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* This library 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.
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2008-02-27 20:56:47 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-07-23 19:31:55 +04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-02-27 20:56:47 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file csync_private.h
|
|
|
|
*
|
|
|
|
* @brief Private interface of csync
|
|
|
|
*
|
|
|
|
* @defgroup csyncInternalAPI csync internal API
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CSYNC_PRIVATE_H
|
|
|
|
#define _CSYNC_PRIVATE_H
|
|
|
|
|
2008-04-28 12:16:31 +04:00
|
|
|
#include <stdint.h>
|
2011-04-06 18:43:04 +04:00
|
|
|
#include <stdbool.h>
|
2008-02-27 20:56:47 +03:00
|
|
|
#include <sqlite3.h>
|
|
|
|
|
2014-01-15 15:20:03 +04:00
|
|
|
#include "config_csync.h"
|
2014-03-26 20:50:27 +04:00
|
|
|
#include "std/c_lib.h"
|
|
|
|
#include "std/c_private.h"
|
2008-02-27 20:56:47 +03:00
|
|
|
#include "csync.h"
|
2013-07-25 17:36:46 +04:00
|
|
|
#include "csync_misc.h"
|
2013-10-25 15:12:59 +04:00
|
|
|
#include "vio/csync_vio_file_stat.h"
|
2008-02-27 20:56:47 +03:00
|
|
|
|
2012-12-07 16:02:46 +04:00
|
|
|
#ifdef WITH_ICONV
|
|
|
|
#include <iconv.h>
|
|
|
|
#endif
|
|
|
|
|
2013-07-12 13:25:49 +04:00
|
|
|
#ifdef HAVE_ICONV_H
|
2013-02-06 17:56:42 +04:00
|
|
|
#include <iconv.h>
|
|
|
|
#endif
|
2013-07-12 13:25:49 +04:00
|
|
|
#ifdef HAVE_SYS_ICONV_H
|
|
|
|
#include <sys/iconv.h>
|
|
|
|
#endif
|
2013-02-06 17:56:42 +04:00
|
|
|
|
2008-02-27 20:56:47 +03:00
|
|
|
#include "csync_macros.h"
|
|
|
|
|
2008-02-29 13:41:15 +03:00
|
|
|
/**
|
|
|
|
* How deep to scan directories.
|
|
|
|
*/
|
|
|
|
#define MAX_DEPTH 50
|
|
|
|
|
2008-05-27 16:15:44 +04:00
|
|
|
#define CSYNC_STATUS_INIT 1 << 0
|
|
|
|
#define CSYNC_STATUS_UPDATE 1 << 1
|
|
|
|
#define CSYNC_STATUS_RECONCILE 1 << 2
|
|
|
|
#define CSYNC_STATUS_PROPAGATE 1 << 3
|
2009-03-26 12:27:04 +03:00
|
|
|
|
|
|
|
#define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \
|
|
|
|
CSYNC_STATUS_UPDATE | \
|
|
|
|
CSYNC_STATUS_RECONCILE | \
|
|
|
|
CSYNC_STATUS_PROPAGATE)
|
2008-04-29 13:20:52 +04:00
|
|
|
|
2008-02-27 20:56:47 +03:00
|
|
|
enum csync_replica_e {
|
|
|
|
LOCAL_REPLICA,
|
2012-10-19 16:23:20 +04:00
|
|
|
REMOTE_REPLICA
|
2008-02-27 20:56:47 +03:00
|
|
|
};
|
|
|
|
|
2013-03-11 22:55:07 +04:00
|
|
|
typedef struct csync_file_stat_s csync_file_stat_t;
|
|
|
|
|
2014-05-29 14:02:46 +04:00
|
|
|
struct csync_owncloud_ctx_s; // csync_owncloud.c
|
|
|
|
|
2008-02-29 13:41:15 +03:00
|
|
|
/**
|
|
|
|
* @brief csync public structure
|
|
|
|
*/
|
|
|
|
struct csync_s {
|
2012-10-27 17:10:16 +04:00
|
|
|
struct {
|
|
|
|
csync_auth_callback auth_function;
|
|
|
|
void *userdata;
|
2014-08-15 17:00:10 +04:00
|
|
|
csync_update_callback update_callback;
|
|
|
|
void *update_callback_userdata;
|
2012-10-27 17:10:16 +04:00
|
|
|
} callbacks;
|
2008-03-20 12:34:58 +03:00
|
|
|
c_strlist_t *excludes;
|
2008-04-29 11:23:51 +04:00
|
|
|
|
|
|
|
struct {
|
2008-05-27 15:48:07 +04:00
|
|
|
char *file;
|
2008-04-29 11:23:51 +04:00
|
|
|
sqlite3 *db;
|
|
|
|
int exists;
|
2014-03-19 19:22:25 +04:00
|
|
|
|
|
|
|
sqlite3_stmt* by_hash_stmt;
|
|
|
|
sqlite3_stmt* by_fileid_stmt;
|
|
|
|
sqlite3_stmt* by_inode_stmt;
|
2014-10-20 21:27:02 +04:00
|
|
|
|
|
|
|
int lastReturnValue;
|
2008-07-09 12:10:00 +04:00
|
|
|
} statedb;
|
2008-04-22 19:23:26 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
char *uri;
|
|
|
|
c_rbtree_t *tree;
|
2008-05-20 15:56:43 +04:00
|
|
|
c_list_t *list;
|
2008-04-28 12:05:40 +04:00
|
|
|
enum csync_replica_e type;
|
2008-04-22 19:23:26 +04:00
|
|
|
} local;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
char *uri;
|
2008-04-23 15:05:40 +04:00
|
|
|
c_rbtree_t *tree;
|
2008-05-20 15:56:43 +04:00
|
|
|
c_list_t *list;
|
2008-04-28 12:05:40 +04:00
|
|
|
enum csync_replica_e type;
|
2012-08-23 18:49:18 +04:00
|
|
|
int read_from_db;
|
2014-09-19 12:58:52 +04:00
|
|
|
const char *root_perms; /* Permission of the root folder. (Since the root folder is not in the db tree, we need to keep a separate entry.) */
|
2008-04-22 19:23:26 +04:00
|
|
|
} remote;
|
2008-04-17 20:02:41 +04:00
|
|
|
|
2014-09-19 12:58:52 +04:00
|
|
|
|
2013-07-12 13:25:49 +04:00
|
|
|
#if defined(HAVE_ICONV) && defined(WITH_ICONV)
|
2014-06-16 18:26:00 +04:00
|
|
|
struct {
|
2012-12-07 16:02:46 +04:00
|
|
|
iconv_t iconv_cd;
|
2008-02-29 13:41:15 +03:00
|
|
|
} options;
|
2014-06-16 18:26:00 +04:00
|
|
|
#endif
|
2008-02-29 13:41:15 +03:00
|
|
|
|
2009-01-23 16:10:08 +03:00
|
|
|
/* replica we are currently walking */
|
2008-04-28 16:08:51 +04:00
|
|
|
enum csync_replica_e current;
|
2009-01-23 16:10:08 +03:00
|
|
|
|
|
|
|
/* replica we want to work on */
|
2008-04-22 19:23:26 +04:00
|
|
|
enum csync_replica_e replica;
|
|
|
|
|
2013-03-11 22:55:07 +04:00
|
|
|
/* Used in the update phase so changes in the sub directories can be notified to
|
|
|
|
parent directories */
|
|
|
|
csync_file_stat_t *current_fs;
|
|
|
|
|
2013-03-12 20:01:39 +04:00
|
|
|
/* csync error code */
|
|
|
|
enum csync_status_codes_e status_code;
|
|
|
|
|
2012-12-14 19:48:47 +04:00
|
|
|
char *error_string;
|
2013-03-13 17:45:12 +04:00
|
|
|
|
2008-04-29 11:23:51 +04:00
|
|
|
int status;
|
2013-05-08 17:28:26 +04:00
|
|
|
volatile int abort;
|
2013-01-04 23:45:10 +04:00
|
|
|
void *rename_info;
|
2014-04-25 15:31:44 +04:00
|
|
|
int read_from_db_disabled;
|
2014-05-29 14:02:46 +04:00
|
|
|
|
|
|
|
struct csync_owncloud_ctx_s *owncloud_context;
|
2014-08-11 20:41:42 +04:00
|
|
|
|
|
|
|
/* hooks for checking the white list */
|
2014-10-11 18:23:32 +04:00
|
|
|
void *checkSelectiveSyncBlackListData;
|
|
|
|
int (*checkSelectiveSyncBlackListHook)(void*, const char*);
|
2008-02-27 20:56:47 +03:00
|
|
|
};
|
|
|
|
|
2008-05-16 16:12:00 +04:00
|
|
|
|
2012-02-04 15:23:54 +04:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack(1)
|
|
|
|
#endif
|
|
|
|
struct csync_file_stat_s {
|
2011-09-08 01:04:21 +04:00
|
|
|
uint64_t phash; /* u64 */
|
|
|
|
time_t modtime; /* u64 */
|
2013-07-30 18:19:12 +04:00
|
|
|
int64_t size; /* u64 */
|
2011-09-08 01:04:21 +04:00
|
|
|
size_t pathlen; /* u64 */
|
2012-08-03 19:48:44 +04:00
|
|
|
uint64_t inode; /* u64 */
|
2011-09-08 01:04:21 +04:00
|
|
|
mode_t mode; /* u32 */
|
|
|
|
int nlink; /* u32 */
|
|
|
|
int type; /* u32 */
|
2013-03-11 22:55:07 +04:00
|
|
|
int child_modified;/*bool*/
|
2013-11-13 17:29:31 +04:00
|
|
|
int should_update_etag; /*bool */
|
2014-08-28 19:16:17 +04:00
|
|
|
int has_ignored_files; /*bool: specify that a directory, or child directory contains ignored files */
|
2012-08-23 18:43:21 +04:00
|
|
|
|
2012-08-02 17:58:54 +04:00
|
|
|
char *destpath; /* for renames */
|
2013-11-13 17:29:31 +04:00
|
|
|
const char *etag;
|
2013-10-25 15:12:59 +04:00
|
|
|
char file_id[FILE_ID_BUF_SIZE+1]; /* the ownCloud file id is fixed width of 21 byte. */
|
2014-06-03 13:50:13 +04:00
|
|
|
char *directDownloadUrl;
|
|
|
|
char *directDownloadCookies;
|
2014-06-06 17:24:17 +04:00
|
|
|
char remotePerm[REMOTE_PERM_BUF_SIZE+1];
|
2014-06-03 13:50:13 +04:00
|
|
|
|
2013-12-04 15:18:09 +04:00
|
|
|
CSYNC_STATUS error_status;
|
2012-08-13 16:24:15 +04:00
|
|
|
|
2011-09-08 01:04:21 +04:00
|
|
|
enum csync_instructions_e instruction; /* u32 */
|
|
|
|
char path[1]; /* u8 */
|
2012-02-04 15:23:54 +04:00
|
|
|
}
|
|
|
|
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
|
|
|
|
__attribute__ ((packed))
|
|
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack()
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2013-07-02 20:25:17 +04:00
|
|
|
void csync_file_stat_free(csync_file_stat_t *st);
|
|
|
|
|
2012-03-19 19:05:23 +04:00
|
|
|
/*
|
|
|
|
* context for the treewalk function
|
|
|
|
*/
|
|
|
|
struct _csync_treewalk_context_s
|
|
|
|
{
|
|
|
|
csync_treewalk_visit_func *user_visitor;
|
|
|
|
int instruction_filter;
|
|
|
|
void *userdata;
|
|
|
|
};
|
|
|
|
typedef struct _csync_treewalk_context_s _csync_treewalk_context;
|
|
|
|
|
2014-02-28 11:49:57 +04:00
|
|
|
|
2008-02-27 20:56:47 +03:00
|
|
|
/**
|
|
|
|
* }@
|
|
|
|
*/
|
|
|
|
#endif /* _CSYNC_PRIVATE_H */
|
2009-05-13 12:12:07 +04:00
|
|
|
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
|