ReactOS  0.4.13-dev-982-g9853eab
infhostput.c
Go to the documentation of this file.
1 /*
2  * PROJECT: .inf file parser
3  * LICENSE: GPL - See COPYING in the top level directory
4  * COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg@reactos.org>
5  */
6 
7 /* INCLUDES *****************************************************************/
8 
9 #include "inflib.h"
10 #include "infhost.h"
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 int
17  const CHAR *FileName,
18  const CHAR *HeaderComment)
19 {
20  WCHAR *Buffer;
23  FILE *File;
24 
26  if (! INF_SUCCESS(Status))
27  {
28  errno = Status;
29  return -1;
30  }
31 
32  File = fopen(FileName, "wb");
33  if (NULL == File)
34  {
35  FREE(Buffer);
36  DPRINT1("fopen() failed (errno %d)\n", errno);
37  return -1;
38  }
39 
40  DPRINT("fopen() successful\n");
41 
42  if (NULL != HeaderComment && '\0' != *HeaderComment)
43  {
44 // fprintf(File, "; %s\r\n\r\n", HeaderComment);
45  }
46 
47  if (BufferSize != fwrite(Buffer, (size_t)1, (size_t)BufferSize, File))
48  {
49  DPRINT1("fwrite() failed (errno %d)\n", errno);
50  fclose(File);
51  FREE(Buffer);
52  return -1;
53  }
54 
55  fclose(File);
56 
57  FREE(Buffer);
58 
59  return 0;
60 }
61 
62 int
64  const WCHAR *Section,
66 {
68 
69  Status = InfpFindOrAddSection((PINFCACHE) InfHandle, Section, Context);
70  if (INF_SUCCESS(Status))
71  {
72  return 0;
73  }
74  else
75  {
76  errno = Status;
77  return -1;
78  }
79 }
80 
81 int
83 {
85 
87  if (INF_SUCCESS(Status))
88  {
89  return 0;
90  }
91  else
92  {
93  errno = Status;
94  return -1;
95  }
96 }
97 
98 int
100 {
102 
104  if (INF_SUCCESS(Status))
105  {
106  return 0;
107  }
108  else
109  {
110  errno = Status;
111  return -1;
112  }
113 }
114 
115 /* EOF */
INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key)
Definition: infput.c:224
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context)
Definition: infput.c:190
char CHAR
Definition: xmlstorage.h:175
INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data)
Definition: infput.c:254
int errno
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
int INFSTATUS
Definition: infpriv.h:77
INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
Definition: infput.c:90
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
int InfHostFindOrAddSection(HINF InfHandle, const WCHAR *Section, PINFCONTEXT *Context)
Definition: infhostput.c:63
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BufferSize
Definition: classpnp.h:419
#define FREE(ptr, size)
Definition: auth_des.c:64
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
int InfHostAddLine(PINFCONTEXT Context, const WCHAR *Key)
Definition: infhostput.c:82
Status
Definition: gdiplustypes.h:24
int InfHostWriteFile(HINF InfHandle, const CHAR *FileName, const CHAR *HeaderComment)
Definition: infhostput.c:16
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
int InfHostAddField(PINFCONTEXT Context, const WCHAR *Data)
Definition: infhostput.c:99