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
834e04a5
Commit
834e04a5
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
First stab at a get_all_msg_headers() method.
parent
fc8899f8
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_msgbase.c
+99
-0
99 additions, 0 deletions
src/sbbs3/js_msgbase.c
with
99 additions
and
0 deletions
src/sbbs3/js_msgbase.c
+
99
−
0
View file @
834e04a5
...
...
@@ -1486,6 +1486,101 @@ js_get_msg_header(JSContext *cx, uintN argc, jsval *arglist)
return
(
JS_TRUE
);
}
static
JSBool
js_get_all_msg_headers
(
JSContext
*
cx
,
uintN
argc
,
jsval
*
arglist
)
{
JSObject
*
obj
=
JS_THIS_OBJECT
(
cx
,
arglist
);
jsval
*
argv
=
JS_ARGV
(
cx
,
arglist
);
JSObject
*
hdrobj
;
JSBool
by_offset
=
JS_FALSE
;
jsrefcount
rc
;
privatemsg_t
*
p
;
private_t
*
priv
;
JSObject
*
proto
;
jsval
val
;
uint32_t
off
;
JSObject
*
array
;
JS_SET_RVAL
(
cx
,
arglist
,
JSVAL_NULL
);
if
((
priv
=
(
private_t
*
)
JS_GetPrivate
(
cx
,
obj
))
==
NULL
)
{
JS_ReportError
(
cx
,
getprivate_failure
,
WHERE
);
return
(
JS_FALSE
);
}
if
(
!
SMB_IS_OPEN
(
&
(
priv
->
smb
)))
return
(
JS_TRUE
);
array
=
JS_NewArrayObject
(
cx
,
0
,
NULL
);
JS_SET_RVAL
(
cx
,
arglist
,
OBJECT_TO_JSVAL
(
array
));
rc
=
JS_SUSPENDREQUEST
(
cx
);
if
((
priv
->
status
=
smb_locksmbhdr
(
&
(
priv
->
smb
)))
!=
SMB_SUCCESS
)
{
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
JS_RESUMEREQUEST
(
cx
,
rc
);
if
(
JS_GetProperty
(
cx
,
JS_GetGlobalObject
(
cx
),
"MsgBase"
,
&
val
)
&&
!
JSVAL_NULL_OR_VOID
(
val
))
{
JS_ValueToObject
(
cx
,
val
,
&
proto
);
if
(
JS_GetProperty
(
cx
,
proto
,
"HeaderPrototype"
,
&
val
)
&&
!
JSVAL_NULL_OR_VOID
(
val
))
JS_ValueToObject
(
cx
,
val
,
&
proto
);
else
proto
=
NULL
;
}
else
proto
=
NULL
;
for
(
off
=
0
;
off
<
priv
->
smb
.
status
.
total_msgs
;
off
++
)
{
if
((
p
=
(
privatemsg_t
*
)
malloc
(
sizeof
(
privatemsg_t
)))
==
NULL
)
{
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
JS_ReportError
(
cx
,
"malloc failed"
);
return
(
JS_FALSE
);
}
memset
(
p
,
0
,
sizeof
(
privatemsg_t
));
/* Parse boolean arguments first */
p
->
p
=
priv
;
p
->
expand_fields
=
JS_TRUE
;
/* This parameter defaults to true */
p
->
msg
.
offset
=
off
;
rc
=
JS_SUSPENDREQUEST
(
cx
);
if
((
priv
->
status
=
smb_getmsgidx
(
&
(
priv
->
smb
),
&
(
p
->
msg
)))
!=
SMB_SUCCESS
)
{
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
if
((
priv
->
status
=
smb_getmsghdr
(
&
(
priv
->
smb
),
&
(
p
->
msg
)))
!=
SMB_SUCCESS
)
{
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
JS_RESUMEREQUEST
(
cx
,
rc
);
if
((
hdrobj
=
JS_NewObject
(
cx
,
&
js_msghdr_class
,
proto
,
obj
))
==
NULL
)
{
smb_freemsgmem
(
&
(
p
->
msg
));
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
return
(
JS_TRUE
);
}
if
(
!
JS_SetPrivate
(
cx
,
hdrobj
,
p
))
{
JS_ReportError
(
cx
,
"JS_SetPrivate failed"
);
free
(
p
);
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
return
(
JS_FALSE
);
}
val
=
OBJECT_TO_JSVAL
(
hdrobj
);
JS_SetElement
(
cx
,
array
,
off
,
&
val
);
}
smb_unlocksmbhdr
(
&
(
priv
->
smb
));
return
(
JS_TRUE
);
}
static
JSBool
js_put_msg_header
(
JSContext
*
cx
,
uintN
argc
,
jsval
*
arglist
)
{
...
...
@@ -2268,6 +2363,10 @@ static jsSyncMethodSpec js_msgbase_functions[] = {
"if you will be re-writing the header later with <i>put_msg_header()</i>"
)
,
312
},
{
"get_all_msg_headers"
,
js_get_all_msg_headers
,
0
,
JSTYPE_ARRAY
,
JSDOCSTR
(
""
)
,
JSDOCSTR
(
"returns an array of all message headers."
)
,
316
},
{
"put_msg_header"
,
js_put_msg_header
,
2
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"[by_offset=<tt>false</tt>,] number, object header"
)
,
JSDOCSTR
(
"write a message header"
)
,
310
...
...
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