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
171a7752
Commit
171a7752
authored
Apr 11, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add --only-create-db option from msells
have SIGHUP cause rereading db file git-svn-id:
https://svn.musicpd.org/mpd/trunk@663
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
8c4bc2d2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
5 deletions
+27
-5
directory.c
src/directory.c
+1
-1
list.c
src/list.c
+3
-0
main.c
src/main.c
+11
-2
player.c
src/player.c
+1
-0
sig_handlers.c
src/sig_handlers.c
+10
-1
song.c
src/song.c
+1
-1
No files found.
src/directory.c
View file @
171a7752
...
@@ -473,7 +473,7 @@ void readDirectoryInfo(FILE * fp,Directory * directory) {
...
@@ -473,7 +473,7 @@ void readDirectoryInfo(FILE * fp,Directory * directory) {
nextDirNode
=
nodeTemp
;
nextDirNode
=
nodeTemp
;
}
}
if
(
!
nextDirNode
)
{
if
(
NULL
==
nextDirNode
)
{
subDirectory
=
newDirectory
(
directory
,
name
,
subDirectory
=
newDirectory
(
directory
,
name
,
mtime
);
mtime
);
insertInList
(
directory
->
subDirectories
,
key
,
insertInList
(
directory
->
subDirectories
,
key
,
...
...
src/list.c
View file @
171a7752
...
@@ -88,6 +88,9 @@ int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key,
...
@@ -88,6 +88,9 @@ int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key,
}
}
else
{
else
{
node
->
prevNode
=
beforeNode
->
prevNode
;
node
->
prevNode
=
beforeNode
->
prevNode
;
if
(
node
->
prevNode
)
{
node
->
prevNode
->
nextNode
=
node
;
}
beforeNode
->
prevNode
=
node
;
beforeNode
->
prevNode
=
node
;
}
}
...
...
src/main.c
View file @
171a7752
...
@@ -58,6 +58,7 @@ typedef struct _Options {
...
@@ -58,6 +58,7 @@ typedef struct _Options {
char
*
dbFile
;
char
*
dbFile
;
int
daemon
;
int
daemon
;
int
createDB
;
int
createDB
;
int
onlyCreateDB
;
}
Options
;
}
Options
;
void
usage
(
char
*
argv
[])
{
void
usage
(
char
*
argv
[])
{
...
@@ -72,6 +73,7 @@ void usage(char * argv[]) {
...
@@ -72,6 +73,7 @@ void usage(char * argv[]) {
ERROR
(
" --help this usage statement
\n
"
);
ERROR
(
" --help this usage statement
\n
"
);
ERROR
(
" --no-daemon don't detach from console
\n
"
);
ERROR
(
" --no-daemon don't detach from console
\n
"
);
ERROR
(
" --create-db force (re)creation database
\n
"
);
ERROR
(
" --create-db force (re)creation database
\n
"
);
ERROR
(
" --only-create-db create database and exit
\n
"
);
ERROR
(
" --no-create-db don't create database
\n
"
);
ERROR
(
" --no-create-db don't create database
\n
"
);
ERROR
(
" --verbose verbose logging
\n
"
);
ERROR
(
" --verbose verbose logging
\n
"
);
ERROR
(
" --version prints version information
\n
"
);
ERROR
(
" --version prints version information
\n
"
);
...
@@ -91,6 +93,7 @@ void parseOptions(int argc, char ** argv, Options * options) {
...
@@ -91,6 +93,7 @@ void parseOptions(int argc, char ** argv, Options * options) {
options
->
usr
=
NULL
;
options
->
usr
=
NULL
;
options
->
daemon
=
1
;
options
->
daemon
=
1
;
options
->
createDB
=
0
;
options
->
createDB
=
0
;
options
->
onlyCreateDB
=
0
;
options
->
dbFile
=
NULL
;
options
->
dbFile
=
NULL
;
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
...
@@ -109,6 +112,10 @@ void parseOptions(int argc, char ** argv, Options * options) {
...
@@ -109,6 +112,10 @@ void parseOptions(int argc, char ** argv, Options * options) {
options
->
createDB
=
1
;
options
->
createDB
=
1
;
argcLeft
--
;
argcLeft
--
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"--only-create-db"
)
==
0
)
{
options
->
onlyCreateDB
=
1
;
argcLeft
--
;
}
else
if
(
strcmp
(
argv
[
i
],
"--no-create-db"
)
==
0
)
{
else
if
(
strcmp
(
argv
[
i
],
"--no-create-db"
)
==
0
)
{
options
->
createDB
=
-
1
;
options
->
createDB
=
-
1
;
argcLeft
--
;
argcLeft
--
;
...
@@ -210,7 +217,7 @@ int main(int argc, char * argv[]) {
...
@@ -210,7 +217,7 @@ int main(int argc, char * argv[]) {
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
if
((
listenSocket
=
establish
(
port
))
<
0
)
{
if
(
!
options
.
onlyCreateDB
&&
(
listenSocket
=
establish
(
port
))
<
0
)
{
ERROR
(
"error binding port
\n
"
);
ERROR
(
"error binding port
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
...
@@ -340,7 +347,8 @@ int main(int argc, char * argv[]) {
...
@@ -340,7 +347,8 @@ int main(int argc, char * argv[]) {
strncpy
(
directorydb
,
options
.
dbFile
,
MAXPATHLEN
);
strncpy
(
directorydb
,
options
.
dbFile
,
MAXPATHLEN
);
directorydb
[
MAXPATHLEN
]
=
'\0'
;
directorydb
[
MAXPATHLEN
]
=
'\0'
;
}
}
if
(
options
.
createDB
>
0
||
readDirectoryDB
()
<
0
)
{
if
(
options
.
createDB
>
0
||
options
.
onlyCreateDB
||
readDirectoryDB
()
<
0
)
{
if
(
options
.
createDB
<
0
)
{
if
(
options
.
createDB
<
0
)
{
ERROR
(
"can't open db file and using
\"
--no-create-db
\"
"
ERROR
(
"can't open db file and using
\"
--no-create-db
\"
"
" command line option
\n
"
);
" command line option
\n
"
);
...
@@ -351,6 +359,7 @@ int main(int argc, char * argv[]) {
...
@@ -351,6 +359,7 @@ int main(int argc, char * argv[]) {
ERROR
(
"problem opening db for reading or writing
\n
"
);
ERROR
(
"problem opening db for reading or writing
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
options
.
onlyCreateDB
)
exit
(
EXIT_SUCCESS
);
}
}
initCommands
();
initCommands
();
...
...
src/player.c
View file @
171a7752
...
@@ -103,6 +103,7 @@ int playerInit() {
...
@@ -103,6 +103,7 @@ int playerInit() {
sa
.
sa_handler
=
SIG_IGN
;
sa
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGPIPE
,
&
sa
,
NULL
);
sigaction
(
SIGPIPE
,
&
sa
,
NULL
);
sigaction
(
SIGHUP
,
&
sa
,
NULL
);
sa
.
sa_handler
=
decodeSigHandler
;
sa
.
sa_handler
=
decodeSigHandler
;
sigaction
(
SIGCHLD
,
&
sa
,
NULL
);
sigaction
(
SIGCHLD
,
&
sa
,
NULL
);
sigaction
(
SIGTERM
,
&
sa
,
NULL
);
sigaction
(
SIGTERM
,
&
sa
,
NULL
);
...
...
src/sig_handlers.c
View file @
171a7752
...
@@ -19,10 +19,12 @@
...
@@ -19,10 +19,12 @@
#include "sig_handlers.h"
#include "sig_handlers.h"
#include "player.h"
#include "player.h"
#include "playlist.h"
#include "playlist.h"
#include "directory.h"
#include <signal.h>
#include <signal.h>
struct
sigaction
original_termSa
;
struct
sigaction
original_termSa
;
struct
sigaction
original_hupSa
;
void
termSigHandler
(
int
signal
)
{
void
termSigHandler
(
int
signal
)
{
if
(
signal
==
SIGTERM
)
{
if
(
signal
==
SIGTERM
)
{
...
@@ -35,6 +37,10 @@ void termSigHandler(int signal) {
...
@@ -35,6 +37,10 @@ void termSigHandler(int signal) {
void
usr1SigHandler
(
int
signal
)
{
void
usr1SigHandler
(
int
signal
)
{
}
}
void
hupSigHandler
(
int
signal
)
{
readDirectoryDB
();
}
void
initSigHandlers
()
{
void
initSigHandlers
()
{
struct
sigaction
sa
;
struct
sigaction
sa
;
...
@@ -46,12 +52,15 @@ void initSigHandlers() {
...
@@ -46,12 +52,15 @@ void initSigHandlers() {
sigaction
(
SIGUSR1
,
&
sa
,
NULL
);
sigaction
(
SIGUSR1
,
&
sa
,
NULL
);
sa
.
sa_handler
=
player_sigHandler
;
sa
.
sa_handler
=
player_sigHandler
;
sigaction
(
SIGCHLD
,
&
sa
,
NULL
);
sigaction
(
SIGCHLD
,
&
sa
,
NULL
);
sa
.
sa_handler
=
hupSigHandler
;
sigaction
(
SIGHUP
,
&
sa
,
&
original_hupSa
);
sa
.
sa_handler
=
termSigHandler
;
sa
.
sa_handler
=
termSigHandler
;
sigaddset
(
&
sa
.
sa_mask
,
SIGTERM
);
/*sigaddset(&sa.sa_mask,SIGTERM);*/
sigaction
(
SIGTERM
,
&
sa
,
&
original_termSa
);
sigaction
(
SIGTERM
,
&
sa
,
&
original_termSa
);
}
}
void
finishSigHandlers
()
{
void
finishSigHandlers
()
{
sigaction
(
SIGHUP
,
&
original_termSa
,
NULL
);
sigaction
(
SIGTERM
,
&
original_termSa
,
NULL
);
sigaction
(
SIGTERM
,
&
original_termSa
,
NULL
);
}
}
...
...
src/song.c
View file @
171a7752
...
@@ -191,9 +191,9 @@ void insertSongIntoList(SongList * list, ListNode ** nextSongNode, char * key,
...
@@ -191,9 +191,9 @@ void insertSongIntoList(SongList * list, ListNode ** nextSongNode, char * key,
tempSong
->
tag
=
song
->
tag
;
tempSong
->
tag
=
song
->
tag
;
tempSong
->
mtime
=
song
->
mtime
;
tempSong
->
mtime
=
song
->
mtime
;
song
->
tag
=
NULL
;
song
->
tag
=
NULL
;
freeJustSong
(
song
);
addSongToTables
(
tempSong
);
addSongToTables
(
tempSong
);
}
}
freeJustSong
(
song
);
*
nextSongNode
=
(
*
nextSongNode
)
->
nextNode
;
*
nextSongNode
=
(
*
nextSongNode
)
->
nextNode
;
}
}
else
{
else
{
...
...
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