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
a8c37e07
Commit
a8c37e07
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Simplified the "is_daemon" portion of the various xxx_lputs routines.
Created macro for pid filename.
parent
b6e3c9eb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sbbscon.c
+45
-60
45 additions, 60 deletions
src/sbbs3/sbbscon.c
with
45 additions
and
60 deletions
src/sbbs3/sbbscon.c
+
45
−
60
View file @
a8c37e07
...
@@ -59,6 +59,9 @@
...
@@ -59,6 +59,9 @@
#endif
#endif
/* Constants */
#define SBBS_PID_FILE "/var/run/sbbs.pid"
/* Global variables */
/* Global variables */
BOOL
bbs_running
=
FALSE
;
BOOL
bbs_running
=
FALSE
;
BOOL
bbs_stopped
=
FALSE
;
BOOL
bbs_stopped
=
FALSE
;
...
@@ -370,21 +373,16 @@ static int ftp_lputs(char *str)
...
@@ -370,21 +373,16 @@ static int ftp_lputs(char *str)
time_t
t
;
time_t
t
;
struct
tm
*
tm_p
;
struct
tm
*
tm_p
;
if
(
is_daemon
)
{
t
=
time
(
NULL
);
sprintf
(
logline
,
"ftp %.*s"
,
sizeof
(
logline
)
-
2
,
str
);
tm_p
=
localtime
(
&
t
);
}
if
(
tm_p
==
NULL
||
is_daemon
)
else
{
tstr
[
0
]
=
0
;
t
=
time
(
NULL
);
else
tm_p
=
localtime
(
&
t
);
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
if
(
tm_p
==
NULL
)
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
tstr
[
0
]
=
0
;
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
else
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
sprintf
(
logline
,
"%sftp %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
sprintf
(
logline
,
"%sftp %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
}
truncsp
(
logline
);
truncsp
(
logline
);
lputs
(
logline
);
lputs
(
logline
);
...
@@ -413,21 +411,16 @@ static int mail_lputs(char *str)
...
@@ -413,21 +411,16 @@ static int mail_lputs(char *str)
time_t
t
;
time_t
t
;
struct
tm
*
tm_p
;
struct
tm
*
tm_p
;
if
(
is_daemon
)
{
t
=
time
(
NULL
);
sprintf
(
logline
,
"mail %.*s"
,
sizeof
(
logline
)
-
2
,
str
);
tm_p
=
localtime
(
&
t
);
}
if
(
tm_p
==
NULL
||
is_daemon
)
else
{
tstr
[
0
]
=
0
;
t
=
time
(
NULL
);
else
tm_p
=
localtime
(
&
t
);
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
if
(
tm_p
==
NULL
)
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
tstr
[
0
]
=
0
;
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
else
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
sprintf
(
logline
,
"%smail %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
sprintf
(
logline
,
"%smail %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
}
truncsp
(
logline
);
truncsp
(
logline
);
lputs
(
logline
);
lputs
(
logline
);
...
@@ -456,21 +449,16 @@ static int services_lputs(char *str)
...
@@ -456,21 +449,16 @@ static int services_lputs(char *str)
time_t
t
;
time_t
t
;
struct
tm
*
tm_p
;
struct
tm
*
tm_p
;
if
(
is_daemon
)
{
t
=
time
(
NULL
);
sprintf
(
logline
,
"srvc %.*s"
,
sizeof
(
logline
)
-
2
,
str
);
tm_p
=
localtime
(
&
t
);
}
if
(
tm_p
==
NULL
||
is_daemon
)
else
{
tstr
[
0
]
=
0
;
t
=
time
(
NULL
);
else
tm_p
=
localtime
(
&
t
);
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
if
(
tm_p
==
NULL
)
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
tstr
[
0
]
=
0
;
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
else
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
sprintf
(
logline
,
"%ssrvc %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
sprintf
(
logline
,
"%ssrvc %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
}
truncsp
(
logline
);
truncsp
(
logline
);
lputs
(
logline
);
lputs
(
logline
);
...
@@ -499,21 +487,16 @@ static int event_lputs(char *str)
...
@@ -499,21 +487,16 @@ static int event_lputs(char *str)
time_t
t
;
time_t
t
;
struct
tm
*
tm_p
;
struct
tm
*
tm_p
;
if
(
is_daemon
)
{
t
=
time
(
NULL
);
sprintf
(
logline
,
"evnt %.*s"
,
sizeof
(
logline
)
-
2
,
str
);
tm_p
=
localtime
(
&
t
);
}
if
(
tm_p
==
NULL
||
is_daemon
)
else
{
tstr
[
0
]
=
0
;
t
=
time
(
NULL
);
else
tm_p
=
localtime
(
&
t
);
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
if
(
tm_p
==
NULL
)
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
tstr
[
0
]
=
0
;
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
else
sprintf
(
tstr
,
"%d/%d %02d:%02d:%02d "
,
tm_p
->
tm_mon
+
1
,
tm_p
->
tm_mday
,
tm_p
->
tm_hour
,
tm_p
->
tm_min
,
tm_p
->
tm_sec
);
sprintf
(
logline
,
"%sevnt %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
sprintf
(
logline
,
"%sevnt %.*s"
,
tstr
,
sizeof
(
logline
)
-
2
,
str
);
}
truncsp
(
logline
);
truncsp
(
logline
);
lputs
(
logline
);
lputs
(
logline
);
...
@@ -532,7 +515,7 @@ void _sighandler_quit(int sig)
...
@@ -532,7 +515,7 @@ void _sighandler_quit(int sig)
while
(
bbs_running
||
ftp_running
||
mail_running
||
services_running
)
while
(
bbs_running
||
ftp_running
||
mail_running
||
services_running
)
mswait
(
1
);
mswait
(
1
);
if
(
is_daemon
)
if
(
is_daemon
)
unlink
(
"/var/run/sbbs.pid"
);
unlink
(
SBBS_PID_FILE
);
exit
(
0
);
exit
(
0
);
}
}
...
@@ -967,9 +950,11 @@ int main(int argc, char** argv)
...
@@ -967,9 +950,11 @@ int main(int argc, char** argv)
#ifdef __unix__
#ifdef __unix__
/* Write the standard .pid file if running as a daemon */
/* Write the standard .pid file if running as a daemon */
if
(
is_daemon
)
{
if
(
is_daemon
)
{
pidfile
=
fopen
(
"/var/run/sbbs.pid"
,
"w"
);
pidfile
=
fopen
(
SBBS_PID_FILE
,
"w"
);
fprintf
(
pidfile
,
"%d"
,
getpid
());
if
(
pidfile
!=
NULL
)
{
fclose
(
pidfile
);
fprintf
(
pidfile
,
"%d"
,
getpid
());
fclose
(
pidfile
);
}
}
}
#endif
#endif
...
...
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