]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/xcommon.h
Merge branch 'sid'
[nfs-utils.git] / support / include / xcommon.h
1 /*
2  * xcommon.h -- Support function prototypes. Functions are in xcommon.c.
3  *
4  * 2006-06-06 Amit Gud <agud@redhat.com>
5  * - Moved code snippets  from mount/sundries.h of util-linux
6  *   and merged code from support/nfs/xmalloc.c by Olaf Kirch <okir@monad.swb.de> here.
7  */
8
9 #ifndef _XMALLOC_H
10 #define _MALLOC_H
11
12 #include <sys/types.h>
13 #include <fcntl.h>
14 #include <limits.h>
15 #include <signal.h>
16 #include <stdarg.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 #define streq(s, t)     (strcmp ((s), (t)) == 0)
21
22 /* Functions in sundries.c that are used in mount.c and umount.c  */ 
23 char *canonicalize (const char *path);
24 void nfs_error (const char *fmt, ...);
25 void *xmalloc (size_t size);
26 void *xrealloc(void *p, size_t size);
27 void xfree(void *);
28 char *xstrdup (const char *s);
29 char *xstrndup (const char *s, int n);
30 char *xstrconcat2 (const char *, const char *);
31 char *xstrconcat3 (const char *, const char *, const char *);
32 char *xstrconcat4 (const char *, const char *, const char *, const char *);
33 void die (int errcode, const char *fmt, ...);
34
35 extern void die(int err, const char *fmt, ...);
36 extern void (*at_die)(void);
37
38 /* exit status - bits below are ORed */
39 #define EX_SUCCESS      0       /* no failure occurred */
40 #define EX_USAGE        1       /* incorrect invocation or permission */
41 #define EX_SYSERR       2       /* out of memory, cannot fork, ... */
42 #define EX_SOFTWARE     4       /* internal mount bug or wrong version */
43 #define EX_USER         8       /* user interrupt */
44 #define EX_FILEIO      16       /* problems writing, locking, ... mtab/fstab */
45 #define EX_FAIL        32       /* mount failure */
46 #define EX_SOMEOK      64       /* some mount succeeded */
47 #define EX_BG         256       /* retry in background (internal only) */
48
49 #endif /* XMALLOC_H */