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 
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, uint64_t inode);
00063 
00064 char *csync_statedb_get_uniqId(CSYNC *ctx, uint64_t jHash, csync_vio_file_stat_t *buf);
00065 
00066 /**
00067  * @brief Query all files metadata inside and below a path.
00068  * @param ctx        The csync context.
00069  * @param path       The path.
00070  *
00071  * This function queries all metadata of all files inside or below the
00072  * given path. The result is a linear string list with a multiple of 9
00073  * entries. For each result file there are 9 strings which are phash,
00074  * path, inode, uid, gid, mode, modtime, type and md5 (unique id).
00075  *
00076  * Note that not only the files in the given path are part of the result
00077  * but also the files in directories below the given path. Ie. if the
00078  * parameter path is /home/kf/test, we have /home/kf/test/file.txt in
00079  * the result but also /home/kf/test/homework/another_file.txt
00080  *
00081  * @return   A stringlist containing a multiple of 9 entries.
00082  */
00083 c_strlist_t *csync_statedb_get_below_path(CSYNC *ctx, const char *path);
00084 
00085 /**
00086  * @brief A generic statedb query.
00087  *
00088  * @param ctx        The csync context.
00089  * @param statement  The SQL statement to execute
00090  * 
00091  * @return   A stringlist of the entries of a column. An emtpy stringlist if
00092  *           nothing has been found. NULL on error.
00093  */
00094 c_strlist_t *csync_statedb_query(CSYNC *ctx, const char *statement);
00095 
00096 /**
00097  * @brief Insert function for the statedb.
00098  *
00099  * @param ctx        The csync context.
00100  * @param statement  The SQL statement to insert into the statedb.
00101  *
00102  * @return  The rowid of the most recent INSERT on success, 0 if the query
00103  *          wasn't successful.
00104  */
00105 int csync_statedb_insert(CSYNC *ctx, const char *statement);
00106 
00107 int csync_statedb_create_tables(CSYNC *ctx);
00108 
00109 int csync_statedb_drop_tables(CSYNC *ctx);
00110 
00111 int csync_statedb_insert_metadata(CSYNC *ctx);
00112 
00113 /**
00114  * }@
00115  */
00116 #endif /* _CSYNC_STATEDB_H */
00117 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */

Generated on Mon Aug 18 13:58:05 2014 for doc by  doxygen 1.5.6