sync/sql_func.yml2
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 3102 50a03176b73f
child 3739 523fb9710660
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 // Copyleft (c) 2017, 2018, p≡p foundation
     5 
     6 // Written by Volker Birk
     7 
     8 
     9 // prepare SQL statement
    10 
    11 function "init_sql" {
    12     param "sql";
    13     ||
    14         sqlite3_stmt *_sql;
    15         int int_result = sqlite3_prepare_v2(session->db,
    16     ||
    17     indent(2); copy '$sql';
    18     ||
    19             , -1, &_sql, NULL);
    20         assert(int_result == SQLITE_OK);
    21         if (!(int_result == SQLITE_OK))
    22             return PEP_UNKNOWN_ERROR;
    23 
    24     ||
    25 }
    26 
    27 // exec_sql_* is returning _result
    28 
    29 function "exec_sql_int" {
    30     param "sql";
    31     call "init_sql" with "sql", "$sql";
    32     ||
    33         int _result = 0;
    34         int_result = sqlite3_step(_sql);
    35         assert(int_result == SQLITE_ROW);
    36         if (int_result == SQLITE_ROW)
    37             _result = sqlite3_column_int(_sql, 0);
    38         sqlite3_finalize(_sql);
    39         if (int_result != SQLITE_ROW)
    40             return PEP_UNKNOWN_ERROR;
    41 
    42     ||
    43 }
    44