Пример #1
0
    static bool HandleRBACGroupAddCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        RBACCommandResult result = command->rbac->AddGroup(command->id, command->realmId);
        RBACGroup const* group = sAccountMgr->GetRBACGroup(command->id);

        switch (result)
        {
            case RBAC_CANT_ADD_ALREADY_ADDED:
                handler->PSendSysMessage(LANG_RBAC_GROUP_IN_LIST, command->id, group->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case RBAC_OK:
                handler->PSendSysMessage(LANG_RBAC_GROUP_ADDED, command->id, group->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case RBAC_ID_DOES_NOT_EXISTS:
                handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
                break;
            default:
                break;
        }

        if (command->needDelete)
            delete command;

        return true;
    }
Пример #2
0
    static bool HandleRBACRoleRevokeCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        RBACCommandResult result = command->rbac->RevokeRole(command->id, command->realmId);
        RBACRole const* role = sAccountMgr->GetRBACRole(command->id);

        switch (result)
        {
            case RBAC_CANT_REVOKE_NOT_IN_LIST:
                handler->PSendSysMessage(LANG_RBAC_ROLE_REVOKED_NOT_IN_LIST, command->id, role->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case RBAC_OK:
                handler->PSendSysMessage(LANG_RBAC_ROLE_REVOKED, command->id, role->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case RBAC_ID_DOES_NOT_EXISTS:
                handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
                break;
            default:
                break;
        }

        if (command->needDelete)
            delete command;

        return true;
    }
Пример #3
0
    static bool HandleRBACGroupListCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args, false);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage(LANG_RBAC_GROUP_LIST_HEADER, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACGroupContainer const& groups = command->rbac->GetGroups();
        if (groups.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (RBACGroupContainer::const_iterator it = groups.begin(); it != groups.end(); ++it)
            {
                RBACGroup const* group = sAccountMgr->GetRBACGroup(*it);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, group->GetId(), group->GetName().c_str());
            }
        }

        if (command->needDelete)
            delete command;

        return true;
    }
Пример #4
0
    static bool HandleRBACAccountPermissionCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args, false);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage(LANG_RBAC_PERM_LIST_GLOBAL, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACPermissionContainer const& permissions = command->rbac->GetPermissions();
        if (!permissions.any())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
                if (permissions.test(i))
                {
                    RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
                    handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
                }
        }

        if (command->needDelete)
            delete command;

        return true;
    }
Пример #5
0
 /**
 * Constructs a WORHP algorithm
 */
worhp::worhp(int iter, double feas, double opt, bool screen_output)
{
	// We construct the map between parameters and integers used to set and get them
	define_param_map();

	// We set the screen output member from algorithm::base
	set_screen_output(screen_output);

	// We deactivate WORHP keyboard handler as it does introduce funny problems
	setenv("WORHP_DISABLE_KEYBOARD_HANDLER", "1", 0);

	// We deal with screen output (this is buggy in lworhp 1.8.0, hopefully future releases can fix the problem
	// and we will be able to restore the screen output upon request
	if (m_screen_output) {
		SetWorhpPrint(default_output);
	} else {
		SetWorhpPrint(no_screen_output);
	}

	// We read the algorithm parameters from the xml file, if this is not found
	// we set default values and ignore the issue.
	int status;
	m_params.initialised = false;
	ReadParams(&status, const_cast<char*>("param.xml"), &m_params);
	status = OK;
	m_params.MatrixCC = false; // Not sure what this deas exactly

	// We set some of the parameters exposed in the constructor
	set_param("TolFeas", feas);
	set_param("TolOpti", opt);
	set_param("MaxIter", iter);
}
Пример #6
0
    static bool HandleRBACPermRevokeCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        rbac::RBACCommandResult result = command->rbac->RevokePermission(command->id, command->realmId);
        rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);

        switch (result)
        {
            case rbac::RBAC_CANT_REVOKE_NOT_IN_LIST:
                handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED_NOT_IN_LIST, command->id, permission->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case rbac::RBAC_OK:
                handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED, command->id, permission->GetName().c_str(),
                    command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
                break;
            case rbac::RBAC_ID_DOES_NOT_EXISTS:
                handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
                break;
            default:
                break;
        }

        delete command;

        return true;
    }
Пример #7
0
//------------------------------------------------------------------------
bool CItem::ReadItemParams(const IItemParamsNode *root)
{
	if(!root)
	{
		GameWarning("Warning: ItemParams for item <%s> NULL", GetEntity()->GetName());
		return false;
	}

	const IItemParamsNode *params = root->GetChild("params");
	const IItemParamsNode *geometry = root->GetChild("geometry");
	const IItemParamsNode *actions = root->GetChild("actions");
	const IItemParamsNode *layers = root->GetChild("layers");
	const IItemParamsNode *accessories = root->GetChild("accessories");
	const IItemParamsNode *damagelevels = root->GetChild("damagelevels");
	const IItemParamsNode *accessoryAmmo = root->GetChild("accessoryAmmo");

	if(params) ReadParams(params);

	if(actions) ReadActions(actions);

	if(geometry) ReadGeometry(geometry);

	if(layers) ReadLayers(layers);

	if(accessories) ReadAccessories(accessories);

	if(damagelevels) ReadDamageLevels(damagelevels);

	if(accessoryAmmo) ReadAccessoryAmmo(accessoryAmmo);

	m_sharedparams->SetValid(true);

	return true;
}
Пример #8
0
void CCommandLineParser::ProcessSwitch(const char* switch_str)
{
	const s_arg_entry* s;
	if (!FindArgument(switch_str, true, &s))
		RaiseError("unknown switch");
	CArgEntity entity(s->id);
#ifdef CP_IGNORE_REST
	// special case: if we get the forward switch stop processing
	// everything and treat it as a single command.
	if (s->id == kIgnoreRest) {
		char* arg_str;
		while (ReadString(&arg_str)) entity.Add(arg_str);
	} else 	ReadParams(s, entity);
#else
	ReadParams(s, entity);
#endif
	switches.insert(std::pair<e_arg_ids, CArgEntity>(entity.id, entity));
}
Пример #9
0
void CCommandLineParser::ProcessCommand(const char* command_str)
{
	const s_arg_entry* command;
	if (!FindArgument(command_str, false, &command))
		RaiseError("unknown command");

	if (this->command.id != kNone)
		RaiseError("unexpected command.. already got one.");
	this->command.SetID(command->id);
	ReadParams(command, this->command);		
}
Пример #10
0
void cController::ReadParams(const std::string& file)
{
	if (file != "")
	{
		std::ifstream f_stream(file);
		if (f_stream.is_open())
		{
			ReadParams(f_stream);
		}
		f_stream.close();
	}
}
Пример #11
0
    static bool HandleRBACPermListCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args, false);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
        rbac::RBACPermissionContainer const& granted = command->rbac->GetGrantedPermissions();
        if (granted.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (rbac::RBACPermissionContainer::const_iterator itr = granted.begin(); itr != granted.end(); ++itr)
            {
                rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
            }
        }

        handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
        rbac::RBACPermissionContainer const& denied = command->rbac->GetDeniedPermissions();
        if (denied.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (rbac::RBACPermissionContainer::const_iterator itr = denied.begin(); itr != denied.end(); ++itr)
            {
                rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
            }
        }
        handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_BY_SEC_LEVEL, command->rbac->GetId(), command->rbac->GetName().c_str(), command->rbac->GetSecurityLevel());
        rbac::RBACPermissionContainer const& defaultPermissions = sAccountMgr->GetRBACDefaultPermissions(command->rbac->GetSecurityLevel());
        if (defaultPermissions.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (rbac::RBACPermissionContainer::const_iterator itr = defaultPermissions.begin(); itr != defaultPermissions.end(); ++itr)
            {
                rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
            }
        }

        delete command;

        return true;
    }
Пример #12
0
BOOL CWAdvDlg::PreTranslateMessage(MSG* pMsg)
{
	if((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)){
		CWnd* ppp = GetFocus();

		if(GetDlgItem(IDOK) != ppp) {
			ReadParams();
			m_ctrlOK.SetFocus();
			return true;
		}
	}	
	return CDialog::PreTranslateMessage(pMsg);
}
Пример #13
0
BOOL CWingScaleDlg::PreTranslateMessage(MSG* pMsg) 
{
	CWnd* pWnd = GetFocus();
	if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN){ 
		if(GetDlgItem(IDCANCEL) != pWnd && GetDlgItem(IDOK) != pWnd) {
			ReadParams();
			m_ctrlOK.SetFocus();
		}
		else if(GetDlgItem(IDOK) == pWnd ) OnOK();
		else if(GetDlgItem(IDCANCEL) == pWnd ) OnCancel();

		return true;
	}
	
	return CDialog::PreTranslateMessage(pMsg);
}
Пример #14
0
int main( int argc, char* argv[] )
{
	gArgs.SetCmdLine( argc, argv );

	ReadParams();

	ChannelLoop();

	for( int i = 0; i < 4; ++i )
		RasterFree( ffras[i] );

	fprintf( flog, "\n" );
	fclose( flog );

	return 0;
}
Пример #15
0
    static bool HandleRBACPermListCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args, false);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage(LANG_RBAC_PERM_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACPermissionContainer const& granted = command->rbac->GetGrantedPermissions();
        if (!granted.any())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
                if (granted.test(i))
                {
                    RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
                    handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
                }
        }

        handler->PSendSysMessage(LANG_RBAC_PERM_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACPermissionContainer const& denied = command->rbac->GetDeniedPermissions();
        if (!denied.any())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
                if (denied.test(i))
                {
                    RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
                    handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
                }
        }

        delete command;

        return true;
    }
Пример #16
0
BOOL CDsnPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

// 	TODO: Add extra initialization here
//	ODBC-Data-Sources lesen	
	CWaitCursor wc;
	CString strCaption;
	VERIFY (strCaption.LoadString (IDS_USER_DSN_CAPT));
	m_dlgUserDsn.m_tType = UserDataSource;
	VERIFY (0 == m_tbDsn.AddDialog (&m_dlgUserDsn, IDD_USER_DSN_MEDIUM, strCaption));
	VERIFY (strCaption.LoadString (IDS_SYSTEM_DSN_CAPT));
	m_dlgSystemDsn.m_tType = SystemDataSource;
	VERIFY (1 == m_tbDsn.AddDialog (&m_dlgSystemDsn, IDD_USER_DSN_MEDIUM, strCaption));
	VERIFY (strCaption.LoadString (IDS_FILE_DSN_CAPT));
	m_dlgFileDsn.m_tType = FileDataSource;
	VERIFY (2 == m_tbDsn.AddDialog (&m_dlgFileDsn, IDD_FILE_DSN_MEDIUM, strCaption));
	m_tbDsn.SetActiveDialog (0);

//  TRiAS-Namen austauschen
	FakeName(GetDlgItem(IDB_DSN_ON_TRIAS));
	FakeName(GetDlgItem(IDB_DSN_ON_TABLE));

#ifndef WIN32    
	if (!ReadParams ())
	{
		GetParent () -> EndDialog (IDCANCEL);
		return TRUE;
	}
	SetControlState ();
	if (!ModifyButtonsText ())
	{
		GetParent () -> EndDialog (IDCANCEL);
		return TRUE;
	} 
	UpdateWindow ();
	PostMessage (IDM_SETFOCUS, 0, 0L);
#endif
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #17
0
    static bool HandleRBACRoleListCommand(ChatHandler* handler, char const* args)
    {
        RBACCommandData* command = ReadParams(handler, args, false);

        if (!command)
        {
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage(LANG_RBAC_ROLE_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACGroupContainer const& granted = command->rbac->GetGrantedRoles();
        if (granted.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (RBACRoleContainer::const_iterator it = granted.begin(); it != granted.end(); ++it)
            {
                RBACRole const* role = sAccountMgr->GetRBACRole(*it);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
            }
        }

        handler->PSendSysMessage(LANG_RBAC_ROLE_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
        RBACGroupContainer const& denied = command->rbac->GetDeniedRoles();
        if (denied.empty())
            handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
        else
        {
            for (RBACRoleContainer::const_iterator it = denied.begin(); it != denied.end(); ++it)
            {
                RBACRole const* role = sAccountMgr->GetRBACRole(*it);
                handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
            }
        }

        if (command->needDelete)
            delete command;

        return true;
    }
Пример #18
0
static void setup (FileList *f, Element_List **U){
  int i,k;
  Curve *curve;

  ReadParams  (f->rea.fp);

  //option_set("FAMOFF", 1);

  if((i=iparam("NORDER-req"))!=UNSET){
    iparam_set("LQUAD",i);
    iparam_set("MQUAD",i);
  }

  *U = ReadMesh(f->rea.fp, strtok(f->rea.name,"."));       /* Generate the list of elements */
  U[0]->Cat_mem();

  if(option("variable"))  ReadOrderFile   (strtok(f->rea.name,"."),*U);

  if(f->mesh.name) Get_Body(f->mesh.fp);

  return;
}
Пример #19
0
void ValidateCommand :: ReadValidationFile( const ALib::CommandLine & cmd ) {

	Clear();

	string fname = cmd.GetValue( FLAG_VFILE );
	if ( fname == "" ) {
		CSVTHROW( "Need validation file specified by "
					<< FLAG_VFILE << " flag" );
	}

	std::ifstream ifs( fname.c_str() );
	if ( ! ifs.is_open() ) {
		CSVTHROW( "Cannot open validation file " << fname << " for input" );
	}

	string line;
	while( std::getline( ifs, line ) ) {
		if ( ALib::IsEmpty( line ) || line[0] == '#' ) {	// a comment
			continue;
		}

		unsigned int pos = 0;
		string name = ReadName( line, pos );
		FieldList flist = ReadFields( line, pos );
		ValidationRule::Params params = ReadParams( line, pos );

		ValidationRule * rule = RuleFactory::CreateRule( name, flist, params );
		if ( rule == 0 ) {
			CSVTHROW( "Unknown rule: " << name );
		}

		//rule->DumpOn( std::cout );

		mRules.push_back( rule );

	}
}
Пример #20
0
void CWingScaleDlg::OnOK() 
{
	ReadParams();
	CDialog::OnOK();
}
Пример #21
0
int main(int argc, char **argv)
{
	int i, j, k, treeNo, sumLength;
	char ch;
	TTree **treeSet;
	FILE *text_fv;
	clock_t totalStart;
	double totalSecs, scale, sum;
	char *ancestor;

	totalStart = clock();

	ReadParams(argc, argv);

	if (rateHetero == CodonRates && invariableSites) {
		fprintf(stderr, "Invariable sites model cannot be used with codon rate heterogeneity.\n");
		exit(4);
	}

	if (writeAncestors && fileFormat == NEXUSFormat) {
		fprintf(stderr, "Warning - When writing ancestral sequences, relaxed PHYLIP format is used.\n");
	}

	if (writeAncestors && maxPartitions > 1) {
		fprintf(stderr, "Writing ancestral sequences can only be used for a single partition.\n");
		exit(4);
	}
			
	if (!userSeed)
		randomSeed = CreateSeed();
		
	SetSeed(randomSeed);

	if (!quiet)
 		PrintTitle();
	
	numTrees = OpenTreeFile();

	/* if (!treeFile) { */
		ReadFileParams();
	/*} */


	if ((ancestorSeq>0 && !hasAlignment) || ancestorSeq>numSequences) {
		fprintf(stderr, "Bad ancestral sequence number: %d (%d sequences loaded)\n", ancestorSeq, numSequences);
		exit(4);
	}
	
	if (textFile) {
		if ( (text_fv=fopen(textFileName, "rt"))==NULL ) {
			fprintf(stderr, "Error opening text file for insertion into output: '%s'\n", textFileName);
			exit(4);
		}
	}

	ancestor=NULL;
	if (hasAlignment) {
		AllocateMemory();	
		ReadFile();
		
		if (numSites<0)
			numSites=numAlignmentSites;		
			
		if (ancestorSeq>0) {
			if (numSites!=numAlignmentSites) {
				fprintf(stderr, "Ancestral sequence is of a different length to the simulated sequences (%d)\n", numAlignmentSites);
				exit(4);
			}
			ancestor=sequences[ancestorSeq-1];
		}
	} else if (numSites<0)
		numSites=1000;
	
	SetModel(model);
	
	numTaxa=-1;
	scale=1.0;
	
	treeSet = (TTree **)malloc(sizeof(TTree **) * maxPartitions);
	if (treeSet==NULL) {
		fprintf(stderr, "Out of memory\n");
		exit(5);
	}
	
	partitionLengths = (int *)malloc(sizeof(int) * maxPartitions);
	if (partitionLengths==NULL) {
		fprintf(stderr, "Out of memory\n");
		exit(5);
	}
	
	partitionRates = (double *)malloc(sizeof(double) * maxPartitions);
	if (partitionRates==NULL) {
		fprintf(stderr, "Out of memory\n");
		exit(5);
	}
	
	for (i = 0; i < maxPartitions; i++) {
		if ((treeSet[i]=NewTree())==NULL) {
			fprintf(stderr, "Out of memory\n");
			exit(5);
		}
	}
					
	CreateRates();
	
	treeNo=0;
	do {
		partitionLengths[0] = -1;
		ReadTree(tree_fv, treeSet[0], treeNo+1, 0, NULL, &partitionLengths[0], &partitionRates[0]);

		if (treeNo==0) {
			numTaxa=treeSet[0]->numTips;
			
			if (!quiet)
				fprintf(stderr, "Random number generator seed: %ld\n\n", randomSeed);
				
			if (fileFormat == NEXUSFormat) {
				fprintf(stdout, "#NEXUS\n");
				fprintf(stdout, "[\nGenerated by %s %s\n\n", PROGRAM_NAME, VERSION_NUMBER);
				PrintVerbose(stdout);
				fprintf(stdout, "]\n\n");
			}
		} else if (treeSet[0]->numTips != numTaxa) {
			fprintf(stderr, "All trees must have the same number of tips.\n");
			exit(4);
		}
		
		if (maxPartitions == 1) {
			if (partitionLengths[0] != -1) {
				fprintf(stderr, "\nWARNING: The treefile contained partion lengths but only one partition\n");
				fprintf(stderr, "was specified.\n");
			}
			partitionLengths[0] = numSites;
		}

		sumLength = partitionLengths[0];
		i = 1;
		while (sumLength < numSites && i <= maxPartitions) {
			if (!IsTreeAvail(tree_fv)) {
				fprintf(stderr, "\nA set of trees number %d had less partition length (%d) than\n", treeNo + 1, sumLength);
				fprintf(stderr, "was required to make a sequence of length %d.\n", numSites);
				exit(4);
			}
				
			ReadTree(tree_fv, treeSet[i], treeNo+1, treeSet[0]->numTips, treeSet[0]->names, 
						&partitionLengths[i], &partitionRates[i]);
						
			if (treeSet[i]->numTips != numTaxa) {
				fprintf(stderr, "All trees must have the same number of tips.\n");
				exit(4);
			}
			
			sumLength += partitionLengths[i];
			i++;
		}
		if (i > maxPartitions) {
			fprintf(stderr, "\nA set of trees number %d had more partitions (%d) than\n", treeNo + 1, i);
			fprintf(stderr, "was specified in the user options (%d).\n", maxPartitions);
		}
		numPartitions = i;
				
		if (sumLength != numSites) {
			fprintf(stderr, "The sum of the partition lengths in the treefile does not equal\n");
			fprintf(stderr, "the specified number of sites.\n");
			exit(4);
		}
			
		for (i = 0; i < numPartitions; i++)
			CreateSequences(treeSet[i], partitionLengths[i]);
		
		if (numPartitions > 1) {
			sum = 0.0;
			for (i = 0; i < numPartitions; i++)
				sum += partitionRates[i] * partitionLengths[i];
				
			for (i = 0; i < numPartitions; i++)
				partitionRates[i] *= numSites / sum;
		}
		
		if (treeNo==0 && verbose && !quiet) {
			PrintVerbose(stderr);
			InitProgressBar(numTrees*numDatasets);
			DrawProgressBar();
		}

		for (i=0; i<numDatasets; i++) {
			SetCategories();
			
			k = 0;
			for (j = 0; j < numPartitions; j++) {
				scale = partitionRates[j];
				
				if (scaleTrees) { 
					if (!treeSet[j]->rooted) {
						fprintf(stderr, "To scale tree length, they must be rooted and ultrametric.\n");
						exit(4);
					}
					scale *= treeScale/treeSet[j]->totalLength;
				} else if (scaleBranches)
					scale *= branchScale;

				EvolveSequences(treeSet[j], k, partitionLengths[j], scale, ancestor);
				k += partitionLengths[j];
			}
			
			if (writeAncestors)
				WriteAncestralSequences(stdout, treeSet[0]);
			else
				WriteSequences(stdout, (numTrees > 1 ? treeNo+1 : -1), (numDatasets > 1 ? i+1 : -1), treeSet, partitionLengths);

			if (writeRates) {
				WriteRates(stderr);
			}

			if (textFile) {
				while (!feof(text_fv)) {
					ch = fgetc(text_fv);
					if (!feof(text_fv))
						fputc(ch, stdout);
				}
				fputc('\n', stdout);
				rewind(text_fv);
			}
			
			if (verbose && !quiet)
				ProgressBar();
		}
				
		for (i = 0; i < numPartitions; i++)
			DisposeTree(treeSet[i]);
			
		treeNo++;
	} while (IsTreeAvail(tree_fv));
	
/*	for (i = 0; i < maxPartitions; i++)
		FreeTree(treeSet[i]);	*/
	
	if (treeFile)
		fclose(tree_fv);

	if (textFile)
		fclose(text_fv);

	totalSecs = (double)(clock() - totalStart) / CLOCKS_PER_SEC;
	if (!quiet) {
		fprintf(stderr, "Time taken: %G seconds\n", totalSecs);
		if (verboseMemory)
			fprintf(stderr, "Total memory used: %ld\n", totalMem);
	}
	
	return 0;
}
Пример #22
0
void TwoDPanelDlg::OnApply()
{
	if(m_bApplied) return;

	//reset everything and retry
	XFoil *pXFoil = (XFoil*)s_pXFoil;

	Foil *pMemFoil = (Foil*)m_pMemFoil;
	Foil *pBufferFoil = (Foil*)m_pBufferFoil;

	for (int i=0; i< pMemFoil->nb; i++)
	{
		pXFoil->xb[i+1] = pMemFoil->xb[i] ;
		pXFoil->yb[i+1] = pMemFoil->yb[i];
	}
	pXFoil->nb = pMemFoil->nb;

	pXFoil->lflap = false;
	pXFoil->lbflap = false;

	if(pXFoil->Preprocess())
	{
		pXFoil->CheckAngles();
	}
	else
	{
		QMessageBox::information(this, tr("Warning"), tr("Unrecognized foil format"));
		return;
	}

	ReadParams();

	pXFoil->pangen();

	if(pXFoil->n>IQX)
	{
		QString strange = QString(tr("The total number of panels cannot exceed %1")).arg(IQX);
		QMessageBox::information(this, tr("Warning"), strange);
		//reset everything and retry
		for (int i=0; i< pMemFoil->nb; i++)
		{
			pXFoil->x[i+1] = pMemFoil->xb[i] ;
			pXFoil->y[i+1] = pMemFoil->yb[i];
		}
		pXFoil->n = pMemFoil->nb;
	}
	else
	{
		for (int j=0; j< pXFoil->n; j++)
		{
			pBufferFoil->xb[j] = pXFoil->x[j+1];
			pBufferFoil->yb[j] = pXFoil->y[j+1];
		}
		pBufferFoil->nb = pXFoil->n;
//		pXFoil->SetFoilFlap(pBufferFoil);
		pBufferFoil->InitFoil();
		pBufferFoil->SetFlap();
	}
	m_bApplied = true;
	m_bModified = true;

	m_pParent->update();
}
Пример #23
0
void WAdvancedDlg::OnOK()
{
	ReadParams();
	accept();
}
Пример #24
0
/*
 *----------------------------------------------------------------------
 *
 * FCGX_Accept_r --
 *
 *      Accepts a new request from the HTTP server.
 *
 * Results:
 *	0 for successful call, -1 for error.
 *
 * Side effects:
 *
 *      Finishes the request accepted by (and frees any
 *      storage allocated by) the previous call to FCGX_Accept.
 *      Creates input, output, and error streams and
 *      assigns them to *in, *out, and *err respectively.
 *      Creates a parameters data structure to be accessed
 *      via getenv(3) (if assigned to environ) or by FCGX_GetParam
 *      and assigns it to *envp.
 *
 *      DO NOT retain pointers to the envp array or any strings
 *      contained in it (e.g. to the result of calling FCGX_GetParam),
 *      since these will be freed by the next call to FCGX_Finish
 *      or FCGX_Accept.
 *
 *----------------------------------------------------------------------
 */
int FCGX_Accept_r(FCGX_Request * reqDataPtr)
{
	if (!libInitialized) {
		return -9998;
	}

	/* Finish the current request, if any. */
	FCGX_Finish_r(reqDataPtr);

	for (;;) {
		/*
		 * If a connection isn't open, accept a new connection (blocking).
		 * If an OS error occurs in accepting the connection,
		 * return -1 to the caller, who should exit.
		 */
		if (reqDataPtr->ipcFd < 0) {
			int fail_on_intr =
				reqDataPtr->flags & FCGI_FAIL_ACCEPT_ON_INTR;

			reqDataPtr->ipcFd =
				OS_Accept(reqDataPtr->listen_sock, fail_on_intr,
				webServerAddressList);
			if (reqDataPtr->ipcFd < 0) {
				return (errno > 0) ? (0 - errno) : -9999;
			}
		}
		/*
		 * A connection is open.  Read from the connection in order to
		 * get the request's role and environment.  If protocol or other
		 * errors occur, close the connection and try again.
		 */
		reqDataPtr->isBeginProcessed = FALSE;
		reqDataPtr->in = NewReader(reqDataPtr, 8192, 0);
		FillBuffProc(reqDataPtr->in);
		if (!reqDataPtr->isBeginProcessed) {
			goto TryAgain;
		}
		{
			char *roleStr;
			switch (reqDataPtr->role) {
			case FCGI_RESPONDER:
				roleStr = "FCGI_ROLE=RESPONDER";
				break;
			case FCGI_AUTHORIZER:
				roleStr = "FCGI_ROLE=AUTHORIZER";
				break;
			case FCGI_FILTER:
				roleStr = "FCGI_ROLE=FILTER";
				break;
			default:
				goto TryAgain;
			}
			reqDataPtr->paramsPtr = NewParams(30);
			PutParam(reqDataPtr->paramsPtr, StringCopy(roleStr));
		}
		SetReaderType(reqDataPtr->in, FCGI_PARAMS);
		if (ReadParams(reqDataPtr->paramsPtr, reqDataPtr->in) >= 0) {
			/*
			 * Finished reading the environment.  No errors occurred, so
			 * leave the connection-retry loop.
			 */
			break;
		}

		/*
		 * Close the connection and try again.
		 */
TryAgain:
		FCGX_Free(reqDataPtr, 1);

	}			/* for (;;) */
	/*
	 * Build the remaining data structures representing the new
	 * request and return successfully to the caller.
	 */
	SetReaderType(reqDataPtr->in, FCGI_STDIN);
	reqDataPtr->out = NewWriter(reqDataPtr, 8192, FCGI_STDOUT);
	reqDataPtr->err = NewWriter(reqDataPtr, 512, FCGI_STDERR);
	reqDataPtr->nWriters = 2;
	reqDataPtr->envp = reqDataPtr->paramsPtr->vec;
	return 0;
}
Пример #25
0
/*
 *----------------------------------------------------------------------
 *
 * ProcessManagementRecord --
 *
 *      Reads and responds to a management record.  The only type of
 *      management record this library understands is FCGI_GET_VALUES.
 *      The only variables that this library's FCGI_GET_VALUES
 *      understands are FCGI_MAX_CONNS, FCGI_MAX_REQS, and FCGI_MPXS_CONNS.
 *      Ignore other FCGI_GET_VALUES variables; respond to other
 *      management records with a FCGI_UNKNOWN_TYPE record.
 *
 *----------------------------------------------------------------------
 */
static int ProcessManagementRecord(int type, FCGX_Stream * stream)
{
	FCGX_Stream_Data *data = (FCGX_Stream_Data *) stream->data;
	ParamsPtr paramsPtr = NewParams(3);
	char **pPtr;
	char response[64];	/* 64 = 8 + 3*(1+1+14+1)* + padding */
	char *responseP = &response[FCGI_HEADER_LEN];
	char *name, value = '\0';
	int len, paddedLen;
	if (type == FCGI_GET_VALUES) {
		ReadParams(paramsPtr, stream);
		if ((FCGX_GetError(stream) != 0) || (data->contentLen != 0)) {
			FreeParams(&paramsPtr);
			return FCGX_PROTOCOL_ERROR;
		}
		for (pPtr = paramsPtr->vec; pPtr < paramsPtr->cur; pPtr++) {
			name = *pPtr;
			*(strchr(name, '=')) = '\0';
			if (strcmp(name, FCGI_MAX_CONNS) == 0) {
				value = '1';
			} else if (strcmp(name, FCGI_MAX_REQS) == 0) {
				value = '1';
			} else if (strcmp(name, FCGI_MPXS_CONNS) == 0) {
				value = '0';
			} else {
				name = NULL;
			}
			if (name != NULL) {
#include <fmt.h>
				len = strlen(name);
				responseP[0] = (char)len;
				responseP[1] = (char)1;
				fmt_str(responseP + 2, name);
				responseP[2 + len] = value;
				responseP[3 + len] = '\0';
//                sprintf(responseP, "%c%c%s%c", len, 1, name, value);
				responseP += len + 3;
			}
		}
		len = responseP - &response[FCGI_HEADER_LEN];
		paddedLen = AlignInt8(len);
		*((FCGI_Header *) response)
			= MakeHeader(FCGI_GET_VALUES_RESULT,
			FCGI_NULL_REQUEST_ID, len, paddedLen - len);
		FreeParams(&paramsPtr);
	} else {
		paddedLen = len = sizeof(FCGI_UnknownTypeBody);
		((FCGI_UnknownTypeRecord *) response)->header
			= MakeHeader(FCGI_UNKNOWN_TYPE, FCGI_NULL_REQUEST_ID,
			len, 0);
		((FCGI_UnknownTypeRecord *) response)->body
			= MakeUnknownTypeBody(type);
	}
	if (write_it_all(data->reqDataPtr->ipcFd, response,
			FCGI_HEADER_LEN + paddedLen) < 0) {
		SetError(stream, OS_Errno);
		return -1;
	}

	return MGMT_RECORD;
}
Пример #26
0
void CWAdvDlg::OnOK() 
{
	ReadParams();
	CDialog::OnOK();
}
Пример #27
0
void CWAdvDlg::OnClose() 
{
	ReadParams();		
	CDialog::OnClose();
}