int main(){ //Open logging file. Global_Logging_File.open("Output.txt"); //The list of rules. std::vector<Rule> RuleList; //Add the rules. Rule New1("S->abS"); Rule New2("S->bcS"); Rule New3("S->bbS"); Rule New4("S->a"); Rule New5("S->cb"); RuleList.push_back(New1); RuleList.push_back(New2); RuleList.push_back(New3); RuleList.push_back(New4); RuleList.push_back(New5); Combined Ghosts("S"); //Create a instance of the trace class. //Process the rule list. Ghosts.Process(RuleList, 0); //Close logging file. Global_Logging_File.close(); return 0; }
static CJcSymbolItem* RebuildSymbolTable(CJcSymbolStack* pStack, CJcSegment* pSegment, jc_uint* pLen) { jc_uint i, nLen = 0, nTotal = pStack->oProtoTypeTable.nCount; CJcSymbolItem* pTab = NULL; if(nTotal) { CJcProtoType* pProto = pStack->oProtoTypeTable.pProtoTypeTable; pTab = New2(CJcSymbolItem, nTotal); for(i=0; i<nTotal; ++i,++pProto) { CJcSymbolItem* pSym = pTab + nLen; pProto->nNewIdx = (jc_uint)(-1); if(pProto->oSymbol.nStorage == JC_STATIC) continue; if(!pProto->nUsed) { if(pProto->oSymbol.nSymbol == JC_FUNCTION_SYMBOL) { if(pProto->oSymbol.info.pFunction->nOpt != JC_CS) continue; } else { if(pProto->oSymbol.info.pVariable->nOpt != JC_DS) continue; } } pSym->name = PutInSegment(pSegment, pProto->oName.pStr, pProto->oName.nLen+1, 1); if(pProto->oSymbol.nSymbol == JC_FUNCTION_SYMBOL) { pSym->type = JC_FUNCTION_SYM; pSym->opt = pProto->oSymbol.info.pFunction->nOpt; pSym->arg = pProto->oSymbol.info.pFunction->nArg; } else { pSym->type = JC_VARIABLE_SYM; pSym->opt = pProto->oSymbol.info.pVariable->nOpt; pSym->arg = pProto->oSymbol.info.pVariable->nArg; } if(pProto->oSymbol.nStorage & JC_SHARE) pSym->type |= JC_SHARE_SYM; pProto->nNewIdx = nLen++; } if(!nLen) { g_oInterface.Free(pTab); pTab = NULL; } } *pLen = nLen; return pTab; }
LPIDENT SERVER::GetIdentifier (void) { if (m_lpiThis == NULL) { if ((m_lpiThis = IDENT::FindIdent (this)) == NULL) m_lpiThis = New2 (IDENT,(this)); m_lpiThis->m_cRef ++; } return m_lpiThis; }
void AfsAdmSvr_Startup (void) { l.pNotify = New2 (NOTIFYCALLBACK,(AfsAdmSvr_NotifyCallback, 0)); l.fOperational = FALSE; ULONG status; if (AfsClass_Initialize (&status)) l.fOperational = TRUE; else { Print (dlERROR, TEXT("Could not initialize AfsClass (fatal error 0x%08lX)"), status); Print (dlERROR, TEXT("Remaining active to tell potential clients about the problem")); } if (!l.hThreadShutdown) { DWORD dwThreadID; l.hThreadShutdown = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)AfsAdmSvr_AutoShutdownThread, (LPVOID)0, 0, &dwThreadID); } }
/* * EXPORTED FUNCTIONS _________________________________________________________________ * */ int GetCurrentConfig(HWND hParent, BOOL& bCanceled) { pProg = 0; bCancel = FALSE; bBakConfigured = FALSE; pProg = New2 (PROGRESSDISPLAY,(hParent, IDD_GET_CURRENT_CONFIG, (DLGPROC)GetCurConfigDlgProc)); pProg->SetProgressRange(0, MAX_STEPS); HWND hLogo = GetDlgItem(pProg->GetWindow(), IDC_LOGO); AfsAppLib_StartAnimation(hLogo); pProg->Show(GetCurrentConfigState, 0); AfsAppLib_StopAnimation(hLogo); int dwResult = pProg->GetStatus(); pProg->Close(); bCanceled = bCancel; return dwResult; }
LPIDENT FILESET::GetIdentifier (void) { if (m_lpiThis == NULL) { TCHAR szCell[ cchNAME ]; TCHAR szServer[ cchNAME ]; TCHAR szAggregate[ cchNAME ]; m_lpiAggregate->GetCellName (szCell); m_lpiAggregate->GetLongServerName (szServer); m_lpiAggregate->GetAggregateName (szAggregate); // Finding the identifier for a fileset is a little tricky, because // (a) a fileset identifier's unique "key" includes the fileset's // aggregate, and (b) filesets can move around in the cell. // // We'll search through our list of IDENTs and see if we can find // an old IDENT object that refers to this fileset; if we can't find // one, we'll create a new one. To make sure we have an accurate match, // we'll require that the IDENT we find match all of the following // criteria: // 1- The identifier must point to a fileset // 2- The identifier must have the same fileset ID as this FILESET // 3- The identifier's cRef must be zero (i.e., there should // not be another FILESET object out there which thinks *it* // uses that IDENT) // 4- The identifier must (obviously) point to the cell in which // this FILESET object resides // 5- If this is a fileset replica, the IDENT must be on the same // aggregate as this fileset // // Note that the IDENT class maintains its list of IDENTs in a // HASHLIST that a key placed on volume IDs. We'll use that key // to speed up our search enormously. // BOOL fRequireSameAggregate = ProbablyReplica(); for (LPENUM pEnum = IDENT::x_lkFilesetID->FindFirst (&m_idVolume); pEnum; pEnum = pEnum->FindNext()) { // Only volumes which match this fileset ID will get here. // LPIDENT lpiFind = (LPIDENT)( pEnum->GetObject() ); if (lpiFind->m_iType != itFILESET) continue; if (lpiFind->m_cRef != 0) continue; if (lstrcmpi (szCell, lpiFind->m_szCell)) continue; if (fRequireSameAggregate) { if (lstrcmpi (szServer, lpiFind->m_szServer)) continue; if (lstrcmpi (szAggregate, lpiFind->m_szAggregate)) continue; } // Found a match! Update the IDENT's name and location, // to ensure it jives with reality... for instance, if // a fileset has been moved, we'll need to fix the // server and aggregate names. Since this affects one // of the keys in the IDENT class's hashlist, update that list. // Delete (pEnum); m_lpiThis = lpiFind; lstrcpy (m_lpiThis->m_szServer, szServer); lstrcpy (m_lpiThis->m_szAggregate, szAggregate); lstrcpy (m_lpiThis->m_szFileset, m_szName); m_lpiThis->Update(); break; } if (m_lpiThis == NULL) m_lpiThis = New2 (IDENT,(this)); // Create a new IDENT if necessary. m_lpiThis->m_cRef ++; } return m_lpiThis; }
void CreateNotificationDispatch (void) { InitializeCriticalSection (&csDispatch); Handler = New2 (NOTIFYCALLBACK,((NOTIFYCALLBACKPROC)DispatchNotification, 0L)); }
BOOL SERVER::RefreshServices (BOOL fNotify, ULONG *pStatus) { BOOL rc = TRUE; DWORD status = 0; if (m_fServicesOutOfDate) { m_fServicesOutOfDate = FALSE; if (fIsMonitored()) { if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshServicesBegin, GetIdentifier()); // First thing is to forget about what services we think we have now. // LPENUM pEnum; for (pEnum = m_lServices->FindLast(); pEnum; pEnum = pEnum->FindPrevious()) { LPSERVICE lpService = (LPSERVICE)(pEnum->GetObject()); lpService->SendDeleteNotifications(); m_lServices->Remove (lpService); Delete (lpService); } // Next, the harder part: look through the server to find a list // of services. // PVOID hCell; PVOID hBOS; if ((hBOS = OpenBosObject (&hCell, &status)) == NULL) rc = FALSE; else { WORKERPACKET wpBegin; wpBegin.wpBosProcessNameGetBegin.hServer = hBOS; if (!Worker_DoTask (wtaskBosProcessNameGetBegin, &wpBegin, &status)) rc = FALSE; else { LPSERVICE lpService = New2 (SERVICE,(this, TEXT("BOS"))); m_lServices->Add (lpService); NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpService->GetIdentifier()); for (;;) { TCHAR szServiceName[ cchNAME ]; WORKERPACKET wpNext; wpNext.wpBosProcessNameGetNext.hEnum = wpBegin.wpBosProcessNameGetBegin.hEnum; wpNext.wpBosProcessNameGetNext.pszService = szServiceName; if (!Worker_DoTask (wtaskBosProcessNameGetNext, &wpNext, &status)) { if (status == ADMITERATORDONE) status = 0; else rc = FALSE; break; } lpService = New2 (SERVICE,(this, wpNext.wpBosProcessNameGetNext.pszService)); m_lServices->Add (lpService); NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpService->GetIdentifier()); } WORKERPACKET wpDone; wpDone.wpBosProcessNameGetDone.hEnum = wpBegin.wpBosProcessNameGetBegin.hEnum; Worker_DoTask (wtaskBosProcessNameGetDone, &wpDone); } CloseBosObject(); } if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshServicesEnd, GetIdentifier(), ((rc) ? 0 : status)); } } if (pStatus && !rc) *pStatus = status; return TRUE; }
BOOL SERVER::RefreshAggregates (BOOL fNotify, ULONG *pStatus) { BOOL rc = TRUE; DWORD status = 0; if (m_fAggregatesOutOfDate) { m_fAggregatesOutOfDate = FALSE; if (fIsMonitored()) { if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshAggregatesBegin, GetIdentifier()); // First thing is to forget about what aggregates we think we have // now. // LPENUM pEnum; for (pEnum = m_lAggregates->FindLast(); pEnum; pEnum = pEnum->FindPrevious()) { LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject()); lpAggregate->SendDeleteNotifications(); m_lAggregates->Remove (lpAggregate); Delete (lpAggregate); } // Next, the harder part: look through the server to find a list // of aggregates. // PVOID hCell; PVOID hVOS; if ((hVOS = OpenVosObject (&hCell, &status)) == NULL) rc = FALSE; else { WORKERPACKET wpBegin; wpBegin.wpVosPartitionGetBegin.hCell = hCell; wpBegin.wpVosPartitionGetBegin.hServer = hVOS; if (!Worker_DoTask (wtaskVosPartitionGetBegin, &wpBegin, &status)) rc = FALSE; else { for (;;) { WORKERPACKET wpNext; wpNext.wpVosPartitionGetNext.hEnum = wpBegin.wpVosPartitionGetBegin.hEnum; if (!Worker_DoTask (wtaskVosPartitionGetNext, &wpNext, &status)) { if (status == ADMITERATORDONE) status = 0; else rc = FALSE; break; } vos_partitionEntry_p pData = &wpNext.wpVosPartitionGetNext.Data; LPTSTR pszName = AnsiToString (pData->name); LPTSTR pszDevice = AnsiToString (pData->deviceName); LPAGGREGATE lpAggregate = New2 (AGGREGATE,(this, pszName, pszDevice)); lpAggregate->m_as.dwID = lpAggregate->GetID(); FreeString (pszDevice, pData->deviceName); FreeString (pszName, pData->name); lpAggregate->m_wGhost |= GHOST_HAS_SERVER_ENTRY; lpAggregate->m_as.ckStorageTotal = pData->totalSpace; lpAggregate->m_as.ckStorageFree = pData->totalFreeSpace; m_lAggregates->Add (lpAggregate); NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpAggregate->GetIdentifier()); } WORKERPACKET wpDone; wpDone.wpVosPartitionGetDone.hEnum = wpBegin.wpVosPartitionGetBegin.hEnum; Worker_DoTask (wtaskVosPartitionGetDone, &wpDone); } CloseVosObject(); } if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshAggregatesEnd, GetIdentifier(), ((rc) ? 0 : status)); } } if (pStatus && !rc) *pStatus = status; return TRUE; }