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
2362ee4a
Commit
2362ee4a
authored
Jan 21, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use config_get_positive() instead of manual parsing
Simplify some code by using config_get_positive(), instead of doing manual parsing and validation each time.
parent
f11eb14c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
81 deletions
+21
-81
client.c
src/client.c
+17
-54
listen.c
src/listen.c
+1
-15
playlist.c
src/playlist.c
+3
-12
No files found.
src/client.c
View file @
2362ee4a
...
...
@@ -59,11 +59,9 @@ static const char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
/* set this to zero to indicate we have no possible clients */
static
unsigned
int
client_max_connections
;
/*CLIENT_MAX_CONNECTIONS_DEFAULT; */
static
int
client_timeout
=
CLIENT_TIMEOUT_DEFAULT
;
static
size_t
client_max_command_list_size
=
CLIENT_MAX_COMMAND_LIST_DEFAULT
;
static
size_t
client_max_output_buffer_size
=
CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT
;
static
int
client_timeout
;
static
size_t
client_max_command_list_size
;
static
size_t
client_max_output_buffer_size
;
struct
deferred_buffer
{
size_t
size
;
...
...
@@ -553,55 +551,20 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
void
client_manager_init
(
void
)
{
char
*
test
;
struct
config_param
*
param
;
param
=
config_get_param
(
CONF_CONN_TIMEOUT
);
if
(
param
)
{
client_timeout
=
strtol
(
param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
client_timeout
<=
0
)
{
g_error
(
"connection timeout
\"
%s
\"
is not a positive "
"integer, line %i"
,
CONF_CONN_TIMEOUT
,
param
->
line
);
}
}
param
=
config_get_param
(
CONF_MAX_CONN
);
if
(
param
)
{
client_max_connections
=
strtol
(
param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
client_max_connections
<=
0
)
{
g_error
(
"max connections
\"
%s
\"
is not a positive integer"
", line %i"
,
param
->
value
,
param
->
line
);
}
}
else
client_max_connections
=
CLIENT_MAX_CONNECTIONS_DEFAULT
;
param
=
config_get_param
(
CONF_MAX_COMMAND_LIST_SIZE
);
if
(
param
)
{
long
tmp
=
strtol
(
param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
tmp
<=
0
)
{
g_error
(
"max command list size
\"
%s
\"
is not a positive "
"integer, line %i"
,
param
->
value
,
param
->
line
);
}
client_max_command_list_size
=
tmp
*
1024
;
}
param
=
config_get_param
(
CONF_MAX_OUTPUT_BUFFER_SIZE
);
if
(
param
)
{
long
tmp
=
strtol
(
param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
tmp
<=
0
)
{
g_error
(
"max output buffer size
\"
%s
\"
is not a positive "
"integer, line %i"
,
param
->
value
,
param
->
line
);
}
client_max_output_buffer_size
=
tmp
*
1024
;
}
client_timeout
=
config_get_positive
(
CONF_CONN_TIMEOUT
,
CLIENT_TIMEOUT_DEFAULT
);
client_max_connections
=
config_get_positive
(
CONF_MAX_CONN
,
CLIENT_MAX_CONNECTIONS_DEFAULT
);
client_max_command_list_size
=
config_get_positive
(
CONF_MAX_COMMAND_LIST_SIZE
,
CLIENT_MAX_COMMAND_LIST_DEFAULT
/
1024
)
*
1024
;
client_max_output_buffer_size
=
config_get_positive
(
CONF_MAX_OUTPUT_BUFFER_SIZE
,
CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT
/
1024
)
*
1024
;
}
static
void
client_close_all
(
void
)
...
...
src/listen.c
View file @
2362ee4a
...
...
@@ -253,23 +253,9 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
void
listenOnPort
(
void
)
{
int
port
=
DEFAULT_PORT
;
int
port
=
config_get_positive
(
CONF_PORT
,
DEFAULT_PORT
)
;
struct
config_param
*
param
=
config_get_next_param
(
CONF_BIND_TO_ADDRESS
,
NULL
);
struct
config_param
*
portParam
=
config_get_param
(
CONF_PORT
);
if
(
portParam
)
{
char
*
test
;
port
=
strtol
(
portParam
->
value
,
&
test
,
10
);
if
(
port
<=
0
||
*
test
!=
'\0'
)
{
g_error
(
"%s
\"
%s
\"
specified at line %i is not a "
"positive integer"
,
CONF_PORT
,
portParam
->
value
,
portParam
->
line
);
}
}
boundPort
=
port
;
do
{
parseListenConfigParam
(
port
,
param
);
...
...
src/playlist.c
View file @
2362ee4a
...
...
@@ -71,7 +71,7 @@
static
GRand
*
g_rand
;
static
Playlist
playlist
;
static
int
playlist_state
=
PLAYLIST_STATE_STOP
;
unsigned
playlist_max_length
=
DEFAULT_PLAYLIST_MAX_LENGTH
;
unsigned
playlist_max_length
;
static
int
playlist_stopOnError
;
static
unsigned
playlist_errorCount
;
static
int
playlist_noGoToNext
;
...
...
@@ -135,9 +135,6 @@ playlist_tag_event(void)
void
initPlaylist
(
void
)
{
char
*
test
;
struct
config_param
*
param
;
g_rand
=
g_rand_new
();
playlist
.
length
=
0
;
...
...
@@ -147,14 +144,8 @@ void initPlaylist(void)
playlist
.
queued
=
-
1
;
playlist
.
current
=
-
1
;
param
=
config_get_param
(
CONF_MAX_PLAYLIST_LENGTH
);
if
(
param
)
{
playlist_max_length
=
strtol
(
param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
g_error
(
"max playlist length
\"
%s
\"
is not an integer, "
"line %i"
,
param
->
value
,
param
->
line
);
}
playlist_max_length
=
config_get_positive
(
CONF_MAX_PLAYLIST_LENGTH
,
DEFAULT_PLAYLIST_MAX_LENGTH
);
playlist_saveAbsolutePaths
=
config_get_bool
(
CONF_SAVE_ABSOLUTE_PATHS
,
...
...
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