//====================================================================================================================
// Prepare and calculate values for a frame size
//====================================================================================================================
void cSoundBlockList::SetFrameSize(int FrameSize,int TheChannels,int64_t TheSamplingRate,enum AVSampleFormat TheSampleFormat) {
    ClearList();
    SamplingRate   =TheSamplingRate;
    SampleFormat   =TheSampleFormat;
    SoundPacketSize=FrameSize;
    Channels       =TheChannels;
    NbrPacketForFPS=1;
    dDuration      =double(SoundPacketSize)/(double(SamplingRate)*double(SampleBytes)*double(Channels));
    WantedDuration =dDuration*1000;
    if (TempData) {
        av_free(TempData);
        TempData=NULL;
    }
    TempData=(u_int8_t *)av_malloc(SoundPacketSize+8);
}
Beispiel #2
0
bool ZipFile::LoadList()
{
    ClearList();

    if(!SwitchMode(ZipFile::OPEN))
        return false;

    int ret = unzGoToFirstFile(uzFile);
    if(ret != UNZ_OK)
        return false;

    char filename[1024];
    unz_file_info cur_file_info;
    RealArchiveItemCount = 0;

    do
    {
        if(unzGetCurrentFileInfo(uzFile, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) == UNZ_OK)
        {
            bool isDir = false;
            if(filename[strlen(filename)-1] == '/')
            {
                isDir = true;
                filename[strlen(filename)-1] = '\0';
            }

            int strlength = strlen(filename)+1;

            ArchiveFileStruct * CurArcFile = new ArchiveFileStruct;
            CurArcFile->filename = new char[strlength];
            strcpy(CurArcFile->filename, filename);
            CurArcFile->length = cur_file_info.uncompressed_size;
            CurArcFile->comp_length = cur_file_info.compressed_size;
            CurArcFile->isdir = isDir;
            CurArcFile->fileindex = RealArchiveItemCount;
            CurArcFile->ModTime = (u64) cur_file_info.dosDate;
            CurArcFile->archiveType = ZIP;

            ZipStructure.push_back(CurArcFile);
        }
        ++RealArchiveItemCount;
    }
    while(unzGoToNextFile(uzFile) == UNZ_OK);

    PathControl();

    return true;
}
NewFromTemplateDlg::~NewFromTemplateDlg()
{
	//dtor
    delete XRCCTRL(*this, "listProjects", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
    delete XRCCTRL(*this, "listFiles", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
    delete XRCCTRL(*this, "listCustoms", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);

    XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_NORMAL);
    XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_SMALL);
    XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_NORMAL);
    XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_SMALL);
    XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_NORMAL);
    XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(0, wxIMAGE_LIST_SMALL);

	ClearList();
}
void CDuyetFile::ApproveFolderToList(const TCHAR *strPath)
{
	ClearList();

	TCHAR strPathFileData[MAX_PATH] = {0};

	GetCurrentDirectory(MAX_PATH, strPathFileData);
	StringCchCat(strPathFileData, MAX_PATH, _T("\\danhsach.ini"));
	
	// UTF16-LE BOM(FFFE)
	WORD wBOM = 0xFEFF;
	DWORD NumberOfBytesWritten;

	HANDLE hFileOut = CreateFile(strPathFileData, FILE_WRITE_DATA, 0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);
	if(INVALID_HANDLE_VALUE == hFileOut)
	{
		AfxMessageBox(_T("Không thể tạo file"), MB_ICONSTOP);
		return;
	}
	//write unicode.
	::WriteFile(hFileOut, &wBOM, sizeof(WORD), &NumberOfBytesWritten, NULL);
	TCHAR strTemp[MAX_PATH] = {0};
	StringCchCopy(strTemp, MAX_PATH, strPath);
	CString temp = strPath;
	temp.Delete(wcslen(temp) - 2, 2);
	int iIndex = (int)wcslen(temp);
	for(; iIndex >= 0 ; iIndex--)
	{
		if(temp[iIndex] == L'\\')
		{
			break;
		}
	}
	temp.Delete(iIndex + 1,(int)wcslen(temp) - iIndex +1 );
	//FormatPath(temp);
	StringCchCopy(strRootPath, MAX_PATH, temp);

	if(ApproveFolder(strPath, &hFileOut))
	{
		
		AfxMessageBox(_T("Duyệt file hoàn tất"), MB_ICONINFORMATION);
	}
	else
		AfxMessageBox(_T("Duyệt file thất bại"), MB_ICONSTOP);
	CloseHandle(hFileOut);
}
Beispiel #5
0
void ClearAstStatement(AstStatement* stmt, void* dummy) {
	if (stmt == NULL) {
		return;
	}
	stmt->type = SIMPLE_STMT;
	stmt->line = 0;
	if (stmt->code) {
		free(stmt->code);
		stmt->code = NULL;
	}
	if (stmt->sub) {
		ClearList(stmt->sub, (ListItemFn)ClearAstStatement);
		free(stmt->sub);
		stmt->sub = NULL;
	}
	stmt->sub_print_count = 0;
}
Beispiel #6
0
void CFileView::SetMapDoc(CMapEditorDoc* value)
{
	if (_mapDoc != value)
	{
		if (_mapDoc)
		{
			ClearList();
			_mapDoc->UnregObserver(_mapDocEvent);
		}
		_mapDoc = value;
		if (_mapDoc)
		{
			_mapDoc->RegObserver(_mapDocEvent);
			UpdateList();
		}
	}
}
bool CWebBrowserDownloadHandler::OnInit()
{
  ClearList();
  m_items.clear();

  for (const auto& file : GetActiveDownloads())
    m_items.push_back(file.second);
  for (const auto& file : GetFinishedDownloads())
  {
    if (file.second->GetName().empty())
      continue;
    m_items.push_back(file.second);
  }

  for (const auto& file : m_items)
  {
    kodi::gui::ListItemPtr item(new kodi::gui::CListItem(file->GetName()));

    std::string info;
    if (file->IsComplete())
    {
      info = kodi::GetLocalizedString(30015);

      std::time_t time = file->GetDownloadTime();
      auto tm = *std::localtime(&time);

      std::string format = kodi::GetRegion("datelong") + " - " + kodi::GetRegion("time");
      std::ostringstream oss;
      oss << std::put_time(&tm, format.c_str());
      item->SetProperty("downloadtime", oss.str());
    }
    else if (file->IsCanceled())
      info = kodi::GetLocalizedString(30096);
    else if (file->IsPaused())
      info = StringUtils::Format(kodi::GetLocalizedString(30095).c_str(), file->GetProcessText().c_str());
    else
      info = file->GetProcessText();

    item->SetLabel2(info);
    item->SetPath(file->GetPath());
    AddListItem(item);
  }

  return true;
}
Beispiel #8
0
void CVisTracker::DoProcessing()
{
	PotatoList *					potList = (PotatoList *)m_oportPotatoObjects.GetBuffer();
	FastLabelObject *				labelObjects = (FastLabelObject*)m_iportLabelObjects.GetBuffer();

	// Clear the list if requested.
	if (m_bClearListNext)
	{
		m_bClearListNext = false;
		ClearList();
	}
	
	// Track all known objects.
	TrackObjects( labelObjects, potList->pObjects );
	
	// Add the new objects to the list of known objects.
	AddNewObjects( labelObjects, potList->pObjects );
}
Beispiel #9
0
bool GuiBGM::LoadStandard()
{
    ClearList();
    if(currentPath)
    {
        delete [] currentPath;
        currentPath = NULL;
    }

    strcpy(Settings.ogg_path, "");

    bool ret = GuiSound::Load(bg_music_ogg, bg_music_ogg_size, true);

    if(ret)
        Play();

    return ret;
}
Beispiel #10
0
bool GuiBGM::LoadStandard()
{
    ClearList();
    if (currentPath)
    {
        delete[] currentPath;
        currentPath = NULL;
    }

    strcpy(cfg.BgMusicPath, "");
	cfg.BgMusicLoop = LOOP;
	
    bool ret = GuiSound::Load(bg_music_ogg, bg_music_ogg_size, false);

    if (ret) Play();

    return ret;
}
Beispiel #11
0
// Objekt neu initialisieren --------------------------------------------------
void init_new_object (void) 
{
	lgi = -1;		// noch keine Geometrie gelesen
	mi[0] = MAXMI;		// Merkmalsfeldgröße
	mi[1] = 0;		// noch keine Merkmale gelesen
	curr_mi = &mi[-1];	// aktuelle Merkmalswerte
	curr_mi_text = (char *)&curr_mi[3];
	koord_paare = 0;	// Anzahl der Stützpunkte
	mi_count = 3;		// Zaehler der Merkmalswerte
	mi_werte = 0;		// Anzahl der Merkmalswerte
	satz_nr = on = 0;

	sta[0] = E_OBJEKT;	// für alle Fälle wieder auf ElementarObjekt
	guid[0] = '\0';

// RelationsDaten
	ClearList();		// interne Datenstrukturen initialisieren
}
Beispiel #12
0
Llist::Llist(Llist& lst)
{
	//--- Test for empty list ------------
	if (lst._headNode == NULL)
		return;

	// check to see if this object is equal to the right hand object
	if (this != &lst)
	{
		ClearList();
		Node* oldNode = lst.GetFirst();
		//clone the old head node
		_headNode = oldNode->Clone();
		//get the next old node
		oldNode = oldNode->GetNextNode();
		//clone the next old node
		Node* newNode = oldNode->Clone();
		//set Next Node for head node
		_headNode->SetNextNode(newNode);
		//set prev node for next node to the new _headNode
		newNode->SetPrevNode(_headNode);
		//get the pointer to the next node in the old list
		oldNode = oldNode->GetNextNode();
		while (oldNode != NULL)
		{
			//clone the old Node
			Node* nextNode = oldNode->Clone();
			//set the next node of newNode
			newNode->SetNextNode(nextNode);
			//set the prev node of nextNode to newNode
			nextNode->SetPrevNode(newNode);
			//point newNode to nextNode						//TODO check this
			newNode = nextNode;
			//get the pointer to the next node in the old list
			oldNode = oldNode->GetNextNode();
		}
		_endNode = newNode;
		_nodeCount = lst.GetCount();
	}
	//print out the copy constructor message
	string classname = typeid(*this).name();
	cout << classname << COPY_CONSTRUCTOR << endl;
}
Beispiel #13
0
/********************************************************************
	Method:    OperatorTest
	Parameter:
	Returns:

	Purpose:   测试函数

*********************************************************************/
bool OperationTest()
{
    LinkList L;

    CreateListByHeadTest(L);	//	头插法测试

    InsertTest(L);	//	插入测试

    DeleteTest(L);	//	删除测试

    ClearListTest(L);

    LinkList L2;
    CreateListByTailTest(L2);	// 尾插法测试

    ClearList(L2);

    DestroyList(L);		//	销毁
    return true;
}
Beispiel #14
0
int main(){
  int i;
  node *root = (node*) malloc( sizeof(node) );
  root->value = 2;
  root->next = NULL;  

  DisplayList(root);
  for(i = 3; i < 8; i++)
    InsertTail(&root, i);
	
  for(i = 1; i >= 0; i--)
	InsertHead(&root, i);
  	
  DisplayList(root);

  ClearList(&root);  
  
  DisplayList(root);
  
  return 0;
}
Beispiel #15
0
void main()
{
	LinkList L;
	ElemType e;
	int j;
	Status i;
	InitList(L);
	i = ListEmpty(L);
	printf("L是否空 i = %d (1:空 0:否)\n", i);
	ListInsert(L, 1, 3);
	ListInsert(L, 2, 5);
	i = GetElem(L, 1, e);
	j = ListLength(L);
	printf("L中的数据元素个数=%d, 第一个数据元素的值为%d.\n", j, e);
	printf("L中的数据元素依次为:");
	ListTraverse(L, print);
	PriorElem(L, 5, e);
	printf("5前面的元素的值为%d.\n", e);
	NextElem(L, 3, e);
	printf("3后面的元素的值为%d.\n", e);
	printf("L是否空 %d(1:空 0:否)\n", ListEmpty(L));
	j = LocateElem(L, 5, equal);
	if ( j )
		printf("L的第%d个元素为5.\n", j);
	else
		printf("不存在值为5的元素.\n");
	i = ListDelete(L, 2, e);
	printf("删除L的第2个元素:\n");
	if ( i )
	{
		printf("删除的元素值为%d, 现在L中的数据元素依次为", e);
		ListTraverse(L, print);
	}
	else
		printf("删除不成功!\n");
	ClearList(L);
	printf("清空L后, L是否空:%d (1:空 0:否)\n", ListEmpty(L));
	DestroyList(L);
}
Beispiel #16
0
/*--- メイン ---*/
int main(void) {
    Menu  menu;
    Node  *list;
    
    InitList(&list);
    
    do {
	Node  x;
	int n;
	char name[NAMELEN];
	
	switch (menu = SelectMenu()) {
	    case Insert: x = Read("挿入");
		InsertNode(&list, x.no, x.name);
		break;
	    case InsertNth: x = Read("挿入");
		printf("何番目? "); scanf("%d", &n);
		InsertNodeNth(&list, n, x.no, x.name);
		break;
	    case Append: x = Read("挿入");
		AppendNode(&list, x.no, x.name);
		break;
	    case Delete: DeleteNode(&list);
		break;
	    case DeleteNth: printf("何番目? "); scanf("%d", &n);
		DeleteNodeNth(&list, n);
		break;
	    case Clear: ClearList(&list);
		break;
	    case Print: PrintList(&list);
		break;
	}
    } while (menu != Term);
    
    TermList(&list);
    
    return (0);
}
Beispiel #17
0
void TDrawListView::FormatData(const Tecg* ecg,  int unsigned index)
{
	// Large number for now :-)
  char buf1[80];
  char buf2[80];
  char buf3[80];
  char buf4[80];
  char buf5[80];

//  TColor color(line->QueryColor());
  wsprintf(buf1, "No. Of Points in ECG = (%d)",
			  ecg->length());
  wsprintf(buf2, "(x,y) Scales         = (%d,%d)",
			  ecg->get_x_scale(), ecg->get_y_scale());
  wsprintf(buf3, "R Hight threshold    = (%d)",
			  ecg->get_r_thresh());
  wsprintf(buf4, "R Change threshold   = (%d)",
			  ecg->get_r_change());
  wsprintf(buf5, "Y (min,max)          = (%d,%d)",
			  ecg->get_y_min(), ecg->get_y_max());
  wsprintf(buf5, "Y mean               = (%d)",
			  ecg->get_y_mean());

//  DeleteString(index);
  ClearList();
  AddString(ecg->ECG_Data_String1.c_str());
  AddString(ecg->ECG_Data_String2.c_str());
  AddString(ecg->ECG_Data_String3.c_str());
  AddString(buf1);
  AddString(buf2);
  AddString(buf3);
  AddString(buf4);
  AddString(buf5);

  SetSelIndex(index);
}
Beispiel #18
0
BOOL DropDown::Init(CWindowID Window, CGadgetID Gadget)
{
	if (Window)
	{
		wxWindow * pGadget = DialogManager::GetGadget(Window, Gadget);
		if (pGadget && pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
		{
			if (!Initialised)			// Only ever add myself to the list once
			{
				m_pPopup = new wxCamVListBoxComboPopup(this);
				ERROR2IF(!m_pPopup, FALSE, "Could not get new list popup");
				((wxOwnerDrawnComboBox *)pGadget)->SetPopupControl(m_pPopup);
				CurrentDropDowns.AddHead(this);
			}
	
			ParentDlg = Window;
			ParentGadget = Gadget;
	
			Initialised = TRUE;
			return(TRUE);
		}
		ERROR3("DropDown::Init failed - illegal Gadget");
		return(FALSE);
	}
	else
	{
		// release all memory
		KillList();
		ClearList();
		ParentDlg=NULL;
		ParentGadget=0;
		Initialised=FALSE;
		CurrentDropDowns.RemoveItem(this);
		return TRUE;
	}
}
//====================================================================================================================
// Prepare and calculate values for a frame rate
//====================================================================================================================
void cSoundBlockList::SetFPS(double TheWantedDuration,int TheChannels,int64_t TheSamplingRate,enum AVSampleFormat TheSampleFormat) {
    // Adjust value for 6 FPS (because rounded value make seek of audio files)
    if ((TheWantedDuration>166)&&(TheWantedDuration<167)) TheWantedDuration=166;

    ClearList();
    SamplingRate   =TheSamplingRate;
    SampleFormat   =TheSampleFormat;
    Channels       =TheChannels;
    WantedDuration =TheWantedDuration;
    NbrPacketForFPS=1;
    dDuration      =double(WantedDuration)/1000;
    SoundPacketSize=int(dDuration*double(SamplingRate))*SampleBytes*Channels;

    while (SoundPacketSize>MAXSOUNDPACKETSIZE) {
        SoundPacketSize =SoundPacketSize/2;
        dDuration       =dDuration/2;
        NbrPacketForFPS*=2;
    }
    if (TempData) {
        av_free(TempData);
        TempData=NULL;
    }
    TempData=(u_int8_t *)av_malloc(SoundPacketSize+8);
}
int main()
{        
    LinkList L;
    ElemType e;
    Status i;
    int j,k;
    i=InitList(&L);
    printf("初始化L后:ListLength(L)=%d\n",ListLength(L));
    for(j=1;j<=5;j++)
            i=ListInsert(&L,1,j);
    printf("在L的表头依次插入1~5后:L.data=");
    ListTraverse(L); 

    printf("ListLength(L)=%d \n",ListLength(L));
    i=ListEmpty(L);
    printf("L是否空:i=%d(1:是 0:否)\n",i);

    i=ClearList(&L);
    printf("清空L后:ListLength(L)=%d\n",ListLength(L));
    i=ListEmpty(L);
    printf("L是否空:i=%d(1:是 0:否)\n",i);

    for(j=1;j<=10;j++)
            ListInsert(&L,j,j);
    printf("在L的表尾依次插入1~10后:L.data=");
    ListTraverse(L); 

    printf("ListLength(L)=%d \n",ListLength(L));

    ListInsert(&L,1,0);
    printf("在L的表头插入0后:L.data=");
    ListTraverse(L); 
    printf("ListLength(L)=%d \n",ListLength(L));

    GetElem(L,5,&e);
    printf("第5个元素的值为:%d\n",e);
    for(j=3;j<=4;j++)
    {
            k=LocateElem(L,j);
            if(k)
                    printf("第%d个元素的值为%d\n",k,j);
            else
                    printf("没有值为%d的元素\n",j);
    }
    

    k=ListLength(L); /* k为表长 */
    for(j=k+1;j>=k;j--)
    {
            i=ListDelete(&L,j,&e); /* 删除第j个数据 */
            if(i==ERROR)
                    printf("删除第%d个数据失败\n",j);
            else
                    printf("删除第%d个的元素值为:%d\n",j,e);
    }
    printf("依次输出L的元素:");
    ListTraverse(L); 

    j=5;
    ListDelete(&L,j,&e); /* 删除第5个数据 */
    printf("删除第%d个的元素值为:%d\n",j,e);

    printf("依次输出L的元素:");
    ListTraverse(L); 

    i=ClearList(&L);
    printf("\n清空L后:ListLength(L)=%d\n",ListLength(L));
    CreateListHead(&L,20);
    printf("整体创建L的元素(头插法):");
    ListTraverse(L); 
    
    i=ClearList(&L);
    printf("\n删除L后:ListLength(L)=%d\n",ListLength(L));
    CreateListTail(&L,20);
    printf("整体创建L的元素(尾插法):");
    ListTraverse(L); 


    return 0;
}
Beispiel #21
0
//-----------------------------------------------------------------------------
uint TCheckList::Transfer(void* buffer, TTransferDirection direction)
{  
  long            style          = GetStyle();
  TCheckListData* checkListData = (TCheckListData*)buffer;

  if (direction == tdGetData){
    // First, clear out Strings array and fill with contents of list box
    //
    checkListData->Clear(false);

    int count = GetCount();
    for(int i =0; i < count; i++)
      checkListData->AddItem(GetItem(i));

    // Update transfer data with new selected item(s)
    //
    checkListData->ResetSelections();

    if (!(style & MULTIPLESEL)) {
      // Single selection
      //
      checkListData->Select(GetSelIndex());
    }
    else {
      // Multiple selection
      //
      int selCount = GetSelCount();
      if (selCount > 0) {
        TAPointer<int> selections(new int[selCount]);

        GetSelIndexes(selections, selCount);

        // Select each item by index
        //
        for (int selIndex = 0; selIndex < selCount; selIndex++)
          checkListData->Select(selections[selIndex]);
      }
    }
  }
  else if (direction == tdSetData){
    ClearList();

    // Add each string, item data and selections in listBoxData to list box
    //
    const int noSelection = -1;
    uint selCount = checkListData->GetSelCount();  // for multi selection
    int  selIndex  = noSelection;               // for single selection
    for (uint i = 0; i < checkListData->ItemCount(); i++){
      // Index may be different from i when the listbox is sorted.
      //
       int index =  AddString((LPCTSTR)checkListData->GetItem(i));
      if (style & MULTIPLESEL) {
        for (uint j = 0; j < selCount; j++)
          if (checkListData->GetSelIndices()[j] == (int)i) {
            SetSel(index, true);
            break;
          }
      }
      else {
        if (selCount && (uint)checkListData->GetSelIndices()[0] == i)
          selIndex = index;
        else
          // Inserted something before item and the item to select has been
          // pushed further down in the list.
          //
          if (selIndex != noSelection && index <= selIndex)
            selIndex++;
      }
    }
    if (selIndex != noSelection && !(style & MULTIPLESEL))
      SetSelIndex(selIndex);
  }
  return sizeof(TCheckListData);
}
Beispiel #22
0
void COpenCreDlg::OnDestroy() 
{
	ClearList();
	CDialog::OnDestroy();
}
Beispiel #23
0
BOOL FontDropDown::FillInFontList()
{
	ERROR2IF(ParentDlg == NULL, FALSE, "FontDropDown not properly initialised");
	TRACEUSER("wuerthne", _T("FillInFontList"));

	SetListRedraw(FALSE);										// Disable redraw while updating
	ClearList();												// Delete combobox contents

	// Setup the static class pointer variable so we can add things to this dropdown...
	CurrentFontDropDown = (void *)this;

	if(Fonts.GetCount() == 0)
	{
		TRACEUSER("wuerthne", _T("FontDropDown enumerating fonts"));
		FontDropEnumFont EnumObj;
		EnumObj.Execute();

		// Loop through the list, checking for ATM / TTF duplicates, and remove the TTF ones from the list
		FontDropItem *Item = (FontDropItem *)Fonts.GetHead();
		while (Item != NULL)
		{
			FontClass ItemType = Item->Type;
			if(ItemType == FC_ATM)
			{
				// It's an ATM font, go through whole list checking for TTF equiv.
				BOOL Removed = FALSE;
				String_64 ItemName(Item->FontName);
				FontDropItem *InnerLoopItem = (FontDropItem *)Fonts.GetHead();
				while (InnerLoopItem != NULL && Removed == FALSE)
				{
					// Have we found our font ? Remove it if we have...
					if((InnerLoopItem->Type == FC_TRUETYPE) && (InnerLoopItem->FontName == ItemName))
					{
						Fonts.RemoveItem((ListItem *)InnerLoopItem);
						delete InnerLoopItem;
						InnerLoopItem = NULL;
						Removed = TRUE;
					}

					// Get the next item
					if(!Removed)
						InnerLoopItem = (FontDropItem *)Fonts.GetNext((ListItem *)InnerLoopItem);
				}
			}
			// Get the next item
			Item = (FontDropItem *)Fonts.GetNext((ListItem *)Item);
		}
	}

	ListItem *Item = Fonts.GetHead();

	while (Item != NULL)
	{
		// Add the font in the list to the combo box
		AddItem((void *) Item);

		// Try the next item
		Item = Fonts.GetNext(Item);
	}

	SetListRedraw(TRUE);									// Re-enable redraw

	return(TRUE);
}
int main()
{

    SqList L;
	SqList Lb;

    ElemType e;
    Status i;
    int j,k;
    i=InitList(&L);
    printf("初始化L后:L.length=%d\n",L.length);
    for(j=1;j<=5;j++)
            i=ListInsert(&L,1,j);
    printf("在L的表头依次插入1~5后:L.data=");
    ListTraverse(L);

    printf("L.length=%d \n",L.length);
    i=ListEmpty(L);
    printf("L是否空:i=%d(1:是 0:否)\n",i);

    i=ClearList(&L);
    printf("清空L后:L.length=%d\n",L.length);
    i=ListEmpty(L);
    printf("L是否空:i=%d(1:是 0:否)\n",i);

    for(j=1;j<=10;j++)
            ListInsert(&L,j,j);
    printf("在L的表尾依次插入1~10后:L.data=");
    ListTraverse(L);

    printf("L.length=%d \n",L.length);

    ListInsert(&L,1,0);
    printf("在L的表头插入0后:L.data=");
    ListTraverse(L);
    printf("L.length=%d \n",L.length);

    GetElem(L,5,&e);
    printf("第5个元素的值为:%d\n",e);
    for(j=3;j<=4;j++)
    {
            k=LocateElem(L,j);
            if(k)
                    printf("第%d个元素的值为%d\n",k,j);
            else
                    printf("没有值为%d的元素\n",j);
    }


    k=ListLength(L); /* k为表长 */
    for(j=k+1;j>=k;j--)
    {
            i=ListDelete(&L,j,&e); /* 删除第j个数据 */
            if(i==ERROR)
                    printf("删除第%d个数据失败\n",j);
            else
                    printf("删除第%d个的元素值为:%d\n",j,e);
    }
    printf("依次输出L的元素:");
    ListTraverse(L);

    j=5;
    ListDelete(&L,j,&e); /* 删除第5个数据 */
    printf("删除第%d个的元素值为:%d\n",j,e);

    printf("依次输出L的元素:");
    ListTraverse(L);

	//构造一个有10个数的Lb
	i=InitList(&Lb);
    for(j=6;j<=15;j++)
            i=ListInsert(&Lb,1,j);

	unionL(&L,Lb);

	printf("依次输出合并了Lb的L的元素:");
    ListTraverse(L);

    return 0;
}
Beispiel #25
0
 void main() /* 除了几个输出语句外,主程和main2-1.c很像 */
 {
   LinkList L; /* 与main2-1.c不同 */
   ElemType e,e0;
   Status i;
   int j,k;
   i=InitList(&L);
   for(j=1;j<=5;j++)
     i=ListInsert(L,1,j);
   printf("在L的表头依次插入1~5后:L=");
   ListTraverse(L,visit); /* 依次对元素调用visit(),输出元素的值 */
   i=ListEmpty(L);
   printf("L是否空:i=%d(1:是 0:否)\n",i);
   i=ClearList(L);
   printf("清空L后:L=");
   ListTraverse(L,visit);
   i=ListEmpty(L);
   printf("L是否空:i=%d(1:是 0:否)\n",i);
   for(j=1;j<=10;j++)
     ListInsert(L,j,j);
   printf("在L的表尾依次插入1~10后:L=");
   ListTraverse(L,visit);
   GetElem(L,5,&e);
   printf("第5个元素的值为:%d\n",e);
   for(j=0;j<=1;j++)
   {
     k=LocateElem(L,j,comp);
     if(k)
       printf("第%d个元素的值为%d\n",k,j);
     else
       printf("没有值为%d的元素\n",j);
   }
   for(j=1;j<=2;j++) /* 测试头两个数据 */
   {
     GetElem(L,j,&e0); /* 把第j个数据赋给e0 */
     i=PriorElem(L,e0,&e); /* 求e0的前驱 */
     if(i==INFEASIBLE)
       printf("元素%d无前驱\n",e0);
     else
       printf("元素%d的前驱为:%d\n",e0,e);
   }
   for(j=ListLength(L)-1;j<=ListLength(L);j++)/*最后两个数据 */
   {
     GetElem(L,j,&e0); /* 把第j个数据赋给e0 */
     i=NextElem(L,e0,&e); /* 求e0的后继 */
     if(i==INFEASIBLE)
       printf("元素%d无后继\n",e0);
     else
       printf("元素%d的后继为:%d\n",e0,e);
   }
   k=ListLength(L); /* k为表长 */
   for(j=k+1;j>=k;j--)
   {
     i=ListDelete(L,j,&e); /* 删除第j个数据 */
     if(i==ERROR)
       printf("删除第%d个数据失败\n",j);
     else
       printf("删除的元素为:%d\n",e);
   }
   printf("依次输出L的元素:");
   ListTraverse(L,visit);
   DestroyList(&L);
   printf("销毁L后:L=%u\n",L);
 }
Beispiel #26
0
void UserList2(int mode) {

	DIR *dp;	
	FILE *statefp;
	char fname[256];
	USERSTATE udata;
	int i,x=0;
	struct dirent *dirinfo;
	struct stat st;	
	Data userdat;
	Header h;
	
	CreateList(&h);

	printf("\x1b[0mRetrieving List..");	
	fflush(stdout);
	sprintf(fname,"%s/users/",BBSDIR);
	dp = opendir(fname);
	
	while((dirinfo = readdir(dp)) != NULL) {
		if(dirinfo->d_name[0] == '.') continue;		
		sprintf(fname,"%s/users/%s/state",BBSDIR,dirinfo->d_name);
		if((statefp = fopen(fname,"rb")) != NULL) {
			if(fread((char *)&udata,sizeof(USERSTATE),1,statefp) == 1) {
				strcpy(userdat.name,dirinfo->d_name);
				userdat.time_laston = udata.time_laston;
				userdat.no_calls = udata.no_calls;
				userdat.no_posts = udata.no_posts;
				userdat.no_drops = udata.no_drops;
				userdat.time_posting = udata.time_posting;
				if(mode == NON_MEMBERS) {
					sprintf(fname,"%s/users/%s/keycode",BBSDIR,dirinfo->d_name);
					if(!stat(fname,&st)) {/** if keycode **/
						AddItem(&h, &userdat);
						x++;
					}
				} else {
					sprintf(fname,"%s/users/%s/keycode",BBSDIR,dirinfo->d_name);
					if(stat(fname,&st)) {/** if no keycode **/
						AddItem(&h, &userdat);
						x++;
					}
				}
			}
			fclose(statefp);
		}
	}
	closedir(dp);
	printf("\n\033[0;35mCounted \033[1;35m%d \033[0;35mUser(s)\n\n",x);
	Pause2();
	printf("\n");
	Sort(&h);
	ResetList(&h);	
	PrintListHeader();
	i=0;
	while(NextItem(&h)) {
		if(i>(rows-6)) {
			fflush(stdout);
			if(!More2()) {
				printf("\n");
				return;
			}
			printf("\n");
			i=0;
			PrintListHeader();
		}
		GetItem(h,&userdat);
		sprintf(fname,"%s/users/%s/user_profile",BBSDIR,userdat.name);
		if(stat(fname,&st))	
			printf("\x1b[0m%-17.17s", userdat.name);
		else
			printf("\x1b[1;33m%-17.17s", userdat.name);
		printf("\x1b[0;35m%5.1f", ((time(NULL) - userdat.time_laston )/86400.0));
		printf("\x1b[32m%4d", userdat.no_calls);
		printf("\x1b[31m%4d", userdat.no_posts);
		printf("\x1b[33m%2d ", userdat.no_drops);
		printf("\x1b[34m%d\n", userdat.time_posting);
		i++;
		fflush(stdout);
	}
	printf("\n");
	ClearList(&h);
	return;
}
Beispiel #27
0
int main(int argc, char **argv)
{



	struct passwd *pw = getpwuid(getuid());
	const char *homedir = pw->pw_dir;

	char db_fname [STR_MAX];
	
	strcpy(db_fname, homedir);
	strcat(db_fname, DEFAULT_DB_FNAME);
	
	extern char *optarg;
	char * optarg_insert = 0;
	char * optarg_remove = 0;
	bool bl_size = 0;
	bool bl_clear = 0;
	bool bl_remove = 0;
	bool bl_insert = 0;

	char c;
	while ((c = getopt (argc, argv, "n:r:sc")) != -1)
		switch (c)
		{
			case 'n': optarg_insert = optarg; bl_insert ++; break;
			case 'r': optarg_remove = optarg; bl_remove ++; break;
			case 's': bl_size ++; break;
			case 'c': bl_clear ++; break;
			default: return Help()-1;
		}

	if (bl_insert && bl_remove)
		return Help()-1;

	db_Read_File(db_fname);

	if (bl_size)
	{
		printf("%d", Length(sdb));
		return 0;
	}

	if (bl_clear)
	{
		ClearList(&sdb);
		db_Write_File(db_fname);
		return 0;	
	}

	if (bl_insert)
	{
		db_Insert(optarg_insert);		
		db_Write_File(db_fname);
		return 0;
	}
	
	if (bl_remove)
	{
		int i = atoi(optarg_remove);
		if (ListValidOrder(sdb, i))
			DeleteByOrder(&sdb, i);
		else
			fprintf(stderr, "Out of range\n");
		db_Write_File(db_fname);
		return 0;
	}

	db_Print(sdb);
	ClearList(&sdb);

	return 0;
}
void COpenSavedDlg::OnDestroy() 
{
	ClearList();

	CDialog::OnDestroy();	
}
Beispiel #29
0
bool MSQLiteReader::Destroy(void)
	{
	ClearList();
	ClearObject();
	return true;
	}
Beispiel #30
0
// Object bearbeiten ----------------------------------------------------------
int end_previous_object (void) 
{
long irc = 0L;

	lgi++;		/* Geometriezaehler korrigieren */
	if (lgi < koord_paare)
		return (db_error (EGCNT, ASCPARSER, yylineno));

// bevor irgend etwas passiert Header neu einlesen
	if (g_fReReadHeader) {
		DEXN_ReReadHeader();
		DEXN_ReScale();
		g_fReReadHeader = false;		// nur einmal
	}

// auswerten ob Komplexobjekt 
	if (lgi == 0) {
		if (RelCount() == 0)
			return db_error (EBADKO, ASCPARSER, yylineno);
		if (!r_flag)
			return EOKAY;	// keine Relationen, keine KomplexObjekte
		sta[0] = K_OBJEKT;	// Status setzen
		sta[1] = 0;		
	}

HPROJECT hPr = DEX_GetDataSourceHandle();

	_ASSERTE(NULL != hPr);
	irc = CreateObject (on, id, sta, mi, lgi, gxi, gyi);
	if (g_flag) {

	// evtl. ObjectGuid setzen
		if (irc && '\0' != guid[0]) {
		OBJECTGUID OUID;

			INITSTRUCT (OUID, OBJECTGUID);
			OUID.lONr = on;
			if (SUCCEEDED(CLSIDFromString (WideString(guid), &OUID.guid))) {
			// versuchen über GUID zu finden
				if (FAILED(DEX_FindObjectFromGuidEx (hPr, OUID))) {
				// alten Guid wieder setzen
				HRESULT hr = DEX_SetObjectGuid (OUID);

//					if (FAILED(hr) && HRESULT_FROM_ERRCODE(S_DUPLICATE) == hr) {
//						TX_ASSERT(0 != OUID.lONr);		// Objekt muß existieren
//
//					// GUID bereits in GeoDB vorhanden !!??
//						irc = S_DUPLICATE;
//
//					// neu erzeugtes Objekt löschen
//						DEX_DeleteObject (on);
//						CountObjects (sta[1], false);
//
//					// Geometrie an existierendem Objekt korrigieren
//						on = OUID.lONr;					// hier spielt die Musik
//						irc = CreateObject (on, id, sta, mi, lgi, gxi, gyi);
//					}
				}
			}
		}
	} else
		irc = UpdateFeatures (hPr, on, id, sta, mi);

// evtl. zur AusgabeObjektmenge hinzufügen
	if (irc && g_Enum.IsValid())
		g_Enum -> AddItem (on);

// Protocoll, Relationen etc.
bool fBreak = false;

	if (NULL != g_pDlg) {
		if (irc) 
			g_pDlg -> SetPos (ftell (yyin), on);
		fBreak = g_pDlg -> Break();
	}

	if (fpProt) fprintf (fpProt, "Satz %5ld, Objekt %5ld: Irc = %3ld\n", satz_nr, on, irc);

	if (irc && r_flag) {
		if (RelCount()) {
		// Relationen aufbauen
		long lONr, lRCode;
		short iRTyp;

			ResetList();
			while (RetrieveNextFromList (&lONr, &lRCode, &iRTyp)) 
				CreateRelation (on, lONr, lRCode, iRTyp);
			ClearList();
		}

	// Zuordnung Objekt <--> SatzNummer für Relationen merken
		StoreInTree (on, satz_nr);
	}

return fBreak;
}