move sql functions to psql.c

This commit is contained in:
Levi Neely 2025-03-15 10:07:17 +01:00
parent 2d9e9e03cf
commit f714a06048
37 changed files with 1629 additions and 1638 deletions

View File

@ -31,6 +31,7 @@
#include "plibs.h"
#include "pnetlibs.h"
#include "psys.h"
#include "psql.h"
#include <stdio.h>

View File

@ -32,6 +32,7 @@
#include "pfileops.h"
#include "plibs.h"
#include "pnetlibs.h"
#include "psql.h"
#include <stdio.h>

View File

@ -53,6 +53,7 @@
#include "prun.h"
#include "psys.h"
#include "ptask.h"
#include "psql.h"
#include <string.h>

View File

@ -70,6 +70,7 @@
#include "ptools.h"
#include "publiclinks.h"
#include "putil.h"
#include "psql.h"
#define PSYNC_SQL_DOWNLOAD \
"synctype&" NTO_STR(PSYNC_DOWNLOAD_ONLY) "=" NTO_STR(PSYNC_DOWNLOAD_ONLY)

View File

@ -48,6 +48,7 @@
#include "ptask.h"
#include "ptimer.h"
#include "pupload.h"
#include "psql.h"
#include "ppath.h"
#include "pfile.h"

View File

@ -33,6 +33,7 @@
#include "pdiff.h"
#include "pfoldersync.h"
#include "plibs.h"
#include "psql.h"
void pfileops_create_fldr(const binresult *meta) {
psync_sql_res *res;

View File

@ -43,6 +43,7 @@
#include "psys.h"
#include "ppath.h"
#include "pfile.h"
#include "psql.h"
#include <stddef.h>
#include <string.h>

View File

@ -28,11 +28,14 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <errno.h>
#include <fuse.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <stdatomic.h>
@ -59,15 +62,8 @@
#include "psys.h"
#include "ppath.h"
#include "ptimer.h"
#include "psql.h"
#include <errno.h>
#include <fuse.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef FUSE_STAT
#define FUSE_STAT stat

View File

@ -33,12 +33,6 @@
#include <errno.h>
#include <pthread.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include "pcryptofolder.h"
#include "pfile.h"
#include "pfscrypto.h"
@ -47,6 +41,7 @@
#include "ppath.h"
#include "prun.h"
#include "psys.h"
#include "psql.h"
// this is only for debug, adds needless checks of tree for local files
#if IS_DEBUG

View File

@ -29,12 +29,8 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <string.h>
#include "pcryptofolder.h"
#include "pfoldersync.h"
@ -43,7 +39,9 @@
#include "pfstasks.h"
#include "plibs.h"
#include "psys.h"
#include <string.h>
#include "pdbg.h"
#include "psql.h"
static PSYNC_THREAD int cryptoerr = 0;

View File

@ -35,12 +35,6 @@
#include <stdio.h>
#include <string.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include "pcache.h"
#include "pcryptofolder.h"
#include "putil.h"
@ -52,6 +46,7 @@
#include "ppathstatus.h"
#include "psettings.h"
#include "ptimer.h"
#include "psql.h"
typedef struct {

View File

@ -34,12 +34,6 @@
#include <string.h>
#include <pthread.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include "pcache.h"
#include "pdiff.h"
#include "pfile.h"
@ -59,6 +53,7 @@
#include "ptimer.h"
#include "pupload.h"
#include "putil.h"
#include "psql.h"
#include "pqevent.h"

View File

@ -31,15 +31,16 @@
#define FUSE_USE_VERSION 26
#include "pfsxattr.h"
#include "pfsfolder.h"
#include "pfstasks.h"
#include "plibs.h"
#include <errno.h>
#include <fuse.h>
#include <string.h>
#include "pfsxattr.h"
#include "pfsfolder.h"
#include "pfstasks.h"
#include "psql.h"
#include "plibs.h"
// needed by psync_fs_set_thread_name
extern PSYNC_THREAD const char *psync_thread_name;

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,6 @@ extern "C" {
#include "pstatus.h"
#include "pdbg.h"
#include <sqlite3.h>
#include <stdint.h>
#include <string.h>
@ -142,39 +141,7 @@ extern "C" {
#define psync_get_result_cell(res, row, col) \
(res)->data[(row) * (res)->cols + (col)]
typedef struct {
uint32_t type;
uint32_t length;
union {
uint64_t num;
int64_t snum;
const char *str;
double real;
};
} psync_variant;
typedef struct {
sqlite3_stmt *stmt;
const char *sql;
int column_count;
int locked;
psync_variant row[];
} psync_sql_res;
typedef struct {
uint32_t rows;
uint32_t cols;
uint64_t data[];
} psync_full_result_int;
typedef const uint64_t *psync_uint_row;
typedef const char *const *psync_str_row;
typedef const psync_variant *psync_variant_row;
typedef void (*psync_run_after_t)(void *);
typedef int (*psync_list_builder_sql_callback)(psync_list_builder_t *, void *, psync_variant_row);
typedef void (*psync_transaction_callback_t)(void *);
extern int psync_do_run;
extern int psync_recache_contacts;
@ -188,98 +155,6 @@ extern pthread_mutex_t psync_my_auth_mutex;
extern PSYNC_THREAD uint32_t psync_error;
extern uint16_t const *__hex_lookup;
int psync_sql_connect(const char *db) PSYNC_NONNULL(1);
int psync_sql_close();
int psync_sql_reopen(const char *path);
void psync_sql_checkpoint_lock();
void psync_sql_checkpoint_unlock();
#if IS_DEBUG
#define psync_sql_trylock() psync_sql_do_trylock(__FILE__, __LINE__)
#define psync_sql_lock() psync_sql_do_lock(__FILE__, __LINE__)
#define psync_sql_rdlock() psync_sql_do_rdlock(__FILE__, __LINE__)
#define psync_sql_statement(sql) psync_sql_do_statement(sql, __FILE__, __LINE__)
#define psync_sql_start_transaction() psync_sql_do_start_transaction(__FILE__, __LINE__)
#define psync_sql_query_nocache(sql) psync_sql_do_query_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query(sql) psync_sql_do_query(sql, __FILE__, __LINE__)
#define psync_sql_query_rdlock_nocache(sql) psync_sql_do_query_rdlock_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query_rdlock(sql) psync_sql_do_query_rdlock(sql, __FILE__, __LINE__)
#define psync_sql_query_nolock_nocache(sql) psync_sql_do_query_nolock_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query_nolock(sql) psync_sql_do_query_nolock(sql, __FILE__, __LINE__)
#define psync_sql_prep_statement_nocache(sql) psync_sql_do_prep_statement_nocache(sql, __FILE__, __LINE__)
#define psync_sql_prep_statement(sql) psync_sql_do_prep_statement(sql, __FILE__, __LINE__)
int psync_sql_do_trylock(const char *file, unsigned line);
void psync_sql_do_lock(const char *file, unsigned line);
void psync_sql_do_rdlock(const char *file, unsigned line);
int psync_sql_do_statement(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
int psync_sql_do_start_transaction(const char *file, unsigned line);
psync_sql_res *psync_sql_do_query_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_rdlock_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_rdlock(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_nolock_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_nolock(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_prep_statement_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_prep_statement(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
void psync_sql_dump_locks();
#else
int psync_sql_trylock();
void psync_sql_lock();
void psync_sql_rdlock();
int psync_sql_statement(const char *sql) PSYNC_NONNULL(1);
int psync_sql_start_transaction();
psync_sql_res *psync_sql_query_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_rdlock_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_rdlock(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_nolock(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_nolock_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_prep_statement(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_prep_statement_nocache(const char *sql) PSYNC_NONNULL(1);
#endif
void psync_sql_unlock();
void psync_sql_rdunlock();
int psync_sql_has_waiters();
int psync_sql_isrdlocked();
int psync_sql_islocked();
int psync_sql_tryupgradelock();
int psync_sql_sync();
int psync_sql_commit_transaction();
int psync_sql_rollback_transaction();
void psync_sql_transation_add_callbacks(psync_transaction_callback_t commit_callback, psync_transaction_callback_t rollback_callback, void *ptr);
char *psync_sql_cellstr(const char *sql) PSYNC_NONNULL(1);
int64_t psync_sql_cellint(const char *sql, int64_t dflt) PSYNC_NONNULL(1);
char **psync_sql_rowstr(const char *sql) PSYNC_NONNULL(1);
psync_variant *psync_sql_row(const char *sql) PSYNC_NONNULL(1);
int psync_sql_reset(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run_free(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run_free_nocache(psync_sql_res *res) PSYNC_NONNULL(1);
void psync_sql_bind_uint(psync_sql_res *res, int n, uint64_t val) PSYNC_NONNULL(1);
void psync_sql_bind_int(psync_sql_res *res, int n, int64_t val) PSYNC_NONNULL(1);
void psync_sql_bind_double(psync_sql_res *res, int n, double val) PSYNC_NONNULL(1);
void psync_sql_bind_string(psync_sql_res *res, int n, const char *str) PSYNC_NONNULL(1);
void psync_sql_bind_lstring(psync_sql_res *res, int n, const char *str, size_t len) PSYNC_NONNULL(1);
void psync_sql_bind_blob(psync_sql_res *res, int n, const char *str, size_t len) PSYNC_NONNULL(1);
void psync_sql_bind_null(psync_sql_res *res, int n) PSYNC_NONNULL(1);
void psync_sql_free_result(psync_sql_res *res) PSYNC_NONNULL(1);
void psync_sql_free_result_nocache(psync_sql_res *res) PSYNC_NONNULL(1);
psync_variant_row psync_sql_fetch_row(psync_sql_res *res) PSYNC_NONNULL(1);
psync_str_row psync_sql_fetch_rowstr(psync_sql_res *res) PSYNC_NONNULL(1);
psync_uint_row psync_sql_fetch_rowint(psync_sql_res *res) PSYNC_NONNULL(1);
psync_full_result_int *psync_sql_fetchall_int(psync_sql_res *res) PSYNC_NONNULL(1);
uint32_t psync_sql_affected_rows() PSYNC_PURE;
uint64_t psync_sql_insertid() PSYNC_PURE;
int psync_rename_conflicted_file(const char *path);
void psync_run_after_sec(psync_run_after_t run, void *ptr, uint32_t seconds);
@ -287,26 +162,8 @@ void psync_free_after_sec(void *ptr, uint32_t seconds);
int psync_match_pattern(const char *name, const char *pattern, size_t plen);
psync_list_builder_t *psync_list_builder_create(size_t element_size,
size_t offset);
void psync_list_bulder_add_sql(psync_list_builder_t *builder,
psync_sql_res *res,
psync_list_builder_sql_callback callback);
void *psync_list_bulder_add_element(psync_list_builder_t *builder);
void psync_list_add_string_offset(psync_list_builder_t *builder, size_t offset);
void psync_list_add_lstring_offset(psync_list_builder_t *builder, size_t offset,
size_t length);
void *psync_list_builder_finalize(psync_list_builder_t *builder);
void psync_pqsort(void *base, size_t cnt, size_t sort_first, size_t size, int (*compar)(const void *, const void *));
void psync_qpartition(void *base, size_t cnt, size_t sort_first, size_t size, int (*compar)(const void *, const void *));
void psync_try_free_memory();
uint64_t psync_err_number_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
const char *psync_err_string_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
const char *psync_lstring_expected(const char *file, const char *function, int unsigned line, const psync_variant *v, size_t *len) PSYNC_NONNULL(4, 5);
double psync_err_real_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
/* needs 12 characters of buffer space on top of the length of the prefix */
static inline void psync_get_string_id(char *dst, const char *prefix, uint64_t id) {

View File

@ -82,8 +82,6 @@ struct psync_list_builder_t_ {
struct psync_list_builder_t_;
typedef struct psync_list_builder_t_ psync_list_builder_t;
typedef int (*psync_list_compare)(const psync_list *, const psync_list *);
#define psync_list_init(l) \
@ -150,5 +148,10 @@ void psync_list_sort(psync_list *l, psync_list_compare cmp);
void psync_list_extract_repeating(psync_list *l1, psync_list *l2, psync_list *extracted1, psync_list *extracted2, psync_list_compare cmp);
uint32_t *psync_list_bulder_push_num(psync_list_builder_t *builder);
uint32_t psync_list_bulder_pop_num(psync_list_builder_t *builder);
psync_list_builder_t *psync_list_builder_create(size_t element_size, size_t offset);
void *psync_list_bulder_add_element(psync_list_builder_t *builder);
void psync_list_add_string_offset(psync_list_builder_t *builder, size_t offset);
void psync_list_add_lstring_offset(psync_list_builder_t *builder, size_t offset, size_t length);
void *psync_list_builder_finalize(psync_list_builder_t *builder);
#endif

View File

@ -45,6 +45,7 @@
#include "prun.h"
#include "plist.h"
#include "plocalscan.h"
#include "psql.h"
#define NOTIFY_MSG_ADD 0
#define NOTIFY_MSG_DEL 1

View File

@ -29,13 +29,9 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/sha256.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <ctype.h>
#include <string.h>
#include "pdevice.h"
#include "pfile.h"
@ -56,9 +52,8 @@
#include "pupload.h"
#include "ppath.h"
#include "putil.h"
#include "psql.h"
#include <ctype.h>
#include <string.h>
typedef struct {
psync_list list;

View File

@ -1,5 +1,7 @@
#include "pcompiler.h"
#include "plibs.h"
#include "psql.h"
#include "pdbg.h"
#include <sys/mman.h>
void *pmem_mmap(size_t size) {

View File

@ -49,6 +49,7 @@
#include "ppath.h"
#include "psys.h"
#include "ptree.h"
#include "psql.h"
#include "pfile.h"
// required by psync_send_debug

View File

@ -31,6 +31,7 @@
#include <errno.h>
#include <pthread.h>
#include <string.h>
#include "papi.h"
#include "pfile.h"
@ -47,7 +48,7 @@
#include "psys.h"
#include "ptimer.h"
#include "putil.h"
#include <string.h>
#include "psql.h"
#define P2P_ENCTYPE_RSA_AES 0

View File

@ -29,12 +29,10 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "pcache.h"
#include "pcrc32c.h"
@ -50,12 +48,9 @@
#include "psys.h"
#include "putil.h"
#include "pfile.h"
#include "pstatus.h"
#include "ptimer.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "psql.h"
#define CACHE_PAGES (PSYNC_FS_MEMORY_CACHE / PSYNC_FS_PAGE_SIZE)
#define CACHE_HASH (CACHE_PAGES / 2)

View File

@ -8,6 +8,7 @@
#include "plibs.h"
#include "ppath.h"
#include "psettings.h"
#include "psql.h"
char *ppath_default_db() {
char *pcdir, *dbp, *home, *oldp;

View File

@ -29,23 +29,19 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <string.h>
#include "pcryptofolder.h"
#include "pfoldersync.h"
#include "pfs.h"
#include "plibs.h"
#include "plist.h"
#include "ppathstatus.h"
#include "pstatus.h"
#include "ptask.h"
#include "ptree.h"
#include <string.h>
#include "psql.h"
#include "pfstasks.h"
#define PATH_CACHE_SIZE 512
#define PATH_HASH_SIZE 512

View File

@ -8,6 +8,7 @@
#include "ppath.h"
#include "prand.h"
#include "psettings.h"
#include "psql.h"
static void add_file(const char *fn, psync_lhash_ctx *hctx, size_t max) {
char buff[4096];

View File

@ -29,12 +29,9 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <ctype.h>
#include <string.h>
#include "pfs.h"
#include "plibs.h"
@ -44,8 +41,7 @@
#include "psettings.h"
#include "ppath.h"
#include "ptimer.h"
#include <ctype.h>
#include <string.h>
#include "psql.h"
typedef void (*setting_callback)();
typedef void (*filter_callback)(void *);

View File

@ -39,6 +39,7 @@
#include "psettings.h"
#include "psock.h"
#include "ptimer.h"
#include "psql.h"
#include "ptask.h"
#define PROXY_NONE 0

1395
pclsync/psql.c Normal file

File diff suppressed because it is too large Load Diff

152
pclsync/psql.h Normal file
View File

@ -0,0 +1,152 @@
// IMPORTANT: include pdbg.h before this file
#ifndef __PSQL_H
#define __PSQL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sqlite3.h>
#include <stddef.h>
#include <stdint.h>
#include "pcompiler.h"
#include "plist.h"
typedef struct {
uint32_t type;
uint32_t length;
union {
uint64_t num;
int64_t snum;
const char *str;
double real;
};
} psync_variant;
typedef struct {
sqlite3_stmt *stmt;
const char *sql;
int column_count;
int locked;
psync_variant row[];
} psync_sql_res;
typedef struct {
uint32_t rows;
uint32_t cols;
uint64_t data[];
} psync_full_result_int;
typedef const uint64_t *psync_uint_row;
typedef const char *const *psync_str_row;
typedef const psync_variant *psync_variant_row;
typedef int (*psync_list_builder_sql_callback)(psync_list_builder_t *, void *, psync_variant_row);
typedef void (*psync_transaction_callback_t)(void *);
int psync_sql_connect(const char *db) PSYNC_NONNULL(1);
int psync_sql_close();
int psync_sql_reopen(const char *path);
void psync_sql_checkpoint_lock();
void psync_sql_checkpoint_unlock();
#if IS_DEBUG
#define psync_sql_trylock() psync_sql_do_trylock(__FILE__, __LINE__)
#define psync_sql_lock() psync_sql_do_lock(__FILE__, __LINE__)
#define psync_sql_rdlock() psync_sql_do_rdlock(__FILE__, __LINE__)
#define psync_sql_statement(sql) psync_sql_do_statement(sql, __FILE__, __LINE__)
#define psync_sql_start_transaction() psync_sql_do_start_transaction(__FILE__, __LINE__)
#define psync_sql_query_nocache(sql) psync_sql_do_query_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query(sql) psync_sql_do_query(sql, __FILE__, __LINE__)
#define psync_sql_query_rdlock_nocache(sql) psync_sql_do_query_rdlock_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query_rdlock(sql) psync_sql_do_query_rdlock(sql, __FILE__, __LINE__)
#define psync_sql_query_nolock_nocache(sql) psync_sql_do_query_nolock_nocache(sql, __FILE__, __LINE__)
#define psync_sql_query_nolock(sql) psync_sql_do_query_nolock(sql, __FILE__, __LINE__)
#define psync_sql_prep_statement_nocache(sql) psync_sql_do_prep_statement_nocache(sql, __FILE__, __LINE__)
#define psync_sql_prep_statement(sql) psync_sql_do_prep_statement(sql, __FILE__, __LINE__)
int psync_sql_do_trylock(const char *file, unsigned line);
void psync_sql_do_lock(const char *file, unsigned line);
void psync_sql_do_rdlock(const char *file, unsigned line);
int psync_sql_do_statement(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
int psync_sql_do_start_transaction(const char *file, unsigned line);
psync_sql_res *psync_sql_do_query_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_rdlock_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_rdlock(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_nolock_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_query_nolock(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_prep_statement_nocache(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_do_prep_statement(const char *sql, const char *file, unsigned line) PSYNC_NONNULL(1);
void psync_sql_dump_locks();
#else
int psync_sql_trylock();
void psync_sql_lock();
void psync_sql_rdlock();
int psync_sql_statement(const char *sql) PSYNC_NONNULL(1);
int psync_sql_start_transaction();
psync_sql_res *psync_sql_query_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_rdlock_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_rdlock(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_nolock(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_query_nolock_nocache(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_prep_statement(const char *sql) PSYNC_NONNULL(1);
psync_sql_res *psync_sql_prep_statement_nocache(const char *sql) PSYNC_NONNULL(1);
#endif
void psync_sql_unlock();
void psync_sql_rdunlock();
int psync_sql_has_waiters();
int psync_sql_isrdlocked();
int psync_sql_islocked();
int psync_sql_tryupgradelock();
int psync_sql_sync();
int psync_sql_commit_transaction();
int psync_sql_rollback_transaction();
void psync_sql_transation_add_callbacks(psync_transaction_callback_t commit_callback, psync_transaction_callback_t rollback_callback, void *ptr);
char *psync_sql_cellstr(const char *sql) PSYNC_NONNULL(1);
int64_t psync_sql_cellint(const char *sql, int64_t dflt) PSYNC_NONNULL(1);
char **psync_sql_rowstr(const char *sql) PSYNC_NONNULL(1);
psync_variant *psync_sql_row(const char *sql) PSYNC_NONNULL(1);
int psync_sql_reset(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run_free(psync_sql_res *res) PSYNC_NONNULL(1);
int psync_sql_run_free_nocache(psync_sql_res *res) PSYNC_NONNULL(1);
void psync_sql_bind_uint(psync_sql_res *res, int n, uint64_t val) PSYNC_NONNULL(1);
void psync_sql_bind_int(psync_sql_res *res, int n, int64_t val) PSYNC_NONNULL(1);
void psync_sql_bind_double(psync_sql_res *res, int n, double val) PSYNC_NONNULL(1);
void psync_sql_bind_string(psync_sql_res *res, int n, const char *str) PSYNC_NONNULL(1);
void psync_sql_bind_lstring(psync_sql_res *res, int n, const char *str, size_t len) PSYNC_NONNULL(1);
void psync_sql_bind_blob(psync_sql_res *res, int n, const char *str, size_t len) PSYNC_NONNULL(1);
void psync_sql_bind_null(psync_sql_res *res, int n) PSYNC_NONNULL(1);
void psync_sql_free_result(psync_sql_res *res) PSYNC_NONNULL(1);
void psync_sql_free_result_nocache(psync_sql_res *res) PSYNC_NONNULL(1);
psync_variant_row psync_sql_fetch_row(psync_sql_res *res) PSYNC_NONNULL(1);
psync_str_row psync_sql_fetch_rowstr(psync_sql_res *res) PSYNC_NONNULL(1);
psync_uint_row psync_sql_fetch_rowint(psync_sql_res *res) PSYNC_NONNULL(1);
psync_full_result_int *psync_sql_fetchall_int(psync_sql_res *res) PSYNC_NONNULL(1);
uint32_t psync_sql_affected_rows() PSYNC_PURE;
uint64_t psync_sql_insertid() PSYNC_PURE;
void psync_list_bulder_add_sql(psync_list_builder_t *builder, psync_sql_res *res, psync_list_builder_sql_callback callback);
uint64_t psync_err_number_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
const char *psync_err_string_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
const char *psync_lstring_expected(const char *file, const char *function, int unsigned line, const psync_variant *v, size_t *len) PSYNC_NONNULL(4, 5);
double psync_err_real_expected(const char *file, const char *function, int unsigned line, const psync_variant *v) PSYNC_COLD;
void psync_try_free_memory();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -28,6 +28,8 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/
#include <stdarg.h>
#include <string.h>
#include "pfile.h"
#include "pstatus.h"
@ -37,8 +39,7 @@
#include "psettings.h"
#include "ptask.h"
#include "putil.h"
#include <stdarg.h>
#include <string.h>
#include "psql.h"
static uint32_t statuses[PSTATUS_NUM_STATUSES] = {
PSTATUS_INVALID, PSTATUS_ONLINE_OFFLINE,

View File

@ -29,13 +29,9 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <stddef.h>
#include <string.h>
#include "pdownload.h"
#include "pfile.h"
@ -50,7 +46,9 @@
#include "ptask.h"
#include "ptree.h"
#include "putil.h"
#include <string.h>
#include "pdbg.h"
#include "psql.h"
extern const unsigned char pfile_invalid_chars[];

View File

@ -35,12 +35,6 @@
#include <stddef.h>
#include <string.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include "papi.h"
#include "pbusinessaccount.h"
#include "pcache.h"
@ -83,6 +77,7 @@
#include "publiclinks.h"
#include "pupload.h"
#include "putil.h"
#include "psql.h"
// Variable containing UNIX time of the last backup file deleted event
time_t lastBupDelEventTime = 0;

View File

@ -3,7 +3,8 @@
#include <unistd.h>
#include <sys/resource.h>
#include "plibs.h"
#include "pdbg.h"
#include "psql.h"
#include "psys.h"
static uid_t psync_uid;

View File

@ -32,12 +32,6 @@
#include <errno.h>
#include <pthread.h>
#include <stddef.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include "papi.h"
@ -55,6 +49,7 @@
#include "ptask.h"
#include "ptree.h"
#include "pupload.h"
#include "psql.h"
#define get_len(t) (sizeof(t) - offsetof(t, request))

View File

@ -33,21 +33,20 @@
*/
#include <stdio.h>
#include "papi.h"
#include "plibs.h"
#include "pnetlibs.h"
#include "psettings.h"
#include "ptools.h"
#include "stdlib.h"
#include "string.h"
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "papi.h"
#include "plibs.h"
#include "pnetlibs.h"
#include "psettings.h"
#include "ptools.h"
#include "psql.h"
char *ptools_get_mac_addr() {
char buffer[128];

View File

@ -26,6 +26,9 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include "publiclinks.h"
#include "papi.h"
#include "pfsfolder.h"
@ -33,8 +36,7 @@
#include "pnetlibs.h"
#include "prun.h"
#include "ptimer.h"
#include <stdio.h>
#include <string.h>
#include "psql.h"
#define FOLDERID_ENTRY_SIZE 18

View File

@ -29,11 +29,6 @@
DAMAGE.
*/
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/pkcs5.h>
#include <mbedtls/ssl.h>
#include <pthread.h>
#include <stddef.h>
@ -57,6 +52,7 @@
#include "ptools.h"
#include "pupload.h"
#include "putil.h"
#include "psql.h"
extern const unsigned char pfile_invalid_chars[];