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
1f4dae0d
Commit
1f4dae0d
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Updated copyright date.
Better file length and read error checking in printfile() and printtail().
parent
52b3fcdb
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/prntfile.cpp
+40
-21
40 additions, 21 deletions
src/sbbs3/prntfile.cpp
with
40 additions
and
21 deletions
src/sbbs3/prntfile.cpp
+
40
−
21
View file @
1f4dae0d
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
0
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
3
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
...
...
@@ -48,7 +48,7 @@ void sbbs_t::printfile(char *str, long mode)
char
*
p
;
int
file
;
BOOL
wip
=
FALSE
,
rip
=
FALSE
,
html
=
FALSE
;
long
length
,
savcon
=
console
;
long
l
,
length
,
savcon
=
console
;
FILE
*
stream
;
p
=
strrchr
(
str
,
'.'
);
...
...
@@ -88,16 +88,25 @@ void sbbs_t::printfile(char *str, long mode)
if
(
mode
&
P_OPENCLOSE
)
{
length
=
filelength
(
file
);
if
(
length
<
0
)
{
close
(
file
);
errormsg
(
WHERE
,
ERR_CHK
,
str
,
length
);
return
;
}
if
((
buf
=
(
char
*
)
MALLOC
(
length
+
1L
))
==
NULL
)
{
close
(
file
);
console
=
savcon
;
errormsg
(
WHERE
,
ERR_ALLOC
,
str
,
length
+
1L
);
return
;
}
buf
[
lread
(
file
,
buf
,
length
)
]
=
0
;
l
=
lread
(
file
,
buf
,
length
);
fclose
(
stream
);
putmsg
(
buf
,
mode
);
FREE
((
char
*
)
buf
);
if
(
l
!=
length
)
errormsg
(
WHERE
,
ERR_READ
,
str
,
length
);
else
{
buf
[
l
]
=
0
;
putmsg
(
buf
,
mode
);
}
FREE
(
buf
);
}
else
{
putmsg_fp
(
stream
,
filelength
(
file
),
mode
);
...
...
@@ -114,9 +123,10 @@ void sbbs_t::printfile(char *str, long mode)
void
sbbs_t
::
printtail
(
char
*
str
,
int
lines
,
long
mode
)
{
char
HUGE16
*
buf
,
HUGE16
*
p
;
int
file
,
cur
=
0
;
ulong
length
,
l
;
char
*
buf
;
char
*
p
;
int
file
,
cur
=
0
;
long
length
,
l
;
if
(
mode
&
P_NOABORT
)
{
if
(
online
==
ON_REMOTE
)
{
...
...
@@ -136,31 +146,40 @@ void sbbs_t::printtail(char *str, int lines, long mode)
return
;
}
length
=
filelength
(
file
);
if
(
length
<
0
)
{
close
(
file
);
errormsg
(
WHERE
,
ERR_CHK
,
str
,
length
);
return
;
}
if
((
buf
=
(
char
*
)
MALLOC
(
length
+
1L
))
==
NULL
)
{
close
(
file
);
errormsg
(
WHERE
,
ERR_ALLOC
,
str
,
length
+
1L
);
return
;
}
l
=
lread
(
file
,
buf
,
length
);
buf
[
l
]
=
0
;
close
(
file
);
p
=
(
buf
+
l
)
-
1
;
if
(
*
p
==
LF
)
p
--
;
while
(
*
p
&&
p
>
buf
)
{
if
(
*
p
==
LF
)
cur
++
;
if
(
cur
>=
lines
)
{
p
++
;
break
;
if
(
l
!=
length
)
errormsg
(
WHERE
,
ERR_READ
,
str
,
length
);
else
{
buf
[
l
]
=
0
;
p
=
(
buf
+
l
)
-
1
;
if
(
*
p
==
LF
)
p
--
;
while
(
*
p
&&
p
>
buf
)
{
if
(
*
p
==
LF
)
cur
++
;
if
(
cur
>=
lines
)
{
p
++
;
break
;
}
p
--
;
}
p
--
;
p
utmsg
(
p
,
mode
);
}
putmsg
(
p
,
mode
);
if
(
mode
&
P_NOABORT
&&
online
==
ON_REMOTE
)
{
SYNC
;
rioctl
(
IOSM
|
ABORT
);
}
FREE
(
(
char
*
)
buf
);
FREE
(
buf
);
}
/****************************************************************************/
...
...
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