void AppNodeStar::TemplatePage(Wt::WContainerWidget* pcw, FTemplate f) { std::string sTitle( "NodeStar: Network Infrastructure Data Management" ); setTitle( sTitle ); auto pTitle( new Wt::WText( "NodeStar: Network Infrastructure Data Management" ) ); pTitle->setStyleClass( "MainTitle" ); pcw->addWidget( pTitle ); // should show up to the right of the title if ( this->internalPathMatches( "/auth/signin" ) ) { // don't show sign in status } else { if ( m_pAuth->LoggedIn() ) { //pcw->addWidget( m_pAuth->NewAuthWidget() ); AddLink( pcw, "member", "/auth/signout", "Sign Out" ); AddLink( pcw, "member", "/member/home", "Home" ); } else { AddLink( pcw, "admin", "/auth/signin", "Sign In" ); AddLink( pcw, "default", "/home", "Home" ); } } f( pcw ); }
bool ParmLinkMgr::LinkAllGroup() { Parm* pA = m_WorkingParmLink.GetParmA(); Parm* pB = m_WorkingParmLink.GetParmB(); if ( pA->get_geom_base() == pB->get_geom_base() ) return false; string gnameA = string( pA->get_group_name().get_char_star() ); string gnameB = string( pB->get_group_name().get_char_star() ); vector< Parm* > parmAVec = GetParmVec( pA->get_geom_base(), gnameA ); vector< Parm* > parmBVec = GetParmVec( pB->get_geom_base(), gnameB ); for ( int k = 0 ; k < (int)parmAVec.size() ; k++ ) { for ( int n = 0 ; n < (int)parmBVec.size() ; n++ ) { Parm* parmA = parmAVec[k]; Parm* parmB = parmBVec[n]; if ( parmA->get_name() == parmB->get_name() ) { AddLink( parmA, parmB ); } } } return true; }
void QUserPanel::DropItem(const char* itemname, TClass* cl, int kind) { switch (TabWidget->currentIndex()) { case 0: DragLbl->setText("User dropped item"); DragItemLbl->setText(itemname); DragClassLbl->setText(cl==0 ? "No class specified" : cl->GetName()); DragKindLbl->setText(kindString(kind)); break; case 1: if (cl==0) { PrintLbl->setText("Can not drop item of uncknown class"); } else { PrintLbl->setText(QString("Print item: ") + itemname); RemoveLink("PrintItem"); AddLink(itemname, "PrintItem"); PrintObject(GetLinked("PrintItem", 2)); } break; case 2: DrawObjectOnCanvas(itemname); break; } }
bool LoopModule::ExecCommand(const Command& command, bool wantAnswer) { if(command.GetType() == ctGET) // получить состояние связанного модуля { return AddLink(command,wantAnswer) ? true : false; } // if else if(command.GetType() == ctSET) // установить состояние связанного модуля { return AddLink(command,wantAnswer) ? true : false; } // if return true; }
xmlNodePtr LinkMgrSingleton::DecodeXml( xmlNodePtr & node ) { m_UserParms.DecodeXml( node ); if ( m_UserParms.GetNumUserParms() < m_NumPredefinedUserParms ) { m_UserParms.Renew(m_NumPredefinedUserParms); } xmlNodePtr linkmgr_node = XmlUtil::GetNode( node, "LinkMgr", 0 ); if ( linkmgr_node ) { int num = XmlUtil::GetNumNames( linkmgr_node, "Link" ); for ( int i = 0 ; i < num ; i++ ) { xmlNodePtr link_node = XmlUtil::GetNode( linkmgr_node, "Link", i ); if ( link_node ) { Link* link = new Link(); link->DecodeXml( link_node ); AddLink( link ); } } } return linkmgr_node; }
void CPROC ClientConnected( PCLIENT pListen, PCLIENT pNew ) { printf( "gain client %p\n", pNew ); SetNetworkCloseCallback( pNew, ClientClosed ); SetNetworkReadComplete( pNew, ServerRecieve ); AddLink( &clients, pNew ); }
struct configured_plugin *GetPlugin( CTEXTSTR plugin_mask ) { struct configured_plugin *plugin; INDEX idx; TEXTSTR full_name = StrDup( plugin_mask ); TEXTSTR extra_path = (TEXTSTR)StrChr( plugin_mask, ';' ); if( extra_path ) { extra_path[0] = 0; extra_path++; } LIST_FORALL( l.plugins, idx, struct configured_plugin*, plugin ) { if( StrCaseCmp( plugin->plugin_mask, plugin_mask ) == 0 ) break; } if( !plugin ) { plugin = New( struct configured_plugin ); plugin->plugin_full_name = full_name; plugin->plugin_mask = StrDup( plugin_mask ); plugin->plugin_extra_path = StrDup( extra_path ); plugin->pLoadOn = NULL; plugin->pNoLoadOn = NULL; plugin->pli = NULL; plugin->flags.bDelete = FALSE; plugin->flags.bLoaded = FALSE; plugin->flags.bNoLoad = FALSE; AddLink( &l.plugins, plugin ); }
void loadlinkdb() { char master[NICKLEN+1]; char slave[NICKLEN+1]; MYSQL_RES *result; MYSQL_ROW row; if (!reconnect_to_db()) { fprintf(stderr,"Cannot connect to db\n"); operlog("Cannot connect to db"); return; } mysql_query(&mysql,"SELECT * FROM child_links"); if ((result = mysql_use_result(&mysql)) == NULL) { printf("CRITICAL: Cannot load link table: mysql_use_result returned NULL\n"); return; } while ((row = mysql_fetch_row(result))) { strncpy(master,row[0],NICKLEN); strncpy(slave,row[1],NICKLEN); if (find_link(slave) || find_link2(master,slave)) continue; AddLink(master,slave); if (vv) printf("Link added with master %s and slave %s\n",master,slave); } mysql_close(&mysql); }
static uintptr_t CPROC AddPostInstallCommand( uintptr_t psv, arg_list args ) { PARAM( args, CTEXTSTR, cmd ); PARAM( args, CTEXTSTR, cmd_args ); struct command *command = New( struct command ); command->cmd = StrDup( cmd ); command->args = StrDup( cmd_args ); AddLink( &l.commands, command ); return psv; }
static int OnCreateCommon( MyName )( PSI_CONTROL pc ) { MyValidatedControlData( struct media_control_panel*, media, pc ); if( media ) { media->panel = pc; media->media = NULL; AddLink( &l.controls, media ); } return 1; }
void QUserPanel::DrawObjectOnCanvas(const char* itemname) { RemoveLink("DrawItem"); AddLink(itemname, "DrawItem"); TObject* obj = GetLinked("DrawItem", 2); if (obj!=0) { fxDrawCanvas->getCanvas()->Clear(); fxDrawCanvas->getCanvas()->cd(); obj->Draw(""); fxDrawCanvas->getCanvas()->Update(); } }
static void AliasHandleFtpIn(struct libalias *la, struct ip *pip, /* IP packet to examine/patch */ struct alias_link *lnk) /* The link to go through (aliased port) */ { int hlen, tlen, dlen, pflags; char *sptr; struct tcphdr *tc; /* Calculate data length of TCP packet */ tc = (struct tcphdr *)ip_next(pip); hlen = (pip->ip_hl + tc->th_off) << 2; tlen = ntohs(pip->ip_len); dlen = tlen - hlen; /* Place string pointer and beginning of data */ sptr = (char *)pip; sptr += hlen; /* * Check that data length is not too long and previous message was * properly terminated with CRLF. */ pflags = GetProtocolFlags(lnk); if (dlen <= MAX_MESSAGE_SIZE && (pflags & WAIT_CRLF) == 0 && ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER && (ParseFtpPortCommand(la, sptr, dlen) != 0 || ParseFtpEprtCommand(la, sptr, dlen) != 0)) { /* * Alias active mode client requesting data from server * behind NAT. We need to alias server->client connection * to external address client is connecting to. */ AddLink(la, GetOriginalAddress(lnk), la->true_addr, GetAliasAddress(lnk), htons(FTP_CONTROL_PORT_NUMBER - 1), htons(la->true_port), GET_ALIAS_PORT, IPPROTO_TCP); } /* Track the msgs which are CRLF term'd for PORT/PASV FW breach */ if (dlen) { sptr = (char *)pip; /* start over at beginning */ tlen = ntohs(pip->ip_len); /* recalc tlen, pkt may * have grown. */ if (sptr[tlen - 2] == '\r' && sptr[tlen - 1] == '\n') pflags &= ~WAIT_CRLF; else pflags |= WAIT_CRLF; SetProtocolFlags(lnk, pflags); } }
void SerializeCeosRecordsFromFile(Link_t *record_list, VSILFILE *fp) { CeosRecord_t *crec; Link_t *Link; while(!VSIFEofL(fp)) { crec = HMalloc(sizeof(CeosRecord_t)); VSIFReadL(crec,sizeof(CeosRecord_t),1,fp); crec->Buffer = HMalloc(crec->Length * sizeof(char) ); VSIFReadL(crec->Buffer,sizeof(char),crec->Length,fp); Link = ceos2CreateLink(crec); AddLink(record_list,Link); } }
//_____________________________________________________________________________ Bool_t KVDBKey::LinkTo(KVDBRecord* rec, Bool_t linkback) { // This function adds a record to the list of cross-references // if fIsUnique is kTRUE we check if there is already an object with the same name: // if so we return kFALSE otherwise the record is added and kTRUE is returned. // if fSingle is kTRUE the list can handle only one object: // if the list is empty the record is added and kTRUE is returned, otherwise kFALSE. // check if more than one object is allowed if (fSingle && (GetLinks()->GetSize() > 0) && (GetLinks()->First())) { Warning("LinkTo(KVDBRecord*)", "%s : Only one cross-reference allowed.\nCurrent cross-reference is:%s\nCan't add new record \"%s\" in list", GetName(), GetLinks()->First()->GetName(), rec->GetName()); return kFALSE; } // check if identical names are allowed if (fIsUnique) { if (fLinks->FindObject(rec->GetName())) { Warning("LinkTo(KVDBRecord*)", "%s : Cross-references must have different names.\nA record named %s already exists.\nCan't add new record \"%s\" in list", GetName(), rec->GetName(), rec->GetName()); return kFALSE; } } AddLink(rec); if (linkback) { //if linkback is kTRUE then a mirror link to this record will be made in record "rec" //if a key with the same name as the table containing the current record is found //in the record to link , then this key is linked back to the current record. //if no key is found, one will be created, and then the linkback performed. //check parent is set if (!GetParent()) { Error("LinkTo", "Parent table not set for key %s", GetName()); return kFALSE; } const Char_t* table_name = GetParent()->GetTable()->GetName(); KVDBKey* key = rec->GetKey(table_name); if (!key) key = rec->AddKey(table_name, GetParent()->GetName()); key->LinkTo(GetParent(), kFALSE); //linkback=kFALSE otherwise infinite circular linkage results !!! } return kTRUE; }
void CISO8583FEApp::OnTpmConfiguredLink(CMultiXTpmConfiguredLink &Link) { if(Link.OpenMode == MultiXOpenModeServer) { CISO8583FEServerLink *pLink = new CISO8583FEServerLink(Link.ConfigParams); AddLink(pLink); if(!pLink->Listen(Link.LocalPort)) { Logger()->ReportError(DebugPrint(0,"Listen Failed on Ip=%s , Port=%s\n",Link.LocalAddress.c_str(),Link.LocalPort.c_str())); } else { DebugPrint(1,"Started Listenning on Ip=%s , Port=%s\n",pLink->LocalName().c_str(),pLink->LocalPort().c_str()); } } CMultiXApp::OnTpmConfiguredLink(Link); }
struct video_sequence *GetSequenceEx( int ID, LOGICAL bCreate ) #define GetSequence(ID) GetSequenceEx( ID, TRUE ) { struct video_sequence *seq; INDEX idx; LIST_FORALL( g.playlists, idx, struct video_sequence *, seq ) { if( seq->sequence == ID ) return seq; } if( bCreate ) { seq = New( struct video_sequence ); MemSet( seq, 0, sizeof( struct video_sequence ) ); seq->sequence = ID; AddLink( &g.playlists, seq ); } else
//==== Link All Parms In A Container (Component) ====// bool LinkMgrSingleton::LinkAllComp() { Parm* pA = ParmMgr.FindParm( m_WorkingLink->GetParmA() ); Parm* pB = ParmMgr.FindParm( m_WorkingLink->GetParmB() ); ParmContainer* pcA = pA->GetLinkContainer(); ParmContainer* pcB = pB->GetLinkContainer(); if ( !pcA || !pcB ) { return false; } if ( pcA == pcB ) { return false; } vector< string > parmAVec, parmBVec; pcA->AddLinkableParms( parmAVec, pcA->GetID() ); pcB->AddLinkableParms( parmBVec, pcB->GetID() ); for ( int k = 0 ; k < ( int )parmAVec.size() ; k++ ) { for ( int n = 0 ; n < ( int )parmBVec.size() ; n++ ) { Parm* parmA = ParmMgr.FindParm( parmAVec[k] ); Parm* parmB = ParmMgr.FindParm( parmBVec[n] ); if ( parmA && parmB ) { if ( parmA->GetName() == parmB->GetName() && parmA->GetDisplayGroupName() == parmB->GetDisplayGroupName() ) { AddLink( parmAVec[k], parmBVec[n] ); } } } } return true; }
void TGo4TreeViewer::ProcessDropEvent(QGo4LineEdit* edt, bool caninit) { QString value = edt->text(); TGo4BrowserProxy* br = Browser(); if (br==0) return; if (fxTreeName.length()==0) { if (!caninit) { StatusMessage("First drop something on X, Y or Z field"); edt->setText(""); return; } TString treename; if (!br->DefineTreeName(value.toLatin1().constData(), treename)) { StatusMessage(QString("Invalid tree ") + value); edt->setText(""); return; } fxTreeName = treename.Data(); setToolTip(QString("Selected tree: ") + fxTreeName); TreeDrawBtn->setEnabled(true); AddLink(treename.Data(), "Tree"); } TString leafname; if (!br->DefineLeafName(value.toLatin1().constData(), fxTreeName.toLatin1().constData(), leafname)) { edt->setText(""); StatusMessage(QString("Invalid leaf name ") + value); return; } // count number of [ and replace by [] // this means, by default accumulate over all members TObjArray* it=leafname.Tokenize("["); leafname=((TObjString *)it->First())->GetName(); for(Int_t i=1;i<it->GetEntriesFast();i++) leafname.Append("[]"); edt->setText(leafname.Data()); edt->setFocus(); it->Delete(); }
xmlNodePtr AdvLinkMgrSingleton::DecodeXml( xmlNodePtr & node ) { xmlNodePtr linkmgr_node = XmlUtil::GetNode( node, "AdvLinkMgr", 0 ); if ( linkmgr_node ) { int num = XmlUtil::GetNumNames( linkmgr_node, "AdvLink" ); for ( int i = 0 ; i < num ; i++ ) { xmlNodePtr link_node = XmlUtil::GetNode( linkmgr_node, "AdvLink", i ); if ( link_node ) { AdvLink* link = AddLink( "" ); link->DecodeXml( link_node ); link->BuildScript(); } } } return linkmgr_node; }
bool ParmLinkMgr::LinkAllComp() { Parm* pA = m_WorkingParmLink.GetParmA(); Parm* pB = m_WorkingParmLink.GetParmB(); if ( pA->get_geom_base() == pB->get_geom_base() ) return false; //==== For All Parms in GeomA, Try to Find Match in GeomB and Link ====// vector< string > groupAVec = GetGroupNameVec( pA->get_geom_base() ); vector< string > groupBVec = GetGroupNameVec( pB->get_geom_base() ); for ( int i = 0 ; i < (int)groupAVec.size() ; i++ ) { for ( int j = 0 ; j < (int)groupBVec.size() ; j++ ) { if ( groupAVec[i].compare( groupBVec[j] ) == 0 ) { vector< Parm* > parmAVec = GetParmVec( pA->get_geom_base(), groupAVec[i] ); vector< Parm* > parmBVec = GetParmVec( pB->get_geom_base(), groupBVec[j] ); for ( int k = 0 ; k < (int)parmAVec.size() ; k++ ) { for ( int n = 0 ; n < (int)parmBVec.size() ; n++ ) { Parm* parmA = parmAVec[k]; Parm* parmB = parmBVec[n]; if ( parmA->get_name() == parmB->get_name() ) { AddLink( parmA, parmB ); } } } } } } return true; }
//==== Add Curr Link ====// bool LinkMgrSingleton::AddCurrLink() { //==== Check if Modifying Already Add Link ====// if ( m_CurrLinkIndex >= 0 && m_CurrLinkIndex < ( int )m_LinkVec.size() ) { return false; } if ( m_WorkingLink->GetParmA() == m_WorkingLink->GetParmB() ) { return false; } if ( CheckForDuplicateLink( m_WorkingLink->GetParmA(), m_WorkingLink->GetParmB() ) ) { return false; } AddLink( m_WorkingLink->GetParmA(), m_WorkingLink->GetParmB() ); return true; }
//==== Link All Parms In A Group ====// bool LinkMgrSingleton::LinkAllGroup() { Parm* pA = ParmMgr.FindParm( m_WorkingLink->GetParmA() ); Parm* pB = ParmMgr.FindParm( m_WorkingLink->GetParmB() ); if ( !pA || !pB ) { return false; } string gnameA = pA->GetDisplayGroupName(); string gnameB = pB->GetDisplayGroupName(); if ( ( pA->GetLinkContainer() == pB->GetLinkContainer() ) && ( gnameA == gnameB ) ) { return false; } vector< string > parmAVec, parmBVec; pA->GetLinkContainer()->GetParmIDs( pA->GetID(), parmAVec ); pB->GetLinkContainer()->GetParmIDs( pB->GetID(), parmBVec ); for ( int k = 0 ; k < ( int )parmAVec.size() ; k++ ) { for ( int n = 0 ; n < ( int )parmBVec.size() ; n++ ) { Parm* parmA = ParmMgr.FindParm( parmAVec[k] ); Parm* parmB = ParmMgr.FindParm( parmBVec[n] ); if ( parmA && parmB && ( parmA->GetName() == parmB->GetName() ) ) { AddLink( parmAVec[k], parmBVec[n] ); } } } return true; }
void XMLCALL start_tags( void *UserData , const XML_Char *name , const XML_Char **atts ) { struct xml_userdata *userdata = (struct xml_userdata *)UserData; TEXTSTR p[2]; p[0] = NULL; p[1] = NULL; //lprintf( WIDE("begin a tag %s with..."), name ); if( StrCmp( name, "player" ) == 0 ) { LOGICAL make_new; make_new = TRUE; if( userdata->loading ) { if( StrCmp( userdata->loading->prizeNum, "1000000" ) == 0 ) { if( ffl.million_claimed ) { Release( userdata->loading->cardNum ); Release( userdata->loading->playerName ); Release( userdata->loading->prizeDesc ); Release( userdata->loading->prizeNum ); Release( userdata->loading->timestamp ); MemSet( userdata->loading, 0, sizeof( struct loaded_player ) ); make_new = FALSE; } } } // don't store internally the million dollar player.... // otherwise he will get written back out if( make_new ) { struct loaded_player *load = New( struct loaded_player ); AddLink( &ffl.xml_players, load ); MemSet( load, NULL, sizeof( struct loaded_player ) ); userdata->loading = load; } }
void LAYER::Link( PLAYER via, int link_type, int32_t x, int32_t y ) { // links via to this // or links via from this AddLink( &linked, via ); switch( link_type ) { case LINK_VIA_START: via->route_start_layer.layer = this; via->route_start_layer.x = x; via->route_start_layer.y = y; break; case LINK_VIA_END: via->flags.bEnded = TRUE; via->route_end_layer.layer = this; via->route_end_layer.x = x; via->route_end_layer.y = y; break; } // and we need to consider how to recover the linked // state of the actual peices that are linked. }
void AppNodeStar::ShowMainMenu( Wt::WContainerWidget* pcw ) { // still need to show the widget, and there needs to be a click event so when // logged in we can refresh // so devote a page to the login, clean out main menu, // but still need an event on when logged in is successful // because nothing else happens on the page if ( m_pAuth->LoggedIn() ) { AddLink( pcw, "member", "/show/addresses", "Address List" ); AddLink( pcw, "member", "/admin/tables/upload", "Upload" ); // <a id="ov7qcp1" // href="admin/tables/populate/mysql?wtd=jLpA57e4vgIIoYxI" // class="Wt-rr"><span id="ov7qcp0">Populate Tables: MySQL sourced</span> // </a> auto pMenu = new Wt::WContainerWidget( pcw ); // test against database, and figure out which can be shown, particularily the tables/init one pMenu->setList(true); // ==> sub WContainerWidget added as <li> elements AddLink( pMenu, "admin", "/admin/tables/init", "Init Tables" ); AddLink( pMenu, "admin", "/admin/tables/populate/basics", "Populate Tables: Basics" ); // use the Upload class to do this one: AddLink( pMenu, "admin", "/ad min/tables/populate/mysql", "Populate Tables: MySQL sourced" ); // use the Upload class to do this one: AddLink( pMenu, "admin", "/admin/tables/populate/smcxml", "Populate Tables: SMC XML sourced" ); } else { } // sample button code, but now implemented as a link //Wt::WPushButton* pBtn = new Wt::WPushButton( "Show Addresses" ); //pBtn->clicked().connect(this, &AppNodeStar::HandleShowAddresses ); //pcw->addWidget( pBtn ); }
void CEntityMng::Initialize( float visibleDist ) { worldentity_t *entity; int i; m_frameFlag = 0; m_visibleDist = visibleDist; m_MDLMng->ClearWorldUseFlag(); m_linked = NULL; m_currCameraPathEntity = NULL; m_currPathEntity = NULL; m_numActivator = 0; entity = &m_entities[0]; for( i = 0 ; i < m_numEntities ; i++ , entity++ ) { entity->linkedCluster = m_world->FindCluster( entity->origin ); if( entity->linkedCluster < 0 ) { entity->inuse = false; continue; } entity->targetEntity = SearchTarget( entity->target ); if( entity->targetEntity ) entity->targetEntity->prevEntity = entity; entity->inuse = false; switch( entity->classType ) { case GTH_WORLD_ENTITY_TYPE_PLAYER_POS : break; case GTH_WORLD_ENTITY_TYPE_MODEL : entity->idxMDLEntity = m_MDLMng->AddWorldEntity( entity->itemName , entity->origin , entity->angles ); if( entity->idxMDLEntity < 0 ) break; if( !m_MDLMng->GetMDLWorldClassBoundBox( entity->idxMDLEntity , entity->mins , entity->maxs ) ) { VectorClear( entity->mins ); VectorClear( entity->maxs ); } entity->radius = CalculateRadius( entity->mins , entity->maxs ); AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_TELEPORT : if( !entity->target ) break; entity->idxMDLEntity = m_MDLMng->AddWorldEntity( entity->itemName , entity->origin , entity->angles ); if( entity->idxMDLEntity < 0 ) break; if( !m_MDLMng->GetMDLWorldClassBoundBox( entity->idxMDLEntity , entity->mins , entity->maxs ) ) { VectorClear( entity->mins ); VectorClear( entity->maxs ); } AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_ACTIVATOR : if( !entity->targetEntity ) break; AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_DEACTIVATOR : if( !entity->targetEntity ) break; AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_DOOR : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_PATH : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = false; break; case GTH_WORLD_ENTITY_TYPE_CAMERA_PATH : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = false; break; case GTH_WORLD_ENTITY_TYPE_SOUND : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = true; break; default: break; } } }
// read HTK subnet definition and create corresponding subnet GramSubN::GramSubN(Source *src) { char nbuf[132],vbuf[132],buf[32],*ptr,ntype,del; int i,n,st,en,nl=0, nn=0; float prob; Boolean isOk = TRUE; try{ name = "!!MAIN!!"; // if sublat it will be overwritten with HTK name entry = NULL; exit = NULL; refcount = 0; // read the header info while((ptr=GetNextFieldName(nbuf,&del,src))) { if (nbuf[0]=='\n') { if (nl != 0 && nn != 0) break; } else if (strlen(ptr)==1) { ntype=*ptr; switch(ntype) { case 'N': nn=GetIntField('N',del,vbuf,src); break; case 'L': nl=GetIntField('L',del,vbuf,src); break; default: GetFieldValue(0,src); break; } } else { if (strcmp(ptr,"SUBLAT") == 0) GetFieldValue(vbuf,src),name=vbuf; else GetFieldValue(NULL,src); } } if (feof(src->f)) return; // No main network // read the node and link defs vector<GramNode *> nodemap(nn); string nodename,tag; NodeKind kind; for (i=0; i<nn; i++) nodemap[i] = NULL; do { if ((ptr=GetNextFieldName(nbuf,&del,src)) == NULL) break; /* Recognised line types have only one character names */ if (strlen(ptr)==1) ntype=*ptr; else ntype=0; if (ntype == '.') { ptr = NULL; break; } switch(ntype) { case '\n': break; case 'I': n=GetIntField('I',del,vbuf,src); if (n < 0 || n >= nn){ HRError(10723,"AGram: node %d is missing",n); throw ATK_Error(10723); } if (nodemap[n] != NULL){ HRError(10724,"AGram: multiple defs for node %d",n); throw ATK_Error(10724); } nodename=""; tag=""; kind = UnknNode; while((ptr=GetNextFieldName(nbuf,&del,src)) != NULL) { if (nbuf[0]=='\n') break; else { if (strlen(ptr)>=1) ntype=*ptr; else ntype=0; switch(ntype) { case 'W': GetFieldValue(vbuf,src); if (strcmp(vbuf,"!NULL")==0) kind = NullNode; else { nodename = vbuf; kind = WordNode; } break; case 's': GetFieldValue(vbuf,src); tag = vbuf; break; case 'L': GetFieldValue(vbuf,src); nodename = vbuf; kind = CallNode; break; default: GetFieldValue(0,src); break; } } } if (kind == UnknNode){ HRError(10725,"AGram: node %d not fully defined",n); throw ATK_Error(10725); } if (kind==NullNode) {sprintf(buf,"%d",n); nodename=buf;} nodemap[n] = new GramNode(kind,nodename,tag); nodes.push_back(nodemap[n]); break; case 'J': n=GetIntField('I',del,vbuf,src); if (n<0 || n>=nl){ HRError(10726,"AGram: link %d is not possible",n); throw ATK_Error(10726); } st = en = -1; prob=0.0; while ((ptr=GetNextFieldName(nbuf,&del,src))) { if (nbuf[0]=='\n') break; else { if (strlen(ptr)>=1) ntype=*ptr; else ntype=0; switch(ntype) { case 'S': st=GetIntField('S',del,vbuf,src); if (st<0 || st>=nn){ HRError(10727,"AGram: start node %d out of range",st); throw ATK_Error(10727); } break; case 'E': en=GetIntField('E',del,vbuf,src); if (en<0 || en>=nn){ HRError(10727,"AGram: end node %d out of range",en); throw ATK_Error(10727); } break; case 'l': prob=float(GetFltField('l',del,vbuf,src)); break; default: GetFieldValue(0,src); break; } } } if (st<0 || en <0){ HRError(10728,"AGram: incomplete link spec (%d to %d)",st,en); throw ATK_Error(10728); } if (nodemap[st]==NULL){ HRError(10729,"AGram: start node %d undefined",st); throw ATK_Error(10729); } if (nodemap[en]==NULL){ HRError(10729,"AGram: end node %d undefined",en); throw ATK_Error(10729); } AddLink(nodemap[st],nodemap[en],prob); break; default: GetFieldValue(0,src); while ((ptr=GetNextFieldName(nbuf,&del,src))) { if (nbuf[0]=='\n') break; else GetFieldValue(0,src); } break; } }while(ptr != NULL); // set end points SetEnds(); // finally check that all is well n = IsBroken(TRUE); if (n != 0){ switch(n){ case 1: HRError(10729,"AGram: entry/exit node missing"); break; case 2: HRError(10729,"AGram: entry node has predecessors"); break; case 3: HRError(10729,"AGram: exit node has successors"); break; case 4: HRError(10729,"AGram: no path from entry to exit"); break; case 5: HRError(10729,"AGram: unreachable nodes"); break; } throw ATK_Error(10729); } } catch (ATK_Error e){ HRError(e.i,"AGram: error detected in subnet %s",name.c_str()); throw e; } }
void TGo4LogInfo::WorkWithInfo(TGo4Slot* slot) { ResetWidget(); AddLink(slot, "Loginfo"); }
void WP_command( int argc ) { char cmd_command[1024]; if( argc < 3) return; trap_CmdArgv( 2, cmd_command, sizeof( cmd_command ) ); if(!strcmp(cmd_command, "add")) { waypoint_t wp; if( argc < 7 ) return; memset(&wp, 0 ,sizeof(wp)); trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) ); wp.index = atoi( cmd_command ); trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) ); wp.origin[0] = atof( cmd_command ); trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) ); wp.origin[1] = atof( cmd_command ); trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) ); wp.origin[2] = atof( cmd_command ); wp.teams = 15 ;// (1<<0)+(1<<1)+(1<<2)+(1<<3); if( argc > 7 ) { trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) ); wp.flags = atoi( cmd_command ); } if( argc > 8 ) { trap_CmdArgv( 8, cmd_command, sizeof( cmd_command ) ); wp.teams = atoi( cmd_command ); } if( argc > 9 ) { trap_CmdArgv( 9, cmd_command, sizeof( cmd_command ) ); wp.radius = atof( cmd_command ); } AddWaypoint(&wp); return; } if(!strcmp(cmd_command, "link")) { wp_link_t link; int i1,i2; if( argc < 5 ) return; memset(&link, 0 ,sizeof(link)); trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) ); i1 = atoi( cmd_command ); trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) ); i2 = atoi( cmd_command ); link.teams = 15; if( argc > 5 ) { trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) ); link.flags = atoi( cmd_command ); } if( argc > 6 ) { trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) ); link.teams = atoi( cmd_command ); } if( argc > 7 ) { trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) ); link.req_velocity = atof( cmd_command ); } AddLink( i1, i2, &link); return; } if(!strcmp(cmd_command, "dlink")) { wp_link_t link; int i1,i2; if( argc < 5 ) return; memset(&link, 0 ,sizeof(link)); trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) ); i1 = atoi( cmd_command ); trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) ); i2 = atoi( cmd_command ); link.teams = 15; if( argc > 5 ) { trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) ); link.flags = atoi( cmd_command ); } if( argc > 6 ) { trap_CmdArgv( 6, cmd_command, sizeof( cmd_command ) ); link.teams = atoi( cmd_command ); } if( argc > 7 ) { trap_CmdArgv( 7, cmd_command, sizeof( cmd_command ) ); link.req_velocity = atof( cmd_command ); } AddLink( i1, i2, &link); AddLink( i2, i1, &link); return; } if(!strcmp(cmd_command, "target")) { if( argc < 6 ) return; trap_CmdArgv( 3, cmd_command, sizeof( cmd_command ) ); end_pos[0] = atof( cmd_command ); trap_CmdArgv( 4, cmd_command, sizeof( cmd_command ) ); end_pos[1] = atof( cmd_command ); trap_CmdArgv( 5, cmd_command, sizeof( cmd_command ) ); end_pos[2] = atof( cmd_command ); return; } if(!strcmp(cmd_command, "draw")) { DrawWPS(); return; } if(!strcmp(cmd_command, "clear")) { ClearWaypoints(); return; } }
void HTMLPage::slotFinished() { QByteArray ba = reply->readAll(); reply->close(); loaded = true; QString htmlstr(ba); QString titleTag("<title>"); title = HTMLExtract(titleTag, htmlstr); QString s(ba); QStringList sl = s.split("<"); //qDebug() << sl; datas.clear(); url_str = url.toString(); url_prefix = url_str.left(url_str.lastIndexOf("/")); numimages = 0; numlinks = 0; numtexts = 0; for (int i=0; i<sl.size(); ++i) { if (sl[i].contains("img ", Qt::CaseInsensitive) && sl[i].contains("src", Qt::CaseInsensitive)) { QStringList sl2 = sl[i].split("\""); for (int j=0; j<sl2.size()-1; ++j) { if (sl2[j].contains("src", Qt::CaseInsensitive) && sl2[j].contains("=", Qt::CaseInsensitive)) { ++j; AddImage(sl2[j]); } } } else if ((sl[i].contains("a ", Qt::CaseInsensitive) && sl[i].contains("href", Qt::CaseInsensitive)) || (sl[i].contains("meta ", Qt::CaseInsensitive) && sl[i].contains("url", Qt::CaseInsensitive))) { QStringList sl2 = sl[i].split("\""); for (int j=0; j<sl2.size()-1; ++j) { if (sl2[j].contains("href", Qt::CaseInsensitive) && sl2[j].contains("=", Qt::CaseInsensitive)) { ++j; if (sl2[j].right(5).contains(".") && !sl2[j].right(4).contains("htm")) { continue; } AddLink(sl2[j]); } else if (sl2[j].contains("data-href", Qt::CaseInsensitive) && sl2[j].contains("=", Qt::CaseInsensitive)) { ++j; AddLink(sl2[j]); } } } else if (sl[i].contains("div ", Qt::CaseInsensitive)) { //get this case working: //<div title="Google" align="left" id="hplogo" onload="window.lol&&lol()" style="background:url(/images/srpr/logo11w.png) no-repeat;background-size:269px 95px;height:95px;width:269px"><div nowrap="" style="color:#777;font-size:16px;font-weight:bold;position:relative;left:218px;top:70px">Canada</div></div> HTMLData newdata; newdata.type = DIV; newdata.data = sl[i]; datas.push_back(newdata); //QStringList sl2 = sl[i].split("\""); QStringList sl2 = GetStringsBetween("\"", "\"", sl[i]); for (int j=0; j<sl2.size(); ++j) { QStringList sl3 = GetStringsBetween("(", ")", sl2[j]); for (int k=0; k<sl3.size(); ++k) { QString extension = sl3[k].right(4); if (extension.compare(".png", Qt::CaseInsensitive) == 0 || extension.compare(".jpg", Qt::CaseInsensitive) == 0|| extension.compare(".gif", Qt::CaseInsensitive) == 0) { AddImage(sl3[k]); } } } } //extract any other text QString textpiece = sl[i].mid(sl[i].indexOf(">") + 1); textpiece = textpiece.trimmed(); if (textpiece.length() > 0) { HTMLData newdata; newdata.type = TEXT; newdata.data = textpiece; datas.push_back(newdata); ++numtexts; } } qDebug() << title << numimages << "images," << numlinks << "links," << numtexts << " texts."; }