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
989790e7
Commit
989790e7
authored
Aug 12, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client/Response: add method WriteBinary()
Move code from read_stream_art().
parent
831bc711
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
Response.cxx
src/client/Response.cxx
+8
-0
Response.hxx
src/client/Response.hxx
+9
-0
FileCommands.cxx
src/command/FileCommands.cxx
+2
-8
No files found.
src/client/Response.cxx
View file @
989790e7
...
...
@@ -56,6 +56,14 @@ Response::Format(const char *fmt, ...) noexcept
return
success
;
}
bool
Response
::
WriteBinary
(
ConstBuffer
<
void
>
payload
)
noexcept
{
return
Format
(
"binary: %zu
\n
"
,
payload
.
size
)
&&
Write
(
payload
.
data
,
payload
.
size
)
&&
Write
(
"
\n
"
);
}
void
Response
::
Error
(
enum
ack
code
,
const
char
*
msg
)
noexcept
{
...
...
src/client/Response.hxx
View file @
989790e7
...
...
@@ -26,6 +26,7 @@
#include <stddef.h>
#include <stdarg.h>
template
<
typename
T
>
struct
ConstBuffer
;
class
Client
;
class
TagMask
;
...
...
@@ -76,6 +77,14 @@ public:
bool
FormatV
(
const
char
*
fmt
,
va_list
args
)
noexcept
;
bool
Format
(
const
char
*
fmt
,
...)
noexcept
;
/**
* Write a binary chunk; this writes the "binary" line, the
* given chunk and the trailing newline.
*
* @return true on success
*/
bool
WriteBinary
(
ConstBuffer
<
void
>
payload
)
noexcept
;
void
Error
(
enum
ack
code
,
const
char
*
msg
)
noexcept
;
void
FormatError
(
enum
ack
code
,
const
char
*
fmt
,
...)
noexcept
;
};
...
...
src/command/FileCommands.cxx
View file @
989790e7
...
...
@@ -296,14 +296,8 @@ read_stream_art(Response &r, const char *uri, size_t offset)
read_size
=
is
->
Read
(
lock
,
&
buffer
,
CHUNK_SIZE
);
}
r
.
Format
(
"size: %"
PRIoffset
"
\n
"
"binary: %u
\n
"
,
art_file_size
,
read_size
);
r
.
Write
(
buffer
,
read_size
);
r
.
Write
(
"
\n
"
);
r
.
Format
(
"size: %"
PRIoffset
"
\n
"
,
art_file_size
);
r
.
WriteBinary
({
buffer
,
read_size
});
return
CommandResult
::
OK
;
}
...
...
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