doc
csync_statedb.h
Go to the documentation of this file.
1 /*
2  * libcsync -- a library to sync a directory with another
3  *
4  * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
5  * Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>wie
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file csync_private.h
24  *
25  * @brief Private interface of csync
26  *
27  * @defgroup csyncstatedbInternals csync statedb internals
28  * @ingroup csyncInternalAPI
29  *
30  * @{
31  */
32 
33 #ifndef _CSYNC_STATEDB_H
34 #define _CSYNC_STATEDB_H
35 
36 #include "c_lib.h"
37 #include "csync_private.h"
38 
39 void csync_set_statedb_exists(CSYNC *ctx, int val);
40 
42 
43 /**
44  * @brief Load the statedb.
45  *
46  * This function tries to load the statedb. If it doesn't exists it creates
47  * the sqlite3 database, but doesn't create the tables. This will be done when
48  * csync gets destroyed.
49  *
50  * @param ctx The csync context.
51  * @param statedb Path to the statedb file (sqlite3 db).
52  *
53  * @return 0 on success, less than 0 if an error occured with errno set.
54  */
55 int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
56 
57 int csync_statedb_write(CSYNC *ctx, sqlite3 *db);
58 
59 int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten);
60 
62 
64 
65 /**
66  * @brief A generic statedb query.
67  *
68  * @param ctx The csync context.
69  * @param statement The SQL statement to execute
70  *
71  * @return A stringlist of the entries of a column. An emtpy stringlist if
72  * nothing has been found. NULL on error.
73  */
74 c_strlist_t *csync_statedb_query(sqlite3 *db, const char *statement);
75 
76 /**
77  * @brief Insert function for the statedb.
78  *
79  * @param ctx The csync context.
80  * @param statement The SQL statement to insert into the statedb.
81  *
82  * @return The rowid of the most recent INSERT on success, 0 if the query
83  * wasn't successful.
84  */
85 int csync_statedb_insert(sqlite3 *db, const char *statement);
86 
87 int csync_statedb_create_tables(sqlite3 *db);
88 
89 int csync_statedb_drop_tables(sqlite3 *db);
90 
91 int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db);
92 
93 /**
94  * }@
95  */
96 #endif /* _CSYNC_STATEDB_H */
97 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb)
Load the statedb.
csync_file_stat_t * csync_statedb_get_stat_by_inode(sqlite3 *db, ino_t inode)
c_strlist_t * csync_statedb_query(sqlite3 *db, const char *statement)
A generic statedb query.
Private interface of csync.
ino_t inode
Definition: csync_private.h:37
int csync_statedb_write(CSYNC *ctx, sqlite3 *db)
Structure for a stringlist.
Definition: c_string.h:53
csync public structure
Definition: csync_private.h:89
uint64_t phash
Definition: csync_private.h:33
csync_file_stat_t * csync_statedb_get_stat_by_hash(sqlite3 *db, uint64_t phash)
int csync_statedb_insert(sqlite3 *db, const char *statement)
Insert function for the statedb.
void csync_set_statedb_exists(CSYNC *ctx, int val)
int csync_statedb_insert_metadata(CSYNC *ctx, sqlite3 *db)
int csync_statedb_close(const char *statedb, sqlite3 *db, int jwritten)
int csync_statedb_create_tables(sqlite3 *db)
int csync_get_statedb_exists(CSYNC *ctx)
int csync_statedb_drop_tables(sqlite3 *db)