static wbt_status wbt_save_argv(int argc, char** argv) { size_t len; int i; wbt_argc = argc; wbt_os_argv = argv; wbt_mem_t tmp_buf; if (wbt_malloc(&tmp_buf, (argc + 1) * sizeof(char *)) != WBT_OK) { return WBT_ERROR; } wbt_argv = tmp_buf.ptr; for (i = 0; i < argc; i++) { len = wbt_strlen(argv[i]) + 1; if(wbt_malloc(&tmp_buf, len) != WBT_OK) { return WBT_ERROR; } wbt_argv[i] = tmp_buf.ptr; memcpy((u_char *) wbt_argv[i], (u_char *) argv[i], len); } wbt_argv[i] = NULL; wbt_os_environ = environ; return WBT_OK; }
wbt_status wbt_conf_set_file( const char * file ) { wbt_config_file_name.str = (char *)file; /* 这个类型转换只是为了避免编译器报 * 错,不允许通过该指针进行写操作 */ wbt_config_file_name.len = wbt_strlen(file); return WBT_OK; }