// Clean-up the L3 switch void CleanupL3Sw(L3SW *s) { UINT i; // Validate arguments if (s == NULL) { return; } for (i = 0;i < LIST_NUM(s->IfList);i++) { L3IF *f = LIST_DATA(s->IfList, i); Free(f); } ReleaseList(s->IfList); for (i = 0;i < LIST_NUM(s->TableList);i++) { L3TABLE *t = LIST_DATA(s->TableList, i); Free(t); } ReleaseList(s->TableList); DeleteLock(s->lock); Free(s); }
// Configuration release void ElFreeConfig(EL *e) { UINT i; LIST *o; // Validate arguments if (e == NULL) { return; } // Write the configuration file ElSaveConfig(e); FreeCfgRw(e->CfgRw); // Stop all capture o = NewList(NULL); LockList(e->DeviceList); { for (i = 0;i < LIST_NUM(e->DeviceList);i++) { EL_DEVICE *d = LIST_DATA(e->DeviceList, i); Insert(o, CopyStr(d->DeviceName)); } for (i = 0;i < LIST_NUM(o);i++) { char *name = LIST_DATA(o, i); ElDeleteCaptureDevice(e, name); Free(name); } ReleaseList(o); } UnlockList(e->DeviceList); ReleaseList(e->DeviceList); }
int main(int argc, const char * argv[]) { List *cmnds = NULL; char *string = NULL; int quit = 0; ErrorCode errorCode = ERRORCODE_NO_ERROR, endOfFile = ERRORCODE_NO_ERROR; CATCH_ERROR(InitInput(&string), errHandler); // allocating input string MEM(string, initialError); // checking if allocation was successful, otherwise quiting while (endOfFile == ERRORCODE_NO_ERROR && quit != 1) // ends on <quit> command { ReleaseList(&cmnds); // releasing list of tokens endOfFile = ReadStringFromStream(stdin, &string); // reading string of unknown length CATCH_ERROR(Tokenize(string, &cmnds), errHandler); // creating a list of tokens from input string CATCH_ERROR(Route(cmnds, &quit), errHandler); // trying to find a matching method errHandler: PrintErrorFeedback(errorCode); // on error printing feedback info and continuing main loop } ReleaseList(&cmnds); // after escaping while ReleaseInput(string); return 0; initialError: return 1; }
// Release the Layer-3 interface void L3FreeInterface(L3IF *f) { UINT i; L3PACKET *p; PKT *pkt; // Validate arguments if (f == NULL) { return; } for (i = 0;i < LIST_NUM(f->ArpTable);i++) { L3ARPENTRY *a = LIST_DATA(f->ArpTable, i); Free(a); } ReleaseList(f->ArpTable); f->ArpTable = NULL; for (i = 0;i < LIST_NUM(f->ArpWaitTable);i++) { L3ARPWAIT *w = LIST_DATA(f->ArpWaitTable, i); Free(w); } ReleaseList(f->ArpWaitTable); f->ArpWaitTable = NULL; while (p = GetNext(f->IpPacketQueue)) { Free(p->Packet->PacketData); FreePacket(p->Packet); Free(p); } ReleaseQueue(f->IpPacketQueue); f->IpPacketQueue = NULL; for (i = 0;i < LIST_NUM(f->IpWaitList);i++) { L3PACKET *p = LIST_DATA(f->IpWaitList, i); Free(p->Packet->PacketData); FreePacket(p->Packet); Free(p); } ReleaseList(f->IpWaitList); f->IpWaitList = NULL; while (pkt = GetNext(f->SendQueue)) { Free(pkt->PacketData); FreePacket(pkt); } ReleaseQueue(f->SendQueue); f->SendQueue = NULL; }
// Stop all L3 switches in the Cedar void L3FreeAllSw(CEDAR *c) { LIST *o; UINT i; // Validate arguments if (c == NULL) { return; } o = NewListFast(NULL); LockList(c->L3SwList); { for (i = 0;i < LIST_NUM(c->L3SwList);i++) { L3SW *s = LIST_DATA(c->L3SwList, i); Insert(o, CopyStr(s->Name)); } for (i = 0;i < LIST_NUM(o);i++) { char *name = LIST_DATA(o, i); L3DelSw(c, name); Free(name); } ReleaseList(o); } UnlockList(c->L3SwList); }
// Release the table void FreeTable() { UINT i, num; TABLE **tables; if (TableList == NULL) { return; } TrackingDisable(); num = LIST_NUM(TableList); tables = ToArray(TableList); for (i = 0;i < num;i++) { TABLE *t = tables[i]; Free(t->name); Free(t->str); Free(t->unistr); Free(t); } ReleaseList(TableList); TableList = NULL; Free(tables); Zero(old_table_name, sizeof(old_table_name)); TrackingEnable(); }
// Get Ethernet device list on Solaris TOKEN_LIST *GetEthListSolaris() { TOKEN_LIST *t; int i, s; LIST *o; o = NewListFast(CompareStr); s = socket(AF_INET, SOCK_DGRAM, 0); if (s != INVALID_SOCKET) { struct lifnum lifn; lifn.lifn_family = AF_INET; lifn.lifn_flags = 0; if (ioctl(s, SIOCGLIFNUM, (char *)&lifn) >= 0) { struct lifconf lifc; struct lifreq *buf; UINT numifs; UINT bufsize; numifs = lifn.lifn_count; Debug("NumIFs:%d\n",numifs); bufsize = numifs * sizeof(struct lifreq); buf = Malloc(bufsize); lifc.lifc_family = AF_INET; lifc.lifc_flags = 0; lifc.lifc_len = bufsize; lifc.lifc_buf = (char*) buf; if (ioctl(s, SIOCGLIFCONF, (char *)&lifc) >= 0) { for (i = 0; i<numifs; i++) { if(StartWith(buf[i].lifr_name, "lo") == false){ Add(o, CopyStr(buf[i].lifr_name)); } } } Free(buf); } closesocket(s); } Sort(o); t = ZeroMalloc(sizeof(TOKEN_LIST)); t->NumTokens = LIST_NUM(o); t->Token = ZeroMalloc(sizeof(char *) * t->NumTokens); for (i = 0;i < LIST_NUM(o);i++) { char *name = LIST_DATA(o, i); t->Token[i] = name; } ReleaseList(o); return t; }
// Delete old entries in Non-SSL connection list void DeleteOldNoSsl(CEDAR *c) { UINT i; LIST *o; // Validate arguments if (c == NULL) { return; } o = NewListFast(NULL); for (i = 0;i < LIST_NUM(c->NonSslList);i++) { NON_SSL *n = LIST_DATA(c->NonSslList, i); if (n->EntryExpires <= Tick64()) { Add(o, n); } } for (i = 0;i < LIST_NUM(o);i++) { NON_SSL *n = LIST_DATA(o, i); Delete(c->NonSslList, n); Free(n); } ReleaseList(o); }
// Release of the Tick64 void FreeTick64() { UINT i; if (tk64 == NULL) { // Uninitialized return; } // Termination process tk64->Halt = true; Set(halt_tick_event); WaitThread(tk64->Thread, INFINITE); ReleaseThread(tk64->Thread); // Releasing process for (i = 0;i < LIST_NUM(tk64->AdjustTime);i++) { ADJUST_TIME *t = LIST_DATA(tk64->AdjustTime, i); Free(t); } ReleaseList(tk64->AdjustTime); DeleteLock(tk64->TickLock); Free(tk64); tk64 = NULL; ReleaseEvent(halt_tick_event); halt_tick_event = NULL; }
void main() { int nMenu = 0; LoadList(DATA_FILE_NAME); // 메인 이벤트 반복문 while ((nMenu = PrintUI()) != 0) { switch (nMenu) { case 1: // Add Add(); break; case 2: // Search Search(); break; case 3: // Print all PrintAll(); break; case 4: // Remove Remove(); break; } } // 종료 전에 파일로 저장하고 메모리를 해제한다. SaveList(DATA_FILE_NAME); ReleaseList(); }
// Cut out the token from the string (not ignore the blanks between delimiters) TOKEN_LIST *ParseTokenWithNullStr(char *str, char *split_chars) { LIST *o; UINT i, len; BUF *b; char zero = 0; TOKEN_LIST *t; // Validate arguments if (str == NULL) { return NullToken(); } if (split_chars == NULL) { split_chars = DefaultTokenSplitChars(); } b = NewBuf(); o = NewListFast(NULL); len = StrLen(str); for (i = 0;i < (len + 1);i++) { char c = str[i]; bool flag = IsCharInStr(split_chars, c); if (c == '\0') { flag = true; } if (flag == false) { WriteBuf(b, &c, sizeof(char)); } else { WriteBuf(b, &zero, sizeof(char)); Insert(o, CopyStr((char *)b->Buf)); ClearBuf(b); } } t = ZeroMalloc(sizeof(TOKEN_LIST)); t->NumTokens = LIST_NUM(o); t->Token = ZeroMalloc(sizeof(char *) * t->NumTokens); for (i = 0;i < t->NumTokens;i++) { t->Token[i] = LIST_DATA(o, i); } ReleaseList(o); FreeBuf(b); return t; }
// Listener stop void ElStopListener(EL *e) { UINT i; THREAD **threads; SOCK **socks; UINT num_threads, num_socks; // Validate arguments if (e == NULL) { return; } StopAllListener(e->Cedar); LockList(e->AdminThreadList); { threads = ToArray(e->AdminThreadList); num_threads = LIST_NUM(e->AdminThreadList); DeleteAll(e->AdminThreadList); socks = ToArray(e->AdminSockList); num_socks = LIST_NUM(e->AdminSockList); DeleteAll(e->AdminSockList); } UnlockList(e->AdminThreadList); for (i = 0;i < num_socks;i++) { Disconnect(socks[i]); ReleaseSock(socks[i]); } for (i = 0;i < num_threads;i++) { WaitThread(threads[i], INFINITE); ReleaseThread(threads[i]); } Free(threads); Free(socks); ReleaseList(e->AdminSockList); ReleaseList(e->AdminThreadList); ReleaseListener(e->Listener); }
// Delete the folder void CfgDeleteFolder(FOLDER *f) { FOLDER **ff; ITEM **tt; UINT num, i; // Validate arguments if (f == NULL) { return; } // Remove all subfolders num = LIST_NUM(f->Folders); ff = Malloc(sizeof(FOLDER *) * num); Copy(ff, f->Folders->p, sizeof(FOLDER *) * num); for (i = 0;i < num;i++) { CfgDeleteFolder(ff[i]); } Free(ff); // Remove all items num = LIST_NUM(f->Items); tt = Malloc(sizeof(ITEM *) * num); Copy(tt, f->Items->p, sizeof(ITEM *) * num); for (i = 0;i < num;i++) { CfgDeleteItem(tt[i]); } Free(tt); // Memory release Free(f->Name); // Remove from the parent list if (f->Parent != NULL) { Delete(f->Parent->Folders, f); } // Release the list ReleaseList(f->Folders); ReleaseList(f->Items); // Release of the memory of the body Free(f); }
// Get the candidates list of of the real command name whose abbreviation matches to the command specified by the user TOKEN_LIST *GetRealnameCandidate(char *input_name, TOKEN_LIST *real_name_list) { TOKEN_LIST *ret; LIST *o; UINT i; bool ok = false; // Validate arguments if (input_name == NULL || real_name_list == NULL) { return NullToken(); } o = NewListFast(NULL); for (i = 0;i < real_name_list->NumTokens;i++) { char *name = real_name_list->Token[i]; // Search for an exact match with the highest priority first if (StrCmpi(name, input_name) == 0) { Insert(o, name); ok = true; break; } } if (ok == false) { // If there is no command to exact match, check whether it matches to a short form command for (i = 0;i < real_name_list->NumTokens;i++) { char *name = real_name_list->Token[i]; if (IsOmissionName(input_name, name) || IsNameInRealName(input_name, name)) { // A abbreviation is found Insert(o, name); ok = true; } } } if (ok) { // One or more candidate is found ret = ListToTokenList(o); } else { ret = NullToken(); } ReleaseList(o); return ret; }
void KPlayerTeam::Release() { m_nFlag = 0; m_nFigure = TEAM_CAPTAIN; m_nApplyCaptainID = -1; m_nApplyCaptainID = 0; m_dwApplyTimer = 0; m_bAutoRefuseInviteFlag = FALSE; // TRUE 自动拒绝 FALSE 手动 ReleaseList(); }
// Stop the L3 switch function of the Cedar void FreeCedarLayer3(CEDAR *c) { // Validate arguments if (c == NULL) { return; } ReleaseList(c->L3SwList); c->L3SwList = NULL; }
// Release and stop the IPsec server void FreeIPsecServer(IPSEC_SERVER *s) { UINT i; IPSEC_SERVICES sl; // Validate arguments if (s == NULL) { return; } s->NoMoreChangeSettings = true; // Stopp the L2TP server StopL2TPServer(s->L2TP, false); // Stop the IKE server StopIKEServer(s->Ike); // Stop all the services explicitly Zero(&sl, sizeof(sl)); IPsecServerSetServices(s, &sl); // Releasing process FreeUdpListener(s->UdpListener); ReleaseCedar(s->Cedar); FreeL2TPServer(s->L2TP); FreeIKEServer(s->Ike); for (i = 0;i < LIST_NUM(s->EtherIPIdList);i++) { ETHERIP_ID *k = LIST_DATA(s->EtherIPIdList, i); Free(k); } ReleaseList(s->EtherIPIdList); // Stop the OS monitoring thread s->Halt = true; Set(s->OsServiceCheckThreadEvent); WaitThread(s->OsServiceCheckThread, INFINITE); ReleaseThread(s->OsServiceCheckThread); ReleaseEvent(s->OsServiceCheckThreadEvent); DeleteLock(s->LockSettings); Free(s); }
void main() { cur *Cur = NULL; node *Node = NULL; InitList(&Node, &Cur); InsertNode(&Node, &Cur, 0, rand()); InsertNode(&Node, &Cur, 1, rand()); InsertNode(&Node, &Cur, 2, rand()); DeleteNode(&Node, &Cur, 1); DeleteNode(&Node, &Cur, CountList(&Node, &Cur)); DeleteNode(&Node, &Cur, 0); ShowList(&Node, &Cur); ReleaseList(&Node, &Cur); }
// Release the VLAN list void UnixVLanFree() { UINT i; for (i = 0;i < LIST_NUM(unix_vlan);i++) { UNIX_VLAN_LIST *t = LIST_DATA(unix_vlan, i); UnixCloseTapDevice(t->fd); Free(t); } ReleaseList(unix_vlan); unix_vlan = NULL; }
// Free Ethernet adapter list void FreeEthAdaptersList() { UINT i; if (eth_list == NULL) { return; } for (i = 0;i < LIST_NUM(eth_list);i++) { WP_ADAPTER *a = LIST_DATA(eth_list, i); Free(a); } ReleaseList(eth_list); eth_list = NULL; }
void FlagMgr::Init() { //ReleaseImage(); ReleaseList(); listBack = DataOwner::GetInst()->imageFactory->GetImage(ImageFactory::ImageID::SPEED_LIST); blockBack = DataOwner::GetInst()->imageFactory->GetImage(ImageFactory::ImageID::SPEED_BLOCK); goldBack = DataOwner::GetInst()->imageFactory->GetImage(ImageFactory::ImageID::GOLD_STOCK); listParam = DataOwner::GetInst()->imageFactory->GetParam(ImageFactory::ImageID::SPEED_LIST); blackParam = DataOwner::GetInst()->imageFactory->GetParam(ImageFactory::ImageID::SPEED_BLOCK); goldParam = DataOwner::GetInst()->imageFactory->GetParam(ImageFactory::ImageID::GOLD_STOCK); frame = DataOwner::GetInst()->imageFactory->GetImage(ImageFactory::ImageID::BLOCK_FRAME); frameParam = DataOwner::GetInst()->imageFactory->GetParam(ImageFactory::ImageID::BLOCK_FRAME); missCount = 0; state = State::MAIN; }
// Get the string name that begins with the specified name TOKEN_LIST *GetTableNameStartWith(char *str) { UINT i; UINT len; LIST *o; TOKEN_LIST *t; char tmp[MAX_SIZE]; // Validate arguments if (str == NULL) { return NullToken(); } StrCpy(tmp, sizeof(tmp), str); StrUpper(tmp); len = StrLen(tmp); o = NewListFast(NULL); for (i = 0;i < LIST_NUM(TableList);i++) { TABLE *t = LIST_DATA(TableList, i); UINT len2 = StrLen(t->name); if (len2 >= len) { if (Cmp(t->name, tmp, len) == 0) { Insert(o, CopyStr(t->name)); } } } t = ZeroMalloc(sizeof(TOKEN_LIST)); t->NumTokens = LIST_NUM(o); t->Token = ZeroMalloc(sizeof(char *) * t->NumTokens); for (i = 0;i < t->NumTokens;i++) { t->Token[i] = LIST_DATA(o, i); } ReleaseList(o); return t; }
// Free the string list void FreeStrList(LIST *o) { UINT i; // Validate arguments if (o == NULL) { return; } for (i = 0;i < LIST_NUM(o);i++) { char *s = LIST_DATA(o, i); Free(s); } ReleaseList(o); }
// すべてのオブジェクトの表示 void DebugPrintAllObjects() { UINT i; LIST *view; // リスト作成 view = NewListFast(SortObjectView); LockTrackingList(); { for (i = 0; i < TRACKING_NUM_ARRAY; i++) { if (hashlist[i] != NULL) { TRACKING_LIST *t = hashlist[i]; while (true) { Add(view, t->Object); if (t->Next == NULL) { break; } t = t->Next; } } } } UnlockTrackingList(); // ソート Sort(view); // 描画 for (i = 0; i < LIST_NUM(view); i++) { TRACKING_OBJECT *o = (TRACKING_OBJECT *)LIST_DATA(view, i); PrintObjectList(o); } // リスト解放 ReleaseList(view); Print("\n"); }
// Free net service list void FreeNetSvcList(CEDAR *cedar) { UINT i; // Validate arguments if (cedar == NULL) { return; } for (i = 0;i < LIST_NUM(cedar->NetSvcList);i++) { NETSVC *n = LIST_DATA(cedar->NetSvcList, i); Free(n->Name); Free(n); } ReleaseList(cedar->NetSvcList); }
// Polling for the ARP resolution waiting list void L3PollingArpWaitTable(L3IF *f) { UINT i; LIST *o = NULL; // Validate arguments if (f == NULL) { return; } for (i = 0;i < LIST_NUM(f->ArpWaitTable);i++) { L3ARPWAIT *w = LIST_DATA(f->ArpWaitTable, i); if (w->Expire <= Tick64()) { // The ARP request entry is expired if (o == NULL) { o = NewListFast(NULL); } Insert(o, w); } else if ((w->LastSentTime + ARP_REQUEST_TIMEOUT) <= Tick64()) { // Send a next ARP request packet w->LastSentTime = Tick64(); L3SendArpRequestNow(f, w->IpAddress); } } if (o != NULL) { for (i = 0;i < LIST_NUM(o);i++) { L3ARPWAIT *w = LIST_DATA(o, i); Delete(f->ArpWaitTable, w); Free(w); } ReleaseList(o); } }
// Clear old ARP table entries void L3DeleteOldArpTable(L3IF *f) { UINT i; LIST *o = NULL; // Validate arguments if (f == NULL) { return; } if ((f->LastDeleteOldArpTable + ARP_ENTRY_POLLING_TIME) > Tick64()) { return; } f->LastDeleteOldArpTable = Tick64(); for (i = 0;i < LIST_NUM(f->ArpTable);i++) { L3ARPENTRY *a = LIST_DATA(f->ArpTable, i); if (a->Expire <= Tick64()) { // Expired if (o == NULL) { o = NewListFast(NULL); } Insert(o, a); } } if (o != NULL) { for (i = 0;i < LIST_NUM(o);i++) { L3ARPENTRY *a = LIST_DATA(o, i); Delete(f->ArpTable, a); Free(a); } ReleaseList(o); } }
// Release the Attribute list void SstpFreeAttributeList(LIST *o) { UINT i; // Validate arguments if (o == NULL) { return; } for (i = 0;i < LIST_NUM(o);i++) { SSTP_ATTRIBUTE *a = LIST_DATA(o, i); SstpFreeAttribute(a); } ReleaseList(o); }
// Release the adapter list void SuFreeAdapterList(LIST *o) { UINT i; // Validate arguments if (o == NULL) { return; } for (i = 0; i < LIST_NUM(o); i++) { SU_ADAPTER_LIST *a = LIST_DATA(o, i); Free(a); } ReleaseList(o); }
// Free the local-bridge list void FreeLocalBridgeList(CEDAR *c) { UINT i; // Validate arguments if (c == NULL) { return; } for (i = 0;i < LIST_NUM(c->LocalBridgeList);i++) { LOCALBRIDGE *br = LIST_DATA(c->LocalBridgeList, i); Free(br); } ReleaseList(c->LocalBridgeList); c->LocalBridgeList = NULL; }