Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
aed6a4a4
Commit
aed6a4a4
authored
Mar 01, 2010
by
Christian Costa
Committed by
Alexandre Julliard
Mar 01, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dxof: Fix file types checks + tests.
parent
074465b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
12 deletions
+109
-12
d3dxof.c
dlls/d3dxof/d3dxof.c
+27
-12
d3dxof.c
dlls/d3dxof/tests/d3dxof.c
+82
-0
No files found.
dlls/d3dxof/d3dxof.c
View file @
aed6a4a4
...
...
@@ -42,6 +42,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
#define XOFFILE_FORMAT_VERSION_303 MAKEFOUR('0','3','0','3')
#define XOFFILE_FORMAT_BINARY MAKEFOUR('b','i','n',' ')
#define XOFFILE_FORMAT_TEXT MAKEFOUR('t','x','t',' ')
#define XOFFILE_FORMAT_BINARY_MSZIP MAKEFOUR('b','z','i','p')
#define XOFFILE_FORMAT_TEXT_MSZIP MAKEFOUR('t','z','i','p')
#define XOFFILE_FORMAT_COMPRESSED MAKEFOUR('c','m','p',' ')
#define XOFFILE_FORMAT_FLOAT_BITS_32 MAKEFOUR('0','0','3','2')
#define XOFFILE_FORMAT_FLOAT_BITS_64 MAKEFOUR('0','0','6','4')
...
...
@@ -58,6 +60,15 @@ static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImp
static
HRESULT
IDirectXFileEnumObjectImpl_Create
(
IDirectXFileEnumObjectImpl
**
ppObj
);
static
HRESULT
IDirectXFileSaveObjectImpl_Create
(
IDirectXFileSaveObjectImpl
**
ppObj
);
/* FOURCC to string conversion for debug messages */
const
char
*
debugstr_fourcc
(
DWORD
fourcc
)
{
if
(
!
fourcc
)
return
"'null'"
;
return
wine_dbg_sprintf
(
"
\'
%c%c%c%c
\'
"
,
(
char
)(
fourcc
),
(
char
)(
fourcc
>>
8
),
(
char
)(
fourcc
>>
16
),
(
char
)(
fourcc
>>
24
));
}
HRESULT
IDirectXFileImpl_Create
(
IUnknown
*
pUnkOuter
,
LPVOID
*
ppObj
)
{
IDirectXFileImpl
*
object
;
...
...
@@ -247,16 +258,18 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
goto
error
;
}
if
((
header
[
2
]
!=
XOFFILE_FORMAT_BINARY
)
&&
(
header
[
2
]
!=
XOFFILE_FORMAT_TEXT
)
&&
(
header
[
2
]
!=
XOFFILE_FORMAT_COMPRESSED
))
if
((
header
[
2
]
!=
XOFFILE_FORMAT_BINARY
)
&&
(
header
[
2
]
!=
XOFFILE_FORMAT_TEXT
)
&&
(
header
[
2
]
!=
XOFFILE_FORMAT_BINARY_MSZIP
)
&&
(
header
[
2
]
!=
XOFFILE_FORMAT_TEXT_MSZIP
))
{
WARN
(
"File type %s unknown
\n
"
,
debugstr_fourcc
(
header
[
2
]));
hr
=
DXFILEERR_BADFILETYPE
;
goto
error
;
}
if
(
header
[
2
]
==
XOFFILE_FORMAT_COMPRESSED
)
if
(
(
header
[
2
]
==
XOFFILE_FORMAT_BINARY_MSZIP
)
||
(
header
[
2
]
==
XOFFILE_FORMAT_TEXT_MSZIP
)
)
{
FIXME
(
"Compressed format
s not supported yet
\n
"
);
hr
=
DXFILEERR_BAD
VALUE
;
FIXME
(
"Compressed format
%s not supported yet
\n
"
,
debugstr_fourcc
(
header
[
2
])
);
hr
=
DXFILEERR_BAD
ALLOC
;
goto
error
;
}
...
...
@@ -381,20 +394,22 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
read_bytes
(
&
buf
,
&
token_header
,
4
);
if
((
token_header
!=
XOFFILE_FORMAT_BINARY
)
&&
(
token_header
!=
XOFFILE_FORMAT_TEXT
)
&&
(
token_header
!=
XOFFILE_FORMAT_COMPRESSED
))
return
DXFILEERR_BADFILETYPE
;
if
(
token_header
==
XOFFILE_FORMAT_TEXT
)
if
((
token_header
!=
XOFFILE_FORMAT_BINARY
)
&&
(
token_header
!=
XOFFILE_FORMAT_TEXT
)
&&
(
token_header
!=
XOFFILE_FORMAT_BINARY_MSZIP
)
&&
(
token_header
!=
XOFFILE_FORMAT_TEXT_MSZIP
))
{
buf
.
txt
=
TRUE
;
WARN
(
"File type %s unknown
\n
"
,
debugstr_fourcc
(
token_header
));
return
DXFILEERR_BADFILETYPE
;
}
if
(
token_header
==
XOFFILE_FORMAT_COMPRESSED
)
if
(
(
token_header
==
XOFFILE_FORMAT_BINARY_MSZIP
)
||
(
token_header
==
XOFFILE_FORMAT_TEXT_MSZIP
)
)
{
FIXME
(
"Compressed format
s not supported yet
\n
"
);
return
DXFILEERR_BAD
VALUE
;
FIXME
(
"Compressed format
%s not supported yet
\n
"
,
debugstr_fourcc
(
token_header
)
);
return
DXFILEERR_BAD
ALLOC
;
}
if
(
token_header
==
XOFFILE_FORMAT_TEXT
)
buf
.
txt
=
TRUE
;
read_bytes
(
&
buf
,
&
token_header
,
4
);
if
((
token_header
!=
XOFFILE_FORMAT_FLOAT_BITS_32
)
&&
(
token_header
!=
XOFFILE_FORMAT_FLOAT_BITS_64
))
...
...
dlls/d3dxof/tests/d3dxof.c
View file @
aed6a4a4
...
...
@@ -53,6 +53,13 @@ char object[] =
"1; 2; 3;
\n
"
"}
\n
"
;
char
empty_txt_file
[]
=
"xof 0302txt 0064"
;
char
empty_bin_file
[]
=
"xof 0302bin 0064"
;
char
empty_tzip_file
[]
=
"xof 0302tzip0064"
;
char
empty_bzip_file
[]
=
"xof 0302bzip0064"
;
char
empty_cmp_file
[]
=
"xof 0302cmp 0064"
;
char
empty_xxxx_file
[]
=
"xof 0302xxxx0064"
;
static
void
init_function_pointers
(
void
)
{
/* We have to use LoadLibrary as no d3dxof functions are referenced directly */
...
...
@@ -190,6 +197,80 @@ static void test_CreateEnumObject(void)
ok
(
ref
==
0
,
"Got refcount %d, expected 0
\n
"
,
ref
);
}
static
void
test_file_types
(
void
)
{
HRESULT
hr
;
LPDIRECTXFILE
dxfile
=
NULL
;
LPDIRECTXFILEENUMOBJECT
enum_object
;
DXFILELOADMEMORY
lminfo
;
if
(
!
pDirectXFileCreate
)
{
win_skip
(
"DirectXFileCreate is not available
\n
"
);
return
;
}
hr
=
pDirectXFileCreate
(
&
dxfile
);
ok
(
hr
==
DXFILE_OK
,
"DirectXFileCreate: %x
\n
"
,
hr
);
if
(
!
dxfile
)
{
skip
(
"Couldn't create DirectXFile interface
\n
"
);
return
;
}
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_txt_file
,
strlen
(
empty_txt_file
));
ok
(
hr
==
DXFILE_OK
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_bin_file
,
strlen
(
empty_bin_file
));
ok
(
hr
==
DXFILE_OK
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_tzip_file
,
strlen
(
empty_tzip_file
));
ok
(
hr
==
DXFILEERR_BADALLOC
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_bzip_file
,
strlen
(
empty_bzip_file
));
ok
(
hr
==
DXFILEERR_BADALLOC
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_cmp_file
,
strlen
(
empty_cmp_file
));
ok
(
hr
==
DXFILEERR_BADFILETYPE
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
hr
=
IDirectXFile_RegisterTemplates
(
dxfile
,
empty_xxxx_file
,
strlen
(
empty_xxxx_file
));
ok
(
hr
==
DXFILEERR_BADFILETYPE
,
"IDirectXFileImpl_RegisterTemplates: %x
\n
"
,
hr
);
lminfo
.
lpMemory
=
empty_txt_file
;
lminfo
.
dSize
=
strlen
(
empty_txt_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILE_OK
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
if
(
hr
==
DXFILE_OK
)
IDirectXFileEnumObject_Release
(
enum_object
);
lminfo
.
lpMemory
=
empty_bin_file
;
lminfo
.
dSize
=
strlen
(
empty_bin_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILE_OK
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
if
(
hr
==
DXFILE_OK
)
IDirectXFileEnumObject_Release
(
enum_object
);
lminfo
.
lpMemory
=
empty_tzip_file
;
lminfo
.
dSize
=
strlen
(
empty_tzip_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILEERR_BADALLOC
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
lminfo
.
lpMemory
=
empty_bzip_file
;
lminfo
.
dSize
=
strlen
(
empty_bzip_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILEERR_BADALLOC
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
lminfo
.
lpMemory
=
empty_cmp_file
;
lminfo
.
dSize
=
strlen
(
empty_cmp_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILEERR_BADFILETYPE
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
lminfo
.
lpMemory
=
empty_xxxx_file
;
lminfo
.
dSize
=
strlen
(
empty_xxxx_file
);
hr
=
IDirectXFile_CreateEnumObject
(
dxfile
,
&
lminfo
,
DXFILELOAD_FROMMEMORY
,
&
enum_object
);
ok
(
hr
==
DXFILEERR_BADFILETYPE
,
"IDirectXFile_CreateEnumObject: %x
\n
"
,
hr
);
IDirectXFile_Release
(
dxfile
);
}
/* Set it to 1 to expand the string when dumping the object. This is useful when there is
* only one string in a sub-object (very common). Use with care, this may lead to a crash. */
#define EXPAND_STRING 0
...
...
@@ -364,6 +445,7 @@ START_TEST(d3dxof)
test_refcount
();
test_CreateEnumObject
();
test_file_types
();
test_dump
();
FreeLibrary
(
hd3dxof
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment