2000-09-27 00:46:36 +02:00
|
|
|
/*
|
|
|
|
* SetupX .inf file parsing functions
|
|
|
|
*
|
2000-12-13 22:31:37 +01:00
|
|
|
* FIXME:
|
|
|
|
* - return values ???
|
|
|
|
* - this should be reimplemented at some point to have its own
|
|
|
|
* file parsing instead of using profile functions,
|
|
|
|
* as some SETUPX exports probably demand that
|
|
|
|
* (IpSaveRestorePosition, IpFindNextMatchLine, ...).
|
2000-09-27 00:46:36 +02:00
|
|
|
*/
|
|
|
|
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2000-09-27 00:46:36 +02:00
|
|
|
#include "debugtools.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2000-11-04 03:57:18 +01:00
|
|
|
#include "heap.h"
|
2000-09-27 00:46:36 +02:00
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "setupx16.h"
|
2001-04-17 19:39:35 +02:00
|
|
|
#include "setupapi_private.h"
|
2000-09-27 00:46:36 +02:00
|
|
|
|
2001-04-17 19:39:35 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(setupapi);
|
2000-09-27 00:46:36 +02:00
|
|
|
|
|
|
|
WORD InfNumEntries = 0;
|
2000-11-04 03:57:18 +01:00
|
|
|
INF_FILE *InfList = NULL;
|
|
|
|
HINF16 IP_curr_handle = 0;
|
2000-09-27 00:46:36 +02:00
|
|
|
|
|
|
|
RETERR16 IP_OpenInf(LPCSTR lpInfFileName, HINF16 *lphInf)
|
|
|
|
{
|
2000-11-26 23:40:49 +01:00
|
|
|
HFILE hFile = _lopen(lpInfFileName, OF_READ);
|
2000-09-27 00:46:36 +02:00
|
|
|
|
|
|
|
if (!lphInf)
|
|
|
|
return IP_ERROR;
|
|
|
|
|
2000-11-04 03:57:18 +01:00
|
|
|
/* this could be improved by checking for already freed handles */
|
|
|
|
if (IP_curr_handle == 0xffff)
|
|
|
|
return ERR_IP_OUT_OF_HANDLES;
|
|
|
|
|
2000-11-26 23:40:49 +01:00
|
|
|
if (hFile != HFILE_ERROR)
|
2000-09-27 00:46:36 +02:00
|
|
|
{
|
|
|
|
InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
|
2000-11-04 03:57:18 +01:00
|
|
|
InfList[InfNumEntries].hInf = IP_curr_handle++;
|
2000-09-27 00:46:36 +02:00
|
|
|
InfList[InfNumEntries].hInfFile = hFile;
|
2000-11-13 05:16:05 +01:00
|
|
|
InfList[InfNumEntries].lpInfFileName = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
strlen(lpInfFileName)+1);
|
|
|
|
strcpy( InfList[InfNumEntries].lpInfFileName, lpInfFileName );
|
2000-11-04 03:57:18 +01:00
|
|
|
*lphInf = InfList[InfNumEntries].hInf;
|
2000-09-27 00:46:36 +02:00
|
|
|
InfNumEntries++;
|
2000-11-04 03:57:18 +01:00
|
|
|
TRACE("ret handle %d.\n", *lphInf);
|
2000-09-27 00:46:36 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
*lphInf = 0xffff;
|
|
|
|
return ERR_IP_INVALID_INFFILE;
|
|
|
|
}
|
|
|
|
|
2000-11-04 03:57:18 +01:00
|
|
|
BOOL IP_FindInf(HINF16 hInf, WORD *ret)
|
|
|
|
{
|
|
|
|
WORD n;
|
|
|
|
|
|
|
|
for (n=0; n < InfNumEntries; n++)
|
|
|
|
if (InfList[n].hInf == hInf)
|
|
|
|
{
|
|
|
|
*ret = n;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-27 00:46:36 +02:00
|
|
|
LPCSTR IP_GetFileName(HINF16 hInf)
|
|
|
|
{
|
2000-11-04 03:57:18 +01:00
|
|
|
WORD n;
|
|
|
|
if (IP_FindInf(hInf, &n))
|
2000-09-27 00:46:36 +02:00
|
|
|
{
|
2000-11-04 03:57:18 +01:00
|
|
|
return InfList[n].lpInfFileName;
|
2000-09-27 00:46:36 +02:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
RETERR16 IP_CloseInf(HINF16 hInf)
|
|
|
|
{
|
|
|
|
int i;
|
2000-11-04 03:57:18 +01:00
|
|
|
WORD n;
|
2000-11-26 23:40:49 +01:00
|
|
|
RETERR16 res = ERR_IP_INVALID_HINF;
|
2000-09-27 00:46:36 +02:00
|
|
|
|
2000-11-04 03:57:18 +01:00
|
|
|
if (IP_FindInf(hInf, &n))
|
2000-09-27 00:46:36 +02:00
|
|
|
{
|
2000-11-26 23:40:49 +01:00
|
|
|
_lclose(InfList[n].hInfFile);
|
2000-11-04 03:57:18 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, InfList[n].lpInfFileName);
|
|
|
|
for (i=n; i < InfNumEntries-1; i++)
|
2000-09-27 00:46:36 +02:00
|
|
|
InfList[i] = InfList[i+1];
|
|
|
|
InfNumEntries--;
|
|
|
|
InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
|
2000-11-04 03:57:18 +01:00
|
|
|
res = OK;
|
2000-09-27 00:46:36 +02:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IpOpen16
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
RETERR16 WINAPI IpOpen16(LPCSTR lpInfFileName, HINF16 *lphInf)
|
|
|
|
{
|
|
|
|
TRACE("('%s', %p)\n", lpInfFileName, lphInf);
|
|
|
|
return IP_OpenInf(lpInfFileName, lphInf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IpClose16
|
|
|
|
*/
|
|
|
|
RETERR16 WINAPI IpClose16(HINF16 hInf)
|
|
|
|
{
|
|
|
|
return IP_CloseInf(hInf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IpGetProfileString16
|
|
|
|
*/
|
|
|
|
RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen)
|
|
|
|
{
|
2000-11-04 03:57:18 +01:00
|
|
|
TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf), section, entry);
|
2000-11-13 05:16:05 +01:00
|
|
|
GetPrivateProfileStringA(section, entry, "", buffer, buflen, IP_GetFileName(hInf));
|
2000-09-27 00:46:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|