コード例 #1
0
ファイル: s7_text.cpp プロジェクト: GermanBluefox/ioBroker.s7
//---------------------------------------------------------------------------
BaseString NumToString(int Value, int Base, unsigned int Len)
{
	char CNumber[50];
	BaseString result;
	itoa(Value,CNumber,Base);
	result.assign(CNumber);
	if (Len>0)
	{
		while (result.length()<Len)
            result="0"+result;
	}
	return result;
}
コード例 #2
0
ファイル: common.cpp プロジェクト: 4T-Shirt/mysql
int
insert_file(FILE * f, class Properties& p, bool break_on_empty){
  if(f == 0)
    return -1;

  while(!feof(f)){
    char buf[1024];
    fgets(buf, 1024, f);
    BaseString tmp = buf;

    if(tmp.length() > 0 && tmp.c_str()[0] == '#')
      continue;

    if(insert(tmp.c_str(), p) != 0 && break_on_empty)
      break;
  }

  return 0;
}
コード例 #3
0
static 
bool 
pr_fix_ndb_connectstring(Properties& props, proc_rule_ctx& ctx, int)
{
  const char * val;
  atrt_cluster& cluster = *ctx.m_cluster;

  if (cluster.m_options.m_features & atrt_options::AO_NDBCLUSTER)
  {
    if (!cluster.m_options.m_loaded.get(ndbcs, &val))
    {
      /**
       * Construct connect string for this cluster
     */
      BaseString str;
      for (unsigned i = 0; i<cluster.m_processes.size(); i++)
      {
	atrt_process* tmp = cluster.m_processes[i];
	if (tmp->m_type == atrt_process::AP_NDB_MGMD)
	{
	  if (str.length())
	  {
	    str.append(";");
	  }
	  const char * port;
	  require(tmp->m_options.m_loaded.get("--PortNumber=", &port));
	  str.appfmt("%s:%s", tmp->m_host->m_hostname.c_str(), port);
	}
      }
      cluster.m_options.m_loaded.put(ndbcs, str.c_str());
      cluster.m_options.m_generated.put(ndbcs, str.c_str());
      cluster.m_options.m_loaded.get(ndbcs, &val);
    }
    
    for (unsigned i = 0; i<cluster.m_processes.size(); i++)
    {
      cluster.m_processes[i]->m_proc.m_env.appfmt(" NDB_CONNECTSTRING=%s", 
						  val);
    }
  }
  return true;
}
コード例 #4
0
void
MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx,
				    const class Properties &args)
{
  struct PurgeStruct ps;
  BaseString str;
  ps.str = &str;

  m_mgmsrv.get_connected_nodes(ps.free_nodes);
  ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes

  m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps);
  m_mgmsrv.get_socket_server()->checkSessions();

  m_output->println("purge stale sessions reply");
  if (str.length() > 0)
    m_output->println("purged:%s",str.c_str());
  m_output->println("result: Ok");
  m_output->println("");
}
コード例 #5
0
ファイル: main.cpp プロジェクト: guanlisheng/infobright-4.0.7
int main(int argc, char** argv) {
    NDB_INIT(argv[0]);

    load_defaults("my",load_default_groups,&argc,&argv);
    int ho_error;
#ifndef DBUG_OFF
    opt_debug= "d:t:O,/tmp/ndb_mgm.trace";
#endif
    if ((ho_error=handle_options(&argc, &argv, my_long_options,
                                 ndb_std_get_one_option)))
        exit(ho_error);

    char buf[MAXHOSTNAMELEN+10];
    if(argc == 1) {
        BaseString::snprintf(buf, sizeof(buf), "%s",  argv[0]);
        opt_connect_str= buf;
    } else if (argc >= 2) {
        BaseString::snprintf(buf, sizeof(buf), "%s:%s",  argv[0], argv[1]);
        opt_connect_str= buf;
    }

    if (!isatty(0) || opt_execute_str)
    {
        prompt= 0;
    }

    signal(SIGPIPE, handler);
    com = new Ndb_mgmclient(opt_connect_str,1);
    int ret= 0;
    BaseString histfile;
    if (!opt_execute_str)
    {
#ifdef HAVE_READLINE
        char *histfile_env= getenv("NDB_MGM_HISTFILE");
        if (histfile_env)
            histfile.assign(histfile_env,strlen(histfile_env));
        else if(getenv("HOME"))
        {
            histfile.assign(getenv("HOME"),strlen(getenv("HOME")));
            histfile.append("/.ndb_mgm_history");
        }
        if (histfile.length())
            read_history(histfile.c_str());
#endif

        ndbout << "-- NDB Cluster -- Management Client --" << endl;
        while(read_and_execute(_try_reconnect));

#ifdef HAVE_READLINE
        if (histfile.length())
        {
            BaseString histfile_tmp;
            histfile_tmp.assign(histfile);
            histfile_tmp.append(".TMP");
            if(!write_history(histfile_tmp.c_str()))
                my_rename(histfile_tmp.c_str(), histfile.c_str(), MYF(MY_WME));
        }
#endif
    }
    else
    {
        com->execute(opt_execute_str,_try_reconnect, 0, &ret);
    }
    delete com;

    ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
    return ret;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: Cona19/mysql5.6.24-improve
int main(int argc, char** argv){
  NDB_INIT(argv[0]);

  ndb_opt_set_usage_funcs(short_usage_sub, usage);
  load_defaults("my",load_default_groups,&argc,&argv);
  int ho_error;
#ifndef DBUG_OFF
  opt_debug= "d:t:O,/tmp/ndb_mgm.trace";
#endif
  if ((ho_error=handle_options(&argc, &argv, my_long_options,
			       ndb_std_get_one_option)))
    exit(ho_error);

  BaseString connect_str(opt_ndb_connectstring);
  if(argc == 1) {
    connect_str.assfmt("%s", argv[0]);
  } else if (argc >= 2) {
    connect_str.assfmt("%s:%s", argv[0], argv[1]);
  }

  if (!isatty(0) || opt_execute_str)
  {
    prompt= 0;
  }

  com = new Ndb_mgmclient(connect_str.c_str(), opt_verbose);
  int ret= 0;
  BaseString histfile;
  if (!opt_execute_str)
  {
#ifdef HAVE_READLINE
    char *histfile_env= getenv("NDB_MGM_HISTFILE");
    if (histfile_env)
      histfile.assign(histfile_env,strlen(histfile_env));
    else if(getenv("HOME"))
    {
      histfile.assign(getenv("HOME"),strlen(getenv("HOME")));
      histfile.append("/.ndb_mgm_history");
    }
    if (histfile.length())
      read_history(histfile.c_str());
#endif

    ndbout << "-- NDB Cluster -- Management Client --" << endl;
    while(read_and_execute(opt_try_reconnect))
      ;

#ifdef HAVE_READLINE
    if (histfile.length())
    {
      BaseString histfile_tmp;
      histfile_tmp.assign(histfile);
      histfile_tmp.append(".TMP");
      if(!write_history(histfile_tmp.c_str()))
        my_rename(histfile_tmp.c_str(), histfile.c_str(), MYF(MY_WME));
    }
#endif
  }
  else
  {
    com->execute(opt_execute_str, opt_try_reconnect, 0, &ret);
  }
  delete com;

  ndb_end(opt_ndb_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);

  // Don't allow negative return code
  if (ret < 0)
    ret = 255;
  return ret;
}