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
c9ce172f
Commit
c9ce172f
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
DLL-ify
parent
010380f0
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/comio/comio.c
+2
-2
2 additions, 2 deletions
src/comio/comio.c
src/comio/comio.h
+36
-16
36 additions, 16 deletions
src/comio/comio.h
src/comio/comio_nix.c
+15
-15
15 additions, 15 deletions
src/comio/comio_nix.c
src/comio/comio_win32.c
+14
-14
14 additions, 14 deletions
src/comio/comio_win32.c
with
67 additions
and
47 deletions
src/comio/comio.c
+
2
−
2
View file @
c9ce172f
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include
"comio.h"
#include
"comio.h"
#include
"genwrap.h"
/* msclock */
#include
"genwrap.h"
/* msclock */
size_t
comReadBuf
(
COM_HANDLE
handle
,
char
*
buf
,
size_t
buflen
,
const
char
*
terminators
,
int
timeout
)
size_t
COMIOCALL
comReadBuf
(
COM_HANDLE
handle
,
char
*
buf
,
size_t
buflen
,
const
char
*
terminators
,
int
timeout
)
{
{
BYTE
ch
;
BYTE
ch
;
size_t
len
=
0
;
size_t
len
=
0
;
...
@@ -59,7 +59,7 @@ size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, const char* termi
...
@@ -59,7 +59,7 @@ size_t comReadBuf(COM_HANDLE handle, char* buf, size_t buflen, const char* termi
return
len
;
return
len
;
}
}
size_t
comReadLine
(
COM_HANDLE
handle
,
char
*
buf
,
size_t
buflen
,
int
timeout
)
size_t
COMIOCALL
comReadLine
(
COM_HANDLE
handle
,
char
*
buf
,
size_t
buflen
,
int
timeout
)
{
{
size_t
len
;
size_t
len
;
...
...
This diff is collapsed.
Click to expand it.
src/comio/comio.h
+
36
−
16
View file @
c9ce172f
...
@@ -42,6 +42,26 @@
...
@@ -42,6 +42,26 @@
#define COM_ERROR -1
#define COM_ERROR -1
#ifdef _WIN32
#ifdef __BORLANDC__
#define COMIOCALL __stdcall
#else
#define COMIOCALL
#endif
#if defined(COMIO_IMPORTS) || defined(COMIO_EXPORTS)
#if defined(COMIO_IMPORTS)
#define COMIOEXPORT __declspec( dllimport )
#else
#define COMIOEXPORT __declspec( dllexport )
#endif
#else
/* self-contained executable */
#define COMIOEXPORT
#endif
#else
#define COMIOCALL
#define COMIOEXPORT
#endif
#ifdef _WIN32
#ifdef _WIN32
#include
<windows.h>
#include
<windows.h>
...
@@ -92,24 +112,24 @@
...
@@ -92,24 +112,24 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
char
*
comVersion
(
char
*
str
,
size_t
len
);
COMIOEXPORT
char
*
COMIOCALL
comVersion
(
char
*
str
,
size_t
len
);
COM_HANDLE
comOpen
(
const
char
*
device
);
COMIOEXPORT
COM_HANDLE
COMIOCALL
comOpen
(
const
char
*
device
);
BOOL
comClose
(
COM_HANDLE
);
COMIOEXPORT
BOOL
COMIOCALL
comClose
(
COM_HANDLE
);
long
comGetBaudRate
(
COM_HANDLE
);
COMIOEXPORT
long
COMIOCALL
comGetBaudRate
(
COM_HANDLE
);
BOOL
comSetBaudRate
(
COM_HANDLE
,
ulong
rate
);
COMIOEXPORT
BOOL
COMIOCALL
comSetBaudRate
(
COM_HANDLE
,
ulong
rate
);
int
comGetModemStatus
(
COM_HANDLE
);
COMIOEXPORT
int
COMIOCALL
comGetModemStatus
(
COM_HANDLE
);
int
comRaiseDTR
(
COM_HANDLE
);
COMIOEXPORT
int
COMIOCALL
comRaiseDTR
(
COM_HANDLE
);
int
comLowerDTR
(
COM_HANDLE
);
COMIOEXPORT
int
COMIOCALL
comLowerDTR
(
COM_HANDLE
);
BOOL
comWriteByte
(
COM_HANDLE
,
BYTE
);
COMIOEXPORT
BOOL
COMIOCALL
comWriteByte
(
COM_HANDLE
,
BYTE
);
int
comWriteBuf
(
COM_HANDLE
,
const
BYTE
*
,
size_t
buflen
);
COMIOEXPORT
int
COMIOCALL
comWriteBuf
(
COM_HANDLE
,
const
BYTE
*
,
size_t
buflen
);
int
comWriteString
(
COM_HANDLE
,
const
char
*
);
COMIOEXPORT
int
COMIOCALL
comWriteString
(
COM_HANDLE
,
const
char
*
);
BOOL
comReadByte
(
COM_HANDLE
,
BYTE
*
);
COMIOEXPORT
BOOL
COMIOCALL
comReadByte
(
COM_HANDLE
,
BYTE
*
);
size_t
comReadBuf
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
COMIOEXPORT
size_t
COMIOCALL
comReadBuf
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
,
const
char
*
terminators
,
int
timeout
/* in milliseconds */
);
,
const
char
*
terminators
,
int
timeout
/* in milliseconds */
);
size_t
comReadLine
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
COMIOEXPORT
size_t
COMIOCALL
comReadLine
(
COM_HANDLE
,
char
*
buf
,
size_t
buflen
,
int
timeout
/* in milliseconds */
);
,
int
timeout
/* in milliseconds */
);
BOOL
comPurgeInput
(
COM_HANDLE
);
COMIOEXPORT
BOOL
COMIOCALL
comPurgeInput
(
COM_HANDLE
);
BOOL
comPurgeOutput
(
COM_HANDLE
);
COMIOEXPORT
BOOL
COMIOCALL
comPurgeOutput
(
COM_HANDLE
);
#if defined(__cplusplus)
#if defined(__cplusplus)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/comio/comio_nix.c
+
15
−
15
View file @
c9ce172f
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
#include
"comio.h"
#include
"comio.h"
#include
"genwrap.h"
#include
"genwrap.h"
char
*
comVersion
(
char
*
str
,
size_t
len
)
char
*
COMIOCALL
comVersion
(
char
*
str
,
size_t
len
)
{
{
char
revision
[
16
];
char
revision
[
16
];
...
@@ -50,7 +50,7 @@ char* comVersion(char* str, size_t len)
...
@@ -50,7 +50,7 @@ char* comVersion(char* str, size_t len)
return
str
;
return
str
;
}
}
COM_HANDLE
comOpen
(
const
char
*
device
)
COM_HANDLE
COMIOCALL
comOpen
(
const
char
*
device
)
{
{
COM_HANDLE
handle
;
COM_HANDLE
handle
;
struct
termios
t
;
struct
termios
t
;
...
@@ -101,12 +101,12 @@ Fun snippet from the FreeBSD manpage:
...
@@ -101,12 +101,12 @@ Fun snippet from the FreeBSD manpage:
return
handle
;
return
handle
;
}
}
BOOL
comClose
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comClose
(
COM_HANDLE
handle
)
{
{
return
(
!
close
(
handle
));
return
(
!
close
(
handle
));
}
}
long
comGetBaudRate
(
COM_HANDLE
handle
)
long
COMIOCALL
comGetBaudRate
(
COM_HANDLE
handle
)
{
{
struct
termios
t
;
struct
termios
t
;
speed_t
in
;
speed_t
in
;
...
@@ -124,7 +124,7 @@ long comGetBaudRate(COM_HANDLE handle)
...
@@ -124,7 +124,7 @@ long comGetBaudRate(COM_HANDLE handle)
return
((
long
)(
in
>
out
?
in
:
out
));
return
((
long
)(
in
>
out
?
in
:
out
));
}
}
BOOL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
BOOL
COMIOCALL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
{
{
struct
termios
t
;
struct
termios
t
;
...
@@ -139,7 +139,7 @@ BOOL comSetBaudRate(COM_HANDLE handle, unsigned long rate)
...
@@ -139,7 +139,7 @@ BOOL comSetBaudRate(COM_HANDLE handle, unsigned long rate)
return
TRUE
;
return
TRUE
;
}
}
int
comGetModemStatus
(
COM_HANDLE
handle
)
int
COMIOCALL
comGetModemStatus
(
COM_HANDLE
handle
)
{
{
int
status
;
int
status
;
...
@@ -149,24 +149,24 @@ int comGetModemStatus(COM_HANDLE handle)
...
@@ -149,24 +149,24 @@ int comGetModemStatus(COM_HANDLE handle)
return
status
;
return
status
;
}
}
BOOL
comRaiseDTR
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comRaiseDTR
(
COM_HANDLE
handle
)
{
{
int
flags
=
TIOCM_DTR
;
int
flags
=
TIOCM_DTR
;
return
(
ioctl
(
handle
,
TIOCMBIS
,
&
flags
)
==
0
);
return
(
ioctl
(
handle
,
TIOCMBIS
,
&
flags
)
==
0
);
}
}
BOOL
comLowerDTR
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comLowerDTR
(
COM_HANDLE
handle
)
{
{
int
flags
=
TIOCM_DTR
;
int
flags
=
TIOCM_DTR
;
return
(
ioctl
(
handle
,
TIOCMBIC
,
&
flags
)
==
0
);
return
(
ioctl
(
handle
,
TIOCMBIC
,
&
flags
)
==
0
);
}
}
BOOL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
BOOL
COMIOCALL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
{
{
return
(
write
(
handle
,
&
ch
,
1
)
==
1
);
return
(
write
(
handle
,
&
ch
,
1
)
==
1
);
}
}
int
comWriteBuf
(
COM_HANDLE
handle
,
const
BYTE
*
buf
,
size_t
buflen
)
int
COMIOCALL
comWriteBuf
(
COM_HANDLE
handle
,
const
BYTE
*
buf
,
size_t
buflen
)
{
{
return
write
(
handle
,
buf
,
buflen
);
return
write
(
handle
,
buf
,
buflen
);
}
}
...
@@ -174,27 +174,27 @@ int comWriteBuf(COM_HANDLE handle, const BYTE* buf, size_t buflen)
...
@@ -174,27 +174,27 @@ int comWriteBuf(COM_HANDLE handle, const BYTE* buf, size_t buflen)
/*
/*
* TODO: This seem kinda dangerous for short writes...
* TODO: This seem kinda dangerous for short writes...
*/
*/
int
comWriteString
(
COM_HANDLE
handle
,
const
char
*
str
)
int
COMIOCALL
comWriteString
(
COM_HANDLE
handle
,
const
char
*
str
)
{
{
return
comWriteBuf
(
handle
,
(
BYTE
*
)
str
,
strlen
(
str
));
return
comWriteBuf
(
handle
,
(
BYTE
*
)
str
,
strlen
(
str
));
}
}
BOOL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
BOOL
COMIOCALL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
{
{
return
(
read
(
handle
,
ch
,
1
)
==
1
);
return
(
read
(
handle
,
ch
,
1
)
==
1
);
}
}
BOOL
comPurgeInput
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comPurgeInput
(
COM_HANDLE
handle
)
{
{
return
(
tcflush
(
handle
,
TCIFLUSH
)
==
0
);
return
(
tcflush
(
handle
,
TCIFLUSH
)
==
0
);
}
}
BOOL
comPurgeOutput
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comPurgeOutput
(
COM_HANDLE
handle
)
{
{
return
(
tcflush
(
handle
,
TCOFLUSH
)
==
0
);
return
(
tcflush
(
handle
,
TCOFLUSH
)
==
0
);
}
}
BOOL
comDrainOutput
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comDrainOutput
(
COM_HANDLE
handle
)
{
{
return
(
tcdrain
(
handle
)
==
0
);
return
(
tcdrain
(
handle
)
==
0
);
}
}
This diff is collapsed.
Click to expand it.
src/comio/comio_win32.c
+
14
−
14
View file @
c9ce172f
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include
"comio.h"
#include
"comio.h"
#include
"genwrap.h"
#include
"genwrap.h"
char
*
comVersion
(
char
*
str
,
size_t
len
)
char
*
COMIOCALL
comVersion
(
char
*
str
,
size_t
len
)
{
{
char
revision
[
16
];
char
revision
[
16
];
...
@@ -48,7 +48,7 @@ char* comVersion(char* str, size_t len)
...
@@ -48,7 +48,7 @@ char* comVersion(char* str, size_t len)
return
str
;
return
str
;
}
}
COM_HANDLE
comOpen
(
const
char
*
device
)
COM_HANDLE
COMIOCALL
comOpen
(
const
char
*
device
)
{
{
COM_HANDLE
handle
;
COM_HANDLE
handle
;
COMMTIMEOUTS
timeouts
;
COMMTIMEOUTS
timeouts
;
...
@@ -85,12 +85,12 @@ COM_HANDLE comOpen(const char* device)
...
@@ -85,12 +85,12 @@ COM_HANDLE comOpen(const char* device)
return
handle
;
return
handle
;
}
}
BOOL
comClose
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comClose
(
COM_HANDLE
handle
)
{
{
return
CloseHandle
(
handle
);
return
CloseHandle
(
handle
);
}
}
long
comGetBaudRate
(
COM_HANDLE
handle
)
long
COMIOCALL
comGetBaudRate
(
COM_HANDLE
handle
)
{
{
DCB
dcb
;
DCB
dcb
;
...
@@ -100,7 +100,7 @@ long comGetBaudRate(COM_HANDLE handle)
...
@@ -100,7 +100,7 @@ long comGetBaudRate(COM_HANDLE handle)
return
dcb
.
BaudRate
;
return
dcb
.
BaudRate
;
}
}
BOOL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
BOOL
COMIOCALL
comSetBaudRate
(
COM_HANDLE
handle
,
unsigned
long
rate
)
{
{
DCB
dcb
;
DCB
dcb
;
...
@@ -112,7 +112,7 @@ BOOL comSetBaudRate(COM_HANDLE handle, unsigned long rate)
...
@@ -112,7 +112,7 @@ BOOL comSetBaudRate(COM_HANDLE handle, unsigned long rate)
return
SetCommState
(
handle
,
&
dcb
);
return
SetCommState
(
handle
,
&
dcb
);
}
}
int
comGetModemStatus
(
COM_HANDLE
handle
)
int
COMIOCALL
comGetModemStatus
(
COM_HANDLE
handle
)
{
{
DWORD
status
=
0
;
DWORD
status
=
0
;
...
@@ -122,24 +122,24 @@ int comGetModemStatus(COM_HANDLE handle)
...
@@ -122,24 +122,24 @@ int comGetModemStatus(COM_HANDLE handle)
return
COM_ERROR
;
return
COM_ERROR
;
}
}
BOOL
comRaiseDTR
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comRaiseDTR
(
COM_HANDLE
handle
)
{
{
return
EscapeCommFunction
(
handle
,
SETDTR
);
return
EscapeCommFunction
(
handle
,
SETDTR
);
}
}
BOOL
comLowerDTR
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comLowerDTR
(
COM_HANDLE
handle
)
{
{
return
EscapeCommFunction
(
handle
,
CLRDTR
);
return
EscapeCommFunction
(
handle
,
CLRDTR
);
}
}
BOOL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
BOOL
COMIOCALL
comWriteByte
(
COM_HANDLE
handle
,
BYTE
ch
)
{
{
DWORD
wr
=
0
;
DWORD
wr
=
0
;
return
WriteFile
(
handle
,
&
ch
,
sizeof
(
ch
),
&
wr
,
NULL
)
&&
wr
==
sizeof
(
BYTE
);
return
WriteFile
(
handle
,
&
ch
,
sizeof
(
ch
),
&
wr
,
NULL
)
&&
wr
==
sizeof
(
BYTE
);
}
}
int
comWriteBuf
(
COM_HANDLE
handle
,
const
BYTE
*
buf
,
size_t
buflen
)
int
COMIOCALL
comWriteBuf
(
COM_HANDLE
handle
,
const
BYTE
*
buf
,
size_t
buflen
)
{
{
DWORD
wr
=
0
;
DWORD
wr
=
0
;
...
@@ -149,24 +149,24 @@ int comWriteBuf(COM_HANDLE handle, const BYTE* buf, size_t buflen)
...
@@ -149,24 +149,24 @@ int comWriteBuf(COM_HANDLE handle, const BYTE* buf, size_t buflen)
return
wr
;
return
wr
;
}
}
int
comWriteString
(
COM_HANDLE
handle
,
const
char
*
str
)
int
COMIOCALL
comWriteString
(
COM_HANDLE
handle
,
const
char
*
str
)
{
{
return
comWriteBuf
(
handle
,
str
,
strlen
(
str
));
return
comWriteBuf
(
handle
,
str
,
strlen
(
str
));
}
}
BOOL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
BOOL
COMIOCALL
comReadByte
(
COM_HANDLE
handle
,
BYTE
*
ch
)
{
{
DWORD
rd
;
DWORD
rd
;
return
ReadFile
(
handle
,
ch
,
sizeof
(
BYTE
),
&
rd
,
NULL
)
&&
rd
==
sizeof
(
BYTE
);
return
ReadFile
(
handle
,
ch
,
sizeof
(
BYTE
),
&
rd
,
NULL
)
&&
rd
==
sizeof
(
BYTE
);
}
}
BOOL
comPurgeInput
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comPurgeInput
(
COM_HANDLE
handle
)
{
{
return
PurgeComm
(
handle
,
PURGE_RXCLEAR
);
return
PurgeComm
(
handle
,
PURGE_RXCLEAR
);
}
}
BOOL
comPurgeOutput
(
COM_HANDLE
handle
)
BOOL
COMIOCALL
comPurgeOutput
(
COM_HANDLE
handle
)
{
{
return
PurgeComm
(
handle
,
PURGE_TXCLEAR
);
return
PurgeComm
(
handle
,
PURGE_TXCLEAR
);
}
}
...
...
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