1 /**********************************************************************************
4 * - Appends Sections which do not exist in hIni. Ignores all else.
5 * - Does not try to append 'missing' Entries to existing Sections (does not try to merge).
6 * - hIni will become ReadOnly
8 **************************************************
9 * This code was created by Peter Harvey @ CodeByDesign.
10 * Released under LGPL 28.JAN.99
12 * Contributions from...
13 * -----------------------------------------------
14 * Peter Harvey - pharvey@codebydesign.com
15 **************************************************/
17 #include "inifile_intern.h"
19 #include <aros/libcall.h>
21 /*****************************************************************************
24 AROS_LH2(int, iniAppend
,
27 AROS_LHA(HINI
, hIni
, D0
),
28 AROS_LHA(char *, pszFileName
, A0
),
31 struct Library
*, inifileBase
, 9, inifile
)
51 *****************************************************************************/
56 char szLine
[INI_MAX_LINE
+1];
57 char szObjectName
[INI_MAX_OBJECT_NAME
+1];
58 char szPropertyName
[INI_MAX_PROPERTY_NAME
+1];
59 char szPropertyValue
[INI_MAX_PROPERTY_VALUE
+1];
62 if ( strlen( pszFileName
) > ODBC_FILENAME_MAX
)
66 hFile
= fopen( pszFileName
, "r" );
70 iniObjectLast( hIni
);
71 iniPropertyLast( hIni
);
73 /* SCAN UNTIL WE GET TO AN OBJECT NAME OR EOF */
75 if ( _iniScanUntilObject( hIni
, hFile
, szLine
) == INI_SUCCESS
)
79 if ( szLine
[0] == hIni
->cLeftBracket
)
81 _iniObjectRead( hIni
, szLine
, szObjectName
);
82 if ( iniObjectSeek( hIni
, szObjectName
) == INI_SUCCESS
)
84 iniObjectLast( hIni
);
85 iniPropertyLast( hIni
);
86 if ( _iniScanUntilNextObject( hIni
, hFile
, szLine
) != INI_SUCCESS
)
91 iniObjectInsert( hIni
, szObjectName
);
92 if ( fgets( szLine
, INI_MAX_LINE
, hFile
) == NULL
)
96 else if ( (szLine
[0] != hIni
->cComment
) && isalnum(szLine
[0]) )
98 _iniPropertyRead( hIni
, szLine
, szPropertyName
, szPropertyValue
);
99 iniPropertyInsert( hIni
, szPropertyName
, szPropertyValue
);
100 if ( fgets( szLine
, INI_MAX_LINE
, hFile
) == NULL
)
105 if ( fgets( szLine
, INI_MAX_LINE
, hFile
) == NULL
)
111 /* WE ARE NOT GOING TO TRY TO BE SMART ENOUGH TO SAVE THIS STUFF */