本文整理汇总了C++中CSYNC_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ CSYNC_LOG函数的具体用法?C++ CSYNC_LOG怎么用?C++ CSYNC_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CSYNC_LOG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: csync_statedb_close
int csync_statedb_close(CSYNC *ctx) {
int rc = 0;
if (!ctx) {
return -1;
}
/* deallocate query resources */
if( ctx->statedb.by_fileid_stmt ) {
sqlite3_finalize(ctx->statedb.by_fileid_stmt);
ctx->statedb.by_fileid_stmt = NULL;
}
if( ctx->statedb.by_hash_stmt ) {
sqlite3_finalize(ctx->statedb.by_hash_stmt);
ctx->statedb.by_hash_stmt = NULL;
}
if( ctx->statedb.by_inode_stmt) {
sqlite3_finalize(ctx->statedb.by_inode_stmt);
ctx->statedb.by_inode_stmt = NULL;
}
ctx->statedb.lastReturnValue = SQLITE_OK;
int sr = sqlite3_close(ctx->statedb.db);
CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "sqlite3_close=%d", sr);
ctx->statedb.db = 0;
return rc;
}
开发者ID:JamesFmoran,项目名称:client,代码行数:30,代码来源:csync_statedb.c
示例2: sqlite_profile
static void sqlite_profile( void *x, const char* sql, sqlite3_uint64 time)
{
(void)x;
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
"_SQL_ %s: %llu", sql, time);
}
开发者ID:JamesFmoran,项目名称:client,代码行数:7,代码来源:csync_statedb.c
示例3: csync_commit
int csync_commit(CSYNC *ctx) {
int rc = 0;
if (ctx == NULL) {
return -1;
}
ctx->status_code = CSYNC_STATUS_OK;
if (ctx->statedb.db != NULL
&& csync_statedb_close(ctx) < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "ERR: closing of statedb failed.");
rc = -1;
}
ctx->statedb.db = NULL;
_csync_clean_ctx(ctx);
ctx->remote.read_from_db = 0;
ctx->read_remote_from_db = true;
ctx->db_is_empty = false;
/* Create new trees */
c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp);
c_rbtree_create(&ctx->remote.tree, _key_cmp, _data_cmp);
ctx->status = CSYNC_STATUS_INIT;
SAFE_FREE(ctx->error_string);
rc = 0;
return rc;
}
开发者ID:Hopebaytech,项目名称:client,代码行数:34,代码来源:csync.c
示例4: csync_destroy
int csync_destroy(CSYNC *ctx) {
int rc = 0;
if (ctx == NULL) {
errno = EBADF;
return -1;
}
ctx->status_code = CSYNC_STATUS_OK;
if (ctx->statedb.db != NULL
&& csync_statedb_close(ctx) < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "ERR: closing of statedb failed.");
rc = -1;
}
ctx->statedb.db = NULL;
_csync_clean_ctx(ctx);
SAFE_FREE(ctx->local.uri);
SAFE_FREE(ctx->remote.uri);
SAFE_FREE(ctx->error_string);
#ifdef WITH_ICONV
c_close_iconv();
#endif
SAFE_FREE(ctx);
return rc;
}
开发者ID:Hopebaytech,项目名称:client,代码行数:30,代码来源:csync.c
示例5: switch
csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) {
switch(ctx->replica) {
case REMOTE_REPLICA:
if(ctx->remote.read_from_db) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Read from db flag is true, should not!" );
}
return owncloud_opendir(name);
break;
case LOCAL_REPLICA:
return csync_vio_local_opendir(name);
break;
default:
CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica);
break;
}
return NULL;
}
开发者ID:Absolight,项目名称:mirall,代码行数:17,代码来源:csync_vio.c
示例6: _merge_and_write_statedb
static int _merge_and_write_statedb(CSYNC *ctx) {
struct timespec start, finish;
char errbuf[256] = {0};
int jwritten = 0;
int rc = 0;
/* if we have a statedb */
if (ctx->statedb.db != NULL) {
/* and we have successfully synchronized */
if (ctx->status >= CSYNC_STATUS_DONE) {
/* merge trees */
if (csync_merge_file_trees(ctx) < 0) {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Unable to merge trees: %s",
errbuf);
ctx->status_code = CSYNC_STATUS_MERGE_FILETREE_ERROR;
rc = -1;
} else {
csync_gettime(&start);
/* write the statedb to disk */
rc = csync_statedb_write(ctx, ctx->statedb.db);
if (rc == 0) {
jwritten = 1;
csync_gettime(&finish);
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
"Writing the statedb of %zu files to disk took %.2f seconds",
c_rbtree_size(ctx->local.tree), c_secdiff(finish, start));
} else {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Unable to write statedb: %s",
errbuf);
ctx->status_code = CSYNC_STATUS_STATEDB_WRITE_ERROR;
rc = -1;
}
}
}
rc = csync_statedb_close(ctx->statedb.file, ctx->statedb.db, jwritten);
ctx->statedb.db = NULL;
if (rc < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "ERR: closing of statedb failed.");
}
}
return rc;
}
开发者ID:gco,项目名称:csync,代码行数:45,代码来源:csync.c
示例7: fill_tree_from_db
static bool fill_tree_from_db(CSYNC *ctx, const char *uri)
{
const char *path = NULL;
if( strlen(uri) < strlen(ctx->remote.uri)+1) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "name does not contain remote uri!");
return false;
}
path = uri + strlen(ctx->remote.uri)+1;
if( csync_statedb_get_below_path(ctx, path) < 0 ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "StateDB could not be read!");
return false;
}
return true;
}
开发者ID:etiess,项目名称:mirall,代码行数:18,代码来源:csync_update.c
示例8: csync_vio_set_file_id
void csync_vio_set_file_id( char* dst, const char *src ) {
if( src && dst ) {
if( strlen(src) > FILE_ID_BUF_SIZE ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Ignoring file_id because it is too long: %s", src);
strcpy(dst, "");
} else {
strcpy(dst, src);
}
}
}
开发者ID:jturcotte,项目名称:owncloud-client,代码行数:10,代码来源:csync_vio_file_stat.c
示例9: csync_exclude_load
int csync_exclude_load(CSYNC *ctx, const char *fname) {
int fd = -1;
int i = 0;
int rc = -1;
off_t size;
char *buf = NULL;
char *entry = NULL;
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
fd = open(fname, O_RDONLY);
if (fd < 0) {
return -1;
}
size = lseek(fd, 0, SEEK_END);
if (size < 0) {
rc = -1;
goto out;
}
lseek(fd, 0, SEEK_SET);
if (size == 0) {
rc = 0;
goto out;
}
buf = c_malloc(size);
if (read(fd, buf, size) != size) {
rc = -1;
goto out;
}
close(fd);
/* FIXME: Don't add duplicates */
entry = buf;
for (i = 0; i < size; i++) {
if (buf[i] == '\n') {
if (entry != buf + i) {
buf[i] = '\0';
if (*entry != '#' || *entry == '\n') {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Adding entry: %s", entry);
_csync_exclude_add(ctx, entry);
}
}
entry = buf + i + 1;
}
}
SAFE_FREE(buf);
rc = 0;
out:
SAFE_FREE(buf);
close(fd);
return rc;
}
开发者ID:valarauco,项目名称:galletica,代码行数:55,代码来源:csync_exclude.c
示例10: _csync_file_stat_from_metadata_table
// This funciton parses a line from the metadata table into the given csync_file_stat
// structure which it is also allocating.
// Note that this function calls laso sqlite3_step to actually get the info from db and
// returns the sqlite return type.
static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3_stmt *stmt )
{
int rc = SQLITE_ERROR;
int column_count;
int len;
if( ! stmt ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Fatal: Statement is NULL.");
return SQLITE_ERROR;
}
column_count = sqlite3_column_count(stmt);
rc = sqlite3_step(stmt);
if( rc == SQLITE_ROW ) {
if(column_count > 7) {
const char *name;
/* phash, pathlen, path, inode, uid, gid, mode, modtime */
len = sqlite3_column_int(stmt, 1);
*st = c_malloc(sizeof(csync_file_stat_t) + len + 1);
if (*st == NULL) {
return SQLITE_NOMEM;
}
/* clear the whole structure */
ZERO_STRUCTP(*st);
/* The query suceeded so use the phash we pass to the function. */
(*st)->phash = sqlite3_column_int64(stmt, 0);
(*st)->pathlen = sqlite3_column_int(stmt, 1);
name = (const char*) sqlite3_column_text(stmt, 2);
memcpy((*st)->path, (len ? name : ""), len + 1);
(*st)->inode = sqlite3_column_int64(stmt,3);
(*st)->uid = sqlite3_column_int(stmt, 4);
(*st)->gid = sqlite3_column_int(stmt, 5);
(*st)->mode = sqlite3_column_int(stmt, 6);
(*st)->modtime = strtoul((char*)sqlite3_column_text(stmt, 7), NULL, 10);
if(*st && column_count > 8 ) {
(*st)->type = sqlite3_column_int(stmt, 8);
}
if(column_count > 9 && sqlite3_column_text(stmt, 9)) {
(*st)->etag = c_strdup( (char*) sqlite3_column_text(stmt, 9) );
}
if(column_count > 10 && sqlite3_column_text(stmt,10)) {
csync_vio_set_file_id((*st)->file_id, (char*) sqlite3_column_text(stmt, 10));
}
}
}
return rc;
}
开发者ID:DeepDiver1975,项目名称:mirall,代码行数:58,代码来源:csync_statedb.c
示例11: _csync_propagation_cleanup
static int _csync_propagation_cleanup(CSYNC *ctx) {
c_list_t *list = NULL;
c_list_t *walk = NULL;
char *uri = NULL;
char *dir = NULL;
switch (ctx->current) {
case LOCAL_REPLICA:
list = ctx->local.list;
uri = ctx->local.uri;
break;
case REMOTE_REPLICA:
list = ctx->remote.list;
uri = ctx->remote.uri;
break;
default:
break;
}
if (list == NULL) {
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
return 0;
}
list = c_list_sort(list, _csync_cleanup_cmp);
if (list == NULL) {
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
return -1;
}
for (walk = c_list_last(list); walk != NULL; walk = c_list_prev(walk)) {
csync_file_stat_t *st = NULL;
st = (csync_file_stat_t *) walk->data;
if (asprintf(&dir, "%s/%s", uri, st->path) < 0) {
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
return -1;
}
if (csync_vio_rmdir(ctx, dir) < 0) {
/* Write it back to statedb, that we try to delete it next time. */
st->instruction = CSYNC_INSTRUCTION_NONE;
} else {
st->instruction = CSYNC_INSTRUCTION_DELETED;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "CLEANUP dir: %s", dir);
SAFE_FREE(dir);
}
return 0;
}
开发者ID:OpenDataSpace,项目名称:ocsync,代码行数:54,代码来源:csync_propagate.c
示例12: csync_vio_stat
int csync_vio_stat(CSYNC *ctx, const char *uri, csync_vio_file_stat_t *buf) {
int rc = -1;
switch(ctx->replica) {
case REMOTE_REPLICA:
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "ERROR: Cannot call remote stat, not implemented");
assert(ctx->replica != REMOTE_REPLICA);
break;
case LOCAL_REPLICA:
rc = csync_vio_local_stat(uri, buf);
if (rc < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Local stat failed, errno %d for %s", errno, uri);
}
break;
default:
break;
}
return rc;
}
开发者ID:jturcotte,项目名称:owncloud-client,代码行数:20,代码来源:csync_vio.c
示例13: switch
csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name) {
switch(ctx->replica) {
case REMOTE_REPLICA:
if(ctx->remote.read_from_db) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Read from db flag is true, should not!" );
}
return ctx->callbacks.remote_opendir_hook(name, ctx->callbacks.vio_userdata);
break;
case LOCAL_REPLICA:
if( ctx->callbacks.update_callback ) {
ctx->callbacks.update_callback(ctx->replica, name, ctx->callbacks.update_callback_userdata);
}
return csync_vio_local_opendir(name);
break;
default:
CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica);
break;
}
return NULL;
}
开发者ID:jturcotte,项目名称:owncloud-client,代码行数:20,代码来源:csync_vio.c
示例14: _csync_config_copy_default
static int _csync_config_copy_default (const char *config) {
int rc = 0;
#ifdef _WIN32
/* For win32, try to copy the conf file from the directory from where the app was started. */
mbchar_t tcharbuf[MAX_PATH+1];
char *buf;
int len = 0;
/* Get the path from where the application was started */
len = GetModuleFileNameW(NULL, tcharbuf, MAX_PATH);
if(len== 0) {
rc = -1;
} else {
char *last_bslash;
buf = c_utf8_from_locale(tcharbuf);
/* cut the trailing filename off */
if ((last_bslash = strrchr(buf, '\\')) != NULL) {
*last_bslash='\0';
}
strncat(buf, "\\" CSYNC_CONF_FILE, MAX_PATH);
if(c_copy(buf, config, 0644) < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Could not copy /%s to %s", buf, config );
rc = -1;
}
c_free_locale_string(buf);
}
#else
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Copy %s/config/%s to %s", SYSCONFDIR,
CSYNC_CONF_FILE, config);
if (c_copy(SYSCONFDIR "/ocsync/" CSYNC_CONF_FILE, config, 0644) < 0) {
if (c_copy(BINARYDIR "/config/" CSYNC_CONF_FILE, config, 0644) < 0) {
rc = -1;
}
}
#endif
return rc;
}
开发者ID:alexta901,项目名称:mirall,代码行数:41,代码来源:csync_config.c
示例15: SQLITE_BUSY_HANDLED
csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
const char *file_id ) {
csync_file_stat_t *st = NULL;
int rc = 0;
if (!file_id) {
return 0;
}
if (c_streq(file_id, "")) {
return 0;
}
if( !ctx || ctx->db_is_empty ) {
return NULL;
}
if( ctx->statedb.by_fileid_stmt == NULL ) {
const char *query = "SELECT * FROM metadata WHERE fileid=?1";
SQLITE_BUSY_HANDLED(sqlite3_prepare_v2(ctx->statedb.db, query, strlen(query), &ctx->statedb.by_fileid_stmt, NULL));
ctx->statedb.lastReturnValue = rc;
if( rc != SQLITE_OK ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for file id query.");
return NULL;
}
}
/* bind the query value */
sqlite3_bind_text(ctx->statedb.by_fileid_stmt, 1, file_id, -1, SQLITE_STATIC);
rc = _csync_file_stat_from_metadata_table(&st, ctx->statedb.by_fileid_stmt);
ctx->statedb.lastReturnValue = rc;
if( !(rc == SQLITE_ROW || rc == SQLITE_DONE) ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata: %d!", rc);
}
// clear the resources used by the statement.
sqlite3_reset(ctx->statedb.by_fileid_stmt);
return st;
}
开发者ID:rajeshpillai,项目名称:client,代码行数:40,代码来源:csync_statedb.c
示例16: _csync_propagation_file_visitor
static int _csync_propagation_file_visitor(void *obj, void *data) {
csync_file_stat_t *st = NULL;
CSYNC *ctx = NULL;
st = (csync_file_stat_t *) obj;
ctx = (CSYNC *) data;
switch(st->type) {
case CSYNC_FTW_TYPE_SLINK:
break;
case CSYNC_FTW_TYPE_FILE:
switch (st->instruction) {
case CSYNC_INSTRUCTION_NEW:
if (_csync_new_file(ctx, st) < 0) {
goto err;
}
break;
case CSYNC_INSTRUCTION_SYNC:
if (_csync_sync_file(ctx, st) < 0) {
goto err;
}
break;
case CSYNC_INSTRUCTION_REMOVE:
if (_csync_remove_file(ctx, st) < 0) {
goto err;
}
break;
case CSYNC_INSTRUCTION_CONFLICT:
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"case CSYNC_INSTRUCTION_CONFLICT: %s",st->path);
if (_csync_conflict_file(ctx, st) < 0) {
goto err;
}
break;
default:
break;
}
break;
case CSYNC_FTW_TYPE_DIR:
/*
* We have to walk over the files first. If you create or rename a file
* in a directory on unix. The modification time of the directory gets
* changed.
*/
break;
default:
break;
}
return 0;
err:
return -1;
}
开发者ID:brunobg,项目名称:csync,代码行数:52,代码来源:csync_propagate.c
示例17: csync_file_locked_or_open
bool csync_file_locked_or_open( const char *dir, const char *fname) {
char *tmp_uri = NULL;
bool ret;
if (!csync_file_locked_or_open_ext) {
return false;
}
if (asprintf(&tmp_uri, "%s/%s", dir, fname) < 0) {
return -1;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "csync_file_locked_or_open %s", tmp_uri);
ret = csync_file_locked_or_open_ext(tmp_uri);
SAFE_FREE(tmp_uri);
return ret;
}
开发者ID:ArthurChiao,项目名称:client,代码行数:14,代码来源:csync_util.c
示例18: _csync_statedb_check
static int _csync_statedb_check(const char *statedb) {
int fd = -1;
char buf[BUF_SIZE] = {0};
sqlite3 *db = NULL;
/* check db version */
fd = open(statedb, O_RDONLY);
if (fd >= 0) {
if (read(fd, (void *) buf, (size_t) BUF_SIZE - 1) >= 0) {
buf[BUF_SIZE - 1] = '\0';
close(fd);
if (c_streq(buf, "SQLite format 3")) {
if (sqlite3_open(statedb, &db ) == SQLITE_OK) {
/* everything is fine */
sqlite3_close(db);
return 0;
} else {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "database corrupted, removing!");
unlink(statedb);
}
sqlite3_close(db);
} else {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite version mismatch");
unlink(statedb);
}
}
}
/* create database */
if (sqlite3_open(statedb, &db) == SQLITE_OK) {
sqlite3_close(db);
return 0;
}
sqlite3_close(db);
return -1;
}
开发者ID:MarkusLitz,项目名称:csync,代码行数:37,代码来源:csync_statedb.c
示例19: sqlite3_prepare_v2
/* caller must free the memory */
csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
uint64_t inode)
{
csync_file_stat_t *st = NULL;
int rc;
if (!inode) {
return NULL;
}
if( !ctx ) {
return NULL;
}
if( ctx->statedb.by_inode_stmt == NULL ) {
const char *inode_query = "SELECT * FROM metadata WHERE inode=?1";
rc = sqlite3_prepare_v2(ctx->statedb.db, inode_query, strlen(inode_query), &ctx->statedb.by_inode_stmt, NULL);
if( rc != SQLITE_OK ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Unable to create stmt for inode query.");
return NULL;
}
}
if( ctx->statedb.by_inode_stmt == NULL ) {
return NULL;
}
sqlite3_bind_int64(ctx->statedb.by_inode_stmt, 1, (long long signed int)inode);
if( _csync_file_stat_from_metadata_table(&st, ctx->statedb.by_inode_stmt) < 0 ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Could not get line from metadata by inode!");
}
sqlite3_reset(ctx->statedb.by_inode_stmt);
return st;
}
开发者ID:DeepDiver1975,项目名称:mirall,代码行数:38,代码来源:csync_statedb.c
示例20: csync_vio_closedir
int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) {
int rc = -1;
if (dhandle == NULL) {
errno = EBADF;
return -1;
}
switch(ctx->replica) {
case REMOTE_REPLICA:
if( ctx->remote.read_from_db ) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Remote ReadFromDb is true, should not!");
}
rc = owncloud_closedir(dhandle);
break;
case LOCAL_REPLICA:
rc = csync_vio_local_closedir(dhandle);
break;
default:
CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "Invalid replica (%d)", (int)ctx->replica);
break;
}
return rc;
}
开发者ID:Absolight,项目名称:mirall,代码行数:24,代码来源:csync_vio.c
注:本文中的CSYNC_LOG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论