Abandoning silverblade-audio branch.
[reactos.git] / reactos / lib / inflib / infhostgen.c
index 60c8d5d..ee1b52a 100644 (file)
@@ -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@reactos.org>
  */
 
 /* INCLUDES *****************************************************************/
 
-#include <stdio.h>
-#include <errno.h>
 #include "inflib.h"
 #include "infhost.h"
 
 int
 InfHostOpenBufferedFile(PHINF InfHandle,
                         void *Buffer,
-                        unsigned long BufferSize,
-                        unsigned long *ErrorLine)
+                        ULONG BufferSize,
+                        ULONG *ErrorLine)
 {
   INFSTATUS Status;
   PINFCACHE Cache;
-  char *FileBuffer;
+  CHAR *FileBuffer;
 
   *InfHandle = NULL;
-  *ErrorLine = (unsigned long)-1;
+  *ErrorLine = (ULONG)-1;
 
   /* Allocate file buffer */
   FileBuffer = MALLOC(BufferSize + 1);
@@ -50,7 +46,7 @@ InfHostOpenBufferedFile(PHINF InfHandle,
   Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
   if (Cache == NULL)
     {
-      DPRINT("MALLOC() failed\n");
+      DPRINT1("MALLOC() failed\n");
       FREE(FileBuffer);
       return(INF_STATUS_INSUFFICIENT_RESOURCES);
     }
@@ -81,49 +77,49 @@ InfHostOpenBufferedFile(PHINF InfHandle,
 
 int
 InfHostOpenFile(PHINF InfHandle,
-                char *FileName,
-                unsigned long *ErrorLine)
+                const CHAR *FileName,
+                ULONG *ErrorLine)
 {
   FILE *File;
-  char *FileBuffer;
-  unsigned long FileLength;
+  CHAR *FileBuffer;
+  ULONG FileLength;
   PINFCACHE Cache;
   INFSTATUS Status;
 
   *InfHandle = NULL;
-  *ErrorLine = (unsigned long)-1;
+  *ErrorLine = (ULONG)-1;
 
   /* Open the inf file */
   File = fopen(FileName, "rb");
   if (NULL == File)
     {
-      DPRINT("fopen() failed (errno %d)\n", errno);
+      DPRINT1("fopen() failed (errno %d)\n", errno);
       return -1;
     }
 
   DPRINT("fopen() successful\n");
 
   /* Query file size */
-  if (fseek(File, 0, SEEK_END))
+  if (fseek(File, (size_t)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;
     }
 
   FileLength = ftell(File);
-  if ((unsigned long) -1 == FileLength)
+  if ((ULONG) -1 == FileLength)
     {
-      DPRINT("ftell() failed (errno %d)\n", errno);
+      DPRINT1("ftell() failed (errno %d)\n", errno);
       fclose(File);
       return -1;
     }
-  DPRINT("File size: %lu\n", FileLength);
+  DPRINT("File size: %u\n", (UINT)FileLength);
 
   /* Rewind */
-  if (fseek(File, 0, SEEK_SET))
+  if (fseek(File, (size_t)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;
     }
@@ -138,9 +134,9 @@ InfHostOpenFile(PHINF InfHandle,
     }
 
   /* Read file */
-  if (FileLength != fread(FileBuffer, 1, FileLength, File))
+  if (FileLength != fread(FileBuffer, (size_t)1, (size_t)FileLength, File))
     {
-      DPRINT("fread() failed (errno %d)\n", errno);
+      DPRINT1("fread() failed (errno %d)\n", errno);
       fclose(File);
       return -1;
     }
@@ -154,7 +150,7 @@ InfHostOpenFile(PHINF InfHandle,
   Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
   if (Cache == NULL)
     {
-      DPRINT("MALLOC() failed\n");
+      DPRINT1("MALLOC() failed\n");
       FREE(FileBuffer);
       return -1;
     }
@@ -197,7 +193,7 @@ InfHostCloseFile(HINF InfHandle)
 
   while (Cache->FirstSection != NULL)
     {
-      Cache->FirstSection = InfpCacheFreeSection(Cache->FirstSection);
+      Cache->FirstSection = InfpFreeSection(Cache->FirstSection);
     }
   Cache->LastSection = NULL;