csync_statedb.h

Go to the documentation of this file.
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  * vim: ft=c.doxygen ts=2 sw=2 et cindent
00021  */
00022 
00023 /**
00024  * @file csync_private.h
00025  *
00026  * @brief Private interface of csync
00027  *
00028  * @defgroup csyncstatedbInternals csync statedb internals
00029  * @ingroup csyncInternalAPI
00030  *
00031  * @{
00032  */
00033 
00034 #ifndef _CSYNC_STATEDB_H
00035 #define _CSYNC_STATEDB_H
00036 
00037 #include "c_lib.h"
00038 #include "csync_private.h"
00039 
00040 void csync_set_statedb_exists(CSYNC *ctx, int val);
00041 
00042 int csync_get_statedb_exists(CSYNC *ctx);
00043 
00044 /**
00045  * @brief Load the statedb.
00046  *
00047  * This function tries to load the statedb. If it doesn't exists it creates
00048  * the sqlite3 database, but doesn't create the tables. This will be done when
00049  * csync gets destroyed.
00050  *
00051  * @param ctx      The csync context.
00052  * @param statedb  Path to the statedb file (sqlite3 db).
00053  *
00054  * @return 0 on success, less than 0 if an error occured with errno set.
00055  */
00056 int csync_statedb_load(CSYNC *ctx, const char *statedb);
00057 
00058 int csync_statedb_write(CSYNC *ctx);
00059 
00060 int csync_statedb_close(CSYNC *ctx, const char *statedb, int jwritten);
00061 
00062 csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash);
00063 
00064 csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, ino_t inode);
00065 
00066 /**
00067  * @brief A generic statedb query.
00068  *
00069  * @param ctx        The csync context.
00070  * @param statement  The SQL statement to execute
00071  * 
00072  * @return   A stringlist of the entries of a column. An emtpy stringlist if
00073  *           nothing has been found. NULL on error.
00074  */
00075 c_strlist_t *csync_statedb_query(CSYNC *ctx, const char *statement);
00076 
00077 /**
00078  * @brief Insert function for the statedb.
00079  *
00080  * @param ctx        The csync context.
00081  * @param statement  The SQL statement to insert into the statedb.
00082  *
00083  * @return  The rowid of the most recent INSERT on success, 0 if the query
00084  *          wasn't successful.
00085  */
00086 int csync_statedb_insert(CSYNC *ctx, const char *statement);
00087 
00088 int csync_statedb_create_tables(CSYNC *ctx);
00089 
00090 int csync_statedb_drop_tables(CSYNC *ctx);
00091 
00092 int csync_statedb_insert_metadata(CSYNC *ctx);
00093 
00094 /**
00095  * }@
00096  */
00097 #endif /* _CSYNC_STATEDB_H */
00098 

Generated on Mon May 4 17:43:35 2009 for doc by  doxygen 1.5.6