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
83fc9480
Commit
83fc9480
authored
Dec 27, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmdline: use g_build_filename() for ~/.mpdconf
Build the path with g_build_filename(). Also use g_get_home_dir() and g_file_test().
parent
f5ff00bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
20 deletions
+10
-20
cmdline.c
src/cmdline.c
+10
-20
No files found.
src/cmdline.c
View file @
83fc9480
...
@@ -29,15 +29,10 @@
...
@@ -29,15 +29,10 @@
#include <glib.h>
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf"
#define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf"
#define USER_CONFIG_FILE_LOCATION "
/
.mpdconf"
#define USER_CONFIG_FILE_LOCATION ".mpdconf"
static
void
version
(
void
)
static
void
version
(
void
)
{
{
...
@@ -131,21 +126,16 @@ void parseOptions(int argc, char **argv, Options *options)
...
@@ -131,21 +126,16 @@ void parseOptions(int argc, char **argv, Options *options)
if
(
argc
<=
1
)
{
if
(
argc
<=
1
)
{
/* default configuration file path */
/* default configuration file path */
struct
stat
st
;
char
*
path
;
char
*
homedir
=
getenv
(
"HOME"
);
char
userfile
[
MPD_PATH_MAX
]
=
""
;
path
=
g_build_filename
(
g_get_home_dir
(),
USER_CONFIG_FILE_LOCATION
,
NULL
);
if
(
homedir
&&
(
strlen
(
homedir
)
+
if
(
g_file_test
(
path
,
G_FILE_TEST_IS_REGULAR
))
strlen
(
USER_CONFIG_FILE_LOCATION
))
<
readConf
(
path
);
MPD_PATH_MAX
)
{
else
if
(
g_file_test
(
SYSTEM_CONFIG_FILE_LOCATION
,
strcpy
(
userfile
,
homedir
);
G_FILE_TEST_IS_REGULAR
))
strcat
(
userfile
,
USER_CONFIG_FILE_LOCATION
);
}
if
(
strlen
(
userfile
)
&&
0
==
stat
(
userfile
,
&
st
))
readConf
(
userfile
);
else
if
(
0
==
stat
(
SYSTEM_CONFIG_FILE_LOCATION
,
&
st
))
readConf
(
SYSTEM_CONFIG_FILE_LOCATION
);
readConf
(
SYSTEM_CONFIG_FILE_LOCATION
);
g_free
(
path
);
}
else
if
(
argc
==
2
)
{
}
else
if
(
argc
==
2
)
{
/* specified configuration file */
/* specified configuration file */
readConf
(
argv
[
1
]);
readConf
(
argv
[
1
]);
...
...
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