ELinks 0.16.1.1
bookmarks.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "bfu/dialog.h"
#include "bfu/hierbox.h"
#include "bfu/listbox.h"
#include "bookmarks/backend/common.h"
#include "bookmarks/bookmarks.h"
#include "bookmarks/dialogs.h"
#include "config/home.h"
#include "config/options.h"
#include "intl/libintl.h"
#include "main/module.h"
#include "main/object.h"
#include "protocol/uri.h"
#include "session/task.h"
#include "terminal/tab.h"
#include "util/conv.h"
#include "util/hash.h"
#include "util/lists.h"
#include "util/memory.h"
#include "util/secsave.h"
#include "util/string.h"
Include dependency graph for bookmarks.c:

Macros

#define check_bookmark_cache(url)

Functions

static enum evhook_status bookmark_change_hook (va_list ap, void *data)
static enum evhook_status bookmark_write_hook (va_list ap, void *data)
static void bookmark_snapshot ()
static int change_hook_folder_state (struct session *ses, struct option *current, struct option *changed)
static void init_bookmarks (struct module *module)
static void free_bookmarks (struct bookmark list *bookmarks_list, struct listbox_item list *box_items)
static void done_bookmarks (struct module *module)
void read_bookmarks (void)
void write_bookmarks (void)
void bookmarks_set_dirty (void)
void bookmarks_unset_dirty (void)
int bookmarks_are_dirty (void)
static void done_bookmark (struct bookmark *bm)
void delete_bookmark (struct bookmark *bm)
static void delete_folder_by_name (const char *foldername)
 Deletes any bookmarks with no URLs (i.e., folders) and of which the title matches the given argument.
static struct bookmarkinit_bookmark (struct bookmark *root, const char *title, const char *url)
 Allocate and initialize a bookmark in the given folder.
static void add_bookmark_item_to_bookmarks (struct bookmark *bm, struct bookmark *root, int place)
struct bookmarkadd_bookmark (struct bookmark *root, int place, const char *title, const char *url)
 Add a bookmark to the bookmark list.
struct bookmarkadd_bookmark_cp (struct bookmark *root, int place, int codepage, const char *title, const char *url)
 Add a bookmark to the bookmark list.
int update_bookmark (struct bookmark *bm, int codepage, char *title, char *url)
struct bookmarkget_bookmark_by_name (struct bookmark *folder, char *title)
 Search for a bookmark with the given title.
struct bookmarkget_bookmark (char *url)
static void bookmark_terminal (struct terminal *term, struct bookmark *folder)
void bookmark_terminal_tabs (struct terminal *term, char *foldername)
 Create a bookmark for each document on the specified terminal, and a folder to contain those bookmarks.
static void bookmark_all_terminals (struct bookmark *folder)
char * get_auto_save_bookmark_foldername_utf8 (void)
void bookmark_auto_save_tabs (struct terminal *term)
void open_bookmark_folder (struct session *ses, char *foldername)
 Open all bookmarks from the named folder.

Variables

struct bookmark list bookmarks = { D_LIST_HEAD(bookmarks) }
static int bookmarks_dirty = 0
static struct hashbookmark_cache = NULL
static struct bookmarkbm_snapshot_last_folder
static union option_info bookmark_options_info []
struct event_hook_info bookmark_hooks []
struct module bookmarks_module

Macro Definition Documentation

◆ check_bookmark_cache

#define check_bookmark_cache ( url)
Value:
(bookmark_cache && (url) && *(url))
static struct hash * bookmark_cache
Definition bookmarks.c:40

Function Documentation

◆ add_bookmark()

struct bookmark * add_bookmark ( struct bookmark * root,
int place,
const char * title,
const char * url )

Add a bookmark to the bookmark list.

Parameters
rootThe folder in which to add the bookmark, or NULL to add it at top level.
place0 means add to the top. 1 means add to the bottom.
titleTitle of the bookmark. Must be in UTF-8 and not NULL. "-" means add a separator.
urlURL to which the bookmark will point. Must be in UTF-8. NULL or "" means add a bookmark folder.
Returns
the new bookmark, or NULL on error.
See also
add_bookmark_cp()

◆ add_bookmark_cp()

struct bookmark * add_bookmark_cp ( struct bookmark * root,
int place,
int codepage,
const char * title,
const char * url )

Add a bookmark to the bookmark list.

Parameters
rootThe folder in which to add the bookmark, or NULL to add it at top level.
place0 means add to the top. 1 means add to the bottom.
codepageCodepage of title and url.
titleTitle of the bookmark. Must not be NULL. "-" means add a separator.
urlURL to which the bookmark will point. NULL or "" means add a bookmark folder.
Returns
the new bookmark.
See also
add_bookmark()

◆ add_bookmark_item_to_bookmarks()

void add_bookmark_item_to_bookmarks ( struct bookmark * bm,
struct bookmark * root,
int place )
static

◆ bookmark_all_terminals()

void bookmark_all_terminals ( struct bookmark * folder)
static

◆ bookmark_auto_save_tabs()

void bookmark_auto_save_tabs ( struct terminal * term)

◆ bookmark_change_hook()

enum evhook_status bookmark_change_hook ( va_list ap,
void * data )
static

◆ bookmark_snapshot()

void bookmark_snapshot ( void )
static

◆ bookmark_terminal()

void bookmark_terminal ( struct terminal * term,
struct bookmark * folder )
static

◆ bookmark_terminal_tabs()

void bookmark_terminal_tabs ( struct terminal * term,
char * foldername )

Create a bookmark for each document on the specified terminal, and a folder to contain those bookmarks.

Parameters
termThe terminal whose open documents should be bookmarked.
foldernameThe name of the new bookmark folder, in UTF-8.

◆ bookmark_write_hook()

enum evhook_status bookmark_write_hook ( va_list ap,
void * data )
static

◆ bookmarks_are_dirty()

int bookmarks_are_dirty ( void )

◆ bookmarks_set_dirty()

void bookmarks_set_dirty ( void )

◆ bookmarks_unset_dirty()

void bookmarks_unset_dirty ( void )

◆ change_hook_folder_state()

int change_hook_folder_state ( struct session * ses,
struct option * current,
struct option * changed )
static

◆ delete_bookmark()

void delete_bookmark ( struct bookmark * bm)

◆ delete_folder_by_name()

void delete_folder_by_name ( const char * foldername)
static

Deletes any bookmarks with no URLs (i.e., folders) and of which the title matches the given argument.

Parameters
foldernameThe title of the folder, in UTF-8.

◆ done_bookmark()

void done_bookmark ( struct bookmark * bm)
static

◆ done_bookmarks()

void done_bookmarks ( struct module * module)
static

◆ free_bookmarks()

void free_bookmarks ( struct bookmark list * bookmarks_list,
struct listbox_item list * box_items )
static

◆ get_auto_save_bookmark_foldername_utf8()

char * get_auto_save_bookmark_foldername_utf8 ( void )

◆ get_bookmark()

struct bookmark * get_bookmark ( char * url)
Todo
Bug 1066: URLs in bookmark_cache should be UTF-8

◆ get_bookmark_by_name()

struct bookmark * get_bookmark_by_name ( struct bookmark * folder,
char * title )

Search for a bookmark with the given title.

The search does not recurse into subfolders.

Parameters
folderSearch in this folder. NULL means search in the root.
titleSearch for this title. Must be in UTF-8 and not NULL.
Returns
The bookmark, or NULL if not found.

◆ init_bookmark()

struct bookmark * init_bookmark ( struct bookmark * root,
const char * title,
const char * url )
static

Allocate and initialize a bookmark in the given folder.

This however does not set bookmark.box_item; use add_bookmark() for that.

Parameters
rootThe folder in which to add the bookmark, or NULL to add it at top level.
titleTitle of the bookmark. Must be in UTF-8 and not NULL. "-" means add a separator.
urlURL to which the bookmark will point. Must be in UTF-8. NULL or "" means add a bookmark folder.
Returns
the new bookmark, or NULL on error.

◆ init_bookmarks()

void init_bookmarks ( struct module * module)
static

◆ open_bookmark_folder()

void open_bookmark_folder ( struct session * ses,
char * foldername )

Open all bookmarks from the named folder.

Parameters
sesThe session in which to open the first bookmark. The other bookmarks of the folder open in new tabs on the same terminal.
foldernameThe name of the bookmark folder, in UTF-8.
Todo
Bug 1066: Tell the URI layer that bookmark->url is UTF-8.

◆ read_bookmarks()

void read_bookmarks ( void )

◆ update_bookmark()

int update_bookmark ( struct bookmark * bm,
int codepage,
char * title,
char * url )

◆ write_bookmarks()

void write_bookmarks ( void )

Variable Documentation

◆ bm_snapshot_last_folder

struct bookmark* bm_snapshot_last_folder
static

◆ bookmark_cache

struct hash* bookmark_cache = NULL
static

◆ bookmark_hooks

struct event_hook_info bookmark_hooks[]
Initial value:
= {
{ "bookmark-delete", 0, bookmark_change_hook, {NULL} },
{ "bookmark-move", 0, bookmark_change_hook, {NULL} },
{ "bookmark-update", 0, bookmark_change_hook, {NULL} },
{ "periodic-saving", 0, bookmark_write_hook, {NULL} },
}
static enum evhook_status bookmark_write_hook(va_list ap, void *data)
Definition bookmarks.c:112
static enum evhook_status bookmark_change_hook(va_list ap, void *data)
Definition bookmarks.c:99
#define NULL
Definition explodename.c:35
#define NULL_EVENT_HOOK_INFO
Definition event.h:88

◆ bookmark_options_info

union option_info bookmark_options_info[]
static

◆ bookmarks

struct bookmark list bookmarks = { D_LIST_HEAD(bookmarks) }

◆ bookmarks_dirty

int bookmarks_dirty = 0
static

◆ bookmarks_module

struct module bookmarks_module
Initial value:
N_("Bookmarks"),
)
static union option_info bookmark_options_info[]
Definition bookmarks.c:47
static void init_bookmarks(struct module *module)
Definition bookmarks.c:138
struct event_hook_info bookmark_hooks[]
Definition bookmarks.c:89
static void done_bookmarks(struct module *module)
Definition bookmarks.c:171
#define N_(msg)
Definition libintl.h:25
#define struct_module(name, options, hooks, submods, data, init, done)
Definition module.h:44