예제 #1
7
파일: copy.c 프로젝트: alreimer/httpd_nh221
inline void include_(char *line, char *var_head, FILE *out)	//SSI made total brutal, no checks of file path, and include must be along in string of file!
{
    char *var_head2;
    struct parsestr strct;

do{
    if ((var_head2 = parsestr2(&strct, var_head,"par=\"/[/*/]\"/ "))!=NULL){	//<!--#include par="size:web_name:name:pattern" -->
	/*collect parameters in a array*/
	char *a, *ptr;
	int i = 0, str_size, val_size;
	struct cfg_parse1 *cfg_pointer;
	*cfg_p = (struct cfg_parse1 *)malloc(sizeof(struct cfg_parse1));

	cfg_pointer = *cfg_p;
	if(cfg_pointer == NULL) continue;
	ptr = var_head2;

	    while(i < 3){
		a = w_strtok(&ptr, ':');
	        if(a)
		    switch(i){
		    case 0:	val_size = atoi(a);
				if(!val_size || val_size > 300) return;	//size is in impassable range - so skip it all (whole parameter string will be skipped!)
				a = ptr;
				str_size = strlen(a)+1;
				ptr = (char*)malloc(str_size + 2*val_size);//str = "[part of var_head2][value][new_value]"
				if(ptr == NULL){
					i = 5; continue;
				}
				strcpy(ptr, a);
				cfg_pointer->type = CFG_PAR;
				cfg_pointer->str = ptr;
				cfg_pointer->size = val_size;
				cfg_pointer->changed = 0;
				cfg_pointer->saved = 0;
				cfg_pointer->value = ptr + str_size;
//				*(cfg_pointer->value) = '\0';
				cfg_pointer->new_value = ptr + str_size + val_size;
//				*(cfg_pointer->new_value) = '\0';
				memset(cfg_pointer->value, 0, 2*val_size);//fill with zeros
				cfg_pointer->name = NULL;
				cfg_pointer->pattern = NULL;
				cfg_pointer->web_name = NULL;
				cfg_pointer->next = NULL;
				break;
	    	    case 1:	cfg_pointer->web_name = a; break;
		    case 2:	cfg_pointer->name = a; cfg_pointer->pattern = ptr; break;
		    }
		else {
		    printf("par=\"\" not full, broken by %d\n", i+1);
		    break;
		}
	    i++;
	    }
	if(i != 5){
printf("Collected parameter: %s:%s:%lld:%s\n", cfg_pointer->web_name, cfg_pointer->name, cfg_pointer->size, cfg_pointer->pattern);
	    cfg_p = &(cfg_pointer->next);
	}else{
	    printf("ERROR allocate memory\n");
	    if(cfg_p && *cfg_p){
		free(*cfg_p);
		*cfg_p = NULL;	//main criteria to abort moving in array.
	    }
	}

    } else if ((var_head2 = parsestr2(&strct, var_head,"readcfg/ "))!=NULL){	//<!--#include readcfg -->
	/*start to fill parameters from config to collected array*/
	ReadConfiguration();
    } else if ((var_head2 = parsestr2(&strct, var_head,"area=\"/[/*/]\"/ "))!=NULL){	//<!--#include area="size:web_name" -->
	/*collect parameters in a array*/
	char *a, *ptr;
	int i = 0, str_size;
	long long val_size;
	struct cfg_parse1 *cfg_pointer;
	*cfg_p = (struct cfg_parse1 *)malloc(sizeof(struct cfg_parse1));

	cfg_pointer = *cfg_p;
	if(cfg_pointer == NULL) continue;
	ptr = var_head2;

	    while(i < 2){
		a = w_strtok(&ptr, ':');
	        if(a)
		    switch(i){
		    case 0:	val_size = atoll(a);
				if(val_size > 32 *1024) return;	//size is in impassable range - so skip it all (whole parameter string will be skipped!)
				a = ptr;
				str_size = strlen(a)+1;
				ptr = (char*)malloc(str_size + val_size);//str = "[part of var_head2][value]"
				if(ptr == NULL){
					i = 5; continue;
				}
				strcpy(ptr, a);
				cfg_pointer->type = (val_size != 0) ? CFG_AREA : CFG_TMP;
				cfg_pointer->str = ptr;
				cfg_pointer->size = val_size;
				cfg_pointer->changed = 0;
				cfg_pointer->saved = 0;
				if(val_size != 0){//AREA="size:name"
				cfg_pointer->value = ptr + str_size;
				cfg_pointer->new_value = ptr + str_size;
				memset(cfg_pointer->value, 0, val_size);//fill memory with 0
				}else{//AREA="0:temp_name"
				cfg_pointer->value = NULL;
				cfg_pointer->new_value = NULL;
				}
				cfg_pointer->name = NULL; //ptr + str_size - 1;
				cfg_pointer->pattern = NULL; //ptr + str_size - 1;
				cfg_pointer->web_name = NULL;
				cfg_pointer->next = NULL;
				break;
		    case 1:	cfg_pointer->web_name = a; break;
		    }
		else {
		    printf("area=\"\" not full, broken by %d\n", i+1);
		    break;
		}
	    i++;
	    }
	if(i != 5){
printf("Collected parameter: [%s:%lld]\n", cfg_pointer->web_name, cfg_pointer->size);
	    cfg_p = &(cfg_pointer->next);
	}else{
	    printf("ERROR allocate memory\n");
	    if(cfg_p && *cfg_p){
		free(*cfg_p);
		*cfg_p = NULL;	//main criteria to abort moving in array.
	    }
	}

    } else
    
//printf("include file: %s\n", var_head);
    if ((var_head2 = parsestr2(&strct, var_head,"file=\"/[/*/N\\N/]\"/ "))!=NULL){	//<!--#include file="..\".." -->

//printf("include file: %s\n", var_head2);
	copy_file_include(var_head2, out);
    } else
    if ((var_head2 = parsestr2(&strct, var_head,"exec=\"/[/*/]\"/ "))!=NULL){	//<!--#include exec="..." -->

        my_system(out, var_head2);
    } else if ((var_head2 = parsestr2(&strct, var_head,"shell=\"\"/[/*/]\"\"/ "))!=NULL){	//<!--#include shell=""..."" -->

        my_shell(out, var_head2);
    } else if ((var_head2 = parsestr2(&strct, var_head,"cgi=\"/[/*/]\"/ "))!=NULL){	//<!--#include cgi="..." -->

	if(DoCGI(out, var_head2))  fprintf(out, "Not Found: %s\n", var_head2);// what about arg??
	else  free_par_tmp();//clear all "temp"-parameters

    } else if((var_head2 = parsestr2(&strct, var_head, "tbl_select=\"/[/*/]\"/ "))!=NULL){

	show_tbl(var_head2, out);
    } else if((var_head2 = parsestr2(&strct, var_head, "tbl_check=\"/[/*/]\"/ "))!=NULL){

	show_tbl_chck(var_head2, out);
    } else if((var_head2 = parsestr2(&strct, var_head, "chtbl_stat=\"/[/*/]\"/ "))!=NULL){

	change_tbl_stat(var_head2);
    } else if((var_head2 = parsestr2(&strct, var_head, "InIt/ "))!=NULL){		//<!--#include InIt -->

	ReadConfiguration();
    } else if((var_head2 = parsestr2(&strct, var_head, "write_par=\"/[/*/N\\N/]\"/ "))!=NULL){	//<!--#include write_par="par:value" -->

		// write_par  par:value		this is used in copy_CGI.c - the same code!
		char *tmp, *tmp2;
		long long size;
			    tmp2 = w_strtok(&var_head2, ':');
			    if(tmp2 && *tmp2 && *var_head2){
			    	tmp = get_var(&size, tmp2);
				if(tmp && size){
				    strncpy_(tmp, var_head2, size-1);
//				    tmp[size-1] = '\0';
				}
//				if(tmp2 != var_head2) *(var_head2-1) = ':';
			    }
    }//need some end hier (else)

}while(var_head2 && (var_head = strct.end));	//end of parsing string

}
예제 #2
0
//
// Initialize the exemption subsystem
//
VOID InitializeExecutive()
{
	ULONG ConfigEnabledSubsystems = 0;

	//
	// Initialize the exemption list and synchronization objects
	//
	InitializeListHead(
			&ThreadExemptionList);
	ExInitializeFastMutex(
			&ThreadExemptionListMutex);

	//
	// Initialize the region exemption list and synchronization objects
	//
	InitializeListHead(
			&RegionExemptionList);
	ExInitializeFastMutex(
			&RegionExemptionListMutex);

	//
	// Initialize the randomization state based on what's been defined in the
	// configuration registry key
	//
	ReadConfiguration(
			&ConfigEnabledSubsystems);

	DebugPrint(("InitializeExecutive(): CONFIG: ConfigEnabledSubsystems mask is %.8x.",
			ConfigEnabledSubsystems));

	EnableRandomizationSubsystems(
			ConfigEnabledSubsystems,
			TRUE);
}
예제 #3
0
파일: md2.c 프로젝트: kneth/MDreac
int main(int argc, char *argv[]) {

    size_t i;
    FILE *statfile;

    ReadParameters(argc, argv);
    Initialize();
    statfile = fopen(outname, "w");
    ReadConfiguration();
    for(i=0; i<nsteps; i++) { /* a number of single time steps */
        ApplyPerBoundaries();
        if ((i % liststeps) == 0) {
            PutInBox();
            MakeList();
        }
        ComputeForces();
        if (microcanon) {
            Leapfrog();
        }
        else {
            NoseHoover();
        }
        if ((i % iosteps) == 0) {
            fprintf(statfile, "%ld %e %e %e %e %e\n", i, Ekin, Epot, P, eta, Ekin+Epot);
        }
    }
    fclose(statfile);
    WriteConfiguration(final_conf);
    return 1;
}
예제 #4
0
int
XplServiceMain(int argc, char *argv[])
{
    int ccode;
    int startupOpts;

    if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) {
        Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser());
        return(1);
    }
    XplInit();

    /* initialize all the libraries we need to */
    startupOpts = BA_STARTUP_CONNIO | BA_STARTUP_NMAP;
    ccode = BongoAgentInit(&AVirus.agent, AGENT_NAME, DEFAULT_CONNECTION_TIMEOUT, startupOpts);
    if ( ccode == -1) {
        LogFailureF("%s: Exiting", AGENT_NAME);
        return -1;
    }

    ReadConfiguration();
    AVirus.nmap.ssl.config.key.file = MsgGetFile(MSGAPI_FILE_PRIVKEY, NULL, 0);
    AVirus.nmap.ssl.config.certificate.file = MsgGetFile(MSGAPI_FILE_PUBKEY, NULL, 0);
    AVirus.nmap.ssl.config.key.type = GNUTLS_X509_FMT_PEM;
    AVirus.nmap.ssl.context = ConnSSLContextAlloc(&(AVirus.nmap.ssl.config));

    XplSignalHandler(SignalHandler);

    /* start the server thread */
    XplStartMainThread(AGENT_NAME, &id, AntiVirusServer, 8192, NULL, ccode);
    
    XplUnloadApp(XplGetThreadID());
    return 0;
}
예제 #5
0
파일: itip.c 프로젝트: bongo-project/bongo
int
XplServiceMain(int argc, char *argv[])
{
    int ccode;
    int minThreads;
    int maxThreads;
    int minSleep;
    int startupOpts;

    if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) {
        XplConsolePrintf(AGENT_NAME ": Could not drop to unprivileged user '%s'\r\n" AGENT_NAME ": exiting.\n", MsgGetUnprivilegedUser());
        return -1;
    }
    XplInit();

    strcpy(ItipAgent.nmapAddress, "127.0.0.1");

    /* Initialize the Bongo libraries */
    startupOpts = BA_STARTUP_CONNIO | BA_STARTUP_NMAP;
    ccode = BongoAgentInit(&ItipAgent.agent, AGENT_NAME, DEFAULT_CONNECTION_TIMEOUT, startupOpts);
    if (ccode == -1) {
        XplConsolePrintf(AGENT_NAME ": Exiting.\r\n");
        return -1;
    }

    BongoCalInit(MsgGetDir(MSGAPI_DIR_DBF, NULL, 0));

    /* Set up socket for listening on an incoming queue */ 
    ItipAgent.queueNumber = Q_FIVE;
    ItipAgent.nmapConn = BongoQueueConnectionInit(&ItipAgent.agent, ItipAgent.queueNumber);

    if (!ItipAgent.nmapConn) {
        BongoAgentShutdown(&ItipAgent.agent);
        XplConsolePrintf(AGENT_NAME ": Exiting.\r\n");
        return -1;
    }

    BongoQueueAgentGetThreadPoolParameters(&ItipAgent.agent,
                                          &minThreads, &maxThreads, &minSleep);
    
    /* Create a thread pool for managing connections */
    ItipAgent.threadPool = BongoThreadPoolNew(AGENT_DN " Clients",
                                          BONGO_QUEUE_AGENT_DEFAULT_STACK_SIZE,
                                          minThreads, maxThreads, minSleep);

    if (ItipAgent.threadPool == NULL) {
        BongoAgentShutdown(&ItipAgent.agent);
        XplConsolePrintf(AGENT_NAME ": Unable to create thread pool.\r\n" AGENT_NAME ": Exiting.\r\n");
        return -1;
    }
    
    ReadConfiguration();

    XplSignalHandler(SignalHandler);

    /* Start the server thread */
    XplStartMainThread(AGENT_NAME, &id, ItipAgentServer, 8192, NULL, ccode);
    
    return 0;
}
예제 #6
0
파일: acpland.cpp 프로젝트: josthas/KrusAGS
void ResetConfiguration()
{
  reset_configuration = true;

  ReadConfiguration(ANDROID_CONFIG_FILENAME, true);

  reset_configuration = false;
}
예제 #7
0
파일: acplios.cpp 프로젝트: Aquilon96/ags
bool readConfigFile(char* directory)
{
  chdir(directory);

  ResetConfiguration();

  return ReadConfiguration(IOS_CONFIG_FILENAME, true);
}
예제 #8
0
파일: Setting.cpp 프로젝트: mmanley/Antares
Setting::Setting(const char *name)
	:
	fAuto(true)
{
	fSocket = socket(AF_INET, SOCK_DGRAM, 0);
	fName = name;
	ReadConfiguration();	
}
예제 #9
0
Settings::Settings(const char* name)
	:
	fAuto(true),
	fDisabled(false),
	fNameServers(5, true)
{
	fName = name;

	ReadConfiguration();
}
예제 #10
0
파일: acpland.cpp 프로젝트: josthas/KrusAGS
JNIEXPORT jboolean JNICALL
  Java_com_bigbluecup_android_PreferencesActivity_readConfigFile(JNIEnv* env, jobject object, jstring directory)
{
  const char* cdirectory = env->GetStringUTFChars(directory, NULL);
  chdir(cdirectory);
  env->ReleaseStringUTFChars(directory, cdirectory);

  ResetConfiguration();

  return ReadConfiguration(ANDROID_CONFIG_FILENAME, true);
}
예제 #11
0
/*-------------------------------------------------*/
void ParameterInit()
{
  printf("\n ParameterInit\n");
  masses = new double[4];
  ReadConfiguration();
  PulseLimitsInit();
  ADCInit();
  QDCInit();
  PrintParameters();
  printf("Finished initialising parameters - to the sorting!\n");
}
예제 #12
0
파일: Settings.cpp 프로젝트: mariuz/haiku
Settings::Settings(const char* name)
	:
	fAuto(true), 
	fDisabled(false),
	fNameServers(5, true)
{
	fSocket = socket(AF_INET, SOCK_DGRAM, 0);
	fName = name;

	ReadConfiguration();
}
예제 #13
0
NetworkSettings::NetworkSettings(const char* name)
	:
	fDisabled(false),
	fNameServers(5, true)
{
	fName = name;
	_DetectProtocols();

	fNetworkDevice = new BNetworkDevice(fName);
	fNetworkInterface = new BNetworkInterface(fName);

	ReadConfiguration();
}
예제 #14
0
int start_ipc(void *hapd,unsigned char *ssid_p, int *ssid_len_p,void *inject_func, char *cap_info){
	
	memcpy( wlan0_capa, cap_info, 21);
	
	ReadConfiguration(&con_wtp);
	
	int sockfd = open_socket();
	
	goto_preconnect(sockfd, hapd);
	wait_ADD_WLAN(sockfd, ssid_p, ssid_len_p, hapd); 
	
	wl.frag = -1;
	wl.rts = -1;
	wl.freq_params.channel = 0;
	wl.freq_params.ht_enabled = 0;
	wl.freq_params.mode = 0;
	wl.freq_params.sec_channel_offset = 0;
	wl.freq_params.freq = 2452;
	
	wl.que[0].queue_id = 0;
	wl.que[0].cwmin = 3;
	wl.que[0].cwmax = 7;
	wl.que[0].aifs = 2;
	
	wl.que[1].queue_id = 1;
	wl.que[1].cwmin = 7;
	wl.que[1].cwmax = 15;
	wl.que[1].aifs = 2;
	
	wl.que[2].queue_id = 2;
	wl.que[2].cwmin = 15;
	wl.que[2].cwmax = 1023;
	wl.que[2].aifs = 3;
	
	wl.que[3].queue_id = 3;
	wl.que[3].cwmin = 31;
	wl.que[3].cwmax = 1023;
	wl.que[3].aifs = 7;
	
	//void (*pointer_WTP_inject_frame_in_air)(void*,unsigned char*,int);
	//pointer_WTP_inject_frame_in_air = inject_func;
		
	if(sockfd){
		if (eloop_register_read_sock(sockfd, recv_request, hapd, inject_func)) {
			wpa_printf(MSG_ERROR, "Clould not register IPC socket start_ipc");
			return 0;
		}
	}
	wpa_printf(MSG_DEBUG, "SOCKET Created %d",sockfd);
	return sockfd;
}
예제 #15
0
파일: acplios.cpp 프로젝트: Aquilon96/ags
void startEngine(char* filename, char* directory, int loadLastSave)
{
  strcpy(psp_game_file_name, filename);

  // Get the base directory (usually "/sdcard/ags").
  chdir(directory);

  // Reset configuration.
  ResetConfiguration();

  // Read general configuration.
  ReadConfiguration(IOS_CONFIG_FILENAME, true);

  // Get the games path.
  char path[256];
  strcpy(path, psp_game_file_name);
  int lastindex = strlen(path) - 1;
  while (path[lastindex] != '/')
  {
    path[lastindex] = 0;
    lastindex--;
  }
  chdir(path);
  
  setenv("ULTRADIR", "..", 1);

  // Read game specific configuration.
  ReadConfiguration(IOS_CONFIG_FILENAME, false);

  psp_load_latest_savegame = loadLastSave;

  // Start the engine main function.
  main(1, &psp_game_file_name_pointer);
  
  // Explicitly quit here, otherwise the app will hang forever.
  exit(0);
}
예제 #16
0
void __fastcall TMainFrm::FormCreate(TObject *Sender)
{
IndyVersionLabel->Caption=POP->Version;
  ReadConfiguration();
   //setup path to put attachments into
   FAttachPath = IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))); //starting directory
   FAttachPath = FAttachPath + "Attach\\";
   if (!DirectoryExists(FAttachPath))
     ForceDirectories(FAttachPath);

   FMsgCount = 0;
   FMailBoxSize = 0;
   ShowBusy(false);

}
예제 #17
0
//-----------interface with outside functions-----------------------------------
bool EnvironmentROBARM::InitializeEnv(const char* sEnvFile)
{

	FILE* fCfg = fopen(sEnvFile, "r");
	if(fCfg == NULL)
	{
		printf("ERROR: unable to open %s\n", sEnvFile);
		exit(1);
	}
	ReadConfiguration(fCfg);

	//Initialize other parameters of the environment
	InitializeEnvConfig();

	//initialize Environment
	if(InitializeEnvironment() == false)
        return false;

	//pre-compute heuristics
	ComputeHeuristicValues();

	return true;
}
void SingleWallCalibrationToolbox::OnActivated()
{
  LOG_TRACE("SingleWallCalibrationToolbox::OnActivated"); 

  if (m_State == ToolboxState_Done)
  {
    SetDisplayAccordingToState();
    return;
  }

  if ( (m_ParentMainWindow->GetVisualizationController()->GetDataCollector() != NULL)
    && (m_ParentMainWindow->GetVisualizationController()->GetDataCollector()->GetConnected()))
  {
    if (m_Calibration->ReadConfiguration(vtkPlusConfig::GetInstance()->GetDeviceSetConfigurationData()) != PLUS_SUCCESS)
    {
      LOG_ERROR("Reading single wall calibration configuration failed!");
      return;
    }

    // Read spatial calibration configuration
    if (ReadConfiguration(vtkPlusConfig::GetInstance()->GetDeviceSetConfigurationData()) != PLUS_SUCCESS)
    {
      LOG_ERROR("Reading spatial calibration configuration failed!");
      return;
    }

    // Set initialized if it was uninitialized
    if (m_State == ToolboxState_Uninitialized || m_State == ToolboxState_Error)
    {
      SetState(ToolboxState_Idle);
    }
    else
    {
      SetDisplayAccordingToState();
    }

    // Set validation transform names for tracked frame lists
    std::string toolReferenceFrame;
    if ( (m_ParentMainWindow->GetSelectedChannel() == NULL)
      || (m_ParentMainWindow->GetSelectedChannel()->GetOwnerDevice()->GetToolReferenceFrameName() == NULL) )
    {
      LOG_ERROR("Failed to get tool reference frame name!");
      return;
    }

    toolReferenceFrame = m_ParentMainWindow->GetSelectedChannel()->GetOwnerDevice()->GetToolReferenceFrameName();
    PlusTransformName transformNameForValidation(m_ParentMainWindow->GetProbeCoordinateFrame(), toolReferenceFrame.c_str());
    m_SpatialCalibrationData->SetFrameTransformNameForValidation(transformNameForValidation);
    m_SpatialValidationData->SetFrameTransformNameForValidation(transformNameForValidation);
    m_RecordingBuffer->SetFrameTransformNameForValidation(transformNameForValidation);

    // Initialize algorithms and containers
    if ( m_Calibration->ReadConfiguration(vtkPlusConfig::GetInstance()->GetDeviceSetConfigurationData()) != PLUS_SUCCESS 
      || m_Segmentation->ReadConfiguration(vtkPlusConfig::GetInstance()->GetDeviceSetConfigurationData()) != PLUS_SUCCESS )
    {
      LOG_ERROR("Reading configuration failed!");
      return;
    }

    m_SpatialCalibrationData->Clear();
    m_SpatialValidationData->Clear();
    m_RecordingBuffer->Clear();

    m_NumberOfSegmentedCalibrationImages = 0;
    m_NumberOfSegmentedValidationImages = 0;
    m_LastRecordedFrameTimestamp = 0.0;

    m_Segmentation->SetTrackedFrameList(m_RecordingBuffer);

    m_CancelRequest = false;
  }
  else
  {
    SetState(ToolboxState_Uninitialized);
  }
}
예제 #19
0
void ProcessCommandLine(int argc, char** argv)
{
	high_score_filename = GetHighScoresFilename(argv[0]);
	ReadHighScores(high_score_filename);
	ReadConfiguration(argv[0]);

	for (int i = 1; i < argc; i++) {
		if (!stricmp(argv[i], "-windowed"))
			configuration.graphics_driver = GFX_AUTODETECT_WINDOWED;
		else if (!stricmp(argv[i], "-fullscreen"))
			configuration.graphics_driver = GFX_AUTODETECT_FULLSCREEN;
		else if (!stricmp(argv[i], "-sw")) {
			if (i+1 < argc) {
				i++;
				if (!isdigit(argv[i][0])) {
					std::cout << "Expected a number after -w." << std::endl;
					allegro_exit();
					exit(1);
				}
				configuration.screen_width = atoi(argv[i]);
			}
		}
		else if (!stricmp(argv[i], "-sh")) {
			if (i+1 < argc) {
				i++;
				if (!isdigit(argv[i][0])) {
					std::cout << "Expected a number after -h." << std::endl;
					allegro_exit();
					exit(1);
				}
				configuration.screen_height = atoi(argv[i]);
			}
		}
		else if (!stricmp(argv[i], "-bpp")) {
			if (i+1 < argc) {
				i++;
				if (!isdigit(argv[i][0])) {
					std::cout << "Expected a number after -bpp." << std::endl;
					allegro_exit();
					exit(1);
				}
				configuration.color_depth = atoi(argv[i]);
				if (!IsSupportedColorDepth(configuration.color_depth)) {
					std::cout << "Unsupported color depth." << std::endl;
					allegro_exit();
					exit(1);
				}
			}
		}
		else if (!stricmp(argv[i], "-blocks")) {
			if (i+1 < argc) {
				i++;
				if (!isdigit(argv[i][0])) {
					std::cout << "Expected a number after -blocks." << std::endl;
					allegro_exit();
					exit(1);
				}
				int blocks = atoi(argv[i]);
				if (blocks < 2 || blocks > NUMBER_OF_BLOCK_BITMAPS) {
					std::cout << "Number of block types must be from 2 to 5." << std::endl;
					allegro_exit();
					exit(1);
				}
				configuration.number_of_block_types = blocks;
			}
		}
		else if (!stricmp(argv[i], "-height")) {
			if (i+1 < argc) {
				i++;
				if (!isdigit(argv[i][0])) {
					std::cout << "Expected a number after -height." << std::endl;
					allegro_exit();
					exit(1);
				}
				configuration.initial_height = atoi(argv[i]);
				if (configuration.initial_height < 0) {
					std::cout << "Initial height must be 0 or greater." << std::endl;
					allegro_exit();
					exit(1);
				}
				else if (configuration.initial_height >= PANEL_HEIGHT) {
					std::cout << "Maximum initial height is " << PANEL_HEIGHT-1 << "." << std::endl;
					allegro_exit();
					exit(1);
				}
			}
		}
		else {
			std::cout << "Unrecognized command line option: " <<
				argv[i] << std::endl;
			std::cout << "Supported options are:" << std::endl;
			std::cout << "-windowed   -- Run in windowed mode" << std::endl;
			std::cout << "-fullscreen -- Run in fullscreen mode" << std::endl;
			std::cout << "-sw ###     -- Screen width" << std::endl;
			std::cout << "-sh ###     -- Screen height" << std::endl;
			std::cout << "-bpp ##     -- Color depth" << std::endl;
			std::cout << "-blocks #   -- Number of block types" << std::endl;
			std::cout << "-height ##  -- Initial height of blocks" << std::endl;
			allegro_exit();
			exit(1);
		}
	}
}
예제 #20
0
ConfigManager::ConfigManager(const char *filename) {
	initcheck=B_OK;
	configMsg=new BMessage();
	configfile=new BFile(filename, B_READ_WRITE | B_CREATE_FILE);
	ReadConfiguration();
}
예제 #21
0
//----------------------------------------------------------------------------
int PX2SceneExport::DoExport (const TCHAR *filename, ExpInterface *ept,
							 Interface* max, BOOL suppressPrompts, 
							 DWORD options)
{
	// 从硬盘加载导出插件配置文件,设置用户导出选项。建立并保存Phoenix2的场景图,
	// 并且再次将新的配置写入配置文件。
	//	filename:
	//		用户要保存的Phoenix2场景图文件名。
	//	export:
	//		Max的导出功能指针接口。
	//	max:
	//		Max的一般职能接口。
	//	suppressPrompts:
	//		是否允许用户输入。
	//	options:
	//		确定是导出整个场景,还是导出选择选择的。

	mMax = max;
	INode* exportNode = NULL;
	bool exportSelected;

	if (options == SCENE_EXPORT_SELECTED)
	{
		// 用户选择“导出选择的物体”,确信,选择的节点只有一个。(相当于用户选择
		// 了要到处的场景树的最顶层节点)。
		if (mMax->GetSelNodeCount() != 1)
		{
			assertion (false, "只能导出一个选择节点。");
			return 0;
		}

		exportNode = mMax->GetSelNode(0);
		exportSelected = true;
	}
	else
	{
		// 导出整个场景,从Max的跟节点开始导出
		exportNode = mMax->GetRootNode();
		exportSelected = false;
	}

	// 获得导出插件配置文件所在位置
	mStrConfigFile = mMax->GetDir(APP_PLUGCFG_DIR);
	mStrConfigFile += "\\Max9ToPX2.cfg";

	// 读取导出插件的配置信息
	ReadConfiguration();

	// 显示导出插件对话框
	if (!suppressPrompts)
	{
		assertion(PX2Max8ClassDesc::msInstance!=0, "msInstance must not be 0");

		INT_PTR piResult = DialogBoxParam(PX2Max8ClassDesc::msInstance,
			MAKEINTRESOURCE(IDD_MAX8TOPX2_DIALOG), GetActiveWindow(), 
			DialogProcedure, (LPARAM)this);

		if (!piResult)
			return 1;
	}

	max->ProgressStart(_T("正在导出:"), TRUE, ProgressBarCallback, NULL);

	// 将Max场景转换到Phoenix2场景
	SceneBuilder(filename, exportSelected, &mEffectiveSettings, ept,
		max, exportNode);

	max->ProgressEnd();

	// 保存导出插件的配置信息
	WriteConfiguration();

	return 1;
}
예제 #22
0
HSTool::HSTool(void)
{
	ReadConfiguration();
}
예제 #23
0
int
XplServiceMain(int argc, char *argv[])
{
    BOOL recover;
    int ccode;
    int startupOpts;

    LogStart();

    if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) {
        Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser());
        return -1;
    }
    
    XplInit();

    /* Set the default port */
    Agent.agent.port = BONGO_QUEUE_PORT;

    /* Initialize the Bongo libraries */
    startupOpts = BA_STARTUP_CONNIO | BA_STARTUP_NMAP | BA_STARTUP_MSGLIB | BA_STARTUP_MSGAUTH;
    ccode = BongoAgentInit(&Agent.agent, AGENT_NAME, DEFAULT_CONNECTION_TIMEOUT, startupOpts);
    if (ccode == -1) {
        Log(LOG_ERROR, "Initialization failed exiting.");
        return -1;
    }
    
    XplRWLockInit(&Conf.lock);
    XplSafeWrite(Agent.activeThreads, 0);

    ReadConfiguration(&recover);

    BongoAgentAddConfigMonitor(&Agent.agent, CheckConfig);
    BongoAgentAddDiskMonitor(&Agent.agent, CheckDiskspace);
    // Load monitor disabled, see CheckLoad()
    //BongoAgentAddLoadMonitor(&Agent.agent, CheckLoad);

    Agent.clientListener = ServerSocketInit(Agent.agent.port);
    if (Agent.clientListener == NULL) {
        Log(LOG_ERROR, "Server Initialization failed exiting.");
        return -1;
    }

    if (QueueInit() == FALSE) {
        Log(LOG_ERROR, "Queue Initialization failed exiting.");
        return -1;
    }

    LoadProtocolCommandTree(&Agent.authCommands, authCommands);
    LoadProtocolCommandTree(&Agent.commands, commands);

    /* FIXME: We want to pool work on the command level rather than
     * the connection level.  Until then the threadpool will have a
     * thread per client, so no (practical) limit */
    Agent.clientThreadPool = BongoThreadPoolNew("Queue Clients", STACKSPACE_Q, 2, INT_MAX, 0);

    XplSignalHandler(SignalHandler);

    ccode = CreateQueueThreads(recover);

    BongoAgentStartMonitor(&Agent.agent);

    MsgSetRecoveryFlag("queue");

    /* Start the server thread */
    XplStartMainThread(AGENT_NAME, &id, QueueServer, 8192, NULL, ccode);

    LogShutdown();
    
    XplUnloadApp(XplGetThreadID());
    
    return 0;
}
예제 #24
0
파일: acpland.cpp 프로젝트: josthas/KrusAGS
JNIEXPORT jboolean JNICALL 
  Java_com_bigbluecup_android_EngineGlue_startEngine(JNIEnv* env, jobject object, jclass stringclass, jstring filename, jstring directory, jstring appDirectory, jboolean loadLastSave)
{
  // Get JNI interfaces.
  java_object = env->NewGlobalRef(object);
  java_environment = env;
  java_class = (jclass)java_environment->NewGlobalRef(java_environment->GetObjectClass(object));
  java_messageCallback = java_environment->GetMethodID(java_class, "showMessage", "(Ljava/lang/String;)V");
  java_blockExecution = java_environment->GetMethodID(java_class, "blockExecution", "()V");
  java_setRotation = java_environment->GetMethodID(java_class, "setRotation", "(I)V");
  java_enableLongclick = java_environment->GetMethodID(java_class, "enableLongclick", "()V");

  // Initialize JNI for Allegro.
  android_allegro_initialize_jni(java_environment, java_class, java_object);

  // Get the file to run from Java.
  const char* cpath = java_environment->GetStringUTFChars(filename, NULL);
  strcpy(psp_game_file_name, cpath);
  java_environment->ReleaseStringUTFChars(filename, cpath);

  // Get the base directory (usually "/sdcard/ags").
  const char* cdirectory = java_environment->GetStringUTFChars(directory, NULL);
  chdir(cdirectory);
  strcpy(android_base_directory, cdirectory);
  java_environment->ReleaseStringUTFChars(directory, cdirectory);

  // Get the app directory (something like "/data/data/com.bigbluecup.android.launcher")
  const char* cappDirectory = java_environment->GetStringUTFChars(appDirectory, NULL);
  strcpy(android_app_directory, cappDirectory);
  java_environment->ReleaseStringUTFChars(appDirectory, cappDirectory);

  // Reset configuration.
  ResetConfiguration();

  // Read general configuration.
  ReadConfiguration(ANDROID_CONFIG_FILENAME, true);

  // Get the games path.
  char path[256];
  strcpy(path, psp_game_file_name);
  int lastindex = strlen(path) - 1;
  while (path[lastindex] != '/')
  {
    path[lastindex] = 0;
    lastindex--;
  }
  chdir(path);
  
  setenv("ULTRADIR", "..", 1);

  // Read game specific configuration.
  ReadConfiguration(ANDROID_CONFIG_FILENAME, false);

  // Set the screen rotation.
  if (psp_rotation > 0)
    java_environment->CallVoidMethod(java_object, java_setRotation, psp_rotation);

  if (config_mouse_longclick > 0)
    java_environment->CallVoidMethod(java_object, java_enableLongclick);

  psp_load_latest_savegame = loadLastSave;

  // Start the engine main function.
  main(1, &psp_game_file_name_pointer);
  
  // Explicitly quit here, otherwise the app will hang forever.
  exit(0);
  
  return true;
}