Revert "Coding style and const fixes to last PR"

This reverts commit fbb1f8800a.
This commit is contained in:
Joachim Nilsson
2018-11-15 10:26:03 +01:00
parent fbb1f8800a
commit 66d8ae84e2
4 changed files with 24 additions and 19 deletions

View File

@@ -117,27 +117,37 @@ el_status_t do_suspend(void)
return CSstay;
}
static int my_rl_check_secret(const char *line)
static int my_rl_check_secret(const char* source)
{
const char *pattern = (char *)"^unlock\\s";
const char* pattern = (char *)"^unlock\\s";
regex_t regex;
int rc = 0;
if (!line || regcomp(&regex, pattern, 0))
return 0;
int reti;
int rez = 0;
if (!regexec(&regex, line, 0, NULL, 0))
rc = 1;
if (!pattern || !source)
return rez;
/* Compile regular expression */
reti = regcomp(&regex, pattern, 0);
if (reti) // If couldn't compile regex
return rez;
/* Execute regular expression */
reti = regexec(&regex, source, 0, NULL, 0);
if (!reti) // If regex match
rez = 1;
/* Free memory allocated to the pattern buffer by regcomp() */
regfree(&regex);
return rc;
return rez;
}
int main(void)
{
char *line;
char *prompt = "cli> ";
char *prompt = "cli> ";
/* Setup callbacks */
rl_set_complete_func(&my_rl_complete);