void ns2overloadedGlobalFunction_24(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns1::ClassA> SharedClassA; checkArguments("ns2overloadedGlobalFunction",nargout,nargin,1); ns1::ClassA& a = *unwrap_shared_ptr< ns1::ClassA >(in[0], "ptr_ns1ClassA"); out[0] = wrap_shared_ptr(SharedClassA(new ns1::ClassA(ns2::overloadedGlobalFunction(a))),"ns1.ClassA", false); }
void ns2ClassA_memberFunction_9(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns2::ClassA> Shared; checkArguments("memberFunction",nargout,nargin-1,0); Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA"); out[0] = wrap< double >(obj->memberFunction()); }
int main(int argc, char *argv[]) { if(argc == 1 && !cgiIsOnWeb()) usage(); cgiSpoof(&argc, argv); checkArguments(); hSetDb(origGenome); if(hgTest) runSamples("hgCoordConv.test.good", "hgCoordConv.test.bad", origGenome, origGenome, numTests); else { /* do our thing */ if(calledSelf) { cartEmptyShell(doConvertCoordinates, hUserCookie(), excludeVars, NULL); } else { /* Check to see if in zoo browser... if so call doFormZoo */ if (!containsStringNoCase(origDb, "zoo")) cartEmptyShell(doForm, hUserCookie(), excludeVars, NULL); else cartEmptyShell(doFormZoo, hUserCookie(), excludeVars, NULL); } } return 0; }
sExpression *apply(sExpression *procOrLambda, sExpression *argument, sEnvironment *env){ if(isPrimitiveProc(procOrLambda)) { sProc *cfunc = toProc(procOrLambda); return applyProc(cfunc, argument); } else if(isLambdaType(procOrLambda)) { sLambda *lambd = toLambda(procOrLambda); sList *body = lambd->body; sList *arguments; sList *parameters; if(isList(argument)){ //可変長引数のため parameters = checkParameters(lambd->parameters, toList(argument)); arguments = checkArguments(parameters, toList(argument), lambd->isVarArgument); }else{ parameters = lambd->parameters; arguments = toList(cons(argument, &sNull)); } sEnvironment *env = extendEnvironment(parameters, arguments, lambd->frame); if(isList(car(body))){ return evalSequence(body, env); }else{ return eval(newExp(body, LIST_TAG), env); } } return &sNull; }
// Operators static int equal(lua_State *L) { checkArguments(L); Circle s = Circle_pull(L, 1); Circle t = Circle_pull(L, 2); lua_pushboolean(L, s == t); return 1; }
void ns2ClassA_nsArg_10(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns2::ClassA> Shared; checkArguments("nsArg",nargout,nargin-1,1); Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA"); ns1::ClassB& arg = *unwrap_shared_ptr< ns1::ClassB >(in[1], "ptr_ns1ClassB"); out[0] = wrap< int >(obj->nsArg(arg)); }
static int sub(lua_State *L) { checkArguments(L); Matrix2* v = checkMatrix2(L, 1); Matrix2* u = checkMatrix2(L, 2); Matrix2_push(L, new Matrix2(*v-*u)); return 1; }
void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) { static ento::mpi::MPIFunctionClassifier FuncClassifier(*Result.Context); const CallExpr *const CE = Result.Nodes.getNodeAs<CallExpr>("CE"); if (!CE->getDirectCallee()) return; const IdentifierInfo *Identifier = CE->getDirectCallee()->getIdentifier(); if (!Identifier || !FuncClassifier.isMPIType(Identifier)) return; // These containers are used, to capture buffer, MPI datatype pairs. SmallVector<const Type *, 1> BufferTypes; SmallVector<const Expr *, 1> BufferExprs; SmallVector<StringRef, 1> MPIDatatypes; // Adds a buffer, MPI datatype pair of an MPI call expression to the // containers. For buffers, the type and expression is captured. auto addPair = [&CE, &Result, &BufferTypes, &BufferExprs, &MPIDatatypes]( const size_t BufferIdx, const size_t DatatypeIdx) { // Skip null pointer constants and in place 'operators'. if (CE->getArg(BufferIdx)->isNullPointerConstant( *Result.Context, Expr::NPC_ValueDependentIsNull) || tooling::fixit::getText(*CE->getArg(BufferIdx), *Result.Context) == "MPI_IN_PLACE") return; StringRef MPIDatatype = tooling::fixit::getText(*CE->getArg(DatatypeIdx), *Result.Context); const Type *ArgType = argumentType(CE, BufferIdx); // Skip unknown MPI datatypes and void pointers. if (!isStandardMPIDatatype(MPIDatatype) || ArgType->isVoidType()) return; BufferTypes.push_back(ArgType); BufferExprs.push_back(CE->getArg(BufferIdx)); MPIDatatypes.push_back(MPIDatatype); }; // Collect all buffer, MPI datatype pairs for the inspected call expression. if (FuncClassifier.isPointToPointType(Identifier)) { addPair(0, 2); } else if (FuncClassifier.isCollectiveType(Identifier)) { if (FuncClassifier.isReduceType(Identifier)) { addPair(0, 3); addPair(1, 3); } else if (FuncClassifier.isScatterType(Identifier) || FuncClassifier.isGatherType(Identifier) || FuncClassifier.isAlltoallType(Identifier)) { addPair(0, 2); addPair(3, 5); } else if (FuncClassifier.isBcastType(Identifier)) { addPair(0, 2); } } checkArguments(BufferTypes, BufferExprs, MPIDatatypes, Result.Context->getLangOpts()); }
void ns2ClassA_nsReturn_11(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns2::ns3::ClassB> SharedClassB; typedef boost::shared_ptr<ns2::ClassA> Shared; checkArguments("nsReturn",nargout,nargin-1,1); Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA"); double q = unwrap< double >(in[1]); out[0] = wrap_shared_ptr(SharedClassB(new ns2::ns3::ClassB(obj->nsReturn(q))),"ns2.ns3.ClassB", false); }
int main(int argc, char *argv[]) { std::string startMode = checkArguments (argc,argv); QApplication a(argc, argv); bool simulationMode=false; if (startMode=="simulation") simulationMode = true; DataProcessing dataProcessor(simulationMode); MapWidget mapW; OriginDataWidget originDataW; StationsDataWidget stationsDataW; /**SIGNAL -> SLOT mapping**/ QObject::connect (&dataProcessor, SIGNAL(stationsLoaded(std::set<Station>)), &stationsDataW, SLOT(showStationsData(std::set<Station>))); QObject::connect (&dataProcessor, SIGNAL(stationsLoaded(std::set<Station>)), &mapW, SLOT(paintStations(std::set<Station>))); QObject::connect (&dataProcessor, SIGNAL(originReceived(Origin)), &originDataW, SLOT(showOriginData(Origin))); QObject::connect (&dataProcessor, SIGNAL(originReceived(Origin)), &mapW, SLOT(paintOrigin(Origin))); QObject::connect (&dataProcessor, SIGNAL(stationColorReceived(std::set<Station>)), &stationsDataW, SLOT(changeStationsData(std::set<Station>))); QObject::connect (&dataProcessor, SIGNAL(stationColorReceived(std::set<Station>)), &mapW, SLOT(changeStationsColors(std::set<Station>))); QObject::connect (&dataProcessor, SIGNAL(eventReceived(Origin)), &originDataW, SLOT(showOriginData(Origin))); QObject::connect (&dataProcessor, SIGNAL(eventReceived(Origin)), &mapW, SLOT(paintOrigin(Origin))); mapW.show(); originDataW.show(); stationsDataW.show(); if (startMode == "realtime"){ dataProcessor.init(); } else if (startMode == "simulation"){ QDateTime datetime =QDateTime::fromString(QString(argv[2])+" "+QString(argv[3]), "yyyy-MM-dd hh:mm:ss"); dataProcessor.init(); dataProcessor.initSimulation(datetime); } return a.exec(); }
//-------------------------------------------------- // This unittest reads a cdoc file list it's contents //-------------------------------------------------- int main(int argc, char** argv) { int err = ERR_OK, k, i; char *infile=0; DEncEncryptedData* pEncData; char buf1[50], buf2[50]; fprintf(stdout, "%s - %s\n", g_szProg, g_szVer); if(argc < 1) { printf("USAGE: %s <cdoc-infile>\n", g_szProg); return -1; } else { for(i = 0; (err == ERR_OK) && (i < argc); i++) { err = checkArguments(argc, argv, &i, &infile); } } init(argc, argv); fprintf(stdout, "Read cdoc: %s\n", infile); err = dencSaxReadEncryptedData(&pEncData, infile); if(!err) { fprintf(stdout, "\nEncryptedData - Id=%s Type=%s MimeType=%s EncryptionMethod=%s", (pEncData->szId ? pEncData->szId : ""), (pEncData->szType ? pEncData->szType : ""), (pEncData->szMimeType ? pEncData->szMimeType : ""), (pEncData->szEncryptionMethod ? pEncData->szEncryptionMethod : "")); err = dencMetaInfo_GetLibVersion(pEncData, buf1, buf2); fprintf(stdout, "\n\tLIBRARY: %s VERSION: %s", buf1, buf2); err = dencMetaInfo_GetFormatVersion(pEncData, buf1, buf2); fprintf(stdout, "\n\tFORMAT: %s VERSION: %s", buf1, buf2); for(k = 0; k < pEncData->nEncryptedKeys; k++) { DEncEncryptedKey *pEncKey = pEncData->arrEncryptedKeys[k]; fprintf(stdout, "\nEncryptedKey: Id=%s Recipient=%s KeyName=%s CarriedKeyName=%s EncryptionMethod=%s Cert: %s", (pEncKey->szId ? pEncKey->szId : ""), (pEncKey->szRecipient ? pEncKey->szRecipient : ""), (pEncKey->szKeyName ? pEncKey->szKeyName : ""), (pEncKey->szCarriedKeyName ? pEncKey->szCarriedKeyName : ""), (pEncKey->szEncryptionMethod ? pEncKey->szEncryptionMethod : ""), (pEncKey->pCert ? "OK" : "NULL")); } if(pEncData->encProperties.nEncryptionProperties > 0) { fprintf(stdout, "\nEncryptionProperties: %s", (pEncData->encProperties.szId ? pEncData->encProperties.szId : "")); for(k = 0; k < pEncData->encProperties.nEncryptionProperties; k++) { DEncEncryptionProperty *pEncProp = pEncData->encProperties.arrEncryptionProperties[k]; fprintf(stdout, "\nEncryptionProperty Id=%s Target=%s Name=%s Content=%s\n", (pEncProp->szId ? pEncProp->szId : ""), (pEncProp->szTarget ? pEncProp->szTarget : ""), (pEncProp->szName ? pEncProp->szName : ""), (pEncProp->szContent ? pEncProp->szContent : "")); } } } // display result listStatus(g_szProg, err); return err; }
//-------------------------------------------------- // This unittest reads a ddoc file and removes a data file //-------------------------------------------------- int main(int argc, char** argv) { int err = ERR_OK, i, nMaxDfLen; char *infile=0, *outfile=0, *dfid; SignedDoc* pSigDoc = 0; DataFile* pDf = 0; fprintf(stdout, "%s - %s\n", g_szProg, g_szVer); if(argc < 3) { printf("USAGE: %s <ddoc-infile> <ddoc-outfile> <datafile-id>\n", g_szProg); return -1; } else { for(i = 0; (err == ERR_OK) && (i < argc); i++) { err = checkArguments(argc, argv, &i, &infile); err = checkArguments(argc, argv, &i, &outfile); err = checkArguments(argc, argv, &i, &dfid); } } init(argc, argv); nMaxDfLen = ConfigItem_lookup_int("DATAFILE_MAX_CACHE", 0); fprintf(stdout, "Read ddoc: %s\n", infile); err = ddocSaxReadSignedDocFromFile(&pSigDoc, infile, 0, nMaxDfLen); if(!err) { fprintf(stdout, "Find datafile: %s\n", dfid); pDf = getDataFileWithId(pSigDoc, dfid); if(pDf) { err = DataFile_delete(pSigDoc, dfid); } else { err = ERR_BAD_DATAFILE_INDEX; fprintf(stdout, "Invalid datafile id: %s\n", dfid); } } if(!err) { fprintf(stdout, "Writing ddoc: %s\n", outfile); err = createSignedDoc(pSigDoc, infile, outfile); } // display result listStatus(g_szProg, err); return err; }
void ClassD_deconstructor_21(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ClassD> Shared; checkArguments("delete_ClassD",nargout,nargin,1); Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0])); Collector_ClassD::iterator item; item = collector_ClassD.find(self); if(item != collector_ClassD.end()) { delete self; collector_ClassD.erase(item); } }
void ns2ns3ClassB_deconstructor_15(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns2::ns3::ClassB> Shared; checkArguments("delete_ns2ns3ClassB",nargout,nargin,1); Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0])); Collector_ns2ns3ClassB::iterator item; item = collector_ns2ns3ClassB.find(self); if(item != collector_ns2ns3ClassB.end()) { delete self; collector_ns2ns3ClassB.erase(item); } }
//-------------------------------------------------- // This unittest reads a ddoc file and adds a data file //-------------------------------------------------- int main(int argc, char** argv) { int err = ERR_OK, i, nMaxDfLen; char *infile=0, *outfile=0, *dfinfile, *mime=0, *content="EMBEDDED_BASE64"; SignedDoc* pSigDoc = 0; DataFile* pDf = 0; fprintf(stdout, "%s - %s\n", g_szProg, g_szVer); if(argc < 5) { printf("USAGE: %s <ddoc-infile> <ddoc-outfile> <datafile-name> <mime-type> [<content-type>]\n", g_szProg); return -1; } else { for(i = 0; (err == ERR_OK) && (i < argc); i++) { err = checkArguments(argc, argv, &i, &infile); err = checkArguments(argc, argv, &i, &outfile); err = checkArguments(argc, argv, &i, &dfinfile); err = checkArguments(argc, argv, &i, &mime); err = checkArguments(argc, argv, &i, &content); } } init(argc, argv); nMaxDfLen = ConfigItem_lookup_int("DATAFILE_MAX_CACHE", 0); fprintf(stdout, "Read ddoc: %s\n", infile); err = ddocSaxReadSignedDocFromFile(&pSigDoc, infile, 0, nMaxDfLen); if(!err) { fprintf(stdout, "Add datafile: %s mime: %s content: %s\n", dfinfile, mime, content); err = DataFile_new(&pDf, pSigDoc, NULL, dfinfile, content, mime, 0, NULL, 0, NULL, NULL); } if(!err) err = calculateDataFileSizeAndDigest(pSigDoc, pDf->szId, infile, DIGEST_SHA1); if(!err) { fprintf(stdout, "Writing ddoc: %s\n", outfile); err = createSignedDoc(pSigDoc, infile, outfile); } // display result listStatus(g_szProg, err); return err; }
StaticMapLayer::StaticMapLayer(const QVector<QVector<StaticMapObject*>> & staticObjects) : staticObjects(staticObjects) { try { checkArguments(staticObjects); } catch(...) { freeResources(); throw; } }
static int multiply(lua_State *L) { checkArguments(L); Matrix2* v = checkMatrix2(L, 1); if (lua_isnumber(L,2)) { real scale = lua_tonumber(L,2); Matrix2_push(L, new Matrix2((*v)*scale)); } else { Matrix2* u = checkMatrix2(L, 2); Matrix2_push(L, new Matrix2((*v)*(*u))); } return 1; }
int main(int argc, char* argv[]){ g_argc = argc; g_argv = argv; if (checkArguments()) return; size = argc-optind-1; int pids[size]; g_pids = pids; int i = 0; for (; i < size; i++) executeCopy(i); waitChildren(); }
int main(int argc, char **argv){ //find out which test from which suite to run int testNumber, testSuite; checkArguments(argc, argv); testNumber = atoi(argv[1]); testSuite = atoi(argv[2]); //start up a generator and get a test running on it unif01_Gen *gen; gen = ulcg_CreateLCG (2147483647, 16807, 0, 12345); //start the test & suite that was passed startSingleTest(gen, testNumber, testSuite); ulcg_DeleteGen (gen); return 0; }
int main(int argc, char* argv[]) { if (checkArguments(argc) != 0) return -1; char date[MAXDATESIZE]; getDates(argv[1], date); char direc[sizeof(argv[1]) + sizeof(date) + 2 + 1]; sprintf(direc, "%s/%s", argv[1], date); //direc[strlen(direc) - 1] = 0; chdirec(direc); //printf("\n%s\n", direc); readBCKP(argv[1], direc, argv[2]); return EXIT_SUCCESS; }
int main(int argc, char** argv) { checkArguments(argc); applyArguents(argv); streams::openAll(); streams::handleErrors(); source = &streams::oldConfig; target = &streams::newConfig; int totalEdits = reader::readInteger(streams::changesFile); if (totalEdits == 0) reachEnd(); else { for (int i = 1; i <= totalEdits; i += 1) { char mode; string newData; char offset = ' '; string oldData; setStreams(i, totalEdits); getEdit(mode, newData, offset, oldData); int lineNumber = reachEdit(oldData); makeEdit(mode, offset, newData, lineNumber); reachEnd(); streams::closeTemp(); } } streams::closeAll(); return 0; }
bool StaticRecordsReader::checkRecord(char *mem, qint64 memSize, qint64 pos, qint64 &readedSize, bool &success, QString argName, QVariant &argValue, quint64 &time, SimpleEventInfo *info) { time = 0; success = false; if(!translateArg(mem, memSize, pos, time)) return false; pos += sizeof(quint64); readedSize += sizeof(quint64); if(argName == "time") { argValue.setValue(time); success = true; } quint8 eventID = 0; if(!translateArg(mem, memSize, pos, eventID)) return false; pos += sizeof(quint8); readedSize += sizeof(quint8); if(argName == "eventID") { argValue.setValue(eventID); success = true; } if(!checkArguments(mem, memSize, pos, readedSize, success, argName, argValue, info, eventID)) return false; return true; }
int main(int argc, char* argv[]) { string config_path, house_path, algo_path, score_path; map<string, string> houses_mapName, algo_mapName, config_mapName, score_mapName; vector <fs::path> fileName_currDir; vector <House*> houses; vector <AbstractAlgorithm*> algos; map<string, string> configBeforeValid; map<string, int> config; map<string, string> ErrorMSGHouse; vector<unique_ptr<AbstractAlgorithm>> Algos; map<string, string> ErrorMSGAlgo; string ErrorMSGScore = ""; bool makeVideo = false; int number_threads; vector<void*> handlersVector; void* scoreHandler; scoreFunc scorefunction = nullptr; bool house_exist, config_exist, algo_exist, score_exist; checkArguments(argc, argv, config_path, algo_path, house_path, score_path, number_threads, makeVideo); if (makeVideo && (number_threads > 1)) { cout << "Cannot create video with more than one thread" << endl; return 1; } house_exist = updateFilesFromDirectory(houses_mapName, ".house", house_path); config_exist = updateFilesFromDirectory(config_mapName, ".ini", config_path); algo_exist = updateFilesFromDirectory(algo_mapName, "_.so", algo_path); if (score_path != "") { score_exist = updateFilesFromDirectory(score_mapName, "score_formula.so", score_path); if (score_exist) { for (auto scoreFilesNames : score_mapName) { const char* tmpname = scoreFilesNames.first.c_str(); scoreHandler = dlopen(tmpname, RTLD_NOW); if (scoreHandler == nullptr) { ErrorMSGScore = "score_formula.so exists in '" + score_path + "' but cannot be opened or is not a valid .so"; break; } *(void **)(&scorefunction) = dlsym(scoreHandler, "calc_score"); if (scorefunction == nullptr) { ErrorMSGScore = "score_formula.so is a valid.so but it does not have a valid score formula"; break; } } } } else { scorefunction = nullptr; score_exist = true; } if (!house_exist || !algo_exist || !config_exist || !score_exist) { Usage(house_path, config_path, algo_path, score_path, house_exist, config_exist, algo_exist, score_exist); return 1; } if (ErrorMSGScore != "") { cout << ErrorMSGScore << endl; return 1; } int numberOfValidHouses = checkHouses(houses_mapName, &houses, &ErrorMSGHouse); if (!checkConfig(config_mapName.begin()->first, &configBeforeValid, config_path)) { return 1; } convertToMapInt(configBeforeValid, &config); for (auto algoSoFilesNames : algo_mapName) { int resNum = AlgorithmRegistrar::getInstance().loadAlgorithm(algoSoFilesNames.first, algoSoFilesNames.first); if (resNum == -1) { ErrorMSGAlgo[algoSoFilesNames.first] = "file cannot be loaded or is not a valid .so"; continue; } else if (resNum == -2) { ErrorMSGAlgo[algoSoFilesNames.first] = "valid .so but no algorithm was registered after loading it"; continue; } } Algos = AlgorithmRegistrar::getInstance().getAlgorithms(); list<string> algorithmNames = AlgorithmRegistrar::getInstance().getAlgorithmNames(); for (vector<unique_ptr<AbstractAlgorithm>>::size_type k = 0; k != Algos.size(); k++) { auto l_front = algorithmNames.begin(); std::advance(l_front, k); string algoName = *l_front; if (ErrorMSGAlgo.find(algoName) == ErrorMSGAlgo.end()) algos.push_back(Algos[k].release()); } bool scoreError = true; int numberOfValidAlgo = algos.size(); if (numberOfValidAlgo && numberOfValidHouses) { vector<string> algoOnlyNames, houseonlyNames; createVcetorFromMapValues(algoOnlyNames, algo_mapName, ErrorMSGAlgo); createVcetorFromMapValues(houseonlyNames, houses_mapName, ErrorMSGHouse); Simulator sim(houses, algos, config, algoOnlyNames, houseonlyNames, makeVideo); scoreError = sim.runSimulator(algoOnlyNames, houseonlyNames, number_threads, scorefunction); } if (ErrorMSGHouse.size() > 0 || ErrorMSGAlgo.size() > 0) { cout << "\n" << "Errors:" << endl; if (houses.size() == 0) cout << "All house files in target folder " << "'" << house_path << "'" << " cannot be opened or are invalid:" << endl; PrintErrors(ErrorMSGHouse, houses_mapName, "house"); if (algos.size() == 0) cout << "All algorithm files in target folder " << "'" << algo_path << "'" << " cannot be opened or are invalid:" << endl; PrintErrors(ErrorMSGAlgo, algo_mapName, "so"); } if (!scoreError) cout << "Score formula could not calculate some scores, see -1 in the results table" << endl; for (auto it = houses.begin(); it != houses.end(); it++) delete *it; AlgorithmRegistrar::getInstance().closeAlgorithms(); houses.clear(); Algos.clear(); return 0; }
Execute::Execute(const std::vector<std::string>& args, const ConfigurationChecker& conf): _formula_manager(FormulaManager()), Command(conf) { checkArguments(args); _script_name = args[1]; }
int main(int argc, char *argv[]) { int i; int fd; int ret; int c; const char *device; const char *script_file; int num_args = 0; int args[MAX_COMMAND_ARGS]; char *line, *cmd, *arg; while ((c = getopt (argc, argv, "t")) != -1) { if (c=='t') { print_actions = 1; } else { fprintf(stderr, "Unknown option: -%c\n", c); } } if((argc - optind) != 2) { fprintf(stderr, "Usage: %s [options] <device> <script file>\n\n" "Options:\n" " -t print event timings\n", argv[0]); return 1; } device = argv[optind]; script_file = argv[optind + 1]; fd = open(device, O_RDWR); if(fd < 0) { fprintf(stderr, "could not open %s, %s\n", device, strerror(errno)); return 1; } uint32_t device_flags = figure_out_events_device_reports(fd); FILE *f = fopen(script_file, "r"); if (!f) { printf("Unable to read file %s", script_file); return 1; } line = malloc(sizeof(char)*MAX_COMMAND_LEN); int lineCount = 0; while (fgets(line, MAX_COMMAND_LEN, f) != NULL) { // Remove end-of-line comments. char *comment = strstr(line, "#"); if (comment != NULL) *comment = '\0'; lineCount += 1; int hasNextCmd = 1; char *tempLine = line; commandLoop: while (hasNextCmd) { num_args = 0; hasNextCmd = 0; int errCode = 0; // Parse {-} comments before command names. do { if ((cmd = strtok(tempLine, " \n")) == NULL) goto commandLoop; tempLine = NULL; } while ((errCode = parseComment(cmd, lineCount)) == 1); if (errCode < 0) return 1; while ((arg = strtok(NULL, " \n")) != NULL) { // Parse comment {-} within arguments. if ((errCode = parseComment(arg, lineCount)) != 0) { if (errCode < 0) return 1; continue; } // If we enter a new command, we remember the position for the next iteration. if (*arg == ';') { hasNextCmd = 1; break; } assert(num_args < MAX_COMMAND_ARGS); args[num_args] = atoi(arg); num_args++; } if (strcmp(cmd, "tap") == 0) { checkArguments(cmd, num_args, 4, lineCount); execute_tap(fd, device_flags, args[0], args[1], args[2], args[3]); } else if (strcmp(cmd, "drag") == 0) { checkArguments(cmd, num_args, 6, lineCount); execute_drag(fd, device_flags, args[0], args[1], args[2], args[3], args[4], args[5]); } else if (strcmp(cmd, "sleep") == 0) { checkArguments(cmd, num_args, 1, lineCount); execute_sleep(args[0]); } else if (strcmp(cmd, "pinch") == 0) { checkArguments(cmd, num_args, 10, lineCount); execute_pinch(fd, device_flags, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); } else if (strcmp(cmd, "keyup") == 0) { checkArguments(cmd, num_args, 1, lineCount); execute_keyup(fd, args[0]); } else if (strcmp(cmd, "keydown") == 0) { checkArguments(cmd, num_args, 1, lineCount); execute_keydown(fd, args[0]); } else { printf("Unrecognized command at line %d: '%s'\n", lineCount, cmd); return 1; } } } free(line); return 0; }
void ns2ClassA_afunction_12(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr<ns2::ClassA> Shared; checkArguments("ns2ClassA.afunction",nargout,nargin,0); out[0] = wrap< double >(ns2::ClassA::afunction()); }
void ns2aGlobalFunction_23(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("ns2aGlobalFunction",nargout,nargin,0); out[0] = wrap< Vector >(ns2::aGlobalFunction()); }
//! Die Hauptfunktion zum Testen // int main(int argc, char *argv[]) { int res; rlimit rlp; res = getrlimit(RLIMIT_CORE, &rlp); std::cout<<"max core size: "<<rlp.rlim_cur<<std::endl; std::cout<<"current core size: "<<rlp.rlim_max<<std::endl; rlp.rlim_cur = 20000; res = getrlimit(RLIMIT_CORE, &rlp); if (res < 0) { std::cout<<"err: "<<errno<<std::endl; perror("setrlimit: RLIMIT_CORE"); exit(-2); } importmaps = false; //di::postgres::enable_trace_query = true; // get more info for unspecified exceptions std::set_terminate(__gnu_cxx::__verbose_terminate_handler); // save starting time time_t starttime; time(&starttime); std::stringstream ss; ss << starttime; configOptions["starttime"] = ss.str(); //Initialize Logging Options InitLogOptions(); Logger::writeMessage("basic", "\nStarte Illarion !"); // initialize randomizer initRandom(); // initialize signalhandlers if (! init_sighandlers()) { return 1; } // deactivate savethread // unsigned long int thisonlinetime = 0; checkArguments(argc, argv); // set up logfiles etc. and check if everything works if (! setup_files()) { return 1; } Logger::writeMessage("basic", "main: server requires clientversion: " + configOptions["clientversion"], false); Logger::writeMessage("basic", "main: listen port: " + configOptions["port"], false); Logger::writeMessage("basic", "main: data directory: " + configOptions["datadir"], false); // initialise DB Manager Database::ConnectionManager::Login login; Database::ConnectionManager::Server server; login.database = configOptions["postgres_db"]; login.user = configOptions["postgres_user"]; login.password = configOptions["postgres_pwd"]; server.host = configOptions["postgres_host"]; server.port = configOptions["postgres_port"]; Database::ConnectionManager::getInstance().setupManager(login, server); Database::SchemaHelper::setSchemata(configOptions["postgres_schema_server"], configOptions["postgres_schema_account"]); //Welt anlegen World *world = World::create(configOptions["datadir"] , starttime); //Laden der Daten fr die Welt (Items, Scripte, Tabellen etc.) loadData(); if (!importmaps) { world->Load("Illarion"); } else { configOptions["disable_login"] = "******"; world->load_from_editor(configOptions["datadir"] + std::string("map/import/oberwelt_0")); } std::cout<<"Creation the PlayerManager"<<std::endl; PlayerManager::get()->activate(); std::cout<<"PlayerManager activated"<<std::endl; PlayerManager::TPLAYERVECTOR &newplayers = PlayerManager::get()->getLogInPlayers(); timespec stime; stime.tv_sec = 0; stime.tv_nsec = 25000000; //25ms //NPC's erschaffen world->initNPC(); //run both reload scripts to initialize semi-dynamic data try { boost::shared_ptr<LuaReloadScript> tmpScript(new LuaReloadScript("server.reload_defs")); if (!tmpScript->onReload()) { std::cerr << "server.reload_defs.onReload returned false" << std::endl; } } catch (ScriptException &e) { std::cerr << "reload_defs: " << e.what() << std::endl; } try { boost::shared_ptr<LuaReloadScript> tmpScript(new LuaReloadScript("server.reload_tables")); if (!tmpScript->onReload()) { std::cerr << "server.reload_tables.onReload returned false" << std::endl; }; } catch (ScriptException &e) { std::cerr << "reload_tables: " << e.what() << std::endl; } Logger::writeMessage("basic","Scheduler wird Initialisiert \n",false); //Scheduler Initialisieren world->initScheduler(); int new_players_processed; running = true; // die OnlinePlayer-Liste aktualisieren (-> auf 0) world->saveAllPlayerNamesToFile(configOptions["datadir"] + std::string(ONLINEPLFILE)); while (running) { // Ausgaben auf std::cout in die Datei schreiben std::cout.flush(); // make sure we don't block the server with processing new players... new_players_processed = 0; // process new players from connection thread while (!newplayers.empty() && new_players_processed < MAXPLAYERSPROCESSED) { new_players_processed++; Player *newPlayer = newplayers.non_block_pop_front(); if (newPlayer) { login_save(newPlayer); if (newPlayer->isMonitoringClient()) { world->monitoringClientList->clientConnect(newPlayer); } else { try { std::cout<<"login sucessully from: "<<newPlayer->name<<" "<<newPlayer->id<<std::endl; world->Players.push_back(newPlayer); newPlayer->login(); try { std::cout<<"calling onlogin"<<std::endl; loginScript->onLogin(newPlayer); } catch (ScriptException &e) { std::cerr<<"Login Script: Failed to load scripts/login.lua !"<<std::endl; } world->updatePlayerList(); } catch (Player::LogoutException &e) { std::cout<<"got logout Exception during login!"<<std::endl; boost::shared_ptr<BasicServerCommand> cmd(new LogOutTC(e.getReason())); newPlayer->Connection->shutdownSend(cmd); //newPlayer->Connection->closeConnection(); PlayerManager::get()->getLogOutPlayers().non_block_push_back(newPlayer); } } } else { std::cout<<"try to get new player but was NULL!"<<std::endl; } } // get new players // Eingaben der Player abarbeiten und die Karte altern world->turntheworld(); nanosleep(&stime, NULL); } Logger::writeMessage("basic","Beende Illarion!"); std::cout<<"Server Shutdown:"<<std::endl; scriptVariables->save(); std::cout<<"Scriptvariables saved!"<<std::endl; world->forceLogoutOfAllPlayers(); //saving all players which where forced logged out. PlayerManager::get()->saveAll(); world->takeMonsterAndNPCFromMap(); Logger::writeMessage("basic","Statistik aktualisieren"); Logger::writeMessage("basic","OnlinePlayer-Liste aktualisieren (-> auf 0)"); world->saveAllPlayerNamesToFile(configOptions["datadir"] + std::string(ONLINEPLFILE)); Logger::writeMessage("basic","Karten speichern"); world->Save("Illarion"); Logger::writeMessage("basic","InitialConnection beenden"); Logger::writeMessage("basic", "Die in loadItems(..) angelegten Tabellen loeschen"); delete CommonItems; CommonItems = NULL; delete ItemNames; ItemNames = NULL; delete WeaponItems; WeaponItems = NULL; delete ArmorItems; ArmorItems = NULL; delete ContainerItems; ContainerItems = NULL; delete TilesModItems; TilesModItems = NULL; delete Tiles; Tiles = NULL; delete world; world = NULL; reset_sighandlers(); time(&starttime); Logger::writeMessage("basic","main: Ende "); return EXIT_SUCCESS; }
void nmfDriver(const char* a, const int k, int iter, const char* w0, const char* h0, alg_t alg, options_t * opts) { #ifdef PROFILE_NMF_DRIVER struct timeval start, end; gettimeofday(&start, 0); #endif #if DEBUG_LEVEL >= 2 printf("Entering nmfDriver\n"); #endif #ifdef ERROR_CHECKING errno = 0; //no error occured so far #endif options_t default_opts; //Explicit options or Defaultoptions (if opts = NULL) if (!opts) { set_default_opts(&default_opts); opts = &default_opts; } // checking arguments if (checkArguments(a, k, iter, w0, h0, opts)) { perror("Arguments invalid in nmfDriver"); return; } // declaring basic variables to load matrices int m, n, m_w0, n_w0, m_h0, n_h0; double * A, *W0, *H0; W0 = NULL; H0 = NULL; loadMatrix(a, &m, &n, &A); if (errno) { perror("Loading matrix A failed in nmfDriver"); free(A); return; } if (k > m || k > n) { errno = EDOM; perror("Approximation factor k bigger than original matrix dimensions."); free(A); return; } if (w0 && h0) { loadMatrix(w0, &m_w0, &n_w0, &W0); loadMatrix(h0, &m_h0, &n_h0, &H0); } else { generateMatrix(m, n, k, opts->init, opts->min_init, opts->max_init, &W0, &H0, A, opts); } #ifdef ERROR_CHECKING if(errno) { perror("Loading matrix W0 failed in nmfDriver"); perror("Loading matrix H0 failed in nmfDriver"); free(H0); free(A); free(W0); return; } #endif #ifdef PROFILE_MATLAB_COMPARISON struct timeval start_matlab, end_matlab; gettimeofday(&start_matlab, 0); #endif if (checkMatrices(A, W0, H0, m, n, k)) { errno = EDOM; perror("Matrices not compatible in nmfDriver"); free(A); free(W0); free(H0); return; } //memory for saving matrices w and h with the best norm double * wbest = (double*) malloc(sizeof(double)*m*k); double * hbest = (double*) malloc(sizeof(double)*k*n); //memory for normalizing final matrices wbest and hbest double * hlen = (double*) malloc(sizeof(double)*k); idx_double * wlen = (idx_double*) malloc(sizeof(idx_double)*k); //stores the indices of column-sums as well for resorting wbest/hbest #ifdef ERROR_CHECKING if(errno) { perror("Failed allocating memory in nmfDriver"); free(A); free(W0); free(H0); free(wbest); free(hbest); free(hlen); free(wlen); return; } #endif double norm = 0.0; norm = HUGE_VAL; double normbest = 0.0; normbest = HUGE_VAL; int repetitions; for (repetitions = 1; repetitions <= opts->rep; ++repetitions) { switch (alg) { case mu: norm = nmf_mu(A, &W0, &H0, m, n, k, &iter, opts->TolX, opts->TolFun); break; case als: norm = nmf_als(&A, &W0, &H0, m, n, k, &iter, opts->TolX, opts->TolFun); break; case neals: norm = nmf_neals(&A, &W0, &H0, m, n, k, &iter, opts->TolX, opts->TolFun); break; case alspg: norm = nmf_alspg(&A, &W0, &H0, m, n, k, &iter, opts->TolX); break; case pg: norm = nmf_pg(&A, &W0, &H0, m, n, k, &iter, opts->TolX); break; } //storing best matrices w and h so far, if the norm is the best so far if (norm < normbest) { normbest = norm; swap(&wbest, &W0); swap(&hbest, &H0); } //re-initialise the starting matrices w0 and h0, if there are more repetitions to be run if (repetitions < opts->rep) { generateMatrix(m, n, k, ran, opts->min_init, opts->max_init, &W0, &H0, A, opts); } } //end of loop from 1 to rep #if DEBUG_LEVEL >= 0 //Output final norm printf("Final Norm: %.16f\n", normbest); #endif //normalizing results //------------------- double temp; temp = 0.; int i, j; //calculating hlen for (i = 0; i<k; ++i) { temp = 0.; for (j = 0; j<n; ++j) { temp += pow(hbest[i + j*k], 2); } temp = sqrt(temp); if (temp == 0.) { hlen[i] = 1.; fprintf(stderr, "Warning: Matrix H doesn't have full rank\n"); } else hlen[i] = temp; } //wbest = wbest .* hlen' for (i=0; i<m; ++i) { for (j=0; j<k; ++j) { wbest[i + j*m] *= hlen[j]; } } //hbest = hbest ./ hlen for (j=0; j<n; ++j) for (i=0; i<k; ++i) hbest[i + j*k] /= hlen[i]; //Calculating wlen for sorting columns of w and rows of h for(j = 0; j<k; ++j) { temp = 0; for(i=0; i<m; ++i) { temp += wbest[i+j*m] * wbest[i+j*m]; } wlen[j].val = temp; wlen[j].idx = j; } //sort wlen in descending order int elementsize = 0; elementsize = sizeof(idx_double); qsort(wlen, k, elementsize, cmpidx_double); //resorting columns of wbest according to order in wlen for(j=0; j<k; ++j) { for(i=0; i<m; ++i) { W0[i + j*m] = wbest[i + wlen[j].idx*m]; } } //resorting rows of hbest according to order in wlen for(j=0; j<n; ++j) { for(i=0; i<k; ++i) { H0[i + j*k] = hbest[wlen[i].idx + j*k]; } } #ifdef PROFILE_MATLAB_COMPARISON gettimeofday(&end_matlab, 0); outputTiming("Timing of MATLAB_COMPARISON:", start_matlab, end_matlab); #endif //storing final results in files if (opts->w_out) storeMatrix(opts->w_out, m, k, W0); if (opts->h_out) storeMatrix(opts->h_out, k, n, H0); //freeing memory of dynamic variables free(A); free(W0); free(H0); free(wbest); free(hbest); free(hlen); free(wlen); #if DEBUG_LEVEL >= 2 printf("Exiting nmfDriver\n"); #endif #ifdef PROFILE_NMF_DRIVER gettimeofday(&end, 0); outputTiming("Timing:", start, end); #endif }