2000-09-27 00:46:36 +02:00
|
|
|
/*
|
|
|
|
* SetupX .inf file parsing functions
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 2000 Andreas Mohr for Codeweavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
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>
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-27 00:46:36 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#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
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* IpOpen (SETUPX.2)
|
2000-09-27 00:46:36 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
RETERR16 WINAPI IpOpen16(LPCSTR lpInfFileName, HINF16 *lphInf)
|
|
|
|
{
|
|
|
|
TRACE("('%s', %p)\n", lpInfFileName, lphInf);
|
|
|
|
return IP_OpenInf(lpInfFileName, lphInf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* IpClose (SETUPX.4)
|
2000-09-27 00:46:36 +02:00
|
|
|
*/
|
|
|
|
RETERR16 WINAPI IpClose16(HINF16 hInf)
|
|
|
|
{
|
|
|
|
return IP_CloseInf(hInf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* IpGetProfileString (SETUPX.210)
|
2000-09-27 00:46:36 +02:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|