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
4 #include "pEp_internal.h"
5 #include "resource_id.h"
7 pEp_rid_list_t* new_rid_node(pEp_resource_id_type type, const char* resource) {
12 pEp_rid_list_t* retval = (pEp_rid_list_t*)calloc(1, sizeof(pEp_rid_list_t));
17 retval->rid_type = type;
18 retval->rid = strdup(resource);
27 void free_rid_list(pEp_rid_list_t* list) {
29 pEp_rid_list_t* nextptr = list->next;
36 const char* get_resource_ptr_noown(const char* uri) {
37 char* uri_delim = strstr(uri, "://");
44 char* get_resource(char* uri) {
45 const char* resource_ptr = get_resource_ptr_noown(uri);
46 char* resource_str = NULL;
48 resource_str = strdup(resource_ptr);
52 bool is_file_uri(char* str) {
53 return(!str ? false : strncmp(str, "file://", 7) == 0);
56 bool is_cid_uri(const char* str) {
57 return(!str ? false : strncmp(str, "cid://", 6) == 0);
60 pEp_rid_list_t* parse_uri(const char* uri) {
63 pEp_resource_id_type type = (is_cid_uri(uri) ? PEP_RID_CID : PEP_RID_FILENAME);
64 const char* resource = get_resource_ptr_noown(uri);
65 return new_rid_node(type, resource);
68 char* build_uri(const char* uri_prefix, const char* resource) {
69 if (!uri_prefix || !resource)
71 const char* delim = "://";
72 const int delim_len = 3;
73 int prefix_len = strlen(uri_prefix);
74 int resource_len = strlen(resource);
75 int retval_len = prefix_len + delim_len + resource_len;
77 char* retval = calloc(1, retval_len + 1);
78 strlcpy(retval, uri_prefix, retval_len + 1);
79 strlcat(retval, delim, retval_len + 1);
80 strlcat(retval, resource, retval_len + 1);