diff options
author | James Maki <jmaki@multitech.com> | 2010-04-23 11:58:20 -0500 |
---|---|---|
committer | James Maki <jmaki@multitech.com> | 2010-04-23 11:58:20 -0500 |
commit | 14fb44b17123b27e562379f51b75ee889982688d (patch) | |
tree | 3c2344f5c42396ab839638ee12f7c2f66a2656cb /src/utils.h | |
download | sms-utils-14fb44b17123b27e562379f51b75ee889982688d.tar.gz sms-utils-14fb44b17123b27e562379f51b75ee889982688d.tar.bz2 sms-utils-14fb44b17123b27e562379f51b75ee889982688d.zip |
initial commit
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..3254b3c --- /dev/null +++ b/src/utils.h @@ -0,0 +1,42 @@ +#ifndef __UTILS_H +#define __UTILS_H + +#include <stdarg.h> +#include <sys/types.h> +#include <sys/wait.h> + +#define BIT(nr) (1UL << (nr)) + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) +#define __STRINGIFY(x...) #x +#define STRINGIFY(x...) __STRINGIFY(x) + +enum { + false = 0, + true = 1, +}; + +int tokcmp(const char *cmd, const char *pattern); +char *strrstrip(char *str); + +ssize_t safe_read(int fd, void *buf, size_t count); +ssize_t safe_readn(int fd, void *buf, size_t len); +ssize_t safe_write(int fd, const void *buf, size_t count); +ssize_t full_write(int fd, const void *buf, size_t len); + +enum { + USER_YESNO_NO = 0, + USER_YESNO_YES = 1, +}; + +int user_yesno(int def, const char *fmt, ...); +int systemf(const char *fmt, ...); +FILE *popenf(const char *mode, const char *fmt, ...); +char *shell_path_expand(const char *path); + +#define YAML_INDENT 2 + +#define indentf(n, format, args...) \ + printf("%*s" format , n, "" , ## args) + +#endif /* ~__UTILS_H */ |