1 // bindgen-flags: --rustified-enum ".*" 2 3 /** 4 * Stores a pointer to the ops struct, and the offset: the place to 5 * write the parsed result in the destination structure. 6 */ 7 struct cmdline_token_hdr { 8 struct cmdline_token_ops *ops; 9 unsigned int offset; 10 }; 11 typedef struct cmdline_token_hdr cmdline_parse_token_hdr_t; 12 13 /** 14 * A token is defined by this structure. 15 * 16 * parse() takes the token as first argument, then the source buffer 17 * starting at the token we want to parse. The 3rd arg is a pointer 18 * where we store the parsed data (as binary). It returns the number of 19 * parsed chars on success and a negative value on error. 20 * 21 * complete_get_nb() returns the number of possible values for this 22 * token if completion is possible. If it is NULL or if it returns 0, 23 * no completion is possible. 24 * 25 * complete_get_elt() copy in dstbuf (the size is specified in the 26 * parameter) the i-th possible completion for this token. returns 0 27 * on success or and a negative value on error. 28 * 29 * get_help() fills the dstbuf with the help for the token. It returns 30 * -1 on error and 0 on success. 31 */ 32 struct cmdline_token_ops { 33 /** parse(token ptr, buf, res pts, buf len) */ 34 int (*parse)(cmdline_parse_token_hdr_t *, const char *, void *, 35 unsigned int); 36 /** return the num of possible choices for this token */ 37 int (*complete_get_nb)(cmdline_parse_token_hdr_t *); 38 /** return the elt x for this token (token, idx, dstbuf, size) */ 39 int (*complete_get_elt)(cmdline_parse_token_hdr_t *, int, char *, 40 unsigned int); 41 /** get help for this token (token, dstbuf, size) */ 42 int (*get_help)(cmdline_parse_token_hdr_t *, char *, unsigned int); 43 }; 44 45 enum cmdline_numtype { 46 UINT8 = 0, 47 UINT16, 48 UINT32, 49 UINT64, 50 INT8, 51 INT16, 52 INT32, 53 INT64 54 }; 55 56 struct cmdline_token_num_data { 57 enum cmdline_numtype type; 58 }; 59 60 struct cmdline_token_num { 61 struct cmdline_token_hdr hdr; 62 struct cmdline_token_num_data num_data; 63 }; 64 typedef struct cmdline_token_num cmdline_parse_token_num_t; 65