OSDN Git Service

Updated Delphi language bindings.
[mhash384/mhash384.git] / bindings / Delphi / native / src / MHashDelphi384.cpp
1 /* ---------------------------------------------------------------------------------------------- */
2 /* MHash-384 - Language bindings for Delphi                                                       */
3 /* Copyright(c) 2016 LoRd_MuldeR <mulder2@gmx.de>                                                 */
4 /*                                                                                                */
5 /* Permission is hereby granted, free of charge, to any person obtaining a copy of this software  */
6 /* and associated documentation files (the "Software"), to deal in the Software without           */
7 /* restriction, including without limitation the rights to use, copy, modify, merge, publish,     */
8 /* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the  */
9 /* Software is furnished to do so, subject to the following conditions:                           */
10 /*                                                                                                */
11 /* The above copyright notice and this permission notice shall be included in all copies or       */
12 /* substantial portions of the Software.                                                          */
13 /*                                                                                                */
14 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING  */
15 /* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND     */
16 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   */
17 /* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
18 /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.        */
19 /* ---------------------------------------------------------------------------------------------- */
20
21 #define MHASH_DISABLE_STL 1
22 #include <mhash_384.h>
23
24 #ifdef __cplusplus
25 #define EXPORT_FUNC(NAME,TYPE,...) extern "C" __declspec(dllexport) TYPE NAME(__VA_ARGS__)
26 #else
27 #define EXPORT_FUNC(NAME,TYPE,...) __declspec(dllexport) TYPE NAME(__VA_ARGS__)
28 #endif
29
30 EXPORT_FUNC(mhash384_create, uintptr_t, void)
31 {
32         return (uintptr_t) new mhash::MHash384();
33 }
34
35 EXPORT_FUNC(mhash384_update, void, const uintptr_t instance, uint8_t *const input, const size_t offset, const size_t len)
36 {
37         reinterpret_cast<mhash::MHash384*>(instance)->update(input + offset, len);
38 }
39
40 EXPORT_FUNC(mhash384_result, void, const uintptr_t instance, uint8_t *const buffer)
41 {
42         reinterpret_cast<mhash::MHash384*>(instance)->finalize(buffer);
43 }
44
45 EXPORT_FUNC(mhash384_freeup, void, const uintptr_t instance)
46 {
47         delete reinterpret_cast<mhash::MHash384*>(instance);
48 }
49
50 EXPORT_FUNC(mhash384_getver, void, uint32_t *const major, uint32_t *const minor, uint32_t *const patch)
51 {
52         *major = MHASH_384_VERSION_MAJOR;
53         *minor = MHASH_384_VERSION_MINOR;
54         *patch = MHASH_384_VERSION_PATCH;
55 }