protocol

protocol tests
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/protocol

commit df5238c9edb3c99c65e003054bbda8cc1398a9f9
parent 35f9f92924fcdfab4665eb44792f2bc1995921b3
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 28 Feb 2017 18:58:46 +0100

Add(write_payload_error)

Diffstat:
Msrc/write_package.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/write_package.c b/src/write_package.c @@ -45,11 +45,25 @@ static void *write_payload_auth_ack(void *pkg, size_t *count) { return ret; } +static void *write_payload_error(void *pkg, size_t *count) { + error_t *err = pkg; + void *ret; + + ret = malloc(sizeof(err->error_type) + sizeof(err->error_len) + err->error_len); + assert(ret != NULL); + + write_member(err->error_type, ret, *count); + write_member(err->error_len, ret, *count); + write_string(err->err, ret, err->error_len, *count); + + return ret; +} typedef void *(*write_callback)(void *, size_t *); static const write_callback arr[] = { &write_payload_auth, - &write_payload_auth_ack + &write_payload_auth_ack, + &write_payload_error }; void *write_payload(package_t *pkg, size_t *count) {