diff options
author | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-08-26 22:20:58 +0000 |
---|---|---|
committer | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-08-26 22:20:58 +0000 |
commit | 452e7bdc03546c71d2d9ebffbcd254b5842e052d (patch) | |
tree | 47cae3fbb2656e04c14894d1bea04b7add05fdee /Gui/cfg.c | |
parent | c39611bbe90b79a9e17ffe4ff95a4c1a058eba92 (diff) | |
download | mpv-452e7bdc03546c71d2d9ebffbcd254b5842e052d.tar.bz2 mpv-452e7bdc03546c71d2d9ebffbcd254b5842e052d.tar.xz |
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
- wsXDNDProcessSelection return Truae fix
- add url list saving support from Morten Volden <mvolden@tdcadsl.dk>
- fix bug's in this patches
- fix some memleak and bug
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7093 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui/cfg.c')
-rw-r--r-- | Gui/cfg.c | 79 |
1 files changed, 59 insertions, 20 deletions
@@ -106,9 +106,22 @@ static config_t gui_opts[] = { NULL, NULL, 0, 0, 0, 0, NULL } }; +char * gfgets( char * str, int size, FILE * f ) +{ + char * s = fgets( str,size,f ); + char c; + if ( s ) + { + c=s[ strlen( s ) - 1 ]; if ( c == '\n' || c == '\r' ) s[ strlen( s ) - 1 ]=0; + c=s[ strlen( s ) - 1 ]; if ( c == '\n' || c == '\r' ) s[ strlen( s ) - 1 ]=0; + } + return s; +} + int cfg_read( void ) { char * cfg = get_path( "gui.conf" ); + FILE * f; // -- read configuration mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg ); @@ -122,26 +135,39 @@ int cfg_read( void ) free( cfg ); // -- read pl - { - FILE * f; - cfg=get_path( "gui.pl" ); - if ( (f=fopen( cfg,"rt" )) == NULL ) return 1; - while ( !feof( f ) ) - { - char tmp[512]; plItem * item = calloc( 1,sizeof( plItem ) ); char c; - if ( fgets( tmp,512,f ) == NULL ) continue; - c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; - c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; - item->path=strdup( tmp ); - fgets( tmp,512,f ); - c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; - c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; - item->name=strdup( tmp ); - gtkSet( gtkAddPlItem,0,(void*)item ); - } - fclose( f ); - free( cfg ); - } + cfg=get_path( "gui.pl" ); + if ( (f=fopen( cfg,"rt" )) ) + { + while ( !feof( f ) ) + { + char tmp[512]; plItem * item; + if ( gfgets( tmp,512,f ) == NULL ) continue; + item=calloc( 1,sizeof( plItem ) ); + item->path=strdup( tmp ); + gfgets( tmp,512,f ); + item->name=strdup( tmp ); + gtkSet( gtkAddPlItem,0,(void*)item ); + } + fclose( f ); + } + free( cfg ); + + //-- read previously visited urls + cfg=get_path( "gui.url" ); + if ( (f=fopen( cfg,"rt" )) ) + { + while ( !feof( f ) ) + { + char tmp[512]; URLItem * item; + if ( gfgets( tmp,512,f ) == NULL ) continue; + item=calloc( 1,sizeof( URLItem ) ); + item->url=strdup( tmp ); + gtkSet( gtkAddURLItem,0,(void*)item ); + } + fclose( f ); + } + free( cfg ); + return 0; } @@ -195,6 +221,19 @@ int cfg_write( void ) } free( cfg ); +// -- save URL's + cfg=get_path( "gui.url" ); + if ( (f=fopen( cfg,"wt+" )) ) + { + while ( URLList ) + { + if ( URLList->url ) fprintf( f,"%s\n",URLList->url ); + URLList=URLList->next; + } + fclose( f ); + } + free( cfg ); + return 0; } |