1 /* Version information */
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"
27 add_module_to_string(struct string
*string
, struct module
*module
,
28 struct terminal
*term
)
30 struct module
*submodule
;
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
, ")");
48 add_modules_to_string(struct string
*string
, struct terminal
*term
)
50 struct module
*module
;
53 foreach_module (module
, builtin_modules
, i
) {
54 if (i
> 0) add_to_string(string
, ", ");
55 add_module_to_string(string
, module
, term
);
59 /* Wrap string on spaces starting at position @start_at, trying
60 * to keep lines undex @maxlen length */
62 wrap_string(struct string
*string
, int start_at
, int maxlen
)
64 unsigned char *pos
, *start_pos
;
65 unsigned char *last_pos
= NULL
;
67 assert(string
&& string
->source
&& start_at
< string
->length
);
68 if_assert_failed
return;
70 if (maxlen
<= 0) return;
72 pos
= start_pos
= &string
->source
[start_at
];
73 while ((pos
= strchr(pos
, ' '))) {
74 int len
= pos
- start_pos
;
80 if (last_pos
) *last_pos
= '\n';
81 pos
= start_pos
= last_pos
+ 1;
87 /* @more will add more information especially for info box. */
89 get_dyn_full_version(struct terminal
*term
, int more
)
91 static const unsigned char comma
[] = ", ";
94 if (!init_string(&string
)) return NULL
;
96 add_format_to_string(&string
, "ELinks %s", VERSION_STRING
);
98 add_char_to_string(&string
, more
? '\n' : ' ');
99 add_format_to_string(&string
, "%s", build_id
);
102 add_char_to_string(&string
, '\n');
103 add_format_to_string(&string
, _("Built on %s %s", term
),
104 build_date
, build_time
);
107 add_to_string(&string
, "\n\n");
108 add_to_string(&string
, _("Text WWW browser", term
));
111 string_concat(&string
,
113 _("Features:", term
), "\n",
119 #ifdef CONFIG_FASTMEM
120 comma
, _("Fastmem", term
),
122 #ifdef CONFIG_OWN_LIBC
123 comma
, _("Own Libc Routines", term
),
125 #ifndef CONFIG_BACKTRACE
126 comma
, _("No Backtrace", term
),
141 comma
, _("No mouse", term
),
146 #ifdef CONFIG_COMBINE
147 comma
, _("Combining characters", term
),
150 (unsigned char *) NULL
153 add_modules_to_string(&string
, term
);
157 unsigned char *last_newline
= strrchr(string
.source
, '\n');
160 start_at
= last_newline
- string
.source
+ 1;
163 wrap_string(&string
, start_at
, 72);
166 return string
.source
;
169 /* This one is used to prevent usage of straconcat() at backtrace time. */
171 init_static_version(void)
173 unsigned char *s
= get_dyn_full_version((struct terminal
*) NULL
, 0);
176 safe_strncpy(full_static_version
, s
, sizeof(full_static_version
));