const xi_response_t* xi_feed_update( xi_context_t* xi , const xi_feed_t* feed ) { // we shall need it later layer_state_t state = LAYER_STATE_OK; // extract the input layer layer_t* input_layer = xi->layer_chain.top; layer_t* io_layer = xi->layer_chain.bottom; { // init & connect state = CALL_ON_SELF_INIT( io_layer, 0, LAYER_HINT_NONE ); if( state != LAYER_STATE_OK ) { return 0; } xi_connection_data_t conn_data = { XI_HOST, XI_PORT }; state = CALL_ON_SELF_CONNECT( io_layer, ( void *) &conn_data, LAYER_HINT_NONE ); if( state != LAYER_STATE_OK ) { return 0; } } // clean the response before writing to it memset( ( ( csv_layer_data_t* ) input_layer->user_data )->response, 0, sizeof( xi_response_t ) ); // create the input parameter http_layer_input_t http_layer_input = { HTTP_LAYER_INPUT_FEED_UPDATE , xi , 0 , { .xi_update_feed = { ( xi_feed_t * ) feed } } }; state = CALL_ON_SELF_DATA_READY( input_layer, ( void *) &http_layer_input, LAYER_HINT_NONE ); if( state == LAYER_STATE_OK ) { CALL_ON_SELF_ON_DATA_READY( io_layer, ( void *) 0, LAYER_HINT_NONE ); } CALL_ON_SELF_CLOSE( input_layer ); return ( ( csv_layer_data_t* ) input_layer->user_data )->response; }
const xi_response_t* xi_feed_update( xi_context_t* xi , const xi_feed_t* feed ) { layer_t* io_layer = connect_to_endpoint( xi->layer_chain.bottom, XI_HOST, XI_PORT ); if( io_layer == 0 ) { // we are in trouble return 0; } // extract the input layer layer_t* input_layer = xi->layer_chain.top; // clean the response before writing to it memset( ( ( csv_layer_data_t* ) input_layer->user_data )->response, 0, sizeof( xi_response_t ) ); // create the input parameter http_layer_input_t http_layer_input = { HTTP_LAYER_INPUT_FEED_UPDATE , xi , 0 , { .xi_update_feed = { ( xi_feed_t * ) feed } } }; layer_state_t state = CALL_ON_SELF_DATA_READY( input_layer, ( void *) &http_layer_input, LAYER_HINT_NONE ); if( state == LAYER_STATE_OK ) { CALL_ON_SELF_ON_DATA_READY( io_layer, ( void *) 0, LAYER_HINT_NONE ); } CALL_ON_SELF_CLOSE( input_layer ); return ( ( csv_layer_data_t* ) input_layer->user_data )->response; }
if( state != LAYER_STATE_OK ) { return 0; } } // clean the response before writing to it memset( ( ( csv_layer_data_t* ) input_layer->user_data )->response, 0, sizeof( xi_response_t ) ); // create the input parameter http_layer_input_t http_layer_input = { HTTP_LAYER_INPUT_DATASTREAM_GET , xi , 0 , { ( struct xi_get_datastream_t ) { datastream_id, o } } }; state = CALL_ON_SELF_DATA_READY( input_layer, ( void *) &http_layer_input, LAYER_HINT_NONE ); if( state == LAYER_STATE_OK ) { CALL_ON_SELF_ON_DATA_READY( io_layer, ( void *) 0, LAYER_HINT_NONE ); } CALL_ON_SELF_CLOSE( input_layer ); return ( ( csv_layer_data_t* ) input_layer->user_data )->response; } const xi_response_t* xi_datastream_create( xi_context_t* xi, xi_feed_id_t feed_id , const char * datastream_id