crypt32/tests: Fix some test failures on Win9x.
[wine] / dlls / d3dxof / d3dxof_private.h
1 /*
2  *      DirectX File private interfaces (D3DXOF.DLL)
3  *
4  * Copyright 2004, 2008 Christian Costa
5  *
6  * This file contains the (internal) driver registration functions,
7  * driver enumeration APIs and DirectDraw creation functions.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #ifndef __D3DXOF_PRIVATE_INCLUDED__
25 #define __D3DXOF_PRIVATE_INCLUDED__
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wtypes.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "dxfile.h"
35
36 #define MAX_NAME_LEN 32
37 #define MAX_ARRAY_DIM 4
38 #define MAX_MEMBERS 50
39 #define MAX_CHILDS 100
40 #define MAX_TEMPLATES 200
41 #define MAX_OBJECTS 500
42 #define MAX_SUBOBJECTS 500
43 #define MAX_STRINGS_BUFFER 10000
44
45 #define MAX_DATA_SIZE 400000
46
47 typedef struct {
48     DWORD type;
49     LONG idx_template;
50     char name[MAX_NAME_LEN];
51     ULONG nb_dims;
52     BOOL  dim_fixed[MAX_ARRAY_DIM]; /* fixed or variable */
53     ULONG dim_value[MAX_ARRAY_DIM]; /* fixed value or member index */
54 } member;
55
56 typedef struct {
57     char name[MAX_NAME_LEN];
58     GUID class_id;
59     BOOL open;
60     BOOL binary;
61     ULONG nb_childs;
62     char childs[MAX_CHILDS][MAX_NAME_LEN];
63     ULONG nb_members;
64     member members[MAX_MEMBERS];
65 } xtemplate;
66
67 typedef struct {
68     char* name;
69     ULONG start;
70     ULONG size;
71 } xobject_member;
72
73 struct _xobject {
74    BOOL binary;
75    struct _xobject* ptarget;
76    char name[MAX_NAME_LEN];
77    GUID class_id;
78    GUID type;
79    LPBYTE pdata;
80    ULONG pos_data;
81    DWORD size;
82    ULONG nb_members;
83    xobject_member members[MAX_MEMBERS];
84    ULONG nb_childs;
85    ULONG nb_subobjects;
86    struct _xobject * childs[MAX_CHILDS];
87    struct _xobject * root;
88 };
89
90 typedef struct _xobject xobject;
91
92 typedef struct {
93     IDirectXFile lpVtbl;
94     LONG ref;
95     ULONG nb_xtemplates;
96     xtemplate xtemplates[MAX_TEMPLATES];
97 } IDirectXFileImpl;
98
99 typedef struct {
100     IDirectXFileBinary lpVtbl;
101     LONG ref;
102 } IDirectXFileBinaryImpl;
103
104 typedef struct {
105     IDirectXFileData lpVtbl;
106     LONG ref;
107     xobject* pobj;
108     int cur_enum_object;
109     BOOL from_ref;
110     ULONG level;
111     LPBYTE pdata;
112     LPBYTE pstrings;
113 } IDirectXFileDataImpl;
114
115 typedef struct {
116     IDirectXFileDataReference lpVtbl;
117     LONG ref;
118     xobject* ptarget;
119 } IDirectXFileDataReferenceImpl;
120
121 typedef struct {
122     IDirectXFileObject lpVtbl;
123     LONG ref;
124 } IDirectXFileObjectImpl;
125
126 typedef struct {
127   /* Buffer to parse */
128   LPBYTE buffer;
129   DWORD rem_bytes;
130   /* Misc info */
131   WORD current_token;
132   BOOL token_present;
133   BOOL txt;
134   ULONG cur_subobject;
135   ULONG cur_pos_data;
136   LPBYTE cur_pstrings;
137   BYTE value[100];
138   xobject** pxo_globals;
139   ULONG nb_pxo_globals;
140   xobject* pxo_tab;
141   IDirectXFileImpl* pdxf;
142   xobject* pxo;
143   xtemplate* pxt[MAX_SUBOBJECTS];
144   ULONG level;
145   LPBYTE pdata;
146   LPBYTE pstrings;
147 } parse_buffer;
148
149 typedef struct {
150     IDirectXFileEnumObject lpVtbl;
151     LONG ref;
152     DXFILELOADOPTIONS source;
153     HANDLE hFile;
154     HANDLE file_mapping;
155     LPBYTE buffer;
156     HGLOBAL resource_data;
157     parse_buffer buf;
158     IDirectXFileImpl* pDirectXFile;
159     ULONG nb_xobjects;
160     xobject* xobjects[MAX_OBJECTS];
161     IDirectXFileData* pRefObjects[MAX_OBJECTS];
162 } IDirectXFileEnumObjectImpl;
163
164 typedef struct {
165     IDirectXFileSaveObject lpVtbl;
166     LONG ref;
167 } IDirectXFileSaveObjectImpl;
168
169 HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj);
170 HRESULT IDirectXFileFileObjectImpl_Create(IDirectXFileObjectImpl** ppObj);
171 HRESULT IDirectXFileFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
172
173 BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size);
174 BOOL parse_template(parse_buffer * buf);
175 void dump_template(xtemplate* templates_array, xtemplate* ptemplate);
176 BOOL is_template_available(parse_buffer * buf);
177 BOOL parse_object(parse_buffer * buf);
178
179 #endif /* __D3DXOF_PRIVATE_INCLUDED__ */