1 /*
2  * Copyright (C) 2023 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 DEV_AUTH_BASE_CMD_H
17 #define DEV_AUTH_BASE_CMD_H
18 
19 #include "json_utils.h"
20 #include "string_util.h"
21 
22 typedef enum {
23     ABORT_IF_ERROR = 1,
24     CONTINUE_IF_ERROR = 2
25 } ErrorHandleStrategy;
26 
27 typedef enum {
28     CMD_STATE_CONTINUE = 1,
29     CMD_STATE_FINISH = 2,
30 } CmdState;
31 
32 typedef struct BaseCmd BaseCmd;
33 struct BaseCmd {
34     int32_t type;
35     bool isCaller;
36     int32_t strategy;
37     int32_t curState;
38     int32_t beginState;
39     int32_t finishState;
40     int32_t failState;
41     int32_t (*start)(BaseCmd *, CJson **);
42     int32_t (*process)(BaseCmd *, const CJson *, CJson **, CmdState *);
43     void (*destroy)(BaseCmd *);
44 };
45 
46 #endif
47