mirror of
https://github.com/clearlinux/hyperstart.git
synced 2026-09-03 12:11:34 +00:00
Merge pull request #163 from laijs/c-string
enable using api command data as c-string inplace
This commit is contained in:
+3
-1
@@ -166,7 +166,9 @@ int hyper_event_read(struct hyper_event *he, int efd)
|
||||
}
|
||||
|
||||
fprintf(stdout, "get length %" PRIu32"\n", len);
|
||||
if (len > buf->size) {
|
||||
// test it with '>=' to leave at least one byte in handle(),
|
||||
// so that handle() can convert the data to c-string inplace.
|
||||
if (len >= buf->size) {
|
||||
fprintf(stderr, "get length %" PRIu32", too long\n", len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1062,6 +1062,8 @@ static int hyper_channel_handle(struct hyper_event *de, uint32_t len)
|
||||
uint8_t *data = NULL;
|
||||
int i, ret = 0;
|
||||
|
||||
// append a null byte to it. hyper_event_read() left this room for us.
|
||||
buf->data[buf->get] = 0;
|
||||
for (i = 0; i < buf->get; i++)
|
||||
fprintf(stdout, "%0x ", buf->data[i]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user