1 /* 2 * Copyright (c) 2025 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 16 #ifndef PAC_FUNCTIONS_H 17 #define PAC_FUNCTIONS_H 18 #include <cstdint> 19 #include "jerryscript.h" 20 namespace OHOS { 21 namespace NetManagerStandard { 22 class PacFunctions { 23 public: 24 PacFunctions() = default; 25 ~PacFunctions() = default; 26 static void RegisterPacFunctions(void); 27 28 private: 29 static jerry_value_t JsIsPlainHostname(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 30 const jerry_value_t args[], const jerry_length_t argsCnt); 31 static jerry_value_t JsDnsDomainIs(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 32 const jerry_value_t args[], const jerry_length_t argsCnt); 33 static jerry_value_t JsLocalHostOrDomainIs(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 34 const jerry_value_t args[], const jerry_length_t argsCnt); 35 static jerry_value_t JsConsoleInfo(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 36 const jerry_value_t args[], const jerry_length_t argsCnt); 37 static jerry_value_t JsIsResolvable(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 38 const jerry_value_t args[], const jerry_length_t argsCnt); 39 static jerry_value_t JsMyIpAddress(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 40 const jerry_value_t args[], const jerry_length_t argsCnt); 41 static jerry_value_t JsMyIpAddressEx(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 42 const jerry_value_t args[], const jerry_length_t argsCnt); 43 static jerry_value_t JsIsInNet(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 44 const jerry_value_t args[], const jerry_length_t argsCnt); 45 static jerry_value_t JsIsInNetEx(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 46 const jerry_value_t args[], const jerry_length_t argsCnt); 47 static jerry_value_t JsWeekdayRange(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 48 const jerry_value_t args[], const jerry_length_t argsCnt); 49 static jerry_value_t JsTimeRange(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 50 const jerry_value_t args[], const jerry_length_t argsCnt); 51 static jerry_value_t JsDateRange(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 52 const jerry_value_t args[], const jerry_length_t argsCnt); 53 static jerry_value_t JsShExpMatch(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 54 const jerry_value_t args[], const jerry_length_t argsCnt); 55 static jerry_value_t JsDnsDomainLevels(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 56 const jerry_value_t args[], const jerry_length_t argsCnt); 57 static jerry_value_t JsDnsResolve(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 58 const jerry_value_t args[], const jerry_length_t argsCnt); 59 static jerry_value_t JsSortIpAddressList(const jerry_value_t funcObjVal, const jerry_value_t thisVal, 60 const jerry_value_t args[], const jerry_length_t argsCnt); 61 62 static void RegisterGlobalFunction(jerry_value_t globalObj, const char *funcName, 63 jerry_external_handler_t handler); 64 static void RegisterHostDomainFunctions(jerry_value_t globalObj); 65 static void RegisterDnsResolveFunctions(jerry_value_t globalObj); 66 static void RegisterIpAddressFunctions(jerry_value_t globalObj); 67 static void RegisterTimeAndDateFunctions(jerry_value_t globalObj); 68 static void RegisterPatternMatchingFunctions(jerry_value_t globalObj); 69 }; 70 } // namespace NetManagerStandard 71 } // namespace OHOS 72 #endif 73