From 04a85b3b36fdbaaac5fa95d61f59f481bbcf7520 Mon Sep 17 00:00:00 2001 From: wdenk Date: Thu, 15 Apr 2004 18:22:41 +0000 Subject: * Patches by Pantelis Antoniou, 30 Mar 2004: - add auto-complete support to the U-Boot CLI - add support for NETTA and NETPHONE boards; fix NETVIA board * Patch by Yuli Barcohen, 28 Mar 2004: - Add support for MPC8272 family including MPC8247/8248/8271/8272 - Add support for MPC8272ADS evaluation board (another flavour of MPC8260ADS) - Change configuration method for MPC8260ADS family --- common/env_common.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'common/env_common.c') diff --git a/common/env_common.c b/common/env_common.c index e7ee4991f..d46f24f60 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -260,3 +260,44 @@ void env_relocate (void) disable_nvram(); #endif } + +#ifdef CONFIG_AUTO_COMPLETE +int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) +{ + int i, nxt, len, vallen, found; + const char *lval, *rval; + + found = 0; + cmdv[0] = NULL; + + len = strlen(var); + /* now iterate over the variables and select those that match */ + for (i=0; env_get_char(i) != '\0'; i=nxt+1) { + + for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) + ; + + lval = env_get_addr(i); + rval = strchr(lval, '='); + if (rval != NULL) { + vallen = rval - lval; + rval++; + } else + vallen = strlen(lval); + + if (len > 0 && (vallen < len || memcmp(lval, var, len) != 0)) + continue; + + if (found >= maxv - 2 || bufsz < vallen + 1) { + cmdv[found++] = "..."; + break; + } + cmdv[found++] = buf; + memcpy(buf, lval, vallen); buf += vallen; bufsz -= vallen; + *buf++ = '\0'; bufsz--; + } + + cmdv[found] = NULL; + return found; +} +#endif -- cgit v1.2.3