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
f11eb14c
Commit
f11eb14c
authored
Jan 21, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: added config_get_positive()
This convenience function parses a configuration value into a positive integer. It aborts if parsing fails.
parent
17222e95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
conf.c
src/conf.c
+20
-0
conf.h
src/conf.h
+3
-0
No files found.
src/conf.c
View file @
f11eb14c
...
...
@@ -407,6 +407,26 @@ config_get_path(const char *name)
return
param
->
value
=
path
;
}
unsigned
config_get_positive
(
const
char
*
name
,
unsigned
default_value
)
{
struct
config_param
*
param
=
config_get_param
(
name
);
long
value
;
char
*
endptr
;
if
(
param
==
NULL
)
return
default_value
;
value
=
strtol
(
param
->
value
,
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
g_error
(
"Not a valid number in line %i"
,
param
->
line
);
if
(
value
<=
0
)
g_error
(
"Not a positive number in line %i"
,
param
->
line
);
return
(
unsigned
)
value
;
}
struct
block_param
*
getBlockParam
(
struct
config_param
*
param
,
const
char
*
name
)
{
...
...
src/conf.h
View file @
f11eb14c
...
...
@@ -110,6 +110,9 @@ config_get_string(const char *name, const char *default_value);
const
char
*
config_get_path
(
const
char
*
name
);
unsigned
config_get_positive
(
const
char
*
name
,
unsigned
default_value
);
struct
block_param
*
getBlockParam
(
struct
config_param
*
param
,
const
char
*
name
);
...
...
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