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
d8525301
Commit
d8525301
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created methods: ascii_str (convert ex-ascii string to pure ascii) and
strip_exascii (remove all ex-ascii chars from string).
parent
e45e1caf
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/js_global.c
+41
-0
41 additions, 0 deletions
src/sbbs3/js_global.c
with
41 additions
and
0 deletions
src/sbbs3/js_global.c
+
41
−
0
View file @
d8525301
...
...
@@ -269,6 +269,26 @@ js_ascii(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return
(
JS_TRUE
);
}
static
JSBool
js_ascii_str
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
char
*
p
;
JSString
*
js_str
;
if
((
js_str
=
JS_ValueToString
(
cx
,
argv
[
0
]))
==
NULL
)
return
(
JS_FALSE
);
if
((
p
=
JS_GetStringBytes
(
js_str
))
==
NULL
)
return
(
JS_FALSE
);
ascii_str
(
p
);
js_str
=
JS_NewStringCopyZ
(
cx
,
p
);
*
rval
=
STRING_TO_JSVAL
(
js_str
);
return
(
JS_TRUE
);
}
static
JSBool
js_strip_ctrl
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
...
...
@@ -288,6 +308,25 @@ js_strip_ctrl(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
return
(
JS_TRUE
);
}
static
JSBool
js_strip_exascii
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
char
*
p
;
JSString
*
js_str
;
if
((
js_str
=
JS_ValueToString
(
cx
,
argv
[
0
]))
==
NULL
)
return
(
JS_FALSE
);
if
((
p
=
JS_GetStringBytes
(
js_str
))
==
NULL
)
return
(
JS_FALSE
);
strip_exascii
(
p
);
js_str
=
JS_NewStringCopyZ
(
cx
,
p
);
*
rval
=
STRING_TO_JSVAL
(
js_str
);
return
(
JS_TRUE
);
}
static
JSBool
js_fexist
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
...
...
@@ -570,7 +609,9 @@ static JSFunctionSpec js_global_functions[] = {
{
"crc32"
,
js_crc32
,
1
},
/* calculate 32-bit CRC of string */
{
"chksum"
,
js_chksum
,
1
},
/* calculate 32-bit chksum of string */
{
"ascii"
,
js_ascii
,
1
},
/* convert str to ascii-val or vice-versa */
{
"ascii_str"
,
js_ascii_str
,
1
},
/* convert ex-ascii in str to plain ascii */
{
"strip_ctrl"
,
js_strip_ctrl
,
1
},
/* strip ctrl chars from string */
{
"strip_exascii"
,
js_strip_exascii
,
1
},
/* strip ex-ascii chars from string */
{
"file_exists"
,
js_fexist
,
1
},
/* verify file existence */
{
"file_remove"
,
js_remove
,
1
},
/* delete a file */
{
"file_isdir"
,
js_isdir
,
1
},
/* check if directory */
...
...
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