本文整理汇总了C++中env_set函数的典型用法代码示例。如果您正苦于以下问题:C++ env_set函数的具体用法?C++ env_set怎么用?C++ env_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了env_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: last_stage_init
int last_stage_init(void)
{
#if defined(CONFIG_KMCOGE4)
/* on KMCOGE4, the BFTIC4 is on the LBAPP2 */
struct bfticu_iomap *bftic4 =
(struct bfticu_iomap *)CONFIG_SYS_LBAPP2_BASE;
u8 dip_switch = in_8((u8 *)&(bftic4->mswitch)) & BFTICU_DIPSWITCH_MASK;
if (dip_switch != 0) {
/* start bootloader */
puts("DIP: Enabled\n");
env_set("actual_bank", "0");
}
#endif
set_km_env();
return 0;
}
示例2: try_userprofile_envvar_for_home
/* tries to use USERPROFILE environment variable to find home directory */
static int
try_userprofile_envvar_for_home(void)
{
LOG_FUNC_ENTER;
#ifndef _WIN32
return 0;
#else
char home[PATH_MAX];
const char *userprofile = env_get("USERPROFILE");
if(userprofile == NULL || !is_dir(userprofile))
return 0;
snprintf(home, sizeof(home), "%s", userprofile);
to_forward_slash(home);
env_set(HOME_EV, home);
return 1;
#endif
}
示例3: main
int main()
{
const char *ret;
size_t len;
env_set("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
"key3;:,:=;key4", 1);
ret = hwconfig_arg("key1", &len);
printf("%zd %.*s\n", len, (int)len, ret);
assert(len == 29);
assert(hwconfig_arg_cmp("key1", "subkey1=value1,subkey2=value2"));
assert(!strncmp(ret, "subkey1=value1,subkey2=value2", len));
ret = hwconfig_subarg("key1", "subkey1", &len);
printf("%zd %.*s\n", len, (int)len, ret);
assert(len == 6);
assert(hwconfig_subarg_cmp("key1", "subkey1", "value1"));
assert(!strncmp(ret, "value1", len));
ret = hwconfig_subarg("key1", "subkey2", &len);
printf("%zd %.*s\n", len, (int)len, ret);
assert(len == 6);
assert(hwconfig_subarg_cmp("key1", "subkey2", "value2"));
assert(!strncmp(ret, "value2", len));
ret = hwconfig_arg("key2", &len);
printf("%zd %.*s\n", len, (int)len, ret);
assert(len == 6);
assert(hwconfig_arg_cmp("key2", "value3"));
assert(!strncmp(ret, "value3", len));
assert(hwconfig("key3"));
assert(hwconfig_arg("key4", &len) == NULL);
assert(hwconfig_arg("bogus", &len) == NULL);
unenv_set("hwconfig");
assert(hwconfig(NULL) == 0);
assert(hwconfig("") == 0);
assert(hwconfig("key3") == 0);
return 0;
}
示例4: try_exe_directory_for_vifmrc
/* tries to use vifmrc in directory of executable file as configuration file */
static int
try_exe_directory_for_vifmrc(void)
{
LOG_FUNC_ENTER;
#ifndef _WIN32
return 0;
#else
char vifmrc[PATH_MAX];
GetModuleFileNameA(NULL, vifmrc, sizeof(vifmrc));
to_forward_slash(vifmrc);
*strrchr(vifmrc, '/') = '\0';
strcat(vifmrc, "/" VIFMRC);
if(!path_exists(vifmrc))
return 0;
env_set(MYVIFMRC_EV, vifmrc);
return 1;
#endif
}
示例5: strm_var_set
int
strm_var_set(strm_state* state, strm_string* name, strm_value val)
{
strm_env *e;
if (!state) {
if (!globals) {
globals = kh_init(env);
}
e = globals;
}
else {
if (!state->env) {
state->env = kh_init(env);
}
e = state->env;
}
return env_set(e, name, val);
}
示例6: board_late_init
int board_late_init(void)
{
if (gpio_request(HOT_WATER_BUTTON, "hot-water-button") < 0) {
puts("Failed to get hot-water-button pin\n");
return -ENODEV;
}
gpio_direction_input(HOT_WATER_BUTTON);
/*
* if hot-water-button is pressed
* change bootcmd
*/
if (gpio_get_value(HOT_WATER_BUTTON))
return 0;
env_set("bootcmd", "run swupdate");
return 0;
}
示例7: add_to_path
/* Adds a path to PATH environment variable. */
static void
add_to_path(const char *path)
{
const char *old_path;
char *new_path;
old_path = env_get("PATH");
new_path = malloc(strlen(path) + 1 + strlen(old_path) + 1);
#ifndef _WIN32
sprintf(new_path, "%s:%s", path, old_path);
#else
sprintf(new_path, "%s;%s", path, old_path);
to_back_slash(new_path);
#endif
env_set("PATH", new_path);
free(new_path);
}
示例8: board_late_init
int board_late_init(void)
{
int ret;
char tmp[2 * MAX_STRING_LENGTH + 2];
omap_nand_switch_ecc(1, 8);
if (factory_dat.asn[0] != 0)
sprintf(tmp, "%s_%s", factory_dat.asn,
factory_dat.comp_version);
else
strcpy(tmp, "QMX7.E38_4.0");
ret = env_set("boardid", tmp);
if (ret)
printf("error setting board id\n");
return 0;
}
示例9: dm_test_eth_act
/**
* This test case is trying to test the following scenario:
* - All ethernet devices are not probed
* - "ethaddr" for all ethernet devices are not set
* - "ethact" is set to a valid ethernet device name
*
* With Sandbox default test configuration, all ethernet devices are
* probed after power-up, so we have to manually create such scenario:
* - Remove all ethernet devices
* - Remove all "ethaddr" environment variables
* - Set "ethact" to the first ethernet device
*
* Do a ping test to see if anything goes wrong.
*/
static int dm_test_eth_act(struct unit_test_state *uts)
{
struct udevice *dev[DM_TEST_ETH_NUM];
const char *ethname[DM_TEST_ETH_NUM] = {"[email protected]", "[email protected]",
"sbe5", "[email protected]"};
const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr",
"eth3addr", "eth1addr"};
char ethaddr[DM_TEST_ETH_NUM][18];
int i;
memset(ethaddr, '\0', sizeof(ethaddr));
net_ping_ip = string_to_ip("1.1.2.2");
/* Prepare the test scenario */
for (i = 0; i < DM_TEST_ETH_NUM; i++) {
ut_assertok(uclass_find_device_by_name(UCLASS_ETH,
ethname[i], &dev[i]));
ut_assertok(device_remove(dev[i], DM_REMOVE_NORMAL));
/* Invalidate MAC address */
strncpy(ethaddr[i], env_get(addrname[i]), 17);
/* Must disable access protection for ethaddr before clearing */
env_set(".flags", addrname[i]);
env_set(addrname[i], NULL);
}
/* Set ethact to "[email protected]" */
env_set("ethact", ethname[0]);
/* Segment fault might happen if something is wrong */
ut_asserteq(-ENODEV, net_loop(PING));
for (i = 0; i < DM_TEST_ETH_NUM; i++) {
/* Restore the env */
env_set(".flags", addrname[i]);
env_set(addrname[i], ethaddr[i]);
/* Probe the device again */
ut_assertok(device_probe(dev[i]));
}
env_set(".flags", NULL);
env_set("ethact", NULL);
return 0;
}
示例10: board_late_init
int board_late_init(void)
{
#if (defined(CONFIG_KM_COGE5UN) | defined(CONFIG_KM_MGCOGE3UN))
u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
/* if pin 1 do full erase */
if (dip_switch != 0) {
/* start bootloader */
puts("DIP: Enabled\n");
env_set("actual_bank", "0");
}
#endif
#if defined(CONFIG_KM_FPGA_CONFIG)
wait_for_fpga_config();
fpga_reset();
toggle_eeprom_spi_bus();
#endif
return 0;
}
示例11: try_exe_directory_for_conf
/* Tries to use directory of executable file as configuration directory.
* Returns non-zero on success, otherwise zero is returned. */
static int
try_exe_directory_for_conf(void)
{
LOG_FUNC_ENTER;
char exe_dir[PATH_MAX + 1];
if(get_exe_dir(exe_dir, sizeof(exe_dir)) != 0)
{
return 0;
}
if(!path_exists_at(exe_dir, VIFMRC, DEREF))
{
return 0;
}
env_set(VIFM_EV, exe_dir);
return 1;
}
示例12: board_late_init
int board_late_init(void)
{
setup_board_eeprom_env();
u8 val;
/*
* DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
* This is the POWERHOLD-in-Low behavior.
*/
palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);
/*
* Default FIT boot on HS devices. Non FIT images are not allowed
* on HS devices.
*/
if (get_device_type() == HS_DEVICE)
env_set("boot_fit", "1");
/*
* Set the GPIO7 Pad to POWERHOLD. This has higher priority
* over DEV_CTRL.DEV_ON bit. This can be reset in case of
* PMIC Power off. So to be on the safer side set it back
* to POWERHOLD mode irrespective of the current state.
*/
palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
&val);
val = val | TPS65903X_PAD2_POWERHOLD_MASK;
palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
val);
omap_die_id_serial();
omap_set_fastboot_vars();
am57x_idk_lcd_detect();
#if !defined(CONFIG_SPL_BUILD)
board_ti_set_ethaddr(2);
#endif
return 0;
}
示例13: board_late_init
int board_late_init(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
char *name = "unknown";
if (is_dra72x()) {
if (board_is_dra72x_revc_or_later())
name = "dra72x-revc";
else if (board_is_dra71x_evm())
name = "dra71x";
else
name = "dra72x";
} else if (is_dra76x_abz()) {
name = "dra76x_abz";
} else if (is_dra76x_acd()) {
name = "dra76x_acd";
} else {
name = "dra7xx";
}
set_board_info_env(name);
/*
* Default FIT boot on HS devices. Non FIT images are not allowed
* on HS devices.
*/
if (get_device_type() == HS_DEVICE)
env_set("boot_fit", "1");
omap_die_id_serial();
omap_set_fastboot_vars();
/*
* Hook the LDO1 regulator to EN pin. This applies only to LP8733
* Rest all regulators are hooked to EN Pin at reset.
*/
if (board_is_dra71x_evm())
palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
#endif
return 0;
}
示例14: dm_test_eth_rotate
static int dm_test_eth_rotate(struct unit_test_state *uts)
{
char ethaddr[18];
int retval;
/* Set target IP to mock ping */
net_ping_ip = string_to_ip("1.1.2.2");
/* Invalidate eth1's MAC address */
memset(ethaddr, '\0', sizeof(ethaddr));
strncpy(ethaddr, env_get("eth1addr"), 17);
/* Must disable access protection for eth1addr before clearing */
env_set(".flags", "eth1addr");
env_set("eth1addr", NULL);
retval = _dm_test_eth_rotate1(uts);
/* Restore the env */
env_set("eth1addr", ethaddr);
env_set("ethrotate", NULL);
if (!retval) {
/* Invalidate eth0's MAC address */
strncpy(ethaddr, env_get("ethaddr"), 17);
/* Must disable access protection for ethaddr before clearing */
env_set(".flags", "ethaddr");
env_set("ethaddr", NULL);
retval = _dm_test_eth_rotate2(uts);
/* Restore the env */
env_set("ethaddr", ethaddr);
}
/* Restore the env */
env_set(".flags", NULL);
return retval;
}
示例15: create_config_dir
/* ensures existence of configuration directory */
static void
create_config_dir(void)
{
LOG_FUNC_ENTER;
/* ensure existence of configuration directory */
if(!is_dir(cfg.config_dir))
{
#ifndef _WIN32
FILE *f;
char help_file[PATH_MAX];
char rc_file[PATH_MAX];
if(make_dir(cfg.config_dir, 0777) != 0)
return;
snprintf(help_file, sizeof(help_file), "%s/" VIFM_HELP, cfg.config_dir);
if((f = fopen(help_file, "r")) == NULL)
create_help_file();
else
fclose(f);
snprintf(rc_file, sizeof(rc_file), "%s/" VIFMRC, cfg.config_dir);
if((f = fopen(rc_file, "r")) == NULL)
create_rc_file();
else
fclose(f);
/* This should be first start of Vifm, ensure that newly created sample
* vifmrc file is used right away. */
env_set(MYVIFMRC_EV, rc_file);
#else
if(make_dir(cfg.config_dir, 0777) != 0)
return;
#endif
add_default_bookmarks();
}
}