Read element from message (in progress)

FossilOrigin-Name: 6ee8f267da48de9b865abf5b7565097387e6436118a1cc80a198c3a47294fc5c
This commit is contained in:
7u83@mail.ru
2018-03-05 20:42:11 +00:00
parent af03e1c601
commit 8817d54d14
11 changed files with 42 additions and 18 deletions

View File

@ -32,6 +32,8 @@
#include "mod.h"
#include "message_set.h"
#include "cw_types.h"
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
@ -215,6 +217,17 @@ int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * dat
}
void cw_read_elem(struct cw_ElemHandler * handler, struct conn * conn,
uint8_t * elem_data, int elem_len, struct sockaddr * from){
mavldata_t data, *result;
char str[30];
result = handler->type->get(&data,elem_data,elem_len);
handler->type->to_str(result,str,30);
printf("Read %d-%s: %s %s\n", handler->id, handler->name, handler->key, str);
/*mavl_add(conn->remote_cfg*/
}
static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
struct sockaddr *from)
@ -386,6 +399,9 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
elem_len = cw_get_elem_len(elem);
cw_read_elem(handler, conn, cw_get_elem_data(elem), elem_len, from);
printf ("Would start elem processing now %d - %s\n",handler->id, handler->name);
continue;
exit(0);

2
src/cw/cw_read_elem.c Normal file
View File

@ -0,0 +1,2 @@

View File

@ -59,4 +59,4 @@ static int put(struct mdata_Elem * e, uint8_t *dst)
#define _I_FROM_STR from_str
const struct mdata_Type cw_type_dword = MDATA_TYPE_INIT();
*/
*/

View File

@ -60,4 +60,4 @@ static int put(struct mdata_Elem * e, uint8_t *dst)
#define _I_FROM_STR from_str
const struct mdata_Type cw_type_word = MDATA_TYPE_INIT();
*/
*/

View File

@ -36,9 +36,12 @@ struct cw_Type{
extern const struct cw_Type cw_type_byte;
#define CW_TYPE_BYTE (&cw_type_byte)
extern const struct mdata_Type cw_type_word;
extern const struct mdata_Type cw_type_dword;
extern const struct cw_Type cw_type_word;
extern const struct cw_Type cw_type_dword;
void cw_types_mavl_delete(mavldata_t *data);
#define cw_types_mavl_create()\
mavl_create(mavl_cmp_kv, cw_types_mavl_delete)
#endif

View File

@ -0,0 +1,7 @@
#include "cw_types.h"
void cw_types_mavl_delete(mavldata_t *data){
const struct cw_Type * type = data->kv.priv;
if (type->del)
type->del(data);
}

View File

@ -32,7 +32,7 @@ struct cw_ElemHandler {
int proto;
int min_len;
int max_len;
const struct mdata_Type * type;
const struct cw_Type * type;
const char * key;
/*
int (*start_in)(struct conn *conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from);