1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-17 06:24:12 -04:00
elinks/src/cookies/cookies.h
Kalle Olavi Niemitalo ab23505519 cookies: New function init_cookie has a monopoly.
All cookies are now constructed with the new function init_cookie.
Requested by Miciah Dashiel Butler Masters.

This also fixes a bug where the "Add cookie" button left cookie->path == NULL,
causing a crash later when deciding whether to send the cookie to the server.
2006-06-05 20:22:55 +00:00

57 lines
1.5 KiB
C

#ifndef EL__COOKIES_COOKIES_H
#define EL__COOKIES_COOKIES_H
#include "main/module.h"
#include "main/object.h"
#include "protocol/uri.h"
#include "util/string.h"
#include "util/time.h"
struct listbox_item;
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;
unsigned char host[1]; /* Must be at end of struct. */
};
struct cookie {
OBJECT_HEAD(struct cookie);
unsigned char *name, *value;
unsigned char *path, *domain;
struct cookie_server *server; /* The host the cookie originated from */
time_t expires; /* Expiration time. Zero means undefined */
int secure; /* Did it have 'secure' attribute */
struct listbox_item *box_item;
};
struct cookie_server *get_cookie_server(unsigned char *host, int hostlen);
struct cookie *init_cookie(unsigned char *name, unsigned char *value,
unsigned char *path, unsigned char *domain,
struct cookie_server *server);
void accept_cookie(struct cookie *);
void done_cookie(struct cookie *);
void delete_cookie(struct cookie *);
void set_cookie(struct uri *, unsigned char *);
void load_cookies(void);
void save_cookies(void);
/* 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. */
struct string *send_cookies(struct uri *uri);
extern struct module cookies_module;
#endif