diff options
author | Yang Lin <lin.a.yang@intel.com> | 2012-05-30 19:43:21 +0800 |
---|---|---|
committer | Yang Lin <lin.a.yang@intel.com> | 2012-05-30 19:43:21 +0800 |
commit | 8c82de96cd23e4823a2d29eb2de2295c0866b0c9 (patch) | |
tree | 4c255e87442eb17f710f1674e13303ff56be0c7a /common.h | |
download | quota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.tar.gz quota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.tar.bz2 quota-8c82de96cd23e4823a2d29eb2de2295c0866b0c9.zip |
Initial commit to Gerrittizen/20120530.11.0_branch1.0
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..8b04e55 --- /dev/null +++ b/common.h @@ -0,0 +1,49 @@ +/* + * + * Various things common for all utilities + * + */ + +#ifndef GUARD_COMMON_H +#define GUARD_COMMON_H + +#ifndef __attribute__ +# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# define __attribute__(x) +# endif +#endif + +#define MY_EMAIL "jack@suse.cz" + +/* Name of current program for error reporting */ +extern char *progname; + +/* Finish programs being */ +void __attribute ((noreturn)) die(int, char *, ...) __attribute__ ((__format__ (__printf__, 2, 3))); + +/* Print an error */ +void errstr(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); + +/* If use_syslog is called, all error reports using errstr() and die() are + * written to syslog instead of stderr */ +void use_syslog(); + +/* malloc() with error check */ +void *smalloc(size_t); + +/* realloc() with error check */ +void *srealloc(void *, size_t); + +/* Safe strncpy - always finishes string */ +void sstrncpy(char *, const char *, size_t); + +/* Safe strncat - always finishes string */ +void sstrncat(char *, const char *, size_t); + +/* Safe version of strdup() */ +char *sstrdup(const char *s); + +/* Print version string */ +void version(void); + +#endif /* GUARD_COMMON_H */ |