From 41ae1a0f0d86d2fc19f333ee23889c11beb0a4dd Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 26 Oct 2018 16:00:29 +0300 Subject: Confort to pedantic std-c99 and update readme --- CMakeLists.txt | 17 ++-- README.html | 276 +++++++++++++++++++++++++++++++++++------------------ README.org | 89 +++++++++++++---- src/actionparser.c | 10 +- src/actionparser.h | 2 +- src/actions.c | 4 +- src/ck.c | 2 +- src/ckerrlog.c | 31 +++--- src/ckerrlog.h | 12 +-- src/cklist.c | 20 ++-- src/cklist.h | 16 ++-- src/ckutil.c | 2 +- src/confparser.c | 2 +- src/confparser.h | 1 + src/dblayer.c | 12 +-- 15 files changed, 314 insertions(+), 182 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3808c3c..c5c5620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,21 +14,20 @@ project(ck C) set(ck_MAJOR_VERSION 0) set(ck_MINOR_VERSION 7) -# c flags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +# Feature test macros +set(FEATURE_TEST_MACROS "-D_DEFAULT_SOURCE") +# Default C flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FEATURE_TEST_MACROS} -std=c99 -pedantic") +# Warnings for debug builds +set(C_WARNINGS "-Wall -Wextra -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith") # options -option(CK_ASAN "Build with asan") -option(CK_DEBUG "Build with debug symbols") +option(CK_DEBUG "Build with debug symbols, asan and warnings") option(CK_TESTS "Make the tests") option(CK_SHARED "Build with shared lib") -if(CK_ASAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") -endif() - if (CK_DEBUG) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_WARNINGS} -g3 -fsanitize=address") else(CK_DEBUG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") endif() diff --git a/README.html b/README.html index 7d71922..dc25609 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -232,35 +232,40 @@ for the JavaScript code in this tag.

Table of Contents

-
-

ck

-
+
+

ck

+

The Config Keeper

+ +

+Have you ever wondered: +

+
+

+"Jeez Luiz, how can I manage all my configs across my desktop and server?" +

+ +

+– You +

+
+ +

+or maybe: +

+
+

+"How can I possibly keep all my configs in sync across computers?" +

+ +

+– You again +

+
+ +

+ck is the solution you've been looking for all your life. +

+ +

+With it you can keep track of all the configs you cherish and love, +and store them neat and tidy in a folder you can later sync using +your favorite sync solution (git, nextcloud, rsync). You can even gift +your precious data to Google and use GDrive (not recommended!!). +

+ +

+After you create your local config db you can list them, edit them +and even search in them, all within the comforting hands of ck, your +faithful companion. +

+ +

+You can also use ck to store sensitive configurations (with passwords, etc) +and instruct it to save them in a different folder, so they won't be in the +same place with the normal ones (in the event you want to share your configs +with the rest of us). +

+
+ +
+

Technicalities

+
+

+Upon adding a config to ck, it moves it to the specified folder and adds a symbolic link +back where it came from (ln -s). +

+ +

+Make sure that the target program can read it's configuration from a symlink (the vast +majority should). +

-
-

build it

-
+
+

Download

+
+

+Go ahead and download ck and give it a try. It comes with a help sub-command +that explains any inquires you might have. +

+ +

+Grab the latest zip/tarball from the tag section in the repo and proceed to +the build section. +

+ +

+You can also read the manual down below. +

-
-

requirements

-
-
    -
  • clang (llvm) or gcc (gnu)
  • -
  • cmake
  • -
  • sqlite3-dev
  • -
-
-

compiler

-
-
-
> export CC=clang
-# or
-> export CC=gcc
-
+
+

build it

+
+
+

requirements

+
+
    +
  • cmake
  • +
  • sqlite3-dev
  • +
  • build tools (gcc/llvm, make…)
  • +
-
-

make

-
+
+

make && install

+

Use -DCMAKE_INSTALL_PREFIX when running cmake to change the install path.

@@ -330,22 +407,21 @@ Use -DCMAKE_INSTALL_PREFIX when running cmake to change the install
-
-

for devs

-
+
+

for devs

+

Please be kind to each other.

-
-

CMake options

-
+
+

CMake options

+

cmake accepts the following options:

-
option(CK_ASAN "Build with asan")
-option(CK_DEBUG "Build with debug symbols")
+
option(CK_DEBUG "Build with debug symbols, asan and warnings")
 option(CK_TESTS "Make the tests")
 option(CK_SHARED "Build with shared lib")
 
@@ -355,23 +431,37 @@ cmake accepts the following options: To use any one of them append it after the cmake command like so:

-
cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+
cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
 
+
+
+
+

compiler

+

-Just build with address sanitizer enabled like so: -llvm has better asan than gcc, so I use that. +Pick your favorite

+
+
> export CC=clang
+# or
+> export CC=gcc
+
+
+ +
# clone the repo
 > cd ~/code; git clone https://gitlab.com/grm-grm/ck
 # make a build directory and enter it
 > mkdir ~/ck_build; cd ~/ck_build;
 # run cmake
-> cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+> cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
 # run make
 > make
+# check ck
+> ./test-ck
 # run ck
 > ./ck
 
@@ -379,9 +469,9 @@ llvm has better asan than gcc, so I use that.
-
-

tests

-
+
+

tests

+

The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the tests/ directory @@ -390,9 +480,9 @@ under unit/ directory and test the code.

-
-

run tests

-
+
+

run tests

+

First make sure you build ck with the -DCK_TESTS=1 option. Then go to the build directory and type: @@ -404,9 +494,9 @@ go to the build directory and type:

-
-

test suite

-
+
+

test suite

+
$ ./test-ck -h
 ck test suite
@@ -424,9 +514,9 @@ flags:
 
-
-

manual

-
+
+

manual

+

ck's goal is to assist with the configuration file management. To that end it tries to provides a cli interface that is pretty straight-forward @@ -467,8 +557,8 @@ $ ck search "\(" -

ck configuration

-
+
+

ck configuration

+

ck uses sqlite to index the configuration files. The init -action creates a .ck directory (under $HOME) +action creates a .ck directory (under $HOME) in witch the ckrc and the ckdb reside. The first one contains the two directories described above while the other one is the sqlite db. @@ -517,13 +607,13 @@ $ ck -c /someplace/else ...

-
-

Actions

-
+
+

Actions

+
-
-

init

-
+
+

init

+

or i or -i

@@ -553,9 +643,9 @@ $ ck init /path_to/where_you_want/your_configs/to_be -

add

-
+
+

add

+

or a or -a

@@ -596,9 +686,9 @@ $ ck add program_name config_path [-s] [-p]
-
-

list

-
+
+

list

+

or ls or l or -l

@@ -661,9 +751,9 @@ $ ck -l ckconf
-
-

search

-
+
+

search

+

or grep or s or -s

@@ -712,9 +802,9 @@ $ for i ($(ck ls paths)) grep -E 'A|B' $
-
-

edit

-
+
+

edit

+

or e or -e

@@ -763,7 +853,7 @@ $ ck edit emacs accounts.el
-

Created: 2018-10-23 Tue 10:35

+

Created: 2018-10-26 Fri 16:01

Validate

diff --git a/README.org b/README.org index 2058b59..7d5e4d7 100644 --- a/README.org +++ b/README.org @@ -3,20 +3,62 @@ * ck *The Config Keeper* +Have you ever wondered: +#+BEGIN_QUOTE + "Jeez Luiz, how can I manage all my configs across my desktop and server?" + + -- You +#+END_QUOTE + +or maybe: +#+BEGIN_QUOTE + "How can I possibly keep all my configs in sync across computers?" + + -- You again +#+END_QUOTE + +*ck* is the solution you've been looking for all your life. + +With it you can keep track of all the configs you cherish and love, +and store them neat and tidy in a folder you can later sync using +your favorite sync solution (git, nextcloud, rsync). You can even gift +your precious data to Google and use GDrive (//not recommended!!//). + +After you create your local config db you can list them, edit them +and even search in them, all within the comforting hands of *ck*, your +faithful companion. + +You can also use *ck* to store sensitive configurations (with passwords, etc) +and instruct it to save them in a different folder, so they won't be in the +same place with the normal ones (in the event you want to share your configs +with the rest of us). + +** Technicalities +Upon adding a config to *ck*, it moves it to the specified folder and adds a symbolic link +back where it came from (=ln -s=). + +Make sure that the target program can read it's configuration from a symlink (the vast +majority should). + +** Download +Go ahead and download *ck* and give it a try. It comes with a help sub-command +that explains any inquires you might have. + +Grab the latest zip/tarball from the tag section in the [[https://ubuntos.dynu.net/git/ck][repo]] and proceed to +the [[#build-instructions][build]] section. + +You can also read the manual [[#manual][down below]]. + * build it + :PROPERTIES: + :CUSTOM_ID: build-instructions + :END: ** requirements -- clang (llvm) or gcc (gnu) - cmake - sqlite3-dev +- build tools (gcc/llvm, make...) -** compiler -#+BEGIN_SRC sh - > export CC=clang - # or - > export CC=gcc -#+END_SRC - -** make +** make && install Use =-DCMAKE_INSTALL_PREFIX= when running cmake to change the install path. #+BEGIN_SRC sh # clone the repo @@ -38,28 +80,36 @@ Please be [[https://www.gnu.org/philosophy/kind-communication.html][kind]] to ea ** CMake options cmake accepts the following options: #+BEGIN_SRC cmake - option(CK_ASAN "Build with asan") - option(CK_DEBUG "Build with debug symbols") + option(CK_DEBUG "Build with debug symbols, asan and warnings") option(CK_TESTS "Make the tests") option(CK_SHARED "Build with shared lib") #+END_SRC To use any one of them append it after the cmake command like so: #+BEGIN_SRC sh - cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck + cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck +#+END_SRC + +** compiler +Pick your favorite +#+BEGIN_SRC sh + > export CC=clang + # or + > export CC=gcc #+END_SRC -Just build with address sanitizer enabled like so: -llvm has better asan than gcc, so I use that. + #+BEGIN_SRC sh # clone the repo > cd ~/code; git clone https://gitlab.com/grm-grm/ck # make a build directory and enter it > mkdir ~/ck_build; cd ~/ck_build; # run cmake - > cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck + > cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck # run make > make + # check ck + > ./test-ck # run ck > ./ck #+END_SRC @@ -91,6 +141,9 @@ flags: -h, --help, * print this #+END_SRC * manual + :PROPERTIES: + :CUSTOM_ID: manual + :END: ck's goal is to assist with the configuration file management. To that end it tries to provides a cli interface that is pretty straight-forward and intuitive. @@ -125,15 +178,15 @@ Example usage: #+END_SRC The first command after typing *ck* is the action you wish to perform. Actions are -a very important concept of ck. With an action you can initialize *ck*, add/move/delete -configuration files to it, edit them, list them in various ways and search in their content. +a very important concept of ck. With an action you can initialize *ck*, add/delete +configuration files to/from it, edit them, list them in various ways and search in their content. Actions expect their arguments in the order specified below. This is done to reduce the amount of flags one has to pass to ck. ** ck configuration ck uses sqlite to index the configuration files. The init -action creates a *.ck* directory (under $HOME) +action creates a *.ck* directory (under =$HOME=) in witch the *ckrc* and the *ckdb* reside. The first one contains the two directories described above while the other one is the sqlite db. diff --git a/src/actionparser.c b/src/actionparser.c index 009ee2a..9954fbc 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -34,10 +34,10 @@ static int optNum; /* holds the list of the opts * as given by the user */ -static char **opts; +static const char **opts; /* points to the current token */ -static char *token; +static const char *token; /* the position to be read */ static int pos = 0; @@ -205,7 +205,7 @@ void determine_action(UserOpt *opt) { UserOpt make_empty_user_opt() { UserOpt opt; - opt.action = -1; + opt.action = CK_WRONG_ACTION; opt.err = PERR_NOERR; opt.confDir = NULL; opt.args = list_make_new(); @@ -252,7 +252,7 @@ int get_config(UserOpt *opt) { pos = pos - 1; token = opts[pos]; } - char * defaultConf = ".ck"; + char defaultConf[STR_S] = ".ck"; char * home = getenv("HOME"); opt->confDir = malloc(strlen(defaultConf) + 1 /* '/' */ + strlen(home) + 1); str_join_dirname_with_basename(opt->confDir, home, defaultConf); @@ -378,7 +378,7 @@ void print_parser_help() { report_help(); } -int parse_action(int argc, char* argv[], UserOpt *opt) { +int parse_action(int argc, const char **argv, UserOpt *opt) { /* make empty user opt */ *opt = make_empty_user_opt(); opts = argv; diff --git a/src/actionparser.h b/src/actionparser.h index 6fa6136..3735ea8 100644 --- a/src/actionparser.h +++ b/src/actionparser.h @@ -67,7 +67,7 @@ struct UserOptions { /* Parse cli args, fill UserOpt struct * and return the result enum */ -extern int parse_action(int argc, char* argv[], UserOpt *opt); +extern int parse_action(int argc, const char **argv, UserOpt *opt); extern CkAction parser_get_action(const char *name, char *actionName); extern void get_possible_action_strings(char *dest, CkAction ckAction); extern void free_user_opt(UserOpt *opt); diff --git a/src/actions.c b/src/actions.c index b887399..48a4066 100644 --- a/src/actions.c +++ b/src/actions.c @@ -230,10 +230,8 @@ int run_LIST(UserOpt *opt, Conf *conf) { return 1; } -FILE *popen(const char *command, const char *mode); -int pclose(FILE *stream); - int run_SEARCH(UserOpt *opt, Conf *conf) { + UNUSED(conf); if (system("which grep > /dev/null") != 0) { return 2; } diff --git a/src/ck.c b/src/ck.c index f35cc95..2de5e70 100644 --- a/src/ck.c +++ b/src/ck.c @@ -36,7 +36,7 @@ ERRLOG(main); -int main(int argc, char *argv[]) { +int main(int argc, const char **argv) { initialize_errlog(argc, argv); UserOpt opt; Conf conf = {.vc_dir = NULL, .scrt_dir = NULL}; diff --git a/src/ckerrlog.c b/src/ckerrlog.c index a023521..cfafb39 100644 --- a/src/ckerrlog.c +++ b/src/ckerrlog.c @@ -31,7 +31,7 @@ char *get_time() { return buf; } -void log_command(int argc, char* argv[]) { +void log_command(int argc,const char* argv[]) { char tmp[STR_L] = ""; for(int i = 0; i < argc; i++) { strcat(tmp, argv[i]); @@ -41,7 +41,8 @@ void log_command(int argc, char* argv[]) { } #define X(stream) \ - void add_ ## stream ## _with_delim(char *delim, char *txt, \ + void add_ ## stream ## _with_delim(const char *delim, \ + const char *txt, \ va_list args) { \ char tmp[STR_L]; \ vsprintf(tmp, txt, args); \ @@ -56,22 +57,22 @@ void log_command(int argc, char* argv[]) { CK_STREAMS #undef X -#define X(stream) \ - void ck## stream(char *txt, ...) { \ - va_list args; \ - va_start(args, txt); \ - add_## stream ##_with_delim("\n", txt, args); \ - va_end(args); \ +#define X(stream) \ + void ck## stream(const char *txt, ...) { \ + va_list args; \ + va_start(args, txt); \ + add_## stream ##_with_delim("\n", txt, args); \ + va_end(args); \ } CK_STREAMS #undef X -#define X(stream) \ - void ck## stream ##_with_delim(char *d, char *txt, ...) { \ - va_list args; \ - va_start(args, txt); \ - add_## stream ##_with_delim(d, txt, args); \ - va_end(args); \ +#define X(stream) \ + void ck## stream ##_with_delim(const char *d, const char *txt, ...) { \ + va_list args; \ + va_start(args, txt); \ + add_## stream ##_with_delim(d, txt, args); \ + va_end(args); \ } CK_STREAMS #undef X @@ -123,7 +124,7 @@ extern void errlog_set_verbose(int level) { } -void initialize_errlog(int argc, char* argv[]) { +void initialize_errlog(int argc, const char** argv) { #define X(stream) stream = NULL; CK_STREAMS #undef X diff --git a/src/ckerrlog.h b/src/ckerrlog.h index aa5840b..9d71458 100644 --- a/src/ckerrlog.h +++ b/src/ckerrlog.h @@ -48,17 +48,13 @@ X(logv) \ X(help) -extern void initialize_errlog(int argc, char* argv[]); +extern void initialize_errlog(int argc, const char** argv); extern void report_errlog(); extern void errlog_set_verbose(int level); -extern void ckerr(char *err, ...); -extern void cklog(char *log, ...); -extern void ckhelp(char *log, ...); - -#define X(stream) \ - extern void ck## stream(char *log, ...); \ - void ck## stream ##_with_delim(char *d, char *txt, ...); \ +#define X(stream) \ + extern void ck## stream(const char *log, ...); \ + void ck## stream ##_with_delim(const char *d,const char *txt, ...); \ void report_## stream(); CK_STREAMS #undef X diff --git a/src/cklist.c b/src/cklist.c index 2fdfa07..f255556 100644 --- a/src/cklist.c +++ b/src/cklist.c @@ -50,19 +50,13 @@ int list_next(cklist *ckl) { } char* list_get(cklist *ckl) { - if (ckl->pos == -1) { - return NULL; - } if (ckl->pos >= ckl->size) { return NULL; } return ckl->arr[ckl->pos]; } -char* list_get_at(cklist *ckl, int pos) { - if (ckl->pos == -1) { - return NULL; - } +char* list_get_at(cklist *ckl, unsigned int pos) { if (ckl->pos >= ckl->size || pos >= ckl->size) { return NULL; @@ -94,7 +88,7 @@ cklist* list_move(cklist *ckl) { return _ckl; } -cklist* list_copy_from(cklist *ckl, int index) { +cklist* list_copy_from(cklist *ckl,unsigned int index) { list_rewind(ckl); cklist *_ckl = list_make_new(); if (ckl->pos >= index) { @@ -109,7 +103,7 @@ cklist* list_copy_from(cklist *ckl, int index) { return _ckl; } -cklist* list_copy_until(cklist *ckl, int index) { +cklist* list_copy_until(cklist *ckl,unsigned int index) { list_rewind(ckl); cklist *_ckl = list_make_and_add(list_get(ckl)); while(list_next(ckl)) { @@ -121,7 +115,7 @@ cklist* list_copy_until(cklist *ckl, int index) { return _ckl; } -cklist* list_copy_part(cklist *ckl, int from, int until) { +cklist* list_copy_part(cklist *ckl,unsigned int from,unsigned int until) { list_rewind(ckl); cklist *_ckl = list_make_new(); if (ckl->pos >= from && ckl->pos < until) { @@ -185,7 +179,7 @@ void list_print_concat(cklist *ckl) { } } -int list_exists(cklist *ckl, char *str) { +int list_exists(cklist *ckl, const char *str) { if (ckl->size > 0) { list_rewind(ckl); do { @@ -197,12 +191,12 @@ int list_exists(cklist *ckl, char *str) { return 0; } -int list_size(cklist *ckl) { +unsigned int list_size(cklist *ckl) { return ckl->size; } void list_free(cklist *ckl) { - int i; + unsigned int i; for (i=0; isize; i++) { free(ckl->arr[i]); } diff --git a/src/cklist.h b/src/cklist.h index 3cf0f7c..dcc6763 100644 --- a/src/cklist.h +++ b/src/cklist.h @@ -16,8 +16,8 @@ #define CKLIST_H typedef struct cklist_st cklist; struct cklist_st { - int size; - int pos; + unsigned int size; + unsigned int pos; char **arr; }; @@ -28,9 +28,9 @@ extern void list_rewind(cklist *ckl); extern int list_next(cklist *ckl); extern char* list_get(cklist *ckl); -extern char* list_get_at(cklist *ckl, int pos); +extern char* list_get_at(cklist *ckl,unsigned int pos); -extern int list_size(cklist *ckl); +extern unsigned int list_size(cklist *ckl); /* rewinds */ extern cklist* list_duplicate(cklist *ckl); @@ -38,17 +38,17 @@ extern cklist* list_duplicate(cklist *ckl); extern cklist* list_move(cklist *ckl); /* rewinds * copy from index (>=) to the end */ -extern cklist* list_copy_from(cklist *ckl, int index); +extern cklist* list_copy_from(cklist *ckl,unsigned int index); /* rewinds * copy from the start until (<) index*/ -extern cklist* list_copy_until(cklist *ckl, int index); +extern cklist* list_copy_until(cklist *ckl,unsigned int index); /* rewinds * copy from (>=) until (<) */ -extern cklist* list_copy_part(cklist *ckl, int from, int until); +extern cklist* list_copy_part(cklist *ckl,unsigned int from,unsigned int until); /* return 1 if str exists in the list, 0 otherwise */ -extern int list_exists(cklist *ckl, char *str); +extern int list_exists(cklist *ckl, const char *str); /* rewinds */ extern void list_print_lisp(cklist *ckl); diff --git a/src/ckutil.c b/src/ckutil.c index b852f72..84eb43d 100644 --- a/src/ckutil.c +++ b/src/ckutil.c @@ -97,7 +97,7 @@ int util_move_file(const char *path, const char* dest) { struct stat st, newSt; fstat(srcFile, &st); - sendfile(destFile, srcFile, NULL, st.st_size); + sendfile(destFile, srcFile, NULL, (size_t)st.st_size); close(srcFile); fchmod(destFile, st.st_mode); diff --git a/src/confparser.c b/src/confparser.c index 6dea001..3a7c357 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -42,7 +42,7 @@ ConfVar match_variables(char *line, char matched[]) { } CONFIG_VARIABLES_TABLE #undef X - return -1; + return CV_WRONG_VAL; } void make_config_name(char * ret, const char *confPath) { diff --git a/src/confparser.h b/src/confparser.h index 94541c6..f4c52c3 100644 --- a/src/confparser.h +++ b/src/confparser.h @@ -24,6 +24,7 @@ enum ConfingVariables { CV_NO_VAL_OR_COMMENT, + CV_WRONG_VAL, #define X(var, str, name) CV_##var, CONFIG_VARIABLES_TABLE #undef X diff --git a/src/dblayer.c b/src/dblayer.c index 8703c1e..acdf339 100644 --- a/src/dblayer.c +++ b/src/dblayer.c @@ -41,7 +41,7 @@ int check_initialized_DB(sqlite3 *db) { dbh_form_query_select_all_tables(sql); sqlite3_stmt *stmt; - sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL); + sqlite3_prepare_v2(db, sql, (int)strlen(sql), &stmt, NULL); int program_table_ok, config_table_ok, rel_table_ok = 0; while (sqlite3_step(stmt) != SQLITE_DONE) { @@ -135,7 +135,7 @@ int get_next_valid_id_from_table(DB *db, const char* tableName) { if (rc != SQLITE_OK) { return -1; } - sqlite3_bind_text(stmt, 1, tableName, strlen(tableName), 0); + sqlite3_bind_text(stmt, 1, tableName, (int)strlen(tableName), 0); int id = 0; while (sqlite3_step(stmt) == SQLITE_ROW) { @@ -168,7 +168,7 @@ int insert_to_program_table(DB *db, const char *name) { return -1; } sqlite3_bind_int(stmt, 1, id); - sqlite3_bind_text(stmt, 2, name, strlen(name), 0); + sqlite3_bind_text(stmt, 2, name, (int)strlen(name), 0); if (sqlite3_step(stmt) != SQLITE_DONE) { PRINT_ERR("while excecuting insert to program sql."); db->error = SQL_ERR_SQLITE; @@ -196,7 +196,7 @@ int insert_to_config_table(DB *db, const char *path, const int secret, const int return -1; } sqlite3_bind_int(stmt, 1, id); - sqlite3_bind_text(stmt, 2, path, strlen(path), 0); + sqlite3_bind_text(stmt, 2, path, (int)strlen(path), 0); sqlite3_bind_int(stmt, 3, secret); sqlite3_bind_int(stmt, 4, prime); if (sqlite3_step(stmt) != SQLITE_DONE) { @@ -245,7 +245,7 @@ int get_program_id(DB *db, const char* name) { PRINT_ERR("Error while preparing get_program_id sql."); return -2; } - sqlite3_bind_text(stmt, 1, name, strlen(name), 0); + sqlite3_bind_text(stmt, 1, name, (int)strlen(name), 0); int id = -1; while (sqlite3_step(stmt) == SQLITE_ROW) { id = sqlite3_column_int(stmt, 0); @@ -274,7 +274,7 @@ int get_config_id(DB *db, const char* path) { PRINT_ERR("while preparing get_config_id sql."); return -2; } - sqlite3_bind_text(stmt, 1, path, strlen(path), 0); + sqlite3_bind_text(stmt, 1, path, (int)strlen(path), 0); int id = -1; while (sqlite3_step(stmt) == SQLITE_ROW) { id = sqlite3_column_int(stmt, 0); -- cgit v1.2.3