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
cc9880fb
Commit
cc9880fb
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Moved global object class definition, methods, constructor into globobj.c
parent
9ed4eb00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sysobj.c
+6
-85
6 additions, 85 deletions
src/sbbs3/sysobj.c
with
6 additions
and
85 deletions
src/sbbs3/sysobj.c
+
6
−
85
View file @
cc9880fb
...
...
@@ -39,83 +39,6 @@
#ifdef JAVASCRIPT
static
scfg_t
*
scfg
;
static
JSBool
js_load
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
char
path
[
MAX_PATH
+
1
];
uintN
i
;
JSString
*
str
;
const
char
*
filename
;
JSScript
*
script
;
JSBool
ok
;
jsval
result
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
str
=
JS_ValueToString
(
cx
,
argv
[
i
]);
if
(
!
str
)
return
JS_FALSE
;
argv
[
i
]
=
STRING_TO_JSVAL
(
str
);
filename
=
JS_GetStringBytes
(
str
);
errno
=
0
;
if
(
!
strchr
(
filename
,
BACKSLASH
))
sprintf
(
path
,
"%s%s"
,
scfg
->
exec_dir
,
filename
);
else
strcpy
(
path
,
filename
);
script
=
JS_CompileFile
(
cx
,
obj
,
path
);
if
(
!
script
)
ok
=
JS_FALSE
;
else
{
ok
=
JS_ExecuteScript
(
cx
,
obj
,
script
,
&
result
);
JS_DestroyScript
(
cx
,
script
);
}
if
(
!
ok
)
return
JS_FALSE
;
}
return
JS_TRUE
;
}
static
JSBool
js_format
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
char
tmp
[
1024
];
uintN
i
;
JSString
*
fmt
;
JSString
*
str
;
va_list
arglist
[
64
];
fmt
=
JS_ValueToString
(
cx
,
argv
[
0
]);
if
(
!
fmt
)
return
JS_FALSE
;
for
(
i
=
1
;
i
<
argc
&&
i
<
sizeof
(
arglist
)
/
sizeof
(
arglist
[
0
]);
i
++
)
{
if
(
JSVAL_IS_STRING
(
argv
[
i
]))
{
str
=
JS_ValueToString
(
cx
,
argv
[
i
]);
if
(
!
str
)
return
JS_FALSE
;
arglist
[
i
-
1
]
=
JS_GetStringBytes
(
str
);
}
else
if
(
JSVAL_IS_INT
(
argv
[
i
]))
arglist
[
i
-
1
]
=
(
char
*
)
JSVAL_TO_INT
(
argv
[
i
]);
else
arglist
[
i
-
1
]
=
NULL
;
}
vsprintf
(
tmp
,
JS_GetStringBytes
(
fmt
),(
char
*
)
arglist
);
str
=
JS_NewStringCopyZ
(
cx
,
tmp
);
*
rval
=
STRING_TO_JSVAL
(
str
);
return
JS_TRUE
;
}
static
JSFunctionSpec
js_global_functions
[]
=
{
{
"load"
,
js_load
,
1
},
/* Load and execute a javascript file */
{
"format"
,
js_format
,
1
},
/* return a formatted string (ala printf) */
{
0
}
};
/* System Object Properites */
enum
{
SYS_PROP_NAME
...
...
@@ -400,19 +323,16 @@ JSObject* DLLCALL js_CreateSystemObject(scfg_t* cfg, JSContext* cx, JSObject* pa
JSObject
*
sysobj
;
JSObject
*
statsobj
;
scfg
=
cfg
;
/* for js_load() */
if
(
!
JS_DefineFunctions
(
cx
,
parent
,
js_global_functions
))
return
(
NULL
);
sysobj
=
JS_DefineObject
(
cx
,
parent
,
"system"
,
&
js_system_class
,
NULL
,
0
);
if
(
sysobj
==
NULL
)
return
(
NULL
);
JS_SetPrivate
(
cx
,
sysobj
,
cfg
);
/* Store a pointer to scfg_t */
if
(
!
JS_SetPrivate
(
cx
,
sysobj
,
cfg
))
/* Store a pointer to scfg_t */
return
(
NULL
);
JS_DefineProperties
(
cx
,
sysobj
,
js_system_properties
);
if
(
!
JS_DefineProperties
(
cx
,
sysobj
,
js_system_properties
))
return
(
NULL
);
statsobj
=
JS_DefineObject
(
cx
,
sysobj
,
"stats"
,
&
js_sysstats_class
,
NULL
,
0
);
...
...
@@ -421,7 +341,8 @@ JSObject* DLLCALL js_CreateSystemObject(scfg_t* cfg, JSContext* cx, JSObject* pa
JS_SetPrivate
(
cx
,
statsobj
,
cfg
);
/* Store a pointer to scfg_t */
JS_DefineProperties
(
cx
,
statsobj
,
js_sysstats_properties
);
if
(
!
JS_DefineProperties
(
cx
,
statsobj
,
js_sysstats_properties
))
return
(
NULL
);
return
(
sysobj
);
}
...
...
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