reactos/lib/newinflib/infhostput.c
Jérôme Gardou 88c9e7c6e8 Sync with trunk (r47116), hopefully without breaking anything.
svn path=/branches/reactos-yarotows/; revision=47117
2010-05-07 07:41:13 +00:00

115 lines
2 KiB
C

/*
* PROJECT: .inf file parser
* LICENSE: GPL - See COPYING in the top level directory
* COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "inflib.h"
#include "infhost.h"
#define NDEBUG
#include <debug.h>
int
InfHostWriteFile(HINF InfHandle,
const CHAR *FileName,
const CHAR *HeaderComment)
{
WCHAR *Buffer;
ULONG BufferSize;
INFSTATUS Status;
FILE *File;
Status = InfpBuildFileBuffer((PINFCACHE) InfHandle, &Buffer, &BufferSize);
if (! INF_SUCCESS(Status))
{
errno = Status;
return -1;
}
File = fopen(FileName, "wb");
if (NULL == File)
{
FREE(Buffer);
DPRINT1("fopen() failed (errno %d)\n", errno);
return -1;
}
DPRINT("fopen() successful\n");
if (NULL != HeaderComment && '\0' != *HeaderComment)
{
// fprintf(File, "; %s\r\n\r\n", HeaderComment);
}
if (BufferSize != fwrite(Buffer, (size_t)1, (size_t)BufferSize, File))
{
DPRINT1("fwrite() failed (errno %d)\n", errno);
fclose(File);
FREE(Buffer);
return -1;
}
fclose(File);
FREE(Buffer);
return 0;
}
int
InfHostFindOrAddSection(HINF InfHandle,
const WCHAR *Section,
PINFCONTEXT *Context)
{
INFSTATUS Status;
Status = InfpFindOrAddSection((PINFCACHE) InfHandle, Section, Context);
if (INF_SUCCESS(Status))
{
return 0;
}
else
{
errno = Status;
return -1;
}
}
int
InfHostAddLine(PINFCONTEXT Context, const WCHAR *Key)
{
INFSTATUS Status;
Status = InfpAddLineWithKey(Context, Key);
if (INF_SUCCESS(Status))
{
return 0;
}
else
{
errno = Status;
return -1;
}
}
int
InfHostAddField(PINFCONTEXT Context, const WCHAR *Data)
{
INFSTATUS Status;
Status = InfpAddField(Context, Data);
if (INF_SUCCESS(Status))
{
return 0;
}
else
{
errno = Status;
return -1;
}
}
/* EOF */