00001 /* 00002 * libcsync -- a library to sync a directory with another 00003 * 00004 * Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 /** 00022 * @file csync_private.h 00023 * 00024 * @brief Private interface of csync 00025 * 00026 * @defgroup csyncstatedbInternals csync statedb internals 00027 * @ingroup csyncInternalAPI 00028 * 00029 * @{ 00030 */ 00031 00032 #ifndef _CSYNC_STATEDB_H 00033 #define _CSYNC_STATEDB_H 00034 00035 #include "c_lib.h" 00036 #include "csync_private.h" 00037 00038 void csync_set_statedb_exists(CSYNC *ctx, int val); 00039 00040 int csync_get_statedb_exists(CSYNC *ctx); 00041 00042 /** 00043 * @brief Load the statedb. 00044 * 00045 * This function tries to load the statedb. If it doesn't exists it creates 00046 * the sqlite3 database, but doesn't create the tables. This will be done when 00047 * csync gets destroyed. 00048 * 00049 * @param ctx The csync context. 00050 * @param statedb Path to the statedb file (sqlite3 db). 00051 * 00052 * @return 0 on success, less than 0 if an error occured with errno set. 00053 */ 00054 int csync_statedb_load(CSYNC *ctx, const char *statedb); 00055 00056 int csync_statedb_write(CSYNC *ctx); 00057 00058 int csync_statedb_close(CSYNC *ctx, const char *statedb, int jwritten); 00059 00060 csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash); 00061 00062 csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, ino_t inode); 00063 00064 /** 00065 * @brief A generic statedb query. 00066 * 00067 * @param ctx The csync context. 00068 * @param statement The SQL statement to execute 00069 * 00070 * @return A stringlist of the entries of a column. An emtpy stringlist if 00071 * nothing has been found. NULL on error. 00072 */ 00073 c_strlist_t *csync_statedb_query(CSYNC *ctx, const char *statement); 00074 00075 /** 00076 * @brief Insert function for the statedb. 00077 * 00078 * @param ctx The csync context. 00079 * @param statement The SQL statement to insert into the statedb. 00080 * 00081 * @return The rowid of the most recent INSERT on success, 0 if the query 00082 * wasn't successful. 00083 */ 00084 int csync_statedb_insert(CSYNC *ctx, const char *statement); 00085 00086 int csync_statedb_create_tables(CSYNC *ctx); 00087 00088 int csync_statedb_drop_tables(CSYNC *ctx); 00089 00090 int csync_statedb_insert_metadata(CSYNC *ctx); 00091 00092 /** 00093 * }@ 00094 */ 00095 #endif /* _CSYNC_STATEDB_H */ 00096 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */