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

infrosput.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:    .inf file parser
00003  * LICENSE:    GPL - See COPYING in the top level directory
00004  * COPYRIGHT:  Copyright 2005 Ge van Geldorp <gvg@reactos.org>
00005  */
00006 
00007 /* INCLUDES *****************************************************************/
00008 
00009 #include "inflib.h"
00010 #include "infros.h"
00011 
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 NTSTATUS
00016 InfWriteFile(HINF InfHandle,
00017              PUNICODE_STRING FileName,
00018              PUNICODE_STRING HeaderComment)
00019 {
00020   OBJECT_ATTRIBUTES ObjectAttributes;
00021   IO_STATUS_BLOCK IoStatusBlock;
00022   HANDLE FileHandle;
00023   NTSTATUS Status;
00024   INFSTATUS InfStatus;
00025   PCHAR Buffer;
00026   ULONG BufferSize;
00027   PCHAR HeaderBuffer;
00028   ULONG HeaderBufferSize;
00029   UINT Index;
00030 
00031   InfStatus = InfpBuildFileBuffer((PINFCACHE) InfHandle, &Buffer, &BufferSize);
00032   if (! INF_SUCCESS(InfStatus))
00033     {
00034       DPRINT("Failed to create buffer (Status 0x%lx)\n", InfStatus);
00035       return InfStatus;
00036     }
00037 
00038   /* Open the inf file */
00039   InitializeObjectAttributes(&ObjectAttributes,
00040                              FileName,
00041                              0,
00042                              NULL,
00043                              NULL);
00044 
00045   Status = NtOpenFile(&FileHandle,
00046                       GENERIC_WRITE | SYNCHRONIZE,
00047                       &ObjectAttributes,
00048                       &IoStatusBlock,
00049                       0,
00050                       FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
00051   if (!INF_SUCCESS(Status))
00052     {
00053       DPRINT1("NtOpenFile() failed (Status %lx)\n", Status);
00054       FREE(Buffer);
00055       return Status;
00056     }
00057 
00058   DPRINT("NtOpenFile() successful\n");
00059 
00060   if (NULL != HeaderComment && 0 != HeaderComment->Length)
00061     {
00062       /* This is just a comment header, don't abort on errors here */
00063       HeaderBufferSize = HeaderComment->Length / sizeof(WCHAR) + 7;
00064       HeaderBuffer = MALLOC(HeaderBufferSize);
00065       if (NULL != HeaderBuffer)
00066         {
00067           strcpy(HeaderBuffer, "; ");
00068           for (Index = 0; Index < HeaderComment->Length / sizeof(WCHAR); Index++)
00069             {
00070               HeaderBuffer[2 + Index] = (CHAR) HeaderComment->Buffer[Index];
00071             }
00072           strcpy(HeaderBuffer + (2 + HeaderComment->Length / sizeof(WCHAR)),
00073                  "\r\n\r\n");
00074           NtWriteFile(FileHandle,
00075                       NULL,
00076                       NULL,
00077                       NULL,
00078                       &IoStatusBlock,
00079                       HeaderBuffer,
00080                       HeaderBufferSize,
00081                       NULL,
00082                       NULL);
00083           FREE(HeaderBuffer);
00084         }
00085     }
00086 
00087   /* Write main contents */
00088   Status = NtWriteFile(FileHandle,
00089                        NULL,
00090                        NULL,
00091                        NULL,
00092                        &IoStatusBlock,
00093                        Buffer,
00094                        BufferSize,
00095                        NULL,
00096                        NULL);
00097 
00098   NtClose(FileHandle);
00099   FREE(Buffer);
00100 
00101   if (!INF_SUCCESS(Status))
00102     {
00103       DPRINT1("NtWriteFile() failed (Status %lx)\n", Status);
00104       FREE(Buffer);
00105       return(Status);
00106     }
00107 
00108   return STATUS_SUCCESS;
00109 }
00110 
00111 BOOLEAN
00112 InfFindOrAddSection(HINF InfHandle,
00113                     PCWSTR Section,
00114                     PINFCONTEXT *Context)
00115 {
00116   return INF_SUCCESS(InfpFindOrAddSection((PINFCACHE) InfHandle,
00117                                           Section, Context));
00118 }
00119 
00120 BOOLEAN
00121 InfHostAddLine(PINFCONTEXT Context, PCWSTR Key)
00122 {
00123   return INF_SUCCESS(InfpAddLineWithKey(Context, Key));
00124 }
00125 
00126 BOOLEAN
00127 InfHostAddField(PINFCONTEXT Context, PCWSTR Data)
00128 {
00129   return INF_SUCCESS(InfpAddField(Context, Data));
00130 }
00131 
00132 /* EOF */

Generated on Mon May 28 2012 04:36:09 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.