ReactOS 0.4.16-dev-297-gc569aee
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
15int
17 const CHAR *FileName,
18 const CHAR *HeaderComment)
19{
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
62int
64 const WCHAR *Section,
66{
68
69 Status = InfpFindOrAddSection((PINFCACHE) InfHandle, Section, Context);
71 {
72 return 0;
73 }
74 else
75 {
76 errno = Status;
77 return -1;
78 }
79}
80
81int
83{
85
88 {
89 return 0;
90 }
91 else
92 {
93 errno = Status;
94 return -1;
95 }
96}
97
98int
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 */
#define FREE(ptr, size)
Definition: auth_des.c:64
#define DPRINT1
Definition: precomp.h:8
#define INF_SUCCESS(x)
Definition: builddep.h:82
Definition: bufpool.h:45
Definition: File.h:16
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_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 InfHostWriteFile(HINF InfHandle, const CHAR *FileName, const CHAR *HeaderComment)
Definition: infhostput.c:16
int InfHostAddField(PINFCONTEXT Context, const WCHAR *Data)
Definition: infhostput.c:99
int InfHostFindOrAddSection(HINF InfHandle, const WCHAR *Section, PINFCONTEXT *Context)
Definition: infhostput.c:63
int InfHostAddLine(PINFCONTEXT Context, const WCHAR *Key)
Definition: infhostput.c:82
INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context)
Definition: infput.c:190
INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key)
Definition: infput.c:224
INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
Definition: infput.c:90
int INFSTATUS
Definition: infpriv.h:77
INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data)
Definition: infput.c:254
#define errno
Definition: errno.h:18
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175