diff options
Diffstat (limited to 'tileserver/util.h')
-rw-r--r-- | tileserver/util.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tileserver/util.h b/tileserver/util.h new file mode 100644 index 000000000..a2f1f7bc8 --- /dev/null +++ b/tileserver/util.h @@ -0,0 +1,36 @@ +/* + * util.h: + * Utilities. + * + * Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. + * Email: chris@mysociety.org; WWW: http://www.mysociety.org/ + * + * $Id: util.h,v 1.1 2006-09-20 15:45:51 chris Exp $ + * + */ + +#ifndef __UTIL_H_ /* include guard */ +#define __UTIL_H_ + +/* err FORMAT [ARG ...] + * Write an error message to standard error. */ + /* XXX format this with a timestamp for the error-log? */ +#define err(...) \ + do { \ + fprintf(stderr, "tileserver: "); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + } while (0) + +/* die FORMAT [ARG ...] + * Write an error message to standard error and exit unsuccessfully. */ +#define die(...) do { err(__VA_ARGS__); exit(1); } while (0) + +/* util.c */ +void *xmalloc(const size_t s); +void *xcalloc(const size_t a, const size_t b); +void *xrealloc(void *b, const size_t s); +char *xstrdup(const char *s); +void xfree(void *v); + +#endif /* __UTIL_H_ */ |