aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-09-22 12:58:22 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-09-22 12:58:22 +0300
commit405afc36e0929d887188be09a5886f79ff0ea1c4 (patch)
treef31d36ad4229f207e7e7bfbfe679516295e82952 /src/dblayer.c
parentfe7c216a75ad1a5890c329df73f1d5ab461a1257 (diff)
downloadck-405afc36e0929d887188be09a5886f79ff0ea1c4.tar.gz
ck-405afc36e0929d887188be09a5886f79ff0ea1c4.tar.bz2
ck-405afc36e0929d887188be09a5886f79ff0ea1c4.zip
Standarize error codes
Diffstat (limited to 'src/dblayer.c')
-rw-r--r--src/dblayer.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/dblayer.c b/src/dblayer.c
index 190cb05..dbd772e 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -356,34 +356,34 @@ int add_get_or_insert_program_to_db(DB *db, const char *name) {
return pid;
}
-int add_transaction_begin(DB *db, const AddOpt * const opt) {
+int add_transaction_try(DB *db, const AddOpt * const opt) {
__BEGIN_TRANSACTION__
int pid = add_get_or_insert_program_to_db(db, opt->progName);
if (db->error == SQL_ERR_SQLITE) {
PRINT_ERR("Could not insert program to db.\n");
- return 0;
+ return 1;
}
int cid = add_get_or_insert_config_to_db(db, pid, opt->confPath, opt->secret, opt->prime);
if (db->error == SQL_ERR_SQLITE) {
PRINT_ERR("Could not insert config to db.\n");
- return 0;
+ return 1;
}
else if (db->error == SQL_CONFIG_PATH_EXISTS) {
PRINT_ERR("This config already exists in the database.\n");
- return 0;
+ return 1;
}
else if (db->error == SQL_ERR_PRIMARY_REDEFINITION) {
PRINT_ERR("This program already has a primary config.\n");
- return 0;
+ return 1;
}
add_insert_relationship(db, pid, cid);
if (db->error == SQL_ERR_SQLITE) {
PRINT_ERR("rel update failed\n");
- return 0;
+ return 1;
}
__END_TRANSACTION__
- return 1;
+ return 0;
}
int edit_get_prime_config_from_program(DB *db, char *pName, char *ret, int *secret) {