1 | /**************************************************** |
---|---|
2 | * _odbcinst_GetEntries |
3 | * |
4 | ************************************************** |
5 | * This code was created by Peter Harvey @ CodeByDesign. |
6 | * Released under LGPL 28.JAN.99 |
7 | * |
8 | * Contributions from... |
9 | * ----------------------------------------------- |
10 | * Peter Harvey - pharvey@codebydesign.com |
11 | **************************************************/ |
12 | #include <config.h> |
13 | #include <odbcinstext.h> |
14 | |
15 | int _odbcinst_GetEntries( HINI hIni, |
16 | LPCSTR pszSection, |
17 | LPSTR pRetBuffer, |
18 | int nRetBuffer, |
19 | int *pnBufPos |
20 | ) |
21 | { |
22 | char szPropertyName[INI_MAX_PROPERTY_NAME+1]; |
23 | char *ptr; |
24 | |
25 | *pnBufPos = 0; |
26 | *pRetBuffer = '\0'; |
27 | ptr = pRetBuffer; |
28 | |
29 | iniObjectSeek( hIni, (char *)pszSection ); |
30 | |
31 | /* COLLECT ALL ENTRIES FOR THE GIVEN SECTION */ |
32 | |
33 | for( iniPropertyFirst( hIni ); iniPropertyEOL( hIni ) != TRUE; iniPropertyNext( hIni )) |
34 | { |
35 | iniProperty( hIni, szPropertyName ); |
36 | |
37 | if ( *pnBufPos + 1 + strlen( szPropertyName ) >= nRetBuffer ) |
38 | { |
39 | break; |
40 | } |
41 | else |
42 | { |
43 | strcpy( ptr, szPropertyName ); |
44 | ptr += strlen( ptr ) + 1; |
45 | (*pnBufPos) += strlen( szPropertyName ) + 1; |
46 | } |
47 | } |
48 | |
49 | /* |
50 | * Add final NULL |
51 | */ |
52 | |
53 | if ( *pnBufPos == 0 ) |
54 | { |
55 | ptr ++; |
56 | } |
57 | |
58 | *ptr = '\0'; |
59 | |
60 | return (*pnBufPos); |
61 | } |
62 |