Retry only for https protocol
[elinks.git] / src / scripting / scripting.c
blob6d0b7f6957befd48fc0f71d24e486337521170bc
1 /* General scripting system functionality */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include "elinks.h"
9 #include "bfu/msgbox.h"
10 #include "intl/gettext/libintl.h"
11 #include "main/module.h"
12 #include "scripting/scripting.h"
13 #include "session/session.h"
14 #include "terminal/terminal.h"
15 #include "terminal/window.h"
18 /* Backends dynamic area: */
20 #include "scripting/guile/guile.h"
21 #include "scripting/lua/lua.h"
22 #include "scripting/perl/perl.h"
23 #include "scripting/python/python.h"
24 #include "scripting/ruby/ruby.h"
25 #include "scripting/smjs/smjs.h"
27 #ifdef HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
32 /* Error reporting. */
34 #if defined(CONFIG_SCRIPTING_RUBY) || defined(CONFIG_SCRIPTING_SPIDERMONKEY) || defined(CONFIG_SCRIPTING_PYTHON)
35 void
36 report_scripting_error(struct module *module, struct session *ses,
37 unsigned char *msg)
39 struct terminal *term;
40 struct string string;
42 if (!ses) {
43 term = get_default_terminal();
44 if (term == NULL) {
45 usrerror(gettext("[%s error] %s"),
46 gettext(module->name), msg);
47 sleep(3);
48 return;
51 } else {
52 term = ses->tab->term;
55 if (!init_string(&string))
56 return;
58 add_format_to_string(&string,
59 _("An error occurred while running a %s script", term),
60 _(module->name, term));
62 add_format_to_string(&string, ":\n\n%s", msg);
64 info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
65 N_("Browser scripting error"), ALIGN_LEFT, string.source);
67 #endif
70 static struct module *scripting_modules[] = {
71 #ifdef CONFIG_SCRIPTING_LUA
72 &lua_scripting_module,
73 #endif
74 #ifdef CONFIG_SCRIPTING_GUILE
75 &guile_scripting_module,
76 #endif
77 #ifdef CONFIG_SCRIPTING_PERL
78 &perl_scripting_module,
79 #endif
80 #ifdef CONFIG_SCRIPTING_PYTHON
81 &python_scripting_module,
82 #endif
83 #ifdef CONFIG_SCRIPTING_RUBY
84 &ruby_scripting_module,
85 #endif
86 #ifdef CONFIG_SCRIPTING_SPIDERMONKEY
87 &smjs_scripting_module,
88 #endif
89 NULL,
92 struct module scripting_module = struct_module(
93 /* name: */ N_("Scripting"),
94 /* options: */ NULL,
95 /* events: */ NULL,
96 /* submodules: */ scripting_modules,
97 /* data: */ NULL,
98 /* init: */ NULL,
99 /* done: */ NULL