diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-23 19:34:52 +0200 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-23 19:34:52 +0200 |
commit | 3ad29ab55ad71d706152781b70a43d9f6be407b9 (patch) | |
tree | 4e5a41b23e771faef0f633c6570210a42bd9c037 /ubi-utils/src/common.c | |
parent | 22f5fe49d60ea43524a902408b3112a78f2c5aae (diff) |
ubi-utils: remove all old tools
Remove all old tools because I cannot maintain them and the original
authors do not seem to have time for this. Some of the tools do not
work properly, some are just vague and undocumented and seem to be
oriented to the environment of the IBM guys. Nevertheless, I'll
return the tool as is in the next commit, becouse they are still
useful.
This commit also adds a ubinize utility to generate UBI images.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/common.c')
-rw-r--r-- | ubi-utils/src/common.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/ubi-utils/src/common.c b/ubi-utils/src/common.c index f8110c3..56244df 100644 --- a/ubi-utils/src/common.c +++ b/ubi-utils/src/common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) Artem Bityutskiy, 2007 + * 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 as published by @@ -19,11 +19,13 @@ /* * This file contains various common stuff used by UBI utilities. * - * Author: Artem Bityutskiy + * Authors: Artem Bityutskiy + * Adrian Hunter */ #include <stdio.h> #include <string.h> +#include <ctype.h> /** * ubiutils_bytes_multiplier - convert size specifier to an integer @@ -87,3 +89,56 @@ void ubiutils_print_bytes(long long bytes, int bracket) if (bracket) printf(")"); } + +/** + * ubiutils_print_text - print text and fold it. + * @stream: file stream to print to + * @text: text to print + * @width: maximum allowed text width + * + * Print text and fold it so that each line would not have more then @width + * characters. + */ +void ubiutils_print_text(FILE *stream, const char *text, int width) +{ + int pos, bpos = 0; + const char *p; + char line[1024]; + + if (width > 1023) { + fprintf(stream, "%s\n", text); + return; + } + p = text; + pos = 0; + while (p[pos]) { + while (!isspace(p[pos])) { + line[pos] = p[pos]; + if (!p[pos]) + break; + ++pos; + if (pos == width) { + line[pos] = '\0'; + fprintf(stream, "%s\n", line); + p += pos; + pos = 0; + } + } + while (pos < width) { + line[pos] = p[pos]; + if (!p[pos]) { + bpos = pos; + break; + } + if (isspace(p[pos])) + bpos = pos; + ++pos; + } + line[bpos] = '\0'; + fprintf(stream, "%s\n", line); + p += bpos; + pos = 0; + while (p[pos] && isspace(p[pos])) + ++p; + } +} |