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
8ed3cf3e
Commit
8ed3cf3e
authored
Jan 09, 2009
by
Thomas Jansen
Committed by
Max Kellermann
Jan 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: add a parser for range arguments
A range argument looks like start[:end] and is used to specify the entries of a list that should be returned (rather than the whole list).
parent
5e93d368
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
command.c
src/command.c
+48
-0
No files found.
src/command.c
View file @
8ed3cf3e
...
...
@@ -160,6 +160,54 @@ check_int(struct client *client, int *value_r,
return
true
;
}
static
bool
G_GNUC_PRINTF
(
5
,
6
)
check_range
(
struct
client
*
client
,
int
*
value_r1
,
int
*
value_r2
,
const
char
*
s
,
const
char
*
fmt
,
...)
{
char
*
test
,
*
test2
;
long
value
;
value
=
strtol
(
s
,
&
test
,
10
);
if
(
*
test
!=
'\0'
&&
*
test
!=
':'
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
va_end
(
args
);
return
false
;
}
#if LONG_MAX > INT_MAX
if
(
value
<
INT_MIN
||
value
>
INT_MAX
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Number too large: %s"
,
s
);
return
false
;
}
#endif
*
value_r1
=
(
int
)
value
;
if
(
*
test
==
':'
)
{
value
=
strtol
(
++
test
,
&
test2
,
10
);
if
(
*
test2
!=
'\0'
||
test
==
test2
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
va_end
(
args
);
return
false
;
}
#if LONG_MAX > INT_MAX
if
(
value
<
INT_MIN
||
value
>
INT_MAX
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Number too large: %s"
,
s
);
return
false
;
}
#endif
*
value_r2
=
(
int
)
value
;
}
return
true
;
}
static
bool
check_unsigned
(
struct
client
*
client
,
unsigned
*
value_r
,
const
char
*
s
)
{
...
...
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