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
a00548ec
Commit
a00548ec
authored
1 year ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
BOOL->bool conversion
parent
1575cef0
No related branches found
No related tags found
No related merge requests found
Pipeline
#5368
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/comio/comio.h
+15
-15
15 additions, 15 deletions
src/comio/comio.h
src/comio/comio_nix.c
+33
-33
33 additions, 33 deletions
src/comio/comio_nix.c
src/comio/comio_win32.c
+18
-18
18 additions, 18 deletions
src/comio/comio_win32.c
with
66 additions
and
66 deletions
src/comio/comio.h
+
15
−
15
View file @
a00548ec
...
...
@@ -23,7 +23,7 @@
#define _COMIO_H
#include
<limits.h>
/* INT_MAX */
#include
<gen_defs.h>
/*
BOOL
*/
#include
<gen_defs.h>
/*
bool
*/
#define COM_ERROR -1
#define COM_INFINITE_TIMEOUT INT_MIN
...
...
@@ -99,29 +99,29 @@ extern "C" {
COMIOEXPORT
char
*
comVersion
(
char
*
str
,
size_t
len
);
COMIOEXPORT
COM_HANDLE
comOpen
(
const
char
*
device
);
COMIOEXPORT
BOOL
comClose
(
COM_HANDLE
);
COMIOEXPORT
bool
comClose
(
COM_HANDLE
);
COMIOEXPORT
long
comGetBaudRate
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comSetBaudRate
(
COM_HANDLE
,
ulong
rate
);
COMIOEXPORT
bool
comSetBaudRate
(
COM_HANDLE
,
ulong
rate
);
COMIOEXPORT
int
comGetFlowControl
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comSetFlowControl
(
COM_HANDLE
,
int
);
COMIOEXPORT
bool
comSetFlowControl
(
COM_HANDLE
,
int
);
COMIOEXPORT
int
comGetModemStatus
(
COM_HANDLE
);
COMIOEXPORT
int
comRaiseDTR
(
COM_HANDLE
);
COMIOEXPORT
int
comLowerDTR
(
COM_HANDLE
);
COMIOEXPORT
int
comRaiseRTS
(
COM_HANDLE
);
COMIOEXPORT
int
comLowerRTS
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comWriteByte
(
COM_HANDLE
,
BYTE
);
COMIOEXPORT
bool
comRaiseDTR
(
COM_HANDLE
);
COMIOEXPORT
bool
comLowerDTR
(
COM_HANDLE
);
COMIOEXPORT
bool
comRaiseRTS
(
COM_HANDLE
);
COMIOEXPORT
bool
comLowerRTS
(
COM_HANDLE
);
COMIOEXPORT
bool
comWriteByte
(
COM_HANDLE
,
BYTE
);
COMIOEXPORT
int
comWriteBuf
(
COM_HANDLE
,
const
BYTE
*
,
size_t
buflen
);
COMIOEXPORT
int
comWriteString
(
COM_HANDLE
,
const
char
*
);
COMIOEXPORT
BOOL
comReadByte
(
COM_HANDLE
,
BYTE
*
);
COMIOEXPORT
bool
comReadByte
(
COM_HANDLE
,
BYTE
*
);
COMIOEXPORT
size_t
comReadBuf
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
,
const
char
*
terminators
,
int
timeout
/* in milliseconds */
);
COMIOEXPORT
size_t
comReadLine
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
,
int
timeout
/* in milliseconds */
);
COMIOEXPORT
BOOL
comPurgeInput
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comPurgeOutput
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comDrainOutput
(
COM_HANDLE
);
COMIOEXPORT
BOOL
comSetParity
(
COM_HANDLE
,
BOOL
enable
,
BOOL
odd
);
COMIOEXPORT
BOOL
comSetBits
(
COM_HANDLE
,
size_t
byteSize
,
size_t
stopBits
);
COMIOEXPORT
bool
comPurgeInput
(
COM_HANDLE
);
COMIOEXPORT
bool
comPurgeOutput
(
COM_HANDLE
);
COMIOEXPORT
bool
comDrainOutput
(
COM_HANDLE
);
COMIOEXPORT
bool
comSetParity
(
COM_HANDLE
,
bool
enable
,
bool
odd
);
COMIOEXPORT
bool
comSetBits
(
COM_HANDLE
,
size_t
byteSize
,
size_t
stopBits
);
#if defined(__cplusplus)
}
...
...
This diff is collapsed.
Click to expand it.
src/comio/comio_nix.c
+
33
−
33
View file @
a00548ec
...
...
@@ -245,10 +245,10 @@ Fun snippet from the FreeBSD manpage:
return
handle
;
}
BOOL
comClose
(
COM_HANDLE
handle
)
bool
comClose
(
COM_HANDLE
handle
)
{
if
(
handle
==
COM_HANDLE_INVALID
)
return
FALSE
;
return
false
;
return
(
!
close
(
handle
));
}
...
...
@@ -270,19 +270,19 @@ long comGetBaudRate(COM_HANDLE handle)
return
((
long
)(
in
>
out
?
in
:
out
));
}
BOOL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
bool
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
{
struct
termios
t
;
if
(
tcgetattr
(
handle
,
&
t
))
return
FALSE
;
return
false
;
cfsetispeed
(
&
t
,
rate_to_macro
(
rate
));
cfsetospeed
(
&
t
,
rate_to_macro
(
rate
));
if
(
tcsetattr
(
handle
,
TCSANOW
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
return
TRUE
;
return
true
;
}
int
comGetFlowControl
(
COM_HANDLE
handle
)
...
...
@@ -291,7 +291,7 @@ int comGetFlowControl(COM_HANDLE handle)
struct
termios
t
;
if
(
tcgetattr
(
handle
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
if
((
t
.
c_cflag
&
CTSRTS_FLOW_CFLAGS
)
==
CTSRTS_FLOW_CFLAGS
)
ret
|=
COM_FLOW_CONTROL_RTS_CTS
;
...
...
@@ -301,12 +301,12 @@ int comGetFlowControl(COM_HANDLE handle)
return
ret
;
}
BOOL
comSetFlowControl
(
COM_HANDLE
handle
,
int
modes
)
bool
comSetFlowControl
(
COM_HANDLE
handle
,
int
modes
)
{
struct
termios
t
;
if
(
tcgetattr
(
handle
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
if
(
modes
&
COM_FLOW_CONTROL_RTS_CTS
)
t
.
c_cflag
|=
CTSRTS_FLOW_CFLAGS
;
...
...
@@ -319,17 +319,17 @@ BOOL comSetFlowControl(COM_HANDLE handle, int modes)
t
.
c_iflag
&=
~
XONXOFF_FLOW_IFLAGS
;
if
(
tcsetattr
(
handle
,
TCSANOW
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
return
TRUE
;
return
true
;
}
BOOL
comSetParity
(
COM_HANDLE
handle
,
BOOL
enable
,
BOOL
odd
)
bool
comSetParity
(
COM_HANDLE
handle
,
bool
enable
,
bool
odd
)
{
struct
termios
t
;
if
(
tcgetattr
(
handle
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
if
(
enable
)
{
t
.
c_cflag
|=
PARENB
;
...
...
@@ -341,17 +341,17 @@ BOOL comSetParity(COM_HANDLE handle, BOOL enable, BOOL odd)
t
.
c_cflag
&=
~
(
PARENB
|
PARODD
);
if
(
tcsetattr
(
handle
,
TCSANOW
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
return
TRUE
;
return
true
;
}
BOOL
comSetBits
(
COM_HANDLE
handle
,
size_t
byteSize
,
size_t
stopBits
)
bool
comSetBits
(
COM_HANDLE
handle
,
size_t
byteSize
,
size_t
stopBits
)
{
struct
termios
t
;
if
(
tcgetattr
(
handle
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
t
.
c_cflag
&=
~
CSIZE
;
switch
(
byteSize
)
{
...
...
@@ -374,9 +374,9 @@ BOOL comSetBits(COM_HANDLE handle, size_t byteSize, size_t stopBits)
t
.
c_cflag
&=
~
CSTOPB
;
if
(
tcsetattr
(
handle
,
TCSANOW
,
&
t
)
==-
1
)
return
FALSE
;
return
false
;
return
TRUE
;
return
true
;
}
int
comGetModemStatus
(
COM_HANDLE
handle
)
...
...
@@ -389,33 +389,33 @@ int comGetModemStatus(COM_HANDLE handle)
return
status
;
}
static
BOOL
comSetFlags
(
COM_HANDLE
handle
,
int
flags
,
BOOL
set
)
static
bool
comSetFlags
(
COM_HANDLE
handle
,
int
flags
,
bool
set
)
{
int
cmd
=
set
?
TIOCMBIS
:
TIOCMBIC
;
return
(
ioctl
(
handle
,
cmd
,
&
flags
)
==
0
);
}
BOOL
comRaiseDTR
(
COM_HANDLE
handle
)
bool
comRaiseDTR
(
COM_HANDLE
handle
)
{
return
comSetFlags
(
handle
,
TIOCM_DTR
,
TRUE
);
return
comSetFlags
(
handle
,
TIOCM_DTR
,
true
);
}
BOOL
comLowerDTR
(
COM_HANDLE
handle
)
bool
comLowerDTR
(
COM_HANDLE
handle
)
{
return
comSetFlags
(
handle
,
TIOCM_DTR
,
FALSE
);
return
comSetFlags
(
handle
,
TIOCM_DTR
,
false
);
}
BOOL
comRaiseRTS
(
COM_HANDLE
handle
)
bool
comRaiseRTS
(
COM_HANDLE
handle
)
{
return
comSetFlags
(
handle
,
TIOCM_RTS
,
TRUE
);
return
comSetFlags
(
handle
,
TIOCM_RTS
,
true
);
}
BOOL
comLowerRTS
(
COM_HANDLE
handle
)
bool
comLowerRTS
(
COM_HANDLE
handle
)
{
return
comSetFlags
(
handle
,
TIOCM_RTS
,
FALSE
);
return
comSetFlags
(
handle
,
TIOCM_RTS
,
false
);
}
BOOL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
bool
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
{
return
(
write
(
handle
,
&
ch
,
1
)
==
1
);
}
...
...
@@ -433,22 +433,22 @@ int comWriteString(COM_HANDLE handle, const char* str)
return
comWriteBuf
(
handle
,
(
BYTE
*
)
str
,
strlen
(
str
));
}
BOOL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
bool
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
{
return
(
read
(
handle
,
ch
,
1
)
==
1
);
}
BOOL
comPurgeInput
(
COM_HANDLE
handle
)
bool
comPurgeInput
(
COM_HANDLE
handle
)
{
return
(
tcflush
(
handle
,
TCIFLUSH
)
==
0
);
}
BOOL
comPurgeOutput
(
COM_HANDLE
handle
)
bool
comPurgeOutput
(
COM_HANDLE
handle
)
{
return
(
tcflush
(
handle
,
TCOFLUSH
)
==
0
);
}
BOOL
comDrainOutput
(
COM_HANDLE
handle
)
bool
comDrainOutput
(
COM_HANDLE
handle
)
{
return
(
tcdrain
(
handle
)
==
0
);
}
This diff is collapsed.
Click to expand it.
src/comio/comio_win32.c
+
18
−
18
View file @
a00548ec
...
...
@@ -79,7 +79,7 @@ COM_HANDLE comOpen(const char* device)
return
handle
;
}
BOOL
comClose
(
COM_HANDLE
handle
)
bool
comClose
(
COM_HANDLE
handle
)
{
return
CloseHandle
(
handle
);
}
...
...
@@ -94,12 +94,12 @@ long comGetBaudRate(COM_HANDLE handle)
return
dcb
.
BaudRate
;
}
BOOL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
bool
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
{
DCB
dcb
;
if
(
GetCommState
(
handle
,
&
dcb
)
!=
TRUE
)
return
FALSE
;
return
false
;
dcb
.
BaudRate
=
rate
;
...
...
@@ -123,12 +123,12 @@ int comGetFlowControl(COM_HANDLE handle)
return
result
;
}
BOOL
comSetFlowControl
(
COM_HANDLE
handle
,
int
type
)
bool
comSetFlowControl
(
COM_HANDLE
handle
,
int
type
)
{
DCB
dcb
;
if
(
GetCommState
(
handle
,
&
dcb
)
!=
TRUE
)
return
FALSE
;
return
false
;
dcb
.
fOutxCtsFlow
=
0
;
dcb
.
fRtsControl
=
RTS_CONTROL_DISABLE
;
// This is questionable
...
...
@@ -151,24 +151,24 @@ BOOL comSetFlowControl(COM_HANDLE handle, int type)
return
SetCommState
(
handle
,
&
dcb
);
}
BOOL
comSetParity
(
COM_HANDLE
handle
,
BOOL
enable
,
BOOL
odd
)
bool
comSetParity
(
COM_HANDLE
handle
,
bool
enable
,
bool
odd
)
{
DCB
dcb
;
if
(
GetCommState
(
handle
,
&
dcb
)
!=
TRUE
)
return
FALSE
;
return
false
;
dcb
.
fParity
=
enable
;
dcb
.
Parity
=
enable
?
(
odd
?
ODDPARITY
:
EVENPARITY
)
:
NOPARITY
;
return
SetCommState
(
handle
,
&
dcb
);
}
BOOL
comSetBits
(
COM_HANDLE
handle
,
size_t
byteSize
,
size_t
stopBits
)
bool
comSetBits
(
COM_HANDLE
handle
,
size_t
byteSize
,
size_t
stopBits
)
{
DCB
dcb
;
if
(
GetCommState
(
handle
,
&
dcb
)
!=
TRUE
)
return
FALSE
;
return
false
;
dcb
.
ByteSize
=
(
BYTE
)
byteSize
;
dcb
.
StopBits
=
stopBits
==
2
?
TWOSTOPBITS
:
ONESTOPBIT
;
...
...
@@ -186,27 +186,27 @@ int comGetModemStatus(COM_HANDLE handle)
return
COM_ERROR
;
}
BOOL
comRaiseDTR
(
COM_HANDLE
handle
)
bool
comRaiseDTR
(
COM_HANDLE
handle
)
{
return
EscapeCommFunction
(
handle
,
SETDTR
);
}
BOOL
comLowerDTR
(
COM_HANDLE
handle
)
bool
comLowerDTR
(
COM_HANDLE
handle
)
{
return
EscapeCommFunction
(
handle
,
CLRDTR
);
}
BOOL
comRaiseRTS
(
COM_HANDLE
handle
)
bool
comRaiseRTS
(
COM_HANDLE
handle
)
{
return
EscapeCommFunction
(
handle
,
SETRTS
);
}
BOOL
comLowerRTS
(
COM_HANDLE
handle
)
bool
comLowerRTS
(
COM_HANDLE
handle
)
{
return
EscapeCommFunction
(
handle
,
CLRRTS
);
}
BOOL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
bool
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
{
DWORD
wr
=
0
;
...
...
@@ -228,24 +228,24 @@ int comWriteString(COM_HANDLE handle, const char* str)
return
comWriteBuf
(
handle
,
str
,
strlen
(
str
));
}
BOOL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
bool
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
{
DWORD
rd
;
return
ReadFile
(
handle
,
ch
,
sizeof
(
BYTE
),
&
rd
,
NULL
)
&&
rd
==
sizeof
(
BYTE
);
}
BOOL
comPurgeInput
(
COM_HANDLE
handle
)
bool
comPurgeInput
(
COM_HANDLE
handle
)
{
return
PurgeComm
(
handle
,
PURGE_RXCLEAR
);
}
BOOL
comPurgeOutput
(
COM_HANDLE
handle
)
bool
comPurgeOutput
(
COM_HANDLE
handle
)
{
return
PurgeComm
(
handle
,
PURGE_TXCLEAR
);
}
BOOL
comDrainOutput
(
COM_HANDLE
handle
)
bool
comDrainOutput
(
COM_HANDLE
handle
)
{
return
FlushFileBuffers
(
handle
);
}
...
...
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