bool RtspEmbeddedRtpPacket::bind(RTPPacket * newRtpPacket, ChannelIdType newChannelId, LengthType newLength ) { // check args // if (! checkSanity(newRtpPacket, newChannelId, newLength)) { return false; } // args are fine totalNumFragments = 0; boundaryReached = false; status = BOUND; buildDollarSequenceBuffer(newChannelId, newLength); fillOutBufferFragmentGroupFromPacket(newRtpPacket); startAccounting(); return true; }
bool NElfDecoder::decode_elf_ph() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"NElfDecoder::decode_elf_ph()\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; offset=fphoff; unsigned int phtype,phflags; ULONG phaddr,phpaddr; ULONG phoff,phsize,phfsize,phalign; ULONG lastAddr=0; if(fphnum>1000) fphnum=1000; // Sanity check... for(unsigned int t=0;t<fphnum;t++) { phtype=map->read32(offset+getImageOffset(),LSB); offset+=4; if(bitness==32) { phoff=map->read32(offset+getImageOffset(),LSB); offset+=4; phaddr=map->read32(offset+getImageOffset(),LSB); offset+=4; phpaddr=map->read32(offset+getImageOffset(),LSB); offset+=4; phfsize=map->read32(offset+getImageOffset(),LSB); offset+=4; phsize=map->read32(offset+getImageOffset(),LSB); offset+=4; phflags=map->read32(offset+getImageOffset(),LSB); offset+=4; phalign=map->read32(offset+getImageOffset(),LSB); offset+=4; } else { phflags=map->read32(offset+getImageOffset(),LSB); offset+=4; phoff=map->read64(offset+getImageOffset(),LSB); offset+=8; phaddr=map->read64(offset+getImageOffset(),LSB); offset+=8; phpaddr=map->read64(offset+getImageOffset(),LSB); offset+=8; phfsize=map->read64(offset+getImageOffset(),LSB); offset+=8; phsize=map->read64(offset+getImageOffset(),LSB); offset+=8; phalign=map->read64(offset+getImageOffset(),LSB); offset+=8; } DEBUG_OUT<<"p_node "<<t<<" phtype="<<phtype<<" "<<" phoff="<<phoff; DEBUG_OUT<<" phaddr="<<phaddr<<" "<<" phpaddr="<<phpaddr<<" phfsize="<<phfsize; DEBUG_OUT<<" phsize="<<phsize<<" "<<" phflags="<<phflags; DEBUG_OUT<<"\n"; if(ld->getNeedsReloc()) { phaddr=lastAddr; lastAddr+=phsize; // Align on 32-bit word (Is this right for 64 bit?) if(lastAddr&0x3) lastAddr=(lastAddr&0xfffffffc)+4; } /* if(phtype) { NBinaryNode *n=new NBinaryNode("node_p"),t,phtype,phaddr, phsize,phoff,E_MEM_ALL); if(n) ld->getModule()->getNodes()->append(n); else std::cerr<<"Didn't get NBinaryNode!\n"); } */ } return true; }
bool NAmigaHunkDecoder::decodeNodes() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Amiga decodeNodes...\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; offset=0; numHunks=0; nextHunk=0; readHeader(); readNodes(); return true; }
bool NElfDecoder::decodeNodes() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Elf decodeNodes...\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; bool ret=true; ret=readHeader(); if(ret) { if(fphoff) ret=decode_elf_ph(); } if(ret) { if(fshoff) ret=decode_elf_sh(); } if(ret) ret=readStringsAndSymbols(); return ret; }
static boolean checkRelease(struct gbRelease* release, char* database, unsigned type, unsigned orgCats, char* accPrefix) /* Check a release/type */ { struct sqlConnection* conn = hAllocConn(database); struct gbSelect select; ZeroVar(&select); select.release = release; select.type = type; select.orgCats = orgCats; select.accPrefix = accPrefix; boolean checked = checkSanity(database, &select, conn); hFreeConn(&conn); return checked; }
bool NAmigaHunkDecoder::verifyOkay() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Amiga verify...\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; bool ret=false; ld->reset(); if((binmem[0]==0x00)&&(binmem[1]==0x00)&&(binmem[2]==0x03)&&(binmem[3]==0xf3)) { LSB=false; shouldDemandPage=true; dynamic=false; needsReloc=true; } else { DEBUG_OUT<<"File is not in Amiga format!\n"; return false; } return true; }
bool NAmigaHunkDecoder::readHeader() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"amiga readHeader\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Amiga"; DEBUG_OUT<<" binary at "<<(ULONG)getImageOffset()<<"\n"; #endif // DEBUG_VERBOSE ld->getModule()->setNeedsReloc(true); LSB=false; offset=4; unsigned int nameLen=map->read32(offset+getImageOffset(),LSB); offset+=4; if(nameLen) { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"nameLen="<<nameLen<<"\n"; #endif // DEBUG_VERBOSE offset+=4*nameLen; } numHunks=map->read32(offset+getImageOffset(),LSB); offset+=4; #ifdef DEBUG_VERBOSE DEBUG_OUT<<"numHunks="<<numHunks<<" "; #endif // DEBUG_VERBOSE unsigned int F=map->read32(offset+getImageOffset(),LSB); offset+=4; #ifdef DEBUG_VERBOSE DEBUG_OUT<<"F="<<F<<" "; #endif // DEBUG_VERBOSE unsigned int L=map->read32(offset+getImageOffset(),LSB); offset+=4; #ifdef DEBUG_VERBOSE DEBUG_OUT<<"L="<<L<<"\n"; #endif // DEBUG_VERBOSE offset+=(L-F+1)*4; return true; }
bool NElfDecoder::verifyOkay() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Elf verify...\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; bool ret=false; ld->reset(); LSB=false; bitness=32; if((binmem[0]==0x7f)&&(binmem[1]=='E')&&(binmem[2]=='L')&&(binmem[3]=='F')) { if(binmem[6]!=1) DEBUG_OUT<<"Warning, ELF format may be too new!\n"; if(binmem[4]==2) bitness=64; if(binmem[5]==1) LSB=true; #ifdef DEBUG_VERBOSE if(LSB) DEBUG_OUT<<"Little-endian "; else DEBUG_OUT<<"Big-endian "; #endif // DEBUG_VERBOSE } else { DEBUG_OUT<<"File is not in ELF format!\n"; return false; } return true; }
/* CENTRAL METHOD to parse and render html request*/ int handle(cchar* q0,int conn){ int len=(int)strlen(q0); if(len>1000){ p("checkSanity len>1000"); return 0;// SAFETY! } char* q=editable(q0); checkSanity(q,len); while(q[0]=='/')q++; enum result_format format = html;//txt; html DANGER WITH ROBOTS enum result_verbosity verbosity = normal; if (eq(q, "favicon.ico"))return 0; if(contains(q,"robots.txt")){ Writeline(conn,"User-agent: *\n"); Writeline("Disallow: /\n"); return 0; } char* jsonp=strstr(q,"jsonp");// ?jsonp=fun if(jsonp){ jsonp[-1]=0; jsonp+=6; format = json; } else jsonp=(char*)"parseResults"; if (endsWith(q, ".json")) { format = json; q[len-5]=0; } if (endsWith(q, ".xml")) { format = xml; q[len-4]=0; } if (endsWith(q, ".csv")||endsWith(q, ".tsv")) { format = csv; q[len-4]=0; } if (endsWith(q, ".txt")) { format = txt; q[len-4]=0; } if (endsWith(q, ".html")) { format = html; q[len-5]=0; } if (startsWith(q, ".js")) { q[len-3]=0; Writeline(conn, jsonp); Writeline(conn, "("); format = js; } // todo : dedup!! if (startsWith(q, "all/")) { cut_to(q," +"); cut_to(q," -"); q = q + 4; showExcludes=false; verbosity = alle; } if (startsWith(q, "long/")){ verbosity = longer; q = q + 5; } if (startsWith(q, "full/")) { verbosity = verbose; q = q + 5; } if (startsWith(q, "verbose/")) { verbosity = verbose; q = q + 8; } if (startsWith(q, "short/")) { verbosity = shorter; q = q + 6; } if (startsWith(q, "html/")) { format = html; if(!contains(q,".")&&!contains(q,":")) verbosity=verbose; q = q + 5; } if (startsWith(q, "plain/")) { format = txt; q = q + 6; } if (startsWith(q, "text/")) { format = txt; q = q + 5; } if (startsWith(q, "txt/")) { format = txt; q = q + 4; } if (startsWith(q, "xml/")) { format = xml; q = q + 4; } if (startsWith(q, "csv/")||startsWith(q, "tsv/")) { format = csv; q = q + 4; } if (startsWith(q, "json/")) { format = json; q = q + 5; } if (startsWith(q, "js/")) { q = q + 3; Writeline(conn, jsonp); Writeline(conn, "("); format = js; } if (startsWith(q, "long/")) { verbosity = longer; q = q + 5; } if (startsWith(q, "verbose/")) { verbosity = verbose; q = q + 8; } if (startsWith(q, "short/")) { verbosity = shorter; q = q + 6; } if (startsWith(q, "excludes/")||startsWith(q, "includes/")||startsWith(q, "excluded/")||startsWith(q, "included/")||startsWith(q, "showview/")) { showExcludes=true; verbosity=longer; q = q + 9; } else showExcludes=false; excluded.clear(); included.clear(); if(contains(q,"statement count")){Writeline(conn,itoa((int)context->statementCount).data());return 0;} if(contains(q,"node count")){Writeline(conn,itoa(context->nodeCount).data());return 0;} if (startsWith(q, "all/")) { cut_to(q," +"); cut_to(q," -"); q = q + 4; showExcludes=false; verbosity = alle; } // bool get_topic=false; bool get_topic=true; bool sort=false; if (startsWith(q, "ee/")||startsWith(q, "ee ")) { q[2]=' '; get_topic=true; } if (startsWith(q, "entities/")) { q[8]=' '; get_topic=true; // verbosity=longer; } if(hasWord(q)) loadView(q); if(contains(q,"exclude")||contains(q,"include")){ verbosity=normal; showExcludes=true; } p(q); // !!!!!!!!!!!!!!!!!!!!!!!!!!! // NodeVector all = parse(q); // <<<<<<<< HANDLE QUERY WITH NETBASE! // // !!!!!!!!!!!!!!!!!!!!!!!!!!! autoIds=false; int size=(int)all.size(); if(showExcludes){ for (int i = 0; i < size; i++) { // todo : own routine!!! Node* node = (Node*) all[i]; if(!contains(all,getAbstract(node->name))) all.push_back(getAbstract(node->name)); N parent= getType(node); if(parent){ if(!contains(all,parent))all.push_back(parent); N abs= getAbstract(parent->name); if(parent&&!contains(all,abs))all.push_back(abs); } } show(excluded); } const char* html_block="<!DOCTYPE html><html><head><META HTTP-EQUIV='CONTENT-TYPE' CONTENT='text/html; charset=UTF-8'/></head>"\ "<body><div id='netbase_results'></div>\n<script>var results="; // if((int)all.size()==0)Writeline("0"); // Writeline(conn,q); char buff[10000]; bool use_json= format == json || format == js || format == html; if (format == xml && (startsWith(q,"select")||contains(q," where "))){Writeline(conn,query2(q));return 0;} if (format == xml)Writeline(conn, "<results>\n"); if (format == html)Writeline(conn,html_block); if (use_json)Writeline(conn, "{\"results\":[\n"); const char* statement_format_xml = " <statement id='%d' subject=\"%s\" predicate=\"%s\" object=\"%s\" sid='%d' pid='%d' oid='%d'/>\n"; const char* statement_format_text = " $%d %s %s %s %d->%d->%d\n"; const char* statement_format_json = " { \"id\":%d, \"subject\":\"%s\", \"predicate\":\"%s\", \"object\":\"%s\", \"sid\":%d, \"pid\":%d, \"oid\":%d}"; const char* statement_format_csv = "%d\t%s\t%s\t%s\t%d\t%d\t%d\n"; const char* statement_format = 0; if (format == xml)statement_format = statement_format_xml; if (format == html)statement_format = statement_format_json; if (format == json)statement_format = statement_format_json; if (format == txt)statement_format = statement_format_text; if (format == csv)statement_format = statement_format_csv; const char* entity_format = 0; const char* entity_format_txt = "%s #%d (statements:%d) %s\n"; const char* entity_format_xml = "<entity name=\"%s\" id='%d' statementCount='%d' description='%s'>\n"; const char* entity_format_json = " {\"name\":\"%s\", \"id\":%d, \"statementCount\":%d, \"description\":\"%s\""; const char* entity_format_csv = "%s\t%d\t%d\t%s\n"; if(all.size()==1)entity_format_csv = "";//statements! if (format == xml)entity_format = entity_format_xml; if (format == txt)entity_format = entity_format_txt; if (format == csv)entity_format = entity_format_csv; if (use_json) entity_format = entity_format_json; Node* last=0; warnings=0; char* entity=0; if(startsWith(q,"all")){ entity=(char*)cut_to(q," "); entity=keep_to(entity,"limit"); } sortNodes(all); int count=(int)all.size(); int good=0; for (int i = 0; i < count && i<resultLimit; i++) { Node* node = (Node*) all[i]; if(!checkNode(node))continue; if(node->id==0)continue; if(last==node)continue; if(eq(node->name,"◊"))continue; last=node; if(verbosity ==normal && entity&& eq(entity,node->name))continue; char* text=getText(node); // if(use_json && get_topic){ // if(empty(text))continue;//! no description = no entity? BAD for amazon etc // if(isAbstract(node))continue; // N t=getTopic(node); // } good++; if (use_json)if(good>1)Writeline(conn, "},\n"); sprintf(buff, entity_format, node->name, node->id,node->statementCount,text); Writeline(conn, buff); // if(verbosity != alle && !get_topic) // loadView(node); bool got_topic=false; if(use_json && get_topic){ N c=getClass(node); N t=getTopic(node); N ty=getType(node); // if(!c)c=t; if(!t)t=ty; if(t==node)t=ty; if(t!=Entity && checkNode(t)){ got_topic=true; Writeline(conn, ",\n\t \"topicid\":"+itoa(t->id)); Writeline(conn, ", \"topic\":\""+string(t->name)+"\""); } if(c && c!=t){ Writeline(conn, ",\n\t \"classid\":"+itoa(c->id)); Writeline(conn, ", \"class\":\""+string(c->name)+"\""); } if(ty&& c!=ty && ty!=t){ Writeline(conn, ",\n\t \"typeid\":"+itoa(ty->id)); Writeline(conn, ", \"type\":\""+string(ty->name)+"\""); } } if(use_json)// && (verbosity==verbose||verbosity==shorter))// lol // just name Writeline(conn, ", \"kind\":"+itoa(node->kind)); if((use_json)&&!showExcludes&&node->statementCount>1 && getImage(node)!="") Writeline(", \"image\":\""+replace_all(replace_all(getImage(node,150,/*thumb*/true),"'","%27"),"\"","%22")+"\""); // if((use_json)&&getText(node)[0]!=0) // Writeline(", \"description\":\""+string(getText(node))+"\""); Statement* s = 0; if (format==csv|| verbosity == verbose || verbosity == longer|| verbosity == alle || showExcludes || ( all.size() == 1 && !(verbosity == shorter))) { int count=0; // Writeline(",image:\""+getImage(node->name)+"\""); if (use_json)Writeline(conn, ",\n\t \"statements\":[\n"); // sortStatements( deque<Statement*> statements;// sort while ((s = nextStatement(node, s))&&count++<lookupLimit){// resultLimit if (!checkStatement(s))break; // if(!got_topic &&( s->predicate==_Type|| s->predicate==_SuperClass)){ // addStatementToNode(node, s->id(), true);// next time // } if(get_topic &&!got_topic && verbosity != verbose && (s->predicate>100 || s->predicate<-100)) continue;// only important stuff here! // filter statements if(s->object==0)continue; // if(eq(s->Predicate()->name,"Offizielle Website") && !contains(s->Object()->name,"www")) // continue; if (s->subject==node->id and s->predicate!=4)//_instance statements.push_front(s); else statements.push_back(s); } // if(get_topic && verbosity!=shorter){ // NV topics=getTopics(node); // N s=topics[0]; // for (int j = 0; j < topics.size() && j<=resultLimit; j++) { // N s=topics[j]; // Temporary statement (node,topic,s) // statements.push_front(s); // } // } int good=0; for (int j = 0; j < statements.size() && j<=resultLimit; j++) { s=statements.at(j); // while ((s = nextStatement(node, s))&&count++<resultLimit) { if(format==csv&&all.size()>1)break;// entities vs statements p(s); if(verbosity!=alle&&checkHideStatement(s)){warnings++;continue;} fixLabels(s); if(!(verbosity==verbose||verbosity==alle) && (s->Predicate()==Instance||s->Predicate()==Type))continue; if(use_json && good>0)Writeline(conn, ",\n"); char* objectName=s->Object()->name; if(s->Predicate()==Instance){ N type=findProperty(s->Object(),Type->name,0,50); if( checkNode(type)) objectName=(char*)(concat(concat(objectName, ": "),type->name)); } sprintf(buff, statement_format, s->id(), s->Subject()->name, s->Predicate()->name, objectName, s->Subject()->id, s->Predicate()->id, s->Object()->id); Writeline(conn, buff); good++; } if (use_json)Writeline(conn, "]"); } if (format == xml)Writeline(conn, "</entity>\n"); // string img=getImage(node->name); // if(img!="")Writeline(conn,"<img src=\""+img+"\"/>"); } if (use_json || format == html || format == js)Writeline(conn,good>0?"}\n]}":"]}"); if (format == xml)Writeline(conn, "</results>\n"); if(format == js)Writeline(conn, ")");// jsonp const char* html_end=";\n</script>\n<script src='http://pannous.net/netbase.js'></script></body></html>\n"; if(format == html)Writeline(conn, html_end); // sprintf(buff, "<script src='/js/%s'></script>",q0); // Writeline(conn, buff); // } pf("Warnings/excluded: %d\n",warnings); return 0;// 0K }
bool NElfDecoder::readHeader() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"elf readHeader\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; #ifdef DEBUG_VERBOSE DEBUG_OUT<<"ELF"; if(bitness==64) DEBUG_OUT<<"64"; else DEBUG_OUT<<"32"; DEBUG_OUT<<" binary at "<<(ULONG)getImageOffset()<<"\n"; #endif // DEBUG_VERBOSE offset=5; LSB=false; if(map->read8(offset+getImageOffset())==1) LSB=true; offset=16; // Skip rest of magic number, etc. ftype=map->read16(offset+getImageOffset(),LSB); offset+=2; arch=map->read16(offset+getImageOffset(),LSB); offset+=2; unsigned int vers=map->read32(offset+getImageOffset(),LSB); offset+=4; if(bitness==64) { ld->setEntry(map->read64(offset+getImageOffset(),LSB)); offset+=8; fphoff=map->read64(offset+getImageOffset(),LSB); offset+=8; fshoff=map->read64(offset+getImageOffset(),LSB); offset+=8; } else { ld->setEntry(map->read32(offset+getImageOffset(),LSB)); offset+=4; fphoff=map->read32(offset+getImageOffset(),LSB); offset+=4; fshoff=map->read32(offset+getImageOffset(),LSB); offset+=4; } unsigned int flags=map->read32(offset+getImageOffset(),LSB); offset+=4; unsigned int hsize=map->read16(offset+getImageOffset(),LSB); offset+=2; fphsize=map->read16(offset+getImageOffset(),LSB); offset+=2; fphnum=map->read16(offset+getImageOffset(),LSB); offset+=2; fshsize=map->read16(offset+getImageOffset(),LSB); offset+=2; fshnum=map->read16(offset+getImageOffset(),LSB); offset+=2; fstind=map->read16(offset+getImageOffset(),LSB); offset+=2; ld->setUnknown(false); switch(ftype) { case 1: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"REL"; #endif // DEBUG_VERBOSE break; case 2: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"EXEC"; #endif // DEBUG_VERBOSE break; case 3: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"DYN"; #endif // DEBUG_VERBOSE break; case 4: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"CORE"; #endif // DEBUG_VERBOSE break; case 16: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"REL?"; #endif // DEBUG_VERBOSE break; default: #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Unknown class (#"<<ftype<<")"; #endif // DEBUG_VERBOSE ld->setUnknown(true); break; } ld->setNeedsReloc(false); if(ftype==1) ld->setNeedsReloc(true); #ifdef DEBUG_VERBOSE DEBUG_OUT<<", "; DEBUG_OUT<<archString()<<"\n"; #endif // DEBUG_VERBOSE if(ld->getUnknown()) { DEBUG_OUT<<"ELF file format error!\n"; //return; } #ifdef DEBUG_VERBOSE DEBUG_OUT<<"Header, Entry at "<<ld->getEntry()<<"\n"; DEBUG_OUT<<"phof="<<fphoff<<" phsz="<<fphsize<<" phnm="<<fphnum<<"\n"; DEBUG_OUT<<"shof="<<fshoff<<" shsz="<<fshsize<<" shnm="<<fshnum<<"\n"; DEBUG_OUT<<"stind="<<fstind<<"\n"; #endif // DEBUG_VERBOSE return true; }
bool NElfDecoder::decode_elf_sh() { #ifdef DEBUG_VERBOSE DEBUG_OUT<<"NElfDecoder::decode_elf_sh()\n"; #endif // DEBUG_VERBOSE if(!checkSanity()) return false; if(ld->getUnknown()) return false; offset=fshoff; unsigned int shname,shtype,shlink,shinfo; ULONG shaddr,shoff,shflags,shsize,shalign,shentsize; ULONG lastAddr=0; bool reloc=false; if(fshnum>1000) fshnum=1000; // Sanity check... for(unsigned int t=0;t<fshnum;t++) { reloc=false; ULONG toffset=offset; shname=map->read32(offset+getImageOffset(),LSB); offset+=4; shtype=map->read32(offset+getImageOffset(),LSB); offset+=4; if(bitness==32) { shflags=map->read32(offset+getImageOffset(),LSB); offset+=4; shaddr=map->read32(offset+getImageOffset(),LSB); offset+=4; shoff=map->read32(offset+getImageOffset(),LSB); offset+=4; shsize=map->read32(offset+getImageOffset(),LSB); offset+=4; } else { shflags=map->read64(offset+getImageOffset(),LSB); offset+=8; shaddr=map->read64(offset+getImageOffset(),LSB); offset+=8; shoff=map->read64(offset+getImageOffset(),LSB); offset+=8; shsize=map->read64(offset+getImageOffset(),LSB); offset+=8; } DEBUG_OUT<<"(offset is "<<offset<<")\n"; shlink=map->read32(offset+getImageOffset(),LSB); offset+=4; shinfo=map->read32(offset+getImageOffset(),LSB); offset+=4; if(bitness==32) { shalign=map->read32(offset+getImageOffset(),LSB); offset+=4; shentsize=map->read32(offset+getImageOffset(),LSB); offset+=4; } else { shalign=map->read64(offset+getImageOffset(),LSB); offset+=8; shentsize=map->read64(offset+getImageOffset(),LSB); offset+=8; } DEBUG_OUT<<"s_node "<<t<<" shname="<<shname<<" shoff="<<shoff<<" shaddr="<<shaddr; DEBUG_OUT<<" shsize="<<shsize<<" shlink="<<shlink<<" "<<"shinfo="<<shinfo; DEBUG_OUT<<" shtype="<<shtype<<" shflags="<<shflags<<" "<<"shentsize="<<shentsize; DEBUG_OUT<<"\n"; if(ld->getNeedsReloc()) { reloc=true; shaddr=lastAddr; lastAddr+=shsize; // Align on 32-bit word (Is this right for 64 bit?) if(lastAddr&0x3) lastAddr=(lastAddr&0xfffffffc)+4; } unsigned int perm=0; if(shflags&1) perm|=E_MEM_WRITE; if(shflags&2) perm|=E_MEM_READ; if(shflags&4) perm|=E_MEM_EXEC; if(shtype) { NBinaryNode *n=new NBinaryNode("node_s",t,shtype,shaddr,shsize,shoff,perm,(BYTE *)NULL,toffset); if(n) ld->getModule()->getNodes()->append(n); else { std::cerr<<"Didn't get NBinaryNode!\n"; exit(5); } } } return true; }
int main(int argc, char **argv) { if (argc == 2 && std::string(argv[1]) == "test") return !test(); if (argc < 10) { std::cerr << "Usage: " << argv[0] << " : " << "dataset_directory rows cols hiddenNeurons outputNeurons epochs minibatchSize learningRate picsPerClass" << std::endl; return 1; } size_t inputLayer = atoi(argv[2]) * atoi(argv[3]); size_t hiddenLayer = atoi(argv[4]); size_t outputLayer = atoi(argv[5]); size_t epochs = atoi(argv[6]); size_t minibatchSize = atoi(argv[7]); double learningRate = atof(argv[8]); size_t maxPicsPerClass = atoi(argv[9]); std::cout << "==============" << std::endl; std::cout << "==Parameters==" << std::endl; std::cout << "==============" << std::endl; std::cout << "Number of neurons in input layer : " << atoi(argv[2]) << "x" << atoi(argv[3]) << "=" << inputLayer << std::endl; std::cout << "Number of neurons in hidden layer : " << hiddenLayer << std::endl; std::cout << "Number of neurons in output layer : " << outputLayer << std::endl; std::cout << "Epochs : " << epochs << std::endl; std::cout << "Minibatch size : " << minibatchSize << std::endl; std::cout << "Learning rate : " << learningRate << std::endl; std::cout << "Maximum pictures per class : " << maxPicsPerClass << std::endl; std::cout << "===================" << std::endl; std::cout << "==Opening dataset==" << std::endl; std::cout << "===================" << std::endl; Network::TrainingData trainingSet = getDataSet(std::string(argv[1]), outputLayer, maxPicsPerClass); std::random_shuffle(trainingSet.begin(), trainingSet.end()); Network::TrainingData testSet = slice(trainingSet, 0.9); std::cout << "Checking training and test inputs sanity" << std::endl; checkSanity(trainingSet); checkSanity(testSet); std::cout << "===========================" << std::endl; std::cout << "==Beginning NN processing==" << std::endl; std::cout << "===========================" << std::endl; // dumpInputs(testSet); /* !!!!!!!! */ Network nn({inputLayer, hiddenLayer, outputLayer}); nn.sgd(trainingSet, testSet, epochs, minibatchSize, learningRate); // nn.dump(); // cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE); // cv::imshow("Display Image", image); // cv::waitKey(0); std::cout << "isok" << std::endl; return 0; }