libgeminiclient/libgeminiclient.h

75 lines
1.5 KiB
C
Raw 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>
#ifndef GEMINI_HOSTNAME_MAX
#define GEMINI_HOSTNAME_MAX 1024
#endif
#ifndef GEMINI_URL_MAX
#define GEMINI_URL_MAX 1024
#endif
#ifndef GEMINI_META_MAX
#define GEMINI_META_MAX 1024
#endif
#ifndef GEMINI_REDIRECT_MAX
#define GEMINI_REDIRECT_MAX 5
#endif
enum {
GEMINI_PROMPT = 0x01,
GEMINI_SECPROMPT = 0x02,
GEMINI_TOFU_WRITE = 0x08
};
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, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, \
GEMINI_REDIRECT_MAX, 0, 0 }
struct gemini {
char meta[GEMINI_META_MAX + 1];
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;
size_t metalen;
size_t reqlen;
size_t keylen;
size_t certlen;
size_t index;
int tofufd;
int tofumod;
int flags;
int state;
int redirects;
int maxredirects;
short status;
short port;
};
void gemini_init(struct gemini *);
void gemini_reset(struct gemini *);
struct gemini *gemini_create(void);
int gemini_open(struct gemini *, const char *);
void gemini_close(struct gemini *);
void gemini_destroy(struct gemini *);
ssize_t gemini_read(struct gemini *, void *, size_t);
#endif