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 #ifndef SVC_CONTROL_H 16 #define SVC_CONTROL_H 17 18 #include <vector> 19 #include <string> 20 #include "singleton.h" 21 22 namespace OHOS { 23 enum class SvcCmd : int32_t { 24 ARGS_CNT_NOT_ENOUGH = -4, 25 ARGS_CNT_EXCEED = -3, 26 ARGS_INVALID = -2, 27 28 HELP_CMD = -1, 29 30 WIFI_CMD = 1120, 31 BLUETOOTH_CMD = 1130, 32 NEARLINK_CMD = 1190, 33 }; 34 35 class SvcControl : public Singleton<SvcControl> { 36 public: 37 SvcControl(); 38 ~SvcControl(); 39 40 int32_t Main(int32_t argc, char *argv[], int32_t outFd); 41 42 static void HelpInfo(int32_t fd); 43 44 private: 45 static constexpr int32_t ARG_MAX_COUNT = 64; 46 static constexpr int32_t ARG_MIN_COUNT = 2; 47 static constexpr int32_t SINGLE_ARG_MAXLEN = 256; 48 static constexpr int32_t TIME_OUT = 4; 49 50 SvcCmd Parse(int32_t argc, char *argv[]); 51 virtual SvcCmd ParseCmd(char *argv[], int32_t cnt, bool &isEnd); 52 std::string CmdErrorToString(SvcCmd cmd); 53 void SetCmdArgs(int32_t argc, char *argv[], std::vector<std::u16string> &args); 54 }; 55 } 56 57 #endif 58