2005-09-15 09:58:31 -04:00
|
|
|
/* General scripting system functionality */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "elinks.h"
|
|
|
|
|
2006-02-12 16:07:15 -05:00
|
|
|
#include "bfu/msgbox.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
#include "intl/gettext/libintl.h"
|
|
|
|
#include "main/module.h"
|
|
|
|
#include "scripting/scripting.h"
|
2005-10-20 22:07:43 -04:00
|
|
|
#include "session/session.h"
|
|
|
|
#include "terminal/terminal.h"
|
|
|
|
#include "terminal/window.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Backends dynamic area: */
|
|
|
|
|
|
|
|
#include "scripting/guile/guile.h"
|
|
|
|
#include "scripting/lua/lua.h"
|
|
|
|
#include "scripting/perl/perl.h"
|
|
|
|
#include "scripting/python/python.h"
|
|
|
|
#include "scripting/ruby/ruby.h"
|
2005-12-18 12:40:00 -05:00
|
|
|
#include "scripting/smjs/smjs.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2006-07-24 12:52:25 -04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2005-10-20 22:07:43 -04:00
|
|
|
/* Error reporting. */
|
|
|
|
|
2006-07-24 12:52:25 -04:00
|
|
|
#if defined(CONFIG_SCRIPTING_RUBY) || defined(CONFIG_SCRIPTING_SPIDERMONKEY) || defined(CONFIG_SCRIPTING_PYTHON)
|
2005-10-20 22:07:43 -04:00
|
|
|
void
|
|
|
|
report_scripting_error(struct module *module, struct session *ses,
|
|
|
|
unsigned char *msg)
|
|
|
|
{
|
|
|
|
struct terminal *term;
|
|
|
|
struct string string;
|
|
|
|
|
|
|
|
if (!ses) {
|
|
|
|
if (list_empty(terminals)) {
|
2007-03-22 01:55:59 -04:00
|
|
|
usrerror(gettext("[%s error] %s"),
|
|
|
|
gettext(module->name), msg);
|
2006-07-24 12:52:25 -04:00
|
|
|
sleep(3);
|
2005-10-20 22:07:43 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
term = terminals.next;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
term = ses->tab->term;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!init_string(&string))
|
|
|
|
return;
|
|
|
|
|
|
|
|
add_format_to_string(&string,
|
|
|
|
_("An error occurred while running a %s script", term),
|
2007-03-22 01:55:59 -04:00
|
|
|
_(module->name, term));
|
2005-10-20 22:07:43 -04:00
|
|
|
|
|
|
|
add_format_to_string(&string, ":\n\n%s", msg);
|
|
|
|
|
|
|
|
info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
|
|
|
|
N_("Browser scripting error"), ALIGN_LEFT, string.source);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
static struct module *scripting_modules[] = {
|
2006-01-11 08:06:13 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_LUA
|
2005-09-15 09:58:31 -04:00
|
|
|
&lua_scripting_module,
|
|
|
|
#endif
|
2006-01-11 08:10:41 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_GUILE
|
2005-09-15 09:58:31 -04:00
|
|
|
&guile_scripting_module,
|
|
|
|
#endif
|
2006-01-11 08:07:17 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_PERL
|
2005-09-15 09:58:31 -04:00
|
|
|
&perl_scripting_module,
|
|
|
|
#endif
|
2006-01-11 08:10:58 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_PYTHON
|
2005-09-15 09:58:31 -04:00
|
|
|
&python_scripting_module,
|
|
|
|
#endif
|
2006-01-11 08:10:51 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_RUBY
|
2005-09-15 09:58:31 -04:00
|
|
|
&ruby_scripting_module,
|
2005-10-20 14:38:01 -04:00
|
|
|
#endif
|
2006-01-11 08:14:11 -05:00
|
|
|
#ifdef CONFIG_SCRIPTING_SPIDERMONKEY
|
2005-12-18 12:40:00 -05:00
|
|
|
&smjs_scripting_module,
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct module scripting_module = struct_module(
|
|
|
|
/* name: */ N_("Scripting"),
|
|
|
|
/* options: */ NULL,
|
|
|
|
/* events: */ NULL,
|
|
|
|
/* submodules: */ scripting_modules,
|
|
|
|
/* data: */ NULL,
|
|
|
|
/* init: */ NULL,
|
|
|
|
/* done: */ NULL
|
|
|
|
);
|