doc
Data Structures | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables
csync public API

Data Structures

struct  csync_progress_s
 
struct  csync_tree_walk_file_s
 

Macros

#define CSYNC_CONF_DIR   ".ocsync"
 
#define CSYNC_CONF_FILE   "ocsync.conf"
 
#define CSYNC_EXCLUDE_FILE   "ocsync_exclude.conf"
 
#define CSYNC_LOCK_FILE   ".csync.lock"
 

Typedefs

typedef struct csync_s CSYNC
 
typedef int(* csync_auth_callback )(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)
 
typedef enum csync_error_codes_e CSYNC_ERROR_CODE
 
typedef void(* csync_log_callback )(CSYNC *ctx, int verbosity, const char *function, const char *buffer, void *userdata)
 
typedef struct csync_progress_s CSYNC_PROGRESS
 
typedef void(* csync_progress_callback )(CSYNC_PROGRESS *progress, void *userdata)
 
typedef int csync_treewalk_visit_func (TREE_WALK_FILE *, void *)
 
typedef struct
csync_tree_walk_file_s 
TREE_WALK_FILE
 

Enumerations

enum  csync_error_codes_e {
  CSYNC_ERR_NONE = 0, CSYNC_ERR_LOG, CSYNC_ERR_LOCK, CSYNC_ERR_STATEDB_LOAD,
  CSYNC_ERR_STATEDB_WRITE, CSYNC_ERR_MODULE, CSYNC_ERR_TIMESKEW, CSYNC_ERR_FILESYSTEM,
  CSYNC_ERR_TREE, CSYNC_ERR_MEM, CSYNC_ERR_PARAM, CSYNC_ERR_UPDATE,
  CSYNC_ERR_RECONCILE, CSYNC_ERR_PROPAGATE, CSYNC_ERR_ACCESS_FAILED, CSYNC_ERR_REMOTE_CREATE,
  CSYNC_ERR_REMOTE_STAT, CSYNC_ERR_LOCAL_CREATE, CSYNC_ERR_LOCAL_STAT, CSYNC_ERR_PROXY,
  CSYNC_ERR_LOOKUP, CSYNC_ERR_AUTH_SERVER, CSYNC_ERR_AUTH_PROXY, CSYNC_ERR_CONNECT,
  CSYNC_ERR_TIMEOUT, CSYNC_ERR_HTTP, CSYNC_ERR_PERM, CSYNC_ERR_NOT_FOUND,
  CSYNC_ERR_EXISTS, CSYNC_ERR_NOSPC, CSYNC_ERR_QUOTA, CSYNC_ERR_SERVICE_UNAVAILABLE,
  CSYNC_ERR_FILE_TOO_BIG, CSYNC_ERR_ABORTED, CSYNC_ERR_UNSPEC
}
 
enum  csync_ftw_type_e { CSYNC_FTW_TYPE_FILE, CSYNC_FTW_TYPE_SLINK, CSYNC_FTW_TYPE_DIR, CSYNC_FTW_TYPE_SKIP }
 
enum  csync_instructions_e {
  CSYNC_INSTRUCTION_NONE = 0x00000000, CSYNC_INSTRUCTION_EVAL = 0x00000001, CSYNC_INSTRUCTION_REMOVE = 0x00000002, CSYNC_INSTRUCTION_RENAME = 0x00000004,
  CSYNC_INSTRUCTION_NEW = 0x00000008, CSYNC_INSTRUCTION_CONFLICT = 0x00000010, CSYNC_INSTRUCTION_IGNORE = 0x00000020, CSYNC_INSTRUCTION_SYNC = 0x00000040,
  CSYNC_INSTRUCTION_STAT_ERROR = 0x00000080, CSYNC_INSTRUCTION_ERROR = 0x00000100, CSYNC_INSTRUCTION_DELETED = 0x00000200, CSYNC_INSTRUCTION_UPDATED = 0x00000400
}
 
enum  csync_notify_type_e {
  CSYNC_NOTIFY_INVALID, CSYNC_NOTIFY_START_SYNC_SEQUENCE, CSYNC_NOTIFY_START_DOWNLOAD, CSYNC_NOTIFY_START_UPLOAD,
  CSYNC_NOTIFY_PROGRESS, CSYNC_NOTIFY_FINISHED_DOWNLOAD, CSYNC_NOTIFY_FINISHED_UPLOAD, CSYNC_NOTIFY_FINISHED_SYNC_SEQUENCE,
  CSYNC_NOTIFY_START_DELETE, CSYNC_NOTIFY_END_DELETE, CSYNC_NOTIFY_ERROR
}
 

Functions

int csync_abort_requested (CSYNC *ctx)
 
int csync_add_exclude_list (CSYNC *ctx, const char *path)
 
void csync_clear_exclude_list (CSYNC *ctx)
 
int csync_commit (CSYNC *ctx)
 
int csync_create (CSYNC **csync, const char *local, const char *remote)
 
int csync_destroy (CSYNC *ctx)
 
int csync_disable_statedb (CSYNC *ctx)
 
int csync_enable_conflictcopys (CSYNC *ctx)
 
int csync_enable_statedb (CSYNC *ctx)
 
csync_auth_callback csync_get_auth_callback (CSYNC *ctx)
 
const char * csync_get_config_dir (CSYNC *ctx)
 
CSYNC_ERROR_CODE csync_get_error (CSYNC *ctx)
 
const char * csync_get_error_string (CSYNC *ctx)
 
bool csync_get_local_only (CSYNC *ctx)
 
csync_log_callback csync_get_log_callback (CSYNC *ctx)
 
int csync_get_log_verbosity (CSYNC *ctx)
 
csync_progress_callback csync_get_progress_callback (CSYNC *ctx)
 
const char * csync_get_statedb_file (CSYNC *ctx)
 
int csync_get_status (CSYNC *ctx)
 
void * csync_get_userdata (CSYNC *ctx)
 
int csync_init (CSYNC *ctx)
 
int csync_is_statedb_disabled (CSYNC *ctx)
 
int csync_propagate (CSYNC *ctx)
 
int csync_reconcile (CSYNC *ctx)
 
int csync_remove_config_dir (CSYNC *ctx)
 
void csync_request_abort (CSYNC *ctx)
 
void csync_resume (CSYNC *ctx)
 
int csync_set_auth_callback (CSYNC *ctx, csync_auth_callback cb)
 
int csync_set_config_dir (CSYNC *ctx, const char *path)
 
int csync_set_iconv_codec (const char *from)
 
int csync_set_local_only (CSYNC *ctx, bool local_only)
 
int csync_set_log_callback (CSYNC *ctx, csync_log_callback cb)
 
int csync_set_log_verbosity (CSYNC *ctx, int verbosity)
 
int csync_set_module_property (CSYNC *ctx, const char *key, void *value)
 
int csync_set_progress_callback (CSYNC *ctx, csync_progress_callback cb)
 
int csync_set_status (CSYNC *ctx, int status)
 
int csync_set_userdata (CSYNC *ctx, void *userdata)
 
int csync_update (CSYNC *ctx)
 
const char * csync_version (int req_version)
 
int csync_walk_local_tree (CSYNC *ctx, csync_treewalk_visit_func *visitor, int filter)
 
int csync_walk_remote_tree (CSYNC *ctx, csync_treewalk_visit_func *visitor, int filter)
 

Variables

int64_t csync_progress_s::curr_bytes
 
int64_t csync_progress_s::current_file_no
 
int64_t csync_progress_s::current_overall_bytes
 
const char * csync_tree_walk_file_s::error_string
 
int64_t csync_progress_s::file_size
 
gid_t csync_tree_walk_file_s::gid
 
enum csync_instructions_e csync_tree_walk_file_s::instruction
 
enum csync_notify_type_e csync_progress_s::kind
 
const char * csync_tree_walk_file_s::md5
 
mode_t csync_tree_walk_file_s::mode
 
time_t csync_tree_walk_file_s::modtime
 
int64_t csync_progress_s::overall_file_count
 
int64_t csync_progress_s::overall_transmission_size
 
const char * csync_progress_s::path
 
const char * csync_tree_walk_file_s::path
 
const char * csync_tree_walk_file_s::rename_path
 
enum csync_ftw_type_e csync_tree_walk_file_s::type
 
uid_t csync_tree_walk_file_s::uid
 

Detailed Description

Macro Definition Documentation

#define CSYNC_CONF_DIR   ".ocsync"

Definition at line 48 of file csync.h.

#define CSYNC_CONF_FILE   "ocsync.conf"

Definition at line 49 of file csync.h.

#define CSYNC_EXCLUDE_FILE   "ocsync_exclude.conf"

Definition at line 50 of file csync.h.

#define CSYNC_LOCK_FILE   ".csync.lock"

Definition at line 51 of file csync.h.

Typedef Documentation

typedef struct csync_s CSYNC

csync handle

Definition at line 187 of file csync.h.

typedef int(* csync_auth_callback)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)

Definition at line 189 of file csync.h.

Definition at line 91 of file csync.h.

typedef void(* csync_log_callback)(CSYNC *ctx, int verbosity, const char *function, const char *buffer, void *userdata)

Definition at line 192 of file csync.h.

Definition at line 149 of file csync.h.

typedef void(* csync_progress_callback)(CSYNC_PROGRESS *progress, void *userdata)

Callback definition for file progress callback.

Parameters
progressA struct containing progress information.
userdataUser defined data for the callback.

Definition at line 555 of file csync.h.

typedef int csync_treewalk_visit_func(TREE_WALK_FILE *,void *)

Definition at line 488 of file csync.h.

Definition at line 182 of file csync.h.

Enumeration Type Documentation

Enumerator
CSYNC_ERR_NONE 
CSYNC_ERR_LOG 
CSYNC_ERR_LOCK 
CSYNC_ERR_STATEDB_LOAD 
CSYNC_ERR_STATEDB_WRITE 
CSYNC_ERR_MODULE 
CSYNC_ERR_TIMESKEW 
CSYNC_ERR_FILESYSTEM 
CSYNC_ERR_TREE 
CSYNC_ERR_MEM 
CSYNC_ERR_PARAM 
CSYNC_ERR_UPDATE 
CSYNC_ERR_RECONCILE 
CSYNC_ERR_PROPAGATE 
CSYNC_ERR_ACCESS_FAILED 
CSYNC_ERR_REMOTE_CREATE 
CSYNC_ERR_REMOTE_STAT 
CSYNC_ERR_LOCAL_CREATE 
CSYNC_ERR_LOCAL_STAT 
CSYNC_ERR_PROXY 
CSYNC_ERR_LOOKUP 
CSYNC_ERR_AUTH_SERVER 
CSYNC_ERR_AUTH_PROXY 
CSYNC_ERR_CONNECT 
CSYNC_ERR_TIMEOUT 
CSYNC_ERR_HTTP 
CSYNC_ERR_PERM 
CSYNC_ERR_NOT_FOUND 
CSYNC_ERR_EXISTS 
CSYNC_ERR_NOSPC 
CSYNC_ERR_QUOTA 
CSYNC_ERR_SERVICE_UNAVAILABLE 
CSYNC_ERR_FILE_TOO_BIG 
CSYNC_ERR_ABORTED 
CSYNC_ERR_UNSPEC 

Definition at line 53 of file csync.h.

Enumerator
CSYNC_FTW_TYPE_FILE 
CSYNC_FTW_TYPE_SLINK 
CSYNC_FTW_TYPE_DIR 
CSYNC_FTW_TYPE_SKIP 

Definition at line 113 of file csync.h.

Instruction enum.

In the file traversal structure, it describes the csync state of a file.

Enumerator
CSYNC_INSTRUCTION_NONE 
CSYNC_INSTRUCTION_EVAL 
CSYNC_INSTRUCTION_REMOVE 
CSYNC_INSTRUCTION_RENAME 
CSYNC_INSTRUCTION_NEW 
CSYNC_INSTRUCTION_CONFLICT 
CSYNC_INSTRUCTION_IGNORE 
CSYNC_INSTRUCTION_SYNC 
CSYNC_INSTRUCTION_STAT_ERROR 
CSYNC_INSTRUCTION_ERROR 
CSYNC_INSTRUCTION_DELETED 
CSYNC_INSTRUCTION_UPDATED 

Definition at line 97 of file csync.h.

Enumerator
CSYNC_NOTIFY_INVALID 
CSYNC_NOTIFY_START_SYNC_SEQUENCE 
CSYNC_NOTIFY_START_DOWNLOAD 
CSYNC_NOTIFY_START_UPLOAD 
CSYNC_NOTIFY_PROGRESS 
CSYNC_NOTIFY_FINISHED_DOWNLOAD 
CSYNC_NOTIFY_FINISHED_UPLOAD 
CSYNC_NOTIFY_FINISHED_SYNC_SEQUENCE 
CSYNC_NOTIFY_START_DELETE 
CSYNC_NOTIFY_END_DELETE 
CSYNC_NOTIFY_ERROR 

Definition at line 120 of file csync.h.

Function Documentation

int csync_abort_requested ( CSYNC ctx)

Checks for the abort flag, to be used from the modules.

Parameters
ctxThe csync context.
int csync_add_exclude_list ( CSYNC ctx,
const char *  path 
)

Add an additional exclude list.

Parameters
ctxThe context to add the exclude list.
pathThe path pointing to the file.
Returns
0 on success, less than 0 if an error occured.
void csync_clear_exclude_list ( CSYNC ctx)

Removes all items imported from exclude lists.

Parameters
ctxThe context to add the exclude list.
int csync_commit ( CSYNC ctx)

Commit the sync results to journal.

Parameters
ctxThe context to commit.
Returns
0 on success, less than 0 if an error occured.
int csync_create ( CSYNC **  csync,
const char *  local,
const char *  remote 
)

Allocate a csync context.

Parameters
csyncThe context variable to allocate.
Returns
0 on success, less than 0 if an error occured.
int csync_destroy ( CSYNC ctx)

Destroy the csync context.

Writes the statedb, unlocks csync and frees the memory.

Parameters
ctxThe context to destroy.
Returns
0 on success, less than 0 if an error occured.
int csync_disable_statedb ( CSYNC ctx)

Disable the usage of the statedb.

It is enabled by default.

Parameters
ctxThe csync context.
Returns
0 on success, less than 0 if an error occured.
int csync_enable_conflictcopys ( CSYNC ctx)

Enable the creation of backup copys if files are changed on both sides.

Parameters
ctxThe csync context.
Returns
0 on success, less than 0 if an error occured.
int csync_enable_statedb ( CSYNC ctx)

Enable the usage of the statedb.

It is enabled by default.

Parameters
ctxThe csync context.
Returns
0 on success, less than 0 if an error occured.
csync_auth_callback csync_get_auth_callback ( CSYNC ctx)

Get the authentication callback set.

Parameters
ctxThe csync context.
Returns
The authentication callback set or NULL if an error occured.
const char* csync_get_config_dir ( CSYNC ctx)

Get the config directory.

Parameters
ctxThe csync context.
Returns
The path of the config directory or NULL on error.
CSYNC_ERROR_CODE csync_get_error ( CSYNC ctx)

Get the error code from the last operation.

Returns
An error code defined by structure CSYNC_ERROR_CODE
const char* csync_get_error_string ( CSYNC ctx)

csync_get_error_string - return a string with error information

Parameters
ctx
Returns
A pointer to an error string or NULL.
bool csync_get_local_only ( CSYNC ctx)

Retrieve the flag to tell csync that only a local run is intended.

Returns
1: stay local only, 0: local and remote mode
csync_log_callback csync_get_log_callback ( CSYNC ctx)

Get the logging callback set.

Parameters
ctxThe csync context.
Returns
The logging callback set or NULL if an error occured.
int csync_get_log_verbosity ( CSYNC ctx)

Get the log verbosity.

Parameters
[in]ctxThe csync context to ask for the log verbosity.
Returns
The log verbosity, -1 on error.
csync_progress_callback csync_get_progress_callback ( CSYNC ctx)
const char* csync_get_statedb_file ( CSYNC ctx)

Get the path of the statedb file used.

Parameters
ctxThe csync context.
Returns
The path to the statedb file, NULL if an error occured.
int csync_get_status ( CSYNC ctx)
void* csync_get_userdata ( CSYNC ctx)

Get the userdata saved in the context.

Parameters
ctxThe csync context.
Returns
The userdata saved in the context, NULL if an error occured.
int csync_init ( CSYNC ctx)

Initialize the file synchronizer.

This function loads the configuration, the statedb and locks the client.

Parameters
ctxThe context to initialize.
Returns
0 on success, less than 0 if an error occured.
int csync_is_statedb_disabled ( CSYNC ctx)

Check if the statedb usage is enabled.

Parameters
ctxThe csync context.
Returns
1 if it is enabled, 0 if it is disabled.
int csync_propagate ( CSYNC ctx)

Propagation.

Parameters
ctxThe context to run the propagation on.
Returns
0 on success, less than 0 if an error occured.
int csync_reconcile ( CSYNC ctx)

Reconciliation.

Parameters
ctxThe context to run the reconciliation on.
Returns
0 on success, less than 0 if an error occured.
int csync_remove_config_dir ( CSYNC ctx)

Remove the complete config directory.

Parameters
ctxThe csync context.
Returns
0 on success, less than 0 if an error occured.
void csync_request_abort ( CSYNC ctx)

Aborts the current sync run as soon as possible.

Can be called from another thread.

Parameters
ctxThe csync context.
void csync_resume ( CSYNC ctx)

Clears the abort flag.

Can be called from another thread.

Parameters
ctxThe csync context.
int csync_set_auth_callback ( CSYNC ctx,
csync_auth_callback  cb 
)

Set the authentication callback.

Parameters
ctxThe csync context.
cbThe authentication callback.
Returns
0 on success, less than 0 if an error occured.
int csync_set_config_dir ( CSYNC ctx,
const char *  path 
)

Change the config directory.

Parameters
ctxThe csync context.
pathThe path to the new config directory.
Returns
0 on success, less than 0 if an error occured.
int csync_set_iconv_codec ( const char *  from)

Set iconv source codec for filenames.

Parameters
fromSource codec.
Returns
0 on success, or an iconv error number.
int csync_set_local_only ( CSYNC ctx,
bool  local_only 
)

Flag to tell csync that only a local run is intended.

Call before csync_init

Parameters
local_onlyBool flag to indicate local only mode.
Returns
0 on success, less than 0 if an error occured.
int csync_set_log_callback ( CSYNC ctx,
csync_log_callback  cb 
)

Set the logging callback.

Parameters
ctxThe csync context.
cbThe logging callback.
Returns
0 on success, less than 0 if an error occured.
int csync_set_log_verbosity ( CSYNC ctx,
int  verbosity 
)

Set the log verbosity.

Parameters
ctxThe csync context.
[in]verbosityThe log verbosity.
Returns
0 on success, < 0 if an error occured.
int csync_set_module_property ( CSYNC ctx,
const char *  key,
void *  value 
)

Set a property to module.

Parameters
ctxThe csync context.
keyThe property key
valueAn opaque pointer to the data.
Returns
0 on success, less than 0 if an error occured.
int csync_set_progress_callback ( CSYNC ctx,
csync_progress_callback  cb 
)

Set a progress callback.

This callback reports about up- or download progress of a individual file as well as overall progress.

int csync_set_status ( CSYNC ctx,
int  status 
)
int csync_set_userdata ( CSYNC ctx,
void *  userdata 
)

Save userdata to the context which is passed to the auth callback function.

Parameters
ctxThe csync context.
userdataThe userdata to be stored in the context.
Returns
0 on success, less than 0 if an error occured.
int csync_update ( CSYNC ctx)

Update detection.

Parameters
ctxThe context to run the update detection on.
Returns
0 on success, less than 0 if an error occured.
const char* csync_version ( int  req_version)

Check if csync is the required version or get the version string.

Parameters
req_versionThe version required.
Returns
If the version of csync is newer than the version required it will return a version string. NULL if the version is older.

Example:

if (csync_version(CSYNC_VERSION_INT(0,42,1)) == NULL) {
fprintf(stderr, "libcsync version is too old!\n");
exit(1);
}
if (debug) {
printf("csync %s\n", csync_version(0));
}
int csync_walk_local_tree ( CSYNC ctx,
csync_treewalk_visit_func visitor,
int  filter 
)

Walk the local file tree and call a visitor function for each file.

Parameters
ctxThe csync context.
visitorA callback function to handle the file info.
filterA filter, built from or'ed csync_instructions_e
Returns
0 on success, less than 0 if an error occured.
int csync_walk_remote_tree ( CSYNC ctx,
csync_treewalk_visit_func visitor,
int  filter 
)

Walk the remote file tree and call a visitor function for each file.

Parameters
ctxThe csync context.
visitorA callback function to handle the file info.
filterA filter, built from and'ed csync_instructions_e
Returns
0 on success, less than 0 if an error occured.

Variable Documentation

int64_t csync_progress_s::curr_bytes

Definition at line 139 of file csync.h.

int64_t csync_progress_s::current_file_no

Definition at line 146 of file csync.h.

int64_t csync_progress_s::current_overall_bytes

Definition at line 144 of file csync.h.

const char* csync_tree_walk_file_s::error_string

Definition at line 180 of file csync.h.

int64_t csync_progress_s::file_size

Definition at line 140 of file csync.h.

gid_t csync_tree_walk_file_s::gid

Definition at line 172 of file csync.h.

enum csync_instructions_e csync_tree_walk_file_s::instruction

Definition at line 176 of file csync.h.

enum csync_notify_type_e csync_progress_s::kind

Definition at line 135 of file csync.h.

const char* csync_tree_walk_file_s::md5

Definition at line 179 of file csync.h.

mode_t csync_tree_walk_file_s::mode

Definition at line 174 of file csync.h.

time_t csync_tree_walk_file_s::modtime

Definition at line 166 of file csync.h.

int64_t csync_progress_s::overall_file_count

Definition at line 145 of file csync.h.

int64_t csync_progress_s::overall_transmission_size

Definition at line 143 of file csync.h.

const char* csync_progress_s::path

Definition at line 138 of file csync.h.

const char* csync_tree_walk_file_s::path

Definition at line 164 of file csync.h.

const char* csync_tree_walk_file_s::rename_path

Definition at line 178 of file csync.h.

enum csync_ftw_type_e csync_tree_walk_file_s::type

Definition at line 175 of file csync.h.

uid_t csync_tree_walk_file_s::uid

Definition at line 171 of file csync.h.