| 1 | /********************************************************************************** |
| 2 | * iniCommit |
| 3 | * |
| 4 | * |
| 5 | ************************************************** |
| 6 | * This code was created by Peter Harvey @ CodeByDesign. |
| 7 | * Released under LGPL 28.JAN.99 |
| 8 | * |
| 9 | * Contributions from... |
| 10 | * ----------------------------------------------- |
| 11 | * Peter Harvey - pharvey@codebydesign.com |
| 12 | **************************************************/ |
| 13 | |
| 14 | #include <config.h> |
| 15 | #include "ini.h" |
| 16 | |
| 17 | int iniCommit( HINI hIni ) |
| 18 | { |
| 19 | FILE *hFile; |
| 20 | |
| 21 | /* SANITY CHECK */ |
| 22 | if ( hIni == NULL ) |
| 23 | return INI_ERROR; |
| 24 | |
| 25 | if ( hIni->bReadOnly ) |
| 26 | return INI_ERROR; |
| 27 | |
| 28 | /* OPEN FILE */ |
| 29 | |
| 30 | #ifdef __OS2__ |
| 31 | if (hIni->iniFileType == 0) |
| 32 | { |
| 33 | #endif |
| 34 | hFile = uo_fopen( hIni->szFileName, "w" ); |
| 35 | #ifdef __OS2__ |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | hFile = (FILE *)iniOS2Open (hIni->szFileName); |
| 40 | } |
| 41 | #endif |
| 42 | if ( !hFile ) |
| 43 | return INI_ERROR; |
| 44 | |
| 45 | _iniDump( hIni, hFile ); |
| 46 | |
| 47 | /* CLEANUP */ |
| 48 | if ( hFile != NULL ) |
| 49 | { |
| 50 | #ifdef __OS2__ |
| 51 | if (hIni->iniFileType == 0) |
| 52 | #endif |
| 53 | uo_fclose( hFile ); |
| 54 | #ifdef __OS2__ |
| 55 | else |
| 56 | iniOS2Close( hFile); |
| 57 | #endif |
| 58 | } |
| 59 | |
| 60 | return INI_SUCCESS; |
| 61 | } |
| 62 | |
| 63 | |