Implement NtAccessCheck.
[wine/gsoc-2012-control.git] / dlls / cabinet / fci.c
blob9a97d56e331c14cde2019d3a33b6f41374c27bcc
1 /*
2 * File Compression Interface
4 * Copyright 2002 Patrik Stridvall
5 * Copyright 2005 Gerold Jens Wucherpfennig
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29 #include "fci.h"
30 #include "cabinet.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(cabinet);
36 /***********************************************************************
37 * FCICreate (CABINET.10)
39 * Provided with several callbacks,
40 * returns a handle which can be used to perform operations
41 * on cabinet files.
43 * PARAMS
44 * perf [IO] A pointer to an ERF structure. When FCICreate
45 * returns an error condition, error information may
46 * be found here as well as from GetLastError.
47 * pfnfiledest [I] A pointer to a function which is called when a file
48 * is placed. Only useful for subsequent cabinet files.
49 * pfnalloc [I] A pointer to a function which allocates ram. Uses
50 * the same interface as malloc.
51 * pfnfree [I] A pointer to a function which frees ram. Uses the
52 * same interface as free.
53 * pfnopen [I] A pointer to a function which opens a file. Uses
54 * the same interface as _open.
55 * pfnread [I] A pointer to a function which reads from a file into
56 * a caller-provided buffer. Uses the same interface
57 * as _read
58 * pfnwrite [I] A pointer to a function which writes to a file from
59 * a caller-provided buffer. Uses the same interface
60 * as _write.
61 * pfnclose [I] A pointer to a function which closes a file handle.
62 * Uses the same interface as _close.
63 * pfnseek [I] A pointer to a function which seeks in a file.
64 * Uses the same interface as _lseek.
65 * pfndelete [I] A pointer to a function which deletes a file.
66 * pfnfcigtf [I] A pointer to a function which gets the name of a
67 * temporary file; ignored in wine
68 * pccab [I] A pointer to an initialized CCAB structure
69 * pv [I] A pointer to an application-defined notification
70 * function which will be passed to other FCI functions
71 * as a parameter.
73 * RETURNS
74 * On success, returns an FCI handle of type HFCI.
75 * On failure, the NULL file handle is returned. Error
76 * info can be retrieved from perf.
78 * INCLUDES
79 * fci.h
82 HFCI __cdecl FCICreate(
83 PERF perf,
84 PFNFCIFILEPLACED pfnfiledest,
85 PFNFCIALLOC pfnalloc,
86 PFNFCIFREE pfnfree,
87 PFNFCIOPEN pfnopen,
88 PFNFCIREAD pfnread,
89 PFNFCIWRITE pfnwrite,
90 PFNFCICLOSE pfnclose,
91 PFNFCISEEK pfnseek,
92 PFNFCIDELETE pfndelete,
93 PFNFCIGETTEMPFILE pfnfcigtf,
94 PCCAB pccab,
95 void *pv)
97 HFCI rv;
99 if ((!pfnalloc) || (!pfnfree)) {
100 perf->erfOper = FCIERR_NONE;
101 perf->erfType = ERROR_BAD_ARGUMENTS;
102 perf->fError = TRUE;
104 SetLastError(ERROR_BAD_ARGUMENTS);
105 return NULL;
108 if (!(rv = (HFCI) (*pfnalloc)(sizeof(FCI_Int)))) {
109 perf->erfOper = FCIERR_ALLOC_FAIL;
110 perf->erfType = ERROR_NOT_ENOUGH_MEMORY;
111 perf->fError = TRUE;
113 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
114 return NULL;
117 PFCI_INT(rv)->FCI_Intmagic = FCI_INT_MAGIC;
118 PFCI_INT(rv)->perf = perf;
119 PFCI_INT(rv)->pfnfiledest = pfnfiledest;
120 PFCI_INT(rv)->pfnalloc = pfnalloc;
121 PFCI_INT(rv)->pfnfree = pfnfree;
122 PFCI_INT(rv)->pfnopen = pfnopen;
123 PFCI_INT(rv)->pfnread = pfnread;
124 PFCI_INT(rv)->pfnwrite = pfnwrite;
125 PFCI_INT(rv)->pfnclose = pfnclose;
126 PFCI_INT(rv)->pfnseek = pfnseek;
127 PFCI_INT(rv)->pfndelete = pfndelete;
128 PFCI_INT(rv)->pfnfcigtf = pfnfcigtf;
129 PFCI_INT(rv)->pccab = pccab;
130 PFCI_INT(rv)->pv = pv;
132 /* Still mark as incomplete, because of other missing FCI* APIs */
134 PFCI_INT(rv)->FCI_Intmagic = 0;
135 PFDI_FREE(rv, rv);
136 FIXME("(%p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
137 perf, pfnfiledest, pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose,
138 pfnseek, pfndelete, pfnfcigtf, pccab, pv);
140 perf->erfOper = FCIERR_NONE;
141 perf->erfType = 0;
142 perf->fError = TRUE;
144 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
146 return NULL;
150 /***********************************************************************
151 * FCIAddFile (CABINET.11)
153 BOOL __cdecl FCIAddFile(
154 HFCI hfci,
155 char *pszSourceFile,
156 char *pszFileName,
157 BOOL fExecute,
158 PFNFCIGETNEXTCABINET pfnfcignc,
159 PFNFCISTATUS pfnfcis,
160 PFNFCIGETOPENINFO pfnfcigoi,
161 TCOMP typeCompress)
163 FIXME("(%p, %p, %p, %d, %p, %p, %p, %hu): stub\n", hfci, pszSourceFile,
164 pszFileName, fExecute, pfnfcignc, pfnfcis, pfnfcigoi, typeCompress);
166 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
168 return FALSE;
171 /***********************************************************************
172 * FCIFlushCabinet (CABINET.13)
174 BOOL __cdecl FCIFlushCabinet(
175 HFCI hfci,
176 BOOL fGetNextCab,
177 PFNFCIGETNEXTCABINET pfnfcignc,
178 PFNFCISTATUS pfnfcis)
180 FIXME("(%p, %d, %p, %p): stub\n", hfci, fGetNextCab, pfnfcignc, pfnfcis);
182 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
184 return FALSE;
187 /***********************************************************************
188 * FCIFlushFolder (CABINET.12)
190 BOOL __cdecl FCIFlushFolder(
191 HFCI hfci,
192 PFNFCIGETNEXTCABINET pfnfcignc,
193 PFNFCISTATUS pfnfcis)
195 FIXME("(%p, %p, %p): stub\n", hfci, pfnfcignc, pfnfcis);
197 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
199 return FALSE;
202 /***********************************************************************
203 * FCIDestroy (CABINET.14)
205 * Frees a handle created by FCICreate.
206 * Only reason for failure would be an invalid handle.
208 * PARAMS
209 * hfci [I] The HFCI to free
211 * RETURNS
212 * TRUE for success
213 * FALSE for failure
215 BOOL __cdecl FCIDestroy(HFCI hfci)
217 if (REALLY_IS_FCI(hfci)) {
218 PFCI_INT(hfci)->FCI_Intmagic = 0;
219 PFDI_FREE(hfci, hfci);
220 /*return TRUE; */
221 } else {
222 SetLastError(ERROR_INVALID_HANDLE);
223 return FALSE;
226 /* Still mark as incomplete, because of other missing FCI* APIs */
227 FIXME("(%p): stub\n", hfci);
228 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
229 return FALSE;