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 HFILE16 hFile = _lopen16(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_ERROR16)
33 InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
34 InfList[InfNumEntries].hInf = IP_curr_handle++;
35 InfList[InfNumEntries].hInfFile = hFile;
36 InfList[InfNumEntries].lpInfFileName = HEAP_strdupA(GetProcessHeap(), 0, lpInfFileName);
37 *lphInf = InfList[InfNumEntries].hInf;
39 TRACE("ret handle %d.\n", *lphInf);
43 return ERR_IP_INVALID_INFFILE;
46 BOOL IP_FindInf(HINF16 hInf, WORD *ret)
50 for (n=0; n < InfNumEntries; n++)
51 if (InfList[n].hInf == hInf)
60 LPCSTR IP_GetFileName(HINF16 hInf)
63 if (IP_FindInf(hInf, &n))
65 return InfList[n].lpInfFileName;
70 RETERR16 IP_CloseInf(HINF16 hInf)
74 HFILE16 res = ERR_IP_INVALID_HINF;
76 if (IP_FindInf(hInf, &n))
78 _lclose16(InfList[n].hInfFile);
79 HeapFree(GetProcessHeap(), 0, InfList[n].lpInfFileName);
80 for (i=n; i < InfNumEntries-1; i++)
81 InfList[i] = InfList[i+1];
83 InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
89 /***********************************************************************
93 RETERR16 WINAPI IpOpen16(LPCSTR lpInfFileName, HINF16 *lphInf)
95 TRACE("('%s', %p)\n", lpInfFileName, lphInf);
96 return IP_OpenInf(lpInfFileName, lphInf);
99 /***********************************************************************
102 RETERR16 WINAPI IpClose16(HINF16 hInf)
104 return IP_CloseInf(hInf);
107 /***********************************************************************
108 * IpGetProfileString16
110 RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen)
112 TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf), section, entry);
113 GetPrivateProfileString16(section, entry, "", buffer, buflen, IP_GetFileName(hInf));