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