void proc(const std::string& init_data_path, bool force_cornif,bool use_last = false, const std::string& init_uvp_data = "", const std::string& init_w_data = ""){ env_check(); CellDataMan cm; cm.init(init_data_path, use_last, init_uvp_data, init_w_data); make_dir(OUTPUT_DIR); int num_sc = 0; auto start = std::chrono::system_clock::now(); cm.check_initialized(); }
t_system init_system(char **env) { t_system rtn; rtn.env = env_check(env); rtn.quit = 0; rtn.wait = 1; rtn.promp = 1; rtn.last_rtn = 0; rtn.child_pid = 0; rtn.history = NULL; rtn.alias = NULL; return (rtn); }
/** @SYMTestCaseID SYSLIB-STDLIB-CT-1070 @SYMTestCaseDesc Tests for environment variables @SYMTestPriority High @SYMTestActions Tests for getting and setting the environment variables @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void environment() { char* value; int ret; test_Next("Environment variables"); value=getenv("not_present"); test(value==0); ret=setenv("TEST1","value1",0); test(ret==0); value=getenv("not_present"); test(value==0); env_check("TEST1","value1"); ret=setenv("TEST2","value2",0); test(ret==0); env_check("TEST2","value2"); unsetenv("not_present"); env_check("TEST1","value1"); env_check("TEST2","value2"); ret=setenv("TEST1","different_value",0); /* no rewrite */ test(ret==0); /* apparently this isn't an error */ env_check("TEST1","value1"); env_check("TEST2","value2"); ret=setenv("TEST1","different_value",1); /* with rewrite */ test(ret==0); env_check("TEST1","different_value"); env_check("TEST2","value2"); ret=setenv("TEST2","value2.1",1); test(ret==0); env_check("TEST1","different_value"); env_check("TEST2","value2.1"); unsetenv("TEST1"); value=getenv("TEST1"); test(value==0); env_check("TEST2","value2.1"); ret=setenv("TEST1","a third value which is a really long one so I can force it to realloc some more memory when it does the conversion",0); test(ret==0); env_check("TEST1","a third value which is a really long one so I can force it to realloc some more memory when it does the conversion"); env_check("TEST2","value2.1"); }
int main(int argc, char *argv[]) { FILE *f = NULL; int count; int err = 0; int len; int idx; int i; char *name; char *value; init_private(); f = fopen(BOOTENV_MMCBLK, "rb+"); if (NULL==f) { println("can not open " BOOTENV_MMCBLK); err = -1; goto exit; } if (env_read(f)) { err = -1; goto exit; } /* * display all */ if (1==argc) { for (i=1; i<AT_ENV_COUNT; i++) { if (bootenv[i][0] && !(ENV_HIDDEN & envctl[i].flag)) { println("%s=%s", envctl[i].name, bootenv[i]); } } err = 0; goto exit; } else if (2==argc) { char *name = argv[1]; /* * help */ if (0==strcmp("-h", name) || 0==strcmp("--help", name)) { usage(argc, argv); err = 0; goto exit; } /* * get by name */ else if (NULL==strchr(name, '=')) { value = getvalue_byname(name); if (NULL==value) { println("argv[1](%s) bad name", name); err = -1; } else if (0==value[0]) { /* empty */ err = 0; } else { println("%s", value); err = 0; } goto exit; } } /* * set by name */ for (i=1; i<argc; i++) { char line[2*AT_ENV_LINE_SIZE] = {0}; len = strlen(argv[i]); /* * check input length */ if (len > (2*AT_ENV_LINE_SIZE-1)) { println("argv[%d](%s) too long", i, argv[i]); err = -1; goto exit; } strcpy(line, argv[i]); /* * get name */ name = line; value = strchr(line, '='); if (NULL==value) { println("argv[%d](%s) should as xxx=xxxx", i, argv[i]); err = -1; goto exit; } *value = 0; value++; /* * check name */ idx = getidx_byname(name); if (idx<0) { println("argv[%d](%s) bad name(%s)", i, argv[i], name); err = -1; goto exit; } /* * check value */ if (0==value[0]) { bootenv[idx][0] = 0; } else if (strlen(value) > (AT_ENV_LINE_SIZE-1)) { println("argv[%d](%s) value length max %d", i, argv[i], (AT_ENV_LINE_SIZE-1)); err = -1; goto exit; } else if (env_check(idx, value) < 0) { println("argv[%d](%s) value is invalid", i, argv[i]); err = -1; goto exit; } else if (ENV_READONLY & envctl[idx].flag) { println("argv[%d](%s) is readonly", i, argv[i]); err = -1; goto exit; } else { strcpy(bootenv[idx], value); envctl[idx].flag |= ENV_CHANGED; } } if (env_write(f)) { err = -1; goto exit; } exit: fclose(f); return err; }