Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
sbbs
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
Deucе
sbbs
Commits
a364df43
Commit
a364df43
authored
4 years ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
js_file_area.cpp
parent
c894b500
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#894
failed
4 years ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/js_file_area.cpp
+166
-157
166 additions, 157 deletions
src/sbbs3/js_file_area.cpp
with
166 additions
and
157 deletions
src/sbbs3/js_file_area.cpp
+
166
−
157
View file @
a364df43
...
...
@@ -105,77 +105,82 @@ struct js_file_area_priv {
char
*
html_index_file
;
};
bool
DLLCALL
js_file_area_resolve
(
JSContext
*
cx
,
JS
::
HandleObject
areaobj
,
JS
::
HandleId
id
)
bool
DLLCALL
js_file_area_resolve
(
JSContext
*
cx
,
JS
::
HandleObject
areaobj
,
JS
::
HandleId
id
,
bool
*
resolved
)
{
char
vpath
[
MAX_PATH
+
1
];
JSObject
*
alllibs
;
JSObject
*
alldirs
;
JSObject
*
libobj
;
JSObject
*
dirobj
;
JSObject
*
alt_list
;
JSObject
*
lib_list
;
JSObject
*
dir_list
;
JSString
*
js_str
;
JS
::
Value
val
;
JS
::
Rooted
Object
alllibs
(
cx
)
;
JS
::
Rooted
Object
alldirs
(
cx
)
;
JS
::
Rooted
Object
libobj
(
cx
)
;
JS
::
Rooted
Object
dirobj
(
cx
)
;
JS
::
Rooted
Object
alt_list
(
cx
)
;
JS
::
Rooted
Object
lib_list
(
cx
)
;
JS
::
Rooted
Object
dir_list
(
cx
)
;
JS
::
Rooted
String
js_str
(
cx
)
;
JS
::
Rooted
Value
val
(
cx
)
;
int
lib_index
;
int
dir_index
;
uint
l
,
d
;
BOOL
is_op
;
bool
is_op
;
char
*
name
=
NULL
;
struct
js_file_area_priv
*
p
;
if
((
p
=
(
struct
js_file_area_priv
*
)
JS_GetPrivate
(
areaobj
))
==
NULL
)
return
false
;
if
(
id
!=
JSID_VOID
&&
id
!=
JSID_EMPTY
)
{
JS
::
Value
idval
;
if
(
!
JSID_
IS_
VOID
(
id
)
&&
!
JSID_
IS_
EMPTY
(
id
)
)
{
JS
::
Rooted
Value
idval
(
cx
)
;
JS_IdToValue
(
cx
,
id
,
&
idval
);
if
(
JSVAL_IS_STRING
(
idval
))
JSSTRING_TO_MSTRING
(
cx
,
JSVAL_TO_STRING
(
idval
),
name
,
NULL
);
if
(
idval
.
isString
(
))
JSSTRING_TO_MSTRING
(
cx
,
idval
.
toString
(
),
name
,
NULL
);
}
/* file_area.properties */
if
(
name
==
NULL
||
strcmp
(
name
,
"min_diskspace"
)
==
0
)
{
if
(
name
)
free
(
name
);
val
=
UINT_TO_JSVAL
(
p
->
cfg
->
min_dspace
);
JS_DefineProperty
(
cx
,
areaobj
,
"min_diskspace"
,
val
,
NULL
,
NULL
,
JSPROP_ENUMERATE
);
if
(
name
)
val
.
setNumber
((
uint32_t
)
p
->
cfg
->
min_dspace
);
JS_DefineProperty
(
cx
,
areaobj
,
"min_diskspace"
,
p
->
cfg
->
min_dspace
,
JSPROP_ENUMERATE
);
if
(
name
)
{
*
resolved
=
true
;
return
(
true
);
}
}
if
(
name
==
NULL
||
strcmp
(
name
,
"settings"
)
==
0
)
{
if
(
name
)
free
(
name
);
val
=
UINT_TO_JSVAL
(
p
->
cfg
->
file_misc
);
JS_DefineProperty
(
cx
,
areaobj
,
"settings"
,
val
,
NULL
,
NULL
,
JSPROP_ENUMERATE
);
if
(
name
)
JS_DefineProperty
(
cx
,
areaobj
,
"settings"
,
p
->
cfg
->
file_misc
,
JSPROP_ENUMERATE
);
if
(
name
)
{
*
resolved
=
true
;
return
(
true
);
}
}
if
(
name
==
NULL
||
strcmp
(
name
,
"alt_paths"
)
==
0
)
{
if
(
name
)
free
(
name
);
/* file_area.alt_paths[] */
if
((
alt_list
=
JS_NewArrayObject
(
cx
,
0
,
NULL
))
==
NULL
)
if
((
alt_list
=
JS_NewArrayObject
(
cx
,
0
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
alt_list
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"alt_paths"
,
&
val
))
val
.
setObject
(
*
alt_list
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"alt_paths"
,
val
))
return
false
;
for
(
l
=
0
;
l
<
p
->
cfg
->
altpaths
;
l
++
)
{
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
altpath
[
l
]))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
val
.
setString
(
js_str
);
if
(
!
JS_SetElement
(
cx
,
alt_list
,
l
,
&
val
))
if
(
!
JS_SetElement
(
cx
,
alt_list
,
l
,
val
))
return
false
;
}
if
(
name
)
if
(
name
)
{
*
resolved
=
true
;
return
(
true
);
}
}
#ifdef BUILD_JSDOCS
js_CreateArrayOfStrings
(
cx
,
areaobj
,
"_property_desc_list"
,
file_area_prop_desc
,
JSPROP_READONLY
);
...
...
@@ -184,18 +189,18 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
if
(
name
==
NULL
||
strcmp
(
name
,
"lib"
)
==
0
||
strcmp
(
name
,
"dir"
)
==
0
||
strcmp
(
name
,
"lib_list"
)
==
0
)
{
if
(
name
)
FREE_AND_NULL
(
name
);
if
((
alllibs
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
areaobj
))
==
NULL
)
if
((
alllibs
=
JS_New
Plain
Object
(
cx
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
alllibs
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"lib"
,
&
val
))
val
.
setObject
(
*
alllibs
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"lib"
,
val
))
return
false
;
if
((
alldirs
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
areaobj
))
==
NULL
)
if
((
alldirs
=
JS_New
Plain
Object
(
cx
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
alldirs
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"dir"
,
&
val
))
val
.
setObject
(
*
alldirs
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"dir"
,
val
))
return
false
;
#ifdef BUILD_JSDOCS
...
...
@@ -203,69 +208,69 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
#endif
/* file_area.lib_list[] */
if
((
lib_list
=
JS_NewArrayObject
(
cx
,
0
,
NULL
))
==
NULL
)
if
((
lib_list
=
JS_NewArrayObject
(
cx
,
0
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
lib_list
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"lib_list"
,
&
val
))
val
.
setObject
(
*
lib_list
);
if
(
!
JS_SetProperty
(
cx
,
areaobj
,
"lib_list"
,
val
))
return
false
;
for
(
l
=
0
;
l
<
p
->
cfg
->
total_libs
;
l
++
)
{
if
((
libobj
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
NULL
))
==
NULL
)
if
((
libobj
=
JS_New
Plain
Object
(
cx
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
libobj
);
val
.
setObject
(
*
libobj
);
lib_index
=-
1
;
if
(
p
->
user
==
NULL
||
chk_ar
(
p
->
cfg
,
p
->
cfg
->
lib
[
l
]
->
ar
,
p
->
user
,
p
->
client
))
{
if
(
!
JS_GetArrayLength
(
cx
,
lib_list
,
(
unsigned
*
)
&
lib_index
))
return
false
;
if
(
!
JS_SetElement
(
cx
,
lib_list
,
lib_index
,
&
val
))
if
(
!
JS_SetElement
(
cx
,
lib_list
,
lib_index
,
val
))
return
false
;
}
/* Add as property (associative array element) */
if
(
!
JS_DefineProperty
(
cx
,
alllibs
,
p
->
cfg
->
lib
[
l
]
->
sname
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
|
JSPROP_ENUMERATE
))
,
JSPROP_READONLY
|
JSPROP_ENUMERATE
))
return
false
;
val
=
INT_TO_JSVAL
(
lib_index
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"index"
,
&
val
))
val
.
setNumber
((
double
)
lib_index
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"index"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
l
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"number"
,
&
val
))
val
.
setNumber
(
l
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"number"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
lib
[
l
]
->
sname
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"name"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"name"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
lib
[
l
]
->
lname
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"description"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"description"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
lib
[
l
]
->
arstr
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"ars"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"ars"
,
val
))
return
false
;
sprintf
(
vpath
,
"/%s/%s"
,
p
->
cfg
->
lib
[
l
]
->
sname
,
p
->
html_index_file
);
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
vpath
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"link"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"link"
,
val
))
return
false
;
val
=
BOOLEAN_TO_JSVAL
(
lib_index
>=
0
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"can_access"
,
&
val
))
val
.
setBoolean
(
lib_index
>=
0
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"can_access"
,
val
))
return
false
;
#ifdef BUILD_JSDOCS
...
...
@@ -273,176 +278,176 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
#endif
/* dir_list[] */
if
((
dir_list
=
JS_NewArrayObject
(
cx
,
0
,
NULL
))
==
NULL
)
if
((
dir_list
=
JS_NewArrayObject
(
cx
,
0
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
dir_list
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"dir_list"
,
&
val
))
val
.
setObject
(
*
dir_list
);
if
(
!
JS_SetProperty
(
cx
,
libobj
,
"dir_list"
,
val
))
return
false
;
for
(
d
=
0
;
d
<
p
->
cfg
->
total_dirs
;
d
++
)
{
if
(
p
->
cfg
->
dir
[
d
]
->
lib
!=
l
)
continue
;
if
((
dirobj
=
JS_NewObject
(
cx
,
NULL
,
NULL
,
NULL
))
==
NULL
)
if
((
dirobj
=
JS_New
Plain
Object
(
cx
))
==
NULL
)
return
false
;
val
=
OBJECT_TO_JSVAL
(
dirobj
);
val
.
setObject
(
*
dirobj
);
dir_index
=-
1
;
if
(
p
->
user
==
NULL
||
chk_ar
(
p
->
cfg
,
p
->
cfg
->
dir
[
d
]
->
ar
,
p
->
user
,
p
->
client
))
{
if
(
!
JS_GetArrayLength
(
cx
,
dir_list
,
(
unsigned
*
)
&
dir_index
))
return
false
;
if
(
!
JS_SetElement
(
cx
,
dir_list
,
dir_index
,
&
val
))
if
(
!
JS_SetElement
(
cx
,
dir_list
,
dir_index
,
val
))
return
false
;
}
/* Add as property (associative array element) */
if
(
!
JS_DefineProperty
(
cx
,
alldirs
,
p
->
cfg
->
dir
[
d
]
->
code
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
|
JSPROP_ENUMERATE
))
,
JSPROP_READONLY
|
JSPROP_ENUMERATE
))
return
false
;
if
(
d
==
p
->
cfg
->
user_dir
&&
!
JS_DefineProperty
(
cx
,
areaobj
,
"user_dir"
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
))
,
JSPROP_READONLY
))
return
false
;
if
(
d
==
p
->
cfg
->
sysop_dir
&&
!
JS_DefineProperty
(
cx
,
areaobj
,
"sysop_dir"
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
))
,
JSPROP_READONLY
))
return
false
;
if
(
d
==
p
->
cfg
->
upload_dir
&&
!
JS_DefineProperty
(
cx
,
areaobj
,
"upload_dir"
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
))
,
JSPROP_READONLY
))
return
false
;
if
(
d
==
p
->
cfg
->
lib
[
l
]
->
offline_dir
&&
!
JS_DefineProperty
(
cx
,
libobj
,
"offline_dir"
,
val
,
NULL
,
NULL
,
JSPROP_READONLY
))
,
JSPROP_READONLY
))
return
false
;
val
=
INT_TO_JSVAL
(
dir_index
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"index"
,
&
val
))
val
.
setNumber
((
double
)
dir_index
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"index"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
d
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"number"
,
&
val
))
val
.
setNumber
(
d
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"number"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
lib_index
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_index"
,
&
val
))
val
.
setNumber
((
double
)
lib_index
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_index"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
lib
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_number"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
lib
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_number"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
lib
[
p
->
cfg
->
dir
[
d
]
->
lib
]
->
sname
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_name"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"lib_name"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
code
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"code"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"code"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
sname
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"name"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"name"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
lname
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"description"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"description"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
path
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"path"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"path"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
arstr
))
==
NULL
)
return
false
;
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"ars"
,
STRING_TO_JSVAL
(
js_str
)
,
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"ars"
,
js_str
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
ul_arstr
))
==
NULL
)
return
false
;
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"upload_ars"
,
STRING_TO_JSVAL
(
js_str
)
,
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"upload_ars"
,
js_str
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
dl_arstr
))
==
NULL
)
return
false
;
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"download_ars"
,
STRING_TO_JSVAL
(
js_str
)
,
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"download_ars"
,
js_str
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
ex_arstr
))
==
NULL
)
return
false
;
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"exempt_ars"
,
STRING_TO_JSVAL
(
js_str
)
,
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
/* exception here: Oct-15-2006 */
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"exempt_ars"
,
js_str
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
/* exception here: Oct-15-2006 */
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
op_arstr
))
==
NULL
)
return
false
;
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"operator_ars"
,
STRING_TO_JSVAL
(
js_str
)
,
NULL
,
NULL
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
if
(
!
JS_DefineProperty
(
cx
,
dirobj
,
"operator_ars"
,
js_str
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
exts
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"extensions"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"extensions"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
upload_sem
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"upload_sem"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"upload_sem"
,
val
))
return
false
;
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
p
->
cfg
->
dir
[
d
]
->
data_dir
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"data_dir"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"data_dir"
,
val
))
return
false
;
val
=
UINT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
misc
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"settings"
,
&
val
))
val
.
setNumber
(
p
->
cfg
->
dir
[
d
]
->
misc
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"settings"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
seqdev
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"seqdev"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
seqdev
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"seqdev"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
sort
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"sort"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
sort
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"sort"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
maxfiles
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"max_files"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
maxfiles
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"max_files"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
maxage
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"max_age"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
maxage
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"max_age"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
up_pct
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"upload_credit_pct"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
up_pct
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"upload_credit_pct"
,
val
))
return
false
;
val
=
INT_TO_JSVAL
(
p
->
cfg
->
dir
[
d
]
->
dn_pct
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"download_credit_pct"
,
&
val
))
val
.
setNumber
((
double
)
p
->
cfg
->
dir
[
d
]
->
dn_pct
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"download_credit_pct"
,
val
))
return
false
;
sprintf
(
vpath
,
"/%s/%s/%s"
...
...
@@ -451,8 +456,8 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
,
p
->
html_index_file
);
if
((
js_str
=
JS_NewStringCopyZ
(
cx
,
vpath
))
==
NULL
)
return
false
;
val
=
STRING_TO_JSVAL
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"link"
,
&
val
))
val
.
setString
(
js_str
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"link"
,
val
))
return
false
;
if
(
p
->
user
!=
NULL
...
...
@@ -463,53 +468,53 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
else
is_op
=
FALSE
;
val
=
BOOLEAN_TO_JSVAL
(
dir_index
>=
0
&&
lib_index
>=
0
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_access"
,
&
val
))
val
.
setBoolean
(
dir_index
>=
0
&&
lib_index
>=
0
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_access"
,
val
))
return
false
;
if
(
p
->
user
==
NULL
||
((
is_op
||
p
->
user
->
exempt
&
FLAG
(
'U'
)
||
chk_ar
(
p
->
cfg
,
p
->
cfg
->
dir
[
d
]
->
ul_ar
,
p
->
user
,
p
->
client
))
&&
!
(
p
->
user
->
rest
&
FLAG
(
'T'
))
&&
!
(
p
->
user
->
rest
&
FLAG
(
'U'
))))
val
=
JSVAL_TRUE
;
val
.
setBoolean
(
true
)
;
else
val
=
JSVAL_FALSE
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_upload"
,
&
val
))
val
.
setBoolean
(
false
)
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_upload"
,
val
))
return
false
;
if
(
p
->
user
==
NULL
||
(
chk_ar
(
p
->
cfg
,
p
->
cfg
->
dir
[
d
]
->
dl_ar
,
p
->
user
,
p
->
client
)
&&
!
(
p
->
user
->
rest
&
FLAG
(
'T'
))
&&
!
(
p
->
user
->
rest
&
FLAG
(
'D'
))))
val
=
JSVAL_TRUE
;
val
.
setBoolean
(
true
)
;
else
val
=
JSVAL_FALSE
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_download"
,
&
val
))
val
.
setBoolean
(
false
)
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"can_download"
,
val
))
return
false
;
if
(
is_download_free
(
p
->
cfg
,
d
,
p
->
user
,
p
->
client
))
val
=
JSVAL_TRUE
;
val
.
setBoolean
(
true
)
;
else
val
=
JSVAL_FALSE
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_exempt"
,
&
val
))
val
.
setBoolean
(
false
)
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_exempt"
,
val
))
return
false
;
if
(
is_op
)
val
=
JSVAL_TRUE
;
val
.
setBoolean
(
true
)
;
else
val
=
JSVAL_FALSE
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_operator"
,
&
val
))
val
.
setBoolean
(
false
)
;
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_operator"
,
val
))
return
false
;
val
=
BOOLEAN_TO_JSVAL
(
d
==
p
->
cfg
->
lib
[
l
]
->
offline_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_offline"
,
&
val
))
val
.
setBoolean
(
d
==
p
->
cfg
->
lib
[
l
]
->
offline_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_offline"
,
val
))
return
false
;
val
=
BOOLEAN_TO_JSVAL
(
d
==
p
->
cfg
->
upload_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_upload"
,
&
val
))
val
.
setBoolean
(
d
==
p
->
cfg
->
upload_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_upload"
,
val
))
return
false
;
val
=
BOOLEAN_TO_JSVAL
(
d
==
p
->
cfg
->
sysop_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_sysop"
,
&
val
))
val
.
setBoolean
(
d
==
p
->
cfg
->
sysop_dir
);
if
(
!
JS_SetProperty
(
cx
,
dirobj
,
"is_sysop"
,
val
))
return
false
;
#ifdef BUILD_JSDOCS
...
...
@@ -533,12 +538,14 @@ bool DLLCALL js_file_area_resolve(JSContext* cx, JS::HandleObject areaobj, JS::H
if
(
name
)
free
(
name
);
*
resolved
=
true
;
return
true
;
}
static
bool
js_file_area_enumerate
(
JSContext
*
cx
,
JS
::
HandleObject
obj
)
{
return
(
js_file_area_resolve
(
cx
,
obj
,
JS
::
JSID_VOIDHANDLE
));
bool
resolved
;
return
(
js_file_area_resolve
(
cx
,
obj
,
JSID_VOIDHANDLE
,
&
resolved
));
}
static
void
...
...
@@ -554,26 +561,30 @@ js_file_area_finalize(JSFreeOp *fop, JSObject *obj)
JS_SetPrivate
(
obj
,
NULL
);
}
static
JSClassOps
js_file_area_class_ops
=
{
NULL
/* addProperty */
,
NULL
/* delProperty */
,
NULL
/* getProperty */
,
NULL
/* setProperty */
,
js_file_area_enumerate
/* enumerate */
,
js_file_area_resolve
/* resolve */
,
NULL
/* convert */
,
js_file_area_finalize
/* finalize */
};
static
JSClass
js_file_area_class
=
{
"FileArea"
/* name */
,
JSCLASS_HAS_PRIVATE
/* flags */
,
JS_PropertyStub
/* addProperty */
,
JS_DeletePropertyStub
/* delProperty */
,
JS_PropertyStub
/* getProperty */
,
JS_StrictPropertyStub
/* setProperty */
,
js_file_area_enumerate
/* enumerate */
,
js_file_area_resolve
/* resolve */
,
JS_ConvertStub
/* convert */
,
js_file_area_finalize
/* finalize */
,
&
js_file_area_class_ops
/* cOps */
};
DLLEXPORT
JSObject
*
DLLCALL
js_CreateFileAreaObject
(
JSContext
*
cx
,
JSObject
*
parent
,
scfg_t
*
cfg
,
user_t
*
user
,
client_t
*
client
,
char
*
html_index_file
)
{
JSObject
*
obj
;
DLLEXPORT
JS
::
HandleObject
DLLCALL
js_CreateFileAreaObject
(
JSContext
*
cx
,
JS
::
HandleObject
parent
,
scfg_t
*
cfg
,
user_t
*
user
,
client_t
*
client
,
char
*
html_index_file
)
{
JS
::
RootedObject
obj
(
cx
);
struct
js_file_area_priv
*
p
;
obj
=
JS_DefineObject
(
cx
,
parent
,
"file_area"
,
&
js_file_area_class
,
NULL
obj
=
JS_DefineObject
(
cx
,
parent
,
"file_area"
,
&
js_file_area_class
,
JSPROP_ENUMERATE
|
JSPROP_READONLY
);
if
(
obj
==
NULL
)
...
...
@@ -587,9 +598,7 @@ DLLEXPORT JSObject* DLLCALL js_CreateFileAreaObject(JSContext* cx, JSObject* par
p
->
cfg
=
cfg
;
p
->
user
=
user
;
p
->
client
=
client
;
if
(
html_index_file
==
NULL
)
html_index_file
=
""
;
p
->
html_index_file
=
strdup
(
html_index_file
);
p
->
html_index_file
=
strdup
(
html_index_file
?
html_index_file
:
""
);
JS_SetPrivate
(
obj
,
p
);
...
...
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