d3dxof_private.h 4.5 KB
Newer Older
1 2 3
/*
 *      DirectX File private interfaces (D3DXOF.DLL)
 *
4
 * Copyright 2004, 2008 Christian Costa
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This file contains the (internal) driver registration functions,
 * driver enumeration APIs and DirectDraw creation functions.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 25 26 27 28 29 30 31 32 33 34 35
 */

#ifndef __D3DXOF_PRIVATE_INCLUDED__
#define __D3DXOF_PRIVATE_INCLUDED__

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "wingdi.h"
#include "winuser.h"
#include "dxfile.h"

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 2000
43
#define MAX_STRINGS_BUFFER 10000
44 45 46 47 48 49 50 51 52 53 54 55 56 57

typedef struct {
    DWORD type;
    LONG idx_template;
    char name[MAX_NAME_LEN];
    ULONG nb_dims;
    BOOL  dim_fixed[MAX_ARRAY_DIM]; /* fixed or variable */
    ULONG dim_value[MAX_ARRAY_DIM]; /* fixed value or member index */
} member;

typedef struct {
    char name[MAX_NAME_LEN];
    GUID class_id;
    BOOL open;
58
    BOOL binary;
59 60 61 62 63 64
    ULONG nb_childs;
    char childs[MAX_CHILDS][MAX_NAME_LEN];
    ULONG nb_members;
    member members[MAX_MEMBERS];
} xtemplate;

65
typedef struct {
66
    char* name;
67
    ULONG start;
68 69 70 71
    ULONG size;
} xobject_member;

struct _xobject {
72
   BOOL binary;
73
   struct _xobject* ptarget;
74 75 76 77
   char name[MAX_NAME_LEN];
   GUID class_id;
   GUID type;
   LPBYTE pdata;
78
   ULONG pos_data;
79 80 81 82
   DWORD size;
   ULONG nb_members;
   xobject_member members[MAX_MEMBERS];
   ULONG nb_childs;
83
   ULONG nb_subobjects;
84
   struct _xobject * childs[MAX_CHILDS];
85
   struct _xobject * root;
86 87 88 89
};

typedef struct _xobject xobject;

90
typedef struct {
91
    const IDirectXFileVtbl *lpVtbl;
92
    LONG ref;
93 94
    ULONG nb_xtemplates;
    xtemplate xtemplates[MAX_TEMPLATES];
95 96 97
} IDirectXFileImpl;

typedef struct {
98
    const IDirectXFileBinaryVtbl *lpVtbl;
99
    LONG ref;
100 101 102
} IDirectXFileBinaryImpl;

typedef struct {
103
    const IDirectXFileDataVtbl *lpVtbl;
104
    LONG ref;
105 106
    xobject* pobj;
    int cur_enum_object;
107 108
    BOOL from_ref;
    ULONG level;
109
    LPBYTE pstrings;
110 111 112
} IDirectXFileDataImpl;

typedef struct {
113
    const IDirectXFileDataReferenceVtbl *lpVtbl;
114
    LONG ref;
115
    xobject* ptarget;
116 117 118
} IDirectXFileDataReferenceImpl;

typedef struct {
119
    const IDirectXFileObjectVtbl *lpVtbl;
120
    LONG ref;
121 122
} IDirectXFileObjectImpl;

123 124 125 126 127
typedef struct {
  /* Buffer to parse */
  LPBYTE buffer;
  DWORD rem_bytes;
  /* Misc info */
128 129
  WORD current_token;
  BOOL token_present;
130
  BOOL txt;
131
  ULONG cur_pos_data;
132
  LPBYTE cur_pstrings;
133
  BYTE value[100];
134
  xobject** pxo_globals;
135
  ULONG nb_pxo_globals;
136
  xobject* pxo_tab;
137 138 139 140
  IDirectXFileImpl* pdxf;
  xobject* pxo;
  xtemplate* pxt[MAX_SUBOBJECTS];
  ULONG level;
141
  LPBYTE pdata;
142
  ULONG capacity;
143
  LPBYTE pstrings;
144 145
} parse_buffer;

146
typedef struct {
147
    const IDirectXFileEnumObjectVtbl *lpVtbl;
148
    LONG ref;
149 150
    DXFILELOADOPTIONS source;
    HANDLE hFile;
151 152
    HANDLE file_mapping;
    LPBYTE buffer;
153
    HGLOBAL resource_data;
154
    LPBYTE decomp_buffer;
155 156 157
    parse_buffer buf;
    IDirectXFileImpl* pDirectXFile;
    ULONG nb_xobjects;
158
    xobject* xobjects[MAX_OBJECTS];
159
    IDirectXFileData* pRefObjects[MAX_OBJECTS];
160 161 162
} IDirectXFileEnumObjectImpl;

typedef struct {
163
    const IDirectXFileSaveObjectVtbl *lpVtbl;
164
    LONG ref;
165 166
} IDirectXFileSaveObjectImpl;

167 168 169 170
HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj);
HRESULT IDirectXFileFileObjectImpl_Create(IDirectXFileObjectImpl** ppObj);
HRESULT IDirectXFileFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);

171 172 173 174 175 176
BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size);
BOOL parse_template(parse_buffer * buf);
void dump_template(xtemplate* templates_array, xtemplate* ptemplate);
BOOL is_template_available(parse_buffer * buf);
BOOL parse_object(parse_buffer * buf);

177 178
int mszip_decompress(int inlen, int outlen, char* inbuffer, char* outbuffer);

179
#endif /* __D3DXOF_PRIVATE_INCLUDED__ */