예제 #1
0
void contactDir_Deinit(contactDir * cd)
{
    List_Destroy(&cd->contactCache);
    List_Destroy(&cd->protoCache);
    List_Destroy(&cd->protoNameCache);
    DeleteCriticalSection(&cd->csLock);
}
예제 #2
0
void inspectFile (char * fileName, uuid_t uuid) {
	void * threadData = NULL;
	if (threadInit != NULL) {
		if (!threadInit(&threadData)) {
			rzb_log(LOG_ERR, "Couldn't run nugget inspection threadInit.");
			exit(-1);
		} else {
			rzb_log(LOG_DEBUG, "Thread init for nugget complete.");
		}
	}
	sleep(sleepTime);
	struct EventId * eventId;
	eventId = calloc(1,sizeof(struct EventId));
	struct Block * block = Block_Create ();
	struct List * list	= NTLVList_Create();
	struct stat st;
	stat(fileName, &st);
	//BlockPool_Init();
	block->pId->iLength = st.st_size;
	if (!Transfer_Prepare_File(block, fileName, false)) {
		rzb_log(LOG_ERR, "Trouble preparing file transfer - '%s'", fileName);
		Block_Destroy(block);
		free(eventId);
		List_Destroy(list);
		return;
	}
	Hash_Update(block->pId->pHash, block->data.pointer, block->pId->iLength);
	Hash_Finalize(block->pId->pHash);
	uuid_copy(block->pId->uuidDataType,uuid);
	struct ContextList * current = NULL;
	while (contextList != NULL) {
		current = contextList;
		uint8_t ret = function (block, eventId, list, threadData);
		if ( ret >= 0 ) {
			rzb_log(LOG_NOTICE, "Returned with: %u", ret);
		}
		if (current == contextList)
			break;
	}
	List_Destroy(list);
	/*Don't need to free/destroy as it's done with the judgment.
	 * Was needed previously because of cloning - cloning removed*/
	//Block_Destroy(block);
	//free(eventId);
	if (threadCleanup != NULL) {
		threadCleanup(threadData);
	}
}
void CSmileyString::DestroySmileyList()
{
	//ASSERT( plText == NULL );

	if (plText == NULL) return;

	if (IsBadReadPtr(plText, sizeof(SortedList))) {
		plText = NULL;
		return;
	}

	if (plText->realCount != 0) {
		for (int i = 0; i < plText->realCount; i++) {
			if (plText->items[i] != NULL) {
				ClcContactTextPiece *piece = (ClcContactTextPiece *)plText->items[i];

				if (!IsBadWritePtr(piece, sizeof(ClcContactTextPiece))) {
					if (piece->type == TEXT_PIECE_TYPE_SMILEY && piece->smiley != g_hListeningToIcon)
						DestroyIcon_protect(piece->smiley);
					mir_free(piece);
				}
			}
		}
		List_Destroy(plText);
	}
	mir_free(plText);

	plText = NULL;
}
예제 #4
0
void Cache_DestroySmileyList( SortedList* p_list )
{
	if ( p_list == NULL )
		return;

	if ( p_list->items != NULL )
	{
		int i;
		for ( i = 0 ; i < p_list->realCount ; i++ )
		{
			if ( p_list->items[i] != NULL )
			{
				ClcContactTextPiece *piece = (ClcContactTextPiece *) p_list->items[i];

				if (!IsBadWritePtr(piece, sizeof(ClcContactTextPiece)))
				{
				if (piece->smiley)
					DestroyIcon(piece->smiley);

					mir_free(piece);
				}
			}
		}
	}

	List_Destroy( p_list );
}
예제 #5
0
void FreeDisplayNameCache(SortedList *list)
{
	int i;

	for(i=0;i<(list->realCount);i++)
	{
		pdisplayNameCacheEntry pdnce;
		pdnce=list->items[i];
		if (pdnce&&pdnce->name) mir_free(pdnce->name);
		pdnce->name=NULL;
		//if (pdnce&&pdnce->szProto) mir_free(pdnce->szProto);//proto is system string
		if (pdnce&&pdnce->szGroup) mir_free(pdnce->szGroup);
		if (pdnce&&pdnce->MirVer) mir_free(pdnce->MirVer);

		mir_free(pdnce);
	};
	gdnc++;		
	//mir_free(displayNameCache);
	//displayNameCache=NULL;
	//displayNameCacheSize=0;

	List_Destroy(list);
	list=NULL;

}
TI_STATUS TrafficMonitor_Destroy(TI_HANDLE hTrafficMonitor)
{
	TrafficMonitor_t *TrafficMonitor = (TrafficMonitor_t*)hTrafficMonitor;

	if (TrafficMonitor) {
		/*Unregister from the RX/TX module for the required notification*/
		txCtrlParams_UnRegNotif(TrafficMonitor->hTxCtrl,TrafficMonitor->TxRegReqHandle);
		rxData_UnRegNotif(TrafficMonitor->hRxData,TrafficMonitor->RxRegReqHandle);

		if (TrafficMonitor->NotificationRegList) {
			List_Destroy(TrafficMonitor->NotificationRegList);
		}

		if (TrafficMonitor->hTrafficMonTimer) {
			tmr_DestroyTimer (TrafficMonitor->hTrafficMonTimer);
		}

#ifdef TRAFF_TEST
		if (TestEventTimer) {
			tmr_DestroyTimer (TestEventTimer);
		}
#endif

		os_memoryFree(TrafficMonitor->hOs, TrafficMonitor, sizeof(TrafficMonitor_t));

		return TI_OK;
	}

	return TI_NOK;
}
예제 #7
0
void CarListDestroy() {
	if (CarList != NULL) {
		List_Destroy(CarList);
	}
	if(TempCar!=NULL){
		Car_Destroy(TempCar);
	}
}
예제 #8
0
void UnloadButtonModule()
{
	if ( !bModuleInitialized ) return;
    EnterCriticalSection(&csTips);
	List_Destroy(&lToolTips);
    LeaveCriticalSection(&csTips);
	DeleteCriticalSection(&csTips);
}
예제 #9
0
void FreeDisplayNameCache(SortedList *list)
{
	for (int i = 0; i < list->realCount; i++) {
		FreeDisplayNameCacheItem((ClcCacheEntry*)list->items[i] );
		mir_free(list->items[i]);
	}

	List_Destroy(list);
}
예제 #10
0
파일: Utils.cpp 프로젝트: martok/miranda-ng
void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
{																			
	int i=0;
	if (!pList)
		return;
	for (i=0; i<pList->realCount; i++)
		pItemDestructor(pList->items[i]);	
	List_Destroy(pList);																											
	mir_free(pList);
}
예제 #11
0
파일: hash.c 프로젝트: JTReed/OSUndergrad
/* Destruction is not thread-safe */
void Hash_Destroy(hash_t *hash)
{
	while(hash->buckets > 0)
	{
		List_Destroy(&hash->bucket_list[--hash->buckets]);
	}

	/* hash->buckets should be zero at this point */
	free(hash->bucket_list);
}
예제 #12
0
void Car_Destroy(PTCar car) {

	if (car != NULL) {

		List_Destroy(car->axles);

		free(car);
		car = NULL;

	}
}
예제 #13
0
void ShutdownConsole(void)
{
	int i;

	List_Destroy(&lModules);

	if (gImg) ImageList_Destroy(gImg);

	for(i = 0; i < SIZEOF(hIcons); i++) {
		if (hIcons[i]) DestroyIcon(hIcons[i]);
	}
}
예제 #14
0
void DestroyModularEngine(void)
{
	int i;
	//EnterCriticalSection( &csHooks );
	for( i=0; i < hooks.count; i++ ) {
 		if ( hooks.items[i]->subscriberCount )
			free( hooks.items[i]->subscriber );
		free( hooks.items[i] );
	}
	List_Destroy(( SortedList* )&hooks );
	//LeaveCriticalSection( &csHooks );
	//DeleteCriticalSection( &csHooks );

	//EnterCriticalSection( &csServices );
	for ( i=0; i < services.count; i++ )
		free( services.items[i] );

	List_Destroy(( SortedList* )&services );
	//LeaveCriticalSection( &csServices );
 	//DeleteCriticalSection( &csServices );
	//CloseHandle( hMainThread );
}
예제 #15
0
TI_STATUS DistributorMgr_Destroy(TI_HANDLE hDistributorMgr)
{
	DistributorMgr_t *DistributorMgr =(DistributorMgr_t*)hDistributorMgr;

	if (DistributorMgr == NULL)
		return TI_NOK;

	List_Destroy(DistributorMgr->DistributionList);

	os_memoryFree(DistributorMgr->hOs, hDistributorMgr, sizeof(DistributorMgr_t));

	return TI_OK;

}
예제 #16
0
SO_PUBLIC void
Block_Destroy (struct Block *p_pBlock)
{

    BlockId_Destroy (p_pBlock->pId);

    if (p_pBlock->pParentId != NULL)
    {
        BlockId_Destroy (p_pBlock->pParentId);
    }

    if (p_pBlock->pMetaDataList != NULL)
        List_Destroy (p_pBlock->pMetaDataList);

    free(p_pBlock);
}
예제 #17
0
//计算员工usrID在给定时间区间的销售额,返回销售额
inline int Salesanalysis_Srv_CompSaleVal(int usrID, user_date_t stDate, user_date_t endDate){
	
	int amount=0;
	
	sale_list_t saleList;
	sale_list_t pSale;
	
	List_Init(saleList,sale_node_t);//初始化链表
	Sale_Perst_SelectByUsrID(saleList,usrID,stDate,endDate); //调用销售信息,构建链表
	
	List_ForEach(saleList,pSale){	//遍历链表 
		amount+=pSale->data.value;	//累加售票额 
	} 
	List_Destroy(saleList,sale_node_t);
	return amount;
}
예제 #18
0
void Chtbl_Destroy(CHTbl *htbl)
{
    int i;

	//销毁每个桶存储的链表
    for (i = 0; i < htbl->buckets; i++)
    {
        List_Destroy(&htbl->table[i]);
    }

	//释放存储每个桶的数组的内存
    free(htbl->table);
    memset(htbl, 0 , sizeof(CHTbl));

    return;
}
예제 #19
0
int main(void)
{
    List* list = List_Create();

    int i = 0;
    int j = 1;
    int k = 2;

    List_Insert(list, &i, 0);
    List_Insert(list, &j, 1);
    List_Insert(list, &k, 2);

    List_Clear(list);

    List_Destroy(list);

    return 0;
}
예제 #20
0
파일: Utils.cpp 프로젝트: martok/miranda-ng
void DestructButtonsList()
{
	int i=0;
	//	for ( i=0; i < g_iButtonsCount; i++ )
	while(ButtonsList[i])
	{
		li_ListDestruct(ButtonsList[i]->sl,listdestructor);
		mir_free(ButtonsList[i]->ptszButtonName);
		if(ButtonsList[i]->ptszOPQValue!=ButtonsList[i]->ptszQValue)
			if (ButtonsList[i]->ptszOPQValue) mir_free(ButtonsList[i]->ptszOPQValue);
		if (ButtonsList[i]->ptszQValue) mir_free(ButtonsList[i]->ptszQValue);
		i++;	
	}
	if(QuickList)
	{
		li_ZeroQuickList(QuickList);
		List_Destroy(QuickList);
	}
}
예제 #21
0
/*
 * discard the list of lines associated with a file. this will cause
 * the file to be re-read next time file_getlinelist is called.
 */
void
file_discardlines(FILEDATA fd)
{
    LINE line;

    if (fd == NULL) {
        return;
    }

    if (fd->lines != NULL) {

        /* clear each line to free any memory associated
         * with them, then discard the entire list
         */
		for( line=(LINE)List_First(fd->lines);  line!=NULL;  line = (LINE)List_Next((LPVOID)line)) {
            line_delete(line);
        }
        List_Destroy(&fd->lines);
    }

    /* this is probably done in List_Destroy, but better do it anyway*/
    fd->lines = NULL;
}
예제 #22
0
파일: Sale1.c 프로젝트: dongmengyuan/linuxc
void Sale_UI_MgtEntry() {
	int i, id;
	char choice;

	schedule_list_t head;
	//schedule_node_t *p;
	schedule_node_t *p;
	Pagination_t paging;

	List_Init(head, schedule_node_t);
	//List_Init(head,schedule_node_t);
	
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchAll(head);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n		=================================================================");
        	printf("\n		**************************剧目%s的演出计划*************************");
          	printf("\n		=================================================================");
		printf("\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s\n", "ID", "剧目编号", "演出厅编号",
		 "上映日期","上映时间","票价");
		printf("\n		-----------------------------------------------------------------");
		
		//显示数据
		
			for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
				printf("%5d  『%d』%20s  『%d』%2s ", p->data.id, p->data.play_id, p->data.play_name,p->data.studio_id, p->data.studio_name);
				printf("  %4d-%02d-%02d",p->data.date.year, p->data.date.month, p->data.date.day);
				printf("\t%2d:%02d:%02d ", p->data.time.hour, p->data.time.minute, p->data.time.second);
				printf("\t%5d\n", p->data.price);
				p=p->next;
		}

		printf("\n		==================================================================");
        	printf("\n		|----------总数%2d------------------------------%2d/%2d页---------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n		******************************************************************");
        	printf("\n		|        [P]revPage          |              [N]extPage          |");
		printf("\n		-----------------------------------------------------------------");
		printf("\n		|         [I]D List    	  |             [R]eturn              |");
		printf("\n		******************************************************************");
		printf("\n		==================================================================");
		printf("\n		Iput Your choice:");
		choice=l_getc();
	

		switch (choice) {
		case 'i':
		case 'D':
				
				printf("\n		|     请输入演出计划ID:");
				while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin(); printf("\n		                    **您的输入有误!**");}
				}
				Sale_UI_ShowScheduler(id);
			
				break;
		case 'p':
        case 'P':
			system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,schedule_node_t);
            }
			break;
		case 'n':
        case 'N':
		system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
		}

	
} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
예제 #23
0
void test_algorithm(void)
{
    int padding = 1;
    list_t *imageList = NULL;
    btree_t *tree;
    list_t *treeDumpList = NULL;
    list_t *fileListIter = NULL;
    int i = 0;
    char filename[10];
    int success = 1;
    int initsize = 512;
    
    srand((unsigned int)time(NULL));
        
    for (i = 0; i < 2800; i++)
    {
        list_t *node = NULL;
        image_t *img = NULL;
        img = (image_t *)calloc(1, sizeof(image_t));
        node = List_Create();
        
        sprintf(filename, "%d.png", i);
        
        img->w = 5 + rand() % 20;
        img->h = 5 + rand() % 20;
        Util_CopyString(&img->filename, filename);
        
        node->payload.type = Payload_Image;
        node->payload.data = img;
        
        List_PushFront(&imageList, node);
    }
    
    List_Sort(&imageList);
    
    tree = BTree_Create();
    tree->rect.x = 0;
    tree->rect.y = 0;
    tree->rect.w = initsize;
    tree->rect.h = initsize;
    
    do
    {
        success = 1;
        
        for (fileListIter = imageList; fileListIter != NULL; fileListIter = fileListIter->next)
        {   
            if (BTree_Insert(tree, (image_t *)fileListIter->payload.data, padding) == NULL)
            {
                printf("Shit happens\n");
                success = 0;
                break;
            }
        }
        
        if (!success)
        {
            BTree_Destroy(tree);
            tree = BTree_Create();
            tree->rect.x = 0;
            tree->rect.y = 0;
            initsize = Util_NextPOT(initsize+1);
            tree->rect.w = initsize;
            tree->rect.h = initsize;
        }
        
    } while (!success);
    
    printf("-----\n");
    List_Destroy(imageList, ListDestroy_List|ListDestroy_PayLoad);
    
    treeDumpList = BTree_DumpToList(tree, BTreeTraverse_PostOrder);
    
    {
        list_t *iter = NULL;
        bitmap_t *canvas = NULL;
        rect_t *rect = NULL;
        
        canvas = Bitmap_Create(initsize, initsize);
        
        iter = treeDumpList;
        for (iter = treeDumpList; iter != NULL; iter = iter->next)
        {
            rect = (rect_t *)iter->payload.data;
            if (rect->image != NULL && rect->image->filename != NULL)
            {
                int argb = 0;
                bitmap_t *pad = NULL;
                bitmap_t *png = NULL;
                png = Bitmap_Create(rect->image->w, rect->image->h);
                pad = Bitmap_Create(rect->image->w + rect->padding * 2, rect->image->h + rect->padding * 2);
                argb = rand();
                argb |= 0xFF000000;
                Bitmap_Clean(png, argb);
                Bitmap_Clean(pad, 0);
                Bitmap_CopyPasteBitmap(pad, png, rect->padding, rect->padding);
                Bitmap_CopyPasteBitmap(canvas, pad, rect->x, rect->y);
                Bitmap_Destroy(png);
                Bitmap_Destroy(pad);
            }
        }
        
        Bitmap_WriteAsPNG(canvas, "canvas.png");
        Bitmap_Destroy(canvas);
    }
    
    List_Destroy(treeDumpList, ListDestroy_List);
    
    if (tree != NULL)
        BTree_Destroy(tree);
    
    memtrack_list_allocations();
}
예제 #24
0
void packpng(void)
{
    list_t *pngFileList = NULL;
    list_t *fileListIter = NULL;
    btree_t *tree = NULL;
    list_t *treeDumpList = NULL;
    
    pngFileList = Util_ReadAllPNGs();
    
    tree = BTree_Create();
    tree->rect.x = 0;
    tree->rect.y = 0;
    tree->rect.w = 512;
    tree->rect.h = 512;
    
    for (fileListIter = pngFileList; fileListIter != NULL; fileListIter = fileListIter->next)
    {
        if (BTree_Insert(tree, (image_t *)fileListIter->payload.data, 0) == NULL)
        {
            printf("Enlarge needed\n");
        }
    }
    
    treeDumpList = BTree_DumpToList(tree, BTreeTraverse_PreOrder);
    printf("-----\n");
    List_Print(treeDumpList);
    
    {
        list_t *iter = NULL;
        bitmap_t *canvas = NULL;
        rect_t *rect = NULL;
        
        canvas = Bitmap_Create(512, 512);
        
        iter = treeDumpList;
        for (iter = treeDumpList; iter != NULL; iter = iter->next)
        {
            rect = (rect_t *)iter->payload.data;
            if (rect->image != NULL && rect->image->filename != NULL)
            {
                bitmap_t *png = Bitmap_CreateFromPNG(rect->image->filename);
                printf("        %d - %d %s\n", rect->x, rect->y, rect->image->filename);
                Bitmap_CopyPasteBitmap(canvas, png, rect->x, rect->y);
                Bitmap_Destroy(png);
            }
        }
        
        Bitmap_WriteAsPNG(canvas, "canvas.png");
        Bitmap_Destroy(canvas);
    }
    
    {
        Util_CompileRects(treeDumpList, FileFormat_Lua, "digits");
    }
    
    printf("-----\n");
    List_Destroy(treeDumpList, ListDestroy_List);
    
    if (pngFileList != NULL)
        List_Destroy(pngFileList, ListDestroy_List|ListDestroy_PayLoad);
    
    if (tree != NULL)
        BTree_Destroy(tree);
    
    memtrack_list_allocations();
}
예제 #25
0
void Studio_UI_MgtEntry(void) {
	int i, id;
	char choice;

	studio_list_t head;
	studio_node_t *pos;
	Pagination_t paging;

	List_Init(head, studio_node_t);
	paging.offset = 0;
	paging.pageSize = STUDIO_PAGE_SIZE;

	//��������
	paging.totalRecords = Studio_Srv_FetchAll(head);
	Paging_Locate_FirstPage(head, paging);

	do {
		/*system("cls");*/
		printf("\n==================================================================\n");
		printf("********************** Projection Room List **********************\n");
		printf("%5s  %18s  %10s  %10s  %10s\n", "ID", "Name", "Rows Count",
				"Columns Count", "Seats Count");
		printf("------------------------------------------------------------------\n");
		//��ʾ����
		for (i = 0, pos = (studio_node_t *) (paging.curPos);
				pos != head && i < paging.pageSize; i++) {
			printf("%5d  %18s  %10d  %10d  %10d\n", pos->data.id,
					pos->data.name, pos->data.rowsCount, pos->data.colsCount,
					pos->data.seatsCount);
			pos = pos->next;
		}
		printf("------- Total Records:%2d ----------------------- Page %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf(
				"******************************************************************\n");
		printf(
				"[P]revPage|[N]extPage | [A]dd|[D]elete|[U]pdate | [S]eat | [R]eturn");
		printf(
				"\n==================================================================\n");
		printf("Your Choice:");
		fflush(stdin);
		scanf("%c", &choice);
		fflush(stdin);

		switch (choice) {
		case 'a':
		case 'A':
			if (Studio_UI_Add()) //����ӳɹ����������һҳ��ʾ
			{
				paging.totalRecords = Studio_Srv_FetchAll(head);
				Paging_Locate_LastPage(head, paging, studio_node_t);
			}
			break;
		case 'd':
		case 'D':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Delete(id)) {	//������������
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 'u':
		case 'U':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Modify(id)) {	//������������
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 's':
		case 'S':
			printf("Input the ID:");
			scanf("%d", &id);
			Seat_UI_MgtEntry(id);
			paging.totalRecords = Studio_Srv_FetchAll(head);
			List_Paging(head, paging, studio_node_t);
			break;
		case 'p':
		case 'P':
			if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, studio_node_t);
			}
			break;
		case 'n':
		case 'N':
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, studio_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//�ͷ�����ռ�
	List_Destroy(head, studio_node_t);
}
예제 #26
0
파일: list.c 프로젝트: moyuanming/XJZRYK
void Stack_Destroy(PTStack pl) {
	List_Destroy(pl);
}
예제 #27
0
static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TFtPageData *dat = (struct TFtPageData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	int i;

	switch (msg) {
	case WM_INITDIALOG:
		{
			// Force scrollbar visibility
			SCROLLINFO si = {0};
			si.cbSize = sizeof(si);
			si.fMask = SIF_DISABLENOSCROLL;
			SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

			dat = (struct TFtPageData *)mir_alloc(sizeof(struct TFtPageData));
			dat->wnds = (struct TLayoutWindowList *)List_Create(0, 1);
			dat->scrollPos = 0;
			dat->runningCount = 0;
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
		}
		break;

	case WM_FT_ADD:
		{
			TLayoutWindowInfo *wnd = (struct TLayoutWindowInfo *)mir_alloc(sizeof(struct TLayoutWindowInfo));
			wnd->hwnd = (HWND)lParam;
			GetWindowRect(wnd->hwnd, &wnd->rc);
			List_Insert((SortedList *)dat->wnds, wnd, dat->wnds->realCount);
			LayoutTransfers(hwnd, dat);
			dat->runningCount++;
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
		}
		break;

	case WM_FT_RESIZE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				GetWindowRect(dat->wnds->items[i]->hwnd, &dat->wnds->items[i]->rc);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_REMOVE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				mir_free(dat->wnds->items[i]);
				List_Remove((SortedList *)dat->wnds, i);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_COMPLETED:
		//wParam: { ACKRESULT_SUCCESS | ACKRESULT_FAILED | ACKRESULT_DENIED }
		dat->runningCount--;
		for (i=0; i < dat->wnds->realCount; i++) {
			// no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				SendMessage(GetParent(hwnd), WM_TIMER, 1, (LPARAM)wParam);
				break;
			}
		}
		if (i == dat->wnds->realCount)
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);

		if(dat->runningCount == 0 && wParam == ACKRESULT_SUCCESS && db_get_b(NULL, "SRFile", "AutoClose", 0))
			ShowWindow(hwndFtMgr, SW_HIDE);
		break;

	case WM_FT_CLEANUP:
		for (i=0; i < dat->wnds->realCount; ++i)
			SendMessage(dat->wnds->items[i]->hwnd, WM_FT_CLEANUP, wParam, lParam);
		break;

	case WM_SIZE:
		LayoutTransfers(hwnd, dat);
		break;

	case WM_MOUSEWHEEL:
		{
			int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
			if (zDelta) {
				int nScrollLines = 0;
				SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
				for (i=0; i < (nScrollLines + 1) / 2; i++)
					SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
			}

			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, 0);
			return TRUE;
		}

	case WM_VSCROLL:
		{
			int pos = dat->scrollPos;
			switch (LOWORD(wParam)) {
			case SB_LINEDOWN:
				pos += 15;
				break;
			case SB_LINEUP:
				pos -= 15;
				break;
			case SB_PAGEDOWN:
				pos += dat->height - 10;
				break;
			case SB_PAGEUP:
				pos -= dat->height - 10;
				break;
			case SB_THUMBTRACK:
				pos = HIWORD(wParam);
				break;
			}

			if (pos > dat->dataHeight - dat->height) pos = dat->dataHeight - dat->height;
			if (pos < 0) pos = 0;

			if (dat->scrollPos != pos) {
				ScrollWindow(hwnd, 0, dat->scrollPos - pos, NULL, NULL);
				SetScrollPos(hwnd, SB_VERT, pos, TRUE);
				dat->scrollPos = pos;
			}
			break;
		}

	case M_PRESHUTDOWN:
		for (i=0; i < dat->wnds->realCount; ++i)
			PostMessage(dat->wnds->items[i]->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
		break;

	case M_CALCPROGRESS:
		{
			TFtProgressData *prg = (TFtProgressData *)wParam;
			for (i=0; i < dat->wnds->realCount; ++i) {
				FileDlgData *trdat = (FileDlgData *)GetWindowLongPtr(dat->wnds->items[i]->hwnd, GWLP_USERDATA);
				if (trdat->transferStatus.totalBytes && trdat->fs && !trdat->send && (trdat->transferStatus.totalBytes == trdat->transferStatus.totalProgress))
					prg->scan++;
				else if (trdat->transferStatus.totalBytes && trdat->fs) { // in progress
					prg->run++;
					prg->totalBytes += trdat->transferStatus.totalBytes;
					prg->totalProgress += trdat->transferStatus.totalProgress;
				}
				else if (trdat->fs) // starting
					prg->init++;
			}
		}
		break;

	case WM_DESTROY:
		for (i=0; i < dat->wnds->realCount; ++i)
			mir_free(dat->wnds->items[i]);
		List_Destroy((SortedList *)dat->wnds);
		mir_free(dat->wnds);
		mir_free(dat);
		break;
	}

	return FALSE;
}
예제 #28
0
void RichUtil_Unload(void)
{
	List_Destroy(&sListInt);
}
예제 #29
0
void Studio_UI_MgtEntry(int flag){
    int i,id;
    char choice;
    studio_list_t head;
    head = (studio_list_t)malloc(sizeof(studio_node_t));
    head->prev = head->next = head;
    studio_node_t *pos;
    Pagination_t paging;
    paging.offset=0;
    paging.pageSize=STUDIO_PAGE_SIZE;
    paging.totalRecords=Studio_Srv_FetchAll(head);
    Paging_Locate_FirstPage(head,paging);
    do{
        system("clear");
        printf("\n\n\n\t\t\t==================================================================");
        printf("\n\t\t\t*************************演出厅列表*******************************");
        printf("\n\t\t\t==================================================================");
        printf("\n\t\t\t%s\t%s\t\t%s\t\t%s\t\t%s","ID","ROOM","SIZE","MODE","SEAT");
        printf("\n\t\t\t-----------------------------------------------------------------");
        //改变了数据类型,注意!汉字的输入会导致格式问题
		for (i = 0, pos = (studio_node_t *) (paging.curPos);pos != head && i < paging.pageSize; i++){
           // printf("\n%d--%d\n",strlen(pos->data.MOD),strlen(pos->data.SEAT));
            printf("\n\t\t\t%-8d%-16s%-16s%-16s%-10s\n",pos->data.id,pos->data.ROOM,pos->data.SIZE,pos->data.MOD,pos->data.SEAT);
            pos= pos->next;
        		}
   
        printf("\n		\t==================================================================");
        printf("\n		\t|----------总数%2d------------------------------%2d/%2d页-----------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
        printf("\n		\t==================================================================");
        printf("\n		\t******************************************************************");
        printf("\n\t\t\t[P]revPage|[N]extPage |[A]dd |[D]elete |[U]pdate |[S]eat |[R]eturn");
        printf("\n		\t******************************************************************");
        printf("\n\t\t\tYour choice:");
        scanf("%c",&choice);
        switch(choice){            
	        case 'p':
            case 'P':
            system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,studio_node_t);
            }
            break;
            case 'n':
            case 'N':
            system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,studio_node_t);
            }
            break;
            case 'A':
            case 'a':
            system("clear");
            if(Studio_UI_Add()){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                Paging_Locate_LastPage(head,paging,studio_node_t);
            }
            break;
            case 'd':
            case 'D':
            getchar();
            printf("\t\t\tInput the Room ID:");
            
        scanf("%d",&id);
            if(Studio_UI_Delete(id)){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                List_Paging(head,paging,studio_node_t);
            }
            break;
            case 'u':
            case 'U':
            getchar();
            printf("\t\t\tInput the Room ID:");
            scanf("%d",&id);
            system("clear");
            if(Studio_UI_Modify(id)){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                List_Paging(head,paging,studio_node_t);
            }
            break;
            case 's':
            case 'S':
            getchar();
            printf("\t\t\tInput the Room ID:");
            scanf("%d",&id);
            system("clear");
            Seat_UI_MgtEntry(id,flag);
            paging.totalRecords=Studio_Srv_FetchAll(head);
            List_Paging(head,paging,studio_node_t);
            break;  
        }
    }while(choice !='r'&& choice !='R');     //必须&&
    List_Destroy(head,studio_node_t);
}
예제 #30
0
파일: Sale1.c 프로젝트: dongmengyuan/linuxc
//根据剧目ID显示演出计划
void Sale_UI_ShowScheduler(int playID) {
	int i, id;
	char choice;
	
	play_t pdata;
	ticket_list_t tickList;
	seat_list_t   seatList;
	
	schedule_list_t head;
	schedule_node_t *p;
	Pagination_t paging;
	
	Play_Srv_FetchByID(playID, &pdata);
	
	List_Init(head, schedule_node_t);
	
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchByPlay(head,playID);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n		=================================================================");
        	printf("\n		**************************剧目%s的演出计划*************************");
          	printf("\n		=================================================================");
		printf("\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s\n", "ID", "剧目编号", "演出厅编号",
		 "上映日期","上映时间","票价");
		printf("\n		-----------------------------------------------------------------");
		
		if(!List_IsEmpty(head)){
			//显示数据
			for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
				printf("%5d  『%d』%20s  『%d』%2s ", p->data.id, p->data.play_id, p->data.play_name,p->data.studio_id, p->data.studio_name);
				printf("  %4d-%02d-%02d",p->data.date.year, p->data.date.month, p->data.date.day);
				printf("\t%2d:%02d:%02d ", p->data.time.hour, p->data.time.minute, p->data.time.second);
				printf("\t%5d\n", p->data.price);
			}
		}else{
		
			printf("\n		                    **没有演出厅信息!**");
			printf("\n		==================================================================");
		}
		printf("\n		==================================================================");
        	printf("\n		|----------总数%2d------------------------------%2d/%2d页---------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n		******************************************************************");
        	printf("\n		|       [P]revPage          |              [N]extPage          |");
		printf("\n		-----------------------------------------------------------------");
		printf("\n		|         [S]ale       	  |             [R]eturn              |");
		printf("\n		******************************************************************");
		printf("\n		==================================================================");
		printf("\n		Iput Your choice:");
		choice=l_getc();
	

		switch (choice) {
			
		case 's':
		case 'S':
			{
				
				
				
				List_Init(tickList, ticket_node_t);
				List_Init(seatList,   seat_node_t);
				
				
			
			
				Sale_UI_SellTicket(tickList,seatList);
				
				List_Destroy(tickList, ticket_node_t);
				List_Destroy(seatList,   seat_node_t);
			}
			break;
		case 'p':
        case 'P':
			system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
			break;
		case 'n':
        case 'N':
			 system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}