ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

inffile.c
Go to the documentation of this file.
00001 /*
00002  *  ReactOS kernel
00003  *  Copyright (C) 2002 ReactOS Team
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 /*
00020  * COPYRIGHT:       See COPYING in the top level directory
00021  * PROJECT:         ReactOS text-mode setup
00022  * FILE:            subsys/system/usetup/inffile.c
00023  * PURPOSE:         .inf files support functions
00024  * PROGRAMMER:      Hervé Poussineau
00025  */
00026 
00027 /* INCLUDES ******************************************************************/
00028 
00029 #include "usetup.h"
00030 
00031 #define NDEBUG
00032 #include <debug.h>
00033 
00034 /* FUNCTIONS *****************************************************************/
00035 
00036 #ifdef __REACTOS__
00037 
00038 BOOL WINAPI
00039 InfpFindFirstLineW(
00040     IN HINF InfHandle,
00041     IN PCWSTR Section,
00042     IN PCWSTR Key,
00043     IN OUT PINFCONTEXT Context)
00044 {
00045     PINFCONTEXT pContext;
00046     BOOL ret;
00047 
00048     ret = InfFindFirstLine(InfHandle, Section, Key, &pContext);
00049     if (!ret)
00050         return FALSE;
00051 
00052     memcpy(Context, pContext, sizeof(INFCONTEXT));
00053     InfFreeContext(pContext);
00054     return TRUE;
00055 }
00056 
00057 HINF WINAPI
00058 InfpOpenInfFileW(
00059     IN PCWSTR FileName,
00060     IN PCWSTR InfClass,
00061     IN DWORD InfStyle,
00062     IN LCID LocaleId,
00063     OUT PUINT ErrorLine)
00064 {
00065     HINF hInf = NULL;
00066     UNICODE_STRING FileNameU;
00067     ULONG ErrorLineUL;
00068     NTSTATUS Status;
00069 
00070     RtlInitUnicodeString(&FileNameU, FileName);
00071     Status = InfOpenFile(
00072         &hInf,
00073         &FileNameU,
00074         LANGIDFROMLCID(LocaleId),
00075         &ErrorLineUL);
00076     *ErrorLine = (UINT)ErrorLineUL;
00077     if (!NT_SUCCESS(Status))
00078         return INVALID_HANDLE_VALUE;
00079 
00080     return hInf;
00081 }
00082 
00083 #endif /* __REACTOS__ */
00084 
00085 BOOLEAN
00086 INF_GetData(
00087     IN PINFCONTEXT Context,
00088     OUT PWCHAR *Key,
00089     OUT PWCHAR *Data)
00090 {
00091 #ifdef __REACTOS__
00092     return InfGetData(Context, Key, Data);
00093 #else
00094     static PWCHAR pLastCallData[4] = { NULL, NULL, NULL, NULL };
00095     static DWORD currentIndex = 0;
00096     DWORD dwSize, i;
00097     BOOL ret;
00098 
00099     currentIndex ^= 2;
00100 
00101     if (Key) *Key = NULL;
00102     if (Data) *Data = NULL;
00103 
00104     if (SetupGetFieldCount(Context) != 1)
00105         return FALSE;
00106 
00107     for (i = 0; i <= 1; i++)
00108     {
00109         ret = SetupGetStringFieldW(
00110             Context,
00111             i,
00112             NULL,
00113             0,
00114             &dwSize);
00115         if (!ret)
00116             return FALSE;
00117         HeapFree(GetProcessHeap(), 0, pLastCallData[i + currentIndex]);
00118         pLastCallData[i + currentIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
00119         ret = SetupGetStringFieldW(
00120             Context,
00121             i,
00122             pLastCallData[i + currentIndex],
00123             dwSize,
00124             NULL);
00125         if (!ret)
00126             return FALSE;
00127     }
00128 
00129     if (Key)
00130         *Key = pLastCallData[0 + currentIndex];
00131     if (Data)
00132         *Data = pLastCallData[1 + currentIndex];
00133     return TRUE;
00134 #endif /* !__REACTOS__ */
00135 }
00136 
00137 BOOLEAN
00138 INF_GetDataField(
00139     IN PINFCONTEXT Context,
00140     IN ULONG FieldIndex,
00141     OUT PWCHAR *Data)
00142 {
00143 #ifdef __REACTOS__
00144     return InfGetDataField(Context, FieldIndex, Data);
00145 #else
00146     static PWCHAR pLastCallsData[] = { NULL, NULL, NULL };
00147     static DWORD NextIndex = 0;
00148     DWORD dwSize;
00149     BOOL ret;
00150 
00151     *Data = NULL;
00152 
00153     ret = SetupGetStringFieldW(
00154         Context,
00155         FieldIndex,
00156         NULL,
00157         0,
00158         &dwSize);
00159     if (!ret)
00160         return FALSE;
00161     HeapFree(GetProcessHeap(), 0, pLastCallsData[NextIndex]);
00162     pLastCallsData[NextIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
00163     ret = SetupGetStringFieldW(
00164         Context,
00165         FieldIndex,
00166         pLastCallsData[NextIndex],
00167         dwSize,
00168         NULL);
00169     if (!ret)
00170         return FALSE;
00171 
00172     *Data = pLastCallsData[NextIndex];
00173     NextIndex = (NextIndex + 1) % (sizeof(pLastCallsData) / sizeof(pLastCallsData[0]));
00174     return TRUE;
00175 #endif /* !__REACTOS__ */
00176 }
00177 
00178 HINF WINAPI
00179 INF_OpenBufferedFileA(
00180     IN PSTR FileBuffer,
00181     IN ULONG FileSize,
00182     IN PCSTR InfClass,
00183     IN DWORD InfStyle,
00184     IN LCID LocaleId,
00185     OUT PUINT ErrorLine)
00186 {
00187 #ifdef __REACTOS__
00188     HINF hInf = NULL;
00189     ULONG ErrorLineUL;
00190     NTSTATUS Status;
00191 
00192     Status = InfOpenBufferedFile(
00193         &hInf,
00194         FileBuffer,
00195         FileSize,
00196         LANGIDFROMLCID(LocaleId),
00197         &ErrorLineUL);
00198     *ErrorLine = (UINT)ErrorLineUL;
00199     if (!NT_SUCCESS(Status))
00200         return INVALID_HANDLE_VALUE;
00201 
00202     return hInf;
00203 #else
00204     return INVALID_HANDLE_VALUE;
00205 #endif /* !__REACTOS__ */
00206 }
00207 
00208 /* EOF */

Generated on Sat May 26 2012 04:16:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.