2008-02-27 20:56:47 +03:00
|
|
|
/*
|
|
|
|
* libcsync -- a library to sync a directory with another
|
|
|
|
*
|
2012-10-27 17:15:59 +04:00
|
|
|
* Copyright (c) 2006-2012 by Andreas Schneider <asn@cryptomilk.org>
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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>
|
|
|
|
|
2008-04-17 16:54:21 +04:00
|
|
|
#include "config.h"
|
2008-02-27 20:56:47 +03:00
|
|
|
#include "c_lib.h"
|
2012-02-20 21:21:22 +04:00
|
|
|
#include "c_private.h"
|
2008-02-27 20:56:47 +03:00
|
|
|
#include "csync.h"
|
|
|
|
|
2013-02-06 17:56:42 +04:00
|
|
|
#ifdef WITH_ICONV
|
|
|
|
#include <iconv.h>
|
|
|
|
#endif
|
|
|
|
|
2008-04-17 20:02:41 +04:00
|
|
|
#include "vio/csync_vio_method.h"
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum time difference between two replicas in seconds
|
|
|
|
*/
|
|
|
|
#define MAX_TIME_DIFFERENCE 10
|
|
|
|
|
2008-02-27 20:56:47 +03:00
|
|
|
/**
|
|
|
|
* Maximum size of a buffer for transfer
|
|
|
|
*/
|
2008-06-02 18:05:40 +04:00
|
|
|
#ifndef MAX_XFER_BUF_SIZE
|
|
|
|
#define MAX_XFER_BUF_SIZE (16 * 1024)
|
|
|
|
#endif
|
2008-02-27 20:56:47 +03:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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;
|
2013-05-06 19:14:17 +04:00
|
|
|
csync_overall_progress_callback overall_progress_cb;
|
|
|
|
csync_file_progress_callback file_progress_cb;
|
2012-10-27 17:10:16 +04:00
|
|
|
void *userdata;
|
|
|
|
} 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;
|
2008-06-24 15:36:47 +04:00
|
|
|
int disabled;
|
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;
|
2008-04-22 19:23:26 +04:00
|
|
|
} remote;
|
2008-04-17 20:02:41 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
void *handle;
|
|
|
|
csync_vio_method_t *method;
|
|
|
|
csync_vio_method_finish_fn finish_fn;
|
2012-07-04 15:56:24 +04:00
|
|
|
csync_vio_capabilities_t capabilities;
|
2008-04-17 20:02:41 +04:00
|
|
|
} module;
|
2008-02-29 13:41:15 +03:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int max_depth;
|
|
|
|
int max_time_difference;
|
2008-05-26 17:58:40 +04:00
|
|
|
int sync_symbolic_links;
|
2009-01-19 13:32:58 +03:00
|
|
|
int unix_extensions;
|
2008-02-29 13:41:15 +03:00
|
|
|
char *config_dir;
|
2011-04-06 18:43:04 +04:00
|
|
|
bool with_conflict_copys;
|
2012-02-27 15:18:02 +04:00
|
|
|
bool local_only_mode;
|
2013-02-06 17:56:42 +04:00
|
|
|
#ifdef WITH_ICONV
|
|
|
|
iconv_t iconv_cd;
|
|
|
|
#endif
|
2008-02-29 13:41:15 +03:00
|
|
|
} options;
|
|
|
|
|
2008-11-13 16:08:26 +03:00
|
|
|
struct {
|
|
|
|
uid_t uid;
|
|
|
|
uid_t euid;
|
|
|
|
} pwd;
|
|
|
|
|
2013-05-06 19:14:17 +04:00
|
|
|
struct {
|
|
|
|
int file_count;
|
|
|
|
int current_file_no;
|
|
|
|
long long byte_sum;
|
|
|
|
long long byte_current;
|
|
|
|
} progress;
|
|
|
|
|
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-12 20:01:39 +04:00
|
|
|
/* csync error code */
|
|
|
|
enum csync_status_codes_e status_code;
|
|
|
|
|
2013-03-13 17:45:12 +04:00
|
|
|
char *error_string;
|
|
|
|
|
2008-04-29 11:23:51 +04:00
|
|
|
int status;
|
2008-02-27 20:56:47 +03:00
|
|
|
};
|
|
|
|
|
2008-05-16 16:12:00 +04:00
|
|
|
enum csync_ftw_type_e {
|
|
|
|
CSYNC_FTW_TYPE_FILE,
|
2008-05-26 19:09:42 +04:00
|
|
|
CSYNC_FTW_TYPE_SLINK,
|
2008-05-16 16:12:00 +04:00
|
|
|
CSYNC_FTW_TYPE_DIR
|
|
|
|
};
|
|
|
|
|
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 */
|
|
|
|
off_t size; /* u64 */
|
|
|
|
size_t pathlen; /* u64 */
|
|
|
|
ino_t inode; /* u64 */
|
|
|
|
uid_t uid; /* u32 */
|
|
|
|
gid_t gid; /* u32 */
|
|
|
|
mode_t mode; /* u32 */
|
|
|
|
int nlink; /* u32 */
|
|
|
|
int type; /* u32 */
|
|
|
|
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
|
|
|
|
;
|
|
|
|
|
|
|
|
typedef struct csync_file_stat_s csync_file_stat_t;
|
2008-04-28 12:16:31 +04:00
|
|
|
|
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;
|
|
|
|
|
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: */
|