Implement adding new sections/lines/fields and writing the resulting
file
Modified: trunk/reactos/lib/inflib/builddep.h
Modified: trunk/reactos/lib/inflib/infcommon.h
Modified: trunk/reactos/lib/inflib/infcore.c
Modified: trunk/reactos/lib/inflib/infget.c
Modified: trunk/reactos/lib/inflib/infhost.h
Modified: trunk/reactos/lib/inflib/infhostgen.c
Modified: trunk/reactos/lib/inflib/infhostget.c
Added: trunk/reactos/lib/inflib/infhostglue.c
Added: trunk/reactos/lib/inflib/infhostput.c
Modified: trunk/reactos/lib/inflib/inflib.h
Modified: trunk/reactos/lib/inflib/inflib.mak
Modified: trunk/reactos/lib/inflib/inflib.xml
Modified: trunk/reactos/lib/inflib/infpriv.h
Added: trunk/reactos/lib/inflib/infput.c
Modified: trunk/reactos/lib/inflib/infros.h
Modified: trunk/reactos/lib/inflib/infrosgen.c
Modified: trunk/reactos/lib/inflib/infrosget.c
Added: trunk/reactos/lib/inflib/infrosput.c
_____
Modified: trunk/reactos/lib/inflib/builddep.h
--- trunk/reactos/lib/inflib/builddep.h 2005-11-25 21:29:16 UTC (rev
19571)
+++ trunk/reactos/lib/inflib/builddep.h 2005-11-25 21:37:23 UTC (rev
19572)
@@ -1,18 +1,21 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/builddep.h
- * PURPOSE: Build dependent definitions
- * PROGRAMMER: Ge van Geldorp <gvg(a)reactos.org>
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg(a)reactos.org>
*/
#ifdef INFLIB_HOST
/* Definitions native to the host on which we're building */
+#include <stdarg.h>
+#include <stdio.h>
#include <string.h>
#include <errno.h>
+#define FALSE 0
+#define TRUE 1
+
#define FREE(Area) free(Area)
#define MALLOC(Size) malloc(Size)
#define ZEROMEMORY(Area, Size) memset((Area), '\0', (Size))
@@ -39,6 +42,7 @@
#define _tcscpy strcpy
#define _tcstoul strtoul
#define _tcstol strtol
+#define STRFMT "%s"
extern void DbgPrint(const char *Fmt, ...);
@@ -68,6 +72,8 @@
#define INF_STATUS_BUFFER_OVERFLOW STATUS_BUFFER_OVERFLOW
#define INF_SUCCESS(x) (0 <= (x))
+#define STRFMT "%S"
+
#endif /* INFLIB_HOST */
typedef const TCHAR *PCTSTR;
_____
Modified: trunk/reactos/lib/inflib/infcommon.h
--- trunk/reactos/lib/inflib/infcommon.h 2005-11-25 21:29:16 UTC
(rev 19571)
+++ trunk/reactos/lib/inflib/infcommon.h 2005-11-25 21:37:23 UTC
(rev 19572)
@@ -1,11 +1,9 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infcommon.h
- * PURPOSE: Public .inf routines
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
#ifndef INFCOMMON_H_INCLUDED
_____
Modified: trunk/reactos/lib/inflib/infcore.c
--- trunk/reactos/lib/inflib/infcore.c 2005-11-25 21:29:16 UTC (rev
19571)
+++ trunk/reactos/lib/inflib/infcore.c 2005-11-25 21:37:23 UTC (rev
19572)
@@ -1,11 +1,9 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infcore.c
- * PURPOSE: INF file parser that caches contents of INF file in
memory
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
/* INCLUDES
*****************************************************************/
@@ -85,7 +83,7 @@
/* PRIVATE FUNCTIONS
********************************************************/
static PINFCACHELINE
-InfpCacheFreeLine (PINFCACHELINE Line)
+InfpFreeLine (PINFCACHELINE Line)
{
PINFCACHELINE Next;
PINFCACHEFIELD Field;
@@ -118,7 +116,7 @@
PINFCACHESECTION
-InfpCacheFreeSection (PINFCACHESECTION Section)
+InfpFreeSection (PINFCACHESECTION Section)
{
PINFCACHESECTION Next;
@@ -131,7 +129,7 @@
Next = Section->Next;
while (Section->FirstLine != NULL)
{
- Section->FirstLine = InfpCacheFreeLine (Section->FirstLine);
+ Section->FirstLine = InfpFreeLine (Section->FirstLine);
}
Section->LastLine = NULL;
@@ -141,9 +139,9 @@
}
-static PINFCACHESECTION
-InfpCacheFindSection (PINFCACHE Cache,
- PCTSTR Name)
+PINFCACHESECTION
+InfpFindSection(PINFCACHE Cache,
+ PCTSTR Name)
{
PINFCACHESECTION Section = NULL;
@@ -157,9 +155,9 @@
while (Section != NULL)
{
if (_tcsicmp (Section->Name, Name) == 0)
- {
- return Section;
- }
+ {
+ return Section;
+ }
/* get the next section*/
Section = Section->Next;
@@ -169,9 +167,9 @@
}
-static PINFCACHESECTION
-InfpCacheAddSection (PINFCACHE Cache,
- PTCHAR Name)
+PINFCACHESECTION
+InfpAddSection(PINFCACHE Cache,
+ PCTSTR Name)
{
PINFCACHESECTION Section = NULL;
ULONG Size;
@@ -213,8 +211,8 @@
}
-static PINFCACHELINE
-InfpCacheAddLine (PINFCACHESECTION Section)
+PINFCACHELINE
+InfpAddLine(PINFCACHESECTION Section)
{
PINFCACHELINE Line;
@@ -251,37 +249,47 @@
}
-static PVOID
-InfpAddKeyToLine (PINFCACHELINE Line,
- PTCHAR Key)
+PVOID
+InfpAddKeyToLine(PINFCACHELINE Line,
+ PCTSTR Key)
{
if (Line == NULL)
- return NULL;
+ {
+ DPRINT1("Invalid Line\n");
+ return NULL;
+ }
if (Line->Key != NULL)
- return NULL;
+ {
+ DPRINT1("Line already has a key\n");
+ return NULL;
+ }
- Line->Key = (PTCHAR)MALLOC ((_tcslen (Key) + 1) * sizeof(TCHAR));
+ Line->Key = (PTCHAR)MALLOC((_tcslen(Key) + 1) * sizeof(TCHAR));
if (Line->Key == NULL)
- return NULL;
+ {
+ DPRINT1("MALLOC() failed\n");
+ return NULL;
+ }
- _tcscpy (Line->Key, Key);
+ _tcscpy(Line->Key, Key);
return (PVOID)Line->Key;
}
-static PVOID
-InfpAddFieldToLine (PINFCACHELINE Line,
- PTCHAR Data)
+PVOID
+InfpAddFieldToLine(PINFCACHELINE Line,
+ PCTSTR Data)
{
PINFCACHEFIELD Field;
ULONG Size;
Size = sizeof(INFCACHEFIELD) + (_tcslen(Data) * sizeof(TCHAR));
- Field = (PINFCACHEFIELD)MALLOC (Size);
+ Field = (PINFCACHEFIELD)MALLOC(Size);
if (Field == NULL)
{
+ DPRINT1("MALLOC() failed\n");
return NULL;
}
ZEROMEMORY (Field,
@@ -307,8 +315,8 @@
PINFCACHELINE
-InfpCacheFindKeyLine (PINFCACHESECTION Section,
- PTCHAR Key)
+InfpFindKeyLine(PINFCACHESECTION Section,
+ PCTSTR Key)
{
PINFCACHELINE Line;
@@ -316,9 +324,9 @@
while (Line != NULL)
{
if (Line->Key != NULL && _tcsicmp (Line->Key, Key) == 0)
- {
- return Line;
- }
+ {
+ return Line;
+ }
Line = Line->Next;
}
@@ -363,9 +371,9 @@
inline static int is_eol( struct parser *parser, const CHAR *ptr )
{
return (ptr >= parser->end ||
- *ptr == CONTROL_Z ||
- *ptr == '\n' ||
- (*ptr == '\r' && *(ptr + 1) == '\n'));
+ *ptr == CONTROL_Z ||
+ *ptr == '\n' ||
+ (*ptr == '\r' && *(ptr + 1) == '\n'));
}
@@ -401,18 +409,18 @@
return NULL;
}
- Section = InfpCacheFindSection (parser->file,
- parser->token);
+ Section = InfpFindSection(parser->file,
+ parser->token);
if (Section == NULL)
{
/* need to create a new one */
- Section= InfpCacheAddSection (parser->file,
- parser->token);
+ Section= InfpAddSection(parser->file,
+ parser->token);
if (Section == NULL)
- {
- parser->error = INF_STATUS_NOT_ENOUGH_MEMORY;
- return NULL;
- }
+ {
+ parser->error = INF_STATUS_NOT_ENOUGH_MEMORY;
+ return NULL;
+ }
}
parser->token_len = 0;
@@ -430,14 +438,14 @@
if (!parser->line) /* need to start a new line */
{
if (parser->cur_section == NULL) /* got a line before the first
section */
- {
- parser->error = INF_STATUS_WRONG_INF_STYLE;
- return NULL;
- }
+ {
+ parser->error = INF_STATUS_WRONG_INF_STYLE;
+ return NULL;
+ }
- parser->line = InfpCacheAddLine (parser->cur_section);
+ parser->line = InfpAddLine(parser->cur_section);
if (parser->line == NULL)
- goto error;
+ goto error;
}
else
{
@@ -481,34 +489,34 @@
for (p = pos; !is_eof( parser, p ); p++)
{
switch(*p)
- {
- case '\r':
- continue;
+ {
+ case '\r':
+ continue;
- case '\n':
- parser->line_pos++;
- close_current_line( parser );
- break;
+ case '\n':
+ parser->line_pos++;
+ close_current_line( parser );
+ break;
- case ';':
- push_state( parser, LINE_START );
- set_state( parser, COMMENT );
- return p + 1;
+ case ';':
+ push_state( parser, LINE_START );
+ set_state( parser, COMMENT );
+ return p + 1;
- case '[':
- parser->start = p + 1;
- set_state( parser, SECTION_NAME );
- return p + 1;
+ case '[':
+ parser->start = p + 1;
+ set_state( parser, SECTION_NAME );
+ return p + 1;
- default:
- if (!isspace(*p))
- {
- parser->start = p;
- set_state( parser, KEY_NAME );
- return p;
- }
- break;
- }
+ default:
+ if (!isspace(*p))
+ {
+ parser->start = p;
+ set_state( parser, KEY_NAME );
+ return p;
+ }
+ break;
+ }
}
close_current_line( parser );
return NULL;
@@ -523,14 +531,14 @@
for (p = pos; !is_eol( parser, p ); p++)
{
if (*p == ']')
- {
- push_token( parser, p );
- if (add_section_from_token( parser ) == NULL)
- return NULL;
- push_state( parser, LINE_START );
- set_state( parser, COMMENT ); /* ignore everything else on
the line */
- return p + 1;
- }
+ {
+ push_token( parser, p );
+ if (add_section_from_token( parser ) == NULL)
+ return NULL;
+ push_state( parser, LINE_START );
+ set_state( parser, COMMENT ); /* ignore everything else on
the line */
+ return p + 1;
+ }
}
parser->error = INF_STATUS_BAD_SECTION_NAME_LINE; /* unfinished
section name */
return NULL;
@@ -652,31 +660,31 @@
for (p = pos; !is_eof( parser, p ); p++)
{
switch(*p)
- {
- case '\r':
- continue;
+ {
+ case '\r':
+ continue;
- case '\n':
- parser->line_pos++;
- parser->start = p + 1;
- set_state( parser, LEADING_SPACES );
- return p + 1;
+ case '\n':
+ parser->line_pos++;
+ parser->start = p + 1;
+ set_state( parser, LEADING_SPACES );
+ return p + 1;
- case '\\':
- continue;
+ case '\\':
+ continue;
- case ';':
- push_state( parser, EOL_BACKSLASH );
- set_state( parser, COMMENT );
- return p + 1;
+ case ';':
+ push_state( parser, EOL_BACKSLASH );
+ set_state( parser, COMMENT );
+ return p + 1;
- default:
- if (isspace(*p))
- continue;
- push_token( parser, p );
- pop_state( parser );
- return p;
- }
+ default:
+ if (isspace(*p))
+ continue;
+ push_token( parser, p );
+ pop_state( parser );
+ return p;
+ }
}
parser->start = p;
pop_state( parser );
@@ -693,21 +701,21 @@
for (p = pos; !is_eol( parser, p ); p++)
{
if (*p == '"')
- {
- if (p+1 < parser->end && p[1] == '"') /* double quotes */
- {
- push_token( parser, p + 1 );
- parser->start = token_end = p + 2;
- p++;
- }
- else /* end of quotes */
- {
- push_token( parser, p );
- parser->start = p + 1;
- pop_state( parser );
- return p + 1;
- }
- }
+ {
+ if (p+1 < parser->end && p[1] == '"') /* double
quotes */
+ {
+ push_token( parser, p + 1 );
+ parser->start = token_end = p + 2;
+ p++;
+ }
+ else /* end of quotes */
+ {
+ push_token( parser, p );
+ parser->start = p + 1;
+ pop_state( parser );
+ return p + 1;
+ }
+ }
}
push_token( parser, p );
pop_state( parser );
@@ -723,13 +731,13 @@
for (p = pos; !is_eol( parser, p ); p++)
{
if (*p == '\\')
- {
- parser->start = p;
- set_state( parser, EOL_BACKSLASH );
- return p;
- }
+ {
+ parser->start = p;
+ set_state( parser, EOL_BACKSLASH );
+ return p;
+ }
if (!isspace(*p))
- break;
+ break;
}
parser->start = p;
pop_state( parser );
@@ -745,12 +753,12 @@
for (p = pos; !is_eol( parser, p ); p++)
{
if (*p == '\\')
- {
- set_state( parser, EOL_BACKSLASH );
- return p;
- }
+ {
+ set_state( parser, EOL_BACKSLASH );
+ return p;
+ }
if (!isspace(*p))
- break;
+ break;
}
pop_state( parser );
return p;
@@ -772,9 +780,9 @@
/* parse a complete buffer */
INFSTATUS
InfpParseBuffer (PINFCACHE file,
- const CHAR *buffer,
- const CHAR *end,
- PULONG error_line)
+ const CHAR *buffer,
+ const CHAR *end,
+ PULONG error_line)
{
struct parser parser;
const CHAR *pos = buffer;
@@ -797,13 +805,13 @@
if (parser.error)
{
if (error_line)
- *error_line = parser.line_pos;
+ *error_line = parser.line_pos;
return parser.error;
}
/* find the [strings] section */
- file->StringsSection = InfpCacheFindSection (file,
- _T("Strings"));
+ file->StringsSection = InfpFindSection(file,
+ _T("Strings"));
return INF_STATUS_SUCCESS;
}
_____
Modified: trunk/reactos/lib/inflib/infget.c
--- trunk/reactos/lib/inflib/infget.c 2005-11-25 21:29:16 UTC (rev
19571)
+++ trunk/reactos/lib/inflib/infget.c 2005-11-25 21:37:23 UTC (rev
19572)
@@ -1,11 +1,9 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infrosget.c
- * PURPOSE: Read .inf routines for use in ReactOS
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
/* INCLUDES
*****************************************************************/
@@ -17,65 +15,53 @@
INFSTATUS
-InfpFindFirstLine(HINF InfHandle,
+InfpFindFirstLine(PINFCACHE Cache,
PCTSTR Section,
PCTSTR Key,
PINFCONTEXT *Context)
{
- PINFCACHE Cache;
PINFCACHESECTION CacheSection;
PINFCACHELINE CacheLine;
- if (InfHandle == NULL || Section == NULL || Context == NULL)
+ if (Cache == NULL || Section == NULL || Context == NULL)
{
- DPRINT("Invalid parameter\n");
+ DPRINT1("Invalid parameter\n");
return INF_STATUS_INVALID_PARAMETER;
}
- *Context = MALLOC(sizeof(INFCONTEXT));
- if (NULL == *Context)
+ CacheSection = InfpFindSection(Cache, Section);
+ if (NULL == CacheSection)
{
- DPRINT1("MALLOC() failed\n");
- return INF_STATUS_NO_MEMORY;
+ DPRINT("Section not found\n");
+ return INF_STATUS_NOT_FOUND;
}
- Cache = (PINFCACHE)InfHandle;
+ if (Key != NULL)
+ {
+ CacheLine = InfpFindKeyLine(CacheSection, Key);
+ }
+ else
+ {
+ CacheLine = CacheSection->FirstLine;
+ }
- /* Iterate through list of sections */
- CacheSection = Cache->FirstSection;
- while (CacheSection != NULL)
+ if (NULL == CacheLine)
{
- DPRINT("Comparing '%S' and '%S'\n",
CacheSection->Name, Section);
+ DPRINT("Key not found\n");
+ return INF_STATUS_NOT_FOUND;
+ }
- /* Are the section names the same? */
- if (_tcsicmp(CacheSection->Name, Section) == 0)
- {
- if (Key != NULL)
- {
- CacheLine = InfpCacheFindKeyLine (CacheSection,
(PTCHAR)Key);
- }
- else
- {
- CacheLine = CacheSection->FirstLine;
- }
-
- if (CacheLine == NULL)
- return INF_STATUS_NOT_FOUND;
-
- (*Context)->Inf = (PVOID)Cache;
- (*Context)->Section = (PVOID)CacheSection;
- (*Context)->Line = (PVOID)CacheLine;
-
- return INF_STATUS_SUCCESS;
- }
-
- /* Get the next section */
- CacheSection = CacheSection->Next;
+ *Context = MALLOC(sizeof(INFCONTEXT));
+ if (NULL == *Context)
+ {
+ DPRINT1("MALLOC() failed\n");
+ return INF_STATUS_NO_MEMORY;
}
+ (*Context)->Inf = (PVOID)Cache;
+ (*Context)->Section = (PVOID)CacheSection;
+ (*Context)->Line = (PVOID)CacheLine;
- DPRINT("Section not found\n");
-
- return INF_STATUS_NOT_FOUND;
+ return INF_STATUS_SUCCESS;
}
_____
Modified: trunk/reactos/lib/inflib/infhost.h
--- trunk/reactos/lib/inflib/infhost.h 2005-11-25 21:29:16 UTC (rev
19571)
+++ trunk/reactos/lib/inflib/infhost.h 2005-11-25 21:37:23 UTC (rev
19572)
@@ -1,16 +1,18 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infros.h
- * PURPOSE: Public .inf routines for use on the host build
system
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
#ifndef INFHOST_H_INCLUDED
#define INFHOST_H_INCLUDED
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
#include <infcommon.h>
extern int InfHostOpenBufferedFile(PHINF InfHandle,
@@ -18,8 +20,11 @@
unsigned long BufferSize,
unsigned long *ErrorLine);
extern int InfHostOpenFile(PHINF InfHandle,
- char *FileName,
+ const char *FileName,
unsigned long *ErrorLine);
+extern int InfHostWriteFile(HINF InfHandle,
+ const char *FileName,
+ const char *HeaderComment);
extern void InfHostCloseFile(HINF InfHandle);
extern int InfHostFindFirstLine(HINF InfHandle,
const char *Section,
@@ -60,8 +65,17 @@
extern int InfHostGetDataField(PINFCONTEXT Context,
unsigned long FieldIndex,
char **Data);
-extern VOID InfHostFreeContext(PINFCONTEXT Context);
+extern int InfHostFindOrAddSection(HINF InfHandle,
+ const char *Section,
+ PINFCONTEXT *Context);
+extern int InfHostAddLine(PINFCONTEXT Context, const char *Key);
+extern int InfHostAddField(PINFCONTEXT Context, const char *Data);
+extern void InfHostFreeContext(PINFCONTEXT Context);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* INFROS_H_INCLUDED */
/* EOF */
_____
Modified: trunk/reactos/lib/inflib/infhostgen.c
--- trunk/reactos/lib/inflib/infhostgen.c 2005-11-25 21:29:16 UTC
(rev 19571)
+++ trunk/reactos/lib/inflib/infhostgen.c 2005-11-25 21:37:23 UTC
(rev 19572)
@@ -1,17 +1,13 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infhostgen.c
- * PURPOSE: General .inf routines for use on the host build
system
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
/* INCLUDES
*****************************************************************/
-#include <stdio.h>
-#include <errno.h>
#include "inflib.h"
#include "infhost.h"
@@ -50,7 +46,7 @@
Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
if (Cache == NULL)
{
- DPRINT("MALLOC() failed\n");
+ DPRINT1("MALLOC() failed\n");
FREE(FileBuffer);
return(INF_STATUS_INSUFFICIENT_RESOURCES);
}
@@ -81,7 +77,7 @@
int
InfHostOpenFile(PHINF InfHandle,
- char *FileName,
+ const char *FileName,
unsigned long *ErrorLine)
{
FILE *File;
@@ -97,7 +93,7 @@
File = fopen(FileName, "rb");
if (NULL == File)
{
- DPRINT("fopen() failed (errno %d)\n", errno);
+ DPRINT1("fopen() failed (errno %d)\n", errno);
return -1;
}
@@ -106,7 +102,7 @@
/* Query file size */
if (fseek(File, 0, SEEK_END))
{
- DPRINT("fseek() to EOF failed (errno %d)\n", errno);
+ DPRINT1("fseek() to EOF failed (errno %d)\n", errno);
fclose(File);
return -1;
}
@@ -114,7 +110,7 @@
FileLength = ftell(File);
if ((unsigned long) -1 == FileLength)
{
- DPRINT("ftell() failed (errno %d)\n", errno);
+ DPRINT1("ftell() failed (errno %d)\n", errno);
fclose(File);
return -1;
}
@@ -123,7 +119,7 @@
/* Rewind */
if (fseek(File, 0, SEEK_SET))
{
- DPRINT("fseek() to BOF failed (errno %d)\n", errno);
+ DPRINT1("fseek() to BOF failed (errno %d)\n", errno);
fclose(File);
return -1;
}
@@ -140,7 +136,7 @@
/* Read file */
if (FileLength != fread(FileBuffer, 1, FileLength, File))
{
- DPRINT("fread() failed (errno %d)\n", errno);
+ DPRINT1("fread() failed (errno %d)\n", errno);
fclose(File);
return -1;
}
@@ -154,7 +150,7 @@
Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
if (Cache == NULL)
{
- DPRINT("MALLOC() failed\n");
+ DPRINT1("MALLOC() failed\n");
FREE(FileBuffer);
return -1;
}
@@ -197,7 +193,7 @@
while (Cache->FirstSection != NULL)
{
- Cache->FirstSection = InfpCacheFreeSection(Cache->FirstSection);
+ Cache->FirstSection = InfpFreeSection(Cache->FirstSection);
}
Cache->LastSection = NULL;
_____
Modified: trunk/reactos/lib/inflib/infhostget.c
--- trunk/reactos/lib/inflib/infhostget.c 2005-11-25 21:29:16 UTC
(rev 19571)
+++ trunk/reactos/lib/inflib/infhostget.c 2005-11-25 21:37:23 UTC
(rev 19572)
@@ -1,16 +1,13 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: .inf file parser
- * FILE: lib/inflib/infrosget.c
- * PURPOSE: Read .inf routines for use on the host build system
- * PROGRAMMER: Royce Mitchell III
- * Eric Kohl
- * Ge van Geldorp
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PROGRAMMER: Royce Mitchell III
+ * Eric Kohl
+ * Ge van Geldorp <gvg(a)reactos.org>
*/
/* INCLUDES
*****************************************************************/
-#include <errno.h>
#include "inflib.h"
#include "infhost.h"
_____
Added: trunk/reactos/lib/inflib/infhostglue.c
--- trunk/reactos/lib/inflib/infhostglue.c 2005-11-25 21:29:16 UTC
(rev 19571)
+++ trunk/reactos/lib/inflib/infhostglue.c 2005-11-25 21:37:23 UTC
(rev 19572)
@@ -0,0 +1,24 @@
+/*
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg(a)reactos.org>
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include "inflib.h"
+
+#define NDEBUG
+#include <debug.h>
+
+void
+DbgPrint(const char *Fmt, ...)
+{
+ va_list Args;
+
+ va_start(Args, Fmt);
+ vfprintf(stderr, Fmt, Args);
+ va_end(Args);
+}
+
+/* EOF */
Property changes on: trunk/reactos/lib/inflib/infhostglue.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
_____
Added: trunk/reactos/lib/inflib/infhostput.c
--- trunk/reactos/lib/inflib/infhostput.c 2005-11-25 21:29:16 UTC
(rev 19571)
+++ trunk/reactos/lib/inflib/infhostput.c 2005-11-25 21:37:23 UTC
(rev 19572)
@@ -0,0 +1,114 @@
+/*
+ * PROJECT: .inf file parser
+ * LICENSE: GPL - See COPYING in the top level directory
+ * COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg(a)reactos.org>
+ */
+
+/* INCLUDES
*****************************************************************/
+
+#include "inflib.h"
+#include "infhost.h"
+
+#define NDEBUG
+#include <debug.h>
+
+int
+InfHostWriteFile(HINF InfHandle, const char *FileName,
+ const char *HeaderComment)
+{
+ char *Buffer;
+ unsigned long 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, 1, 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 char *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 char *Key)
+{
+ INFSTATUS Status;
+
+ Status = InfpAddLineWithKey(Context, Key);
+ if (INF_SUCCESS(Status))
+ {
+ return 0;
+ }
+ else
+ {
+ errno = Status;
+ return -1;
+ }
+}
+
+int
[truncated at 1000 lines; 732 more skipped]