Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
28a7c47c
Commit
28a7c47c
authored
Apr 23, 2014
by
deuce
Browse files
Clean up the help functions per Coverity by checking the return values of
f*().
parent
78468dd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
63 deletions
+86
-63
src/uifc/uifc32.c
src/uifc/uifc32.c
+50
-41
src/uifc/uifcx.c
src/uifc/uifcx.c
+36
-22
No files found.
src/uifc/uifc32.c
View file @
28a7c47c
...
...
@@ -2702,50 +2702,59 @@ static void help(void)
_setcursortype
(
_NOCURSOR
);
if
(
api
->
helpbuf
!=
NULL
)
strcpy
(
hbuf
,
api
->
helpbuf
);
else
{
if
((
fp
=
fopen
(
api
->
helpixbfile
,
"rb"
))
==
NULL
)
{
sprintf
(
hbuf
,
"
\2
ERROR
\2
Cannot open help index:
\r\n
%s"
,
api
->
helpixbfile
);
}
else
{
p
=
strrchr
(
helpfile
,
'/'
);
if
(
p
==
NULL
)
p
=
strrchr
(
helpfile
,
'\\'
);
if
(
p
==
NULL
)
p
=
helpfile
;
else
p
++
;
l
=-
1L
;
while
(
!
feof
(
fp
))
{
if
(
!
fread
(
str
,
12
,
1
,
fp
))
break
;
str
[
12
]
=
0
;
fread
(
&
line
,
sizeof
(
line
),
1
,
fp
);
if
(
stricmp
(
str
,
p
)
||
line
!=
helpline
)
{
fseek
(
fp
,
sizeof
(
l
),
SEEK_CUR
);
continue
;
}
fread
(
&
l
,
sizeof
(
l
),
1
,
fp
);
break
;
}
fclose
(
fp
);
if
(
l
==-
1L
)
sprintf
(
hbuf
,
"
\2
ERROR
\2
Cannot locate help key (%s:%u) in:
\r\n
"
" %s"
,
p
,
helpline
,
api
->
helpixbfile
);
else
{
if
((
fp
=
fopen
(
api
->
helpdatfile
,
"rb"
))
==
NULL
)
sprintf
(
hbuf
,
"
\2
ERROR
\2
Cannot open help file:
\r\n
%s"
,
api
->
helpdatfile
);
else
{
fseek
(
fp
,
l
,
SEEK_SET
);
fread
(
hbuf
,
HELPBUF_SIZE
,
1
,
fp
);
if
(
!
api
->
helpbuf
)
{
if
((
fp
=
fopen
(
api
->
helpixbfile
,
"rb"
))
==
NULL
)
sprintf
(
hbuf
,
"ERROR: Cannot open help index: %s"
,
api
->
helpixbfile
);
else
{
p
=
strrchr
(
helpfile
,
'/'
);
if
(
p
==
NULL
)
p
=
strrchr
(
helpfile
,
'\\'
);
if
(
p
==
NULL
)
p
=
helpfile
;
else
p
++
;
l
=-
1L
;
while
(
!
feof
(
fp
))
{
if
(
fread
(
str
,
12
,
1
,
fp
)
!=
1
)
break
;
str
[
12
]
=
0
;
if
(
fread
(
&
line
,
2
,
1
,
fp
)
!=
1
);
if
(
stricmp
(
str
,
p
)
||
line
!=
helpline
)
{
if
(
fseek
(
fp
,
4
,
SEEK_CUR
)
==
0
)
break
;
continue
;
}
if
(
fread
(
&
l
,
4
,
1
,
fp
)
!=
1
)
l
=-
1L
;
break
;
}
fclose
(
fp
);
if
(
l
==-
1L
)
sprintf
(
hbuf
,
"ERROR: Cannot locate help key (%s:%u) in: %s"
,
p
,
helpline
,
api
->
helpixbfile
);
else
{
if
((
fp
=
fopen
(
api
->
helpdatfile
,
"rb"
))
==
NULL
)
sprintf
(
hbuf
,
"ERROR: Cannot open help file: %s"
,
api
->
helpdatfile
);
else
{
if
(
fseek
(
fp
,
l
,
SEEK_SET
)
!=
0
)
{
sprintf
(
hbuf
,
"ERROR: Cannot seek to help key (%s:%u) at %ld in: %s"
,
p
,
helpline
,
l
,
api
->
helpixbfile
);
}
else
{
if
(
fread
(
hbuf
,
1
,
HELPBUF_SIZE
,
fp
)
<
1
)
{
sprintf
(
hbuf
,
"ERROR: Cannot read help key (%s:%u) at %ld in: %s"
,
p
,
helpline
,
l
,
api
->
helpixbfile
);
}
}
fclose
(
fp
);
}
}
}
showbuf
(
WIN_MID
|
WIN_HLP
,
0
,
0
,
76
,
api
->
scrn_len
,
"Online Help"
,
hbuf
,
NULL
,
NULL
);
}
else
{
showbuf
(
WIN_MID
|
WIN_HLP
,
0
,
0
,
76
,
api
->
scrn_len
,
"Online Help"
,
api
->
helpbuf
,
NULL
,
NULL
);
}
showbuf
(
WIN_MID
|
WIN_HLP
,
0
,
0
,
76
,
api
->
scrn_len
,
"Online Help"
,
hbuf
,
NULL
,
NULL
);
}
src/uifc/uifcx.c
View file @
28a7c47c
...
...
@@ -411,15 +411,19 @@ void help()
p
++
;
l
=-
1L
;
while
(
!
feof
(
fp
))
{
if
(
!
fread
(
str
,
12
,
1
,
fp
))
if
(
fread
(
str
,
12
,
1
,
fp
)
!=
1
)
break
;
str
[
12
]
=
0
;
fread
(
&
line
,
2
,
1
,
fp
);
if
(
fread
(
&
line
,
2
,
1
,
fp
)
!=
1
)
;
if
(
stricmp
(
str
,
p
)
||
line
!=
helpline
)
{
fseek
(
fp
,
4
,
SEEK_CUR
);
continue
;
}
fread
(
&
l
,
4
,
1
,
fp
);
break
;
}
if
(
fseek
(
fp
,
4
,
SEEK_CUR
)
==
0
)
break
;
continue
;
}
if
(
fread
(
&
l
,
4
,
1
,
fp
)
!=
1
)
l
=-
1L
;
break
;
}
fclose
(
fp
);
if
(
l
==-
1L
)
sprintf
(
hbuf
,
"ERROR: Cannot locate help key (%s:%u) in: %s"
...
...
@@ -429,21 +433,31 @@ void help()
sprintf
(
hbuf
,
"ERROR: Cannot open help file: %s"
,
api
->
helpdatfile
);
else
{
fseek
(
fp
,
l
,
SEEK_SET
);
fread
(
hbuf
,
HELPBUF_SIZE
,
1
,
fp
);
fclose
(
fp
);
}
}
}
if
(
fseek
(
fp
,
l
,
SEEK_SET
)
!=
0
)
{
sprintf
(
hbuf
,
"ERROR: Cannot seek to help key (%s:%u) at %ld in: %s"
,
p
,
helpline
,
l
,
api
->
helpixbfile
);
}
else
{
if
(
fread
(
hbuf
,
1
,
HELPBUF_SIZE
,
fp
)
<
1
)
{
sprintf
(
hbuf
,
"ERROR: Cannot read help key (%s:%u) at %ld in: %s"
,
p
,
helpline
,
l
,
api
->
helpixbfile
);
}
}
fclose
(
fp
);
}
}
}
uputs
(
hbuf
);
if
(
strlen
(
hbuf
)
>
200
)
{
printf
(
"Hit enter"
);
getstr
(
str
,
sizeof
(
str
)
-
1
);
}
}
else
{
uputs
(
api
->
helpbuf
);
if
(
strlen
(
api
->
helpbuf
)
>
200
)
{
printf
(
"Hit enter"
);
getstr
(
str
,
sizeof
(
str
)
-
1
);
}
}
else
strcpy
(
hbuf
,
api
->
helpbuf
);
uputs
(
hbuf
);
if
(
strlen
(
hbuf
)
>
200
)
{
printf
(
"Hit enter"
);
getstr
(
str
,
sizeof
(
str
)
-
1
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment