Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
67e44b0f
Commit
67e44b0f
authored
Aug 07, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
daemon: convert to C++
parent
bf840700
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
21 deletions
+18
-21
Makefile.am
Makefile.am
+1
-2
Daemon.cxx
src/Daemon.cxx
+13
-13
Daemon.hxx
src/Daemon.hxx
+3
-5
Main.cxx
src/Main.cxx
+1
-1
No files found.
Makefile.am
View file @
67e44b0f
...
...
@@ -62,7 +62,6 @@ mpd_headers = \
src/TextInputStream.hxx
\
src/ls.h
\
src/mixer_plugin.h
\
src/daemon.h
\
src/AudioCompress/config.h
\
src/AudioCompress/compress.h
\
src/open.h
\
...
...
@@ -173,7 +172,7 @@ src_mpd_SOURCES = \
src/Instance.cxx src/Instance.hxx
\
src/Win32Main.cxx
\
src/GlobalEvents.cxx src/GlobalEvents.hxx
\
src/
daemon.c
\
src/
Daemon.cxx src/Daemon.hxx
\
src/AudioCompress/compress.c
\
src/MusicBuffer.cxx src/MusicBuffer.hxx
\
src/MusicPipe.cxx src/MusicPipe.hxx
\
...
...
src/
daemon.c
→
src/
Daemon.cxx
View file @
67e44b0f
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "
daemon.h
"
#include "
Daemon.hxx
"
#include <glib.h>
...
...
@@ -64,11 +64,11 @@ daemonize_kill(void)
FILE
*
fp
;
int
pid
,
ret
;
if
(
pidfile
==
NULL
)
if
(
pidfile
==
nullptr
)
MPD_ERROR
(
"no pid_file specified in the config file"
);
fp
=
fopen
(
pidfile
,
"r"
);
if
(
fp
==
NULL
)
if
(
fp
==
nullptr
)
MPD_ERROR
(
"unable to open pid file
\"
%s
\"
: %s"
,
pidfile
,
g_strerror
(
errno
));
...
...
@@ -96,7 +96,7 @@ daemonize_close_stdin(void)
void
daemonize_set_user
(
void
)
{
if
(
user_name
==
NULL
)
if
(
user_name
==
nullptr
)
return
;
/* set gid */
...
...
@@ -131,7 +131,7 @@ daemonize_detach(void)
{
/* flush all file handles before duplicating the buffers */
fflush
(
NULL
);
fflush
(
nullptr
);
#ifdef HAVE_DAEMON
...
...
@@ -171,9 +171,9 @@ daemonize_detach(void)
void
daemonize
(
bool
detach
)
{
FILE
*
fp
=
NULL
;
FILE
*
fp
=
nullptr
;
if
(
pidfile
!=
NULL
)
{
if
(
pidfile
!=
nullptr
)
{
/* do this before daemon'izing so we can fail gracefully if we can't
* write to the pid file */
g_debug
(
"opening pid file"
);
...
...
@@ -187,7 +187,7 @@ daemonize(bool detach)
if
(
detach
)
daemonize_detach
();
if
(
pidfile
!=
NULL
)
{
if
(
pidfile
!=
nullptr
)
{
g_debug
(
"writing pid file"
);
fprintf
(
fp
,
"%lu
\n
"
,
(
unsigned
long
)
getpid
());
fclose
(
fp
);
...
...
@@ -199,7 +199,7 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
{
if
(
user
)
{
struct
passwd
*
pwd
=
getpwnam
(
user
);
if
(
!
pwd
)
if
(
pwd
==
nullptr
)
MPD_ERROR
(
"no such user
\"
%s
\"
"
,
user
);
user_uid
=
pwd
->
pw_uid
;
...
...
@@ -212,8 +212,8 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
}
if
(
group
)
{
struct
group
*
grp
=
g
rp
=
g
etgrnam
(
group
);
if
(
!
grp
)
struct
group
*
grp
=
getgrnam
(
group
);
if
(
grp
==
nullptr
)
MPD_ERROR
(
"no such group
\"
%s
\"
"
,
group
);
user_gid
=
grp
->
gr_gid
;
had_group
=
true
;
...
...
@@ -226,7 +226,7 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
void
daemonize_finish
(
void
)
{
if
(
pidfile
!=
NULL
)
if
(
pidfile
!=
nullptr
)
unlink
(
pidfile
);
g_free
(
user_name
);
...
...
src/
daemon.h
→
src/
Daemon.hxx
View file @
67e44b0f
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef
DAEMON_H
#define
DAEMON_H
#ifndef
MPD_DAEMON_HXX
#define
MPD_DAEMON_HXX
#include "mpd_error.h"
#include <stdbool.h>
#ifndef WIN32
void
daemonize_init
(
const
char
*
user
,
const
char
*
group
,
const
char
*
pidfile
);
...
...
src/Main.cxx
View file @
67e44b0f
...
...
@@ -54,9 +54,9 @@
#include "DecoderList.hxx"
#include "AudioConfig.hxx"
#include "pcm/PcmResample.hxx"
#include "Daemon.hxx"
extern
"C"
{
#include "daemon.h"
#include "stats.h"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment