int main(int ac, char *av[]) { char rpath[MAX_NAME_LEN]; int status, *jstatus; simplequeue_t *outputQ, *workQ, *qtoa; pthread_t IGMP_broadcast_thread; // create separate thread for broadcasting IGMP group query messages pthread_create(&IGMP_broadcast_thread, NULL, IGMPBroadcast, NULL); // setup the program properties setupProgram(ac, av); // creates a PID file under router_name.pid in the current directory status = makePIDFile(rconfig.router_name, rpath); // shutdown the router on receiving SIGUSR1 or SIGUSR2 redefineSignalHandler(SIGUSR1, shutdownRouter); redefineSignalHandler(SIGUSR2, shutdownRouter); outputQ = createSimpleQueue("outputQueue", INFINITE_Q_SIZE, 0, 1); workQ = createSimpleQueue("work Queue", INFINITE_Q_SIZE, 0, 1); GNETInit(&(rconfig.ghandler), rconfig.config_dir, rconfig.router_name, outputQ); ARPInit(); IPInit(); classifier = createClassifier(); filter = createFilter(classifier, 0); pcore = createPacketCore(rconfig.router_name, outputQ, workQ); // add a default Queue.. the createClassifier has already added a rule with "default" tag // char *qname, char *dqisc, double qweight, double delay_us, int nslots); addPktCoreQueue(pcore, "default", "taildrop", 1.0, 2.0, 0); rconfig.scheduler = PktCoreSchedulerInit(pcore); rconfig.worker = PktCoreWorkerInit(pcore); infoInit(rconfig.config_dir, rconfig.router_name); addTarget("Output Queue", outputQ); qtoa = getCoreQueue(pcore, "default"); if (qtoa != NULL) addTarget("Default Queue", qtoa); else printf("Error .. found null queue for default\n"); // start the CLI.. CLIInit(&(rconfig)); wait4thread(rconfig.scheduler); wait4thread(rconfig.worker); wait4thread(rconfig.ghandler); wait4thread(IGMP_broadcast_thread); }
void TerrainFBO::setup() { w =2048*2; h=2048*2; setupProgram(); setupFBO(); setupDrawData(); npMaterial mat; mat.loadDiffuse("3DAssets/terrainNoise.png"); textureNoise = mat.diffuseTexture; }
return &spritesheets[id].spritesheet; } SpriteList spritesFromSheet(SpriteSheet s, Data squares){ String vs = "attribute vec2 position; attribute vec2 uv;\n\ varying vec2 texcoord; void main(){\n\ gl_Position=vec4(position, 0, 1);\n\ texcoord=uv;}"; String fs = "precision mediump float; \n\ uniform sampler2D texture; \n\ varying vec2 texcoord; \n\ void main() {\n\ gl_FragColor = texture2D(texture, texcoord);\n\ }"; Program = setupProgram(vs, fs); SquareList sl = create_square_list(Program, squares, 0); SpriteList splist = ZERO_STRUCT; splist.squareList = sl; splist.ImageId = spritesheets[s.id].ImageId; return splist; } void renderSpriteList(SpriteList sl) { glUseProgram(sl.squareList.program); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sl.ImageId); glUniform1i( glGetUniformLocation(sl.squareList.program,
int evaluateSyntax(int scode){ char *scodeStr=syntaxString[scode-NUMOFTOKEN]; int *temp=syntaxInner[scode-NUMOFTOKEN]; int j=1; if(currentToken<0){ printf("EOF\n");return -1; } /*evaluate SPROGRAM*/ if(scode==SPROGRAM){ logPutOut(" evaluateSyntax(%s) line:%d\n",scodeStr,lastLineNumber); for(j=1;j<=5;j++){ if(evaluateWord(temp[j])<0){ errPrint("evaluateSyntax(%s)->(%d)",scodeStr,temp[j]); } if(j==2){ setupProgram(tmpString); #ifdef CSL sprintf(cName,"%s.%s",filename,FILETYPE); if((cFile=fopen(cName,"w"))==NULL){ exit(-1); } TAGCOMB("$$",idList.prog->name->name); START(tag); LAD("\t","gr0","0"); CALL("\t","L1"); tagnum++; CALL("\t","FLUSH"); SVC("\t","0"); fclose(cFile); #endif } } #ifdef CSL if((cFile=fopen(cName,"a"))==NULL) exit(-1); END(""); //printTextFile("cFile","library.txt"); fclose(cFile); #endif return(scode); } /*evaluate SBROCK*/ else if(scode==SBROCK){ scope=idList.prog->name->name; logPutOut(" evaluateSyntax(%s) line:%d\n",scodeStr,lastLineNumber); do{ if(currentToken==TVAR){ //except check pPrint(ALLOWINDENT); if(evaluateWord(SVARDECLARE)<0){ errPrint("evaluateSyntax(%s)->(%d)",scodeStr,SVARDECLARE); } }else if(currentToken==TPROCEDURE){ //except check pPrint(ALLOWINDENT); if(evaluateWord(SSUBPROGDECLARE)<0){ errPrint("evaluateSyntax(%s)->(%d)",scodeStr,TPROCEDURE); } }else{ j++; } }while(j==1); pPrint(RESETINDENT); #ifdef CSL if((cFile=fopen(cName,"a"))==NULL) exit(-1); // TAGNAME("L"); TAGCOMB("L","1"); TAGPRINT(tag); fclose(cFile); #endif if(evaluateWord(temp[3])<0){ errPrint("evaluateSyntax(%s)->(%d)",scodeStr,temp[3]); } return(scode); } /*evaluate SVARDECLARE*/ else if(scode==SVARDECLARE){ logPutOut(" evaluateSyntax(%s) line:%d\n",scodeStr,lastLineNumber); int tempType; for(j=1;j<=3;j++){ if(evaluateWord(temp[j])<0){ errPrint("no var(var declaretion)\n"); } if(j==1){ pPrint(ADDINDENT,1); } } if((tempType=evaluateWord(temp[j++]))<0){//j=4 errPrint("must be type\n"); } int arrayNum=0; if(tempType==SARRAY){ arrayNum=tempArray.arrayNum; tempType=tempArray.type; } int k; for(k=0;k<tempListCount;k++){ #ifdef CSL if((cFile=fopen(cName,"a"))==NULL) exit(-1); if(arrayNum==0){ if(scope==idList.prog->name->name){ TAGCOMB("$",tempList->word); }else{ TAGCOMB2("$",tempList->word,"\%",scope); } DC(tag,"0"); }else{ int arr; for(arr=0;arr<=arrayNum;arr++){ if(scope==idList.prog->name->name){ TAGCOMBARRAY("$",tempList->word,arr); }else{ TAGCOMBARRAY2("$",tempList->word,arr,"\%",scope); } DC(tag,"0"); } } fclose(cFile); #endif if(registerList(tempList->word,tempType,arrayNum,lastLineNumber,POSI_VAR,scope)<0){ errPrint("double variable\n"); } tempList=tempList->next; } clearWordList(); if(evaluateWord(temp[j++])<0){//j=5 errPrint("must be ;\n"); } while(1){ int i=j=6; if(validateTopOfSyntax(temp[i])<0){// if there is no first word, it is correct break; //if nothing, its correct }else{ pPrint(ALLOWINDENT); for(i=j;i<=temp[0];i++){ if((tempType=evaluateWord(temp[i]))<0){// varlist printf("errEI1\n");return -1; } if(i==8){ int arrayNum=0; if(tempType>SARRAY){ arrayNum=tempType-SARRAY; tempType=SARRAY; } int k; for(k=0;k<tempListCount;k++){ #ifdef CSL if((cFile=fopen(cName,"a"))==NULL) exit(-1); if(arrayNum==0){ if(scope==idList.prog->name->name){ TAGCOMB("$",tempList->word); }else{ TAGCOMB2("$",tempList->word,"\%",scope); } DC(tag,"0"); }else{ int arr; for(arr=0;arr<=arrayNum;arr++){ if(scope==idList.prog->name->name){ TAGCOMBARRAY("$",tempList->word,arr); }else{ TAGCOMBARRAY2("$",tempList->word,arr,"\%",scope); } DC(tag,"0"); } } fclose(cFile); #endif if(registerList(tempList->word,tempType,arrayNum,lastLineNumber,POSI_VAR,scope)<0){ errPrint("double variable\n"); } tempList=tempList->next; } clearWordList(); } } } } } /*evaluate SVARLIST*/ else if(scode==SVARLIST){//1:{2} patern
int main(int ac, char *av[]) { char rpath[MAX_NAME_LEN]; int status, *jstatus; simplequeue_t *outputQ, *workQ, *qtoa; // setup the program properties setupProgram(ac, av); // creates a PID file under router_name.pid in the current directory status = makePIDFile(rconfig.router_name, rpath); // shutdown the router on receiving SIGUSR1 or SIGUSR2 redefineSignalHandler(SIGUSR1, shutdownRouter); redefineSignalHandler(SIGUSR2, shutdownRouter); outputQ = createSimpleQueue("outputQueue", INFINITE_Q_SIZE, 0, 1); workQ = createSimpleQueue("work Queue", INFINITE_Q_SIZE, 0, 1); GNETInit(&(rconfig.ghandler), rconfig.config_dir, rconfig.router_name, outputQ); ARPInit(); IPInit(); init_ports(); init_tcp(); /*uint32_t dest_ip = 12319800; uint16_t dest_port = 123; uint16_t src_port = 456; char *data = "Hello"; int len = 6; send_udp(dest_ip,dest_port,src_port,data,len);*/ /* *Test udp_recv * */ /*open_port(1, UDP_PROTOCOL); gpacket_t *packet = (gpacket_t *) malloc(sizeof(gpacket_t)); ip_packet_t *ipPacket = (ip_packet_t *)(packet->data.data); ipPacket->ip_src = {0x1,0x1,0x1,0x1}; ipPacket->ip_dst = {0x2,0x2,0x2,0x2}; ipPacket->ip_cksum = 65535; ipPacket->ip_pkt_len = ipPacket->ip_hdr_len; udphdr_t *udpHeader = (udphdr_t *)((uchar *)ipPacket + ipPacket->ip_hdr_len*4); udpHeader->source = 0; // ports udpHeader->dest = 1; udpHeader->len = 0; // length of data in octets udpHeader->check = 65535; udp_recv(packet); free(packet); free(ipPacket); free(udpHeader);*/ /* * * * End test udp_recv * */ printf("dis router"); classifier = createClassifier(); filter = createFilter(classifier, 0); pcore = createPacketCore(rconfig.router_name, outputQ, workQ); // add a default Queue.. the createClassifier has already added a rule with "default" tag // char *qname, char *dqisc, double qweight, double delay_us, int nslots); addPktCoreQueue(pcore, "default", "taildrop", 1.0, 2.0, 0); rconfig.scheduler = PktCoreSchedulerInit(pcore); rconfig.worker = PktCoreWorkerInit(pcore); infoInit(rconfig.config_dir, rconfig.router_name); addTarget("Output Queue", outputQ); qtoa = getCoreQueue(pcore, "default"); if (qtoa != NULL) addTarget("Default Queue", qtoa); else printf("Error .. found null queue for default\n"); // start the CLI.. CLIInit(&(rconfig)); wait4thread(rconfig.scheduler); wait4thread(rconfig.worker); wait4thread(rconfig.ghandler); }