@@ -722,21 +722,19 @@ static line_status iniparser_line(
722
722
/*-------------------------------------------------------------------------*/
723
723
/**
724
724
@brief Parse an ini file and return an allocated dictionary object
725
- @param ininame Name of the ini file to read.
725
+ @param in File to read.
726
+ @param ininame Name of the ini file to read (only used for nicer error messages)
726
727
@return Pointer to newly allocated dictionary
727
728
728
729
This is the parser for ini files. This function is called, providing
729
- the name of the file to be read. It returns a dictionary object that
730
- should not be accessed directly, but through accessor functions
731
- instead.
730
+ the file to be read. It returns a dictionary object that should not
731
+ be accessed directly, but through accessor functions instead.
732
732
733
733
The returned dictionary must be freed using iniparser_freedict().
734
734
*/
735
735
/*--------------------------------------------------------------------------*/
736
- dictionary * iniparser_load ( const char * ininame )
736
+ dictionary * iniparser_load_file ( FILE * in , const char * ininame )
737
737
{
738
- FILE * in ;
739
-
740
738
char line [ASCIILINESZ + 1 ] ;
741
739
char section [ASCIILINESZ + 1 ] ;
742
740
char key [ASCIILINESZ + 1 ] ;
@@ -751,11 +749,6 @@ dictionary * iniparser_load(const char * ininame)
751
749
752
750
dictionary * dict ;
753
751
754
- if ((in = fopen (ininame , "r" ))== NULL ) {
755
- iniparser_error_callback ("iniparser: cannot open %s\n" , ininame );
756
- return NULL ;
757
- }
758
-
759
752
dict = dictionary_new (0 ) ;
760
753
if (!dict ) {
761
754
fclose (in );
@@ -841,6 +834,36 @@ dictionary * iniparser_load(const char * ininame)
841
834
return dict ;
842
835
}
843
836
837
+ /*-------------------------------------------------------------------------*/
838
+ /**
839
+ @brief Parse an ini file and return an allocated dictionary object
840
+ @param ininame Name of the ini file to read.
841
+ @return Pointer to newly allocated dictionary
842
+
843
+ This is the parser for ini files. This function is called, providing
844
+ the name of the file to be read. It returns a dictionary object that
845
+ should not be accessed directly, but through accessor functions
846
+ instead.
847
+
848
+ The returned dictionary must be freed using iniparser_freedict().
849
+ */
850
+ /*--------------------------------------------------------------------------*/
851
+ dictionary * iniparser_load (const char * ininame )
852
+ {
853
+ FILE * in ;
854
+ dictionary * dict ;
855
+
856
+ if ((in = fopen (ininame , "r" ))== NULL ) {
857
+ iniparser_error_callback ("iniparser: cannot open %s\n" , ininame );
858
+ return NULL ;
859
+ }
860
+
861
+ dict = iniparser_load_file (in , ininame );
862
+
863
+ return dict ;
864
+ }
865
+
866
+
844
867
/*-------------------------------------------------------------------------*/
845
868
/**
846
869
@brief Free all memory associated to an ini dictionary
0 commit comments