⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booking.c

📁 MiniWinOuterSM MiniWinOuterSM
💻 C
字号:
// SubScribe.c: implementation of the SubScribe class.
//
//////////////////////////////////////////////////////////////////////

#include "booking.h"
#include "PrThread.h"
#include "PrMem.h"
static BOOKINGNOTIFY BookingNotify=NULL;
static BOOKING*Bookings=NULL;
static PRThread bkTask=NULL;
static PRMutex bkLock=NULL;

int BookingInit(void)
{
	bkLock=PrMutexCreate();
//	bkTask=PrThreadCreate(1024,64,BookingTaskProc,NULL);
	return 0;
}
int BookingTerm(void)
{
	//PrThreadDestroy(bkTask);
	PrMutexDestroy(bkLock);
	return 0;
}
void BookingRegisterNotify(BOOKINGNOTIFY notify)
{
	BookingNotify=notify;
}
static BOOKING*FindBooking(SERVICELOCATOR*sloc)
{
	BOOKING*sub=Bookings;
	while(sub){
		if( (sub->tsId==sloc->tsId)
			&&(sub->serviceId==sloc->serviceId)
			&&(sub->netId==sloc->netId))
			return sub;
		sub=sub->next;
	}
	return NULL;
}
int AddBookingItem(SERVICELOCATOR*sloc,unsigned short date,unsigned int time)
{
	BOOKING*sub;
	BOOKINGITEM*sitm;
	PrMutexLock(bkLock,-1);
	sub=FindBooking(sloc);
	if(sub==NULL){
		sub=(BOOKING*)PrMalloc(sizeof(BOOKING));
		sub->netId=sloc->netId;
		sub->tsId=sloc->tsId;
		sub->serviceId=sloc->serviceId;
		sub->next=Bookings;
		Bookings=sub;
	}
	sitm=(BOOKINGITEM*)PrMalloc(sizeof(BOOKINGITEM));
	sitm->date=date;
	sitm->startTime=time;
	sitm->next=sub->Items;
	sub->Items=sitm;
	PrMutexUnlock(bkLock);
	return 0;
}
int FindBookingItem(SERVICELOCATOR*sloc,unsigned short date,unsigned int time)
{
	int rc=0;
	BOOKING*bk;
	PrMutexLock(bkLock,-1);
	bk=FindBooking(sloc);
	if(bk){
		BOOKINGITEM*bi=bk->Items;
		while(bi){
			if((bi->date==date)&&(bi->startTime==time)){
				rc=1;break;
			}bi=bi->next;
		}
	}
	PrMutexUnlock(bkLock);
	return rc;
}
int DelBookingItem(SERVICELOCATOR*sloc,unsigned short date,unsigned int time)
{
	int rc=0;
	BOOKING*bk;
	PrMutexLock(bkLock,-1);
	bk=FindBooking(sloc);
	if(bk){
		BOOKINGITEM*bi=bk->Items;
		while(bi){
			if((bi->date==date)&&(bi->startTime==time)){
				rc=1;break;
			}bi=bi->next;
		}
	}
	PrMutexUnlock(bkLock);
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -