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
12 static bool set_blob_data(bloblist_t* bloblist, char* blob, size_t size, const char* mime_type,
19 bloblist->mime_type = strdup(mime_type);
20 if (bloblist->mime_type == NULL) {
26 bloblist->filename = strdup(filename);
27 if (bloblist->filename == NULL) {
28 free(bloblist->mime_type);
31 /* Default behaviour, can be overwritten post-allocation with
32 set_blob_content_disposition */
33 if (strncmp(filename, "cid://", 6) == 0)
34 bloblist->disposition = PEP_CONTENT_DISP_INLINE;
38 bloblist->value = blob;
39 bloblist->size = size;
45 DYNAMIC_API bloblist_t *new_bloblist(char *blob, size_t size, const char *mime_type,
48 bloblist_t * bloblist = calloc(1, sizeof(bloblist_t));
53 if (!set_blob_data(bloblist, blob, size, mime_type, filename)) {
61 DYNAMIC_API void free_bloblist(bloblist_t *bloblist)
63 bloblist_t *curr = bloblist;
66 bloblist_t *next = curr->next;
67 if (curr->release_value)
68 curr->release_value(curr->value);
71 free(curr->mime_type);
78 DYNAMIC_API bloblist_t *bloblist_dup(const bloblist_t *src)
84 bloblist_t *bloblist = NULL;
87 char *blob2 = malloc(src->size);
92 memcpy(blob2, src->value, src->size);
94 bloblist = new_bloblist(blob2, src->size, src->mime_type, src->filename);
99 bloblist_t* src_curr = src->next;
100 bloblist_t** dst_curr_ptr = &bloblist->next;
104 blob2 = malloc(src_curr->size);
110 memcpy(blob2, src_curr->value, src_curr->size);
111 *dst_curr_ptr = new_bloblist(blob2, src_curr->size, src_curr->mime_type, src_curr->filename);
112 if (*dst_curr_ptr == NULL)
115 src_curr = src_curr->next;
116 dst_curr_ptr = &((*dst_curr_ptr)->next);
123 free_bloblist(bloblist);
127 DYNAMIC_API bloblist_t *bloblist_add(bloblist_t *bloblist, char *blob, size_t size,
128 const char *mime_type, const char *filename)
135 return new_bloblist(blob, size, mime_type, filename);
137 if (!bloblist->value) { // empty list
138 assert(!bloblist->next);
140 return NULL; // invalid list
142 if (!set_blob_data(bloblist, blob, size, mime_type, filename)) {
150 bloblist_t* list_curr = bloblist;
151 void (*release_value)(char *) = list_curr->release_value;
153 while (list_curr->next)
154 list_curr = list_curr->next;
156 list_curr->next = new_bloblist(blob, size, mime_type, filename);
157 list_curr->release_value = release_value;
159 assert(list_curr->next);
160 if (!list_curr->next)
163 return list_curr->next;
166 DYNAMIC_API int bloblist_length(const bloblist_t *bloblist)
170 for (const bloblist_t *_bl = bloblist; _bl && _bl->value; _bl = _bl->next)
176 DYNAMIC_API void set_blob_disposition(bloblist_t* blob,
177 content_disposition_type disposition)
180 blob->disposition = disposition;