Example #1
0
static BOOL CALLBACK
config_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
  char name[MAX_PATH+1];
  int n;
  const char *s;

  (void)lparam;
  
  switch (msg) 
    {
    case WM_INITDIALOG:
      center_window (dlg, 0);
      s = get_log_file ();
      SetDlgItemText (dlg, IDC_DEBUG_LOGFILE, s? s:"");
      config_dlg_set_labels (dlg);
      break;
      
    case WM_COMMAND:
      switch (LOWORD (wparam)) 
        {
	case IDOK:
          n = GetDlgItemText (dlg, IDC_DEBUG_LOGFILE, name, MAX_PATH-1);
          set_log_file (n>0?name:NULL);
          EndDialog (dlg, TRUE);
          break;
	}
      break;
    }
  
  return FALSE;
}
Example #2
0
//==========================================================================================================
// Process a control message, that is sent for specifying what and how to run a scenario for a single test.
// TODO: should enable overriding global vars here?
//==========================================================================================================
void MServer::process_control_message(string& ctrl_msg, map<string, string>& script_vars)
{
    map<string, Option> options;
    
    options.emplace(SCENARIO, Option(true, true));
    options.emplace(TEST_DIR, Option(true, true));
    options.emplace(DEFAULT_PV_NAME, ParamValOption()); // Will match any var=val and put it as a new option in the map
    
    OptionParser parser(ctrl_msg, options);
    
    // Mandatory options are scenario to run and test dir. All others are parameters to the scenario.
    for(auto pair: options)
    {
        if(pair.first == SCENARIO || pair.first == TEST_DIR)
        {
            vars[pair.first] = pair.second.get_value();
        }
        else
        {
            script_vars[pair.first] = pair.second.get_value();
        }
    }
    
    if(!ifstream(get_value(TEST_DIR)))
    {
        throw string("Dir " + get_value(TEST_DIR) + " doesn't exist");
    }
    
    set_log_file(get_value(TEST_DIR) + "/mserver.log");
}
Example #3
0
static void
create()
{
    ::create();
    set_aggressive(1);
    set_log_file("fort");
    add_property("guardian");
}
Example #4
0
int
main(int argc, char **argv)
{
    int ret;
    pcap_wrapper *pw;
    char ch, filter[128], is_usage = 0, show_version = 0;

    while((ch = getopt(argc, argv, "s:p:i:S:Cd:l:hv")) != -1) {
        switch(ch) {
            case 's': opts.server = strdup(optarg); break;
            case 'p': opts.port= atoi(optarg); break;
            case 'i': opts.device = strdup(optarg); break;
            case 'S': opts.script = strdup(optarg); break;
            case 'C': opts.is_calc_mode = 1; break;
            case 'd': opts.duration = atoi(optarg); break;
            case 'l':
                opts.specified_addresses = 1;
                if (parse_addresses(optarg)) {
                    logger(ERROR, "parsing local addresses\n");
                    return EXIT_FAILURE;
                }
                break;
            case 'f': opts.log_file = strdup(optarg); break;
            case 'h': is_usage = 1; break;
            case 'v': show_version= 1; break;
        }
    }

    if( is_usage ) {
        usage(argv[0]);
        exit(0);
    }
    if(show_version) {
        printf("%s version is %s\n", argv[0], VERSION);
        exit(0);
    }
    if(!opts.specified_addresses && get_addresses() != 0) {
        exit(0);
    }
    if (!opts.port) logger(ERROR, "port is required.\n");
    if (!opts.device) logger(ERROR, "device is required.\n");
    if (opts.log_file) set_log_file(opts.log_file); 
    if (!(pw = pw_create(opts.device))) logger(ERROR, "start captrue packet failed.\n");
    if(opts.server) {
        snprintf(filter, sizeof(filter), "host %s and tcp port %d", opts.server, opts.port);
    } else {
        snprintf(filter, sizeof(filter), "tcp port %d", opts.port);
    }

    check_lua_script();
    // start capature loop.
    ret = core_loop(pw, filter, process_packet);
    if(ret == -1) logger(ERROR, "start core loop failed.\n");

    pw_release(pw);
    script_release(L);
    return 0;
}
Example #5
0
static void
var_set_log_file(DCVariable *var, int argc, char **argv)
{
    if (argc > 2) {
	warn(_("too many arguments\n"));
	return;
    }
    set_log_file(argv[1], true);
}
Example #6
0
File: log.c Project: Mortal/claws
static void rotate_log(LogInstance instance)
{
	if (log_size[instance] > 10 * 1024* 1024) {
		gchar *filename = g_strdup(log_filename[instance]);
		debug_print("rotating %s\n", filename);
		close_log_file(instance);
		set_log_file(instance, filename);
		g_free(filename);
	}
}
Example #7
0
/* Initialize some basic config settings */
void init_default_settings(void)
{
	set_log_file(stdout);
	set_max_pin_attempts(P1_SIZE + P2_SIZE);
        set_delay(DEFAULT_DELAY);
        set_lock_delay(DEFAULT_LOCK_DELAY);
        set_debug(INFO);
        set_auto_channel_select(1);
        set_timeout_is_nack(1);
	set_oo_send_nack(1);
        set_wifi_band(BG_BAND);
}
Example #8
0
int main(int argc, char **argv) {
    if (argc != 4 && argc != 6) {
        print_usage_and_exit();
    }

    int mode = 0;
    if (strcmp(argv[1], "-p1") == 0) {
        mode = 1;
    } else if (strcmp(argv[1], "-p2") == 0) {
        mode = 2;
    }

    char *input, *inter, *output;
    if (mode == 1) {
        input = argv[2];
        inter = argv[3];
        output = NULL;
    } else if (mode == 2) {
        input = NULL;
        inter = argv[2];
        output = argv[3];
    } else {
        input = argv[1];
        inter = argv[2];
        output = argv[3];
    }

    if (argc == 6) {
        if (strcmp(argv[4], "-log") == 0) {
            set_log_file(argv[5]);
        } else {
            print_usage_and_exit();
        }
    }

    int err = assemble(input, inter, output);

    if (err) {
        write_to_log("One or more errors encountered during assembly operation.\n");
    } else {
        write_to_log("Assembly operation completed successfully.\n");
    }

    if (is_log_file_set()) {
        printf("Results saved to %s\n", argv[5]);
    }

    return err;
}
Example #9
0
static int innostore_drv_init()
{
    char log_filename[_POSIX_PATH_MAX];
    size_t log_filename_size = sizeof(log_filename);
    ErlDrvSysInfo sys_info;

    G_ENGINE_STATE_LOCK = erl_drv_mutex_create("innostore_state_lock");
    G_LOGGER_LOCK = erl_drv_mutex_create("innostore_logger_lock");

    // Check if this is beam.smp - cannot run under beam 
    // due to restrictions with driver_send_term
    driver_system_info(&sys_info, sizeof(sys_info));
    if (sys_info.smp_support == 0)
    {
        log("Innostore only supports the SMP runtime, add -smp enable");
        return -1;
    }

    // Initialize Inno's memory subsystem
    if (ib_init() != DB_SUCCESS)
    {
        return -1;
    }

    // Set up the logger
    if (erl_drv_getenv("INNOSTORE_LOG", log_filename, &log_filename_size) == 0)
    {
        set_log_file(log_filename);
    }
    else
    {
        set_log_file(NULL);
    }

    return 0;
}
Example #10
0
//==========================================================================================================
// Mandatory options:
// -ip <IP>             ip to use
// -port <PORT>         port to use
// -test_dir <NAME>     test directory (for log file)
// -scenario <NAME>     scenario file to run
//==========================================================================================================
void MServer::process_args(int argc, char * argv[])
{    
    //------------------------------------------------------------------------------------------------------
    // Collect and check options
    //------------------------------------------------------------------------------------------------------
    map<string, Option> options;

    options.emplace(IPS, Option(true, true));
    options.emplace(SERVER_PORT, Option(true, true));
    options.emplace(CONTROL_PORT, Option(true, true));
    options.emplace(SCENARIO_DIR, Option(false, true));
    options.emplace(RUN_DIR, Option(true, true));
    options.emplace("debug", Option(false, false));
    options.emplace("var", ParamValOption()); // -var name=value

    OptionParser parser(argc, argv, options); // Parse command line option and put values in the map
    
    //------------------------------------------------------------------------------------------------------
    // Put collected values in the vars map. Why not just put it in fields? because script reader will need
    // these values and it will query for them by their variable names.
    //------------------------------------------------------------------------------------------------------
    for(auto pair: options)
    {
        if(pair.first == "debug" && pair.second.was_found())
        {
            debug = true;
        }
        else if(pair.first == IPS)
        {
            extract_ips(pair.second.get_value());
            vars[SERVER_IP] = ips[cur_ip_index];
        }
        else
        {
            vars[pair.first] = pair.second.get_value();
        }
    }
    
    // -scenario_dir option should be given only in developing phase because xcode puts exe in weird places.
    // in "production", the exe will be in a default location relative to voxip root, and we'll resolve the
    // scenario dir location automatically.
    if(vars[SCENARIO_DIR].empty())
    {
        set_scenario_dir(argv[0]);
    }
    
    //------------------------------------------------------------------------------------------------------
    // Check validity of given parameters
    //------------------------------------------------------------------------------------------------------
    if(!debug && !ifstream(get_value(RUN_DIR)))
    {
        throw string("Dir " + get_value(RUN_DIR) + " doesn't exist");
    }

    // Once the run dir is known, direct messages there
    set_log_file(get_value(RUN_DIR) + "/mserver.log");
    log_file_set = true;

    if(!ifstream(get_value(SCENARIO_DIR)))
    {
        throw string("Dir " + get_value(SCENARIO_DIR) + " doesn't exist");
    }
}
Example #11
0
int NDInstanceBase::Create(int argc,const char *argv[])
{
	int i ;
	const char *logfileName = NULL ;
	if (m_bCreated)	{
		return 0;
	}

    system_signals_init() ;
    
	nd_arg(argc, argv);	
	
	//get config file 	
	for (i=1; i<argc; i++){
		if(0 == strcmp(argv[i],"-f" ) && i< argc-1) {
			NDInstanceBase::config_file = argv[++i] ;
		}
		else if(0== strcmp(argv[i], "-c") && i< argc-1) {
			m_config_name = argv[++i] ;
		}
		else if(0==strcmp(argv[i],"-nodev")) {
			m_un_develop = 1;
		}
		
		else if(0==strcmp(argv[i],"-log") && i<argc -1) {
			logfileName = argv[++i];
		}
		else if(0==strcmp(argv[i],"-workdir") &&i<argc -1 ) {
			nd_chdir(argv[++i]) ;
		}
		else if(0==strcmp(argv[i],"-v") || 0==strcmp(argv[i],"--version") ) {
			fprintf(stdout, "version : %s \n" , __g_version_desc) ;
			exit(0) ;
		}
		else if(0==strcmp(argv[i],"-l") || 0==strcmp(argv[i],"--rlimit") ) {
			char buf[1024] ;
			fprintf(stdout, "rlimit: \n %s\n" , get_rlimit_info(buf, sizeof(buf)) ) ;
			exit(0) ;
		}

        else if(0==strcmp(argv[i],"-pid") && i<argc -1){
            FILE *pf = fopen(argv[i+1], "w") ;
            if (pf) {
                fprintf(pf, "%d", nd_processid()) ;
                fclose(pf) ;
            }
            else {
                fprintf(stderr,"write pid error %s file not exist\n", argv[i+1]) ;
                exit(1) ;
            }
        }
	}

	if(!config_file|| !m_config_name) {
		printf("usage: -f config-file -c config-name\n press ANY key to continue\n") ;
		//getch() ;
		exit(1) ;
		//return -1 ;
	}

	if(-1==ReadConfig(m_config_name) ) {
		printf("Read config %s file error \n press ANY key to continue\n", m_config_name) ;
		//getch() ;
		exit(1) ;
	}
	
	nd_set_exit_callback(applib_exit_callback) ;

	if (m_config.i_cfg.open_dump){
#ifndef ND_UNIX
		::SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)nd_unhandler_except);
#else
		enable_core_dump() ;
#endif
	}
	size_t max_connector = m_config.l_cfg.max_connect ;
	if ( max_connector > get_maxopen_fd() ) {
		size_t new_fd_num = set_maxopen_fd(max_connector) ;
		nd_logmsg("set max connect %d real max connect =%d\n",m_config.l_cfg.max_connect, (int) new_fd_num);
	}
	
	if(logfileName && logfileName[0]) {
		strncpy(m_config.i_cfg.log_file, logfileName, sizeof(m_config.i_cfg.log_file)) ;
	}
	if (m_config.i_cfg.log_file[0]){
		set_log_file(m_config.i_cfg.log_file) ;
		if (m_config.i_cfg.log_file_size > 0) {
			nd_setlog_maxsize(m_config.i_cfg.log_file_size) ;
		}
		nd_setlog_func(nd_default_filelog) ;
	}

	if (m_config.i_cfg.callstack_file[0]){
		if(CALLSTACK_INIT(m_config.i_cfg.callstack_file)==-1) {
			nd_logfatal("create map file %s error!\n" AND m_config.i_cfg.callstack_file) ;
			return -1 ;
		}
	}

	nd_net_set_crypt((nd_netcrypt)nd_TEAencrypt, (nd_netcrypt)nd_TEAdecrypt, sizeof(tea_v)) ;
	
// 	if (g_base_inst==NULL){
// 		g_base_inst = this ;
// 	}

	OnCreate();

	m_bCreated = 1;
	return 0 ;

}
Example #12
0
int main(int argc, char *argv[])
{
    int     ret, server_mode;
    void    *host_addr = memalign(1024 * 1024, HOST_SIZE);
    msgType dialog_type;
	sys_ppu_thread_t id; // start server thread

    load_modules();

    init_logging();

	netInitialize();
	netCtlInit();

    // Initialize SPUs
    LOG(lm_main, LOG_DEBUG, ("Initializing SPUs\n"));
    ret = sysSpuInitialize(MAX_PHYSICAL_SPU, MAX_RAW_SPU);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sysSpuInitialize failed: %d\n", ret));
        goto quit;
    }

    init_screen(host_addr, HOST_SIZE);
    ioPadInit(7);

    ret = initialize_exit_handlers();
    if (ret != 0)
        goto quit;

    show_version();

    if (user_requested_exit())
        goto quit;

	u64 CEX=0x4345580000000000ULL;
	u64 DEX=0x4445580000000000ULL;
	u64 DEH=0x4445480000000000ULL;

	if(lv2peek(0x80000000002E79C8ULL)==DEX) {dex_mode=2; c_firmware=3.41f;}
	else
	if(lv2peek(0x80000000002CFF98ULL)==CEX) {dex_mode=0; c_firmware=3.41f;}
	else
	if(lv2peek(0x80000000002EFE20ULL)==DEX) {dex_mode=2; c_firmware=3.55f;}
	else
	if(lv2peek(0x80000000002D83D0ULL)==CEX) {dex_mode=0; c_firmware=3.55f;}
	else
	if(lv2peek(0x8000000000302D88ULL)==DEX) {dex_mode=2; c_firmware=4.21f;}
	else
	if(lv2peek(0x80000000002E8610ULL)==CEX) {dex_mode=0; c_firmware=4.21f;}
	else
	if(lv2peek(0x80000000002E9F08ULL)==CEX) {dex_mode=0; c_firmware=4.30f;}
	else
	if(lv2peek(0x8000000000304630ULL)==DEX) {dex_mode=2; c_firmware=4.30f;}
	else
	if(lv2peek(0x80000000002E9F18ULL)==CEX) {dex_mode=0; c_firmware=4.31f;}
	else
	if(lv2peek(0x80000000002EA488ULL)==CEX) {dex_mode=0; c_firmware=4.40f;}
	else
	if(lv2peek(0x80000000002EA498ULL)==CEX) {dex_mode=0; c_firmware=4.41f;}
	else
	if(lv2peek(0x8000000000304EF0ULL)==DEX) {dex_mode=2; c_firmware=4.41f;}
	else
	if(lv2peek(0x80000000002EA9B8ULL)==CEX) {dex_mode=0; c_firmware=4.46f;}
	else
	if(lv2peek(0x8000000000305410ULL)==DEX) {dex_mode=2; c_firmware=4.46f;}
	else
	if(lv2peek(0x80000000002E9BE0ULL)==CEX) {dex_mode=0; c_firmware=4.50f;}
	else
	if(lv2peek(0x8000000000309698ULL)==DEX) {dex_mode=2; c_firmware=4.50f;}
	else
	if(lv2peek(0x80000000002E9D70ULL)==CEX) {dex_mode=0; c_firmware=4.53f;}
	else
	if(lv2peek(0x80000000002EC5E0ULL)==CEX) {dex_mode=0; c_firmware=4.55f;}
	else
	if(lv2peek(0x80000000002ED850ULL)==CEX) {dex_mode=0; c_firmware=4.60f;}
	else
	if(lv2peek(0x80000000002ED860ULL)==CEX) {dex_mode=0; c_firmware=4.65f;}
	else
	if(lv2peek(0x800000000030F1A8ULL)==DEX) {dex_mode=2; c_firmware=4.65f;}
	else
	if(lv2peek(0x80000000002ED778ULL)==CEX) {dex_mode=0; c_firmware=4.70f;}
	else
	if(lv2peek(0x800000000030F240ULL)==DEX) {dex_mode=2; c_firmware=4.70f;}
	else
	if(lv2peek(0x80000000002ED818ULL)==CEX) {dex_mode=0; c_firmware=4.75f;}
	else
	if(lv2peek(0x800000000030F2D0ULL)==DEX) {dex_mode=2; c_firmware=4.75f;}
	else
	if(lv2peek(0x80000000002ED808ULL)==CEX) {dex_mode=0; c_firmware=4.80f;}
	else
	if(lv2peek(0x800000000030F3A0ULL)==DEX) {dex_mode=2; c_firmware=4.80f;}
	else
	if(lv2peek(0x800000000030F3B0ULL)==DEX) {dex_mode=2; c_firmware=4.81f;}
	else
	if(lv2peek(0x800000000032EB60ULL)==DEH) {deh_mode=2; c_firmware=4.81f;}
	else	
		c_firmware=0.00f;

	if(c_firmware==3.55f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_355D;
	}
	else
	if(c_firmware==3.55f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_355;
	}
	else
	if(c_firmware==4.21f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_421;
	}
	else
	if(c_firmware==4.30f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_430;
	}
	else
	if(c_firmware==4.30f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_430D;
	}
	else
	if(c_firmware==4.31f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_431;
	}
	else
	if(c_firmware==4.40f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_440;
	}
	else
	if(c_firmware==4.41f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_441;
	}
	else
	if(c_firmware==4.41f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_441D;
	}
	else
	if(c_firmware==4.46f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_446;
	}
	else
	if(c_firmware==4.50f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_450;
	}
	else
	if(c_firmware==4.53f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_453;
	}
	else
	if(c_firmware==4.55f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_455;
	}
	else
	if(c_firmware==4.60f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_460;
	}
	else
	if(c_firmware==4.65f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_465;
	}
	else
	if(c_firmware==4.65f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_465D;
	}
	else
	if(c_firmware==4.70f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_470;
	}
	else
	if(c_firmware==4.70f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_470D;
	}
	else
	if(c_firmware==4.75f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_475;
	}
	else
	if(c_firmware==4.80f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_480;
	}
	else
	if(c_firmware==4.80f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_480D;
	}
	else
	if(c_firmware==4.75f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_475D;
	}
	else
	if(c_firmware==4.81f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_481D;
	}
	else
	if(c_firmware==4.46f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_446D;
	}
	else
	if(c_firmware==4.50f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_450D;
	}
	else
	if(c_firmware==4.21f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_421D;
	}
	else
	if(c_firmware==3.41f)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_341;
	}
	else
	if(c_firmware==4.81f && deh_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_481H;
	}	
/*
	if(c_firmware>=4.20f && SYSCALL_TABLE)
	{
		// add and enable lv2 peek/poke + lv1 peek/poke
		lv2poke(0x800000000000171CULL,       0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +   8, 0x396000B644000022ULL);
		lv2poke(0x800000000000171CULL +  16, 0x7C832378E8010010ULL);
		lv2poke(0x800000000000171CULL +  24, 0x7C0803A64E800020ULL);
		lv2poke(0x800000000000171CULL +  32, 0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +  40, 0x396000B744000022ULL);
		lv2poke(0x800000000000171CULL +  48, 0x38600000E8010010ULL);
		lv2poke(0x800000000000171CULL +  56, 0x7C0803A64E800020ULL);
		lv2poke(0x800000000000171CULL +  64, 0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +  72, 0x7D4B537844000022ULL);
		lv2poke(0x800000000000171CULL +  80, 0xE80100107C0803A6ULL);
		lv2poke(0x800000000000171CULL +  88, 0x4E80002080000000ULL);
		lv2poke(0x800000000000171CULL +  96, 0x0000170C80000000ULL);
		lv2poke(0x800000000000171CULL + 104, 0x0000171480000000ULL);
		lv2poke(0x800000000000171CULL + 112, 0x0000171C80000000ULL);
		lv2poke(0x800000000000171CULL + 120, 0x0000173C80000000ULL);
		lv2poke(0x800000000000171CULL + 128, 0x0000175C00000000ULL);
		lv2poke(SYSCALL_PTR( 6), 0x8000000000001778ULL); //sc6
		lv2poke(SYSCALL_PTR( 7), 0x8000000000001780ULL); //sc7
		lv2poke(SYSCALL_PTR( 8), 0x8000000000001788ULL); //sc8
		lv2poke(SYSCALL_PTR( 9), 0x8000000000001790ULL); //sc9
		lv2poke(SYSCALL_PTR(10), 0x8000000000001798ULL); //sc10
	}*/
    // remove patch protection
	if(c_firmware==3.55f)
	    remove_protection();

	if(c_firmware==0.00f)
		ret = -1;
	else
	    ret = patch_lv1_ss_services();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "ERROR: Couldn't patch lv1 services, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    // patch syscall 864 to allow drive re-init
	if(c_firmware==0.0f)
		ret = -1;
	else
	    ret = patch_syscall_864();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "ERROR: Couldn't patch syscall 864, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    // install the necessary modules
    ret = install_modules();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "Installation was aborted, returning to the XMB.", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    if (user_requested_exit())
        goto quit;

    // reset & re-authenticate the BD drive
    sys_storage_reset_bd();
    sys_storage_authenticate_bd();

    // eject current disc
    {
        int fd;
        ret = sys_storage_open(BD_DEVICE, &fd);
        if (ret == 0)
        {
            ioctl_eject(fd);
            sys_storage_close(fd);
        }
    }

    ret = sysDiscRegisterDiscChangeCallback(&bd_eject_disc_callback, &bd_insert_disc_callback);

    // poll for an output_device
    poll_output_devices();

    server_mode = user_select_server_mode();

    if (user_requested_exit())
        goto quit;

    if (server_mode)
    {
#ifdef ENABLE_LOGGING
        if (output_device)
        {
            char file_path[100];
            sprintf(file_path, "%s/daemon_log.txt", output_device);
            set_log_file(file_path);
        }
#endif
    	sysThreadCreate(&id, listener_thread, NULL, 1500, 0x400, 0, "listener");

        while (1)
        {
            // server loop
            server_loop();

            // break out of the loop when requested
            if (user_requested_exit())
                break;
        }
    }
    else
    {
        while (1)
        {
            // main loop
            main_loop();

            // break out of the loop when requested
            if (user_requested_exit())
                break;
        }
    }

    ret = sysDiscUnregisterDiscChangeCallback();

 quit:

    unpatch_lv1_ss_services();

    destroy_logging();
	netDeinitialize();
    unload_modules();

    free(host_addr);

    return 0;
}
Example #13
0
void main_loop(void)
{
    msgType              dialog_type;
    char                 *message = (char *) malloc(512);
    sacd_reader_t        *sacd_reader;
    scarletbook_handle_t *sb_handle = 0;
    int idx = 0;

    if (output_device_changed && output_device)
    {
        char file_path[100];
        sprintf(file_path, "%s/sacd_log.txt", output_device);
        set_log_file(file_path);
        LOG(lm_main, LOG_NOTICE, ("SACD-Ripper Version " SACD_RIPPER_VERSION_STRING));
    }

    // did the disc change?
    if (bd_contains_sacd_disc && bd_disc_changed)
    {
        // open the BD device
        sacd_reader = sacd_open("/dev_bdvd");
        if (sacd_reader)
        {
            // read the scarletbook information
            sb_handle = scarletbook_open(sacd_reader, 0);
            if (sb_handle)
            {
                master_text_t *master_text = &sb_handle->master_text;
                master_toc_t *mtoc = sb_handle->master_toc;

                if (master_text->disc_title || master_text->disc_title_phonetic)
                {
                    idx += snprintf(message_info + idx, 60, "Title: %s\n", substr((master_text->disc_title ? master_text->disc_title : master_text->disc_title_phonetic), 0, 50));
                    LOG(lm_main, LOG_NOTICE, ("Album Title: %s", substr((master_text->disc_title ? master_text->disc_title : master_text->disc_title_phonetic), 0, 50)));
                }

                if (message_info[idx - 1] != '\n') { message_info[idx++] = '\n'; message_info[idx] = '\0'; }

                if (master_text->disc_artist || master_text->disc_artist_phonetic)
                {
                    idx += snprintf(message_info + idx, 60, "Artist: %s\n", substr((master_text->disc_artist ? master_text->disc_artist : master_text->disc_artist_phonetic), 0, 50));
                    LOG(lm_main, LOG_NOTICE, ("Album Artist: %s", substr((master_text->disc_artist ? master_text->disc_artist : master_text->disc_artist_phonetic), 0, 50)));
                }

                if (message_info[idx - 1] != '\n') { message_info[idx++] = '\n'; message_info[idx] = '\0'; }

                idx += snprintf(message_info + idx, 20, "Version: %02i.%02i\n", mtoc->version.major, mtoc->version.minor);
                LOG(lm_main, LOG_NOTICE, ("Disc Version: %02i.%02i\n", mtoc->version.major, mtoc->version.minor));
                idx += snprintf(message_info + idx, 25, "Created: %4i-%02i-%02i\n", mtoc->disc_date_year, mtoc->disc_date_month, mtoc->disc_date_day);

                idx += snprintf(message_info + idx, 15, "Area 0:\n");
                idx += snprintf(message_info + idx, 35, "   Speakers: %s\n", get_speaker_config_string(sb_handle->area[0].area_toc));
                idx += snprintf(message_info + idx, 35, "   Encoding: %s\n", get_frame_format_string(sb_handle->area[0].area_toc));
                idx += snprintf(message_info + idx, 25, "   Tracks: %d (%.2fGB)\n", sb_handle->area[0].area_toc->track_count, ((double) (sb_handle->area[0].area_toc->track_end - sb_handle->area[0].area_toc->track_start) * SACD_LSN_SIZE) / 1073741824.00);
                if (has_both_channels(sb_handle))
                {
                    idx += snprintf(message_info + idx, 2, "\n");
                    idx += snprintf(message_info + idx, 15, "Area 1:\n");
                    idx += snprintf(message_info + idx, 35, "   Speakers: %s\n", get_speaker_config_string(sb_handle->area[1].area_toc));
                    idx += snprintf(message_info + idx, 35, "   Encoding: %s\n", get_frame_format_string(sb_handle->area[1].area_toc));
                    idx += snprintf(message_info + idx, 25, "   Tracks: %d (%.2fGB)\n", sb_handle->area[1].area_toc->track_count, ((double) (sb_handle->area[1].area_toc->track_end - sb_handle->area[1].area_toc->track_start) * SACD_LSN_SIZE) / 1073741824.00);
                }

                idx += snprintf(message_info + idx, 50, "\nclick X to start ripping, O to change output");

                current_ripping_flags = 0;
                if (has_two_channel(sb_handle))
                {
                    current_ripping_flags |= RIP_2CH;
                    if (sb_handle->area[sb_handle->twoch_area_idx].area_toc->frame_format == FRAME_FORMAT_DST)
                    {
                        current_ripping_flags |= RIP_2CH_DST;
                    }
                }
                if (has_multi_channel(sb_handle))
                {
                    current_ripping_flags |= RIP_MCH;
                }

                // validate output format as the ripping flags have changed
                output_format_changed = 1;
                validate_output_format();

                scarletbook_close(sb_handle);
                sb_handle = 0;
            }
            else
            {
                bd_contains_sacd_disc = 0;
            }

            // close the input device asap
            sacd_close(sacd_reader);
            sacd_reader = 0;
        }
        else
        {
            bd_contains_sacd_disc = 0;
        }
    }

    if (output_device_changed || output_format_changed)
    {
        // output device
        if (output_device)
            idx = snprintf(message_output, 35, "Output: %s %.2fGB\n", output_device, output_device_space);
        else
            idx = snprintf(message_output, 35, "Output: NO DEVICE\n");

        // output format
        idx += snprintf(message_output + idx, 20, "Format: ");

        switch (output_format)
        {
        case 0:
            idx += snprintf(message_output + idx, 20, "2ch DSDIFF (DSD)\n");
            break;
        case 1:
            idx += snprintf(message_output + idx, 20, "2ch DSDIFF (DST)\n");
            break;
        case 2:
            idx += snprintf(message_output + idx, 20, "2ch DSF (DSD)\n");
            break;
        case 3:
            idx += snprintf(message_output + idx, 20, "mch DSDIFF (DSD)\n");
            break;
        case 4:
            idx += snprintf(message_output + idx, 20, "mch DSDIFF (DST)\n");
            break;
        case 5:
            idx += snprintf(message_output + idx, 20, "mch DSF (DSF)\n");
            break;
        case 6:
            idx += snprintf(message_output + idx, 20, "ISO\n");
            break;
        }
        idx += snprintf(message_output + idx, 2, "\n");
    }

    // by default we have no user controls
    dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON);

    if (bd_contains_sacd_disc)
    {
        snprintf(message, 512, "%s%s", message_output, message_info);
    }
    else
    {
        snprintf(message, 512, "The current disc is empty or not recognized as an SACD, please re-insert.\n\n%s"
                 , (output_device ? "" : "(Also make sure you connect an external fat32 formatted harddisk!)"));
    }

    // can we start ripping?
    if (bd_contains_sacd_disc)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK);
    }

    msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL);

    dialog_action         = 0;
    bd_disc_changed       = 0;
    output_device_changed = 0;
    output_format_changed = 0;
    while (!dialog_action && !user_requested_exit() && bd_disc_changed == 0 && output_device_changed == 0)
    {
        // poll for new output devices
        poll_output_devices();

        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();

    // did user request to start the ripping process?
    if (dialog_action == 1 && bd_contains_sacd_disc)
    {
        start_ripping_gui(output_format_options[output_format]);

        reset_output_devices();

        // action is handled
        dialog_action = 0;
    }
    else if (dialog_action == 2)
    {
#if 0
        output_format++;

        // max of 7 output options
        if (output_format > 6)
        {
            output_format = 0;
        }
#endif

        // is the current selection valid?
        validate_output_format();

        // action is handled
        output_format_changed = 1;
        dialog_action = 0;
    }

    free(message);
}
Example #14
0
//==========================================================================================================
// Run multiple tests. Control messagaes are sent to tell mserver which scenario to run. After the run a
// message is sent back to indicate success or failure.
// Special message "bye" tells mserver to quit.
//==========================================================================================================
void MServer::run(int argc, char * argv[])
{
    bool last_failed = false;
    
    try
    {
        process_args(argc, argv);
        sip_connection = new SipConnection(vars[SERVER_IP], stoi(vars[SERVER_PORT]));
        ctrl_connection = new ControlConnection(vars[SERVER_IP], stoi(vars[CONTROL_PORT]));
        
        //--------------------------------------------------------------------------------------------------
        // Run tests until a "bye" control message is received
        //--------------------------------------------------------------------------------------------------
        while(true)
        {
            set_log_file(get_value(RUN_DIR) + "/mserver.log"); // Set the log file back to the global log file between tests

            //----------------------------------------------------------------------------------------------
            // Get and process a control message (indicating which scenario to run, etc.)
            //----------------------------------------------------------------------------------------------
            string ctrl_msg = ctrl_connection->get_message();
            
            if(ctrl_msg == "bye")
            {
                break;
            }
            
            if(ctrl_msg == "awake?")
            {
                ctrl_connection->send_message("yes");
                continue;
            }

            reset_connection(last_failed); // Go back to original ip, start listening if stopped
            last_failed = false;
            
            map<string, string> script_vars;
            process_control_message(ctrl_msg, script_vars);
            
            //----------------------------------------------------------------------------------------------
            // Run the scenario
            //----------------------------------------------------------------------------------------------
            try
            {
                ScriptReader reader(get_value(SCENARIO), script_vars);
                sip_connection->check_no_pending_messages();
            }
            catch(string err) // Error caught here is a test error: report it and continue
            {
                cout << endl << err << endl;
                ctrl_connection->send_message(err);
                last_failed = true;
                continue;
            }
            
            ctrl_connection->send_message("success"); // Test succeeded as far as mserver is concerned
        }
    }
    catch (string err) // Error caught here is fatal, and mserver can't run anymore
    {
        if(!log_file_set)
        {
            // This will be in the directory from which the executable was run. This is to catch any messages that
            // occur before the run dir is known
            set_log_file("mserver.log");
        }
        
        cout << endl << err << endl;
        exit(-1);
    }
}
int main(int argc, char *argv[])
{
	SOAP_SOCKET m;
#if defined(_POSIX_THREADS) || defined(_SC_THREADS)
	pthread_t tid;
	pthread_mutex_init(&global_flag, NULL);
	pthread_mutex_init(&libssh2_flag, NULL);
	pthread_cond_init(&termination_flag, NULL);
#endif
	struct soap soap, *tsoap = NULL;
	psoap = &soap;

	int ch, msglevel = LOG_INFO;
	static char *USAGE = "\nUSAGE:\noph_server [-d] [-l <log_file>] [-p <port>] [-v] [-w]\n";

	fprintf(stdout, "%s", OPH_VERSION);
	fprintf(stdout, "%s", OPH_DISCLAIMER);

	set_debug_level(msglevel + 10);

	while ((ch = getopt(argc, argv, "dhl:p:vwxz")) != -1) {
		switch (ch) {
			case 'd':
				msglevel = LOG_DEBUG;
				break;
			case 'h':
				fprintf(stdout, "%s", USAGE);
				return 0;
			case 'l':
				oph_log_file_name = optarg;
				break;
			case 'p':
				oph_server_port = optarg;
				break;
			case 'v':
				return 0;
				break;
			case 'w':
				if (msglevel < LOG_WARNING)
					msglevel = LOG_WARNING;
				break;
			case 'x':
				fprintf(stdout, "%s", OPH_WARRANTY);
				return 0;
			case 'z':
				fprintf(stdout, "%s", OPH_CONDITIONS);
				return 0;
			default:
				fprintf(stdout, "%s", USAGE);
				return 0;
		}
	}

	set_debug_level(msglevel + 10);
	pmesg(LOG_INFO, __FILE__, __LINE__, "Selected log level %d\n", msglevel);

#ifdef OPH_SERVER_LOCATION
	oph_server_location = strdup(OPH_SERVER_LOCATION);
#else
	oph_server_location = getenv(OPH_SERVER_LOCATION_STR);
	if (!oph_server_location) {
		fprintf(stderr, "OPH_SERVER_LOCATION has to be set\n");
		return 1;
	}
#endif
	pmesg(LOG_DEBUG, __FILE__, __LINE__, "Server location '%s'\n", oph_server_location);

	char configuration_file[OPH_MAX_STRING_SIZE];
	snprintf(configuration_file, OPH_MAX_STRING_SIZE, OPH_CONFIGURATION_FILE, oph_server_location);
	set_global_values(configuration_file);

	if (oph_log_file_name) {
		if (logfile)
			fclose(logfile);
		if (!(logfile = fopen(oph_log_file_name, "a"))) {
			fprintf(stderr, "Wrong log file name '%s'\n", oph_log_file_name);
			return 1;
		}
		pmesg(LOG_INFO, __FILE__, __LINE__, "Selected log file '%s'\n", oph_log_file_name);
		if (logfile)
			set_log_file(logfile);
	} else
		oph_log_file_name = hashtbl_get(oph_server_params, OPH_SERVER_CONF_LOGFILE);

	int int_port = strtol(oph_server_port, NULL, 10);

	if (oph_handle_signals()) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "A problem occurred while setting up signal dispositions\n");
		exit(1);
	}

	if (mysql_library_init(0, 0, 0)) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot setup MySQL\n");
		exit(1);
	}

	oph_tp_start_xml_parser();
	if (CRYPTO_thread_setup()) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot setup thread mutex for OpenSSL\n");
		exit(1);
	}
	soap_init(&soap);
	soap.fget = oph_http_get;
	if (soap_register_plugin(&soap, oph_plugin)) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot register %s plugin\n", OPH_PLUGIN_ID);
		soap_print_fault(&soap, stderr);
		cleanup();
		exit(-1);
	}
	// Register serverid
	struct oph_plugin_data *state = NULL;
	if (!(state = (struct oph_plugin_data *) soap_lookup_plugin(&soap, OPH_PLUGIN_ID))) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "Error on lookup plugin struct\n");
		soap_print_fault(&soap, stderr);
		cleanup();
		exit(-1);
	}
	state->serverid = strdup(oph_web_server);

#ifdef WITH_OPENSSL
	/* init gsoap context and SSL */
	if (soap_ssl_server_context(&soap, SOAP_TLSv1_2, oph_server_cert, oph_server_password, oph_server_ca, NULL, NULL, NULL, NULL)) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "SSL Server Context Error\n");
		soap_print_fault(&soap, stderr);
		cleanup();
		exit(1);
	}
#endif

	soap.accept_timeout = oph_server_inactivity_timeout;
	soap.send_timeout = soap.recv_timeout = oph_server_timeout;
	soap.bind_flags |= SO_REUSEADDR;
	m = soap_bind(&soap, NULL, int_port, 100);
	if (!soap_valid_socket(m)) {
		pmesg(LOG_ERROR, __FILE__, __LINE__, "Soap invalid socket\n");
		soap_print_fault(&soap, stderr);
		cleanup();
		exit(1);
	}
	pmesg(LOG_DEBUG, __FILE__, __LINE__, "Bind successful: socket = %d\n", m);

	for (;;) {
		SOAP_SOCKET s = soap_accept(&soap);
		if (!soap_valid_socket(s)) {
			if (soap.errnum) {
				pmesg(LOG_ERROR, __FILE__, __LINE__, "Soap invalid socket\n");
				soap_print_fault(&soap, stderr);
			} else
				pmesg(LOG_ERROR, __FILE__, __LINE__, "Server timed out (timeout set to %d seconds)\n", soap.accept_timeout);
			break;
		}
		tsoap = soap_copy(&soap);
		if (!tsoap) {
			soap_closesock(&soap);
			continue;
		}
#if defined(_POSIX_THREADS) || defined(_SC_THREADS)
		pthread_create(&tid, NULL, (void *(*)(void *)) &process_request, tsoap);
#else
		process_request(tsoap);
#endif
	}
	cleanup();
	return 0;
}
Example #16
0
/* Processes Reaver command line options */
int process_arguments(int argc, char **argv)
{
	int ret_val = EXIT_SUCCESS;
	int c = 0, channel = 0;
	int long_opt_index = 0;
	char bssid[MAC_ADDR_LEN] = { 0 };
	char mac[MAC_ADDR_LEN] = { 0 };
	char *short_options = "b:e:m:i:t:d:c:T:x:r:g:l:o:p:s:C:KZA5ELfnqvDShwN6J";
	struct option long_options[] = {
		{ "pixie-dust", no_argument, NULL, 'K' },
		{ "interface", required_argument, NULL, 'i' },
		{ "bssid", required_argument, NULL, 'b' },
		{ "essid", required_argument, NULL, 'e' },
		{ "mac", required_argument, NULL, 'm' },
		{ "timeout", required_argument, NULL, 't' },
		{ "m57-timeout", required_argument, NULL, 'T' },
		{ "delay", required_argument, NULL, 'd' },
		{ "lock-delay", required_argument, NULL, 'l' },
		{ "fail-wait", required_argument, NULL, 'x' },
		{ "channel", required_argument, NULL, 'c' },
		{ "session", required_argument, NULL, 's' },
		{ "recurring-delay", required_argument, NULL, 'r' },
		{ "max-attempts", required_argument, NULL, 'g' },
		{ "out-file", required_argument, NULL, 'o' },
		{ "pin", required_argument, NULL, 'p' },
		{ "exec", required_argument, NULL, 'C' },
		{ "no-associate", no_argument, NULL, 'A' },
		{ "ignore-locks", no_argument, NULL, 'L' },
		{ "no-nacks", no_argument, NULL, 'N' },
		{ "eap-terminate", no_argument, NULL, 'E' },
		{ "dh-small", no_argument, NULL, 'S' },
		{ "fixed", no_argument, NULL, 'f' },
		{ "daemonize", no_argument, NULL, 'D' },
		{ "5ghz", no_argument, NULL, '5' },
		{ "repeat-m6", no_argument, NULL, '6' },
		{ "nack", no_argument, NULL, 'n' },
		{ "quiet", no_argument, NULL, 'q' },
		{ "verbose", no_argument, NULL, 'v' },
		{ "win7", no_argument, NULL, 'w' },
		{ "help", no_argument, NULL, 'h' },
		{ "timeout-is-nack", no_argument, NULL, 'J' },
		{ 0, 0, 0, 0 }
	};

	/* Since this function may be called multiple times, be sure to set opt index to 0 each time */
	optind = 0;

	while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1)
        {
                switch(c)
                {
                        case 'Z':
                        case 'K':
                                pixie.do_pixie = 1;
                                break;
                        case 'i':
                                set_iface(optarg);
                                break;
                        case 'b':
                                str2mac(optarg, (unsigned char *) &bssid);
                                set_bssid((unsigned char *) &bssid);
                                break;
                        case 'e':
                                set_ssid(optarg);
                                break;
                        case 'm':
                                str2mac(optarg, (unsigned char *) &mac);
                                set_mac((unsigned char *) &mac);
                                break;
                        case 't':
                                set_rx_timeout(atoi(optarg));
                                break;
                        case 'T':
                                set_m57_timeout(strtof(optarg, NULL) * SEC_TO_US);
                                break;
                        case 'c':
				channel = strtod(optarg, NULL);
                                set_fixed_channel(1);
                                break;
                        case '5':
                                set_wifi_band(AN_BAND);
                                break;
                        case '6':
                                set_repeat_m6(1);
                                break;
                        case 'd':
                                set_delay(atoi(optarg));
                                break;
                        case 'l':
                                set_lock_delay(atoi(optarg));
                                break;
			case 'p':
				parse_static_pin(optarg);
				break;
			case 's':       
				set_session(optarg);   
				break;
			case 'C':
				set_exec_string(optarg);
				break;
			case 'A':
				set_external_association(1);
				break;
                        case 'L':
                                set_ignore_locks(1);
                                break;
			case 'o':
				set_log_file(fopen(optarg, "w"));
				break;
                        case 'x':
                                set_fail_delay(atoi(optarg));
                                break;
                        case 'r':
                                parse_recurring_delay(optarg);
                                break;
                        case 'g':
                                set_max_pin_attempts(atoi(optarg));
                                break;
                        case 'D':
				daemonize();
				break;
			case 'E':
                                set_eap_terminate(1);
                                break;
			case 'S':
				set_dh_small(1);
				break;
                        case 'n':
				cprintf(INFO, "[+] ignoring obsolete -n switch\n");
				break;
			case 'J':
                                set_timeout_is_nack(1);
                                break;
                        case 'f':
                                set_fixed_channel(1);
                                break;
                        case 'v':
                                set_debug(get_debug() + 1);
                                break;
                        case 'q':
                                set_debug(CRITICAL);
                                break;
			case 'w':
				set_win7_compat(1);
				break;
			case 'N':
				set_oo_send_nack(0);
				break;
                        default:
                                ret_val = EXIT_FAILURE;
                }
        }

	if(channel)
	{
		change_channel(channel);
	}

	return ret_val;
}
Example #17
0
static void do_set_cfg(void* arg)
{
    PortState* state = (PortState*)arg;

    erl_drv_mutex_lock(G_ENGINE_STATE_LOCK);
    if (G_ENGINE_STATE == ENGINE_STOPPED)
    {
        char* key   = UNPACK_STRING(state->work_buffer, 0);
        const char* value = UNPACK_STRING(state->work_buffer, strlen(key)+1);

        if (strcmp(key, "error_log") == 0)
        {
            if (set_log_file(value) == 0)
            {
                send_ok(state);
            }
            else
            {
                send_error_atom(state, "einval");
            }
        }
        else
        {
            // Check the expected type of the provided key so as to 1. validate it's a good key
            // and 2. know what setter to use.
            ib_cfg_type_t key_type;
            ib_err_t error = ib_cfg_var_get_type(key, &key_type);
            if (error == DB_SUCCESS)
            {
                if (key_type == IB_CFG_TEXT)
                {
                    // HACK: Semantics of setting a text configuration value for innodb changed
                    // to be pointer assignment (from copy) for vsn 1.0.6.6750. So, we strdup the
                    // value to ensure everything works as expected.
                    // TODO: Setup some sort of list of strdup'd values to ensure they all get
                    // cleaned up properly. In typical usage, this isn't going to be a problem
                    // as you only initialize once per run, but it bothers me just the same.
                    error = ib_cfg_set(key, strdup(value));
                }
                else
                {
                    ErlDrvUInt value_i;
                    UNPACK_INT(state->work_buffer, strlen(key)+1, &value_i);
                    error = ib_cfg_set(key, value_i);
                }

            }

            if (error == DB_SUCCESS)
            {
                send_ok(state);
            }
            else
            {
                send_error_str(state, ib_strerror(error));
            }
        }
    }
    else
    {
        send_error_atom(state, "starting");
    }

    erl_drv_mutex_unlock(G_ENGINE_STATE_LOCK);
}
Example #18
0
int main(int argc, char* argv[]) {
    if (!setupGLFW()) return 1;
    glfwWindowHint(GLFW_SAMPLES, 4);
    setupCoreGL();

    #ifndef __APPLE__
    const char* exePath = dirname(argv[0]);
    const char* resPath = "/Resources/";
    const int newPathLen = strlen(exePath) + strlen(resPath) + 1;
    char newPath[newPathLen];
    strcpy(newPath, exePath);
    strcat(newPath, resPath);

    int cwdError;
    if ((cwdError = chdir(newPath)) != 0) {
        perror(newPath);

        return 1;
    }
    #endif

    set_log_file(fopen("../Logs/uf.log", "a"));
    
    setDebug(DEBUG);
    setBind(DEBUG);
 
    #ifdef FULLSCREEN
    GLFWmonitor* monitor = glfwGetPrimaryMonitor();
    const GLFWvidmode* vidmode = glfwGetVideoMode(monitor);
    int width = vidmode->width;
    int height = vidmode->height;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, monitor, NULL);
    #else
    int width = 640;
    int height = 480;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, NULL, NULL);
    #endif

    if (!window) {
        log_msg(LOG_ERROR, "GLFW3 window creation failed.\n");
        
        return 1;
    }
    
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

    char cwd[PATH_MAX];
    getcwd(cwd, sizeof(cwd));

    log_msg(LOG_INFO, "#####################################\n");
    log_msg(LOG_INFO, "Started Ultra Fighters!\n");
    log_msg(LOG_INFO, "Current Working Directory: %s\n", cwd);
    log_msg(LOG_INFO, "Started loop!\n");
    
    GameScene scene(window);

    std::ifstream levelFile("levelname.txt");
    std::string levelName;
    std::getline(levelFile, levelName);
    WavefrontObject room(levelName.c_str());
    scene.addChild(&room);

    HUD hud;
    scene.addChild(&hud);

    SphereNode snode(glm::vec3(-2, 2, 4), 0.75); // @temp
    scene.addChild(&snode); // @temp

    Loop loop = Loop(&scene);
    loop.start();
    
    while (!glfwGetKey(window, GLFW_KEY_ESCAPE) && !glfwWindowShouldClose(window)) {
        glfwPollEvents();
    }
    
    log_msg(LOG_INFO, "Stopping program...\n");
    loop.stop();
    glfwTerminate();
    
    return 0;
}
Example #19
0
int main(int argc, char *argv[])
{
    if (argc < 3)
    {
        fprintf(stderr, "%s [server name] [log file] ([config file]...)\n", argv[0]);
        return 1;
    }

    set_initial_id(); /*NOTE: must be before log file for su servers*/
    set_log_file(argv[2]);

    /*setup~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    if (!set_program_name(argv[0])) return 1;
    if (!change_server_name(argv[1]))
    {
        fprintf(stderr, "%s: invalid server name '%s'\n", argv[0], argv[1]);
        return 1;
    }

    /*use 'clean_server_exit' below here (after initialization)*/

    if (!initialize_server())
    {
        fprintf(stderr, "%s: couldn't initialize server (check log file)\n", argv[0]);
        clean_server_exit(1);
    }


    /*NOTE: stop using standard error here and use logging only because of daemonizing*/


    start_server();


    int current_pid = getpid();


#ifndef PARAM_NO_DAEMON
    if (getsid(0) != getpid())
    {
        notify_parent = current_pid;

        pid_t daemon = fork();

        if (daemon < 0)
        {
            log_server_daemon_error(strerror(errno));
            fprintf(stderr, "%s: daemon error (check log file)\n", argv[0]);
            clean_server_exit(1);
        }

        if (daemon == 0)
        {
            log_server_daemon(current_pid, getpid());
#ifndef PARAM_NO_SESSION

            if (getpid() == setsid())
                /*NOTE: leave 'getpid' first here in case of error*/
                log_server_session_set();

            else
            {
                log_server_session_error(strerror(errno));
                fprintf(stderr, "%s: session error (check log file)\n", argv[0]);
                clean_server_exit(1);
            }
#else
            setpgid(0, 0);
#endif

            raise(SIGSTOP);
        }

        else
        {
            setpgid(0, 0);

            signal(SIGUSR1, &parent_signal);
            signal(SIGUSR2, &parent_signal);

            int error = 0, status = 0;

            while ( ((error = waitpid(daemon, &status, WUNTRACED)) < 0 && errno == EINTR) ||
                    (!WIFSTOPPED(status) && !WIFEXITED(status)) );

            if (error < 0 || WIFEXITED(status))
            {
                fprintf(stderr, "%s: internal error: %s\n", argv[0],
                        (error < 0)? strerror(errno) : "unknown error");
                partial_server_exit(1);
            }

            kill(daemon, SIGCONT);

            struct timespec register_wait = server_register_all_wait();
            nanosleep(&register_wait, NULL);

            partial_server_exit(1);
        }
    }

    else
        log_server_session_leader();
#endif


    set_env_pid();

    if (set_terminal())
        log_server_terminal();

    set_controlling_pid(getpid());
    /*END setup~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


    /*scheduling setup~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    struct sched_param parameters =
    { sched_priority: sched_get_priority_max(SCHED_RR) };
Example #20
0
int main(int argc, char *argv[])
{
	int c = 0;
	FILE *fp = NULL;
	int long_opt_index = 0, i = 0, channel = 0, passive = 0, mode = 0;
	int source = INTERFACE, ret_val = EXIT_FAILURE;
	struct bpf_program bpf = { 0 };
	char *out_file = NULL, *last_optarg = NULL, *target = NULL, *bssid = NULL;
	char *short_options = "i:c:n:o:b:5sfuCDh";
        struct option long_options[] = {
		{ "bssid", required_argument, NULL, 'b' },
                { "interface", required_argument, NULL, 'i' },
                { "channel", required_argument, NULL, 'c' },
		{ "out-file", required_argument, NULL, 'o' },
		{ "probes", required_argument, NULL, 'n' },
		{ "daemonize", no_argument, NULL, 'D' },
		{ "file", no_argument, NULL, 'f' },
		{ "ignore-fcs", no_argument, NULL, 'C' },
		{ "5ghz", no_argument, NULL, '5' },
		{ "scan", no_argument, NULL, 's' },
		{ "survey", no_argument, NULL, 'u' },
                { "help", no_argument, NULL, 'h' },
                { 0, 0, 0, 0 }
        };

	fprintf(stderr, "\nWash v%s WiFi Protected Setup Scan Tool\n", PACKAGE_VERSION);
        fprintf(stderr, "Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <*****@*****.**>\n\n");

	globule_init();
	sql_init();
	create_ap_table();
	set_auto_channel_select(0);
	set_wifi_band(BG_BAND);
	set_debug(INFO);
	set_validate_fcs(1);
	set_log_file(stdout);
	set_max_num_probes(DEFAULT_MAX_NUM_PROBES);

	while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1)
        {
                switch(c)
                {
			case 'f':
				source = PCAP_FILE;
				break;
			case 'i':
				set_iface(optarg);
				break;
			case 'b':
				bssid = strdup(optarg);
				break;
			case 'c':
				channel = atoi(optarg);
				set_fixed_channel(1);
				break;
			case '5':
				set_wifi_band(AN_BAND);
				break;
			case 'n':
				set_max_num_probes(atoi(optarg));
				break;
			case 'o':
				out_file = strdup(optarg);
				break;
			case 's':
				mode = SCAN;
				break;
			case 'u':
				mode = SURVEY;
				break;
			case 'C':
				set_validate_fcs(0);
				break;
			case 'D':
				daemonize();
				break;
			default:
				usage(argv[0]);
				goto end;
		}

		/* Track the last optarg. This is used later when looping back through any specified pcap files. */
		if(optarg)
		{
			if(last_optarg)
			{
				free(last_optarg);
			}

			last_optarg = strdup(optarg);
		}
	}

	/* The interface value won't be set if capture files were specified; else, there should have been an interface specified */
	if(!get_iface() && source != PCAP_FILE)
	{
		usage(argv[0]);
		goto end;
	}

	if(get_iface() && source == PCAP_FILE)
	{
		cprintf(CRITICAL, "[X] ERROR: -i and -f options cannot be used together.\n");
		usage(argv[0]);
		goto end;
	}

	/* If we're reading from a file, be sure we don't try to transmit probe requests */
	if(source == PCAP_FILE)
	{
		passive = 1;
	}

	/* Open the output file, if any. If none, write to stdout. */
	if(out_file)
	{
		fp = fopen(out_file, "wb");
		if(!fp)
		{
			cprintf(CRITICAL, "[X] ERROR: Failed to open '%s' for writing\n", out_file);
			goto end;
		}

		set_log_file(fp);
	}

	/* 
	 * Loop through all of the specified capture sources. If an interface was specified, this will only loop once and the
	 * call to monitor() will block indefinitely. If capture files were specified, this will loop through each file specified
	 * on the command line and monitor() will return after each file has been processed.
	 */
	for(i=argc-1; i>0; i--)
	{
		/* If the source is a pcap file, get the file name from the command line */
		if(source == PCAP_FILE)
		{
			/* If we've gotten to the arguments, we're done */
			if((argv[i][0] == '-') ||
			   (last_optarg && (memcmp(argv[i], last_optarg, strlen(last_optarg)) == 0))
			)
			{
				break;
			}
			else
			{
				target = argv[i];
			}
		}
		/* Else, use the specified interface name */
		else
		{
			target = get_iface();
		}

		set_handle(capture_init(target));
		if(!get_handle())
		{
			cprintf(CRITICAL, "[X] ERROR: Failed to open '%s' for capturing\n", get_iface());
			goto end;
		}

		if(pcap_compile(get_handle(), &bpf, PACKET_FILTER, 0, 0) != 0)
		{
			cprintf(CRITICAL, "[X] ERROR: Failed to compile packet filter\n");
			goto end;
		}
		
		if(pcap_setfilter(get_handle(), &bpf) != 0)
		{
			cprintf(CRITICAL, "[X] ERROR: Failed to set packet filter\n");
			goto end;
		}

		/* Do it. */
		monitor(bssid, passive, source, channel, mode);
		printf("\n");
	}

	ret_val = EXIT_SUCCESS;

end:
	globule_deinit();
	sql_cleanup();
	if(bssid) free(bssid);
	if(out_file) free(out_file);
	if(wpsmon.fp) fclose(wpsmon.fp);
	return ret_val;
}
void set_global_values(const char *configuration_file)
{
	if (!configuration_file)
		return;
	pmesg(LOG_INFO, __FILE__, __LINE__, "Loading configuration from '%s'\n", configuration_file);

	oph_server_params = hashtbl_create(HASHTBL_KEY_NUMBER, NULL);
	if (!oph_server_params)
		return;

	char tmp[OPH_MAX_STRING_SIZE];
	char *value;
	FILE *file = fopen(configuration_file, "r");
	if (file) {
		char key[OPH_MAX_STRING_SIZE], value2[OPH_MAX_STRING_SIZE];
		while (fgets(tmp, OPH_MAX_STRING_SIZE, file)) {
			if (strlen(tmp)) {
				tmp[strlen(tmp) - 1] = '\0';
				if (tmp[0] == OPH_COMMENT_MARK)
					continue;	// Skip possible commented lines
				value = strchr(tmp, OPH_SEPARATOR_KV[0]);
				if (value) {
					value++;
					snprintf(key, value - tmp, "%s", tmp);
					if (value[0]) {
						if (value[0] == OPH_SUBSTITUTION_MARK && !strncasecmp(value + 1, OPH_SERVER_LOCATION_STR, strlen(OPH_SERVER_LOCATION_STR))) {
							snprintf(value2, OPH_MAX_STRING_SIZE, "%s%s", oph_server_location, value + strlen(OPH_SERVER_LOCATION_STR) + 1);
							value = value2;
						}
						hashtbl_insert(oph_server_params, key, value);
					} else
						hashtbl_insert(oph_server_params, key, "");
					pmesg(LOG_DEBUG, __FILE__, __LINE__, "Read %s=%s\n", key, value);
				}
			}
		}
		fclose(file);
	}
	// Pre-process
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_TIMEOUT)))
		oph_server_timeout = strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_INACTIVITY_TIMEOUT)))
		oph_server_inactivity_timeout = strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_WORKFLOW_TIMEOUT)))
		oph_server_workflow_timeout = strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SERVER_FARM_SIZE)))
		oph_server_farm_size = (unsigned int) strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_QUEUE_SIZE)))
		oph_server_queue_size = (unsigned int) strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_AUTO_RETRY)))
		oph_auto_retry = (unsigned int) strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_POLL_TIME)))
		oph_server_poll_time = (unsigned int) strtol(value, NULL, 10);
	if ((value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_BASE_BACKOFF)))
		oph_base_backoff = (unsigned int) strtol(value, NULL, 10);
	if (!logfile && (value = hashtbl_get(oph_server_params, OPH_SERVER_CONF_LOGFILE))) {
		pmesg(LOG_INFO, __FILE__, __LINE__, "Selected log file '%s'\n", value);
		logfile = fopen(value, "a");
		if (logfile)
			set_log_file(logfile);
		// Redirect stdout and stderr to logfile
		if (!freopen(value, "a", stdout))
			pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in redirect stdout to logfile\n");
		if (!freopen(value, "a", stderr))
			pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in redirect stderr to logfile\n");
	}
	// Default values
	if (!oph_server_protocol && !(oph_server_protocol = hashtbl_get(oph_server_params, OPH_SERVER_CONF_PROTOCOL))) {
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_PROTOCOL, OPH_DEFAULT_PROTOCOL);
		oph_server_protocol = hashtbl_get(oph_server_params, OPH_SERVER_CONF_PROTOCOL);
	}
	if (!oph_server_host && !(oph_server_host = hashtbl_get(oph_server_params, OPH_SERVER_CONF_HOST))) {
		if (!gethostname(tmp, OPH_MAX_STRING_SIZE))
			hashtbl_insert(oph_server_params, OPH_SERVER_CONF_HOST, tmp);
		else
			hashtbl_insert(oph_server_params, OPH_SERVER_CONF_HOST, OPH_DEFAULT_HOST);
		oph_server_host = hashtbl_get(oph_server_params, OPH_SERVER_CONF_HOST);
	}
	if (!oph_server_port && !(oph_server_port = hashtbl_get(oph_server_params, OPH_SERVER_CONF_PORT))) {
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_PORT, OPH_DEFAULT_PORT);
		oph_server_port = hashtbl_get(oph_server_params, OPH_SERVER_CONF_PORT);
	}
	if (!(oph_server_cert = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CERT))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SERVER_CERT, oph_server_location);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_CERT, tmp);
		oph_server_cert = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CERT);
	}
	if (!(oph_server_ca = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CA))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SERVER_CA, oph_server_location);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_CA, tmp);
		oph_server_ca = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CA);
	}
	if (!(oph_server_password = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CERT_PASSWORD))) {
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_CERT_PASSWORD, OPH_SERVER_PASSWORD);
		oph_server_password = hashtbl_get(oph_server_params, OPH_SERVER_CONF_CERT_PASSWORD);
	}
	if (!(oph_rmanager_conf_file = hashtbl_get(oph_server_params, OPH_SERVER_CONF_RMANAGER_CONF_FILE))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_RMANAGER_CONF_FILE, oph_server_location);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_RMANAGER_CONF_FILE, tmp);
		oph_rmanager_conf_file = hashtbl_get(oph_server_params, OPH_SERVER_CONF_RMANAGER_CONF_FILE);
	}
	if (!(oph_auth_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_AUTHZ_DIR))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SERVER_AUTHZ, oph_server_location);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_AUTHZ_DIR, tmp);
		oph_auth_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_AUTHZ_DIR);
	}
	if (!(oph_txt_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_TXT_DIR))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_TXT_LOCATION, oph_server_location);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_TXT_DIR, tmp);
		oph_txt_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_TXT_DIR);
	}
	if (!(oph_web_server = hashtbl_get(oph_server_params, OPH_SERVER_CONF_WEB_SERVER))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_WEB_SERVER);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_WEB_SERVER, tmp);
		oph_web_server = hashtbl_get(oph_server_params, OPH_SERVER_CONF_WEB_SERVER);
	}
	if (!(oph_web_server_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_WEB_SERVER_LOCATION))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_WEB_SERVER_LOCATION);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_WEB_SERVER_LOCATION, tmp);
		oph_web_server_location = hashtbl_get(oph_server_params, OPH_SERVER_CONF_WEB_SERVER_LOCATION);
	}
	if (!(oph_operator_client = hashtbl_get(oph_server_params, OPH_SERVER_CONF_OPERATOR_CLIENT))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_OPERATOR_CLIENT);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_OPERATOR_CLIENT, tmp);
		oph_operator_client = hashtbl_get(oph_server_params, OPH_SERVER_CONF_OPERATOR_CLIENT);
	}
	if (!(oph_ip_target_host = hashtbl_get(oph_server_params, OPH_SERVER_CONF_IP_TARGET_HOST))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_IP_TARGET_HOST);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_IP_TARGET_HOST, tmp);
		oph_ip_target_host = hashtbl_get(oph_server_params, OPH_SERVER_CONF_IP_TARGET_HOST);
	}
	if (!(oph_subm_user = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SUBM_USER);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_SUBM_USER, tmp);
		oph_subm_user = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER);
	}
	if (!(oph_subm_user_publk = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PUBLK))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SUBM_USER_PUBLK);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PUBLK, tmp);
		oph_subm_user_publk = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PUBLK);
	}
	if (!(oph_subm_user_privk = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PRIVK))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SUBM_USER_PRIVK);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PRIVK, tmp);
		oph_subm_user_privk = hashtbl_get(oph_server_params, OPH_SERVER_CONF_SUBM_USER_PRIVK);
	}
	if (!(oph_xml_operators = hashtbl_get(oph_server_params, OPH_SERVER_CONF_XML_URL))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_CLIENT_XML_URL);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_XML_URL, tmp);
		oph_xml_operators = hashtbl_get(oph_server_params, OPH_SERVER_CONF_XML_URL);
	}
	if (!(oph_xml_operator_dir = hashtbl_get(oph_server_params, OPH_SERVER_CONF_XML_DIR))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_SERVER_XML_EXT_PATH);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_XML_DIR, tmp);
		oph_xml_operator_dir = hashtbl_get(oph_server_params, OPH_SERVER_CONF_XML_DIR);
	}
	if (!(oph_user_notifier = hashtbl_get(oph_server_params, OPH_SERVER_CONF_NOTIFIER))) {
		snprintf(tmp, OPH_MAX_STRING_SIZE, OPH_USER_NOTIFIER);
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_NOTIFIER, tmp);
		oph_user_notifier = hashtbl_get(oph_server_params, OPH_SERVER_CONF_NOTIFIER);
	}
	if (!(oph_base_src_path = hashtbl_get(oph_server_params, OPH_SERVER_CONF_BASE_SRC_PATH))) {
		hashtbl_insert(oph_server_params, OPH_SERVER_CONF_BASE_SRC_PATH, OPH_BASE_SRC_PATH);
		oph_base_src_path = hashtbl_get(oph_server_params, OPH_SERVER_CONF_BASE_SRC_PATH);
	}


	oph_json_location = oph_web_server_location;	// Position of JSON Response will be the same of web server
}