2 * unix_lib.c - This is the Unix side of the Unix interface.
4 * Copyright 2020 Esme Povirk
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/port.h"
30 #define NONAMELESSUNION
33 #define WIN32_NO_STATUS
40 #include "wincodecs_private.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
46 #include "wincodecs_common.h"
48 static const struct win32_funcs
*win32_funcs
;
50 HRESULT CDECL
stream_getsize(IStream
*stream
, ULONGLONG
*size
)
52 return win32_funcs
->stream_getsize(stream
, size
);
55 HRESULT CDECL
stream_read(IStream
*stream
, void *buffer
, ULONG read
, ULONG
*bytes_read
)
57 return win32_funcs
->stream_read(stream
, buffer
, read
, bytes_read
);
60 HRESULT CDECL
stream_seek(IStream
*stream
, LONGLONG ofs
, DWORD origin
, ULONGLONG
*new_position
)
62 return win32_funcs
->stream_seek(stream
, ofs
, origin
, new_position
);
65 HRESULT CDECL
stream_write(IStream
*stream
, const void *buffer
, ULONG write
, ULONG
*bytes_written
)
67 return win32_funcs
->stream_write(stream
, buffer
, write
, bytes_written
);
70 HRESULT CDECL
decoder_create(const CLSID
*decoder_clsid
, struct decoder_info
*info
, struct decoder
**result
)
72 if (IsEqualGUID(decoder_clsid
, &CLSID_WICPngDecoder
)||
73 IsEqualGUID(decoder_clsid
, &CLSID_WICPngDecoder2
))
74 return png_decoder_create(info
, result
);
76 if (IsEqualGUID(decoder_clsid
, &CLSID_WICTiffDecoder
))
77 return tiff_decoder_create(info
, result
);
79 if (IsEqualGUID(decoder_clsid
, &CLSID_WICJpegDecoder
))
80 return jpeg_decoder_create(info
, result
);
85 HRESULT CDECL
encoder_create(const CLSID
*encoder_clsid
, struct encoder_info
*info
, struct encoder
**result
)
87 if (IsEqualGUID(encoder_clsid
, &CLSID_WICPngEncoder
))
88 return png_encoder_create(info
, result
);
90 if (IsEqualGUID(encoder_clsid
, &CLSID_WICTiffEncoder
))
91 return tiff_encoder_create(info
, result
);
93 if (IsEqualGUID(encoder_clsid
, &CLSID_WICJpegEncoder
))
94 return jpeg_encoder_create(info
, result
);
96 if (IsEqualGUID(encoder_clsid
, &CLSID_WICIcnsEncoder
))
97 return icns_encoder_create(info
, result
);
102 static const struct unix_funcs unix_funcs
= {
105 decoder_get_frame_info
,
107 decoder_get_metadata_blocks
,
108 decoder_get_color_context
,
112 encoder_get_supported_format
,
113 encoder_create_frame
,
115 encoder_commit_frame
,
120 NTSTATUS CDECL
__wine_init_unix_lib( HMODULE module
, DWORD reason
, const void *ptr_in
, void *ptr_out
)
122 if (reason
!= DLL_PROCESS_ATTACH
) return STATUS_SUCCESS
;
124 win32_funcs
= ptr_in
;
126 *(const struct unix_funcs
**)ptr_out
= &unix_funcs
;
127 return STATUS_SUCCESS
;