[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    [PATCH] Initial FCI work for cabinet.dll [cabinet-fci-patch-01.diff]
From:       "Gerold J. Wucherpfennig" <gjwucherpfennig () gmx ! net>
Date:       2005-05-12 18:35:25
Message-ID: 200505122035.26050.gjwucherpfennig () gmx ! net
[Download RAW message or body]

["cabinet-fci-patch-01.diff" (text/x-diff)]

Index: ChangeLog
===================================================================
RCS file: /home/wine/wine/ChangeLog,v
retrieving revision 1.93
diff -u -3 -p -u -p -r1.93 ChangeLog
--- ChangeLog	19 Apr 2005 12:54:44 -0000	1.93
+++ ChangeLog	12 May 2005 18:31:59 -0000
@@ -1,3 +1,9 @@
+
+	* dlls/cabinet/fci.c, dlls/cabinet/cabinet.h,
+	  include/fci.h:
+	Gerold Jens Wucherpfennig <gjwucherpfennig@gmx.net>
+	Initial FCI work (FCICreate and FCIDestroy)
+
 ----------------------------------------------------------------
 2005-04-19  Alexandre Julliard  <julliard@winehq.com>
 
Index: dlls/cabinet/cabinet.h
===================================================================
RCS file: /home/wine/wine/dlls/cabinet/cabinet.h,v
retrieving revision 1.11
diff -u -3 -p -u -p -r1.11 cabinet.h
--- dlls/cabinet/cabinet.h	8 Jan 2004 00:42:36 -0000	1.11
+++ dlls/cabinet/cabinet.h	12 May 2005 18:32:01 -0000
@@ -2,6 +2,7 @@
  * cabinet.h
  *
  * Copyright 2002 Greg Turner
+ * Copyright 2005 Gerold Jens Wucherpfennig
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -292,6 +293,19 @@ typedef struct cds_forward {
 
 typedef struct {
   unsigned int     FCI_Intmagic;
+  PERF perf;
+  PFNFCIFILEPLACED   pfnfiledest;
+  PFNFCIALLOC        pfnalloc;
+  PFNFCIFREE         pfnfree;
+  PFNFCIOPEN         pfnopen;
+  PFNFCIREAD         pfnread;
+  PFNFCIWRITE        pfnwrite;
+  PFNFCICLOSE        pfnclose;
+  PFNFCISEEK         pfnseek;
+  PFNFCIDELETE       pfndelete;
+  PFNFCIGETTEMPFILE  pfnfcigtf;
+  PCCAB              pccab;
+  void *pv;
 } FCI_Int, *PFCI_Int;
 
 typedef struct {
@@ -307,7 +321,7 @@ typedef struct {
 } FDI_Int, *PFDI_Int;
 
 /* cast an HFCI into a PFCI_Int */
-#define PFCI_INT(hfci) ((PFDI_Int)(hfci))
+#define PFCI_INT(hfci) ((PFCI_Int)(hfci))
 
 /* cast an HFDI into a PFDI_Int */
 #define PFDI_INT(hfdi) ((PFDI_Int)(hfdi))
Index: dlls/cabinet/fci.c
===================================================================
RCS file: /home/wine/wine/dlls/cabinet/fci.c,v
retrieving revision 1.3
diff -u -3 -p -u -p -r1.3 fci.c
--- dlls/cabinet/fci.c	5 Sep 2003 23:08:44 -0000	1.3
+++ dlls/cabinet/fci.c	12 May 2005 18:32:02 -0000
@@ -2,6 +2,7 @@
  * File Compression Interface
  *
  * Copyright 2002 Patrik Stridvall
+ * Copyright 2005 Gerold Jens Wucherpfennig
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +27,7 @@
 #include "winbase.h"
 #include "winerror.h"
 #include "fci.h"
+#include "cabinet.h"
 
 #include "wine/debug.h"
 
@@ -33,12 +35,55 @@ WINE_DEFAULT_DEBUG_CHANNEL(cabinet);
 
 /***********************************************************************
  *		FCICreate (CABINET.10)
+ *
+ * Provided with several callbacks,
+ * returns a handle which can be used to perform operations
+ * on cabinet files.
+ *
+ * PARAMS
+ *   perf       [IO]  A pointer to an ERF structure.  When FCICreate
+ *                    returns an error condition, error information may
+ *                    be found here as well as from GetLastError.
+ *   pfnfiledest [I]  A pointer to a function which is called when a file
+ *                    is placed. Only useful for subsequent cabinet files.
+ *   pfnalloc    [I]  A pointer to a function which allocates ram.  Uses
+ *                    the same interface as malloc.
+ *   pfnfree     [I]  A pointer to a function which frees ram.  Uses the
+ *                    same interface as free.
+ *   pfnopen     [I]  A pointer to a function which opens a file.  Uses
+ *                    the same interface as _open.
+ *   pfnread     [I]  A pointer to a function which reads from a file into
+ *                    a caller-provided buffer.  Uses the same interface
+ *                    as _read
+ *   pfnwrite    [I]  A pointer to a function which writes to a file from
+ *                    a caller-provided buffer.  Uses the same interface
+ *                    as _write.
+ *   pfnclose    [I]  A pointer to a function which closes a file handle.
+ *                    Uses the same interface as _close.
+ *   pfnseek     [I]  A pointer to a function which seeks in a file.
+ *                    Uses the same interface as _lseek.
+ *   pfndelete   [I]  A pointer to a function which deletes a file.
+ *   pfnfcigtf   [I]  A pointer to a function which gets the name of a
+ *                    temporary file; ignored in wine
+ *   pccab       [I]  A pointer to an initialized CCAB structure
+ *   pv          [I]  A pointer to an application-defined notification
+ *                    function which will be passed to other FCI functions
+ *                    as a parameter.
+ *
+ * RETURNS
+ *   On success, returns an FCI handle of type HFCI.
+ *   On failure, the NULL file handle is returned. Error
+ *   info can be retrieved from perf.
+ *
+ * INCLUDES
+ *   fci.h
+ *
  */
 HFCI __cdecl FCICreate(
 	PERF perf,
-	PFNFCIFILEPLACED   pfnfcifp,
-	PFNFCIALLOC        pfna,
-	PFNFCIFREE         pfnf,
+	PFNFCIFILEPLACED   pfnfiledest,
+	PFNFCIALLOC        pfnalloc,
+	PFNFCIFREE         pfnfree,
 	PFNFCIOPEN         pfnopen,
 	PFNFCIREAD         pfnread,
 	PFNFCIWRITE        pfnwrite,
@@ -49,17 +94,57 @@ HFCI __cdecl FCICreate(
 	PCCAB              pccab,
 	void *pv)
 {
-    FIXME("(%p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
-	  perf, pfnfcifp, pfna, pfnf, pfnopen, pfnread, pfnwrite, pfnclose,
-	  pfnseek, pfndelete, pfnfcigtf, pccab, pv);
+  HFCI rv;
 
-    perf->erfOper = FCIERR_NONE;
-    perf->erfType = 0;
+  if ((!pfnalloc) || (!pfnfree)) {
+    perf->erfOper = FCIERROR_NONE;
+    perf->erfType = ERROR_BAD_ARGUMENTS;
     perf->fError = TRUE;
 
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    SetLastError(ERROR_BAD_ARGUMENTS);
+    return NULL;
+  }
 
+  if (!((rv = ((HFCI) (*pfnalloc)(sizeof(FCI_Int)))))) {
+    perf->erfOper = FCIERROR_ALLOC_FAIL;
+    perf->erfType = ERROR_NOT_ENOUGH_MEMORY;
+    perf->fError = TRUE;
+
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
     return NULL;
+  }
+
+  PFCI_INT(rv)->FCI_Intmagic = FCI_INT_MAGIC;
+  PFCI_INT(rv)->perf = perf;
+  PFCI_INT(rv)->pfnfiledest = pfnfiledest;
+  PFCI_INT(rv)->pfnalloc = pfnalloc;
+  PFCI_INT(rv)->pfnfree = pfnfree;
+  PFCI_INT(rv)->pfnopen = pfnopen;
+  PFCI_INT(rv)->pfnread = pfnread;
+  PFCI_INT(rv)->pfnwrite = pfnwrite;
+  PFCI_INT(rv)->pfnclose = pfnclose;
+  PFCI_INT(rv)->pfnseek = pfnseek;
+  PFCI_INT(rv)->pfndelete = pfndelete;
+  PFCI_INT(rv)->pfnfcigtf = pfnfcigtf;
+  PFCI_INT(rv)->pccab = pccab;
+  PFCI_INT(rv)->pv = pv;
+
+  /* Still mark as incomplete, because of other missing FCI* APIs */
+
+  PFCI_INT(rv)->FCI_Intmagic = 0;
+  PFDI_FREE(rv, rv);
+  FIXME("(%p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
+    perf, pfnfiledest, pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose,
+    pfnseek, pfndelete, pfnfcigtf, pccab, pv);
+
+  perf->erfOper = FCIERROR_NONE;
+  perf->erfType = 0;
+  perf->fError = TRUE;
+
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+
+  return NULL;
+
 }
 
 /***********************************************************************
@@ -116,12 +201,30 @@ BOOL __cdecl FCIFlushFolder(
 
 /***********************************************************************
  *		FCIDestroy (CABINET.14)
+ *
+ * Frees a handle created by FCICreate.
+ * Only reason for failure would be an invalid handle.
+ *
+ * PARAMS
+ *   hfci [I] The HFCI to free
+ *
+ * RETURNS
+ *   TRUE for success
+ *   FALSE for failure
  */
 BOOL __cdecl FCIDestroy(HFCI hfci)
 {
-    FIXME("(%p): stub\n", hfci);
-
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
+  if (REALLY_IS_FCI(hfci)) {
+    PFCI_INT(hfci)->FCI_Intmagic = 0;
+    PFDI_FREE(hfci, hfci);
+    //return TRUE;
+  } else {
+    SetLastError(ERROR_INVALID_HANDLE);
     return FALSE;
+  }
+
+  /* Still mark as incomplete, because of other missing FCI* APIs */
+  FIXME("(%p): stub\n", hfci);
+  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+  return FALSE;
 }
Index: include/fci.h
===================================================================
RCS file: /home/wine/wine/include/fci.h,v
retrieving revision 1.3
diff -u -3 -p -u -p -r1.3 fci.h
--- include/fci.h	28 Aug 2003 21:43:35 -0000	1.3
+++ include/fci.h	12 May 2005 18:32:17 -0000
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002 Patrik Stridvall
+ * Copyright (C) 2005 Gerold Jens Wucherpfennig
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -112,15 +113,15 @@ typedef unsigned short TCOMP;
  */
 
 typedef enum {
-    FCIERR_NONE,
-    FCIERR_OPEN_SRC,
-    FCIERR_READ_SRC,
-    FCIERR_ALLOC_FAIL,
-    FCIERR_TEMP_FILE,
-    FCIERR_BAD_COMPR_TYPE,
-    FCIERR_CAB_FILE,
-    FCIERR_USER_ABORT,
-    FCIERR_MCI_FAIL,
+    FCIERROR_NONE,
+    FCIERROR_OPEN_SRC,
+    FCIERROR_READ_SRC,
+    FCIERROR_ALLOC_FAIL,
+    FCIERROR_TEMP_FILE,
+    FCIERROR_BAD_COMPR_TYPE,
+    FCIERROR_CAB_FILE,
+    FCIERROR_USER_ABORT,
+    FCIERROR_MCI_FAIL,
 } FCIERROR;
 
 /**********************************************************************/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic