1 /* 2 * Copyright (C) 2021-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 16 17 #ifndef OHOS_DHCP_ARGUMENT_H 18 #define OHOS_DHCP_ARGUMENT_H 19 20 #define ARGUMENT_NAME_SIZE 32 21 #define ARGUMENT_VALUE_SIZE 256 22 #define INIT_ARGS_SIZE 4 23 24 #define NO_ARG 0 25 #define REQUIRED_ARG 1 26 #define OPTIONAL_ARG 2 27 28 #define USAGE_DESC_MAX_LENGTH 32 29 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 typedef struct DhcpUsage DhcpUsage; 36 struct DhcpUsage { 37 struct option *opt; 38 const char *params; 39 const char *desc; 40 const char *example; 41 int required; 42 int (*dealOption)(const char *, const char *); 43 }; 44 45 46 typedef struct ArgumentInfo ArgumentInfo; 47 struct ArgumentInfo { 48 char name[ARGUMENT_NAME_SIZE]; 49 char value[ARGUMENT_VALUE_SIZE]; 50 }; 51 52 int InitArguments(void); 53 int HasArgument(const char *argument); 54 ArgumentInfo *GetArgument(const char *name); 55 int PutArgument(const char *argument, const char *val); 56 57 int ParseArguments(int argc, char *argv[]); 58 59 void FreeArguments(void); 60 61 void ShowHelp(int argc); 62 63 void PrintRequiredArguments(void); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 69 #endif // OHOS_DHCP_ARGUMENT_H 70