diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 157646488..dc12170c1 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -464,6 +464,21 @@ default_ico_callback(hlcache_handle *ico, return NSERROR_OK; } +/* exported interface documented in desktop/searchweb.h */ +ssize_t search_web_iterate_providers(ssize_t from, const char **name) +{ + if (from < 0) + return -1; + + if ((size_t)from >= search_web_ctx.providers_count) + return -1; + + *name = search_web_ctx.providers[from].name; + + return from + 1; +} + + /* exported interface documented in desktop/searchweb.h */ nserror search_web_init(const char *provider_fname) { diff --git a/desktop/searchweb.h b/desktop/searchweb.h index 612e9bdd1..b3b3902cf 100644 --- a/desktop/searchweb.h +++ b/desktop/searchweb.h @@ -78,6 +78,30 @@ nserror search_web_omni(const char *term, enum search_web_omni_flags flags, stru */ nserror search_web_select_provider(int selection); + +/** + * Iterate the search providers, returning their names. + * + * \param from Index to start iteration from. Use 0 to begin iteration. + * Use the value returned from search_web_iterate_providers to + * continue an iteration. + * \param name Pointer to fill in with the search provider name requested. + * \return -1 if there are no more, otherwise the iterator for the next item. + * + * \verb + * ssize_t iter; + * const char *name; + * ... + * for (iter = search_web_iterate_providers(0, &name); + * iter != -1; + * iter = search_web_iterate_providers(iter, &name)) { + * do_something_with(name); + * } + * \endverb + */ +ssize_t search_web_iterate_providers(ssize_t from, const char **name); + + /** * Initialise the web search operations. *