Esempio n. 1
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;
}
Esempio n. 2
0
mvcp_error_code client_queue_add( client demo, client_queue queue, char *file )
{
	mvcp_status_t status;
	mvcp_notifier notifier = mvcp_get_notifier( demo->dv );

	if ( ( queue->tail + 1 ) % 50 == queue->head )
		queue->head = ( queue->head + 1 ) % 50;
	strcpy( queue->list[ queue->tail ], file );
	queue->tail = ( queue->tail + 1 ) % 50;

	mvcp_notifier_get( notifier, &status, queue->unit );
	mvcp_notifier_put( notifier, &status );

	return mvcp_ok;
}