Exemplo n.º 1
0
int cw_put_item(uint8_t * dst, struct mbag_item *item)
{
	if (MBAG_STR == item->type ){
		return cw_put_data(dst, item->data, strlen((char *) item->data));
	}

	if (MBAG_BYTE == item->type){
		return cw_put_byte(dst, item->byte);
	}
	if (MBAG_WORD == item->type){
		return cw_put_word(dst, item->word);
	}
	if (MBAG_DWORD == item->type){
		return cw_put_dword(dst, item->dword);
	}
	if (MBAG_BSTR  == item->type) {
		return cw_put_bstr(dst, item->data);
	}

	if ( MBAG_BSTR16 == item->type)
		return cw_put_bstr16(dst,item->data);

	if (MBAG_VENDORSTR == item->type)
	{
		int l=0;
		l+=cw_put_dword(dst, bstrv_get_vendor_id(item->data));
		l+=cw_put_data(dst+4, bstrv_data(item->data),bstrv_len(item->data));
		return l;
	}
	cw_log(LOG_ERR,"No method to put items of type %d",item->type);


	return 0;
}
Exemplo n.º 2
0
int cw_put_mbag_item(uint8_t * dst, struct mbag_item *item)
{
	if (item->type->put){
		cw_dbg(DBG_X,"User put method to put ");
		return item->type->put(item,dst);
	}


	if (MBAG_STR == item->type ){
		return cw_put_data(dst, item->data, strlen((char *) item->data));
	}

	if (MBAG_DATA == item->type){
		return cw_put_data(dst, item->data+1, *((uint8_t*)item->data));
	}

	if (MBAG_BYTE == item->type){
		return cw_put_byte(dst, item->byte);
	}
	if (MBAG_WORD == item->type){
		return cw_put_word(dst, item->word);
	}
	if (MBAG_DWORD == item->type){
		return cw_put_dword(dst, item->dword);
	}
	if (MBAG_BSTR  == item->type) {
		return cw_put_bstr(dst, item->data);
	}

	if ( MBAG_BSTR16 == item->type)
		return cw_put_bstr16(dst,item->data);

	if (MBAG_VENDORSTR == item->type)
	{
		int l=0;
		l+=cw_put_dword(dst, bstrv_get_vendor_id(item->data));
		l+=cw_put_data(dst+4, bstrv_data(item->data),bstrv_len(item->data));
		return l;
	}

	
	if (MBAG_MBAG == item->type){
		*((void**)dst)=item->data;
		return sizeof(void *);
	}

	cw_log(LOG_ERR,"No method to put items of type %s",item->type->name);


	return 0;
}
Exemplo n.º 3
0
static int put ( const struct cw_KTV *data, uint8_t * dst )
{
	return cw_put_bstr ( dst, data->val.ptr );
}