Now include/common.h contains things that really everyone can use.
And all the stuff specific to ubi-utils is in ubi-utils/include/ubiutils-common.h
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef __UBI_UTILS_COMMON_H__
-#define __UBI_UTILS_COMMON_H__
+#ifndef __MTD_UTILS_COMMON_H__
+#define __MTD_UTILS_COMMON_H__
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
+/*
+ * Note, the user is supposed to define its PROGRAM_NAME before including this
+ * header.
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
return (n != 0 && ((n & (n - 1)) == 0));
}
-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);
-int ubiutils_srand(void);
-
#ifdef __cplusplus
}
#endif
-#endif /* !__UBI_UTILS_COMMON_H__ */
+#endif /* !__MTD_UTILS_COMMON_H__ */
include ../common.mk
-# And the below is the rule to get final executable from its .o and common.o
+# And the below is the rule to get final executable from its .o and ubiutils-common.o
$(TARGETS): $(addprefix $(BUILDDIR)/,\
- libubi.a common.o)
+ libubi.a ubiutils-common.o)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@
$(BUILDDIR)/ubicrc32: $(addprefix $(BUILDDIR)/,\
# $(CC) $(CFLAGS) -o $@ $^
$(BUILDDIR)/ubinize: $(addprefix $(BUILDDIR)/,\
- ubinize.o common.o libiniparser.a libubigen.a)
+ ubinize.o ubiutils-common.o libiniparser.a libubigen.a)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@
$(BUILDDIR)/mtdinfo: $(addprefix $(BUILDDIR)/,\
- libubigen.a common.o)
+ libubigen.a ubiutils-common.o)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lubigen -o $@
$(BUILDDIR)/ubiformat: $(addprefix $(BUILDDIR)/,\
- ubiformat.o common.o libscan.a libubi.a libubigen.a)
+ ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@
$(BUILDDIR)/libubi.a: $(BUILDDIR)/libubi.o
--- /dev/null
+/*
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __UBI_UTILS_COMMON_H__
+#define __UBI_UTILS_COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+int ubiutils_srand(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !__UBI_UTILS_COMMON_H__ */
+
#include <libubigen.h>
#include <libmtd.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.0"
#define PROGRAM_NAME "mtdinfo"
#include <libubi.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.0"
#define PROGRAM_NAME "ubiattach"
#include <mtd_swab.h>
#include <crc32.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.5"
#define PROGRAM_NAME "ubiformat"
#include <libubi.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.1"
#define PROGRAM_NAME "ubimkvol"
#include <libubi.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.1"
#define PROGRAM_NAME "ubinfo"
#include <libubigen.h>
#include <libiniparser.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.2"
#define PROGRAM_NAME "ubinize"
#include <libubi.h>
#include "common.h"
+#include "ubiutils-common.h"
#define PROGRAM_VERSION "1.1"
#define PROGRAM_NAME "ubirsvol"