Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
5acc10ff
Commit
5acc10ff
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added -p (pause on exit) and -q (quiet mode) options.
parent
4fe576f7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/jsexec.c
+44
-16
44 additions, 16 deletions
src/sbbs3/jsexec.c
with
44 additions
and
16 deletions
src/sbbs3/jsexec.c
+
44
−
16
View file @
5acc10ff
...
...
@@ -48,20 +48,46 @@ ulong js_max_bytes=JAVASCRIPT_MAX_BYTES;
ulong
js_context_stack
=
JAVASCRIPT_CONTEXT_STACK
;
FILE
*
confp
=
stdout
;
FILE
*
errfp
=
stderr
;
char
revision
[
16
];
BOOL
pause_on_exit
=
FALSE
;
void
banner
(
FILE
*
fp
)
{
fprintf
(
fp
,
"
\n
JSexec v%s%c-%s (rev %s) - "
"Execute Synchronet JavaScript Module
\n
"
,
VERSION
,
REVISION
,
PLATFORM_DESC
,
revision
);
}
void
usage
(
FILE
*
fp
)
{
banner
(
fp
);
fprintf
(
fp
,
"
\n
usage: jsexec [-opts] [path]module[.js] [args]
\n
"
"
\n
available opts:
\n\n
"
"
\t
-m <bytes> set maximum heap size (default: %lu bytes)
\n
"
"
\t
-s <bytes> set context stack size (default: %lu bytes)
\n
"
"
\t
-t <filename> send console output to stdout and filename
\n
"
"
\t
-e send error message to stdout instead of stderr
\n
"
"
\t
-q send console output to %s (quiet mode)
\n
"
"
\t
-e send error messages to console instead of stderr
\n
"
"
\t
-p wait for keypress (pause) on exit
\n
"
,
JAVASCRIPT_MAX_BYTES
,
JAVASCRIPT_CONTEXT_STACK
,
_PATH_DEVNULL
);
}
void
bail
(
int
code
)
{
if
(
pause_on_exit
)
{
fprintf
(
errfp
,
"
\n
Hit enter to continue..."
);
getchar
();
}
exit
(
code
);
}
static
JSBool
js_log
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
...
...
@@ -415,25 +441,17 @@ long js_exec(const char *fname, char** args)
int
main
(
int
argc
,
char
**
argv
)
{
char
error
[
512
];
char
revision
[
16
];
char
*
module
=
NULL
;
char
*
p
;
int
argn
;
sscanf
(
"$Revision$"
,
"%*s %s"
,
revision
);
fprintf
(
errfp
,
"
\n
JSexec v%s%c-%s (rev %s) - "
"Execute Synchronet JavaScript Module
\n
"
,
VERSION
,
REVISION
,
PLATFORM_DESC
,
revision
);
p
=
getenv
(
"SBBSCTRL"
);
if
(
p
==
NULL
)
{
fprintf
(
errfp
,
"
\n
SBBSCTRL environment variable not set.
\n
"
);
fprintf
(
errfp
,
"
\n
Example: SET SBBSCTRL=/sbbs/ctrl
\n
"
);
exit
(
1
);
bail
(
1
);
}
memset
(
&
scfg
,
0
,
sizeof
(
scfg
));
...
...
@@ -450,11 +468,17 @@ int main(int argc, char **argv)
js_context_stack
=
strtoul
(
argv
[
++
argn
],
NULL
,
0
);
break
;
case
'e'
:
errfp
=
stdout
;
errfp
=
confp
;
break
;
case
'q'
:
confp
=
fopen
(
_PATH_DEVNULL
,
"w"
);
break
;
case
'p'
:
pause_on_exit
=
TRUE
;
break
;
default:
usage
(
errfp
);
return
(
1
);
bail
(
1
);
}
continue
;
}
...
...
@@ -463,16 +487,18 @@ int main(int argc, char **argv)
if
(
module
==
NULL
)
{
usage
(
errfp
);
return
(
1
);
bail
(
1
);
}
banner
(
errfp
);
if
(
chdir
(
scfg
.
ctrl_dir
)
!=
0
)
fprintf
(
errfp
,
"!ERROR changing directory to: %s"
,
scfg
.
ctrl_dir
);
printf
(
"
\n
Loading configuration files from %s
\n
"
,
scfg
.
ctrl_dir
);
if
(
!
load_cfg
(
&
scfg
,
NULL
,
TRUE
,
error
))
{
fprintf
(
errfp
,
"!ERROR loading configuration files: %s
\n
"
,
error
);
exit
(
1
);
bail
(
1
);
}
prep_dir
(
scfg
.
data_dir
,
scfg
.
temp_dir
,
sizeof
(
scfg
.
temp_dir
));
...
...
@@ -481,10 +507,12 @@ int main(int argc, char **argv)
if
(
!
js_init
())
{
fprintf
(
errfp
,
"!JavaScript initialization failure
\n
"
);
return
(
1
);
bail
(
1
);
}
printf
(
"
\n
"
);
return
(
js_exec
(
module
,
&
argv
[
argn
]));
bail
(
js_exec
(
module
,
&
argv
[
argn
]));
return
(
-
1
);
/* never gets here */
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment