- i_sizebuf = ( st.st_size < LONG_MAX ) ? st.st_size : 0;
- }
-
- p_bigbuffer = p_index = malloc( i_sizebuf+1 );
- if( !p_bigbuffer )
- goto error;
- p_bigbuffer[0] = 0;
-
- /* List all available modules */
- module_t **list = module_list_get (NULL);
-
- /* backup file into memory, we only need to backup the sections we won't
- * save later on */
- b_backup = false;
- while( file && fgets( p_line, 1024, file ) )
- {
- if( (p_line[0] == '[') && (p_index2 = strchr(p_line,']')))
- {
-
- /* we found a section, check if we need to do a backup */
- for( i_index = 0; (p_parser = list[i_index]) != NULL; i_index++ )
- {
- if( ((p_index2 - &p_line[1])
- == (int)strlen(p_parser->psz_object_name) )
- && !memcmp( &p_line[1], p_parser->psz_object_name,
- strlen(p_parser->psz_object_name) ) )
- {
- if( !psz_module_name )
- break;
- else if( !strcmp( psz_module_name,
- p_parser->psz_object_name ) )
- break;
- }
- }
-
- if( list[i_index] == NULL )
- {
- /* we don't have this section in our list so we need to back
- * it up */
- *p_index2 = 0;
-#if 0
- msg_Dbg( p_this, "backing up config for unknown module \"%s\"",
- &p_line[1] );
-#endif
- *p_index2 = ']';
-
- b_backup = true;
- }
- else
- {
- b_backup = false;
- }
- }
-
- /* save line if requested and line is valid (doesn't begin with a
- * space, tab, or eol) */
- if( b_backup && (p_line[0] != '\n') && (p_line[0] != ' ')
- && (p_line[0] != '\t') )
- {
- strcpy( p_index, p_line );
- p_index += strlen( p_line );
- }
- }
- if( file )
- fclose( file );
- file = NULL;
-
- /*
- * Save module config in file
- */
- permanent = config_GetConfigFile (p_this);
- if (!permanent)
- {
- module_list_free (list);
- goto error;