Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
[elinks.git] / src / main / version.c
blobc4b33ebf2478073a7699a49c08c17216f5180aef
1 /* Version information */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #ifdef HAVE_UNISTD_H
11 #include <unistd.h>
12 #endif
14 #include "elinks.h"
16 #include "intl/gettext/libintl.h"
17 #include "main/module.h"
18 #include "main/version.h"
19 #include "terminal/terminal.h"
20 #include "util/error.h"
21 #include "util/memory.h"
22 #include "util/string.h"
23 #include "vernum.h"
26 static void
27 add_module_to_string(struct string *string, struct module *module,
28 struct terminal *term)
30 struct module *submodule;
31 int i;
33 if (module->name) add_to_string(string, _(module->name, term));
35 if (!module->submodules) return;
37 add_to_string(string, " (");
39 foreach_module (submodule, module->submodules, i) {
40 if (i > 0) add_to_string(string, ", ");
41 add_module_to_string(string, submodule, term);
44 add_to_string(string, ")");
47 static void
48 add_modules_to_string(struct string *string, struct terminal *term)
50 struct module *module;
51 int i, last_split = 0;
52 unsigned char *last_newline = strrchr(string->source, '\n');
54 if (last_newline)
55 last_split = last_newline - string->source;
57 foreach_module (module, builtin_modules, i) {
58 if (i > 0) add_to_string(string, ", ");
59 if (string->length - last_split > 70) {
60 add_char_to_string(string, '\n');
61 last_split = string->length;
63 add_module_to_string(string, module, term);
67 /* @more will add more information especially for info box. */
68 unsigned char *
69 get_dyn_full_version(struct terminal *term, int more)
71 static const unsigned char comma[] = ", ";
72 struct string string;
74 if (!init_string(&string)) return NULL;
76 add_format_to_string(&string, "ELinks %s", VERSION_STRING);
77 if (*build_id)
78 add_format_to_string(&string, " (%s)", build_id);
79 if (more) {
80 add_to_string(&string, "\n");
81 add_format_to_string(&string, _("Built on %s %s", term),
82 build_date, build_time);
83 add_to_string(&string, "\n\n");
84 add_to_string(&string, _("Text WWW browser", term));
85 } else {
86 add_format_to_string(&string, _(" (built on %s %s)", term),
87 build_date, build_time);
90 string_concat(&string,
91 "\n\n",
92 _("Features:", term), "\n",
93 #ifndef CONFIG_DEBUG
94 _("Standard", term),
95 #else
96 _("Debug", term),
97 #endif
98 #ifdef CONFIG_FASTMEM
99 comma, _("Fastmem", term),
100 #endif
101 #ifdef CONFIG_OWN_LIBC
102 comma, _("Own Libc Routines", term),
103 #endif
104 #ifndef CONFIG_BACKTRACE
105 comma, _("No Backtrace", term),
106 #endif
107 #ifdef CONFIG_IPV6
108 comma, "IPv6",
109 #endif
110 #ifdef CONFIG_GZIP
111 comma, "gzip",
112 #endif
113 #ifdef CONFIG_BZIP2
114 comma, "bzip2",
115 #endif
116 #ifdef CONFIG_LZMA
117 comma, "lzma",
118 #endif
119 #ifndef CONFIG_MOUSE
120 comma, _("No mouse", term),
121 #endif
122 #ifdef CONFIG_UTF8
123 comma, "UTF-8",
124 #endif
125 comma,
126 (unsigned char *) NULL
129 add_modules_to_string(&string, term);
131 return string.source;
134 /* This one is used to prevent usage of straconcat() at backtrace time. */
135 void
136 init_static_version(void)
138 unsigned char *s = get_dyn_full_version((struct terminal *) NULL, 0);
140 if (s) {
141 safe_strncpy(full_static_version, s, sizeof(full_static_version));
142 mem_free(s);