72 lines
1.6 KiB
C
72 lines
1.6 KiB
C
#ifndef LIBGEMINICLIENT_H
|
|
#define LIBGEMINICLIENT_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
|
|
#include <tls.h>
|
|
|
|
#define GEMINI_HOSTNAME_MAX 1024
|
|
#define GEMINI_URL_MAX 1024
|
|
#define GEMINI_META_MAX 1024
|
|
#define GEMINI_REDIRECT_MAX 5
|
|
|
|
#define GEMINI_TOFU_WRITE 0x01
|
|
|
|
struct gemini_tofu {
|
|
struct gemini_tofu *next;
|
|
char *host;
|
|
char *hash;
|
|
time_t date;
|
|
};
|
|
|
|
#define GEMINI_INITIALIZER \
|
|
{ { 0 }, { 0 }, NULL, NULL, NULL, NULL, NULL, NULL, \
|
|
NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, \
|
|
-1, -1, 0, 0, 0, 0, GEMINI_REDIRECT_MAX, 0, 0 }
|
|
struct gemini {
|
|
char response[3 + GEMINI_META_MAX + 2];
|
|
char request[GEMINI_URL_MAX + 2];
|
|
struct tls *tls;
|
|
struct tls_config *tls_config;
|
|
struct gemini_tofu *tofu;
|
|
uint8_t *keymem;
|
|
uint8_t *certmem;
|
|
const char *keyfile;
|
|
const char *certfile;
|
|
const char *tofufile;
|
|
const char *proxy;
|
|
const char *meta;
|
|
const char *extra;
|
|
size_t reqlen;
|
|
size_t reslen;
|
|
size_t metalen;
|
|
size_t extralen;
|
|
size_t keylen;
|
|
size_t certlen;
|
|
size_t index;
|
|
int socketfd;
|
|
int tofufd;
|
|
int tofumod;
|
|
int flags;
|
|
int state;
|
|
int redirects;
|
|
int maxredirects;
|
|
short status;
|
|
short port;
|
|
};
|
|
|
|
struct gemini *gemini_create(void);
|
|
void gemini_init(struct gemini *);
|
|
void gemini_envinit(struct gemini *);
|
|
void gemini_reset(struct gemini *);
|
|
int gemini_connect_query(struct gemini *, const char *,
|
|
const char *);
|
|
int gemini_connect(struct gemini *, const char *);
|
|
ssize_t gemini_read(struct gemini *, void *, size_t);
|
|
void gemini_fini(struct gemini *);
|
|
void gemini_destroy(struct gemini *);
|
|
|
|
#endif
|