1/**********************************************************************************
2 * iniObjectInsert
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 iniObjectInsert( HINI hIni, char *pszObject )
18{
19 HINIOBJECT hObject;
20 char szObjectName[INI_MAX_OBJECT_NAME+1];
21
22 /* SANITY CHECK */
23 if ( hIni == NULL )
24 return INI_ERROR;
25 if ( pszObject == NULL )
26 return INI_ERROR;
27
28 strncpy( szObjectName, pszObject, INI_MAX_OBJECT_NAME );
29 iniAllTrim( szObjectName );
30
31 /* CREATE OBJECT STRUCT */
32 hObject = malloc( sizeof(INIOBJECT) );
33 hIni->hCurProperty = NULL;
34 hObject->hFirstProperty = NULL;
35 hObject->hLastProperty = NULL;
36 hObject->nProperties = 0;
37 hObject->pNext = NULL;
38 hObject->pPrev = NULL;
39 strncpy( hObject->szName, szObjectName, INI_MAX_OBJECT_NAME );
40
41 /* APPEND TO OBJECT LIST */
42 if ( hIni->hFirstObject == NULL )
43 hIni->hFirstObject = hObject;
44
45 hObject->pPrev = hIni->hLastObject;
46 hIni->hLastObject = hObject;
47
48 if ( hObject->pPrev != NULL )
49 hObject->pPrev->pNext = hObject;
50
51 hIni->hCurObject = hObject;
52 hIni->nObjects++;
53
54 return INI_SUCCESS;
55}
56
57
58