56static const char *
default_providers =
"Google|www.google.com|https://www.google.com/search?q=%s|https://www.google.com/favicon.ico|\n";
75 size_t *providers_size_out)
86 providersf = fopen(fname,
"r");
87 if (providersf == NULL) {
91 if (fseek(providersf, 0, SEEK_END) != 0) {
96 ftellsize = ftell(providersf);
103 if (fseek(providersf, 0, SEEK_SET) != 0) {
108 providersd = malloc(fsize + 1);
109 if (providersd == NULL) {
114 if (fread(providersd, 1, fsize, providersf) != fsize) {
119 providersd[fsize] = 0;
123 *providers_out = providersd;
124 *providers_size_out = fsize;
140 size_t providers_size,
142 size_t *providers_count)
146 char *nl = providersd;
151 nl = strchr(nl,
'\n');
162 providers = malloc(pcount *
sizeof(*providers));
163 if (providers == NULL) {
168 for (pidx = 0; pidx < pcount; pidx++) {
169 providers[pidx].
name = nl;
170 nl = strchr(nl,
'|');
179 nl = strchr(nl,
'|');
188 nl = strchr(nl,
'|');
196 providers[pidx].
ico = nl;
197 nl = strchr(nl,
'|');
206 nl = strchr(nl,
'\n');
216 *providers_out = providers;
217 *providers_count = pcount;
251 urlstr_len = strlen(searchstr) + strlen(eterm) + 1;
252 urlstro = urlstr = malloc(urlstr_len);
253 if (urlstr == NULL) {
259 for ( ; *searchstr != 0; searchstr++, urlstro++) {
260 *urlstro = *searchstr;
261 if ((*searchstr ==
'%') && (searchstr[1] ==
's')) {
263 memcpy(urlstro, eterm, strlen(eterm));
264 urlstro += strlen(eterm) - 1;
290 switch (event->
type) {
293 NSLOG(netsurf, INFO,
"icon '%s' retrieved",
300 NSLOG(netsurf, INFO,
"icon %s error: %s",
320 struct nsurl **url_out)
336 eterm = malloc(strlen(term) +
SLEN(
"https://") + 1);
340 sprintf(eterm,
"https://%s", term);
373 struct bitmap *ico_bitmap = NULL;
386 if ((ico_bitmap == NULL) &&
391 *bitmap_out = ico_bitmap;
400 struct bitmap *ico_bitmap = NULL;
428 if ((ico_bitmap == NULL) &&
474 switch (event->
type) {
477 NSLOG(netsurf, INFO,
"default icon '%s' retrieved",
489 NSLOG(netsurf, INFO,
"icon %s error: %s",
529 size_t providers_size;
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_DONE
content has finished processing
@ CONTENT_MSG_ERROR
error occurred
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out)
Generate a nsurl from a search term.
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
static nserror search_web_ico_callback(hlcache_handle *ico, const hlcache_event *event, void *pw)
callback for hlcache icon fetch events.
static const char * default_providers
nserror search_web_select_provider(const char *selection)
Change the currently selected web search provider.
static struct search_web_ctx_s search_web_ctx
static const char * default_search_icon_url
static nserror parse_providers(char *providersd, size_t providers_size, struct search_provider **providers_out, size_t *providers_count)
parse search providers from a memory block.
nserror search_web_finalise(void)
Finalise the web search operations freeing all resources.
static nserror default_ico_callback(hlcache_handle *ico, const hlcache_event *event, void *pw)
callback for hlcache icon fetch events.
static nserror make_search_nsurl(struct search_provider *provider, const char *term, nsurl **url_out)
create a url for a search provider and a term
ssize_t search_web_iterate_providers(ssize_t iter, const char **name)
Iterate the search providers, returning their names.
nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out)
obtain the current providers bitmap
static nserror read_providers(const char *fname, char **providers_out, size_t *providers_size_out)
Read providers file.
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_INIT_FAILED
Initialisation failed.
@ NSERROR_BAD_URL
Bad URL.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_BAD_SIZE
Bad size.
@ NSERROR_INVALID
Invalid data.
@ NSERROR_NOMEM
Memory exhaustion.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result)
Retrieve a high-level cache handle for an object.
High-level resource cache interface.
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
#define NSLOG(catname, level, logmsg, args...)
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
core web search facilities interface.
search_web_omni_flags
Flags which alter the behaviour of the omin search.
@ SEARCH_WEB_OMNI_SEARCHONLY
The search does not attempt to interpret the url as a url before using it as a search term.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
nserror(* provider_update)(const char *provider_name, struct bitmap *ico_bitmap)
called when the search provider details are updated.
content_msg type
Event type.
union content_msg_data data
Event data.
struct gui_search_web_table * search_web
Web search table.
hlcache_handle * ico_handle
< location of domain's favicon
char * ico
< such as "www.google.com?search=%s"
char * hostname
host address such as www.google.com
char * name
readable name such as 'google', 'yahoo', etc
struct search_provider * providers
hlcache_handle * default_ico_handle
struct content_msg_data::@99 errordata
CONTENT_MSG_ERROR - Error from content or underlying fetch.
const char * errormsg
The message.
nserror url_escape(const char *unescaped, bool sptoplus, const char *escexceptions, char **result)
Escape a string suitable for inclusion in an URL.
Interface to URL parsing and joining operations.
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.