int main(int argc, const char * const *argv) { apr_pool_t *pool = NULL; client_options_t options; apt_dir_layout_t *dir_layout; const char *log_conf_path; demo_framework_t *framework; /* APR global initialization */ if(apr_initialize() != APR_SUCCESS) { apr_terminate(); return 0; } /* create APR pool */ pool = apt_pool_create(); if(!pool) { apr_terminate(); return 0; } /* set the default options */ options.root_dir_path = "../"; options.log_priority = NULL; options.log_output = NULL; /* load options */ if(demo_framework_options_load(&options,argc,argv,pool) != TRUE) { apr_pool_destroy(pool); apr_terminate(); return 0; } /* create the structure of default directories layout */ dir_layout = apt_default_dir_layout_create(options.root_dir_path,pool); /* get path to logger configuration file */ log_conf_path = apt_confdir_filepath_get(dir_layout,"logger.xml",pool); /* create and load singleton logger */ apt_log_instance_load(log_conf_path,pool); if(options.log_priority) { /* override the log priority, if specified in command line */ apt_log_priority_set(atoi(options.log_priority)); } if(options.log_output) { /* override the log output mode, if specified in command line */ apt_log_output_mode_set(atoi(options.log_output)); } if(apt_log_output_mode_check(APT_LOG_OUTPUT_FILE) == TRUE) { /* open the log file */ apt_log_file_open(dir_layout->log_dir_path,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,pool); } /* create demo framework */ framework = demo_framework_create(dir_layout); if(framework) { /* run command line */ demo_framework_cmdline_run(framework); /* destroy demo framework */ demo_framework_destroy(framework); } /* destroy singleton logger */ apt_log_instance_destroy(); /* destroy APR pool */ apr_pool_destroy(pool); /* APR global termination */ apr_terminate(); return 0; }
int main(int argc, const char * const *argv) { apr_pool_t *pool; server_options_t options; const char *log_conf_path; apt_dir_layout_t *dir_layout = NULL; /* APR global initialization */ if(apr_initialize() != APR_SUCCESS) { apr_terminate(); return 0; } /* create APR pool */ pool = apt_pool_create(); if(!pool) { apr_terminate(); return 0; } /* load options */ if(options_load(&options,argc,argv,pool) != TRUE) { apr_pool_destroy(pool); apr_terminate(); return 0; } if(options.dir_layout_conf) { /* create and load directories layout from the configuration file */ dir_layout = apt_dir_layout_create(pool); if(dir_layout) apt_dir_layout_load(dir_layout,options.dir_layout_conf,pool); } else { /* create default directories layout */ dir_layout = apt_default_dir_layout_create(options.root_dir_path,pool); } if(!dir_layout) { printf("Failed to Create Directories Layout\n"); apr_pool_destroy(pool); apr_terminate(); return 0; } /* get path to logger configuration file */ log_conf_path = apt_confdir_filepath_get(dir_layout,"logger.xml",pool); /* create and load singleton logger */ apt_log_instance_load(log_conf_path,pool); if(options.log_priority) { /* override the log priority, if specified in command line */ apt_log_priority_set(atoi(options.log_priority)); } if(options.log_output) { /* override the log output mode, if specified in command line */ apt_log_output_mode_set(atoi(options.log_output)); } if(apt_log_output_mode_check(APT_LOG_OUTPUT_FILE) == TRUE) { /* open the log file */ const char *log_dir_path = apt_dir_layout_path_get(dir_layout,APT_LAYOUT_LOG_DIR); apt_log_file_open(log_dir_path,"unimrcpserver",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,TRUE,pool); } if(options.foreground == TRUE) { /* run command line */ uni_cmdline_run(dir_layout,pool); } #ifdef WIN32 else { /* run as windows service */ uni_service_run(options.svcname,dir_layout,pool); } #else else {
bool UmcConsole::Run(int argc, const char * const *argv) { apr_pool_t* pool = NULL; apt_dir_layout_t* pDirLayout = NULL; const char *logConfPath; /* APR global initialization */ if(apr_initialize() != APR_SUCCESS) { apr_terminate(); return false; } /* create APR pool */ pool = apt_pool_create(); if(!pool) { apr_terminate(); return false; } /* load options */ if(!LoadOptions(argc,argv,pool)) { apr_pool_destroy(pool); apr_terminate(); return false; } if(m_Options.m_DirLayoutConf) { /* create and load directories layout from the configuration file */ pDirLayout = apt_dir_layout_create(pool); if(pDirLayout) apt_dir_layout_load(pDirLayout,m_Options.m_DirLayoutConf,pool); } else { /* create default directories layout */ pDirLayout = apt_default_dir_layout_create(m_Options.m_RootDirPath,pool); } if(!pDirLayout) { printf("Failed to Create Directories Layout\n"); apr_pool_destroy(pool); apr_terminate(); return false; } /* get path to logger configuration file */ logConfPath = apt_confdir_filepath_get(pDirLayout,"logger.xml",pool); /* create and load singleton logger */ apt_log_instance_load(logConfPath,pool); if(m_Options.m_LogPriority) { /* override the log priority, if specified in command line */ apt_log_priority_set((apt_log_priority_e)atoi(m_Options.m_LogPriority)); } if(m_Options.m_LogOutput) { /* override the log output mode, if specified in command line */ apt_log_output_mode_set((apt_log_output_e)atoi(m_Options.m_LogOutput)); } if(apt_log_output_mode_check(APT_LOG_OUTPUT_FILE) == TRUE) { /* open the log file */ const char *logDirPath = apt_dir_layout_path_get(pDirLayout,APT_LAYOUT_LOG_DIR); apt_log_file_open(logDirPath,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,FALSE,pool); } /* create demo framework */ if(m_pFramework->Create(pDirLayout,pool)) { /* run command line */ RunCmdLine(); /* destroy demo framework */ m_pFramework->Destroy(); } /* destroy singleton logger */ apt_log_instance_destroy(); /* destroy APR pool */ apr_pool_destroy(pool); /* APR global termination */ apr_terminate(); return true; }