2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-30 16:44:03 +04:00
|
|
|
*/
|
|
|
|
|
2003-09-18 03:27:33 +04:00
|
|
|
/** \file
|
|
|
|
* Fetching of data from a URL (interface).
|
2003-02-09 15:58:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_DESKTOP_FETCH_H_
|
|
|
|
#define _NETSURF_DESKTOP_FETCH_H_
|
|
|
|
|
2003-08-29 16:57:14 +04:00
|
|
|
#include <stdbool.h>
|
2007-01-30 01:27:15 +03:00
|
|
|
#include <sys/select.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FETCH_TYPE,
|
2004-07-10 06:35:31 +04:00
|
|
|
FETCH_PROGRESS,
|
2008-05-30 08:11:16 +04:00
|
|
|
FETCH_HEADER,
|
2004-01-05 05:10:59 +03:00
|
|
|
FETCH_DATA,
|
|
|
|
FETCH_FINISHED,
|
|
|
|
FETCH_ERROR,
|
|
|
|
FETCH_REDIRECT,
|
2006-02-06 03:10:09 +03:00
|
|
|
FETCH_NOTMODIFIED,
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2006-02-23 18:06:54 +03:00
|
|
|
FETCH_AUTH,
|
|
|
|
#endif
|
|
|
|
#ifdef WITH_SSL
|
|
|
|
FETCH_CERT_ERR,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
} fetch_msg;
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
struct content;
|
|
|
|
struct fetch;
|
2003-10-25 18:13:49 +04:00
|
|
|
struct form_successful_control;
|
2006-02-06 03:10:09 +03:00
|
|
|
|
2006-02-23 18:06:54 +03:00
|
|
|
#ifdef WITH_SSL
|
|
|
|
struct ssl_cert_info {
|
|
|
|
long version; /**< Certificate version */
|
|
|
|
char not_before[32]; /**< Valid from date */
|
|
|
|
char not_after[32]; /**< Valid to date */
|
|
|
|
int sig_type; /**< Signature type */
|
|
|
|
long serial; /**< Serial number */
|
|
|
|
char issuer[256]; /**< Issuer details */
|
|
|
|
char subject[256]; /**< Subject details */
|
|
|
|
int cert_type; /**< Certificate type */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
extern bool fetch_active;
|
2007-06-10 21:46:44 +04:00
|
|
|
|
|
|
|
typedef void (*fetch_callback)(fetch_msg msg, void *p, const void *data,
|
|
|
|
unsigned long size);
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
void fetch_init(void);
|
2007-01-27 23:58:20 +03:00
|
|
|
struct fetch * fetch_start(const char *url, const char *referer,
|
2007-06-10 21:46:44 +04:00
|
|
|
fetch_callback callback,
|
|
|
|
void *p, bool only_2xx, const char *post_urlenc,
|
|
|
|
struct form_successful_control *post_multipart,
|
|
|
|
bool verifiable, const char *parent_url, char *headers[]);
|
2003-02-09 15:58:15 +03:00
|
|
|
void fetch_abort(struct fetch *f);
|
|
|
|
void fetch_poll(void);
|
|
|
|
void fetch_quit(void);
|
2003-03-15 18:53:20 +03:00
|
|
|
const char *fetch_filetype(const char *unix_path);
|
2004-03-22 00:32:15 +03:00
|
|
|
char *fetch_mimetype(const char *ro_path);
|
2004-04-02 17:51:13 +04:00
|
|
|
bool fetch_can_fetch(const char *url);
|
2004-06-28 03:24:11 +04:00
|
|
|
void fetch_change_callback(struct fetch *fetch,
|
2007-06-10 21:46:44 +04:00
|
|
|
fetch_callback callback,
|
|
|
|
void *p);
|
2007-01-13 03:19:02 +03:00
|
|
|
long fetch_http_code(struct fetch *fetch);
|
2007-01-27 23:58:20 +03:00
|
|
|
const char *fetch_get_referer(struct fetch *fetch);
|
2008-01-30 22:56:41 +03:00
|
|
|
const char *fetch_get_parent_url(struct fetch *fetch);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2007-06-10 21:46:44 +04:00
|
|
|
/* API for fetchers themselves */
|
|
|
|
|
|
|
|
typedef bool (*fetcher_initialise)(const char *);
|
|
|
|
typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
|
2007-06-10 22:08:22 +04:00
|
|
|
bool, const char *,
|
2008-01-30 22:56:41 +03:00
|
|
|
struct form_successful_control *,
|
|
|
|
const char **);
|
2007-06-10 21:46:44 +04:00
|
|
|
typedef bool (*fetcher_start_fetch)(void *);
|
|
|
|
typedef void (*fetcher_abort_fetch)(void *);
|
|
|
|
typedef void (*fetcher_free_fetch)(void *);
|
|
|
|
typedef void (*fetcher_poll_fetcher)(const char *);
|
|
|
|
typedef void (*fetcher_finalise)(const char *);
|
|
|
|
|
|
|
|
bool fetch_add_fetcher(const char *scheme,
|
|
|
|
fetcher_initialise initialiser,
|
|
|
|
fetcher_setup_fetch setup_fetch,
|
|
|
|
fetcher_start_fetch start_fetch,
|
|
|
|
fetcher_abort_fetch abort_fetch,
|
|
|
|
fetcher_free_fetch free_fetch,
|
|
|
|
fetcher_poll_fetcher poll_fetcher,
|
|
|
|
fetcher_finalise finaliser);
|
|
|
|
|
2007-06-10 22:08:22 +04:00
|
|
|
void fetch_send_callback(fetch_msg msg, struct fetch *fetch,
|
|
|
|
const void *data, unsigned long size);
|
2007-07-04 22:44:13 +04:00
|
|
|
void fetch_remove_from_queues(struct fetch *fetch);
|
|
|
|
void fetch_free(struct fetch *f);
|
2007-06-10 21:46:44 +04:00
|
|
|
void fetch_set_http_code(struct fetch *fetch, long http_code);
|
|
|
|
const char *fetch_get_referer_to_send(struct fetch *fetch);
|
2008-01-30 22:56:41 +03:00
|
|
|
void fetch_set_cookie(struct fetch *fetch, const char *data);
|
2003-02-09 15:58:15 +03:00
|
|
|
#endif
|