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
f76520d4
Commit
f76520d4
authored
16 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
sbbs.editfile() now returns bool.
parent
4264b42c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/sbbs3/js_console.cpp
+2
-2
2 additions, 2 deletions
src/sbbs3/js_console.cpp
src/sbbs3/sbbs.h
+1
-1
1 addition, 1 deletion
src/sbbs3/sbbs.h
src/sbbs3/writemsg.cpp
+16
-14
16 additions, 14 deletions
src/sbbs3/writemsg.cpp
with
19 additions
and
17 deletions
src/sbbs3/js_console.cpp
+
2
−
2
View file @
f76520d4
...
...
@@ -1005,7 +1005,7 @@ js_editfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
cstr
=
JS_GetStringBytes
(
str
);
rc
=
JS_SUSPENDREQUEST
(
cx
);
sbbs
->
editfile
(
JS_GetStringBytes
(
str
));
*
rval
=
BOOLEAN_TO_JSVAL
(
sbbs
->
editfile
(
JS_GetStringBytes
(
str
))
)
;
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
...
...
@@ -1514,7 +1514,7 @@ static jsSyncMethodSpec js_console_functions[] = {
,
JSDOCSTR
(
"print last x lines of file with optional mode"
)
,
310
},
{
"editfile"
,
js_editfile
,
1
,
JSTYPE_
VOID
,
JSDOCSTR
(
"filename"
)
{
"editfile"
,
js_editfile
,
1
,
JSTYPE_
BOOLEAN
,
JSDOCSTR
(
"filename"
)
,
JSDOCSTR
(
"edit/create a text file using the user's preferred message editor"
)
,
310
},
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/sbbs.h
+
1
−
1
View file @
f76520d4
...
...
@@ -476,7 +476,7 @@ public:
void
forwardmail
(
smbmsg_t
*
msg
,
int
usernum
);
void
removeline
(
char
*
str
,
char
*
str2
,
char
num
,
char
skip
);
ulong
msgeditor
(
char
*
buf
,
const
char
*
top
,
char
*
title
);
void
editfile
(
char
*
path
);
bool
editfile
(
char
*
path
);
int
loadmsg
(
smbmsg_t
*
msg
,
ulong
number
);
ushort
chmsgattr
(
ushort
attr
);
void
show_msgattr
(
ushort
attr
);
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/writemsg.cpp
+
16
−
14
View file @
f76520d4
...
...
@@ -953,7 +953,7 @@ ulong sbbs_t::msgeditor(char *buf, const char *top, char *title)
/****************************************************************************/
/* Edits an existing file or creates a new one in MSG format */
/****************************************************************************/
void
sbbs_t
::
editfile
(
char
*
fname
)
bool
sbbs_t
::
editfile
(
char
*
fname
)
{
char
*
buf
,
path
[
MAX_PATH
+
1
];
char
msgtmp
[
MAX_PATH
+
1
];
...
...
@@ -990,18 +990,18 @@ void sbbs_t::editfile(char *fname)
}
CLS
;
rioctl
(
IOCM
|
PAUSE
|
ABORT
);
if
(
external
(
cmdstr
(
cfg
.
xedit
[
useron
.
xedit
-
1
]
->
rcmd
,
msgtmp
,
nulstr
,
NULL
),
mode
,
cfg
.
node_dir
)
==
0
)
{
if
(
external
(
cmdstr
(
cfg
.
xedit
[
useron
.
xedit
-
1
]
->
rcmd
,
msgtmp
,
nulstr
,
NULL
),
mode
,
cfg
.
node_dir
)
!=
0
)
return
false
;
l
=
process_edited_file
(
msgtmp
,
path
,
/* mode: */
0
,
&
lines
);
SAFEPRINTF4
(
str
,
"%s created or edited file: %s (%u bytes, %u lines)"
,
useron
.
alias
,
path
,
l
,
lines
);
logline
(
nulstr
,
str
);
}
rioctl
(
IOSM
|
PAUSE
|
ABORT
);
return
;
return
true
;
}
if
((
buf
=
(
char
*
)
malloc
(
maxlines
*
MAX_LINE_LEN
))
==
NULL
)
{
errormsg
(
WHERE
,
ERR_ALLOC
,
nulstr
,
maxlines
*
MAX_LINE_LEN
);
return
;
return
false
;
}
if
((
file
=
nopen
(
fname
,
O_RDONLY
))
!=-
1
)
{
length
=
filelength
(
file
);
...
...
@@ -1011,13 +1011,13 @@ void sbbs_t::editfile(char *fname)
attr
(
cfg
.
color
[
clr_err
]);
bprintf
(
"
\7\r\n
File size (%lu bytes) is larger than %lu (maxlines: %lu).
\r\n
"
,
length
,
(
ulong
)
maxlines
*
MAX_LINE_LEN
,
maxlines
);
return
;
return
false
;
}
if
(
read
(
file
,
buf
,
length
)
!=
length
)
{
close
(
file
);
free
(
buf
);
errormsg
(
WHERE
,
ERR_READ
,
fname
,
length
);
return
;
return
false
;
}
buf
[
length
]
=
0
;
close
(
file
);
...
...
@@ -1028,13 +1028,13 @@ void sbbs_t::editfile(char *fname)
}
if
(
!
msgeditor
(
buf
,
nulstr
,
nulstr
))
{
free
(
buf
);
return
;
return
false
;
}
bputs
(
text
[
Saving
]);
if
((
stream
=
fnopen
(
NULL
,
fname
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
))
==
NULL
)
{
errormsg
(
WHERE
,
ERR_OPEN
,
fname
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
);
free
(
buf
);
return
;
return
false
;
}
l
=
process_edited_text
(
buf
,
stream
,
/* mode: */
0
,
&
lines
);
bprintf
(
text
[
SavedNBytes
],
l
,
lines
);
...
...
@@ -1043,6 +1043,7 @@ void sbbs_t::editfile(char *fname)
SAFEPRINTF4
(
str
,
"%s created or edited file: %s (%u bytes, %u lines)"
,
useron
.
alias
,
fname
,
l
,
lines
);
logline
(
nulstr
,
str
);
return
true
;
}
/*************************/
...
...
@@ -1264,7 +1265,8 @@ void sbbs_t::editmsg(smbmsg_t *msg, uint subnum)
msg_tmp_fname
(
useron
.
xedit
,
msgtmp
,
sizeof
(
msgtmp
));
removecase
(
msgtmp
);
msgtotxt
(
msg
,
msgtmp
,
0
,
1
);
editfile
(
msgtmp
);
if
(
!
editfile
(
msgtmp
))
return
;
length
=
flength
(
msgtmp
);
if
(
length
<
1L
)
return
;
...
...
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