2018-02-04 20:27:33 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
2018-03-04 23:14:25 +00:00
|
|
|
#include <regex.h>
|
|
|
|
#include <stddef.h>
|
2018-02-04 20:27:33 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "arg.h"
|
|
|
|
|
2018-03-04 23:14:25 +00:00
|
|
|
/* main server struct */
|
|
|
|
struct vhost {
|
2018-03-05 08:51:29 +00:00
|
|
|
char *chost;
|
2018-03-04 23:14:25 +00:00
|
|
|
char *regex;
|
|
|
|
char *dir;
|
|
|
|
char *prefix;
|
|
|
|
regex_t re;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct map {
|
|
|
|
char *chost;
|
|
|
|
char *from;
|
|
|
|
char *to;
|
|
|
|
};
|
|
|
|
|
2020-08-17 09:37:25 +00:00
|
|
|
struct server {
|
2018-03-04 23:14:25 +00:00
|
|
|
char *host;
|
|
|
|
char *port;
|
|
|
|
char *docindex;
|
|
|
|
int listdirs;
|
|
|
|
struct vhost *vhost;
|
|
|
|
size_t vhost_len;
|
|
|
|
struct map *map;
|
|
|
|
size_t map_len;
|
2020-08-17 09:37:25 +00:00
|
|
|
};
|
2018-03-04 23:14:25 +00:00
|
|
|
|
2018-02-04 20:27:33 +00:00
|
|
|
#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 *, ...);
|
|
|
|
|
2019-09-23 14:56:28 +00:00
|
|
|
void epledge(const char *, const char *);
|
|
|
|
void eunveil(const char *, const char *);
|
|
|
|
|
2020-08-05 11:41:44 +00:00
|
|
|
int timestamp(char *, size_t, time_t);
|
2018-03-04 23:59:37 +00:00
|
|
|
int esnprintf(char *, size_t, const char *, ...);
|
2020-08-22 21:20:00 +00:00
|
|
|
int prepend(char *, size_t, const char *);
|
2020-08-30 06:43:10 +00:00
|
|
|
void replace(char **, const char *, const char *);
|
|
|
|
char *read_file(const char* path);
|
2018-02-04 20:27:33 +00:00
|
|
|
|
2018-03-04 23:14:25 +00:00
|
|
|
void *reallocarray(void *, size_t, size_t);
|
|
|
|
long long strtonum(const char *, long long, long long, const char **);
|
|
|
|
|
2018-02-04 20:27:33 +00:00
|
|
|
#endif /* UTIL_H */
|