1/**********************************************************************************
2 * iniPropertyInsert
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
17int iniPropertyInsert( HINI hIni, char *pszProperty, char *pszValue )
18{
19 HINIOBJECT hObject;
20 HINIPROPERTY hProperty;
21
22 /* SANITY CHECKS */
23 if ( hIni == NULL )
24 return INI_ERROR;
25 if ( hIni->hCurObject == NULL )
26 return INI_ERROR;
27 if ( pszProperty == NULL )
28 return INI_ERROR;
29
30 hObject = hIni->hCurObject;
31
32 /* CREATE PROPERTY STRUCT */
33 hProperty = (HINIPROPERTY)malloc( sizeof(INIPROPERTY) );
34 strncpy( hProperty->szName, pszProperty, INI_MAX_PROPERTY_NAME );
35 strncpy( hProperty->szValue, pszValue, INI_MAX_PROPERTY_VALUE );
36 hProperty->pNext = NULL;
37 iniAllTrim( hProperty->szName );
38 iniAllTrim( hProperty->szValue );
39
40 /* APPEND TO LIST */
41 if ( hObject->hFirstProperty == NULL )
42 hObject->hFirstProperty = hProperty;
43
44 hProperty->pPrev = hObject->hLastProperty;
45 hObject->hLastProperty = hProperty;
46
47 if ( hProperty->pPrev != NULL )
48 hProperty->pPrev->pNext = hProperty;
49
50 hIni->hCurProperty = hProperty;
51 hObject->nProperties++;
52
53 return INI_SUCCESS;
54}
55
56
57