···11+// MIT License
22+33+// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
44+55+// Permission is hereby granted, free of charge, to any person obtaining a copy
66+// of this software and associated documentation files (the "Software"), to deal
77+// in the Software without restriction, including without limitation the rights
88+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+// copies of the Software, and to permit persons to whom the Software is
1010+// furnished to do so, subject to the following conditions:
1111+1212+// The above copyright notice and this permission notice shall be included in all
1313+// copies or substantial portions of the Software.
1414+1515+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+// SOFTWARE.
2222+2323+#include "tools.h"
2424+2525+#include <zlib.h>
2626+2727+u32 tic_tool_zip(void* dest, s32 destSize, const void* source, s32 size)
2828+{
2929+ unsigned long destSizeLong = destSize;
3030+ return compress2(dest, &destSizeLong, source, size, Z_BEST_COMPRESSION) == Z_OK ? destSizeLong : 0;
3131+}
3232+3333+u32 tic_tool_unzip(void* dest, s32 destSize, const void* source, s32 size)
3434+{
3535+ unsigned long destSizeLong = destSize;
3636+ return uncompress(dest, &destSizeLong, source, size) == Z_OK ? destSizeLong : 0;
3737+}