Пример #1
0
mvcp_error_code client_set_out( client demo )
{
	int position = 0;
	mvcp_status_t status;
	mvcp_notifier notifier = mvcp_parser_get_notifier( demo->parser );
	mvcp_notifier_get( notifier, &status, demo->selected_unit );
	position = status.position;
	return mvcp_unit_set_out( demo->dv, demo->selected_unit, position );
}
Пример #2
0
static void *mvcp_remote_status_thread( void *arg )
{
	mvcp_remote remote = arg;
	char temp[ 10240 ];
	int length = 0;
	int offset = 0;
	mvcp_tokeniser tokeniser = mvcp_tokeniser_init( );
	mvcp_notifier notifier = mvcp_parser_get_notifier( remote->parser );
	mvcp_status_t status;
	int index = 0;

	mvcp_socket_write_data( remote->status, "STATUS\r\n", 8 );
	temp[ 0 ] = '\0';
	while ( !remote->terminated && 
			( length = mvcp_socket_read_data( remote->status, temp + offset, sizeof( temp ) - 1 ) ) >= 0 )
	{
		if ( length < 0 )
			break;
		temp[ length ] = '\0';
		if ( strchr( temp, '\n' ) == NULL )
		{
			offset = length;
			continue;
		}
		offset = 0;
		mvcp_tokeniser_parse_new( tokeniser, temp, "\n" );
		for ( index = 0; index < mvcp_tokeniser_count( tokeniser ); index ++ )
		{
			char *line = mvcp_tokeniser_get_string( tokeniser, index );
			if ( line[ strlen( line ) - 1 ] == '\r' )
			{
				mvcp_util_chomp( line );
				mvcp_status_parse( &status, line );
				mvcp_notifier_put( notifier, &status );
			}
			else
			{
				strcpy( temp, line );
				offset = strlen( temp );
			}
		}
	}

	mvcp_notifier_disconnected( notifier );
	mvcp_tokeniser_close( tokeniser );
	remote->terminated = 1;

	return NULL;
}