/* * UnsyncVariables * * Clear variables that should be not be set when there is no connection. */ void UnsyncVariables(void) { SetVariable(pset.vars, "DBNAME", NULL); SetVariable(pset.vars, "USER", NULL); SetVariable(pset.vars, "HOST", NULL); SetVariable(pset.vars, "PORT", NULL); SetVariable(pset.vars, "ENCODING", NULL); }
void CGenerator::VarDeclMap() { // verbose output writeRep(" $(type) $(name); // $(alias) (map)\n", stdout); // do the work // write map declaration writeVarDeclMap(); // reset item and id to standard SetVariable(CGenerator::VAR_ITEM, mpszItem); SetVariable(CGenerator::VAR_ID, mpszId); }
CGenerator::CGenerator() { SetOutputFileBasename("struct"); for (int n=0; n<eFileCount; ++n) { mOutputFiles[n] = 0; } SetVariable(VAR_PACKAGE, PACKAGE_STRING); SetVariable(VAR_BUGREPORT, PACKAGE_BUGREPORT); }
void Shader::GetRequiredParameters(SOC_byte *outMatrixParamters, SOC_byte *outLightParameters, char *technique) { if(IsParameterUsed(BasicParameterNames::GetWorldMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::WORLD; if(IsParameterUsed(BasicParameterNames::GetViewMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::VIEW; if(IsParameterUsed(BasicParameterNames::GetProjMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::PROJECTION; if(IsParameterUsed(BasicParameterNames::GetViewProjMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::VIEW_PROJECTION; if(IsParameterUsed(BasicParameterNames::GetWorldViewProjMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::WORLD_VIEW_PROJECTION; if(IsParameterUsed(BasicParameterNames::GetWorldViewInvTnsMatrix(), technique)) requiredMatrixParam |= REQUIRED_TRANSFORM::WORLD_VIEW_INV_TRANS; const char *structName = nullptr; //bool test;// = shader->SetValue("material.ambient", nullptr, sizeof(float)); std::string &checkParam = BasicParameterNames::GetMaterialElement(BasicParameterNames::GetAmbient()); SOC_Vector4 temp(0, 0, 0, 0); if(SetVariable(checkParam.c_str(), &temp)) { requiredLightParam |= REQUIRED_LIGHTING::MATERIAL; float tempfloat = 0.0f; if(SetVariable(BasicParameterNames::GetMaterialElement(BasicParameterNames::GetMaterialShininess()).c_str(), tempfloat)) requiredLightParam |= REQUIRED_LIGHTING::MATERIAL_SHININESS; } structName = shader->GetParameterElement(BasicParameterNames::GetLight(), 0); if(structName != nullptr) { requiredLightParam |= REQUIRED_LIGHTING::LIGHT; if(shader->GetParameterByName(structName, BasicParameterNames::GetLightRange()) != nullptr) requiredLightParam |= REQUIRED_LIGHTING::LIGHT_RANGE; if(shader->GetParameterByName(structName, BasicParameterNames::GetLightSpotAngle()) != nullptr) requiredLightParam |= REQUIRED_LIGHTING::LIGHT_SPOTANGLE; } if(outMatrixParamters) *outMatrixParamters = requiredMatrixParam; if(outLightParameters) *outLightParameters = requiredLightParam; }
int Filter( DWORD pid, char *path ) { vmdb *vdb = (vmdb *)malloc(sizeof(vmdb)); TCHAR sProcessName[MAX_PATH] = { 0 }; char ctemp[MAX_PATH] = { 0 }; vdb = SetVariable(path); HANDLE hHandle = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (hHandle) { GetModuleFileNameEx(hHandle, 0, sProcessName, MAX_PATH); WideCharToMultiByte(CP_ACP, 0, sProcessName, MAX_PATH, ctemp, MAX_PATH, NULL, NULL); CloseHandle(hHandle); for (unsigned int i = 0; i < vdb->num; i++) { if (strstr(ctemp, vdb->vm_data[i])) { free(vdb); return 1; } } } free(vdb); return 0; }
void ZConfigFile::SetBool(std::string section, std::string var, bool val) { std::string tmp = val ? "true" : "false"; section = '[' + section + ']'; SetVariable(section,var,tmp); }
//respawn nameless after he bit the dust void IniSpawn::RespawnNameless() { Game *game = core->GetGame(); Actor *nameless = game->GetPC(0, false); if (NamelessSpawnPoint.isnull()) { core->GetGame()->JoinParty(nameless,JP_INITPOS); NamelessSpawnPoint=nameless->Pos; strnuprcpy(NamelessSpawnArea, nameless->Area, 8); } nameless->Resurrect(); //hardcoded!!! if (NamelessState==36) { nameless->SetStance(IE_ANI_PST_START); } int i; for (i=0;i<game->GetPartySize(false);i++) { MoveBetweenAreasCore(game->GetPC(i, false),NamelessSpawnArea,NamelessSpawnPoint,-1, true); } //certain variables are set when nameless dies for (i=0;i<namelessvarcount;i++) { SetVariable(game, NamelessVar[i].Name,"GLOBAL", NamelessVar[i].Value); } }
void ContourOpAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("ContourOpAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("contourNLevels")) != 0) SetContourNLevels(node->AsInt()); if((node = searchNode->GetNode("contourValue")) != 0) SetContourValue(node->AsDoubleVector()); if((node = searchNode->GetNode("contourPercent")) != 0) SetContourPercent(node->AsDoubleVector()); if((node = searchNode->GetNode("contourMethod")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 3) SetContourMethod(ContourMethod(ival)); } else if(node->GetNodeType() == STRING_NODE) { ContourMethod value; if(ContourMethod_FromString(node->AsString(), value)) SetContourMethod(value); } } if((node = searchNode->GetNode("minFlag")) != 0) SetMinFlag(node->AsBool()); if((node = searchNode->GetNode("maxFlag")) != 0) SetMaxFlag(node->AsBool()); if((node = searchNode->GetNode("min")) != 0) SetMin(node->AsDouble()); if((node = searchNode->GetNode("max")) != 0) SetMax(node->AsDouble()); if((node = searchNode->GetNode("scaling")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetScaling(ContourScaling(ival)); } else if(node->GetNodeType() == STRING_NODE) { ContourScaling value; if(ContourScaling_FromString(node->AsString(), value)) SetScaling(value); } } if((node = searchNode->GetNode("variable")) != 0) SetVariable(node->AsString()); }
void InitInterface_RR(string iniName,ref myCh,ref enemyCh) { refMyCharacter = myCh; refEnemyCharacter = enemyCh; GameInterface.title = "titleRansack"; SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName); SetVariable(); ref shipRef = GetShipByType(sti(refMyCharacter.ship.Type)); CreateImage("myShip","SHIPS",shipRef.name,32,39,160,167); CreateImage("myFace","FACE128_"+refMyCharacter.FaceId,"face",164,39,292,167); CreateString(TRUE,"MyShipType",XI_ConvertString(shipRef.Name),FONT_NORMAL,COLOR_NORMAL,96,140,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"MyShipName",refMyCharacter.ship.Name,FONT_NORMAL,COLOR_NORMAL,177,198,SCRIPT_ALIGN_CENTER,1.0); shipRef = GetShipByType(sti(refEnemyCharacter.ship.Type)); CreateImage("enemyShip","SHIPS",shipRef.name,480,39,608,167); CreateImage("enemyFace","FACE128_"+refEnemyCharacter.FaceId,"face",348,39,476,167); CreateString(TRUE,"EnemyShipType",XI_ConvertString(shipRef.Name),FONT_NORMAL,COLOR_NORMAL,544,140,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"EnemyShipName",refEnemyCharacter.ship.Name,FONT_NORMAL,COLOR_NORMAL,463,198,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"String1",XI_ConvertString(str1),FONT_NORMAL,COLOR_NORMAL,320,240,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"String2",XI_ConvertString(str2),FONT_NORMAL,COLOR_NORMAL,320,268,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"String3",XI_ConvertString(str3_1)+" "+nSurrenderedMen+" "+XI_ConvertString(str3_2),FONT_NORMAL,COLOR_NORMAL,320,296,SCRIPT_ALIGN_CENTER,1.0); SetEventHandler("InterfaceBreak","ProcessCancelExit",0); SetEventHandler("InterfaceCancel","ProcessCancelExit",0); SetEventHandler("KillPress","KillProcess",0); SetEventHandler("SlavesPress","SlavesProcess",0); }
int SolverFormulacaoPadrao::AddEllipsoidalConstraint( const vector<const ProblemSolution*>& x, OPT_ROW::ROWSENSE constraint_sense, int RHS) { // creates the constraint int cons_row = lp_->getNumRows(); int nnz = problem_data_->n() * 2; OPT_ROW row(nnz, constraint_sense, RHS, NULL); lp_->addRow(row); // for each task for (int task = 0; task < problem_data_->n(); ++task) { // counts the weight of every machine assignment map<int, int> machine_to_counts; for (int sol = 0; sol < x.size(); ++sol) { machine_to_counts[x[sol]->assignment(task)] += 1; } // adds to the model for (map<int, int>::iterator it = machine_to_counts.begin(); it != machine_to_counts.end(); ++it) { int machine = it->first; int count = it->second; SetVariable(cons_row, task, machine, count); } } return cons_row; }
void ZConfigFile::SetInt(std::string section, std::string var, int val) { char buf[20]; sprintf(buf,"%d",val); section = '[' + section + ']'; SetVariable(section,var,buf); }
//execute the initial spawn void IniSpawn::InitialSpawn() { SpawnGroup(enterspawn); //these variables are set when entering first for (int i=0;i<localscount;i++) { SetVariable(map, Locals[i].Name,"LOCALS", Locals[i].Value); } }
bool Shader::SetStructVariable(const char *variableName, const char *component, void* data, SOC_uint size) { std::string parameter = variableName; parameter += "."; parameter += component; return SetVariable(parameter.c_str(), data, size); }
VariableSetReturnValue CommandMap::SetVariable(const std::string& name, std::string& value, std::string& previousValue) { auto command = FindCommand(name); if (!command) return eVariableSetReturnValueError; return SetVariable(command, value, previousValue); }
bool InterpretedVM::SetVariable(std::string name, void* value) { for (auto& nameOp : prog.Names) { if (nameOp.second.Name == name) { return SetVariable(nameOp.second.TargetId, value); } } return false; }
void CVariableSystem::SetVariableDefault(LPCTSTR szName, LPCTSTR szValue) { STRING strOld; BOOL bExist = GetVariable(szName, strOld); if(bExist) return; SetVariable(szName, szValue); }
void MakeMain::LoadCmdDefines() { for (int i=0; i < defines.GetCount(); i++) { const CmdSwitchDefine::define *def = defines.GetValue(i); SetVariable(def->name, def->value, Variable::o_command_line, false); } }
/* * SyncVariables * * Make psql's internal variables agree with connection state upon * establishing a new connection. */ void SyncVariables(void) { /* get stuff from connection */ pset.encoding = PQclientEncoding(pset.db); pset.popt.topt.encoding = pset.encoding; pset.sversion = PQserverVersion(pset.db); SetVariable(pset.vars, "DBNAME", PQdb(pset.db)); SetVariable(pset.vars, "USER", PQuser(pset.db)); SetVariable(pset.vars, "HOST", PQhost(pset.db)); SetVariable(pset.vars, "PORT", PQport(pset.db)); SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding)); /* send stuff to it, too */ PQsetErrorVerbosity(pset.db, pset.verbosity); }
void ConfigurationManager::SetVariable(SectionType section, const std::string& name, int value) { char val[1024]; sprintf(val, "%d", value); SetVariable(section, name, val); }
void CGenerator::VarDeclVector() { // verbose output writeRep(" $(type) $(name)[$(size)]; // $(alias) (vector)\n", stdout); // do the work writeVarDeclVector(); // reset item to standard SetVariable(CGenerator::VAR_ITEM, mpszItem); }
/* * do_lo_import() * * Copy large object from file to database */ bool do_lo_import(const char *filename_arg, const char *comment_arg) { PGresult *res; Oid loid; char oidbuf[32]; bool own_transaction; if (!start_lo_xact("\\lo_import", &own_transaction)) return false; SetCancelConn(); loid = lo_import(pset.db, filename_arg); ResetCancelConn(); if (loid == InvalidOid) { psql_error("%s", PQerrorMessage(pset.db)); return fail_lo_xact("\\lo_import", own_transaction); } /* insert description if given */ if (comment_arg) { char *cmdbuf; char *bufptr; size_t slen = strlen(comment_arg); cmdbuf = malloc(slen * 2 + 256); if (!cmdbuf) return fail_lo_xact("\\lo_import", own_transaction); sprintf(cmdbuf, "COMMENT ON LARGE OBJECT %u IS '", loid); bufptr = cmdbuf + strlen(cmdbuf); bufptr += PQescapeStringConn(pset.db, bufptr, comment_arg, slen, NULL); strcpy(bufptr, "'"); if (!(res = PSQLexec(cmdbuf, false))) { free(cmdbuf); return fail_lo_xact("\\lo_import", own_transaction); } PQclear(res); free(cmdbuf); } if (!finish_lo_xact("\\lo_import", own_transaction)) return false; print_lo_result("lo_import %u", loid); sprintf(oidbuf, "%u", loid); SetVariable(pset.vars, "LASTOID", oidbuf); return true; }
void CGenerator::VarDeclSetList() { // verbose output writeRep(" $(type) $(name); // $(alias) (set/list)\n", stdout); // do the work // write set / list declaration writeVarDeclSetList(); // reset item to standard SetVariable(CGenerator::VAR_ITEM, mpszItem); }
void IBFact::ResolveVariableFromCond(const class IBAction* pAction, const IBFactCondDef& oCondDef) { for (uint i = 0; i < oCondDef.m_aLinkNames.size(); ++i) { const IBObject* pObj = pAction->GetVariable(oCondDef.m_aLinkNames[i].m_sActionVarName); if (pObj) SetVariable(oCondDef.m_aLinkNames[i].m_sCondVarName, *pObj); } }
void ZConfigFile::SetVariable(std::string sec, std::string var, std::string val) { std::list<ZCF_Section>::iterator secIter; std::list<ZCF_Variable>::iterator varIter; if(Exists(CleanString(sec))) //if section exists find it { sec = CleanString(sec); for(secIter = rFileLayout.begin(); secIter != rFileLayout.end(); ++secIter) { if(CleanString((*secIter).section) == sec) //if this is the section { if(Exists(sec,var)) //if variable exists find it { var = CleanString(var); for(varIter = (*secIter).varList.begin(); varIter != (*secIter).varList.end(); ++varIter) { if(CleanString((*varIter).var) == var) //once variable found, set value { (*varIter).val = val; break; //break from this loop } } break; //done in the for loop, time to go } else { ZCF_Variable tempVar; tempVar.var = var; (*secIter).varList.push_back(tempVar); SetVariable(sec,var,val); } } } } else { ZCF_Section tempSec; tempSec.section = sec; rFileLayout.push_back(tempSec); SetVariable(sec,var,val); } }
/* * PrintQueryResults: print out query results as required * * Note: Utility function for use by SendQuery() only. * * Returns true if the query executed successfully, false otherwise. */ static bool PrintQueryResults(PGresult *results) { bool success = false; if (!results) return false; switch (PQresultStatus(results)) { case PGRES_TUPLES_OK: success = PrintQueryTuples(results); break; case PGRES_COMMAND_OK: { char buf[10]; success = true; sprintf(buf, "%u", (unsigned int) PQoidValue(results)); if (!QUIET()) { if (pset.popt.topt.format == PRINT_HTML) { fputs("<p>", pset.queryFout); html_escaped_print(PQcmdStatus(results), pset.queryFout); fputs("</p>\n", pset.queryFout); } else fprintf(pset.queryFout, "%s\n", PQcmdStatus(results)); } SetVariable(pset.vars, "LASTOID", buf); break; } case PGRES_EMPTY_QUERY: success = true; break; case PGRES_COPY_OUT: case PGRES_COPY_IN: /* nothing to do here */ success = true; break; default: break; } fflush(pset.queryFout); return success; }
void CHistoryView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here SetVariable(); DrawFrameText(pDC); DrawQuantity(pDC); DrawLineOfAverageFiveDay(pDC); DrawLineOfK(pDC); }
void IBAction::ResolveVariableFromPostCond(const IBFact* pPostCond) { const IBFactCondDef* pCond = m_pDef->FindPostCond(pPostCond->GetFactDef()->GetName()); for (uint i = 0; i < pCond->m_aLinkNames.size(); ++i) { const IBObject* pObj = pPostCond->GetVariable(pCond->m_aLinkNames[i].m_sCondVarName); if (pObj) SetVariable(pCond->m_aLinkNames[i].m_sActionVarName, pObj->GetName(), pObj->GetUserData()); } }
void ZConfigFile::Process(std::string filename) { rFilename = filename; int commentNum,newlineNum; char commentStr[15],newlineStr[15]; std::string section, str, var, tmp; std::ifstream cfile(rFilename.c_str()); commentNum = newlineNum = 0; //comment/newline support is a bit of a hack rFileLayout.clear(); //layout must be cleared, in case variable is being used multiple times while(!cfile.eof() && cfile.is_open()) //parses entire file { std::getline(cfile,str); //read in a line tmp = CleanString(str); //get a clean version //if std::string is bracketed it is a section, if it begins in a letter it is a variable if(tmp[0] == '[' && tmp[tmp.length()-1] == ']') section = str; else if(std::isalpha(tmp[0])) //variables must start with a letter { var = str.substr(0,str.find('=')); //split the std::string at the equals sign SetVariable(section,var,str.substr(str.find('=')+1,str.length()-var.length()-1)); } else if(tmp[0] == '#' || tmp[0] == ';') //acceptable comment characters { sprintf(commentStr,"__comment%d",commentNum); SetVariable(section,commentStr,str); ++commentNum; } else if(tmp.length() == 0 && !cfile.eof()) //avoid adding a line to end of file each time { sprintf(newlineStr,"__newline%d",newlineNum); SetVariable(section,newlineStr,str); ++newlineNum; } } cfile.close(); }
//从文件中读取变量 VOID CVariableSystem::LoadVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf) { KLAssert(szFileName); // mapBuf.clear(); //----------------------------------------------------------- //取得配置文件的大小 HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE == hFile) return; DWORD dwHigh; DWORD dwFileSize = GetFileSize(hFile, &dwHigh); CloseHandle(hFile); hFile = NULL; if(0==dwFileSize) return; //----------------------------------------------------------- //分配足够的内存 CHAR* pTempBuf = new CHAR[dwFileSize+32]; if(!pTempBuf) return; //----------------------------------------------------------- //从配置文件中读取"Variable"节 ::GetPrivateProfileSection("Variable", pTempBuf, dwFileSize, szFileName); //分解 std::vector< STRING > vRet; ConvertSectionInVector(pTempBuf, dwFileSize, vRet); delete[] pTempBuf; pTempBuf=NULL; //加入变量定义 for(INT i=0; i<(INT)vRet.size(); i++) { STRING& strLine = vRet[i]; STRING::size_type tEqu = strLine.find_first_of("= \t"); if(tEqu == STRING::npos) continue; STRING strName = strLine.substr(0, tEqu); CHAR szTemp[1024]; ::GetPrivateProfileString("Variable", strName.c_str(), "", szTemp, 1024, szFileName); SetVariable(strName.c_str(), szTemp, FALSE); } }
/* * StoreQueryTuple: assuming query result is OK, save data into variables * * Returns true if successful, false otherwise. */ static bool StoreQueryTuple(const PGresult *result) { bool success = true; if (PQntuples(result) < 1) { psql_error("no rows returned for \\gset\n"); success = false; } else if (PQntuples(result) > 1) { psql_error("more than one row returned for \\gset\n"); success = false; } else { int i; for (i = 0; i < PQnfields(result); i++) { char *colname = PQfname(result, i); char *varname; char *value; /* concate prefix and column name */ varname = pg_malloc(strlen(pset.gset_prefix) + strlen(colname) + 1); strcpy(varname, pset.gset_prefix); strcat(varname, colname); if (!PQgetisnull(result, 0, i)) value = PQgetvalue(result, 0, i); else { /* for NULL value, unset rather than set the variable */ value = NULL; } if (!SetVariable(pset.vars, varname, value)) { psql_error("could not set variable \"%s\"\n", varname); free(varname); success = false; break; } free(varname); } } return success; }