1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <cstdio>
16 #include <cstring>
17 #include <unistd.h>
18
19 #include "napi/native_api.h"
20 #include "napi/native_node_api.h"
21 #include "napi_zlib.h"
22 namespace OHOS {
23 namespace AppExecFwk {
24 namespace LIBZIP {
25
26 EXTERN_C_START
27 /*
28 * The module initialization.
29 */
Init(napi_env env,napi_value exports)30 static napi_value Init(napi_env env, napi_value exports)
31 {
32 FlushTypeInit(env, exports);
33 CompressLevelInit(env, exports);
34 CompressStrategyInit(env, exports);
35 MemLevelInit(env, exports);
36 ErrorCodeInit(env, exports);
37 ZlibInit(env, exports);
38 return exports;
39 }
40 EXTERN_C_END
41
42 /*
43 * The module definition.
44 */
45 static napi_module _module = {
46 .nm_version = 1,
47 .nm_flags = 0,
48 .nm_filename = nullptr,
49 .nm_register_func = Init,
50 .nm_modname = "zlib",
51 .nm_priv = ((void *)0),
52 .reserved = {0}
53 };
54
55 /*
56 * The module registration.
57 */
RegisterModule(void)58 extern "C" __attribute__((constructor)) void RegisterModule(void)
59 {
60 napi_module_register(&_module);
61 }
62 } // namespace LIBZIP
63 } // namespace AppExecFwk
64 } // namespace OHOS
65