quark

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

util.h (1228B)


      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 "config.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 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 };
     36 
     37 /* general purpose buffer */
     38 struct buffer {
     39 	char data[BUFFER_SIZE];
     40 	size_t len;
     41 };
     42 
     43 #undef MIN
     44 #define MIN(x,y)  ((x) < (y) ? (x) : (y))
     45 #undef MAX
     46 #define MAX(x,y)  ((x) > (y) ? (x) : (y))
     47 #undef LEN
     48 #define LEN(x) (sizeof (x) / sizeof *(x))
     49 
     50 extern char *argv0;
     51 
     52 void warn(const char *, ...);
     53 void die(const char *, ...);
     54 
     55 void epledge(const char *, const char *);
     56 void eunveil(const char *, const char *);
     57 
     58 int timestamp(char *, size_t, time_t);
     59 int esnprintf(char *, size_t, const char *, ...);
     60 int prepend(char *, size_t, const char *);
     61 
     62 void *reallocarray(void *, size_t, size_t);
     63 long long strtonum(const char *, long long, long long, const char **);
     64 
     65 int buffer_appendf(struct buffer *, const char *, ...);
     66 
     67 #endif /* UTIL_H */