xref: /rockchip-linux_mpp/utils/mpp_opt.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2021 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __MPP_OPT_H__
18 #define __MPP_OPT_H__
19 
20 #include "rk_type.h"
21 
22 /*
23  * return zero or positive for option parser aproach step
24  * return negative for failure or option help
25  */
26 typedef RK_S32 (*OptParser)(void *ctx, const char *next);
27 
28 typedef struct MppOptInfo_t {
29     const char*     name;
30     const char*     full_name;
31     const char*     help;
32     OptParser       proc;
33 } MppOptInfo;
34 
35 typedef void* MppOpt;
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 MPP_RET mpp_opt_init(MppOpt *opt);
42 MPP_RET mpp_opt_deinit(MppOpt opt);
43 
44 MPP_RET mpp_opt_setup(MppOpt opt, void *ctx);
45 /* Add NULL info to mark end of options */
46 MPP_RET mpp_opt_add(MppOpt opt, MppOptInfo *info);
47 
48 MPP_RET mpp_opt_parse(MppOpt opt, int argc, char **argv);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /*__MPP_OPT_H__*/
55