quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

util.h (1084B)


      1 /* See LICENSE file for copyright and license details. */
      2 #ifndef UTIL_H
      3 #define UTIL_H
      4 
      5 #include <regex.h>
      6 #include <stddef.h>
      7 #include <time.h>
      8 
      9 #include "arg.h"
     10 
     11 /* main server struct */
     12 struct vhost {
     13 	char *chost;
     14 	char *regex;
     15 	char *dir;
     16 	char *prefix;
     17 	regex_t re;
     18 };
     19 
     20 struct map {
     21 	char *chost;
     22 	char *from;
     23 	char *to;
     24 };
     25 
     26 extern struct server {
     27 	char *host;
     28 	char *port;
     29 	char *docindex;
     30 	int listdirs;
     31 	struct vhost *vhost;
     32 	size_t vhost_len;
     33 	struct map *map;
     34 	size_t map_len;
     35 } s;
     36 
     37 #undef MIN
     38 #define MIN(x,y)  ((x) < (y) ? (x) : (y))
     39 #undef MAX
     40 #define MAX(x,y)  ((x) > (y) ? (x) : (y))
     41 #undef LEN
     42 #define LEN(x) (sizeof (x) / sizeof *(x))
     43 
     44 extern char *argv0;
     45 
     46 void warn(const char *, ...);
     47 void die(const char *, ...);
     48 
     49 void epledge(const char *, const char *);
     50 void eunveil(const char *, const char *);
     51 
     52 #define TIMESTAMP_LEN 30
     53 
     54 char *timestamp(time_t, char buf[TIMESTAMP_LEN]);
     55 int esnprintf(char *, size_t, const char *, ...);
     56 
     57 void *reallocarray(void *, size_t, size_t);
     58 long long strtonum(const char *, long long, long long, const char **);
     59 
     60 #endif /* UTIL_H */