📄 simple.c
字号:
p_range_prev = p_range_current; if( p_menu->psz_path ) { size_t i_path_size = strlen( p_menu->psz_path ); size_t i_file_size = strlen( &file[0] ); if( (i_path_size + i_file_size >= PATH_MAX) || (i_path_size >= PATH_MAX) ) goto error; strncpy( &path[0], p_menu->psz_path, i_path_size ); strncpy( &path[i_path_size], &file[0], PATH_MAX - (i_path_size + i_file_size) ); path[ i_path_size + i_file_size ] = '\0'; p_range_current = osd_StateNew( p_menu, &path[0], "pressed" ); } else /* absolute paths are used. */ p_range_current = osd_StateNew( p_menu, &file[0], "pressed" ); if( !p_range_current ) goto error; if( !p_range_current->p_pic ) { osd_StatesFree( p_menu, p_range_current ); goto error; } p_range_current->i_x = i_x; p_range_current->i_y = i_y; /* increment the number of ranges for this button */ p_up->i_ranges++; if( p_range_prev ) p_range_prev->p_next = p_range_current; else p_up->p_states = p_range_current; p_range_current->p_prev = p_range_prev; msg_Dbg( p_this, " |- range=%d, file=%s%s", p_up->i_ranges, p_menu->psz_path, &file[0] ); } if( i_index > 0 ) { osd_state_t *p_range = NULL; /* Find the default index for state range */ p_range = p_up->p_states; while( (--i_index > 0) && p_range->p_next ) { osd_state_t *p_temp = NULL; p_temp = p_range->p_next; p_range = p_temp; } p_up->p_current_state = p_range; } else p_up->p_current_state = p_up->p_states; } result = fscanf( fd, "\t%24s", &state[0] ); if( result == 0 ) goto error; if( strncmp( &state[0], "end", 3 ) != 0 ) goto error; /* Continue at the beginning of the while() */ continue; } /* Parse the range state */ if( strncmp( &state[0], "range", 5 ) == 0 ) { osd_state_t *p_range_current = NULL; /* range state currently processed */ osd_state_t *p_range_prev = NULL; /* previous state processed range */ int i_index = 0; p_current->b_range = true; result = fscanf( fd, "\t%24s", &action[0] ); if( result == 0 ) goto error; result = fscanf( fd, "\t%d", &i_index ); if( result == 0 ) goto error; msg_Dbg( p_this, " + hotkey down %s, file=%s%s", &action[0], p_menu->psz_path, &file[0] ); free( p_current->psz_action_down ); p_current->psz_action_down = strdup( &action[0] ); /* Parse range contstruction : * range <hotkey> * <state1> <file1> * * <stateN> <fileN> * end */ while( !feof( fd ) ) { result = fscanf( fd, "\t%255s", &file[0] ); if( result == 0 ) goto error; if( strncmp( &file[0], "end", 3 ) == 0 ) break; p_range_prev = p_range_current; if( p_menu->psz_path ) { size_t i_path_size = strlen( p_menu->psz_path ); size_t i_file_size = strlen( &file[0] ); if( (i_path_size + i_file_size >= PATH_MAX) || (i_path_size >= PATH_MAX) ) goto error; strncpy( &path[0], p_menu->psz_path, i_path_size ); strncpy( &path[i_path_size], &file[0], PATH_MAX - (i_path_size + i_file_size) ); path[ i_path_size + i_file_size ] = '\0'; p_range_current = osd_StateNew( p_menu, &path[0], "pressed" ); } else /* absolute paths are used. */ p_range_current = osd_StateNew( p_menu, &file[0], "pressed" ); if( !p_range_current ) goto error; if( !p_range_current->p_pic ) { osd_StatesFree( p_menu, p_range_current ); goto error; } p_range_current->i_x = i_x; p_range_current->i_y = i_y; /* increment the number of ranges for this button */ p_current->i_ranges++; if( p_range_prev ) p_range_prev->p_next = p_range_current; else p_current->p_states = p_range_current; p_range_current->p_prev = p_range_prev; msg_Dbg( p_this, " |- range=%d, file=%s%s", p_current->i_ranges, p_menu->psz_path, &file[0] ); } if( i_index > 0 ) { osd_state_t *p_range = NULL; /* Find the default index for state range */ p_range = p_current->p_states; while( (--i_index > 0) && p_range->p_next ) { osd_state_t *p_temp = NULL; p_temp = p_range->p_next; p_range = p_temp; } p_current->p_current_state = p_range; } else p_current->p_current_state = p_current->p_states; /* Continue at the beginning of the while() */ continue; } if( strncmp( &state[0], "end", 3 ) == 0 ) break; result = fscanf( fd, "\t%255s", &file[0] ); if( result == 0 ) goto error; p_state_prev = p_state_current; if( ( strncmp( ppsz_button_states[0], &state[0], strlen(ppsz_button_states[0]) ) != 0 ) && ( strncmp( ppsz_button_states[1], &state[0], strlen(ppsz_button_states[1]) ) != 0 ) && ( strncmp( ppsz_button_states[2], &state[0], strlen(ppsz_button_states[2]) ) != 0 ) ) { msg_Err( p_this, "invalid button state %s for button %s " "expected %u: unselect, select or pressed)", &state[0], &action[0], (unsigned)strlen(&state[0])); goto error; } if( p_menu->psz_path ) { size_t i_path_size = strlen( p_menu->psz_path ); size_t i_file_size = strlen( &file[0] ); if( (i_path_size + i_file_size >= PATH_MAX) || (i_path_size >= PATH_MAX) ) goto error; strncpy( &path[0], p_menu->psz_path, i_path_size ); strncpy( &path[i_path_size], &file[0], PATH_MAX - (i_path_size + i_file_size) ); path[ i_path_size + i_file_size ] = '\0'; p_state_current = osd_StateNew( p_menu, &path[0], &state[0] ); } else /* absolute paths are used. */ p_state_current = osd_StateNew( p_menu, &file[0], &state[0] ); if( !p_state_current ) goto error; if( !p_state_current->p_pic ) { osd_StatesFree( p_menu, p_state_current ); goto error; } p_state_current->i_x = i_x; p_state_current->i_y = i_y; if( p_state_prev ) p_state_prev->p_next = p_state_current; else p_current->p_states = p_state_current; p_state_current->p_prev = p_state_prev; msg_Dbg( p_this, " |- state=%s, file=%s%s", &state[0], p_menu->psz_path, &file[0] ); } p_current->p_current_state = p_current->p_states; } /* Find the last button and store its pointer. * The OSD menu behaves like a roundrobin list. */ p_current = p_menu->p_button; while( p_current && p_current->p_next ) { osd_button_t *p_temp = NULL; p_temp = p_current->p_next; p_current = p_temp; } p_menu->p_last_button = p_current; fclose( fd ); return VLC_SUCCESS;error: msg_Err( p_menu, "parsing file failed (returned %d)", result ); osd_MenuFree( p_menu ); fclose( fd ); return VLC_EGENERIC;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -