Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygeninfhostput.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 "infhost.h" 00011 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 int 00016 InfHostWriteFile(HINF InfHandle, 00017 const CHAR *FileName, 00018 const CHAR *HeaderComment) 00019 { 00020 WCHAR *Buffer; 00021 ULONG BufferSize; 00022 INFSTATUS Status; 00023 FILE *File; 00024 00025 Status = InfpBuildFileBuffer((PINFCACHE) InfHandle, &Buffer, &BufferSize); 00026 if (! INF_SUCCESS(Status)) 00027 { 00028 errno = Status; 00029 return -1; 00030 } 00031 00032 File = fopen(FileName, "wb"); 00033 if (NULL == File) 00034 { 00035 FREE(Buffer); 00036 DPRINT1("fopen() failed (errno %d)\n", errno); 00037 return -1; 00038 } 00039 00040 DPRINT("fopen() successful\n"); 00041 00042 if (NULL != HeaderComment && '\0' != *HeaderComment) 00043 { 00044 // fprintf(File, "; %s\r\n\r\n", HeaderComment); 00045 } 00046 00047 if (BufferSize != fwrite(Buffer, (size_t)1, (size_t)BufferSize, File)) 00048 { 00049 DPRINT1("fwrite() failed (errno %d)\n", errno); 00050 fclose(File); 00051 FREE(Buffer); 00052 return -1; 00053 } 00054 00055 fclose(File); 00056 00057 FREE(Buffer); 00058 00059 return 0; 00060 } 00061 00062 int 00063 InfHostFindOrAddSection(HINF InfHandle, 00064 const WCHAR *Section, 00065 PINFCONTEXT *Context) 00066 { 00067 INFSTATUS Status; 00068 00069 Status = InfpFindOrAddSection((PINFCACHE) InfHandle, Section, Context); 00070 if (INF_SUCCESS(Status)) 00071 { 00072 return 0; 00073 } 00074 else 00075 { 00076 errno = Status; 00077 return -1; 00078 } 00079 } 00080 00081 int 00082 InfHostAddLine(PINFCONTEXT Context, const WCHAR *Key) 00083 { 00084 INFSTATUS Status; 00085 00086 Status = InfpAddLineWithKey(Context, Key); 00087 if (INF_SUCCESS(Status)) 00088 { 00089 return 0; 00090 } 00091 else 00092 { 00093 errno = Status; 00094 return -1; 00095 } 00096 } 00097 00098 int 00099 InfHostAddField(PINFCONTEXT Context, const WCHAR *Data) 00100 { 00101 INFSTATUS Status; 00102 00103 Status = InfpAddField(Context, Data); 00104 if (INF_SUCCESS(Status)) 00105 { 00106 return 0; 00107 } 00108 else 00109 { 00110 errno = Status; 00111 return -1; 00112 } 00113 } 00114 00115 /* EOF */ Generated on Mon May 28 2012 04:36:09 for ReactOS by
1.7.6.1
|