/*****************************************************************************
* parser.c : OSD import module
*****************************************************************************
- * Copyright (C) 2007 M2X
+ * Copyright (C) 2007-2008 M2X
* $Id$
*
* Authors: Jean-Paul Saman
osd_button_t *p_next = NULL;
osd_button_t *p_prev = NULL;
+ if( !p_current ) return;
+
/* First walk to the end. */
while( p_current->p_next )
{
{
p_state->p_pic = image_ReadUrl( p_menu->p_image, psz_file,
&fmt_in, &fmt_out );
-
- p_state->i_width = p_state->p_pic->p[Y_PLANE].i_visible_pitch;
- p_state->i_height = p_state->p_pic->p[Y_PLANE].i_visible_lines;
+ if( p_state->p_pic )
+ {
+ p_state->i_width = p_state->p_pic->p[Y_PLANE].i_visible_pitch;
+ p_state->i_height = p_state->p_pic->p[Y_PLANE].i_visible_lines;
+ }
}
if( psz_state )
osd_state_t *p_next = NULL;
osd_state_t *p_prev = NULL;
+ if( !p_state ) return;
+
while( p_state->p_next )
{
p_next = p_state->p_next;
/*****************************************************************************
* simple.c - The OSD Menu simple parser code.
*****************************************************************************
- * Copyright (C) 2005-2007 M2X
+ * Copyright (C) 2005-2008 M2X
* $Id$
*
* Authors: Jean-Paul Saman
osd_button_t *p_current = NULL; /* button currently processed */
osd_button_t *p_prev = NULL; /* previous processed button */
-#define MAX_FILE_PATH 256
FILE *fd = NULL;
int result = 0;
{
char action[25] = "";
char cmd[25] = "";
- char path[MAX_FILE_PATH] = "";
+ char path[PATH_MAX] = "";
char *psz_path = NULL;
size_t i_len = 0;
long pos = 0;
/* psz_path is not null and therefor &path[0] cannot be NULL
* it might be null terminated.
*/
- strncpy( &path[0], psz_path, MAX_FILE_PATH );
+ strncpy( &path[0], psz_path, PATH_MAX );
free( psz_path );
psz_path = NULL;
}
/* NULL terminate before asking the length of path[] */
- path[MAX_FILE_PATH-1] = '\0';
+ path[PATH_MAX-1] = '\0';
i_len = strlen(&path[0]);
- if( i_len == MAX_FILE_PATH )
+ if( i_len == PATH_MAX )
i_len--; /* truncate to prevent buffer overflow */
#if defined(WIN32) || defined(UNDER_CE)
if( (i_len > 0) && path[i_len] != '\\' )
char action[25] = "";
char state[25] = "";
char file[256] = "";
- char path[512] = "";
+ char path[PATH_MAX] = "";
int i_x = 0;
int i_y = 0;
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], 512 - (i_path_size + i_file_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" );
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], 512 - (i_path_size + i_file_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" );
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], 512 - (i_path_size + i_file_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] );
fclose( fd );
return VLC_SUCCESS;
-#undef MAX_FILE_PATH
error:
msg_Err( p_menu, "parsing file failed (returned %d)", result );
osd_MenuFree( p_menu );
/*****************************************************************************
* osd.c - The OSD Menu core code.
*****************************************************************************
- * Copyright (C) 2005-2007 M2X
+ * Copyright (C) 2005-2008 M2X
* $Id$
*
* Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
#undef OSD_MENU_DEBUG
-#if 0
-static const char *ppsz_button_states[] = { "unselect", "select", "pressed" };
-#endif
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
if( !p_menu )
return NULL;
+ p_menu->p_parser = NULL;
vlc_object_attach( p_menu, p_this->p_libvlc );
/* Stuff needed for Parser */
{
if( p_menu->p_image )
image_HandlerDelete( p_menu->p_image );
- if( p_menu->psz_file )
- free( p_menu->psz_file );
if( p_menu->p_parser )
module_Unneed( p_menu, p_menu->p_parser );
+ free( p_menu->psz_file );
+
vlc_object_detach( p_menu );
vlc_object_release( p_menu );
}
/**
* Change state on an osd_button_t.
*
- * This function selects the specified state and returns a pointer to it. The
+ * This function selects the specified state and returns a pointer vlc_custom_createto it. The
* following states are currently supported:
* \see OSD_BUTTON_UNSELECT
* \see OSD_BUTTON_SELECT
/* Parse configuration file */
p_osd = osd_ParserLoad( p_this, psz_file );
- if( !p_osd )
+ if( !p_osd || !p_osd->p_state )
goto error;
/* Setup default button (first button) */
return p_osd;
error:
- msg_Err( p_this, "creating OSD menu object failed" );
-
- if( p_osd->p_image )
- image_HandlerDelete( p_osd->p_image );
- if( p_osd->psz_file )
- free( p_osd->psz_file );
-
- vlc_object_detach( p_osd );
- vlc_object_release( p_osd );
- vlc_mutex_unlock( lockval.p_address );
+ __osd_MenuDelete( p_this, p_osd );
return NULL;
}