and the data arrauy in dat.
returns 0 if there are no available data.
*/
-int getData(unsigned char **dat)
+unsigned getData(unsigned char *dat, unsigned length)
{
if ((dataLength > 0) && (dataValid == 1))
{
- *dat = (unsigned char *) malloc(dataLength);
- if (*dat == NULL) exit(-12);
- memcpy(*dat,data,dataLength);
- return dataLength;
+ unsigned l = dataLength < length ? dataLength : length;
+ memcpy(dat,data,l);
+ return l;
}
else
{
- *dat = NULL;
return 0;
}
}
*/
//*************************************************************************************************************************
-int getData(unsigned char **dat);
+unsigned getData(unsigned char *dat, unsigned length);
/*
returns the data length.
and the data arrauy in dat.
CFLAGS += -std=gnu99
bin_PROGRAMS = frm_item
-frm_item_SOURCES = frm_item.c item_blocks.c
+frm_item_SOURCES = frm_item.c item_blocks.c FWSN.c serialsource.c
frm_item_SERVER_IDL = item_idl.idl
frm_item_LIBS = frm forb contract fosa rt ulut fcb_client m
#include <stdio.h>
#include <frsh_distributed.h>
#include <item.h>
-
-//ITEM ADD
-//#include "FWSN.h"
+#include "FWSN.h"
static inline bool node_present(fres_item_node_mask nodes, int node)
{
CORBA_long
get_data(fres_item_scheduler obj, const fres_item_node_mask mask, fres_item_data_seq** data, CORBA_Environment *ev)
{
+ unsigned max = 256;
//struct item_status *item_status = (struct item_status*)forb_instance_data(obj);
- /* TODO: */
+ fres_item_data_seq *d = forb_malloc(sizeof(*d));
+
+ d->_buffer = CORBA_sequence_octet_allocbuf(max); //FIXME: CORBA_sequence_fres_item_data_seq_allocbuf(max);
+ d->_maximum = max;
+ d->_length = getData(d->_buffer, d->_maximum);
+
+ *data = d;
return 0;
}
module fres {
module item {
typedef unsigned long long node_mask;
- typedef sequence<unsigned long> data_seq;
+ typedef sequence<octet> data_seq;
interface scheduler {
/** Adds given nodes to network and stats receiving data from them */
long add_nodes(in node_mask mask);