d3dxof: Support multi-dimentional array in templates.
[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 1
38 #define MAX_MEMBERS 50
39 #define MAX_CHILDS 20
40 #define MAX_TEMPLATES 200
41 #define MAX_OBJECTS 500
42 #define MAX_SUBOBJECTS 120
43 #define MAX_STRINGS_BUFFER 200
44
45 typedef struct {
46     DWORD type;
47     LONG idx_template;
48     char name[MAX_NAME_LEN];
49     ULONG nb_dims;
50     BOOL  dim_fixed[MAX_ARRAY_DIM]; /* fixed or variable */
51     ULONG dim_value[MAX_ARRAY_DIM]; /* fixed value or member index */
52 } member;
53
54 typedef struct {
55     char name[MAX_NAME_LEN];
56     GUID class_id;
57     BOOL open;
58     ULONG nb_childs;
59     char childs[MAX_CHILDS][MAX_NAME_LEN];
60     ULONG nb_members;
61     member members[MAX_MEMBERS];
62 } xtemplate;
63
64 typedef struct {
65     char name[MAX_NAME_LEN];
66     LPBYTE start;
67     ULONG size;
68 } xobject_member;
69
70 struct _xobject {
71    struct _xobject* ptarget;
72    char name[MAX_NAME_LEN];
73    GUID class_id;
74    GUID type;
75    LPBYTE pdata;
76    DWORD size;
77    ULONG nb_members;
78    xobject_member members[MAX_MEMBERS];
79    ULONG nb_childs;
80    ULONG nb_subobjects;
81    struct _xobject * childs[MAX_CHILDS];
82 };
83
84 typedef struct _xobject xobject;
85
86 typedef struct {
87     IDirectXFile lpVtbl;
88     LONG ref;
89     ULONG nb_xtemplates;
90     xtemplate xtemplates[MAX_TEMPLATES];
91 } IDirectXFileImpl;
92
93 typedef struct {
94     IDirectXFileBinary lpVtbl;
95     LONG ref;
96 } IDirectXFileBinaryImpl;
97
98 typedef struct {
99     IDirectXFileData lpVtbl;
100     LONG ref;
101     xobject* pobj;
102     int cur_enum_object;
103     BOOL from_ref;
104     ULONG level;
105     LPBYTE pstrings;
106 } IDirectXFileDataImpl;
107
108 typedef struct {
109     IDirectXFileDataReference lpVtbl;
110     LONG ref;
111     xobject* ptarget;
112 } IDirectXFileDataReferenceImpl;
113
114 typedef struct {
115     IDirectXFileObject lpVtbl;
116     LONG ref;
117 } IDirectXFileObjectImpl;
118
119 typedef struct {
120   /* Buffer to parse */
121   LPBYTE buffer;
122   DWORD rem_bytes;
123   /* Misc info */
124   WORD current_token;
125   BOOL token_present;
126   BOOL txt;
127   ULONG cur_subobject;
128   LPBYTE cur_pdata;
129   LPBYTE cur_pstrings;
130   BYTE value[100];
131   xobject* pxo_globals;
132   ULONG nb_pxo_globals;
133   xobject* pxo_tab;
134   IDirectXFileImpl* pdxf;
135   xobject* pxo;
136   xtemplate* pxt[MAX_SUBOBJECTS];
137   ULONG level;
138   LPBYTE pdata;
139   LPBYTE pstrings;
140 } parse_buffer;
141
142 typedef struct {
143     IDirectXFileEnumObject lpVtbl;
144     LONG ref;
145     DXFILELOADOPTIONS source;
146     HANDLE hFile;
147     parse_buffer buf;
148     IDirectXFileImpl* pDirectXFile;
149     ULONG nb_xobjects;
150     xobject xobjects[MAX_OBJECTS][MAX_SUBOBJECTS];
151 } IDirectXFileEnumObjectImpl;
152
153 typedef struct {
154     IDirectXFileSaveObject lpVtbl;
155     LONG ref;
156 } IDirectXFileSaveObjectImpl;
157
158 HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj);
159 HRESULT IDirectXFileBinaryImpl_Create(IDirectXFileBinaryImpl** ppObj);
160 HRESULT IDirectXFileDataImpl_Create(IDirectXFileDataImpl** ppObj);
161 HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl** ppObj);
162 HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj);
163 HRESULT IDirectXFileFileObjectImpl_Create(IDirectXFileObjectImpl** ppObj);
164 HRESULT IDirectXFileFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
165
166 #endif /* __D3DXOF_PRIVATE_INCLUDED__ */