Changeset 1c3528868c36e57e12cc0d99722255b261f50c41
- Timestamp:
- 02/13/06 09:30:55
(3 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1139819455 +0000
- git-parent:
[8a1c45dff8c198bf15626a10093ce45a7a114c20]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1139819455 +0000
- Message:
All Unicode fixes for fopen() (refs #528)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r9efc237 |
r1c35288 |
|
| 421 | 421 | asprintf( &psz_path, "%s%s", j < 0 ? f_dir : *subdirs, p_fixed_name ); |
|---|
| 422 | 422 | msg_Dbg( p_this, "autodetected subtitle: %s with priority %d", p_fixed_name, i_prio ); |
|---|
| 423 | | /* FIXME: a portable wrapper for stat() or access() would be more suited */ |
|---|
| | 423 | /* FIXME: a portable wrapper for stat() or access() would be more suited */ |
|---|
| 424 | 424 | if( ( f = utf8_fopen( psz_path, "rt" ) ) ) |
|---|
| 425 | 425 | { |
|---|
| 426 | 426 | fclose( f ); |
|---|
| 427 | | msg_Dbg( p_this, "autodetected subtitle: %s with priority %d", p_fixed_name, i_prio ); |
|---|
| | 427 | msg_Dbg( p_this, "autodetected subtitle: %s with priority %d", p_fixed_name, i_prio ); |
|---|
| 428 | 428 | result[i_sub_count].priority = i_prio; |
|---|
| 429 | 429 | result[i_sub_count].psz_fname = psz_path; |
|---|
| r2cb472d |
r1c35288 |
|
| 35 | 35 | #include <vlc_filter.h> |
|---|
| 36 | 36 | #include <vlc_image.h> |
|---|
| | 37 | #include <charset.h> |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | static picture_t *ImageRead( image_handler_t *, block_t *, |
|---|
| … | … | |
| 207 | 208 | int i_size; |
|---|
| 208 | 209 | |
|---|
| 209 | | file = fopen( psz_url, "rb" ); |
|---|
| | 210 | file = utf8_fopen( psz_url, "rb" ); |
|---|
| 210 | 211 | if( !file ) |
|---|
| 211 | 212 | { |
|---|
| … | … | |
| 345 | 346 | } |
|---|
| 346 | 347 | |
|---|
| 347 | | file = fopen( psz_url, "wb" ); |
|---|
| | 348 | file = utf8_fopen( psz_url, "wb" ); |
|---|
| 348 | 349 | if( !file ) |
|---|
| 349 | 350 | { |
|---|
| rbcf4277 |
r1c35288 |
|
| 1626 | 1626 | msg_Dbg( p_this, "loading plugins cache file %s", psz_filename ); |
|---|
| 1627 | 1627 | |
|---|
| 1628 | | file = fopen( psz_filename, "rb" ); |
|---|
| | 1628 | file = utf8_fopen( psz_filename, "rb" ); |
|---|
| 1629 | 1629 | if( !file ) |
|---|
| 1630 | 1630 | { |
|---|
| … | … | |
| 1948 | 1948 | strcat( psz_filename, "/CACHEDIR.TAG" ); |
|---|
| 1949 | 1949 | |
|---|
| 1950 | | file = fopen( psz_filename, "wb" ); |
|---|
| | 1950 | file = utf8_fopen( psz_filename, "wb" ); |
|---|
| 1951 | 1951 | if( file ) |
|---|
| 1952 | 1952 | { |
|---|
| … | … | |
| 1960 | 1960 | msg_Dbg( p_this, "saving plugins cache file %s", psz_filename ); |
|---|
| 1961 | 1961 | |
|---|
| 1962 | | file = fopen( psz_filename, "wb" ); |
|---|
| | 1962 | file = utf8_fopen( psz_filename, "wb" ); |
|---|
| 1963 | 1963 | if( !file ) |
|---|
| 1964 | 1964 | { |
|---|
| r638acbf |
r1c35288 |
|
| 46 | 46 | #include "vlc_xml.h" |
|---|
| 47 | 47 | #include "vlc_interaction.h" |
|---|
| | 48 | #include "charset.h" |
|---|
| 48 | 49 | |
|---|
| 49 | 50 | /***************************************************************************** |
|---|
| … | … | |
| 1277 | 1278 | { |
|---|
| 1278 | 1279 | |
|---|
| 1279 | | p_file = fopen( psz_dest, "w" ); |
|---|
| | 1280 | p_file = utf8_fopen( psz_dest, "w" ); |
|---|
| 1280 | 1281 | if( !p_file ) |
|---|
| 1281 | 1282 | { |
|---|
| recf356c |
r1c35288 |
|
| 44 | 44 | #include "vlc_vlm.h" |
|---|
| 45 | 45 | #include "vlc_vod.h" |
|---|
| | 46 | #include "charset.h" |
|---|
| 46 | 47 | |
|---|
| 47 | 48 | #define FREE( p ) \ |
|---|
| … | … | |
| 195 | 196 | if( !p_vlm || !psz_file ) return 1; |
|---|
| 196 | 197 | |
|---|
| 197 | | file = fopen( psz_file, "wt" ); |
|---|
| | 198 | file = utf8_fopen( psz_file, "wt" ); |
|---|
| 198 | 199 | if( file == NULL ) return 1; |
|---|
| 199 | 200 | |
|---|
| … | … | |
| 222 | 223 | if( !p_vlm || !psz_file ) return 1; |
|---|
| 223 | 224 | |
|---|
| 224 | | file = fopen( psz_file, "r" ); |
|---|
| | 225 | file = utf8_fopen( psz_file, "r" ); |
|---|
| 225 | 226 | if( file == NULL ) return 1; |
|---|
| 226 | 227 | |
|---|
| r2cb472d |
r1c35288 |
|
| 35 | 35 | |
|---|
| 36 | 36 | #include "network.h" |
|---|
| | 37 | #include "charset.h" |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | /* FIXME: rwlock on acl, but libvlc doesn't implement rwlock */ |
|---|
| … | … | |
| 269 | 270 | return -1; |
|---|
| 270 | 271 | |
|---|
| 271 | | file = fopen( psz_path, "r" ); |
|---|
| | 272 | file = utf8_fopen( psz_path, "r" ); |
|---|
| 272 | 273 | if( file == NULL ) |
|---|
| 273 | 274 | return -1; |
|---|
| rfba7cf5 |
r1c35288 |
|
| 35 | 35 | #include <vlc_image.h> |
|---|
| 36 | 36 | #include <vlc_osd.h> |
|---|
| | 37 | #include <charset.h> |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | |
|---|
| … | … | |
| 70 | 71 | p_pic = image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out ); |
|---|
| 71 | 72 | image_HandlerDelete( p_image ); |
|---|
| 72 | | #if 0 |
|---|
| | 73 | #if 0 |
|---|
| 73 | 74 | p_pic = osd_YuvaYuvp( p_this, p_pic ); |
|---|
| 74 | 75 | #endif |
|---|
| … | … | |
| 85 | 86 | { |
|---|
| 86 | 87 | if( !p_menu ) return NULL; |
|---|
| 87 | | |
|---|
| | 88 | |
|---|
| 88 | 89 | p_menu->p_state = (osd_menu_state_t *) malloc( sizeof( osd_menu_state_t ) ); |
|---|
| 89 | 90 | if( !p_menu->p_state ) |
|---|
| … | … | |
| 96 | 97 | p_menu->i_x = i_x; |
|---|
| 97 | 98 | p_menu->i_y = i_y; |
|---|
| 98 | | |
|---|
| 99 | | return p_menu; |
|---|
| | 99 | |
|---|
| | 100 | return p_menu; |
|---|
| 100 | 101 | } |
|---|
| 101 | 102 | |
|---|
| … | … | |
| 124 | 125 | if( !p_button ) |
|---|
| 125 | 126 | return NULL; |
|---|
| 126 | | |
|---|
| | 127 | |
|---|
| 127 | 128 | memset( p_button, 0, sizeof(osd_button_t) ); |
|---|
| 128 | 129 | p_button->psz_action = strdup(psz_action); |
|---|
| … | … | |
| 131 | 132 | p_button->i_x = i_x; |
|---|
| 132 | 133 | p_button->i_y = i_y; |
|---|
| 133 | | |
|---|
| | 134 | |
|---|
| 134 | 135 | return p_button; |
|---|
| 135 | 136 | } |
|---|
| … | … | |
| 137 | 138 | /***************************************************************************** |
|---|
| 138 | 139 | * Free a button |
|---|
| 139 | | *****************************************************************************/ |
|---|
| | 140 | *****************************************************************************/ |
|---|
| 140 | 141 | static void osd_ButtonFree( vlc_object_t *p_this, osd_button_t *p_button ) |
|---|
| 141 | 142 | { |
|---|
| … | … | |
| 143 | 144 | osd_button_t *p_next = NULL; |
|---|
| 144 | 145 | osd_button_t *p_prev = NULL; |
|---|
| 145 | | |
|---|
| | 146 | |
|---|
| 146 | 147 | /* First walk to the end. */ |
|---|
| 147 | 148 | while( p_current->p_next ) |
|---|
| 148 | 149 | { |
|---|
| 149 | 150 | p_next = p_current->p_next; |
|---|
| 150 | | p_current = p_next; |
|---|
| | 151 | p_current = p_next; |
|---|
| 151 | 152 | } |
|---|
| 152 | 153 | /* Then free end first and walk to the start. */ |
|---|
| … | … | |
| 158 | 159 | if( p_current->p_next ) |
|---|
| 159 | 160 | { |
|---|
| 160 | | if( p_current->p_next->psz_name ) |
|---|
| | 161 | if( p_current->p_next->psz_name ) |
|---|
| 161 | 162 | free( p_current->p_next->psz_name ); |
|---|
| 162 | 163 | if( p_current->p_next->psz_action ) |
|---|
| … | … | |
| 168 | 169 | if( p_current->p_feedback ) |
|---|
| 169 | 170 | free( p_current->p_feedback ); |
|---|
| 170 | | |
|---|
| | 171 | |
|---|
| 171 | 172 | p_current->p_next->psz_action_down = NULL; |
|---|
| 172 | 173 | p_current->p_next->psz_action = NULL; |
|---|
| 173 | 174 | p_current->p_next->psz_name = NULL; |
|---|
| 174 | 175 | p_current->p_feedback = NULL; |
|---|
| 175 | | |
|---|
| 176 | | /* Free all states first */ |
|---|
| 177 | | if( p_current->p_next->p_states ) |
|---|
| | 176 | |
|---|
| | 177 | /* Free all states first */ |
|---|
| | 178 | if( p_current->p_next->p_states ) |
|---|
| 178 | 179 | osd_StatesFree( p_this, p_current->p_next->p_states ); |
|---|
| 179 | | p_current->p_next->p_states = NULL; |
|---|
| | 180 | p_current->p_next->p_states = NULL; |
|---|
| 180 | 181 | if( p_current->p_next) free( p_current->p_next ); |
|---|
| 181 | | p_current->p_next = NULL; |
|---|
| 182 | | } |
|---|
| 183 | | |
|---|
| | 182 | p_current->p_next = NULL; |
|---|
| | 183 | } |
|---|
| | 184 | |
|---|
| 184 | 185 | if( p_current->p_up ) |
|---|
| 185 | 186 | { |
|---|
| 186 | | if( p_current->p_up->psz_name ) |
|---|
| | 187 | if( p_current->p_up->psz_name ) |
|---|
| 187 | 188 | free( p_current->p_up->psz_name ); |
|---|
| 188 | 189 | if( p_current->p_up->psz_action ) |
|---|
| … | … | |
| 194 | 195 | if( p_current->p_feedback ) |
|---|
| 195 | 196 | free( p_current->p_feedback ); |
|---|
| 196 | | |
|---|
| | 197 | |
|---|
| 197 | 198 | p_current->p_up->psz_action_down = NULL; |
|---|
| 198 | 199 | p_current->p_up->psz_action = NULL; |
|---|
| 199 | 200 | p_current->p_up->psz_name = NULL; |
|---|
| 200 | 201 | p_current->p_feedback = NULL; |
|---|
| 201 | | |
|---|
| 202 | | /* Free all states first */ |
|---|
| 203 | | if( p_current->p_up->p_states ) |
|---|
| | 202 | |
|---|
| | 203 | /* Free all states first */ |
|---|
| | 204 | if( p_current->p_up->p_states ) |
|---|
| 204 | 205 | osd_StatesFree( p_this, p_current->p_up->p_states ); |
|---|
| 205 | | p_current->p_up->p_states = NULL; |
|---|
| | 206 | p_current->p_up->p_states = NULL; |
|---|
| 206 | 207 | if( p_current->p_up ) free( p_current->p_up ); |
|---|
| 207 | | p_current->p_up = NULL; |
|---|
| | 208 | p_current->p_up = NULL; |
|---|
| 208 | 209 | } |
|---|
| 209 | | } |
|---|
| | 210 | } |
|---|
| 210 | 211 | /* Free the last one. */ |
|---|
| 211 | | if( p_button ) |
|---|
| 212 | | { |
|---|
| 213 | | msg_Dbg( p_this, "+ freeing button %s [%p]", p_button->psz_action, p_button ); |
|---|
| | 212 | if( p_button ) |
|---|
| | 213 | { |
|---|
| | 214 | msg_Dbg( p_this, "+ freeing button %s [%p]", p_button->psz_action, p_button ); |
|---|
| 214 | 215 | if( p_button->psz_name ) free( p_button->psz_name ); |
|---|
| 215 | 216 | if( p_button->psz_action ) free( p_button->psz_action ); |
|---|
| 216 | | if( p_button->psz_action_down ) free( p_button->psz_action_down ); |
|---|
| | 217 | if( p_button->psz_action_down ) free( p_button->psz_action_down ); |
|---|
| 217 | 218 | if( p_current->p_feedback && p_current->p_feedback->p_data_orig ) |
|---|
| 218 | 219 | free( p_current->p_feedback->p_data_orig ); |
|---|
| 219 | 220 | if( p_current->p_feedback ) |
|---|
| 220 | 221 | free( p_current->p_feedback ); |
|---|
| 221 | | |
|---|
| | 222 | |
|---|
| 222 | 223 | p_button->psz_name = NULL; |
|---|
| 223 | 224 | p_button->psz_action = NULL; |
|---|
| 224 | 225 | p_button->psz_action_down = NULL; |
|---|
| 225 | 226 | p_current->p_feedback = NULL; |
|---|
| 226 | | |
|---|
| | 227 | |
|---|
| 227 | 228 | if( p_button->p_states ) |
|---|
| 228 | 229 | osd_StatesFree( p_this, p_button->p_states ); |
|---|
| 229 | | p_button->p_states = NULL; |
|---|
| | 230 | p_button->p_states = NULL; |
|---|
| 230 | 231 | free( p_button ); |
|---|
| 231 | 232 | p_button = NULL; |
|---|
| … | … | |
| 242 | 243 | if( !p_state ) |
|---|
| 243 | 244 | return NULL; |
|---|
| 244 | | |
|---|
| 245 | | memset( p_state, 0, sizeof(osd_state_t) ); |
|---|
| | 245 | |
|---|
| | 246 | memset( p_state, 0, sizeof(osd_state_t) ); |
|---|
| 246 | 247 | p_state->p_pic = osd_LoadImage( p_this, psz_file ); |
|---|
| 247 | 248 | |
|---|
| … | … | |
| 267 | 268 | osd_state_t *p_next = NULL; |
|---|
| 268 | 269 | osd_state_t *p_prev = NULL; |
|---|
| 269 | | |
|---|
| | 270 | |
|---|
| 270 | 271 | while( p_state->p_next ) |
|---|
| 271 | 272 | { |
|---|
| … | … | |
| 284 | 285 | free( p_state->p_next->p_pic->p_data_orig ); |
|---|
| 285 | 286 | if( p_state->p_next->p_pic ) free( p_state->p_next->p_pic ); |
|---|
| 286 | | p_state->p_next->p_pic = NULL; |
|---|
| | 287 | p_state->p_next->p_pic = NULL; |
|---|
| 287 | 288 | if( p_state->p_next->psz_state ) free( p_state->p_next->psz_state ); |
|---|
| 288 | 289 | p_state->p_next->psz_state = NULL; |
|---|
| 289 | 290 | free( p_state->p_next ); |
|---|
| 290 | | p_state->p_next = NULL; |
|---|
| | 291 | p_state->p_next = NULL; |
|---|
| 291 | 292 | } |
|---|
| 292 | 293 | } |
|---|
| … | … | |
| 313 | 314 | { |
|---|
| 314 | 315 | osd_button_t *p_current = NULL; /* button currently processed */ |
|---|
| 315 | | osd_button_t *p_prev = NULL; /* previous processed button */ |
|---|
| 316 | | |
|---|
| 317 | | #define MAX_FILE_PATH 256 |
|---|
| | 316 | osd_button_t *p_prev = NULL; /* previous processed button */ |
|---|
| | 317 | |
|---|
| | 318 | #define MAX_FILE_PATH 256 |
|---|
| 318 | 319 | FILE *fd = NULL; |
|---|
| 319 | 320 | int result = 0; |
|---|
| 320 | | |
|---|
| | 321 | |
|---|
| 321 | 322 | msg_Dbg( p_this, "opening osd definition file %s", psz_file ); |
|---|
| 322 | | fd = fopen( psz_file, "r" ); |
|---|
| 323 | | if( !fd ) |
|---|
| | 323 | fd = utf8_fopen( psz_file, "r" ); |
|---|
| | 324 | if( !fd ) |
|---|
| 324 | 325 | { |
|---|
| 325 | 326 | msg_Err( p_this, "failed opening osd definition file %s", psz_file ); |
|---|
| 326 | 327 | return VLC_EGENERIC; |
|---|
| 327 | 328 | } |
|---|
| 328 | | |
|---|
| 329 | | /* Read first line */ |
|---|
| | 329 | |
|---|
| | 330 | /* Read first line */ |
|---|
| 330 | 331 | if( !feof( fd ) ) |
|---|
| 331 | 332 | { |
|---|
| … | … | |
| 338 | 339 | psz_path = config_GetPsz( p_this, "osdmenu-file-path" ); |
|---|
| 339 | 340 | if( psz_path == NULL ) |
|---|
| 340 | | { |
|---|
| | 341 | { |
|---|
| 341 | 342 | result = fscanf(fd, "%24s %255s", &action[0], &path[0] ); |
|---|
| 342 | 343 | } |
|---|
| 343 | 344 | else |
|---|
| 344 | 345 | { |
|---|
| 345 | | /* psz_path is not null and therefor &path[0] cannot be NULL |
|---|
| | 346 | /* psz_path is not null and therefor &path[0] cannot be NULL |
|---|
| 346 | 347 | * it might be null terminated. |
|---|
| 347 | 348 | */ |
|---|
| … | … | |
| 358 | 359 | if( (i_len > 0) && path[i_len] != '\\' ) |
|---|
| 359 | 360 | path[i_len] = '\\'; |
|---|
| 360 | | #else |
|---|
| | 361 | #else |
|---|
| 361 | 362 | if( (i_len > 0) && path[i_len] != '/' ) |
|---|
| 362 | 363 | path[i_len] = '/'; |
|---|
| … | … | |
| 364 | 365 | path[i_len+1] = '\0'; |
|---|
| 365 | 366 | if( result == 0 || result == EOF ) |
|---|
| 366 | | goto error; |
|---|
| | 367 | goto error; |
|---|
| 367 | 368 | msg_Dbg( p_this, "%s=%s", &action[0], &path[0] ); |
|---|
| 368 | | |
|---|
| | 369 | |
|---|
| 369 | 370 | if( i_len == 0 ) |
|---|
| 370 | 371 | *p_menu = osd_MenuNew( *p_menu, NULL, 0, 0 ); |
|---|
| … | … | |
| 372 | 373 | *p_menu = osd_MenuNew( *p_menu, &path[0], 0, 0 ); |
|---|
| 373 | 374 | } |
|---|
| 374 | | |
|---|
| | 375 | |
|---|
| 375 | 376 | if( !*p_menu ) |
|---|
| 376 | 377 | goto error; |
|---|
| 377 | | |
|---|
| | 378 | |
|---|
| 378 | 379 | /* read successive lines */ |
|---|
| 379 | 380 | while( !feof( fd ) ) |
|---|
| 380 | | { |
|---|
| | 381 | { |
|---|
| 381 | 382 | osd_state_t *p_state_current = NULL; /* button state currently processed */ |
|---|
| 382 | | osd_state_t *p_state_prev = NULL; /* previous state processed button */ |
|---|
| 383 | | |
|---|
| 384 | | char cmd[25] = ""; |
|---|
| | 383 | osd_state_t *p_state_prev = NULL; /* previous state processed button */ |
|---|
| | 384 | |
|---|
| | 385 | char cmd[25] = ""; |
|---|
| 385 | 386 | char action[25] = ""; |
|---|
| 386 | 387 | char state[25] = ""; |
|---|
| 387 | 388 | char file[256] = ""; |
|---|
| 388 | | char path[512] = ""; |
|---|
| | 389 | char path[512] = ""; |
|---|
| 389 | 390 | int i_x = 0; |
|---|
| 390 | 391 | int i_y = 0; |
|---|
| … | … | |
| 392 | 393 | result = fscanf( fd, "%24s %24s (%d,%d)", &cmd[0], &action[0], &i_x, &i_y ); |
|---|
| 393 | 394 | if( result == 0 ) |
|---|
| 394 | | goto error; |
|---|
| | 395 | goto error; |
|---|
| 395 | 396 | if( strncmp( &cmd[0], "action", 6 ) != 0 ) |
|---|
| 396 | 397 | break; |
|---|
| 397 | | msg_Dbg( p_this, " + %s hotkey=%s (%d,%d)", &cmd[0], &action[0], i_x, i_y ); |
|---|
| 398 | | |
|---|
| | 398 | msg_Dbg( p_this, " + %s hotkey=%s (%d,%d)", &cmd[0], &action[0], i_x, i_y ); |
|---|
| | 399 | |
|---|
| 399 | 400 | p_prev = p_current; |
|---|
| 400 | | p_current = osd_ButtonNew( &action[0], i_x, i_y ); |
|---|
| | 401 | p_current = osd_ButtonNew( &action[0], i_x, i_y ); |
|---|
| 401 | 402 | if( !p_current ) |
|---|
| 402 | 403 | goto error; |
|---|
| 403 | | |
|---|
| | 404 | |
|---|
| 404 | 405 | if( p_prev ) |
|---|
| 405 | | p_prev->p_next = p_current; |
|---|
| | 406 | p_prev->p_next = p_current; |
|---|
| 406 | 407 | else |
|---|
| 407 | | (*p_menu)->p_button = p_current; |
|---|
| | 408 | (*p_menu)->p_button = p_current; |
|---|
| 408 | 409 | p_current->p_prev = p_prev; |
|---|
| 409 | | |
|---|
| | 410 | |
|---|
| 410 | 411 | /* parse all states */ |
|---|
| 411 | 412 | while( !feof( fd ) ) |
|---|
| 412 | 413 | { |
|---|
| 413 | 414 | char type[25] = ""; |
|---|
| 414 | | |
|---|
| 415 | | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| | 415 | |
|---|
| | 416 | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| 416 | 417 | if( result == 0 ) |
|---|
| 417 | 418 | goto error; |
|---|
| 418 | | |
|---|
| 419 | | /* FIXME: We only parse one level deep now */ |
|---|
| | 419 | |
|---|
| | 420 | /* FIXME: We only parse one level deep now */ |
|---|
| 420 | 421 | if( strncmp( &state[0], "action", 6 ) == 0 ) |
|---|
| 421 | 422 | { |
|---|
| 422 | 423 | osd_button_t *p_up = NULL; |
|---|
| 423 | | |
|---|
| | 424 | |
|---|
| 424 | 425 | result = fscanf( fd, "%24s (%d,%d)", &action[0], &i_x, &i_y ); |
|---|
| 425 | 426 | if( result == 0 ) |
|---|
| 426 | 427 | goto error; |
|---|
| 427 | | /* create new button */ |
|---|
| 428 | | p_up = osd_ButtonNew( &action[0], i_x, i_y ); |
|---|
| 429 | | if( !p_up ) |
|---|
| | 428 | /* create new button */ |
|---|
| | 429 | p_up = osd_ButtonNew( &action[0], i_x, i_y ); |
|---|
| | 430 | if( !p_up ) |
|---|
| 430 | 431 | goto error; |
|---|
| 431 | | /* Link to list */ |
|---|
| | 432 | /* Link to list */ |
|---|
| 432 | 433 | p_up->p_down = p_current; |
|---|
| 433 | | p_current->p_up = p_up; |
|---|
| | 434 | p_current->p_up = p_up; |
|---|
| 434 | 435 | msg_Dbg( p_this, " + (menu up) hotkey=%s (%d,%d)", &action[0], i_x, i_y ); |
|---|
| 435 | 436 | /* Parse type state */ |
|---|
| 436 | | result = fscanf( fd, "\t%24s %24s", &cmd[0], &type[0] ); |
|---|
| | 437 | result = fscanf( fd, "\t%24s %24s", &cmd[0], &type[0] ); |
|---|
| 437 | 438 | if( result == 0 ) |
|---|
| 438 | 439 | goto error; |
|---|
| 439 | 440 | if( strncmp( &cmd[0], "type", 4 ) == 0 ) |
|---|
| 440 | | { |
|---|
| | 441 | { |
|---|
| 441 | 442 | if( strncmp( &type[0], "volume", 6 ) == 0 ) |
|---|
| 442 | 443 | { |
|---|
| … | … | |
| 446 | 447 | } |
|---|
| 447 | 448 | /* Parse range state */ |
|---|
| 448 | | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| | 449 | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| 449 | 450 | if( result == 0 ) |
|---|
| 450 | 451 | goto error; |
|---|
| 451 | | /* Parse the range state */ |
|---|
| | 452 | /* Parse the range state */ |
|---|
| 452 | 453 | if( strncmp( &state[0], "range", 5 ) == 0 ) |
|---|
| 453 | 454 | { |
|---|
| 454 | 455 | osd_state_t *p_range_current = NULL; /* range state currently processed */ |
|---|
| 455 | | osd_state_t *p_range_prev = NULL; /* previous state processed range */ |
|---|
| | 456 | osd_state_t *p_range_prev = NULL; /* previous state processed range */ |
|---|
| 456 | 457 | int i_index = 0; |
|---|
| 457 | | |
|---|
| | 458 | |
|---|
| 458 | 459 | p_up->b_range = VLC_TRUE; |
|---|
| 459 | | |
|---|
| 460 | | result = fscanf( fd, "\t%24s", &action[0] ); |
|---|
| | 460 | |
|---|
| | 461 | result = fscanf( fd, "\t%24s", &action[0] ); |
|---|
| 461 | 462 | if( result == 0 ) |
|---|
| 462 | 463 | goto error; |
|---|
| 463 | | |
|---|
| 464 | | result = fscanf( fd, "\t%d", &i_index ); |
|---|
| | 464 | |
|---|
| | 465 | result = fscanf( fd, "\t%d", &i_index ); |
|---|
| 465 | 466 | if( result == 0 ) |
|---|
| 466 | 467 | goto error; |
|---|
| 467 | | |
|---|
| | 468 | |
|---|
| 468 | 469 | msg_Dbg( p_this, " + (menu up) hotkey down %s, file=%s%s", &action[0], (*p_menu)->psz_path, &file[0] ); |
|---|
| 469 | | |
|---|
| | 470 | |
|---|
| 470 | 471 | if( p_up->psz_action_down ) free( p_up->psz_action_down ); |
|---|
| 471 | | p_up->psz_action_down = strdup( &action[0] ); |
|---|
| 472 | | |
|---|
| | 472 | p_up->psz_action_down = strdup( &action[0] ); |
|---|
| | 473 | |
|---|
| 473 | 474 | /* Parse range contstruction : |
|---|
| 474 | | * range <hotkey> |
|---|
| | 475 | * range <hotkey> |
|---|
| 475 | 476 | * <state1> <file1> |
|---|
| 476 | 477 | * |
|---|
| 477 | 478 | * <stateN> <fileN> |
|---|
| 478 | | * end |
|---|
| 479 | | */ |
|---|
| | 479 | * end |
|---|
| | 480 | */ |
|---|
| 480 | 481 | while( !feof( fd ) ) |
|---|
| 481 | 482 | { |
|---|
| 482 | | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| | 483 | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| 483 | 484 | if( result == 0 ) |
|---|
| 484 | 485 | goto error; |
|---|
| 485 | 486 | if( strncmp( &file[0], "end", 3 ) == 0 ) |
|---|
| 486 | 487 | break; |
|---|
| 487 | | |
|---|
| | 488 | |
|---|
| 488 | 489 | p_range_prev = p_range_current; |
|---|
| 489 | | |
|---|
| | 490 | |
|---|
| 490 | 491 | if( (*p_menu)->psz_path ) |
|---|
| 491 | 492 | { |
|---|
| 492 | 493 | size_t i_path_size = strlen( (*p_menu)->psz_path ); |
|---|
| 493 | 494 | size_t i_file_size = strlen( &file[0] ); |
|---|
| 494 | | |
|---|
| | 495 | |
|---|
| 495 | 496 | strncpy( &path[0], (*p_menu)->psz_path, i_path_size ); |
|---|
| 496 | 497 | strncpy( &path[i_path_size], &file[0], 512 - (i_path_size + i_file_size) ); |
|---|
| 497 | 498 | path[ i_path_size + i_file_size ] = '\0'; |
|---|
| 498 | | |
|---|
| | 499 | |
|---|
| 499 | 500 | p_range_current = osd_StateNew( p_this, &path[0], "pressed" ); |
|---|
| 500 | 501 | } |
|---|
| 501 | 502 | else /* absolute paths are used. */ |
|---|
| 502 | 503 | p_range_current = osd_StateNew( p_this, &file[0], "pressed" ); |
|---|
| 503 | | |
|---|
| | 504 | |
|---|
| 504 | 505 | if( !p_range_current || !p_range_current->p_pic ) |
|---|
| 505 | 506 | goto error; |
|---|
| 506 | | |
|---|
| 507 | | /* increment the number of ranges for this button */ |
|---|
| | 507 | |
|---|
| | 508 | /* increment the number of ranges for this button */ |
|---|
| 508 | 509 | p_up->i_ranges++; |
|---|
| 509 | | |
|---|
| | 510 | |
|---|
| 510 | 511 | if( p_range_prev ) |
|---|
| 511 | 512 | p_range_prev->p_next = p_range_current; |
|---|
| 512 | 513 | else |
|---|
| 513 | | p_up->p_states = p_range_current; |
|---|
| | 514 | p_up->p_states = p_range_current; |
|---|
| 514 | 515 | p_range_current->p_prev = p_range_prev; |
|---|
| 515 | | |
|---|
| 516 | | msg_Dbg( p_this, " |- range=%d, file=%s%s", |
|---|
| 517 | | p_up->i_ranges, |
|---|
| 518 | | (*p_menu)->psz_path, &file[0] ); |
|---|
| | 516 | |
|---|
| | 517 | msg_Dbg( p_this, " |- range=%d, file=%s%s", |
|---|
| | 518 | p_up->i_ranges, |
|---|
| | 519 | (*p_menu)->psz_path, &file[0] ); |
|---|
| 519 | 520 | } |
|---|
| 520 | 521 | if( i_index > 0 ) |
|---|
| 521 | | { |
|---|
| | 522 | { |
|---|
| 522 | 523 | osd_state_t *p_range = NULL; |
|---|
| 523 | | |
|---|
| 524 | | /* Find the default index for state range */ |
|---|
| | 524 | |
|---|
| | 525 | /* Find the default index for state range */ |
|---|
| 525 | 526 | p_range = p_up->p_states; |
|---|
| 526 | 527 | while( (--i_index > 0) && p_range->p_next ) |
|---|
| … | … | |
| 531 | 532 | } |
|---|
| 532 | 533 | p_up->p_current_state = p_range; |
|---|
| 533 | | } |
|---|
| | 534 | } |
|---|
| 534 | 535 | else p_up->p_current_state = p_up->p_states; |
|---|
| 535 | | |
|---|
| 536 | | } |
|---|
| 537 | | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| | 536 | |
|---|
| | 537 | } |
|---|
| | 538 | result = fscanf( fd, "\t%24s", &state[0] ); |
|---|
| 538 | 539 | if( result == 0 ) |
|---|
| 539 | | goto error; |
|---|
| | 540 | goto error; |
|---|
| 540 | 541 | if( strncmp( &state[0], "end", 3 ) != 0 ) |
|---|
| 541 | 542 | goto error; |
|---|
| 542 | | |
|---|
| | 543 | |
|---|
| 543 | 544 | /* Continue at the beginning of the while() */ |
|---|
| 544 | 545 | continue; |
|---|
| 545 | 546 | } |
|---|
| 546 | | |
|---|
| 547 | | /* Parse the range state */ |
|---|
| | 547 | |
|---|
| | 548 | /* Parse the range state */ |
|---|
| 548 | 549 | if( strncmp( &state[0], "range", 5 ) == 0 ) |
|---|
| 549 | 550 | { |
|---|
| 550 | 551 | osd_state_t *p_range_current = NULL; /* range state currently processed */ |
|---|
| 551 | | osd_state_t *p_range_prev = NULL; /* previous state processed range */ |
|---|
| | 552 | osd_state_t *p_range_prev = NULL; /* previous state processed range */ |
|---|
| 552 | 553 | int i_index = 0; |
|---|
| 553 | | |
|---|
| | 554 | |
|---|
| 554 | 555 | p_current->b_range = VLC_TRUE; |
|---|
| 555 | 556 | |
|---|
| 556 | | result = fscanf( fd, "\t%24s", &action[0] ); |
|---|
| | 557 | result = fscanf( fd, "\t%24s", &action[0] ); |
|---|
| 557 | 558 | if( result == 0 ) |
|---|
| 558 | 559 | goto error; |
|---|
| 559 | | |
|---|
| 560 | | result = fscanf( fd, "\t%d", &i_index ); |
|---|
| | 560 | |
|---|
| | 561 | result = fscanf( fd, "\t%d", &i_index ); |
|---|
| 561 | 562 | if( result == 0 ) |
|---|
| 562 | 563 | goto error; |
|---|
| 563 | | |
|---|
| 564 | | msg_Dbg( p_this, " + hotkey down %s, file=%s%s", &action[0], (*p_menu)->psz_path, &file[0] ); |
|---|
| | 564 | |
|---|
| | 565 | msg_Dbg( p_this, " + hotkey down %s, file=%s%s", &action[0], (*p_menu)->psz_path, &file[0] ); |
|---|
| 565 | 566 | if( p_current->psz_action_down ) free( p_current->psz_action_down ); |
|---|
| 566 | | p_current->psz_action_down = strdup( &action[0] ); |
|---|
| 567 | | |
|---|
| | 567 | p_current->psz_action_down = strdup( &action[0] ); |
|---|
| | 568 | |
|---|
| 568 | 569 | /* Parse range contstruction : |
|---|
| 569 | | * range <hotkey> |
|---|
| | 570 | * range <hotkey> |
|---|
| 570 | 571 | * <state1> <file1> |
|---|
| 571 | 572 | * |
|---|
| 572 | 573 | * <stateN> <fileN> |
|---|
| 573 | | * end |
|---|
| 574 | | */ |
|---|
| | 574 | * end |
|---|
| | 575 | */ |
|---|
| 575 | 576 | while( !feof( fd ) ) |
|---|
| 576 | 577 | { |
|---|
| 577 | | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| | 578 | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| 578 | 579 | if( result == 0 ) |
|---|
| 579 | 580 | goto error; |
|---|
| 580 | 581 | if( strncmp( &file[0], "end", 3 ) == 0 ) |
|---|
| 581 | 582 | break; |
|---|
| 582 | | |
|---|
| | 583 | |
|---|
| 583 | 584 | p_range_prev = p_range_current; |
|---|
| 584 | | |
|---|
| | 585 | |
|---|
| 585 | 586 | if( (*p_menu)->psz_path ) |
|---|
| 586 | 587 | { |
|---|
| 587 | 588 | size_t i_path_size = strlen( (*p_menu)->psz_path ); |
|---|
| 588 | 589 | size_t i_file_size = strlen( &file[0] ); |
|---|
| 589 | | |
|---|
| | 590 | |
|---|
| 590 | 591 | strncpy( &path[0], (*p_menu)->psz_path, i_path_size ); |
|---|
| 591 | 592 | strncpy( &path[i_path_size], &file[0], 512 - (i_path_size + i_file_size) ); |
|---|
| 592 | 593 | path[ i_path_size + i_file_size ] = '\0'; |
|---|
| 593 | | |
|---|
| | 594 | |
|---|
| 594 | 595 | p_range_current = osd_StateNew( p_this, &path[0], "pressed" ); |
|---|
| 595 | 596 | } |
|---|
| 596 | 597 | else /* absolute paths are used. */ |
|---|
| 597 | 598 | p_range_current = osd_StateNew( p_this, &file[0], "pressed" ); |
|---|
| 598 | | |
|---|
| | 599 | |
|---|
| 599 | 600 | if( !p_range_current || !p_range_current->p_pic ) |
|---|
| 600 | 601 | goto error; |
|---|
| 601 | | |
|---|
| 602 | | /* increment the number of ranges for this button */ |
|---|
| | 602 | |
|---|
| | 603 | /* increment the number of ranges for this button */ |
|---|
| 603 | 604 | p_current->i_ranges++; |
|---|
| 604 | | |
|---|
| | 605 | |
|---|
| 605 | 606 | if( p_range_prev ) |
|---|
| 606 | 607 | p_range_prev->p_next = p_range_current; |
|---|
| 607 | 608 | else |
|---|
| 608 | | p_current->p_states = p_range_current; |
|---|
| | 609 | p_current->p_states = p_range_current; |
|---|
| 609 | 610 | p_range_current->p_prev = p_range_prev; |
|---|
| 610 | | |
|---|
| 611 | | msg_Dbg( p_this, " |- range=%d, file=%s%s", |
|---|
| 612 | | p_current->i_ranges, |
|---|
| 613 | | (*p_menu)->psz_path, &file[0] ); |
|---|
| | 611 | |
|---|
| | 612 | msg_Dbg( p_this, " |- range=%d, file=%s%s", |
|---|
| | 613 | p_current->i_ranges, |
|---|
| | 614 | (*p_menu)->psz_path, &file[0] ); |
|---|
| 614 | 615 | } |
|---|
| 615 | 616 | if( i_index > 0 ) |
|---|
| 616 | | { |
|---|
| | 617 | { |
|---|
| 617 | 618 | osd_state_t *p_range = NULL; |
|---|
| 618 | | |
|---|
| 619 | | /* Find the default index for state range */ |
|---|
| | 619 | |
|---|
| | 620 | /* Find the default index for state range */ |
|---|
| 620 | 621 | p_range = p_current->p_states; |
|---|
| 621 | 622 | while( (--i_index > 0) && p_range->p_next ) |
|---|
| … | … | |
| 626 | 627 | } |
|---|
| 627 | 628 | p_current->p_current_state = p_range; |
|---|
| 628 | | } |
|---|
| | 629 | } |
|---|
| 629 | 630 | else p_current->p_current_state = p_current->p_states; |
|---|
| 630 | 631 | /* Continue at the beginning of the while() */ |
|---|
| 631 | 632 | continue; |
|---|
| 632 | | } |
|---|
| | 633 | } |
|---|
| 633 | 634 | if( strncmp( &state[0], "end", 3 ) == 0 ) |
|---|
| 634 | 635 | break; |
|---|
| 635 | | |
|---|
| 636 | | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| | 636 | |
|---|
| | 637 | result = fscanf( fd, "\t%255s", &file[0] ); |
|---|
| 637 | 638 | if( result == 0 ) |
|---|
| 638 | | goto error; |
|---|
| 639 | | |
|---|
| | 639 | goto error; |
|---|
| | 640 | |
|---|
| 640 | 641 | p_state_prev = p_state_current; |
|---|
| 641 | 642 | |
|---|
| … | … | |
| 648 | 649 | goto error; |
|---|
| 649 | 650 | } |
|---|
| 650 | | |
|---|
| | 651 | |
|---|
| 651 | 652 | if( (*p_menu)->psz_path ) |
|---|
| 652 | 653 | { |
|---|
| 653 | 654 | size_t i_path_size = strlen( (*p_menu)->psz_path ); |
|---|
| 654 | 655 | size_t i_file_size = strlen( &file[0] ); |
|---|
| 655 | | |
|---|
| | 656 | |
|---|
| 656 | 657 | strncpy( &path[0], (*p_menu)->psz_path, i_path_size ); |
|---|
| 657 | 658 | strncpy( &path[i_path_size], &file[0], 512 - (i_path_size + i_file_size) ); |
|---|
| 658 | 659 | path[ i_path_size + i_file_size ] = '\0'; |
|---|
| 659 | | |
|---|
| | 660 | |
|---|
| 660 | 661 | p_state_current = osd_StateNew( p_this, &path[0], &state[0] ); |
|---|
| 661 | 662 | } |
|---|
| 662 | 663 | else /* absolute paths are used. */ |
|---|
| 663 | 664 | p_state_current = osd_StateNew( p_this, &file[0], &state[0] ); |
|---|
| 664 | | |
|---|
| | 665 | |
|---|
| 665 | 666 | if( !p_state_current || !p_state_current->p_pic ) |
|---|
| 666 | 667 | goto error; |
|---|
| 667 | | |
|---|
| | 668 | |
|---|
| 668 | 669 | if( p_state_prev ) |
|---|
| 669 | 670 | p_state_prev->p_next = p_state_current; |
|---|
| 670 | 671 | else |
|---|
| 671 | | p_current->p_states = p_state_current; |
|---|
| | 672 | p_current->p_states = p_state_current; |
|---|
| 672 | 673 | p_state_current->p_prev = p_state_prev; |
|---|
| 673 | | |
|---|
| | 674 | |
|---|
| 674 | 675 | msg_Dbg( p_this, " |- state=%s, file=%s%s", &state[0], (*p_menu)->psz_path, &file[0] ); |
|---|
| 675 | 676 | } |
|---|
| … | … | |
| 677 | 678 | } |
|---|
| 678 | 679 | |
|---|
| 679 | | /* Find the last button and store its pointer. |
|---|
| | 680 | /* Find the last button and store its pointer. |
|---|
| 680 | 681 | * The OSD menu behaves like a roundrobin list. |
|---|
| 681 | | */ |
|---|
| | 682 | */ |
|---|
| 682 | 683 | p_current = (*p_menu)->p_button; |
|---|
| 683 | 684 | while( p_current && p_current->p_next ) |
|---|
| … | … | |
| 690 | 691 | fclose( fd ); |
|---|
| 691 | 692 | return 0; |
|---|
| 692 | | |
|---|
| 693 | | #undef MAX_FILE_PATH |
|---|
| | 693 | |
|---|
| | 694 | #undef MAX_FILE_PATH |
|---|
| 694 | 695 | error: |
|---|
| 695 | 696 | msg_Err( p_this, "parsing file failed (returned %d)", result ); |
|---|
| 696 | 697 | fclose( fd ); |
|---|
| 697 | | return 1; |
|---|
| | 698 | return 1; |
|---|
| 698 | 699 | } |
|---|
| 699 | 700 | &nbs |
|---|