/*
- * Copyright (c) Artem Bityutskiy, 2007
+ * Copyright (c) Artem Bityutskiy, 2007, 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define normsg(fmt, ...) do { \
printf(PROGRAM_NAME ": " fmt "\n", ##__VA_ARGS__); \
} while(0)
+#define normsg_cont(fmt, ...) do { \
+ printf(PROGRAM_NAME ": " fmt, ##__VA_ARGS__); \
+} while(0)
/* Error messages */
#define errmsg(fmt, ...) ({ \
#include <limits.h>
#include "libubi.h"
#include "libubi_int.h"
+#include "common.h"
+
+#define PROGRAM_NAME "libubi"
/**
* mkpath - compose full path from 2 given components.
if (read_positive_int(lib->ubi_version, &version))
goto out_error;
if (version != LIBUBI_UBI_VERSION) {
- fprintf(stderr, "LIBUBI: this library was made for UBI version "
- "%d, but UBI version %d is detected\n",
- LIBUBI_UBI_VERSION, version);
+ errmsg("this library was made for UBI version %d, but UBI "
+ "version %d is detected\n", LIBUBI_UBI_VERSION, version);
goto out_error;
}
extern "C" {
#endif
-/* Error messages */
-#define errmsg(fmt, ...) ({ \
- fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \
- -1; \
-})
-
-/* System error messages */
-#define sys_errmsg(fmt, ...) ({ \
- int _err = errno; \
- fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \
- fprintf(stderr, "error %d (%s)\n", _err, strerror(_err)); \
- -1; \
-})
-
/*
* The below are pre-define UBI file and directory names.
*
/*
- * Copyright (C) 2007 Nokia Corporation.
+ * Copyright (C) 2007, 2008 Nokia Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
if (vi->bytes == 0)
return errmsg("file \"%s\" referred from section \"%s\" is empty", *img, sname);
- printf(PROGRAM_NAME ": volume size was not specified in"
- "section \"%s\", assume ", sname);
+ normsg_cont("volume size was not specified in section \"%s\", assume ", sname);
ubiutils_print_bytes(vi->bytes, 1);
printf("\n");
}
sprintf(buf, "%s:vol_type", sname);
p = iniparser_getstring(args.dict, buf, NULL);
if (!p) {
- normsg(": volume type was not specified in "
+ normsg("volume type was not specified in "
"section \"%s\", assume \"dynamic\"\n", sname);
vi->type = UBI_VID_DYNAMIC;
} else {