1/****************************************************
2 * _odbcinst_GetSections
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
15int _odbcinst_GetSections( HINI hIni,
16 LPSTR pRetBuffer,
17 int nRetBuffer,
18 int *pnBufPos /* SET TO 0 IF RESULT DATA IS EMPTY */
19 )
20{
21 char szObjectName[INI_MAX_OBJECT_NAME+1];
22 char *ptr;
23
24 *pnBufPos = 0;
25 *pRetBuffer = '\0';
26 ptr = pRetBuffer;
27
28 /* JUST COLLECT SECTION NAMES */
29
30 for( iniObjectFirst( hIni ); iniObjectEOL( hIni ) != TRUE; iniObjectNext( hIni ))
31 {
32 iniObject( hIni, szObjectName );
33
34 if ( strcasecmp( szObjectName, "ODBC Data Sources" ) == 0 )
35 {
36 continue;
37 }
38 else if ( *pnBufPos + 1 + strlen( szObjectName ) >= nRetBuffer )
39 {
40 break;
41 }
42 else
43 {
44 strcpy( ptr, szObjectName );
45 ptr += strlen( ptr ) + 1;
46 (*pnBufPos) += strlen( szObjectName ) + 1;
47 }
48 }
49
50 /*
51 * Add final NULL
52 */
53
54 if ( *pnBufPos == 0 )
55 {
56 ptr ++;
57 }
58
59 *ptr = '\0';
60
61 return (*pnBufPos);
62}
63