本文整理汇总了C++中env_get_char函数的典型用法代码示例。如果您正苦于以下问题:C++ env_get_char函数的具体用法?C++ env_get_char怎么用?C++ env_get_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了env_get_char函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printk
/* tear down ed*/
#ifdef DEBUGME
printk(KERN_ERR\
"%s: Tearing down data!\n",\
__func__);
#endif /*DEBUGME*/
ed.mtd = -1;
kfree(ed.data);
ed.data = NULL;
put_mtd_device(ed.mtds[0]); ed.mtds[0] = NULL;
put_mtd_device(ed.mtds[1]); ed.mtds[1] = NULL;
#ifdef DEBUGME
printk(KERN_ERR\
"%s: Tearing down complete!\n",\
__func__);
#endif /*DEBUGME*/
return (*buf) ? 0 : -1;
} else {
printk(KERN_ERR\
"%s: Failed to read the env block!\n",\
__func__);
return -3;
}
return 0;
}
#else /*CONFIG_CIRRUS_DUAL_MTD_ENV*/
int rtcnvet_get_env(char *name, char **buf)
{
int j, k, nxt;
if (!env_valid) {
*buf = NULL;
return -1;
}
k = -1;
for (j = 0; env_get_char(j) != '\0'; j = nxt+1) {
for (nxt = j; env_get_char(nxt) != '\0'; ++nxt)
;
k = envmatch((unsigned char *)name, j);
if (k < 0)
continue;
break;
}
if (k < 0) {
printk(KERN_ERR "## Error: \"%s\" not defined\n", name);
*buf = NULL;
} else
*buf = &env_buf[k];
return (*buf) ? 0 : -1;
}
示例2: getenv_f
/*
* Look up variable from environment for restricted C runtime env.
*/
int getenv_f(const char *name, char *buf, unsigned len)
{
int i, nxt;
for (i = 0; env_get_char(i) != '\0'; i = nxt+1) {
int val, n;
for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
if (nxt >= CONFIG_ENV_SIZE)
return -1;
}
val = envmatch((uchar *)name, i);
if (val < 0)
continue;
/* found; copy out */
for (n = 0; n < len; ++n, ++buf) {
if ((*buf = env_get_char(val++)) == '\0')
return n;
}
if (n)
*--buf = '\0';
printf("env_buf [%d bytes] too small for value of \"%s\"\n",
len, name);
return n;
}
return -1;
}
示例3: envmatch
int envmatch(uchar *s1, int i2)
{
while (*s1 == env_get_char(i2++))
if (*s1++ == '=')
return i2;
if (*s1 == '\0' && env_get_char(i2-1) == '=')
return i2;
return -1;
}
示例4: envmatch
static int envmatch (char *s1, int i2)
{
while (*s1 == env_get_char(i2++))
if (*s1++ == '=')
return(i2);
if (*s1 == '\0' && env_get_char(i2-1) == '=')
return(i2);
return(-1);
}
示例5: envmatch
static char *findenv(const char *name)
{
int i, nxt, val;
for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) {
if (nxt >= CFG_ENV_SIZE)
return NULL;
}
val = envmatch((char *)name, i);
if (val < 0)
continue;
return (char *)env_get_addr(val);
}
return NULL;
}
示例6:
static char *findenv(const char *name)
{
int i, nxt, val;
for (i = 0; env_get_char(i) != '\0'; i = nxt+1) {
for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
if (nxt >= CFG_ENV_SIZE) {
return (NULL);
}
}
if ((val=envmatch((char *)name, i)) < 0) {
continue;
}
return ((char *)env_get_addr(val));
}
return (NULL);
}
示例7: API_env_enum
/*
* pseudo signature:
*
* int API_env_enum(const char *last, char **next)
*
* last: ptr to name of env var found in last iteration
*/
static int API_env_enum(va_list ap)
{
int i, n;
char *last, **next;
last = (char *)va_arg(ap, u_int32_t);
if ((next = (char **)va_arg(ap, u_int32_t)) == NULL)
return API_EINVAL;
if (last == NULL)
/* start over */
*next = ((char *)env_get_addr(0));
else {
*next = last;
for (i = 0; env_get_char(i) != '\0'; i = n + 1) {
for (n = i; env_get_char(n) != '\0'; ++n) {
if (n >= CONFIG_ENV_SIZE) {
/* XXX shouldn't we set *next = NULL?? */
return 0;
}
}
if (envmatch((uchar *)last, i) < 0)
continue;
/* try to get next name */
i = n + 1;
if (env_get_char(i) == '\0') {
/* no more left */
*next = NULL;
return 0;
}
*next = ((char *)env_get_addr(i));
return 0;
}
}
return 0;
}
示例8: env_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 = (char *)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;
}
示例9: print_env
void print_env()
{
int i,nxt;
uchar *env = (uchar *)g_env.env_data;
if(!env_valid){
printf("[%s]no valid env\n",MODULE_NAME);
return;
}
printf("[%s]env:\n",MODULE_NAME);
for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
if (nxt >= (int)(CFG_ENV_DATA_SIZE)) {
return;
}
}
printf("%s\n",env+i);
}
}
示例10: rtcnvet_do_printenv
int rtcnvet_do_printenv(char *name)
{
int i, j, k, nxt;
const uint8_t *b;
if (name == NULL) {
/* Print all env variables */
for (i = 0; env_get_char(i) != '\0'; i = nxt+1) {
for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
;
b = (const uint8_t *)&env_buf[i];
dump_hex_f(b, (nxt-i), DUMP_ASCII);
}
printk(KERN_INFO "\nEnvironment size: %d/%d bytes\n",
i, env_size);
return 0;
} else {
k = -1;
for (j = 0; env_get_char(j) != '\0'; j = nxt+1) {
for (nxt = j; env_get_char(nxt) != '\0'; ++nxt)
;
k = envmatch((unsigned char *)name, j);
if (k < 0)
continue;
printk(KERN_INFO "%s=", name);
b = (const uint8_t *)&env_buf[k];
dump_hex_f(b, (nxt-k), DUMP_ASCII);
break;
}
if (k < 0)
printk(KERN_ERR "## Error: \"%s\" not defined\n", name);
return 0;
}
}
示例11: printk
char *get_env(char *name)
{
int i, nxt;
printk("[%s]get_env %s\n",MODULE_NAME,name);
if(!env_valid)
return NULL;
for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
int val;
for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) {
if (nxt >= CFG_ENV_SIZE) {
return (NULL);
}
}
if ((val=envmatch((char *)name, i)) < 0)
continue;
return ((char *)env_get_addr(val));
}
return (NULL);
}
示例12: printenv
/*
* state 0: finish printing this string and return (matched!)
* state 1: no matching to be done; print everything
* state 2: continue searching for matched name
*/
static int printenv(char *name, int state)
{
int i, j;
char c, buf[17];
i = 0;
buf[16] = '\0';
while (state && env_get_char(i) != '\0') {
if (state == 2 && envmatch((uchar *)name, i) >= 0)
state = 0;
j = 0;
do {
buf[j++] = c = env_get_char(i++);
if (j == sizeof(buf) - 1) {
if (state <= 1)
puts(buf);
j = 0;
}
} while (c != '\0');
if (state <= 1) {
if (j)
puts(buf);
putc('\n');
}
if (ctrlc())
return -1;
}
if (state == 0)
i = 0;
return i;
}
示例13: env_check_char_valid
static T_BOOL env_check_char_valid(T_pVOID buffer, T_U32 index, const T_U8 *exclude, T_U32 len)
{
T_U8 ch = env_get_char(buffer, index);
return (!env_char_in_set(ch, exclude, len));
}
示例14: fdt_env
int fdt_env(void *fdt)
{
int nodeoffset;
int err;
int k, nxt;
int i;
static char tmpenv[256];
err = fdt_check_header(fdt);
if (err < 0) {
printf("fdt_env: %s\n", fdt_strerror(err));
return err;
}
/*
* See if we already have a "u-boot-env" node, delete it if so.
* Then create a new empty node.
*/
nodeoffset = fdt_path_offset (fdt, "/u-boot-env");
if (nodeoffset >= 0) {
err = fdt_del_node(fdt, nodeoffset);
if (err < 0) {
printf("fdt_env: %s\n", fdt_strerror(err));
return err;
}
}
/*
* Create a new node "/u-boot-env" (offset 0 is root level)
*/
nodeoffset = fdt_add_subnode(fdt, 0, "u-boot-env");
if (nodeoffset < 0) {
printf("WARNING: could not create /u-boot-env %s.\n",
fdt_strerror(nodeoffset));
return nodeoffset;
}
for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
char *s, *lval, *rval;
/*
* Find the end of the name=definition
*/
for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
;
s = tmpenv;
for (k = i; k < nxt && s < &tmpenv[sizeof(tmpenv) - 1]; ++k)
*s++ = env_get_char(k);
*s++ = '\0';
lval = tmpenv;
/*
* Find the first '=': it separates the name from the value
*/
s = strchr(tmpenv, '=');
if (s != NULL) {
*s++ = '\0';
rval = s;
} else
continue;
err = fdt_setprop(fdt, nodeoffset, lval, rval, strlen(rval)+1);
if (err < 0) {
printf("WARNING: could not set %s %s.\n",
lval, fdt_strerror(err));
return err;
}
}
return 0;
}