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
74b92cc8
Commit
74b92cc8
authored
7 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Support authentication and the new SERVICE_STATUS
parent
c0f0636d
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/showstat.c
+45
-2
45 additions, 2 deletions
src/sbbs3/showstat.c
with
45 additions
and
2 deletions
src/sbbs3/showstat.c
+
45
−
2
View file @
74b92cc8
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
<termios.h>
#include
<unistd.h>
#include
"sbbs_status.h"
#include
"dirwrap.h"
#include
"genwrap.h"
void
usage
(
void
)
{
printf
(
"Usage: showstat <path>
\n
"
);
}
static
struct
termios
old
;
void
noecho
(
void
)
{
struct
termios
new
=
old
;
new
.
c_lflag
&=
~
(
ICANON
|
ECHO
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
new
);
}
void
restore
(
void
)
{
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
old
);
}
int
main
(
int
argc
,
char
**
argv
)
{
SOCKET
sock
;
...
...
@@ -17,6 +33,7 @@ int main(int argc, char **argv)
char
buf
[
4096
];
struct
sbbs_status_msg
*
msg
;
time_t
t
;
char
*
p
;
if
(
argc
!=
2
)
{
usage
();
...
...
@@ -27,6 +44,7 @@ int main(int argc, char **argv)
return
1
;
}
tcgetattr
(
STDIN_FILENO
,
&
old
);
sock
=
socket
(
PF_UNIX
,
SOCK_SEQPACKET
,
0
);
if
(
sock
==
INVALID_SOCKET
)
return
1
;
...
...
@@ -38,12 +56,31 @@ int main(int argc, char **argv)
#else
addrlen
=
offsetof
(
struct
sockaddr_un
,
un_addr
.
sun_path
)
+
strlen
(
addr
.
sun_path
)
+
1
;
#endif
printf
(
"UN: "
);
fgets
(
buf
,
sizeof
(
buf
),
stdin
);
truncnl
(
buf
);
noecho
();
p
=
strchr
(
buf
,
0
);
p
++
;
printf
(
"PW: "
);
fgets
(
p
,
sizeof
(
buf
)
-
(
p
-
buf
),
stdin
);
truncnl
(
p
);
p
=
strchr
(
p
,
0
);
p
++
;
printf
(
"
\n
SY: "
);
fgets
(
p
,
sizeof
(
buf
)
-
(
p
-
buf
),
stdin
);
truncnl
(
p
);
p
=
strchr
(
p
,
0
);
p
++
;
restore
();
puts
(
""
);
if
(
connect
(
sock
,
(
void
*
)
&
addr
,
addrlen
)
!=
0
)
{
fprintf
(
stderr
,
"Unable to connect!
\n
"
);
return
1
;
}
send
(
sock
,
buf
,
1
,
0
);
send
(
sock
,
buf
,
p
-
buf
,
0
);
while
(
sock
!=
-
1
)
{
if
(
recv
(
sock
,
buf
,
sizeof
(
buf
),
0
)
<=
0
)
{
close
(
sock
);
...
...
@@ -70,6 +107,12 @@ int main(int argc, char **argv)
case
SERVICE_WEB
:
printf
(
"WEB: "
);
break
;
case
SERVICE_STATUS
:
printf
(
"STATUS: "
);
break
;
default:
printf
(
"UNKNOWN SERVICE %"
PRIu32
" "
,
msg
->
hdr
.
service
);
break
;
}
switch
(
msg
->
hdr
.
type
)
{
case
STATUS_CLIENTS
:
...
...
@@ -125,7 +168,7 @@ int main(int argc, char **argv)
printf
(
"thread %s (%d)
\n
"
,
msg
->
msg
.
thread_up
.
up
?
"up"
:
"down"
,
msg
->
msg
.
thread_up
.
setuid
);
break
;
default:
printf
(
"!Unhandled type: %
d
\b
"
,
msg
->
hdr
.
type
);
printf
(
"!Unhandled type: %
"
PRIu32
"
\n
"
,
msg
->
hdr
.
type
);
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