void builtin_read_exec_build_vars_from_line( t_argparser_result *arg_res, char *line, char *ifs) { t_lst *vars_copy; char *var; char *value; char *tmp; char *tmp_end; vars_copy = twl_lst_copy(arg_res->remainders, NULL); tmp = line; while ((var = twl_lst_pop_front(vars_copy))) { if (*tmp && twl_strchr(ifs, *tmp)) tmp++; tmp_end = strchr_mult(tmp, ifs, arg_res); builtin_read_loop_content(vars_copy, &value, tmp, tmp_end); tmp += twl_strlen(value); set_env_var(var, value, arg_res); free(value); if (!tmp_end) break ; } while ((var = twl_lst_pop_front(vars_copy))) set_env_var(var, "", arg_res); twl_lst_del(vars_copy, NULL); }
int main() { // FIXME: Can this be passed to all tests through some Autotools magic? set_env_var("CANGJIE_DB", CANGJIE_DB); test_cangjie_new(); test_cangjie_get_characters_single_result(); test_cangjie_get_characters_multiple_queries(); return 0; }
static bool do_change_version(atrt_config& config, SqlResultSet& command, AtrtClient& atrtdb){ /** * TODO make option to restart "not" initial */ uint process_id= command.columnAsInt("process_id"); const char* process_args= command.column("process_args"); g_logger.info("Change version for process: %d, args: %s", process_id, process_args); // Get the process if (process_id > config.m_processes.size()){ g_logger.critical("Invalid process id %d", process_id); return false; } atrt_process& proc= *config.m_processes[process_id]; const char* new_prefix= g_prefix1 ? g_prefix1 : g_prefix; const char* old_prefix= g_prefix; const char *start= strstr(proc.m_proc.m_path.c_str(), old_prefix); if (!start){ /* Process path does not contain old prefix. * Perhaps it contains the new prefix - e.g. is already * upgraded? */ if (strstr(proc.m_proc.m_path.c_str(), new_prefix)) { /* Process is already upgraded, *assume* that this * is ok * Alternatives could be - error, or downgrade. */ g_logger.info("Process already upgraded"); return true; } g_logger.critical("Could not find '%s' in '%s'", old_prefix, proc.m_proc.m_path.c_str()); return false; } // Save current proc state if (proc.m_save.m_saved == false) { proc.m_save.m_proc= proc.m_proc; proc.m_save.m_saved= true; } g_logger.info("stopping process..."); if (!stop_process(proc)) return false; BaseString newEnv = set_env_var(proc.m_proc.m_env, BaseString("MYSQL_BASE_DIR"), BaseString(new_prefix)); proc.m_proc.m_env.assign(newEnv); BaseString suffix(proc.m_proc.m_path.substr(strlen(old_prefix))); proc.m_proc.m_path.assign(new_prefix).append(suffix); if (process_args && strlen(process_args)) { /* Beware too long args */ proc.m_proc.m_args.append(" "); proc.m_proc.m_args.append(process_args); } ndbout << proc << endl; g_logger.info("starting process..."); if (!start_process(proc)) return false; return true; }
static bool do_change_version(atrt_config& config, SqlResultSet& command, AtrtClient& atrtdb){ /** * TODO make option to restart "not" initial */ uint process_id= command.columnAsInt("process_id"); const char* process_args= command.column("process_args"); g_logger.info("Change version for process: %d, args: %s", process_id, process_args); // Get the process if (process_id > config.m_processes.size()){ g_logger.critical("Invalid process id %d", process_id); return false; } atrt_process& proc= *config.m_processes[process_id]; const char* new_prefix= g_prefix1 ? g_prefix1 : g_prefix; const char* old_prefix= g_prefix; const char *start= strstr(proc.m_proc.m_path.c_str(), old_prefix); if (!start){ /* Process path does not contain old prefix. * Perhaps it contains the new prefix - e.g. is already * upgraded? */ if (strstr(proc.m_proc.m_path.c_str(), new_prefix)) { /* Process is already upgraded, *assume* that this * is ok * Alternatives could be - error, or downgrade. */ g_logger.info("Process already upgraded"); return true; } g_logger.critical("Could not find '%s' in '%s'", old_prefix, proc.m_proc.m_path.c_str()); return false; } // Save current proc state if (proc.m_save.m_saved == false) { proc.m_save.m_proc= proc.m_proc; proc.m_save.m_saved= true; } g_logger.info("stopping process..."); if (!stop_process(proc)) return false; BaseString newEnv = set_env_var(proc.m_proc.m_env, BaseString("MYSQL_BASE_DIR"), BaseString(new_prefix)); proc.m_proc.m_env.assign(newEnv); ssize_t pos = proc.m_proc.m_path.lastIndexOf('/') + 1; BaseString exename(proc.m_proc.m_path.substr(pos)); char * exe = find_bin_path(new_prefix, exename.c_str()); proc.m_proc.m_path = exe; if (exe) { free(exe); } if (process_args && strlen(process_args)) { /* Beware too long args */ proc.m_proc.m_args.append(" "); proc.m_proc.m_args.append(process_args); } { /** * In 5.5...binaries aren't compiled with rpath * So we need an explicit LD_LIBRARY_PATH * So when upgrading..we need to change LD_LIBRARY_PATH * So I hate 5.5... */ #if defined(__MACH__) ssize_t p0 = proc.m_proc.m_env.indexOf(" DYLD_LIBRARY_PATH="); #else ssize_t p0 = proc.m_proc.m_env.indexOf(" LD_LIBRARY_PATH="); #endif ssize_t p1 = proc.m_proc.m_env.indexOf(' ', p0 + 1); BaseString part0 = proc.m_proc.m_env.substr(0, p0); BaseString part1 = proc.m_proc.m_env.substr(p1); proc.m_proc.m_env.assfmt("%s%s", part0.c_str(), part1.c_str()); BaseString lib(g_libmysqlclient_so_path); ssize_t pos = lib.lastIndexOf('/') + 1; BaseString libname(lib.substr(pos)); char * exe = find_bin_path(new_prefix, libname.c_str()); char * dir = dirname(exe); #if defined(__MACH__) proc.m_proc.m_env.appfmt(" DYLD_LIBRARY_PATH=%s", dir); #else proc.m_proc.m_env.appfmt(" LD_LIBRARY_PATH=%s", dir); #endif free(exe); free(dir); } ndbout << proc << endl; g_logger.info("starting process..."); if (!start_process(proc)) return false; return true; }