aboutsummaryrefslogtreecommitdiff
path: root/ubi-utils/src/common.h
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-06 18:59:15 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-06 18:59:15 +0200
commita71f0ce8c5f80757096f6e4d0ebca27ccbe14da9 (patch)
tree07645e323044fcfb331df157a80a84b624cdab51 /ubi-utils/src/common.h
parentf3d507be006c46870818c549b8f7dc0b4daccf03 (diff)
ubi-tools: improve printing macros
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/common.h')
-rw-r--r--ubi-utils/src/common.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/ubi-utils/src/common.h b/ubi-utils/src/common.h
index 3ee93ff..203238e 100644
--- a/ubi-utils/src/common.h
+++ b/ubi-utils/src/common.h
@@ -20,6 +20,8 @@
#define __UBI_UTILS_COMMON_H__
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#ifdef __cplusplus
extern "C" {
@@ -40,16 +42,25 @@ extern "C" {
} while(0)
/* Error messages */
-#define errmsg(fmt, ...) do { \
+#define errmsg(fmt, ...) ({ \
fprintf(stderr, PROGRAM_NAME " error: " fmt "\n", ##__VA_ARGS__); \
-} while(0)
+ -1; \
+})
+
+/* System error messages */
+#define sys_errmsg(fmt, ...) ({ \
+ int _err = errno; \
+ fprintf(stderr, PROGRAM_NAME " error: " fmt "\n", ##__VA_ARGS__); \
+ fprintf(stderr, "error %d (%s)", _err, strerror(_err)); \
+ -1; \
+})
/* Warnings */
#define warnmsg(fmt, ...) do { \
fprintf(stderr, PROGRAM_NAME " warning: " fmt "\n", ##__VA_ARGS__); \
} while(0)
-int ubiutils_get_multiplier(const char *str);
+long long ubiutils_get_bytes(const char *str);
void ubiutils_print_bytes(long long bytes, int bracket);
void ubiutils_print_text(FILE *stream, const char *txt, int len);