chiark / gitweb /
Bump version to 7.0.1~iwj0
[chiark-utils.git] / cprogs / common.h
1 /*
2  * common.[ch] - C helpers common to the whole of chiark-utils
3  *
4  * Copyright 2007 Canonical Ltd
5  * Copyright 2016 Canonical Ltd
6  *
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this file; if not, consult the Free Software
20  * Foundation's website at www.fsf.org, or the GNU Project website at
21  * www.gnu.org.
22  *
23  * Should be included early so that _GNU_SOURCE takes effect.
24  */
25
26 #ifndef COMMON_H
27 #define COMMON_H
28
29 #define _GNU_SOURCE
30
31 #include <assert.h>
32 #include <stdarg.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <fcntl.h>
36
37 char *m_vasprintf(const char *fmt, va_list al);
38 char *m_asprintf(const char *fmt, ...);
39
40 /* to be provided by program: */
41 void common_die(const char *what);
42 void common_diee(const char *what); /* prints errno */
43 void nonblock(int fd);
44
45 void *xmalloc(size_t sz);
46
47 #define FILLZERO(object) (memset((&object),0,sizeof(object)))
48
49 extern char **environ; // no header file for this, srsly!
50
51 #endif /*COMMON_H*/