2005-09-15 09:58:31 -04:00
|
|
|
/* Version information */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "elinks.h"
|
|
|
|
|
|
|
|
#include "intl/gettext/libintl.h"
|
|
|
|
#include "main/module.h"
|
|
|
|
#include "main/version.h"
|
|
|
|
#include "terminal/terminal.h"
|
|
|
|
#include "util/error.h"
|
|
|
|
#include "util/memory.h"
|
|
|
|
#include "util/string.h"
|
|
|
|
#include "vernum.h"
|
|
|
|
|
2017-11-17 11:33:51 -05:00
|
|
|
#if defined(CONFIG_LIBEV) || defined(CONFIG_LIBEVENT)
|
|
|
|
extern int event_enabled;
|
|
|
|
#endif
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
add_module_to_string(struct string *string, struct module *module,
|
|
|
|
struct terminal *term)
|
|
|
|
{
|
|
|
|
struct module *submodule;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (module->name) add_to_string(string, _(module->name, term));
|
|
|
|
|
|
|
|
if (!module->submodules) return;
|
|
|
|
|
|
|
|
add_to_string(string, " (");
|
|
|
|
|
|
|
|
foreach_module (submodule, module->submodules, i) {
|
|
|
|
if (i > 0) add_to_string(string, ", ");
|
|
|
|
add_module_to_string(string, submodule, term);
|
|
|
|
}
|
|
|
|
|
|
|
|
add_to_string(string, ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_modules_to_string(struct string *string, struct terminal *term)
|
|
|
|
{
|
|
|
|
struct module *module;
|
2007-04-26 09:00:04 -04:00
|
|
|
int i;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
foreach_module (module, builtin_modules, i) {
|
|
|
|
if (i > 0) add_to_string(string, ", ");
|
|
|
|
add_module_to_string(string, module, term);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-26 09:00:04 -04:00
|
|
|
/* Wrap string on spaces starting at position @start_at, trying
|
|
|
|
* to keep lines undex @maxlen length */
|
|
|
|
static void
|
|
|
|
wrap_string(struct string *string, int start_at, int maxlen)
|
|
|
|
{
|
|
|
|
unsigned char *pos, *start_pos;
|
|
|
|
unsigned char *last_pos = NULL;
|
|
|
|
|
|
|
|
assert(string && string->source && start_at < string->length);
|
|
|
|
if_assert_failed return;
|
|
|
|
|
|
|
|
if (maxlen <= 0) return;
|
|
|
|
|
|
|
|
pos = start_pos = &string->source[start_at];
|
2016-04-20 13:43:37 -04:00
|
|
|
while ((pos = strchr((const char *)pos, ' '))) {
|
2007-04-26 09:00:04 -04:00
|
|
|
int len = pos - start_pos;
|
|
|
|
|
|
|
|
if (len < maxlen) {
|
|
|
|
last_pos = pos;
|
|
|
|
pos++;
|
|
|
|
} else {
|
|
|
|
if (last_pos) *last_pos = '\n';
|
|
|
|
pos = start_pos = last_pos + 1;
|
|
|
|
}
|
|
|
|
if (!*pos) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
/* @more will add more information especially for info box. */
|
|
|
|
unsigned char *
|
|
|
|
get_dyn_full_version(struct terminal *term, int more)
|
|
|
|
{
|
|
|
|
static const unsigned char comma[] = ", ";
|
|
|
|
struct string string;
|
|
|
|
|
|
|
|
if (!init_string(&string)) return NULL;
|
|
|
|
|
|
|
|
add_format_to_string(&string, "ELinks %s", VERSION_STRING);
|
2007-04-26 09:00:04 -04:00
|
|
|
if (*build_id) {
|
2007-04-27 09:08:28 -04:00
|
|
|
add_char_to_string(&string, more ? '\n' : ' ');
|
|
|
|
add_format_to_string(&string, "%s", build_id);
|
2007-04-26 09:00:04 -04:00
|
|
|
}
|
|
|
|
|
2007-04-27 09:08:28 -04:00
|
|
|
add_char_to_string(&string, '\n');
|
|
|
|
add_format_to_string(&string, _("Built on %s %s", term),
|
2007-04-26 09:00:04 -04:00
|
|
|
build_date, build_time);
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
if (more) {
|
|
|
|
add_to_string(&string, "\n\n");
|
|
|
|
add_to_string(&string, _("Text WWW browser", term));
|
|
|
|
}
|
|
|
|
|
|
|
|
string_concat(&string,
|
|
|
|
"\n\n",
|
|
|
|
_("Features:", term), "\n",
|
|
|
|
#ifndef CONFIG_DEBUG
|
|
|
|
_("Standard", term),
|
|
|
|
#else
|
|
|
|
_("Debug", term),
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_FASTMEM
|
|
|
|
comma, _("Fastmem", term),
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_OWN_LIBC
|
|
|
|
comma, _("Own Libc Routines", term),
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_BACKTRACE
|
|
|
|
comma, _("No Backtrace", term),
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IPV6
|
|
|
|
comma, "IPv6",
|
|
|
|
#endif
|
2017-11-11 10:31:32 -05:00
|
|
|
#ifdef CONFIG_BROTLI
|
|
|
|
comma, "brotli",
|
|
|
|
#endif
|
2005-09-15 09:58:31 -04:00
|
|
|
#ifdef CONFIG_GZIP
|
|
|
|
comma, "gzip",
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BZIP2
|
|
|
|
comma, "bzip2",
|
|
|
|
#endif
|
2006-03-31 13:35:08 -05:00
|
|
|
#ifdef CONFIG_LZMA
|
|
|
|
comma, "lzma",
|
|
|
|
#endif
|
2005-09-15 09:58:31 -04:00
|
|
|
#ifndef CONFIG_MOUSE
|
|
|
|
comma, _("No mouse", term),
|
2006-02-07 21:23:21 -05:00
|
|
|
#endif
|
2006-09-17 09:12:47 -04:00
|
|
|
#ifdef CONFIG_UTF8
|
2006-02-07 21:23:21 -05:00
|
|
|
comma, "UTF-8",
|
2008-01-19 12:56:50 -05:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_COMBINE
|
|
|
|
comma, _("Combining characters", term),
|
2017-11-17 11:33:51 -05:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LIBEV
|
|
|
|
comma, (event_enabled ? _("libev", term) : _("libev (disabled)", term)),
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LIBEVENT
|
|
|
|
comma, (event_enabled ? _("libevent", term) : _("libevent (disabled)", term)),
|
2017-11-19 12:29:38 -05:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TERMINFO
|
|
|
|
comma, (get_cmd_opt_bool("terminfo") ? _("terminfo", term) : _("terminfo (disabled)", term)),
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|
|
|
|
comma,
|
2007-03-11 07:01:50 -04:00
|
|
|
(unsigned char *) NULL
|
2005-09-15 09:58:31 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
add_modules_to_string(&string, term);
|
|
|
|
|
2007-04-26 09:00:04 -04:00
|
|
|
if (!more) {
|
|
|
|
int start_at = 0;
|
2016-04-20 15:03:27 -04:00
|
|
|
unsigned char *last_newline = strrchr((const char *)string.source, '\n');
|
2007-04-26 09:00:04 -04:00
|
|
|
|
|
|
|
if (last_newline) {
|
|
|
|
start_at = last_newline - string.source + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wrap_string(&string, start_at, 72);
|
|
|
|
}
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
return string.source;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This one is used to prevent usage of straconcat() at backtrace time. */
|
|
|
|
void
|
|
|
|
init_static_version(void)
|
|
|
|
{
|
|
|
|
unsigned char *s = get_dyn_full_version((struct terminal *) NULL, 0);
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
safe_strncpy(full_static_version, s, sizeof(full_static_version));
|
|
|
|
mem_free(s);
|
|
|
|
}
|
|
|
|
}
|