mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[console.log] Global variable to store console_log_filename
This commit is contained in:
parent
4db2b42799
commit
bc7a1ae6ad
@ -71,6 +71,8 @@ static int interpreter_count;
|
||||
|
||||
static INIT_LIST_OF(struct string_list_item, allowed_urls);
|
||||
|
||||
char *console_log_filename;
|
||||
|
||||
static int
|
||||
is_prefix(char *prefix, char *url, int dl)
|
||||
{
|
||||
@ -449,12 +451,17 @@ static void
|
||||
init_ecmascript_module(struct module *module)
|
||||
{
|
||||
read_url_list();
|
||||
|
||||
if (elinks_home) {
|
||||
console_log_filename = straconcat(elinks_home, "/console.log", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
done_ecmascript_module(struct module *module)
|
||||
{
|
||||
free_string_list(&allowed_urls);
|
||||
mem_free_if(console_log_filename);
|
||||
}
|
||||
|
||||
static struct module *ecmascript_modules[] = {
|
||||
@ -464,8 +471,6 @@ static struct module *ecmascript_modules[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct module ecmascript_module = struct_module(
|
||||
/* name: */ N_("ECMAScript"),
|
||||
/* options: */ ecmascript_options,
|
||||
|
@ -109,6 +109,7 @@ void ecmascript_set_timeout2(struct ecmascript_interpreter *interpreter, JS::Han
|
||||
|
||||
int get_ecmascript_enable(struct ecmascript_interpreter *interpreter);
|
||||
|
||||
extern char *console_log_filename;
|
||||
extern struct module ecmascript_module;
|
||||
|
||||
#endif
|
||||
|
@ -78,19 +78,17 @@ console_log(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc != 1)
|
||||
if (argc != 1 || !console_log_filename)
|
||||
{
|
||||
args.rval().setBoolean(false);
|
||||
return(true);
|
||||
}
|
||||
|
||||
unsigned char *key= JS_EncodeString(ctx, args[0].toString());
|
||||
unsigned char *key = JS_EncodeString(ctx, args[0].toString());
|
||||
|
||||
char *log_fname = stracpy(elinks_home);
|
||||
add_to_strn(&log_fname,"console.log");
|
||||
FILE *f = fopen(console_log_filename, "a");
|
||||
|
||||
FILE *f = fopen(log_fname,"a");
|
||||
if (f)
|
||||
if (f)
|
||||
{
|
||||
fprintf(f, "%s\n", key);
|
||||
fclose(f);
|
||||
|
Loading…
Reference in New Issue
Block a user