2005-09-15 09:58:31 -04:00
|
|
|
#ifndef EL__COOKIES_COOKIES_H
|
|
|
|
#define EL__COOKIES_COOKIES_H
|
|
|
|
|
2007-10-18 03:26:43 -04:00
|
|
|
/* ELinks cookies file format:
|
|
|
|
* NAME\tVALUE\tSERVER\tPATH\tDOMAIN\tEXPIRES\tSECURE\n
|
|
|
|
*
|
|
|
|
* \t is a tabulator
|
|
|
|
* \n is a newline
|
|
|
|
* EXPIRES is the number of seconds since 1970-01-01 00:00:00 UTC.
|
|
|
|
* SECURE is 0 for http and 1 for https.
|
|
|
|
*/
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
#include "main/module.h"
|
|
|
|
#include "main/object.h"
|
|
|
|
#include "protocol/uri.h"
|
|
|
|
#include "util/string.h"
|
|
|
|
#include "util/time.h"
|
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
struct listbox_item;
|
2006-12-09 11:27:40 -05:00
|
|
|
struct terminal;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
enum cookies_accept {
|
|
|
|
COOKIES_ACCEPT_NONE,
|
|
|
|
COOKIES_ACCEPT_ASK,
|
|
|
|
COOKIES_ACCEPT_ALL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cookie_server {
|
|
|
|
OBJECT_HEAD(struct cookie_server);
|
|
|
|
|
|
|
|
struct listbox_item *box_item;
|
2021-01-02 10:20:27 -05:00
|
|
|
char host[1]; /* Must be at end of struct. */
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cookie {
|
|
|
|
OBJECT_HEAD(struct cookie);
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
char *name, *value;
|
|
|
|
char *path, *domain;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct cookie_server *server; /* The host the cookie originated from */
|
|
|
|
time_t expires; /* Expiration time. Zero means undefined */
|
2018-08-25 09:28:29 -04:00
|
|
|
unsigned int secure:1; /* Did it have 'secure' attribute */
|
|
|
|
unsigned int httponly:1; /* Did it have 'httponly' attribute */
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct listbox_item *box_item;
|
|
|
|
};
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
struct cookie_server *get_cookie_server(char *host, int hostlen);
|
|
|
|
struct cookie *init_cookie(char *name, char *value,
|
|
|
|
char *path, char *domain,
|
2006-05-31 17:36:11 -04:00
|
|
|
struct cookie_server *server);
|
2005-09-15 09:58:31 -04:00
|
|
|
void accept_cookie(struct cookie *);
|
|
|
|
void done_cookie(struct cookie *);
|
|
|
|
void delete_cookie(struct cookie *);
|
2021-01-02 10:20:27 -05:00
|
|
|
void set_cookie(struct uri *, char *);
|
2005-09-15 09:58:31 -04:00
|
|
|
void load_cookies(void);
|
2006-12-09 11:27:40 -05:00
|
|
|
void save_cookies(struct terminal *);
|
2006-12-09 09:24:24 -05:00
|
|
|
void set_cookies_dirty(void);
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
/* Note that the returned value points to a static structure and thus the
|
|
|
|
* string will be overwritten at the next call time. The string source
|
|
|
|
* itself is dynamically allocated, though. */
|
2019-04-21 06:27:40 -04:00
|
|
|
struct string *send_cookies(struct uri *uri);
|
|
|
|
struct string *send_cookies_js(struct uri *uri);
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
extern struct module cookies_module;
|
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|