?? booking.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 + -