libgeminiclient/libgeminiclient.h

72 lines
1.6 KiB
C
Raw Permalink Normal View History

2020-04-29 05:03:38 +00:00
#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
2020-04-29 05:03:38 +00:00
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 }
2020-04-29 05:03:38 +00:00
struct gemini {
char response[3 + GEMINI_META_MAX + 2];
2020-04-29 05:03:38 +00:00
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;
2020-04-29 05:03:38 +00:00
size_t reqlen;
size_t reslen;
size_t metalen;
size_t extralen;
2020-04-29 05:03:38 +00:00
size_t keylen;
size_t certlen;
size_t index;
int socketfd;
2020-04-29 05:03:38 +00:00
int tofufd;
int tofumod;
int flags;
int state;
int redirects;
int maxredirects;
short status;
short port;
};
struct gemini *gemini_create(void);
2020-04-29 05:03:38 +00:00
void gemini_init(struct gemini *);
void gemini_envinit(struct gemini *);
2020-04-29 05:03:38 +00:00
void gemini_reset(struct gemini *);
int gemini_connect_query(struct gemini *, const char *,
const char *);
int gemini_connect(struct gemini *, const char *);
2020-04-29 05:03:38 +00:00
ssize_t gemini_read(struct gemini *, void *, size_t);
void gemini_fini(struct gemini *);
void gemini_destroy(struct gemini *);
2020-04-29 05:03:38 +00:00
#endif