2 * SetupX .inf file parsing functions
4 * FIXME: return values ???
7 #include "debugtools.h"
10 #include "wine/winbase16.h"
13 DEFAULT_DEBUG_CHANNEL(setupx);
15 WORD InfNumEntries = 0;
16 INF_HANDLE *InfList = NULL;
18 #define GET_INF_ENTRY(x) ((InfList - x)/4)
20 RETERR16 IP_OpenInf(LPCSTR lpInfFileName, HINF16 *lphInf)
22 HFILE16 hFile = _lopen16(lpInfFileName, OF_READ);
27 if (hFile != HFILE_ERROR16)
29 InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
30 InfList[InfNumEntries].hInfFile = hFile;
31 InfList[InfNumEntries].lpInfFileName = lpInfFileName;
33 *lphInf = &InfList[InfNumEntries-1] - InfList;
37 return ERR_IP_INVALID_INFFILE;
40 LPCSTR IP_GetFileName(HINF16 hInf)
42 if ((hInf <= (InfNumEntries*sizeof(INF_HANDLE *)))
43 && ((hInf & 3) == 0)) /* aligned ? */
45 return InfList[hInf/4].lpInfFileName;
50 RETERR16 IP_CloseInf(HINF16 hInf)
53 HFILE16 res = ERR_IP_INVALID_HINF;
55 if ((hInf <= (InfNumEntries*sizeof(INF_HANDLE *)))
56 && ((hInf & 3) == 0)) /* aligned ? */
58 _lclose16(InfList[hInf/4].hInfFile);
60 for (i=hInf/4; i < InfNumEntries-1; i++)
61 InfList[i] = InfList[i+1];
63 InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
68 /***********************************************************************
72 RETERR16 WINAPI IpOpen16(LPCSTR lpInfFileName, HINF16 *lphInf)
74 TRACE("('%s', %p)\n", lpInfFileName, lphInf);
75 return IP_OpenInf(lpInfFileName, lphInf);
78 /***********************************************************************
81 RETERR16 WINAPI IpClose16(HINF16 hInf)
83 return IP_CloseInf(hInf);
86 /***********************************************************************
87 * IpGetProfileString16
89 RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen)
91 GetPrivateProfileString16(section, entry, "", buffer, buflen, IP_GetFileName(hInf));