update fetcher registration API to return an error code.

By using an error code return we can gracefully handle fetcher
registration faliures instead of just immediately aborting.

The curl handler was also cleaned up and documentation improved
as a side effect.
This commit is contained in:
Vincent Sanders 2014-10-25 17:10:08 +01:00
parent 7cf5cf7cb7
commit 53f0f432dd
7 changed files with 568 additions and 551 deletions

View File

@ -287,14 +287,36 @@ static void fetcher_poll(void *unused)
/* exported interface documented in content/fetch.h */
nserror fetcher_init(void)
{
fetch_curl_register();
fetch_data_register();
fetch_file_register();
fetch_resource_register();
fetch_about_register();
fetch_javascript_register();
nserror ret;
return NSERROR_OK;
ret = fetch_curl_register();
if (ret != NSERROR_OK) {
return ret;
}
ret = fetch_data_register();
if (ret != NSERROR_OK) {
return ret;
}
ret = fetch_file_register();
if (ret != NSERROR_OK) {
return ret;
}
ret = fetch_resource_register();
if (ret != NSERROR_OK) {
return ret;
}
ret = fetch_about_register();
if (ret != NSERROR_OK) {
return ret;
}
ret = fetch_javascript_register();
return ret;
}
/* exported interface documented in content/fetchers.h */

View File

@ -23,6 +23,11 @@
#ifndef NETSURF_CONTENT_FETCHERS_FETCH_ABOUT_H
#define NETSURF_CONTENT_FETCHERS_FETCH_ABOUT_H
/**
* Register about scheme handler.
*
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror fetch_about_register(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,12 @@
#include <curl/curl.h>
void fetch_curl_register(void);
/**
* Register curl scheme handler.
*
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror fetch_curl_register(void);
/** Global cURL multi handle. */
extern CURLM *fetch_curl_multi;

View File

@ -16,13 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* data: URL method handler
/**
* \file
* data scheme fetch handler interface.
*/
#ifndef NETSURF_CONTENT_FETCHERS_FETCH_DATA_H
#define NETSURF_CONTENT_FETCHERS_FETCH_DATA_H
/**
* Register data scheme handler.
*
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror fetch_data_register(void);
#endif

View File

@ -16,13 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* file: URL method handler
/**
* \file
* file scheme fetcher handler interface.
*/
#ifndef NETSURF_CONTENT_FETCHERS_FETCH_FILE_H
#define NETSURF_CONTENT_FETCHERS_FETCH_FILE_H
/**
* Register file scheme handler.
*
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror fetch_file_register(void);
#endif

View File

@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* resource: URL method handler.
/**
* \file
* resource URL scheme handler interface.
*
* The resource fetcher is intended to provide a flat uniform URL
* space for browser local resources referenced by URL. Using this
@ -34,6 +35,8 @@
* Register the resource scheme.
*
* should only be called from the fetch initialise
*
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror fetch_resource_register(void);