1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
7 #ifndef _PARSE_OBJ_LIST_H_
8 #define _PARSE_OBJ_LIST_H_
10 /* This file is an example of extension of libcmdline. It provides an
11 * example of objects stored in a list. */
13 #include <sys/queue.h>
14 #include <cmdline_parse.h>
16 #define OBJ_NAME_LEN_MAX 64
19 SLIST_ENTRY(object) next;
20 char name[OBJ_NAME_LEN_MAX];
24 /* define struct object_list */
25 SLIST_HEAD(object_list, object);
27 /* data is a pointer to a list */
28 struct token_obj_list_data {
29 struct object_list *list;
32 struct token_obj_list {
33 struct cmdline_token_hdr hdr;
34 struct token_obj_list_data obj_list_data;
36 typedef struct token_obj_list parse_token_obj_list_t;
38 extern struct cmdline_token_ops token_obj_list_ops;
40 int parse_obj_list(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
42 int complete_get_nb_obj_list(cmdline_parse_token_hdr_t *tk);
43 int complete_get_elt_obj_list(cmdline_parse_token_hdr_t *tk, int idx,
44 char *dstbuf, unsigned int size);
45 int get_help_obj_list(cmdline_parse_token_hdr_t *tk, char *dstbuf, unsigned int size);
47 #define TOKEN_OBJ_LIST_INITIALIZER(structure, field, obj_list_ptr) \
50 .ops = &token_obj_list_ops, \
51 .offset = offsetof(structure, field), \
54 .list = obj_list_ptr, \
58 #endif /* _PARSE_OBJ_LIST_H_ */