hidclass.sys: Return STATUS_INVALID_USER_BUFFER if buffer_len is 0.
[wine.git] / dlls / windowscodecs / unix_lib.c
blob4b184ef60ebff0ccf1b9063725d2f17c0f31c2e0
1 /*
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
21 #if 0
22 #pragma makedep unix
23 #endif
25 #include "config.h"
26 #include "wine/port.h"
28 #include <stdarg.h>
30 #define NONAMELESSUNION
32 #include "ntstatus.h"
33 #define WIN32_NO_STATUS
34 #include "windef.h"
35 #include "winternl.h"
36 #include "winbase.h"
37 #include "objbase.h"
39 #include "initguid.h"
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);
82 return E_NOTIMPL;
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);
99 return E_NOTIMPL;
102 static const struct unix_funcs unix_funcs = {
103 decoder_create,
104 decoder_initialize,
105 decoder_get_frame_info,
106 decoder_copy_pixels,
107 decoder_get_metadata_blocks,
108 decoder_get_color_context,
109 decoder_destroy,
110 encoder_create,
111 encoder_initialize,
112 encoder_get_supported_format,
113 encoder_create_frame,
114 encoder_write_lines,
115 encoder_commit_frame,
116 encoder_commit_file,
117 encoder_destroy
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;