fully implemented close_request, close_response
This commit is contained in:
parent
d96e7dd1d8
commit
15da4cacca
4 changed files with 33 additions and 32 deletions
|
@ -31,11 +31,8 @@ typedef struct {
|
|||
} sml_close_request;
|
||||
|
||||
sml_close_request *sml_close_request_init();
|
||||
|
||||
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf);
|
||||
|
||||
sml_close_request * sml_close_request_parse(sml_buffer *buf);
|
||||
|
||||
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf);
|
||||
void sml_close_request_free(sml_close_request *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -28,8 +28,9 @@ extern "C" {
|
|||
|
||||
typedef sml_close_request sml_close_response;
|
||||
|
||||
sml_close_response *sml_close_response_init();
|
||||
sml_close_response *sml_close_response_parse(sml_buffer *buf);
|
||||
|
||||
void sml_close_response_write(sml_close_response *msg, sml_buffer *buf);
|
||||
void sml_close_response_free(sml_close_response *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -27,17 +27,8 @@ sml_close_request *sml_close_request_init() {
|
|||
return close_request;
|
||||
}
|
||||
|
||||
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 1);
|
||||
|
||||
if (msg->global_signature != NULL){
|
||||
sml_octet_string_write(msg->global_signature,buf);
|
||||
} else sml_buf_optional_write(buf);
|
||||
}
|
||||
|
||||
sml_close_request * sml_close_request_parse(sml_buffer *buf) {
|
||||
sml_close_request *msg = (sml_close_request *) malloc(sizeof(sml_close_request));
|
||||
memset(msg, 0, sizeof(sml_close_request));
|
||||
sml_close_request *msg = sml_close_request_init();
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
|
@ -59,11 +50,15 @@ error:
|
|||
return 0;
|
||||
}
|
||||
|
||||
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 1);
|
||||
sml_octet_string_write(msg->global_signature,buf);
|
||||
}
|
||||
|
||||
void sml_close_request_free(sml_close_request *msg) {
|
||||
if (msg) {
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
free(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
#include <sml/sml_close_response.h>
|
||||
#include <stdio.h>
|
||||
|
||||
sml_close_response *sml_close_response_init() {
|
||||
sml_close_response *msg = (sml_close_response *) malloc(sizeof(sml_close_response));
|
||||
memset(msg, 0, sizeof(sml_close_response));
|
||||
return msg;
|
||||
}
|
||||
|
||||
sml_close_response *sml_close_response_parse(sml_buffer *buf) {
|
||||
|
||||
sml_close_response *msg = (sml_close_response *) malloc(sizeof(sml_close_response));
|
||||
memset(msg, 0, sizeof(sml_close_response));
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
sml_close_response *msg = sml_close_response_init();
|
||||
|
||||
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
|
||||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
@ -34,21 +38,25 @@ sml_close_response *sml_close_response_parse(sml_buffer *buf) {
|
|||
buf->error = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
msg->global_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return msg;
|
||||
|
||||
|
||||
msg->global_signature = sml_octet_string_parse(buf);
|
||||
if (sml_buf_has_errors(buf)) goto error;
|
||||
|
||||
return msg;
|
||||
|
||||
error:
|
||||
sml_close_response_free(msg);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void sml_close_response_write(sml_close_response *msg, sml_buffer *buf) {
|
||||
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 1);
|
||||
sml_octet_string_write(msg->global_signature,buf);
|
||||
}
|
||||
|
||||
void sml_close_response_free(sml_close_response *msg) {
|
||||
if (msg) {
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
free(msg);
|
||||
}
|
||||
if (msg) {
|
||||
sml_octet_string_free(msg->global_signature);
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue