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
53c89932
Commit
53c89932
authored
21 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
QNX doesn't have poll. :-(
Also, add -g to CFLAGS if a debug build is requested.
parent
38453c29
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/umonitor/GNUmakefile
+1
-0
1 addition, 0 deletions
src/sbbs3/umonitor/GNUmakefile
src/sbbs3/umonitor/umonitor.c
+34
-44
34 additions, 44 deletions
src/sbbs3/umonitor/umonitor.c
with
35 additions
and
44 deletions
src/sbbs3/umonitor/GNUmakefile
+
1
−
0
View file @
53c89932
...
...
@@ -22,6 +22,7 @@ endif
ifdef
DEBUG
BUILD
=
debug
CFLAGS
+=
-g
else
BUILD
=
release
endif
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/umonitor/umonitor.c
+
34
−
44
View file @
53c89932
...
...
@@ -37,7 +37,11 @@
#include
"conwrap.h"
/* this has to go BEFORE curses.h so getkey() can be macroed around */
#include
<curses.h>
#include
<poll.h>
#include
<sys/types.h>
#include
<sys/time.h>
#ifdef __QNX__
#include
<string.h>
#endif
#include
<stdio.h>
#include
<termios.h>
#include
<unistd.h>
...
...
@@ -74,6 +78,7 @@ enum {
enum
{
SPY_NOSOCKET
,
SPY_NOCONNECT
,
SPY_SELECTFAILED
,
SPY_SOCKETLOST
,
SPY_STDINLOST
,
SPY_CLOSED
...
...
@@ -115,14 +120,13 @@ int spyon(char *sockname) {
int
i
;
struct
termios
tio
;
struct
termios
old_tio
;
struct
pollfd
pset
[
2
]
;
fd_set
rd
;
BOOL
b
;
int
retval
=
0
;
/* ToDo Test for it actually being a socket! */
/* Well, it will fail to connect won't it? */
if
((
spy_sock
=
socket
(
PF_LOCAL
,
SOCK_STREAM
,
0
))
==
INVALID_SOCKET
)
{
printf
(
"ERROR %d creating local spy socket"
,
errno
);
return
(
SPY_NOSOCKET
);
...
...
@@ -141,12 +145,11 @@ int spyon(char *sockname) {
cfmakeraw
(
&
tio
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
tio
);
printf
(
"
\r\n\r\n
Local spy mode... press CTRL-C to return to monitor
\r\n\r\n
"
);
pset
[
0
].
fd
=
STDIN_FILENO
;
pset
[
0
].
events
=
POLLIN
;
pset
[
1
].
fd
=
spy_sock
;
pset
[
1
].
events
=
POLLIN
;
while
(
spy_sock
!=
INVALID_SOCKET
)
{
if
((
poll
(
pset
,
2
,
-
1
))
<
0
)
{
FD_ZERO
(
&
rd
);
FD_SET
(
STDIN_FILENO
,
&
rd
);
FD_SET
(
spy_sock
,
&
rd
);
if
((
select
(
spy_sock
>
STDIN_FILENO
?
spy_sock
+
1
:
STDIN_FILENO
+
1
,
&
rd
,
NULL
,
NULL
,
NULL
))
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
break
;
...
...
@@ -157,52 +160,36 @@ int spyon(char *sockname) {
retval
=
SPY_SOCKETLOST
;
break
;
}
if
(
pset
[
0
].
revents
)
{
if
(
pset
[
0
].
revents
&
(
POLLNVAL
|
POLLHUP
|
POLLERR
))
{
if
(
FD_ISSET
(
STDIN_FILENO
,
&
rd
))
{
if
((
i
=
read
(
STDIN_FILENO
,
&
key
,
1
))
==
1
)
{
/* Check for control keys */
switch
(
key
)
{
case
3
:
/* CTRL-C */
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_CLOSED
;
break
;
default:
write
(
spy_sock
,
&
key
,
1
);
}
}
else
if
(
i
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_STDINLOST
;
break
;
}
else
{
if
((
i
=
read
(
STDIN_FILENO
,
&
key
,
1
))
==
1
)
{
/* Check for control keys */
switch
(
key
)
{
case
CTRL
(
'c'
):
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_CLOSED
;
break
;
default:
write
(
spy_sock
,
&
key
,
1
);
}
}
else
if
(
i
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_STDINLOST
;
break
;
}
}
}
if
(
pset
[
1
].
revents
)
{
if
(
pset
[
1
].
revents
&
(
POLLNVAL
|
POLLHUP
|
POLLERR
))
{
if
(
spy_sock
!=
INVALID_SOCKET
&&
FD_ISSET
(
spy_sock
,
&
rd
))
{
if
((
i
=
read
(
spy_sock
,
&
buf
,
1
))
==
1
)
{
write
(
STDOUT_FILENO
,
buf
,
1
);
}
else
if
(
i
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_SOCKETLOST
;
break
;
}
else
{
if
((
i
=
read
(
spy_sock
,
&
buf
,
1
))
==
1
)
{
write
(
STDOUT_FILENO
,
buf
,
1
);
}
else
if
(
i
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
retval
=
SPY_SOCKETLOST
;
break
;
}
}
}
}
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
old_tio
);
...
...
@@ -759,7 +746,10 @@ int main(int argc, char** argv) {
sprintf
(
str2
,
"Failed to connect to %s"
,
str
);
uifc
.
msg
(
str2
);
break
;
case
SPY_SELECTFAILED
:
uifc
.
msg
(
"select() failed, connection terminated."
);
case
SPY_SOCKETLOST
:
uifc
.
msg
(
"Spy socket lost"
);
break
;
...
...
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