void Job::_DeletePorts() { PortMap::const_iterator iterator = Ports().begin(); for (; iterator != Ports().end(); iterator++) { port_id port = iterator->second.GetInt32("port", -1); if (port >= 0) delete_port(port); } }
int Interpreteur( char *Buffer, struct Global *g) { char arg0[80],arg1[80],arg2[80],arg3[80],arg4[80] ; int rc ; bzero(arg0,sizeof(arg1)); bzero(arg1,sizeof(arg1)); bzero(arg2,sizeof(arg2)); bzero(arg3,sizeof(arg3)); bzero(arg4,sizeof(arg4)); fprintf(stderr,"Interpreteur ;") ; sscanf(Buffer,"%s %s %s %s %s\n",arg0,arg1,arg2,arg3,arg4) ; fprintf(stderr,"arg0 %s \n",arg0 ) ; /* ATTENTIO? NE PAS OUBLIER ELSE SINON ERREUR DE SYTAXE */ if (strcmp(arg0,"connexion")==0) rc=Connexion(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"ip")==0 &&( strcmp(arg1,"address")==0) ) rc=IpAddress(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"netmask")==0 ) rc = Netmask(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"gateway")==0 ) rc = Gateway(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"dns")==0 ) rc = Dns(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"ports")==0 ) rc = Ports(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"ping")==0 ) rc = Ping(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"send")==0 ) rc = Send(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"bind")==0) rc = Bind(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"nslookup")==0 ) rc= NsLookup(Buffer,arg1,arg2,arg3, arg4,g) ; else if (strcmp(arg0,"waitreceive")==0 ) rc=WaitReceive(g) ; else if (strcmp(arg0,"read")==0) rc = LireMessage( g ) ; else if (strcmp(arg0,"exit")==0) exit(0); else if (strcmp(arg0,"ipconfig")==0) rc = AfficherParametres( g ) ; else if (strcmp(arg0,"help")==0) rc = Help() ; else if (Blanc1013(Buffer)) { fprintf(stderr,"Ligne vide \n" ) ; rc = 1 ; } else rc = 0 ; fprintf(stderr,"fin Interpeteur\n") ; return(rc) ; }
Ports Ports::operator+( Ports pP) { //take union of ports //conditions: ports with the same name must have the same interface //a port can be bound to one edge only. Ports RetVal; //Get the set of ports of the right hand side std::map<std::string,Interface> P = GetValue(); std::map<std::string,Interface>::iterator It; for(It = P.begin(); It != P.end();It++) { //If the right hand side also has the same port width the same interface if ( pP.HasPort(It->first) && It->second == pP[It->first]) { //add the interface to the set of ports to return RetVal.AddPort(It->first,It->second); //Bound the port to the edge (notice that if the two ports //are bound to two different edges, the user is notified but the //port will be bounded to the edge of the right hand side if ( this->IsBound(It->first)) { RetVal.BoundTo(It->first,BoundTo(It->first)); } if ( pP.IsBound(It->first)) { RetVal.BoundTo(It->first,pP.BoundTo(It->first)); } } //if the interafaces are different then return the empty set of ports //this should be fixed by returning the empty interface instead else if ( pP.HasPort(It->first) && It->second != pP[It->first] ) { return Ports(); } //if the right hand side does not have this port //add the port to the return value directly else if ( ! pP.HasPort(It->first) ) { RetVal.AddPort(It->first,It->second); if ( this->IsBound(It->first)) { RetVal.BoundTo(It->first,BoundTo(It->first)); } } } //add all the ports in the right hand side that are not //in the left hand side P = pP.GetValue(); for(It = P.begin(); It != P.end();It++) { if ( ! HasPort(It->first) ) { RetVal.AddPort(It->first,It->second); if ( pP.IsBound(It->first)) { RetVal.BoundTo(It->first,pP.BoundTo(It->first)); } } } return RetVal; }
/*____________________________________________________________________*/ main(void) { print ("\nMidiShare filters tests.\n"); print ("================================\n"); if( MidiShare()) { version= MidiGetVersion(); print ("MidiShare version %d.%d\n\n", (int)version/100, (int)version%100); if( Open()) { Ports(); Canaux(); Events(); Close(); } else print ("Can't open a MidiShare application !\n"); } else print ("MidiShare is not installed !\n"); print ("\nEnd of filters tests.\n"); return 0; }