本文整理汇总了C++中envmatch函数的典型用法代码示例。如果您正苦于以下问题:C++ envmatch函数的具体用法?C++ envmatch怎么用?C++ envmatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了envmatch函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: __do_env_get_parameter
void __do_env_get_parameter(env_t *nvm, const char *key, char *value)
{
int oldval;
unsigned char *env, *nxt = NULL;
unsigned char *env_data = nvm->data;
/*
* search if variable with this name already exists
*/
oldval = -1;
for (env=env_data; *env; env=nxt+1)
{
for (nxt=env; *nxt; ++nxt)
;
if ((oldval = envmatch((unsigned char *)key, env-env_data, env_data)) >= 0)
break;
}
if (oldval >= 0)
{
strcpy(value, env_data + oldval);
}
else
{
value[0] = '\0';
}
}
开发者ID:Undrizzle,项目名称:apps,代码行数:28,代码来源:nvm-utils.c
示例2: 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;
}
开发者ID:mausvt,项目名称:seagate_central_cns3420_2-6-35,代码行数:57,代码来源:rtc-nvedit.c
示例3: 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;
}
开发者ID:aosp,项目名称:uboot,代码行数:35,代码来源:cmd_nvedit.c
示例4: do_printenv
void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
uchar *env, *nxt;
int i;
#if defined(CFG_FLASH_ENV_ADDR)
uchar *environment = env_init();
#else
env_init();
#endif /* CFG_FLASH_ENV_ADDR */
if (argc == 1) { /* Print all env variables */
uchar *start = environment;
for (env=environment; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
puts (env);
putc ('\n');
if (tstc()) {
getc ();
printf ("\n ** Abort\n");
return;
}
}
printf("\nEnvironment size: %d bytes\n", env-start);
return;
}
for (i=1; i<argc; ++i) { /* print single env variables */
char *name = argv[i];
char *val = NULL;
for (env=environment; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
val=envmatch(name, env);
if (val) {
puts (name);
putc ('=');
puts (val);
putc ('\n');
break;
}
}
if (!val)
printf ("## Error: \"%s\" not defined\n", name);
}
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:52,代码来源:cmd_nvedit.c
示例5: do_printenv
int do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
int i, j, k, nxt;
if (argc == 1) { /* Print all env variables */
for (i=0; get_env_char(bd, i) != '\0'; i=nxt+1) {
for (nxt=i; get_env_char(bd, nxt) != '\0'; ++nxt)
;
for (k=i; k<nxt; ++k)
putc(get_env_char(bd, k));
putc ('\n');
if (ctrlc()) {
printf ("\n ** Abort\n");
return 1;
}
}
printf("\nEnvironment size: %d/%d bytes\n", i, sizeof(bd->bi_env_data));
return 0;
}
for (i=1; i<argc; ++i) { /* print single env variables */
char *name = argv[i];
k = -1;
for (j=0; get_env_char(bd, j) != '\0'; j=nxt+1) {
for (nxt=j; get_env_char(bd, nxt) != '\0'; ++nxt)
;
k = envmatch(bd, name, j);
if (k < 0) {
continue;
}
puts (name);
putc ('=');
while (k < nxt)
putc(get_env_char(bd, k++));
putc ('\n');
break;
}
if (k < 0)
{
printf ("## Error: \"%s\" not defined\n", name);
return 1;
}
}
return 0;
}
开发者ID:qgp,项目名称:armboot,代码行数:51,代码来源:cmd_nvedit.c
示例6: 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;
}
开发者ID:John677,项目名称:Kernal_k3note,代码行数:15,代码来源:env.c
示例7: return
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);
}
开发者ID:CobraJet93,项目名称:kernel-3.10.54,代码行数:16,代码来源:sysenv.c
示例8: return
char *getenv (bd_t * bd, uchar *name)
{
int i, nxt;
for (i=0; get_env_char(bd, i) != '\0'; i=nxt+1) {
int val;
for (nxt=i; get_env_char(bd, nxt) != '\0'; ++nxt) {
if (nxt >= sizeof(bd->bi_env_data)) {
return (NULL);
}
}
if ((val=envmatch(bd, name, i)) < 0)
continue;
return (get_env_addr(bd, val));
}
return (NULL);
}
开发者ID:qgp,项目名称:armboot,代码行数:19,代码来源:cmd_nvedit.c
示例9: 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;
}
开发者ID:105678256,项目名称:u-boot-2010.09,代码行数:49,代码来源:api.c
示例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;
}
}
开发者ID:mausvt,项目名称:seagate_central_cns3420_2-6-35,代码行数:40,代码来源:rtc-nvedit.c
示例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);
}
开发者ID:4Fwolf,项目名称:signal75-kernel-3.10.61,代码行数:22,代码来源:env.c
示例12: defined
char *getenv (uchar *name)
{
uchar *env, *nxt;
#if defined(CFG_FLASH_ENV_ADDR)
uchar *environment = env_init();
#else
env_init();
#endif /* CFG_FLASH_ENV_ADDR */
for (env=environment; *env; env=nxt+1) {
char *val;
for (nxt=env; *nxt; ++nxt)
;
val=envmatch(name, env);
if (!val)
continue;
return (val);
}
return (NULL);
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:23,代码来源:cmd_nvedit.c
示例13: 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;
}
开发者ID:247a,项目名称:lenovo_b6000-8000_kernel_source,代码行数:41,代码来源:cmd_nvedit.c
示例14: set_env
int set_env(char *name,char *value)
{
int len;
int oldval = -1;
char *env, *nxt = NULL;
int ret = 0;
char *env_data = NULL;
pr_notice("[%s]set env, name=%s,value=%s\n",
MODULE_NAME, name, value);
env_init();
env_data = g_env.env_data;
if (!env_buffer) {
return (-1);
}
if (!env_valid) {
env = env_data;
goto add;
}
/* find match name and return the val header pointer*/
for (env = env_data; *env; env = nxt + 1) {
for (nxt=env; *nxt; ++nxt) {
;
}
if ((oldval = envmatch((char *)name, env-env_data)) >= 0)
break;
}/* end find */
if (oldval>0) {
if (*++nxt == '\0') {
if (env > env_data) {
env--;
} else {
*env = '\0';
}
} else {
for (;;) {
*env = *nxt++;
if ((*env == '\0') && (*nxt == '\0'))
break;
++env;
}
}
*++env = '\0';
}
for (env=env_data; *env || *(env+1); ++env) {
;
}
if (env > env_data) {
++env;
}
add:
if (*value == '\0') {
pr_notice("[%s]clear env name=%s\n",
MODULE_NAME, name);
goto write_env;
}
len = strlen(name) + 2;
len += strlen(value) + 1;
if (len > (&env_data[CFG_ENV_DATA_SIZE] - env)) {
pr_err("[%s]env data overflow, %s deleted\n",
MODULE_NAME, name);
return -1;
}
while ((*env = *name++) != '\0') {
env++;
}
*env = '=';
while ((*++env = *value++) != '\0') {
;
}
write_env:
/* end is marked with double '\0' */
*++env = '\0';
memset(env, 0x00, CFG_ENV_DATA_SIZE - (env - env_data));
ret = write_env_area(env_buffer);
if (ret < 0) {
pr_err("[%s]%s error: write env area fail\n",
MODULE_NAME, __FUNCTION__);
memset(env_buffer, 0x00, CFG_ENV_SIZE);
return -1;
}
env_valid = 1;
return 0;
}
开发者ID:CobraJet93,项目名称:kernel-3.10.54,代码行数:88,代码来源:sysenv.c
示例15: set_env
int set_env(char *name,char *value)
{
int len, oldval;
char *env, *nxt = NULL;
int ret;
char *env_data = g_env.env_data;
printk("[%s]set_env %s %s\n",MODULE_NAME,name,value);
oldval = -1;
if(!env_buffer){
return -1;
}
if(!env_valid){
env = env_data;
goto add;
}
for (env=env_data; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
if ((oldval = envmatch((char *)name, env-env_data)) >= 0)
break;
}
if(oldval>0){
if (*++nxt == '\0') {
if (env > env_data) {
env--;
} else {
*env = '\0';
}
} else {
for (;;) {
*env = *nxt++;
if ((*env == '\0') && (*nxt == '\0'))
break;
++env;
}
}
*++env = '\0';
}
for (env=env_data; *env || *(env+1); ++env)
;
if (env > env_data)
++env;
add:
if(*value == '\0'){
printk("[LK_ENV]clear %s\n",name);
goto write_env;
}
/*
* Overflow when:
* "name" + "=" + "val" +"\0\0" > ENV_SIZE - (env-env_data)
*/
len = strlen(name) + 2;
/* add '=' for first arg, ' ' for all others */
len += strlen(value) + 1;
if (len > (&env_data[CFG_ENV_DATA_SIZE]-env)) {
printk ("## Error: environment overflow, \"%s\" deleted\n", name);
return -1;
}
while ((*env = *name++) != '\0')
env++;
*env = '=';
while ((*++env = *value++) != '\0')
;
write_env:
/* end is marked with double '\0' */
*++env = '\0';
memset(env,0x00,CFG_ENV_DATA_SIZE-(env-env_data));
ret = write_env_area(env_buffer);
if(ret < 0){
printk("[%s]write env fail\n",MODULE_NAME);
memset(env_buffer,0x00,CFG_ENV_SIZE);
return -1;
}
env_valid = 1;
return 0;
}
开发者ID:4Fwolf,项目名称:signal75-kernel-3.10.61,代码行数:90,代码来源:env.c
示例16: _do_setenv
void _do_setenv (bd_t *bd, int flag, int argc, char *argv[])
{
int i, len;
int console = -1;
uchar *env, *nxt;
uchar *oldval = NULL;
uchar *name;
#if defined(CFG_FLASH_ENV_ADDR)
uchar *environment = env_init();
ulong real_env_size = env_size;
ulong env_size = real_env_size - sizeof (ulong);
#else
env_init();
#endif /* CFG_FLASH_ENV_ADDR */
name = argv[1];
/*
* search if variable with this name already exists
*/
for (env=environment; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
if ((oldval=envmatch(name, env)) != NULL)
break;
}
/*
* Delete any existing definition
*/
if (oldval) {
#ifndef CONFIG_ENV_OVERWRITE
/*
* Ethernet Address and serial# can be set only once
*/
if ((strcmp (name, "ethaddr") == 0) ||
(strcmp (name, "serial#") == 0) ) {
printf ("Can't overwrite \"%s\"\n", name);
return;
}
#endif
/* Check for console redirection */
if (strcmp(name,"stdin") == 0) {
console = stdin;
} else if (strcmp(name,"stdout") == 0) {
console = stdout;
} else if (strcmp(name,"stderr") == 0) {
console = stderr;
}
if (console != -1) {
if (argc < 3) /* Cannot delete it! */
return;
/* Try assigning specified device */
if (console_assign (console, argv[2]) < 0)
return;
}
if (*++nxt == '\0') {
*env = '\0';
} else {
for (;;) {
*env = *nxt++;
if ((*env == '\0') && (*nxt == '\0'))
break;
++env;
}
}
*++env = '\0';
}
#if defined(CFG_FLASH_ENV_ADDR)
MAKEVALID(environment, real_env_size);
#endif /* CFG_FLASH_ENV_ADDR */
/* Delete only ? */
if (argc < 3)
return;
/*
* Append new definition at the end
*/
for (env=environment; *env || *(env+1); ++env)
;
if (env > environment)
++env;
/*
* Overflow when:
* "name" + "=" + "val" +"\0\0" > env_size - (env-environment)
*/
len = strlen(name) + 2;
/* add '=' for first arg, ' ' for all others */
for (i=2; i<argc; ++i) {
len += strlen(argv[i]) + 1;
}
if (len > (&environment[env_size]-env)) {
printf ("## Error: environment overflow, \"%s\" deleted\n", name);
//.........这里部分代码省略.........
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:101,代码来源:cmd_nvedit.c
示例17: __do_env_set_parameter
void __do_env_set_parameter(env_t *nvm, const char *key, const char *value)
{
int i, len, oldval;
unsigned char *env, *nxt = NULL;
//char *name = "ethaddr";
unsigned char *env_data = nvm->data;
/*
* search if variable with this name already exists
*/
oldval = -1;
for (env=env_data; *env; env=nxt+1)
{
for (nxt=env; *nxt; ++nxt)
;
if ((oldval = envmatch((unsigned char *)key, env-env_data, env_data)) >= 0)
break;
}
/*
* Delete any existing definition
*/
if (oldval >= 0)
{
if (*++nxt == '\0')
{
if (env > env_data) {
env--;
}
else
{
*env = '\0';
}
}
else
{
for (;;)
{
*env = *nxt++;
if ((*env == '\0') && (*nxt == '\0'))
break;
++env;
}
}
*++env = '\0';
}
/*
* Append new definition at the end
*/
for (env=env_data; *env || *(env+1); ++env)
;
if (env > env_data)
++env;
/*
* Overflow when:
* "name" + "=" + "val" +"\0\0" > ENV_SIZE - (env-env_data)
*/
len = strlen(key) + 2;
len += strlen(value) + 1;
if (len > (&env_data[ENV_SIZE]-env)) {
printf ("## Error: environment overflow, \"%s\" deleted\n", key);
return;
}
while ((*env = *key++) != '\0')
env++;
*env = '=';
while ((*++env = *value++) != '\0')
;
/* end is marked with double '\0' */
*++env = '\0';
}
开发者ID:Undrizzle,项目名称:apps,代码行数:74,代码来源:nvm-utils.c
示例18: _do_setenv
int _do_setenv (bd_t *bd, int flag, int argc, char *argv[])
{
int i, len, oldval;
uchar *env, *nxt = 0;
uchar *name;
/* need writable copy in RAM */
if (!bd->bi_env_data)
return 1;
name = argv[1];
/*
* search if variable with this name already exists
*/
oldval = -1;
for (env = bd->bi_env_data; *env; env = nxt+1) {
for (nxt = env; *nxt; ++nxt)
;
if ((oldval = envmatch(bd, name, (ulong)env - (ulong)bd->bi_env_data)) >= 0)
break;
}
/*
* Delete any existing definition
*/
if (oldval >= 0) {
#ifndef CONFIG_ENV_OVERWRITE
/*
* Ethernet Address and serial# can be set only once
*/
if ( (strcmp (name, "serial#") == 0) ||
((strcmp (name, "ethaddr") == 0)
# if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
&& (strcmp (get_env_addr(bd, oldval),MK_STR(CONFIG_ETHADDR)) != 0)
# endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
) ) {
printf ("Can't overwrite \"%s\"\n", name);
return 1;
}
#endif
/*
* Switch to new baudrate if new baudrate is supported
*/
if (strcmp(argv[1],"baudrate") == 0) {
int baudrate = simple_strtoul(argv[2], NULL, 10);
int i;
for (i=0; i<N_BAUDRATES; ++i) {
if (baudrate == baudrate_table[i])
break;
}
if (i == N_BAUDRATES) {
printf ("## Baudrate %d bps not supported\n",
baudrate);
return 1;
}
printf ("## Switch baudrate to %d bps and press ENTER ...\n",
baudrate);
udelay(50000);
serial_setbrg (bd, baudrate);
udelay(50000);
for (;;) {
if (getc() == '\r')
break;
}
bd->bi_baudrate = baudrate;
}
if (*++nxt == '\0') {
if ((ulong)env > (ulong)bd->bi_env_data) {
env--;
} else {
*env = '\0';
}
} else {
for (;;) {
*env = *nxt++;
if ((*env == '\0') && (*nxt == '\0'))
break;
++env;
}
}
*++env = '\0';
}
/* Delete only ? */
if ((argc < 3) || argv[2] == NULL) {
/* Update CRC */
bd->bi_env_crc = crc32(0, bd->bi_env_data, sizeof(bd->bi_env_data));
return 0;
}
/*
* Append new definition at the end
*/
for (env = bd->bi_env_data; *env || *(env+1); ++env)
;
if ((ulong)env > (ulong)bd->bi_env_data)
++env;
//.........这里部分代码省略.........
开发者ID:qgp,项目名称:armboot,代码行数:101,代码来源:cmd_nvedit.c
注:本文中的envmatch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论