Build Lunapaint from Contrib.
[AROS-Contrib.git] / libini / iniPropertyValue.c
blob75881b5c5f5749c432b6f7331b434354639d8465
1 /**********************************************************************************
2 * .
3 * totally untested
5 * see iniElement instead
6 **********************************************************************************/
8 #include "inifile_intern.h"
9 #include "ini.h"
10 #include <aros/libcall.h>
12 /*****************************************************************************
13 NAME */
14 AROS_LH5(int, iniPropertyValue,
16 /* SYNOPSIS */
17 AROS_LHA(char *, pszString, A0),
18 AROS_LHA(char *, pszProperty, A1),
19 AROS_LHA(char *, pszValue, A2),
20 AROS_LHA(char, cEqual, D0),
21 AROS_LHA(char, cPropertySep, D1),
23 /* LOCATION */
24 struct Library *, inifileBase, 40, inifile)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 HISTORY
44 *****************************************************************************/
46 AROS_LIBFUNC_INIT
48 char szBuffer[INI_MAX_LINE+1];
49 char szEqual[2];
50 char szPropertySep[2];
51 char *pProperty;
52 char *pValue;
53 char *pValueLastChar;
55 szEqual[0] = cEqual;
56 szEqual[1] = '\0';
57 szPropertySep[0] = cPropertySep;
58 szPropertySep[1] = '\0';
60 strcpy( pszValue, "" );
61 strncpy( szBuffer, pszString, INI_MAX_LINE );
63 /* find pszProperty */
64 while ( 1 )
66 pProperty = (char *)strtok( szBuffer, (const char *)szPropertySep );
67 if ( pProperty == NULL )
68 break;
69 else
71 /* extract pszValue */
72 if ( strncmp( pProperty, pszProperty, strlen(pszProperty) ) == 0 )
74 pValue = (char *)strtok( szBuffer, (const char *)szEqual );
75 if ( pValue )
77 /* truncate any other data */
78 pValueLastChar = (char *)strchr( pValue, (int)szPropertySep );
79 if ( pValueLastChar )
80 pValueLastChar[0] = '\0';
82 strncpy( pszValue, pValue, INI_MAX_PROPERTY_VALUE );
83 iniAllTrim( pszValue );
85 break;
90 return INI_SUCCESS;
92 AROS_LIBFUNC_EXIT
93 } /* iniPropertyValue */