sysdis-project/central-manager/lib/network/format/serializer.c

65 lines
1.2 KiB
C
Raw Normal View History

2017-04-03 16:04:57 +00:00
#include "serializer.h"
int parse_plane_request(const char* pIn, struct plane_request* pOut){
/* 1. Check buffer length */
if( strlen(pIn)*sizeof(char) != sizeof(struct plane_request) )
return -1;
/* 2. Parse buffer */
memcpy(pOut, pIn, (size_t) sizeof(struct plane_request));
return 0;
}
int parse_viewterm_request(const char* pIn, struct vterm_request* pOut){
/* 1. Check buffer length */
if( strlen(pIn)*sizeof(char) != sizeof(struct vterm_request) )
return -1;
/* 2. Parse buffer */
memcpy(pOut, pIn, sizeof(struct vterm_request));
return 0;
}
int parse_ctrlterm_request(const char* pIn, struct cterm_request* pOut){
/* 1. Check buffer length */
if( strlen(pIn)*sizeof(char) != sizeof(struct cterm_request) )
return -1;
/* 2. Parse buffer */
memcpy(pOut, pIn, sizeof(struct cterm_request));
return 0;
}
int serialize_term_response(const struct term_response* pIn, char* pOut, const size_t pSize){
/* 1. Check buffer length */
if( sizeof(struct term_response) > pSize*sizeof(char) )
return -1;
/* 2. Serialize response into buffer */
memcpy(pOut, pIn, sizeof(struct term_response));
return 0;
}