예제 #1
0
파일: qemu-img.c 프로젝트: tycho/qemu
static int read_password(char *buf, int buf_size)
{
    uint8_t ch;
    int i, ret;

    printf("password: "******"\n");
    return ret;
}
예제 #2
0
파일: melt.c 프로젝트: hrshadhin/mlt
static void abnormal_exit_handler(int signum)
{
    // The process is going down hard. Restore the terminal first.
    term_exit();
    // Reset the default handler so the core gets dumped.
    signal( signum, SIG_DFL );
    raise( signum );
}
예제 #3
0
파일: io.c 프로젝트: abasty/videokiss
char get_keypress( )
{
	char value = '\0';
	int pressed = 0;

	fflush( stdout );

	term_init( );
	while ( ( pressed = term_read( ) ) == -1 ) ;
	term_exit( );

	value = (char)pressed;

	return value;
}
예제 #4
0
파일: client.c 프로젝트: gz818/melted
mvcp_error_code client_transport( client demo )
{
	mvcp_error_code error = mvcp_ok;
	int refresh = 1;
	int terminated = 0;
	mvcp_status_t status;
	mvcp_notifier notifier = mvcp_get_notifier( demo->dv );

	while ( !terminated )
	{
		if ( refresh )
		{
			printf( "  +----+ +------+ +----+ +------+ +---+ +-----+ +------+ +-----+ +---+  \n" );
			printf( "  |1=-5| |2=-2.5| |3=-1| |4=-0.5| |5=1| |6=0.5| |7=1.25| |8=2.5| |9=5|  \n" );
			printf( "  +----+ +------+ +----+ +------+ +---+ +-----+ +------+ +-----+ +---+  \n" );
			printf( "\n" );
			printf( "+----------------------------------------------------------------------+\n" );
			printf( "|              0 = quit, x = eXecute, 'space' = pause                  |\n" );
			printf( "|              g = goto a frame, q = queue maintenance                 |\n" );
			printf( "|     h = step -1, j = end of clip, k = start of clip, l = step 1      |\n" );
			printf( "|        eof handling: p = pause, r = repeat, t = terminate            |\n" );
			printf( "|       i = set in point, o = set out point, c = clear in/out          |\n" );
			printf( "|       u = use point settings, d = don't use point settings           |\n" );
			printf( "+----------------------------------------------------------------------+\n" );
			printf( "\n" );
			term_init( );
			refresh = 0;
		}

		client_change_status( demo, 1 );

		switch( term_read( ) )
		{
			case '0':
				terminated = 1;
				break;
			case -1:
				break;
			case ' ':
				error = mvcp_unit_pause( demo->dv, demo->selected_unit );
				break;
			case '1':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, -5000 );
				break;
			case '2':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, -2500 );
				break;
			case '3':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, -1000 );
				break;
			case '4':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, -500 );
				break;
			case '5':
				error = mvcp_unit_play( demo->dv, demo->selected_unit );
				break;
			case '6':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, 500 );
				break;
			case '7':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, 1250 );
				break;
			case '8':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, 2500 );
				break;
			case '9':
				error = mvcp_unit_play_at_speed( demo->dv, demo->selected_unit, 5000 );
				break;
			case 's':
				error = mvcp_unit_goto( demo->dv, demo->selected_unit, 0 );
				break;
			case 'h':
				error = mvcp_unit_step( demo->dv, demo->selected_unit, -1 );
				break;
			case 'j':
				mvcp_notifier_get( notifier, &status, demo->selected_unit );
				error = mvcp_unit_goto( demo->dv, demo->selected_unit, status.tail_out );
				break;
			case 'k':
				mvcp_notifier_get( notifier, &status, demo->selected_unit );
				error = mvcp_unit_goto( demo->dv, demo->selected_unit, status.in );
				break;
			case 'l':
				error = mvcp_unit_step( demo->dv, demo->selected_unit, 1 );
				break;
			case 'p':
				error = mvcp_unit_set( demo->dv, demo->selected_unit, "eof", "pause" );
				break;
			case 'r':
				error = mvcp_unit_set( demo->dv, demo->selected_unit, "eof", "loop" );
				break;
			case 't':
				error = mvcp_unit_set( demo->dv, demo->selected_unit, "eof", "stop" );
				break;
			case 'i':
				error = client_set_in( demo );
				break;
			case 'o':
				error = client_set_out( demo );
				break;
			case 'g':
				client_change_status( demo, 0 );
				term_exit( );
				error = client_goto( demo );
				refresh = 1;
				break;
			case 'c':
				error = client_clear_in_out( demo );
				break;
			case 'u':
				error = mvcp_unit_set( demo->dv, demo->selected_unit, "points", "use" );
				break;
			case 'd':
				error = mvcp_unit_set( demo->dv, demo->selected_unit, "points", "ignore" );
				break;
			case 'x':
				client_change_status( demo, 0 );
				term_exit( );
				client_execute( demo );
				refresh = 1;
				break;
			case 'q':
				client_change_status( demo, 0 );
				term_exit( );
				client_queue_maintenance( demo, &demo->queues[ demo->selected_unit ] );
				refresh = 1;
				break;
		}

		client_change_status( demo, 0 );
	}

	term_exit( );

	return error;
}
예제 #5
0
파일: client.c 프로젝트: gz818/melted
mvcp_error_code client_load( client demo )
{
	mvcp_error_code error = mvcp_ok;
	int terminated = 0;
	int refresh = 1;
	int start = 0;

	strcpy( demo->current_directory, demo->last_directory );

	term_init( );

	while ( !terminated )
	{
		mvcp_dir dir = mvcp_dir_init( demo->dv, demo->current_directory );

		if ( mvcp_dir_count( dir ) == -1 )
		{
			printf( "Invalid directory - retrying %s\n", demo->last_directory );
			mvcp_dir_close( dir );
			dir = mvcp_dir_init( demo->dv, demo->last_directory );
			if ( mvcp_dir_count( dir ) == -1 )
			{
				printf( "Invalid directory - going back to /\n" );
				mvcp_dir_close( dir );
				dir = mvcp_dir_init( demo->dv, "/" );
				strcpy( demo->current_directory, "/" );
			}
			else
			{
				strcpy( demo->current_directory, demo->last_directory );
			}
		}

		terminated = mvcp_dir_count( dir ) == -1;

		if ( !terminated )
		{
			int index = 0;
			int selected = 0;
			int max = 9;
			int end = 0;

			end = mvcp_dir_count( dir );

			strcpy( demo->last_directory, demo->current_directory );

			while ( !selected && !terminated )
			{
				mvcp_dir_entry_t entry;
				int pressed;

				if ( refresh )
				{
					const char *action = "Load & Play";
					if ( demo->queues[ demo->selected_unit ].mode )
						action = "Queue";
					printf( "%s from %s\n\n", action, demo->current_directory );
					if ( strcmp( demo->current_directory, "/" ) )
						printf( "-: Parent directory\n" );
					for ( index = start; index < end && ( index - start ) < max; index ++ )
					{
						mvcp_dir_get( dir, index, &entry );
						printf( "%d: %s\n", index - start + 1, entry.name );
					}
					while ( ( index ++ % 9 ) != 0 )
						printf( "\n" );
					printf( "\n" );
					if ( start + max < end )
						printf( "space = more files" );
					else if ( end > max )
						printf( "space = return to start of list" );
					if ( start > 0 )
						printf( ", b = previous files" );
					printf( "\n" );
					printf( "0 = abort, t = transport, x = execute command, q = queue maintenance\n\n" );
					refresh = 0;
				}

				client_change_status( demo, 1 );

				pressed = term_read( );
				switch( pressed )
				{
					case -1:
						break;
					case '0':
						terminated = 1;
						break;
					case 'b':
						refresh = start - max >= 0;
						if ( refresh )
							start = start - max;
						break;
					case ' ':
						refresh = start + max < end;
						if ( refresh )
						{
							start = start + max;
						}
						else if ( end > max )
						{
							start = 0;
							refresh = 1;
						}
						break;
					case '-':
						if ( strcmp( demo->current_directory, "/" ) )
						{
							selected = 1;
							( *strrchr( demo->current_directory, '/' ) ) = '\0';
							( *( strrchr( demo->current_directory, '/' ) + 1 ) ) = '\0';
						}
						break;
					case 't':
						client_change_status( demo, 0 );
						term_exit( );
						client_transport( demo );
						term_init( );
						selected = 1;
						break;
					case 'x':
						client_change_status( demo, 0 );
						term_exit( );
						client_execute( demo );
						term_init( );
						selected = 1;
						break;
					case 'q':
						client_change_status( demo, 0 );
						term_exit( );
						client_queue_maintenance( demo, &demo->queues[ demo->selected_unit ] );
						term_init( );
						selected = 1;
						break;
					default:
						if ( pressed >= '1' && pressed <= '9' )
						{
							if ( ( start + pressed - '1' ) < end )
							{
								mvcp_dir_get( dir, start + pressed - '1', &entry );
								selected = 1;
								strcat( demo->current_directory, entry.name );
							}
						}
						break;
				}

				client_change_status( demo, 0 );
			}

			mvcp_dir_close( dir );
		}

		if ( !terminated && demo->current_directory[ strlen( demo->current_directory ) - 1 ] != '/' )
		{
			if ( demo->queues[ demo->selected_unit ].mode == 0 )
			{
				error = mvcp_unit_load( demo->dv, demo->selected_unit, demo->current_directory );
				mvcp_unit_play( demo->dv, demo->selected_unit );
			}
			else
			{
				client_queue_add( demo, &demo->queues[ demo->selected_unit ], demo->current_directory );
				printf( "File %s added to queue.\n", demo->current_directory );
			}
			strcpy( demo->current_directory, demo->last_directory );
			refresh = 0;
		}
		else
		{
			refresh = 1;
			start = 0;
		}
	}

	term_exit( );

	return error;
}
예제 #6
0
파일: client.c 프로젝트: gz818/melted
mvcp_error_code client_queue_maintenance( client demo, client_queue queue )
{
	printf( "Queue Maintenance for Unit %d\n\n", queue->unit );

	if ( !queue->mode )
	{
		char ch;
		printf( "Activate queueing? [Y] " );
		ch = get_keypress( );
		if ( ch == 'y' || ch == 'Y' || ch == '\r' )
			queue->mode = 1;
		printf( "\n\n" );
	}

	if ( queue->mode )
	{
		int terminated = 0;
		int last_position = -2;

		term_init( );

		while ( !terminated )
		{
			int first = ( queue->position + 1 ) % 50;
			int index = first;

			if ( first == queue->tail )
				index = first = queue->head;

			if ( queue->head == queue->tail )
			{
				if ( last_position == -2 )
				{
					printf( "Queue is empty\n" );
					printf( "\n" );
					printf( "0 = exit, t = turn off queueing\n\n" );
					last_position = -1;
				}
			}
			else if ( last_position != queue->position )
			{
				printf( "Order of play\n\n" );

				do 
				{
					printf( "%c%02d: %s\n", index == first ? '*' : ' ', index, queue->list[ index ] + 1 );
					index = ( index + 1 ) % 50;
					if ( index == queue->tail )
						index = queue->head;
				}
				while( index != first );
	
				printf( "\n" );
				printf( "0 = exit, t = turn off queueing, c = clear queue\n\n" );
				last_position = queue->position;
			}

			client_change_status( demo, 1 );
			
			switch( term_read( ) )
			{
				case -1:
					break;
				case '0':
					terminated = 1;
					break;
				case 't':
					terminated = 1;
					queue->mode = 0;
					break;
				case 'c':
					queue->head = queue->tail = 0;
					queue->position = -1;
					last_position = -2;
					break;
			}

			client_change_status( demo, 0 );
		}

		term_exit( );
	}

	return mvcp_ok;
}