dirl/util.h
Laslo Hunhold a36b901d40
Add http_send_body() and data_send_error() and refactor
This turns the data-functions into the only functions "allowed"
to send body-data (called with http_send_body()). The previous (hacky)
approach of doing this in http_send_header() is not only out of place,
it's an easy source of bugs given, for instance, the sending of body
data is not expected with HEAD-requests.

Given html_escape() is now only used in data.c, we move it there from
util.c and make it a static method again.

Signed-off-by: Laslo Hunhold <dev@frign.de>
2020-08-29 00:49:16 +02:00

59 lines
1.1 KiB
C

/* See LICENSE file for copyright and license details. */
#ifndef UTIL_H
#define UTIL_H
#include <regex.h>
#include <stddef.h>
#include <time.h>
#include "arg.h"
/* main server struct */
struct vhost {
char *chost;
char *regex;
char *dir;
char *prefix;
regex_t re;
};
struct map {
char *chost;
char *from;
char *to;
};
struct server {
char *host;
char *port;
char *docindex;
int listdirs;
struct vhost *vhost;
size_t vhost_len;
struct map *map;
size_t map_len;
};
#undef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#undef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#undef LEN
#define LEN(x) (sizeof (x) / sizeof *(x))
extern char *argv0;
void warn(const char *, ...);
void die(const char *, ...);
void epledge(const char *, const char *);
void eunveil(const char *, const char *);
int timestamp(char *, size_t, time_t);
int esnprintf(char *, size_t, const char *, ...);
int prepend(char *, size_t, const char *);
void *reallocarray(void *, size_t, size_t);
long long strtonum(const char *, long long, long long, const char **);
#endif /* UTIL_H */