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

Data Structures

struct  csync_tree_walk_file_s
 

Macros

#define CSYNC_CONF_DIR   ".csync"
 
#define CSYNC_CONF_FILE   "csync.conf"
 
#define CSYNC_EXCLUDE_FILE   "csync_exclude.conf"
 
#define CSYNC_LOCK_FILE   "lock"
 
#define CSYNC_STATUS_IS_EQUAL(x, y)   ((x) == (y))
 
#define CSYNC_STATUS_IS_ERR(x)   (unlikely((x) >= CSYNC_STATUS_ERROR))
 
#define CSYNC_STATUS_IS_OK(x)   (likely((x) == CSYNC_STATUS_OK))
 
#define CSYNC_STRINGIFY(s)   CSYNC_TOSTRING(s)
 
#define CSYNC_TOSTRING(s)   #s
 
#define CSYNC_VERSION(a, b, c)   CSYNC_VERSION_DOT(a, b, c)
 
#define CSYNC_VERSION_DOT(a, b, c)   a ##.## b ##.## c
 
#define CSYNC_VERSION_INT(a, b, c)   ((a) << 16 | (b) << 8 | (c))
 
#define LIBCSYNC_VERSION
 
#define LIBCSYNC_VERSION_INT
 
#define LIBCSYNC_VERSION_MAJOR   0
 
#define LIBCSYNC_VERSION_MICRO   0
 
#define LIBCSYNC_VERSION_MINOR   50
 
#define likely(x)   (x)
 
#define unlikely(x)   (x)
 

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 void(* csync_file_progress_callback) (const char *remote_url, enum csync_notify_type_e kind, long long o1, long long o2, void *userdata)
 
typedef void(* csync_log_callback) (int verbosity, const char *function, const char *buffer, void *userdata)
 
typedef void(* csync_overall_progress_callback) (const char *file_name, int file_no, int file_cnt, long long o1, long long o2, void *userdata)
 
typedef enum csync_status_codes_e CSYNC_STATUS
 
typedef int csync_treewalk_visit_func(TREE_WALK_FILE *, void *)
 
typedef struct csync_tree_walk_file_s TREE_WALK_FILE
 

Enumerations

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_START_DOWNLOAD, CSYNC_NOTIFY_START_UPLOAD, CSYNC_NOTIFY_PROGRESS, CSYNC_NOTIFY_FINISHED_DOWNLOAD,
  CSYNC_NOTIFY_FINISHED_UPLOAD
}
 
enum  csync_status_codes_e {
  CSYNC_STATUS_OK = 0, CSYNC_STATUS_ERROR = 1024, CSYNC_STATUS_UNSUCCESSFUL, CSYNC_STATUS_NO_LOCK,
  CSYNC_STATUS_STATEDB_LOAD_ERROR, CSYNC_STATUS_STATEDB_WRITE_ERROR, CSYNC_STATUS_NO_MODULE, CSYNC_STATUS_TIMESKEW,
  CSYNC_STATUS_FILESYSTEM_UNKNOWN, CSYNC_STATUS_TREE_ERROR, CSYNC_STATUS_MEMORY_ERROR, CSYNC_STATUS_PARAM_ERROR,
  CSYNC_STATUS_UPDATE_ERROR, CSYNC_STATUS_RECONCILE_ERROR, CSYNC_STATUS_PROPAGATE_ERROR, CSYNC_STATUS_REMOTE_ACCESS_ERROR,
  CSYNC_STATUS_REMOTE_CREATE_ERROR, CSYNC_STATUS_REMOTE_STAT_ERROR, CSYNC_STATUS_LOCAL_CREATE_ERROR, CSYNC_STATUS_LOCAL_STAT_ERROR,
  CSYNC_STATUS_PROXY_ERROR, CSYNC_STATUS_LOOKUP_ERROR, CSYNC_STATUS_SERVER_AUTH_ERROR, CSYNC_STATUS_PROXY_AUTH_ERROR,
  CSYNC_STATUS_CONNECT_ERROR, CSYNC_STATUS_TIMEOUT, CSYNC_STATUS_HTTP_ERROR, CSYNC_STATUS_PERMISSION_DENIED,
  CSYNC_STATUS_NOT_FOUND, CSYNC_STATUS_FILE_EXISTS, CSYNC_STATUS_OUT_OF_SPACE, CSYNC_STATUS_QUOTA_EXCEEDED,
  CSYNC_STATUS_SERVICE_UNAVAILABLE, CSYNC_STATUS_FILE_SIZE_ERROR, CSYNC_STATUS_CONTEXT_LOST, CSYNC_STATUS_MERGE_FILETREE_ERROR,
  CSYNC_STATUS_CSYNC_STATUS_ERROR, CSYNC_STATUS_OPENDIR_ERROR, CSYNC_STATUS_READDIR_ERROR, CSYNC_STATUS_OPEN_ERROR
}
 

Functions

int csync_add_exclude_list (CSYNC *ctx, const char *path)
 
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)
 
bool csync_get_local_only (CSYNC *ctx)
 
csync_log_callback csync_get_log_callback (void)
 
int csync_get_log_level (void)
 
void * csync_get_log_userdata (void)
 
const char * csync_get_statedb_file (CSYNC *ctx)
 
int csync_get_status (CSYNC *ctx)
 
const char * csync_get_status_string (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)
 
int csync_set_auth_callback (CSYNC *ctx, csync_auth_callback cb)
 
int csync_set_config_dir (CSYNC *ctx, const char *path)
 
int csync_set_file_progress_callback (CSYNC *ctx, csync_file_progress_callback cb)
 
int csync_set_local_only (CSYNC *ctx, bool local_only)
 
int csync_set_log_callback (csync_log_callback cb)
 
int csync_set_log_level (int level)
 
int csync_set_log_userdata (void *data)
 
int csync_set_module_property (CSYNC *ctx, const char *key, void *value)
 
int csync_set_overall_progress_callback (CSYNC *ctx, csync_overall_progress_callback cb)
 
int csync_set_status (CSYNC *ctx, int status)
 
int csync_set_userdata (CSYNC *ctx, void *userdata)
 
bool csync_status_ok (CSYNC *ctx)
 
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

gid_t csync_tree_walk_file_s::gid
 
enum csync_instructions_e csync_tree_walk_file_s::instruction
 
mode_t csync_tree_walk_file_s::mode
 
time_t csync_tree_walk_file_s::modtime
 
const char * csync_tree_walk_file_s::path
 
int csync_tree_walk_file_s::type
 
uid_t csync_tree_walk_file_s::uid
 

Detailed Description

Macro Definition Documentation

#define CSYNC_CONF_DIR   ".csync"

Definition at line 68 of file csync.h.

#define CSYNC_CONF_FILE   "csync.conf"

Definition at line 69 of file csync.h.

#define CSYNC_EXCLUDE_FILE   "csync_exclude.conf"

Definition at line 70 of file csync.h.

#define CSYNC_LOCK_FILE   "lock"

Definition at line 71 of file csync.h.

#define CSYNC_STATUS_IS_EQUAL (   x,
 
)    ((x) == (y))

Definition at line 133 of file csync.h.

#define CSYNC_STATUS_IS_ERR (   x)    (unlikely((x) >= CSYNC_STATUS_ERROR))

Definition at line 132 of file csync.h.

#define CSYNC_STATUS_IS_OK (   x)    (likely((x) == CSYNC_STATUS_OK))

Definition at line 131 of file csync.h.

#define CSYNC_STRINGIFY (   s)    CSYNC_TOSTRING(s)

Definition at line 45 of file csync.h.

#define CSYNC_TOSTRING (   s)    #s

Definition at line 46 of file csync.h.

#define CSYNC_VERSION (   a,
  b,
 
)    CSYNC_VERSION_DOT(a, b, c)

Definition at line 51 of file csync.h.

#define CSYNC_VERSION_DOT (   a,
  b,
 
)    a ##.## b ##.## c

Definition at line 50 of file csync.h.

#define CSYNC_VERSION_INT (   a,
  b,
 
)    ((a) << 16 | (b) << 8 | (c))

Definition at line 49 of file csync.h.

#define LIBCSYNC_VERSION
Value:
#define LIBCSYNC_VERSION_MINOR
Definition: csync.h:55
#define LIBCSYNC_VERSION_MICRO
Definition: csync.h:56
#define LIBCSYNC_VERSION_MAJOR
Definition: csync.h:54
#define CSYNC_VERSION(a, b, c)
Definition: csync.h:51

Definition at line 61 of file csync.h.

#define LIBCSYNC_VERSION_INT
Value:
#define LIBCSYNC_VERSION_MINOR
Definition: csync.h:55
#define CSYNC_VERSION_INT(a, b, c)
Definition: csync.h:49
#define LIBCSYNC_VERSION_MICRO
Definition: csync.h:56
#define LIBCSYNC_VERSION_MAJOR
Definition: csync.h:54

Definition at line 58 of file csync.h.

#define LIBCSYNC_VERSION_MAJOR   0

Definition at line 54 of file csync.h.

#define LIBCSYNC_VERSION_MICRO   0

Definition at line 56 of file csync.h.

#define LIBCSYNC_VERSION_MINOR   50

Definition at line 55 of file csync.h.

#define likely (   x)    (x)

Definition at line 125 of file csync.h.

#define unlikely (   x)    (x)

Definition at line 128 of file csync.h.

Typedef Documentation

typedef struct csync_s CSYNC

csync handle

Definition at line 183 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 185 of file csync.h.

typedef void(* csync_file_progress_callback) (const char *remote_url, enum csync_notify_type_e kind, long long o1, long long o2, void *userdata)

Callback definition for individual file progress callback.

Parameters
remote_urlThe currently handled file.
kindThe type of progress.
o1The current transmitted bytes.
o2The size of the file.

Definition at line 569 of file csync.h.

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

Definition at line 188 of file csync.h.

typedef void(* csync_overall_progress_callback) (const char *file_name, int file_no, int file_cnt, long long o1, long long o2, void *userdata)

Callback definition for overall progress callback.

Parameters
file_noThe current number of up- or downloaded files.
file_cntThe overall number of files to transmit.
o1The current transmitted bytes.
o2The overall sum of bytes to transmit.
userdataThe user data pointer.

Definition at line 596 of file csync.h.

Definition at line 122 of file csync.h.

typedef int csync_treewalk_visit_func(TREE_WALK_FILE *,void *)

Definition at line 493 of file csync.h.

Definition at line 178 of file csync.h.

Enumeration Type Documentation

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 135 of file csync.h.

Enumerator
CSYNC_NOTIFY_START_DOWNLOAD 
CSYNC_NOTIFY_START_UPLOAD 
CSYNC_NOTIFY_PROGRESS 
CSYNC_NOTIFY_FINISHED_DOWNLOAD 
CSYNC_NOTIFY_FINISHED_UPLOAD 

Definition at line 554 of file csync.h.

Instruction enum.

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

Enumerator
CSYNC_STATUS_OK 
CSYNC_STATUS_ERROR 
CSYNC_STATUS_UNSUCCESSFUL 
CSYNC_STATUS_NO_LOCK 
CSYNC_STATUS_STATEDB_LOAD_ERROR 
CSYNC_STATUS_STATEDB_WRITE_ERROR 
CSYNC_STATUS_NO_MODULE 
CSYNC_STATUS_TIMESKEW 
CSYNC_STATUS_FILESYSTEM_UNKNOWN 
CSYNC_STATUS_TREE_ERROR 
CSYNC_STATUS_MEMORY_ERROR 
CSYNC_STATUS_PARAM_ERROR 
CSYNC_STATUS_UPDATE_ERROR 
CSYNC_STATUS_RECONCILE_ERROR 
CSYNC_STATUS_PROPAGATE_ERROR 
CSYNC_STATUS_REMOTE_ACCESS_ERROR 
CSYNC_STATUS_REMOTE_CREATE_ERROR 
CSYNC_STATUS_REMOTE_STAT_ERROR 
CSYNC_STATUS_LOCAL_CREATE_ERROR 
CSYNC_STATUS_LOCAL_STAT_ERROR 
CSYNC_STATUS_PROXY_ERROR 
CSYNC_STATUS_LOOKUP_ERROR 
CSYNC_STATUS_SERVER_AUTH_ERROR 
CSYNC_STATUS_PROXY_AUTH_ERROR 
CSYNC_STATUS_CONNECT_ERROR 
CSYNC_STATUS_TIMEOUT 
CSYNC_STATUS_HTTP_ERROR 
CSYNC_STATUS_PERMISSION_DENIED 
CSYNC_STATUS_NOT_FOUND 
CSYNC_STATUS_FILE_EXISTS 
CSYNC_STATUS_OUT_OF_SPACE 
CSYNC_STATUS_QUOTA_EXCEEDED 
CSYNC_STATUS_SERVICE_UNAVAILABLE 
CSYNC_STATUS_FILE_SIZE_ERROR 
CSYNC_STATUS_CONTEXT_LOST 
CSYNC_STATUS_MERGE_FILETREE_ERROR 
CSYNC_STATUS_CSYNC_STATUS_ERROR 
CSYNC_STATUS_OPENDIR_ERROR 
CSYNC_STATUS_READDIR_ERROR 
CSYNC_STATUS_OPEN_ERROR 

Definition at line 77 of file csync.h.

Function Documentation

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.
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.
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 ( void  )

Get the logging callback set.

Returns
The logging callback set or NULL if an error occured.
int csync_get_log_level ( void  )

Get the log verbosity.

Returns
The log verbosity, -1 on error.
void* csync_get_log_userdata ( void  )

get the userdata set for the logging callback.

Returns
The userdata or NULL.
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)
const char* csync_get_status_string ( CSYNC ctx)

Get the csync status string.

Parameters
ctxThe csync context.
Returns
A const pointer to a string with more precise status info.
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.
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_file_progress_callback ( CSYNC ctx,
csync_file_progress_callback  cb 
)

Set a progress callback for individual files.

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

Parameters
ctxThe csync context.
cbThe callback
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_log_callback  cb)

Set the logging callback.

Parameters
cbThe logging callback.
Returns
0 on success, less than 0 if an error occured.
int csync_set_log_level ( int  level)

Set the log level.

Parameters
[in]levelThe log verbosity.
Returns
0 on success, < 0 if an error occured.
int csync_set_log_userdata ( void *  data)

Set the userdata passed to the logging callback.

Parameters
[in]dataThe userdata to set.
Returns
0 on success, less than 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_overall_progress_callback ( CSYNC ctx,
csync_overall_progress_callback  cb 
)

Set a progress callback for the overall files.

This callback reports about overall up- or download progress.

Parameters
ctxThe csync context.
cbThe callback
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.
bool csync_status_ok ( CSYNC ctx)

Check internal csync status.

Parameters
csyncThe context to check.
Returns
true if status is error free, false for error states.
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:

1 if (csync_version(CSYNC_VERSION_INT(0,42,1)) == NULL) {
2  fprintf(stderr, "libcsync version is too old!\n");
3  exit(1);
4 }
5 
6 if (debug) {
7  printf("csync %s\n", csync_version(0));
8 }
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 and'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

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.

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.

const char* csync_tree_walk_file_s::path

Definition at line 164 of file csync.h.

int 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.