return 0;
}
+
+/* See if partial string matches a full string.
+ *
+ * @param word the partial word to match
+ * @param name the name which "word" might match
+ * @return
+ * - false if they do not match
+ * - true if "word" is a prefix of "name"
+ *
+ */
+bool fr_command_strncmp(const char *word, const char *name)
+{
+ char const *p, *q;
+
+ if (!*word) return true;
+
+ SKIP_NAME(name);
+
+ /*
+ * If we're done P (partial or full), that's a match.
+ */
+ return (*p == '\0');
+}
int fr_command_complete(fr_cmd_t *head, char const *text, int start,
int max_expansions, char const **expansions);
int fr_command_print_help(FILE *fp, fr_cmd_t *head, char const *text);
+bool fr_command_strncmp(const char *text, const char *name) CC_HINT(nonnull);
#ifdef __cplusplus
}
{
module_instance_t *mi = talloc_get_type_abort(instance, module_instance_t);
module_tab_expand_t *mt = ctx;
- char const *p, *q;
if (mt->count >= mt->max_expansions) return 1;
- if (!*mt->text) {
- matched:
+ if (fr_command_strncmp(mt->text, mi->name)) {
mt->expansions[mt->count] = strdup(mi->name);
mt->count++;
- return 0;
- }
-
- /*
- * @todo - put this in a helper function.
- */
- p = mt->text;
- q = mi->name;
- while (*p && *q && (*p == *q)) {
- p++;
- q++;
}
- if (!*p) goto matched;
-
return 0;
}