1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

[bookmarks] const char * in bookmarks_filename

This commit is contained in:
Witold Filipczyk 2022-01-31 15:32:24 +01:00
parent 192cb6f380
commit 6549fa09fe
4 changed files with 16 additions and 12 deletions

View File

@ -48,22 +48,25 @@ bookmarks_read(void)
int backend_num = get_opt_int("bookmarks.file_format", NULL);
struct bookmarks_backend *backend = bookmarks_backends[backend_num];
char *file_name;
const char *file_name_orig;
FILE *f;
if (!backend
|| !backend->read
|| !backend->filename) return;
file_name = backend->filename(0);
if (!file_name) return;
file_name_orig = backend->filename(0);
if (!file_name_orig) return;
if (elinks_home) {
file_name = straconcat(elinks_home, file_name,
file_name = straconcat(elinks_home, file_name_orig,
(char *) NULL);
if (!file_name) return;
f = fopen(file_name, "rb");
mem_free(file_name);
} else {
f = fopen(file_name_orig, "rb");
}
f = fopen(file_name, "rb");
if (elinks_home) mem_free(file_name);
if (!f) return;
backend->read(f);
@ -80,6 +83,7 @@ bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list)
struct bookmarks_backend *backend = bookmarks_backends[backend_num];
struct secure_save_info *ssi;
char *file_name;
const char *file_name_orig;
if (!bookmarks_are_dirty() && backend_num == loaded_backend_num) return;
if (!backend
@ -90,9 +94,9 @@ bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list)
/* We do this two-passes because we want backend to possibly decide to
* return NULL if it's not suitable to save the bookmarks (otherwise
* they would be just truncated to zero by secure_open()). */
file_name = backend->filename(1);
if (!file_name) return;
file_name = straconcat(elinks_home, file_name, (char *) NULL);
file_name_orig = backend->filename(1);
if (!file_name_orig) return;
file_name = straconcat(elinks_home, file_name_orig, (char *) NULL);
if (!file_name) return;
ssi = secure_open(file_name);

View File

@ -12,7 +12,7 @@ extern "C" {
struct bookmarks_backend {
/* Order matters here. --Zas. */
char *(*filename)(int);
const char *(*filename)(int);
void (*read)(FILE *);
void (*write)(struct secure_save_info *, LIST_OF(struct bookmark) *);
};

View File

@ -189,7 +189,7 @@ write_bookmarks_default(struct secure_save_info *ssi,
write_bookmarks_default_inner(&out, bookmarks_list);
}
static char *
static const char *
filename_bookmarks_default(int writing)
{
return BOOKMARKS_FILENAME;

View File

@ -60,7 +60,7 @@ struct read_bookmarks_xbel {
};
static void read_bookmarks_xbel(FILE *f);
static char * filename_bookmarks_xbel(int writing);
static const char * filename_bookmarks_xbel(int writing);
static int xbeltree_to_bookmarks_list(const struct read_bookmarks_xbel *preload,
struct tree_node *root,
struct bookmark *current_parent);
@ -165,7 +165,7 @@ write_bookmarks_xbel(struct secure_save_info *ssi,
secure_fputs(ssi, "\n</xbel>\n");
}
static char *
static const char *
filename_bookmarks_xbel(int writing)
{
if (writing && !readok) return NULL;