diff options
author | wdenk <wdenk> | 2004-04-15 18:22:41 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2004-04-15 18:22:41 +0000 |
commit | 04a85b3b36fdbaaac5fa95d61f59f481bbcf7520 (patch) | |
tree | a4c6731a78805c51f43a8b195034d2036b28941b /common/env_common.c | |
parent | d716b126718d874f52ffb694e6c22b7235cec483 (diff) | |
download | u-boot-imx-04a85b3b36fdbaaac5fa95d61f59f481bbcf7520.zip u-boot-imx-04a85b3b36fdbaaac5fa95d61f59f481bbcf7520.tar.gz u-boot-imx-04a85b3b36fdbaaac5fa95d61f59f481bbcf7520.tar.bz2 |
* 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
Diffstat (limited to 'common/env_common.c')
-rw-r--r-- | common/env_common.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/common/env_common.c b/common/env_common.c index e7ee499..d46f24f 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 |