当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_ARGV::add方法代码示例

本文整理汇总了C++中ACE_ARGV::add方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_ARGV::add方法的具体用法?C++ ACE_ARGV::add怎么用?C++ ACE_ARGV::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACE_ARGV的用法示例。


在下文中一共展示了ACE_ARGV::add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

int
ACE_TMAIN (int, ACE_TCHAR *argv[])
{
  ACE_Service_Config daemon;
  ACE_ARGV new_args;

  // Load the existing <argv> into our new one.
  new_args.add (argv);
  // Enable loading of static services.
  new_args.add (ACE_TEXT ("-y"));
  // Enable debugging within dynamically linked services.
  new_args.add (ACE_TEXT ("-d"));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("argc = %d\n"),
              new_args.argc ()));

  // Print the contents of the combined <ACE_ARGV>.
  for (int i = 0; i < new_args.argc (); i++)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%d) %s\n"),
                i,
                new_args.argv ()[i]));

  if (daemon.open (new_args.argc (),
                   new_args.argv ()) == -1)
    {
      if (errno != ENOENT)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")),
                          1);
      else // Use static binding.
        {
          ACE_ARGV args;

          args.add (argv[0]);
          args.add (ACE_TEXT ("-p10011")); // Port number.
          ACE_Service_Object *so =
            ACE_SVC_INVOKE (ACE_Naming_Context);

          if (so->init (args.argc (),
                        args.argv ()) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("%p\n"),
                               ACE_TEXT ("ACE_Naming_Context")),
                              1);
        }
    }

  Client_Test test_body;
  if (test_body.open () == -1)
    return 1;

  // Run forever, performing the configured services until we are shut
  // down by a SIGINT/SIGQUIT signal.

  ACE_Reactor::instance ()->run_reactor_event_loop ();
  test_body.close ();

  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:60,代码来源:main.cpp

示例2: failed

int
ACE_TMAIN(int, ACE_TCHAR **)
{
  int result = 0;
#if 0
  ACE_Service_Config serviceConfig;

  char signum[64];
  ACE_OS::sprintf(signum, "%d", SIGUSR1);

  ACE_ARGV args;
  args.add(argv[0]);
  args.add("-s");
  args.add(signum);

  result = serviceConfig.open (
    args.argc(),
    args.argv(),
    ACE_DEFAULT_LOGGER_KEY,
    1, // ignore_static_svcs = 1,
    1, // ignore_default_svc_conf_file = 0,
    0  // ignore_debug_flag = 0
  );
  if(0 != result)
  {
    ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error: serviceConfig.open failed\n")));
    return result;
  }
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.open done\n")));
#endif

  for(int cnt = 0; cnt < 1000; ++cnt)
  {
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Loading ORB cnt = %d\n"), cnt));
    result = ACE_Service_Config::process_directive(scpc_loadOrb);
    if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error loading ORB failed (%d)\n"), result));
      return result;
    }
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Loading ORB done\n")));

    result = ACE_Service_Config::process_directive(scpc_unloadOrb);
    if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error unloading ORB failed (%d)\n"), result));
      return result;
    }
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Unloading ORB done\n")));
  }

  return result;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:53,代码来源:server.cpp

示例3: cl

static int
test_simple_argv (ACE_TCHAR *argv[])
{
  // From command line.
  ACE_ARGV cl (argv);

  // My own stuff.
  ACE_ARGV my;

  // Add to my stuff.
  my.add (ACE_TEXT ("-ORBEndpoint iiop://localhost:12345"));

  // Combine the two (see the ace/ARGV.h constructors documentation).
  ACE_ARGV a (cl.argv (),
              my.argv ());

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("argc = %d\n"),
              a.argc ()));

  // Print the contents of the combined <ACE_ARGV>.
  for (int i = 0; i < a.argc (); i++)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT (" (%d) %s\n"),
                i,
                a.argv ()[i]));

  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:29,代码来源:ARGV_Test.cpp

示例4: not

int
run_main (int, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Bug_2975_Regression_Test"));

  int ret = 0;

  ACE_ARGV args;
  args.add (argv[0], true);
  args.add (ACE_TEXT("-S"));
#if (ACE_USES_CLASSIC_SVC_CONF == 1)
  args.add (
      ACE_TEXT ("\"dynamic ACE_Logger Service_Object * ")
      ACE_TEXT ("ACE:_make_ACE_Logging_Strategy() ")
      ACE_TEXT ("'-p ~TRACE|DEBUG|INFO|WARNING|NOTICE|ERROR|CRITICAL|ALERT'")
      ACE_TEXT ("\""));
#else // not (ACE_USES_CLASSIC_SVC_CONF == 1)
  args.add (
      ACE_TEXT ("'<ACE_Svc_Conf>")
      ACE_TEXT ("<dynamic id=\"ACE_Logger\"")
      ACE_TEXT (" type=\"Service_Object\">")
      ACE_TEXT ("<initializer path=\"ACE\"")
      ACE_TEXT (" init=\"_make_ACE_Logging_Strategy\"")
      ACE_TEXT (" params=\"-p ~TRACE|DEBUG|INFO|WARNING|NOTICE|ERROR|CRITICAL|ALERT\"/>")
      ACE_TEXT ("</dynamic>")
      ACE_TEXT ("</ACE_Svc_Conf>'"));
#endif // not (ACE_USES_CLASSIC_SVC_CONF == 1)

  ret = ACE_Service_Config::open(args.argc(), args.argv(),
                                 ACE_DEFAULT_LOGGER_KEY,
                                 1, 1);

  if (0 != ret)
  {
    ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Service_Config::open() failed\n")));
  }

  ACE_END_TEST;

  return 0;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:41,代码来源:Bug_2975_Regression_Test.cpp

示例5: InitLogStrategy

//初始化日志策略
int Frame_Logging_Strategy::InitLogStrategy(Logging_Config_Param &ConfigParam)
{
    //Set Arg List
    char cmdline[1024] = {0};

    string strTemp = ConfigParam.m_strLogLevel;
    string strLogLevel = GetLogLevel(strTemp);

    if(ConfigParam.m_bSendTerminal)
    {
        ACE_OS::sprintf(cmdline,"-s %s -f STDERR -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }
    else
    {
        ACE_OS::sprintf(cmdline,"-s %s -f OSTREAM -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }

    ACE_Reactor_Impl * pImpl = 0;

    ACE_NEW_RETURN (pImpl, ACE_TP_Reactor, -1);
    

    ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor(pImpl ,1), -1);
    //ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor, -1);
    ACE_NEW_RETURN(pLogStrategy, My_ACE_Logging_Strategy, -1);

    //Set Reactor
    pLogStrategy->reactor(pLogStraReactor);

    ACE_ARGV args;
    //args.add(__argv[0]);
    args.add(ACE_TEXT(cmdline));

    pLogStrategy->init(args.argc(),args.argv());

    if (ACE_Thread_Manager::instance ()->spawn(ACE_THR_FUNC (run_reactor), (void *)pLogStraReactor) == -1)
    {
        ACE_ERROR_RETURN ((LM_ERROR,"Spawning Reactor.\n"),-1);
    }

    ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) %M Init Log Strategy Success [%N,%l]\n")));
    return 0;
}
开发者ID:0328shijian,项目名称:PSS,代码行数:54,代码来源:Frame_Logging_Strategy.cpp

示例6:

ACE_ARGV*
Lorica::Config::get_ifr_options_copy(void)
{
        ACE_ARGV *args;
        ACE_NEW_RETURN(args,
                       ACE_ARGV(),
                       0);
        ssize_t len = this->ifr_args_.size();

        for (ssize_t count = 0; count < len; count++)
                args->add (this->ifr_args_[count].c_str());

        return args;
}
开发者ID:colding,项目名称:lorica,代码行数:14,代码来源:ConfigBase.cpp

示例7:

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  // Set up an argument vector that we can add entries to!
  ACE_ARGV args;

  // Manufacture a "fake" svc.conf entry to demonstrate the -S option
  // that allows us to pass these entries via the "command-line"
  // rather than the svc.conf file.

  for (int i = 0; i < argc; i++)
    args.add (argv[i]);

  args.add (ACE_TEXT ("-y"));
  args.add (ACE_TEXT ("-d"));
  args.add (ACE_TEXT ("-S"));
  args.add (ACE_TEXT ("\"static Timer_Service_1 'timer 1 10 $TRACE'\""));
  args.add (ACE_TEXT ("-S"));
  args.add (ACE_TEXT ("\"dynamic Timer_Service_2 Service_Object * Timer:_make_Timer_Service_2() 'timer 2 10 $TRACE'\""));
  // Test the -f option!
  args.add (ACE_TEXT ("-f svc.conf1"));
  args.add (ACE_TEXT ("-f svc.conf2"));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("argc = %d\n"),
              args.argc ()));

  // Print the contents of the combined <ACE_ARGV>.
  for (int i = 0; i < args.argc (); i++)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%d) %s\n"),
                i,
                args.argv ()[i]));

  int const result = ACE_Service_Config::open (args.argc (),
                                               args.argv (),
                                               ACE_DEFAULT_LOGGER_KEY,
                                               0);
  if (result != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("open")),
                      1);

  // Run forever, performing the configured services until we
  // shutdown.

  ACE_Reactor::run_event_loop ();
  return 0;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:50,代码来源:main.cpp

示例8:

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bug_3319_Regression_Test"));

  ACE_Log_Msg *log_msg = ACE_LOG_MSG;
  ACE_ARGV args;
  args.add (ACE_TEXT("MyProgram"), true);
  int ret = ACE_Service_Config::open(args.argc(), args.argv(),
                                     ACE_DEFAULT_LOGGER_KEY,
                                     1, 1, 1);

  if (ACE_OS::strcmp (log_msg->program_name (), ACE_TEXT("MyProgram")) != 0)
  {
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Program name is not <MyProgram> but <%s>\n"),
                       ACE_Log_Msg::program_name ()),
                       1);
  }

  ACE_END_TEST;

  return ret;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:24,代码来源:Bug_3319_Regression_Test.cpp

示例9: sprintf

  ////////////////////////////////////////////////////////////////////////
  // Now the svc() method where everything interesting happens.
  //
  int 
  SphinxSpeechTask::svc()
  {
#ifdef DEBUG
    ACE_DEBUG ((LM_DEBUG, "(%P|%t) Task 0x%x starts in thread %u\n", (void *) this, ACE_Thread::self ()));
#endif
    
    ACE_ARGV args;
    int error;
    int16 adbuf[4097];
    int32 ts;
    string strtmp;
    string hmmDir=getenv("SPHINX_ROOT");
    hmmDir+="/model/hmm/6k";
    search_hyp_t * result;
    SentenceIDL sentence;

    char * argvtmp;

    args.add("SphinxSpeech");
    args.add("-live TRUE");
    args.add("-ctloffset 0");
    args.add("-ctlcount 100000000");    
    args.add("-agcemax TRUE");
    args.add("-langwt 6.5");
    args.add("-fwdflatlw 8.5");
    args.add("-rescorelw 9.5");
    args.add("-ugwt 0.5");
    args.add("-fillpen 1e-10");
    args.add("-silpen 0.005");
    args.add("-inspen 0.65");
    args.add("-top 1");
    args.add("-topsenfrm 3");
    args.add("-topsenthresh -70000");
    args.add("-beam 2e-06");
    args.add("-npbeam 2e-06");
    args.add("-lpbeam 2e-05");
    args.add("-lponlybeam 0.0005");
    args.add("-nwbeam 0.0005");
    args.add("-fwdflat FALSE");
    args.add("-fwdflatbeam 1e-08");
    args.add("-fwdflatnwbeam 0.0003");
    args.add("-bestpath TRUE");
    
    args.add("-dictfn");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s",speechImpl->dict.c_str());
    args.add(argvtmp);

    args.add("-noisedict");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s/noisedict",hmmDir.c_str());
    args.add(argvtmp);

    args.add("-phnfn");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s/phone",hmmDir.c_str());
    args.add(argvtmp);

    args.add("-mapfn");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s/map",hmmDir.c_str());
    args.add(argvtmp);
    
    args.add("-hmmdir");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s/",hmmDir.c_str());
    args.add(argvtmp);
    
    args.add("-hmmdirlist");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s",hmmDir.c_str());
    args.add(argvtmp);
    
    args.add("-8bsen TRUE");

    args.add("-sendumpfn");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s/sendump",hmmDir.c_str());
    args.add(argvtmp);

    args.add("-cbdir");
    argvtmp=(char*)malloc(255*sizeof(char));
    sprintf(argvtmp,"%s",hmmDir.c_str());
    args.add(argvtmp);
    
    fbs_init(args.argc(), args.argv());

    std::list<std::string>::iterator fit, lmit; //file iterator; lm iterator
     
    for (fit = newLmFileNames.begin(), lmit = newLmNames.begin();
	 fit != newLmFileNames.end();
	 fit = newLmFileNames.begin(), lmit = newLmNames.begin())
    {
      if (lm_read((*fit).c_str(), (*lmit).c_str(), 7.0, .5, 6.5) != 0)
      {
	cerr << "[SphinxSpeechTask] Error: Could not read lm file " << (*fit) << endl;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:101,代码来源:SphinxSpeechTask.cpp

示例10: speech

int
main(int argc, char *argv[])
{
  // set up argv for CORBA init
 
  int i;
  for (i=0; i<argc; ++i)               // search for -ORBSvcConf option
    if (strcmp("-ORBSvcConf", argv[i]) == 0)
      break;

  ACE_ARGV cl;                         // set up new argv
  cl.add(argv);                        // add main argv

  if (i == argc)                       // if no -ORBSvcConf file is specified,
    cl.add("-ORBSvcConf speech.conf"); //  specify one

#ifdef DEBUG
  cout << "Initialize server daemon." << endl;
#endif
  Speech speech(cl.argc(), cl.argv());

  for (int i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "-SpeechInfo") == 0) {
      speech.speechImpl.connection.catInfo();
      return 0;
    }

    if (strcmp(argv[i], "-SpeechSetIntro") == 0) {
      char buffer[256];
      cin.getline(buffer, 256);
      speech.speechImpl.connection.setBootMessage(buffer);
      return 0;
    }
  }

  try {
#ifdef DEBUG
    cout << "Loop forever handling events." << endl;
#endif
    speech.run();
#ifdef DEBUG
    cout << "Speech server ended, exiting." << endl;
#endif
  }
  catch (const Miro::EDevIO& e) {
    cerr << "DevIO excetpion: Device access failed." << endl;
    return 1;
  }
  catch (const CORBA::Exception & e) {
    cerr << "Uncaught CORBA exception: " << e << endl;
    return 1;
  }
  catch (const Miro::ACE_Exception& e) {
    cerr << "ACE exception: " << e << endl;
    return 1;
  }
  catch (...) {
    cerr << "Uncaught exception: " << endl;
    return 1;
  }
  return 0;
}
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:62,代码来源:DtlkSpeech.cpp

示例11:

static int
test_argv_quotes (void)
{
  const ACE_TCHAR *argv_const[] = { ACE_TEXT ("first without quotes"),
                                    ACE_TEXT ("'second in single quotes'"),
                                    ACE_TEXT ("\"third in double quotes\""),
                                    0
                                  };
  ACE_TCHAR **argv = const_cast<ACE_TCHAR **> (argv_const);
  // The convoluted argv definition is to silence warnings from gcc 4.3, which
  // warns if the string-literals are not assigned to const char* and also
  // warns if the const char*[] is passed to the ACE_ARGV constructor as in
  // "args3" below.

  int argc = 3;

  // (argc, argv)
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** argv ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc: %d\n"), argc));

  for (int i = 0; i < argc; ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argv[%02d] = %s\n"), i, argv[i]));

  // args
  ACE_ARGV args;
  for (int i = 0; i < argc; ++i)
    args.add (argv[i]);
  args.add (ACE_TEXT ("'fourth in single quotes'"));
  args.add (ACE_TEXT ("\"fifth in double quotes\""));
  args.add (ACE_TEXT ("sixth without any quotes"));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** args-1 ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args.argc ()));

  for (int i = 0; i < args.argc (); ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args[%02d]: %s\n"), i, args[i]));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args.argc ()));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** args-2 ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args.argc ()));

  for (int i = 0; i < args.argc (); ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argv ()[%02d]: %s\n"),
                i, args.argv ()[i]));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args.argc ()));

  // args2
  ACE_ARGV args2;
  for (int i = 0; i < argc; ++i)
    args2.add (argv[i], true);
  args2.add (ACE_TEXT ("'fourth in single quotes'"), true);
  args2.add (ACE_TEXT ("\"fifth in double quotes\""), true);
  args2.add (ACE_TEXT ("sixth without any quotes"), true);

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** args-3 ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args2.argc ()));

  for (int i = 0; i < args2.argc (); ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args[%02d]: %s\n"), i, args2[i]));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args2.argc ()));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** args-4 ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args2.argc ()));

  for (int i = 0; i < args2.argc (); ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argv ()[%02d]: %s\n"),
                i, args2.argv ()[i]));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args2.argc ()));

  // args3
  ACE_ARGV args3 (argv);

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** args-5 ***\n")));
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args3.argc ()));

  for (int i = 0; i < args3.argc (); ++i)
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args[%02d]: %s\n"), i, args3[i]));

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("args.argc (): %d\n"), args3.argc ()));

  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:86,代码来源:ARGV_Test.cpp

示例12: if

int
ACE_TMAIN(int, ACE_TCHAR ** argv)
{
  int result = 0;
#if !defined (ACE_LACKS_FORK)
  ACE_Sig_Action sigUSR2((ACE_SignalHandler) shutdown_func, SIGUSR2);
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) SIGUSR2 shutdown handler installed\n")));
  ACE_UNUSED_ARG(sigUSR2);

  pid_t pid = -1;
  pid = ACE_OS::fork();
  ACE_Log_Msg::instance ()->sync (argv[0]); // Make %P|%t work right

  if (pid == 0) // child
  {
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) child waiting\n")));
    ACE_OS::sleep(5);
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) signaling parent\n")));
    result = ACE_OS::kill(ACE_OS::getppid(), SIGUSR2);
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) signaled parent\n")));
    //    ACE_OS::sleep (100000);
    return 0;
  }
  else if (pid > 0) // parent
  {
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) parent using ACE_Service_Config, pid=%d\n"), pid));
    ACE_Service_Config serviceConfig;

    ACE_TCHAR signum[64];
    ACE_OS::sprintf(signum, ACE_TEXT("%d"), SIGUSR1);

    ACE_ARGV args;
    args.add(argv[0]);
    args.add(ACE_TEXT("-s"));
    args.add(signum);

    result = serviceConfig.open (
      args.argc(),
      args.argv(),
      ACE_DEFAULT_LOGGER_KEY,
      1, // ignore_static_svcs = 1,
      1, // ignore_default_svc_conf_file = 0,
      0  // ignore_debug_flag = 0
    );
    if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error: serviceConfig.open failed\n")));
      return result;
    }
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.open done\n")));

    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.process_file ...\n")));
#if (ACE_USES_CLASSIC_SVC_CONF == 1)
    result = serviceConfig.process_file(ACE_TEXT("Bug_3251.conf"));
#else
    result = serviceConfig.process_file(ACE_TEXT("Bug_3251.conf.xml"));
#endif
    if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error: serviceConfig.process_file failed\n")));
      return result;
    }
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.process_file done\n")));

    ACE_DEBUG ((LM_INFO, ACE_TEXT ("run_event_loop ...\n")));
    while(!bShutdown)
    {
      ACE_OS::last_error(0);
      result = ACE_Reactor::run_event_loop();
      // reenter loop on EINTR
      if(0 != result && EINTR == ACE_OS::last_error())
      {
        if(bShutdown)
          break;
      }
      else if(0 != result)
      {
        ACE_DEBUG ((
          LM_INFO,
          ACE_TEXT ("(%P|%t) run_event_loop failed (%s, %d)\n"),
          ACE_OS::strerror(ACE_OS::last_error()),
          ACE_OS::last_error()
        ));
      }
    }

    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) run_event_loop done\n")));

    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.fini_svcs ...\n")));
    result = serviceConfig.fini_svcs();
    if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error: serviceConfig.fini_svcs failed\n")));
      return result;
    }
    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.fini_svcs done\n")));

    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.close ...\n")));
    result = serviceConfig.close();
    if(0 != result)
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:server.cpp

示例13: getopt

int
ACE_Service_Config::parse_args_i (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("ACE_Service_Config::parse_args_i");

  // Using PERMUTE_ARGS (default) in order to have all
  // unrecognized options and their value arguments moved
  // to the end of the argument vector. We'll pick them up
  // after processing our options and pass them on to the
  // base class for further parsing.
  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc,
                      argv,
                      ACE_TEXT ("bs:p:"),
                      1  ,                       // Start at argv[1].
                      0,                       // Do not report errors
                      ACE_Get_Opt::RETURN_IN_ORDER);
  //FUZZ: enable check_for_lack_ACE_OS

  // Keep a list of all unknown arguments, begin with the
  // executable's name
  ACE_ARGV superargv;
  superargv.add (argv[0]);

  //FUZZ: disable check_for_lack_ACE_OS
  for (int c; (c = getopt ()) != -1; )
  //FUZZ: enable check_for_lack_ACE_OS
    switch (c)
      {
      case 'p':
        ACE_Service_Config::pid_file_name_ = getopt.opt_arg ();
        break;
      case 'b':
        ACE_Service_Config::be_a_daemon_ = 1;
        break;
      case 's':
        {
          // There's no point in dealing with this on NT since it
          // doesn't really support signals very well...
#if !defined (ACE_LACKS_UNIX_SIGNALS)
          ACE_Service_Config::signum_ =
            ACE_OS::atoi (getopt.opt_arg ());

          if (ACE_Reactor::instance ()->register_handler
              (ACE_Service_Config::signum_,
               ACE_Service_Config::signal_handler_) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("cannot obtain signal handler\n")),
                              -1);
#endif /* ACE_LACKS_UNIX_SIGNALS */
          break;
        }
      default:
        superargv.add ( argv[getopt.opt_ind () - 1],true);
      }

  // Collect any argumets that were left
  for (int c = getopt.opt_ind (); c < argc; c++)
      superargv.add (argv[c-1],true);

  return ACE_Service_Gestalt::parse_args_i (superargv.argc (),
                                            superargv.argv ());

} /* parse_args_i () */
开发者ID:eSDK,项目名称:eSDKClient_Soultion,代码行数:64,代码来源:Service_Config.cpp

示例14: loadOrb

int
ACE_TMAIN(int, ACE_TCHAR **argv)
{
  int result = 0;

  ACE_TCHAR signum[64];
  ACE_OS::sprintf(signum, ACE_TEXT("%d"), SIGUSR1);

  ACE_ARGV args;
  args.add(argv[0]);
  args.add(ACE_TEXT("-s"));
  args.add(signum);

  ACE_Service_Config &serviceConfig = *ACE_Service_Config::singleton ();

  result = serviceConfig.open (args.argc(),
                               args.argv(),
                               ACE_DEFAULT_LOGGER_KEY,
                               true, // ignore_static_svcs = 1,
                               true, // ignore_default_svc_conf_file = 0,
                               false  // ignore_debug_flag = 0
                               );

  if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.open failed\n")));
      return result;
    }
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.open done\n")));

  for(int i = 0; i < 5; ++i)
    {
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb ...\n")));
      result = loadOrb(serviceConfig);
      if(0 != result)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("loadOrb failed\n")));
          return result;
        }
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb done\n")));

      ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify ...\n")));
      result = loadNotify(serviceConfig);
      if(0 != result)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("loadNotify failed\n")));
          return result;
        }
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify done\n")));

      ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify ...\n")));
      result = unloadNotify(serviceConfig);
      if(0 != result)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("unloadNotify failed\n")));
          return result;
        }
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify done\n")));

      ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb ...\n")));
      result = unloadOrb(serviceConfig);
      if(0 != result)
        {
          ACE_ERROR ((LM_ERROR, ACE_TEXT ("unloadOrb failed\n")));
          return result;
        }
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb done\n")));
    }

  ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs ...\n")));
  result = serviceConfig.fini_svcs();
  if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.fini_svcs failed\n")));
      return result;
    }
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs done\n")));

  ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close ...\n")));
  result = serviceConfig.close();
  if(0 != result)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.close failed\n")));
      return result;
    }
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close done\n")));

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:89,代码来源:server.cpp


注:本文中的ACE_ARGV::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。