X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=lib%2Fdisplay_options.c;h=f1c930463e9a22c4bcb361ad33724f296e8d2719;hb=17b3f32dd04f0008890b8bd57ba2ea50601c6f97;hp=29343fc00e3f070debd0a749541083bee59a096c;hpb=7d94c497651b6c36a4915d436e6db86398f480d1;p=u-boot diff --git a/lib/display_options.c b/lib/display_options.c index 29343fc00e..f1c930463e 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2000-2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -13,13 +12,39 @@ #include #include -int display_options (void) +char *display_options_get_banner_priv(bool newlines, const char *build_tag, + char *buf, int size) { -#if defined(BUILD_TAG) - printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG); -#else - printf ("\n\n%s\n\n", version_string); + int len; + + len = snprintf(buf, size, "%s%s", newlines ? "\n\n" : "", + version_string); + if (build_tag && len < size) + len += snprintf(buf + len, size - len, ", Build: %s", + build_tag); + if (len > size - 3) + len = size - 3; + strcpy(buf + len, "\n\n"); + + return buf; +} + +#ifndef BUILD_TAG +#define BUILD_TAG NULL #endif + +char *display_options_get_banner(bool newlines, char *buf, int size) +{ + return display_options_get_banner_priv(newlines, BUILD_TAG, buf, size); +} + +int display_options(void) +{ + char buf[DISPLAY_OPTIONS_BANNER_LENGTH]; + + display_options_get_banner(true, buf, sizeof(buf)); + printf("%s", buf); + return 0; }