blob: 1f37151a028681d9b0f215bb6975261e19e5fd1d [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001/*
John Koleszarc2140b82010-09-09 08:16:39 -04002 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04003 *
John Koleszar94c52e42010-06-18 12:39:21 -04004 * Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04005 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
John Koleszar94c52e42010-06-18 12:39:21 -04007 * in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04008 * be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -04009 */
10
11
James Zern0f512782013-12-15 18:40:23 -080012#ifndef ARGS_H_
13#define ARGS_H_
John Koleszar0ea50ce2010-05-18 11:58:33 -040014#include <stdio.h>
15
James Zern25cfd8e2014-01-18 12:16:11 -080016#ifdef __cplusplus
17extern "C" {
18#endif
19
John Koleszarc6b90392012-07-13 15:21:29 -070020struct arg {
21 char **argv;
22 const char *name;
23 const char *val;
24 unsigned int argv_step;
25 const struct arg_def *def;
John Koleszar0ea50ce2010-05-18 11:58:33 -040026};
27
John Koleszarc6b90392012-07-13 15:21:29 -070028struct arg_enum_list {
29 const char *name;
30 int val;
John Koleszarb0da9b32010-12-17 09:43:39 -050031};
32#define ARG_ENUM_LIST_END {0}
33
John Koleszarc6b90392012-07-13 15:21:29 -070034typedef struct arg_def {
35 const char *short_name;
36 const char *long_name;
37 int has_val;
38 const char *desc;
39 const struct arg_enum_list *enums;
John Koleszar0ea50ce2010-05-18 11:58:33 -040040} arg_def_t;
John Koleszarb0da9b32010-12-17 09:43:39 -050041#define ARG_DEF(s,l,v,d) {s,l,v,d, NULL}
42#define ARG_DEF_ENUM(s,l,v,d,e) {s,l,v,d,e}
John Koleszar0ea50ce2010-05-18 11:58:33 -040043#define ARG_DEF_LIST_END {0}
44
45struct arg arg_init(char **argv);
46int arg_match(struct arg *arg_, const struct arg_def *def, char **argv);
47const char *arg_next(struct arg *arg);
48void arg_show_usage(FILE *fp, const struct arg_def *const *defs);
49char **argv_dup(int argc, const char **argv);
50
51unsigned int arg_parse_uint(const struct arg *arg);
52int arg_parse_int(const struct arg *arg);
53struct vpx_rational arg_parse_rational(const struct arg *arg);
James Zern4e5a7782014-10-11 11:27:23 +020054int arg_parse_enum(const struct arg *arg);
John Koleszarb0da9b32010-12-17 09:43:39 -050055int arg_parse_enum_or_int(const struct arg *arg);
James Zern25cfd8e2014-01-18 12:16:11 -080056#ifdef __cplusplus
57} // extern "C"
58#endif
59
James Zern0f512782013-12-15 18:40:23 -080060#endif // ARGS_H_