2 * SetupX .inf file parsing functions
4 * FIXME: return values ???
7 #include "debugtools.h"
11 #include "wine/winbase16.h"
14 DEFAULT_DEBUG_CHANNEL(setupx
);
16 WORD InfNumEntries
= 0;
17 INF_FILE
*InfList
= NULL
;
18 HINF16 IP_curr_handle
= 0;
20 RETERR16
IP_OpenInf(LPCSTR lpInfFileName
, HINF16
*lphInf
)
22 HFILE hFile
= _lopen(lpInfFileName
, OF_READ
);
27 /* this could be improved by checking for already freed handles */
28 if (IP_curr_handle
== 0xffff)
29 return ERR_IP_OUT_OF_HANDLES
;
31 if (hFile
!= HFILE_ERROR
)
33 InfList
= HeapReAlloc(GetProcessHeap(), 0, InfList
, InfNumEntries
+1);
34 InfList
[InfNumEntries
].hInf
= IP_curr_handle
++;
35 InfList
[InfNumEntries
].hInfFile
= hFile
;
36 InfList
[InfNumEntries
].lpInfFileName
= HeapAlloc( GetProcessHeap(), 0,
37 strlen(lpInfFileName
)+1);
38 strcpy( InfList
[InfNumEntries
].lpInfFileName
, lpInfFileName
);
39 *lphInf
= InfList
[InfNumEntries
].hInf
;
41 TRACE("ret handle %d.\n", *lphInf
);
45 return ERR_IP_INVALID_INFFILE
;
48 BOOL
IP_FindInf(HINF16 hInf
, WORD
*ret
)
52 for (n
=0; n
< InfNumEntries
; n
++)
53 if (InfList
[n
].hInf
== hInf
)
62 LPCSTR
IP_GetFileName(HINF16 hInf
)
65 if (IP_FindInf(hInf
, &n
))
67 return InfList
[n
].lpInfFileName
;
72 RETERR16
IP_CloseInf(HINF16 hInf
)
76 RETERR16 res
= ERR_IP_INVALID_HINF
;
78 if (IP_FindInf(hInf
, &n
))
80 _lclose(InfList
[n
].hInfFile
);
81 HeapFree(GetProcessHeap(), 0, InfList
[n
].lpInfFileName
);
82 for (i
=n
; i
< InfNumEntries
-1; i
++)
83 InfList
[i
] = InfList
[i
+1];
85 InfList
= HeapReAlloc(GetProcessHeap(), 0, InfList
, InfNumEntries
);
91 /***********************************************************************
95 RETERR16 WINAPI
IpOpen16(LPCSTR lpInfFileName
, HINF16
*lphInf
)
97 TRACE("('%s', %p)\n", lpInfFileName
, lphInf
);
98 return IP_OpenInf(lpInfFileName
, lphInf
);
101 /***********************************************************************
104 RETERR16 WINAPI
IpClose16(HINF16 hInf
)
106 return IP_CloseInf(hInf
);
109 /***********************************************************************
110 * IpGetProfileString16
112 RETERR16 WINAPI
IpGetProfileString16(HINF16 hInf
, LPCSTR section
, LPCSTR entry
, LPSTR buffer
, WORD buflen
)
114 TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf
), section
, entry
);
115 GetPrivateProfileStringA(section
, entry
, "", buffer
, buflen
, IP_GetFileName(hInf
));