}
static int
-complete_obj_list_start(cmdline_parse_token_hdr_t *tk, void **opaque)
+complete_obj_list_start(cmdline_parse_token_hdr_t *tk,
+ __attribute__((unused)) const char *tokstr,
+ void **opaque)
{
struct token_obj_list *tk2 = (struct token_obj_list *)tk;
struct token_obj_list_data *tkd = &tk2->obj_list_data;
}
static int
-complete_conf_node_start(cmdline_parse_token_hdr_t *tk, void **opaque)
+complete_conf_node_start(cmdline_parse_token_hdr_t *tk,
+ __attribute__((unused)) const char *tokstr,
+ void **opaque)
{
struct token_conf_node *tk2 = (struct token_conf_node *)tk;
struct token_conf_node_data *tkd = &tk2->conf_node_data;
else
iterate = 1;
+ /* store the incomplete token in tmpbuf */
+ n = preparse.comp_tok_len + 1;
+ if (n > sizeof(tmpbuf))
+ n = sizeof(tmpbuf);
+ snprintf(tmpbuf, n, "%s", preparse.comp_tok_buf);
+
if (iterate == 1 &&
- token->ops->complete_start(token, &preparse.opaque) < 0) {
+ token->ops->complete_start(token, tmpbuf,
+ &preparse.opaque) < 0) {
/* cancel iteration, complete_start() returned
* a negative value, meaning no completion */
iterate = 0;
token->ops->complete_iterate == NULL)
continue;
+ /* store the incomplete token in tmpbuf */
+ n = preparse.comp_tok_len + 1;
+ if (n > sizeof(tmpbuf))
+ n = sizeof(tmpbuf);
+ snprintf(tmpbuf, n, "%s", preparse.comp_tok_buf);
+
/* non completable */
- if (token->ops->complete_start(token, &preparse.opaque) < 0) {
+ if (token->ops->complete_start(token, tmpbuf,
+ &preparse.opaque) < 0) {
if (token->ops->complete_end != NULL)
token->ops->complete_end(token,
&preparse.opaque);
* error.
*
* complete_start() prepares a completion operation. The first
- * argument is the token to complete. The second argument is an opaque
- * pointer that will be given to complete_iterate() function. It can
- * be used to store private data for this completion. For each
- * complete_start() call, the user must call complete_end() at the end
- * of iterations (if defined). Return a negative value if completion
- * is not possible, or 0 on success.
+ * argument is the token to complete. The second argument is the token
+ * to complete, and the third arg is an opaque pointer that will be
+ * given to complete_iterate() function. It can be used to store
+ * private data for this completion. For each complete_start() call,
+ * the user must call complete_end() at the end of iterations (if
+ * defined). Return a negative value if completion is not possible, or
+ * 0 on success.
*
* complete_iterate() copy in dstbuf (the size is specified in the
* parameter) the next possible completion for this token. Return 0 on
int (*parse)(cmdline_parse_token_hdr_t *, const char *, void *,
unsigned int);
/** prepare a completion on this token */
- int (*complete_start)(cmdline_parse_token_hdr_t *, void **);
+ int (*complete_start)(cmdline_parse_token_hdr_t *, const char *,
+ void **);
/** fill dstbuf for this token (token, opaque, dstbuf, size) */
int (*complete_iterate)(cmdline_parse_token_hdr_t *, void **, char *,
unsigned int);
}
static int
-cmdline_complete_string_start(cmdline_parse_token_hdr_t *tk, void **opaque)
+cmdline_complete_string_start(cmdline_parse_token_hdr_t *tk,
+ __attribute__((unused)) const char *tokstr,
+ void **opaque)
{
struct cmdline_token_string *tk2 = (struct cmdline_token_string *)tk;
struct cmdline_token_string_data *sd = &tk2->string_data;;