Beispiel #1
0
void test(){
    /*
    测试链表函数

    测试结果:全部函数运行通过


    */

    List A;
    int a[]={1,2,3,4};
    List B;
    int b[]={5,6,7,8,9};
    List_Init(&A);
    List_Init(&B);
    List_creat(&A,a,4);
    List_creat(&B,b,5);
    printf("\nA:");
    List_printf(&A);
    printf("\nB:");
    List_printf(&B);
    List_Insert(&A,1,2);
    printf("\nA:");
    List_printf(&A);
    printf("\nA length:%d",List_getLength(&A));
    List_clear(&B);
    printf("\nB:");
    List_printf(&B);
    List_destroy(&B);



}
Beispiel #2
0
void Interpreter_Init(Interpreter *pinterpreter, LPCSTR name, List *pflist)
{
    memset(pinterpreter, 0, sizeof(Interpreter));
    StackedSymbolTable_Init(&(pinterpreter->theSymbolTable), name);
    Parser_Init(&(pinterpreter->theParser));
    pinterpreter->ptheFunctionList = pflist;
    List_Init(&(pinterpreter->theImportList));
    List_Init(&(pinterpreter->theInstructionList));
    List_Init(&(pinterpreter->paramList));
    Stack_Init(&(pinterpreter->theDataStack));
    Stack_Init(&(pinterpreter->theLabelStack));
    pp_context_init(&(pinterpreter->theContext));
}
Beispiel #3
0
//结合剧目Play.dat,统计销售数据,构建销售分析salesanalysis_list_t list链表,返回list链表长度
int Salesanalysis_Srv_StaticSale(salesanalysis_list_t list) {
	
	int count=0;
	int sold;	//已售票数 
	int total;	//总票数 
	assert(NULL!=list) ;
	play_list_t playList,pos;
	
	salesanalysis_node_t *newNode;
	

	List_Free(list,salesanalysis_node_t);//释放所有数据结点 
	List_Init(playList,play_node_t);//初始化 
	Play_Srv_FetchAll(playList);//载入剧目信息,构建链表
	
	List_ForEach(playList,pos){ 
		 
		newNode=(salesanalysis_node_t *)malloc(sizeof(salesanalysis_node_t));
		if(!newNode){
			break;
		}
		newNode->data.play_id=pos->data.id;	//剧目信息 
		newNode->data.start_date=pos->data.start_date;
		newNode->data.end_date=pos->data.end_date;
		
		newNode->data.sales=Schedule_Srv_StatRevByPlay(pos->data.id,&sold,&total);
		newNode->data.totaltickets=sold;
		List_AddTail(list,newNode);
		count++;
	}
Beispiel #4
0
Namespace *
_Class_New ( byte * name, uint64 type, int32 cloneFlag )
{
    Namespace * ns = _Namespace_Find ( name, 0, 0 ), * sns ;
    int32 size = 0 ;
    if ( ! ns )
    {
        //if ( type == C_TYPE ) sns = _Namespace_Find ( "C_Syntax", 0, 1 ) ;
        //else 
        sns = _CfrTil_Namespace_InNamespaceGet ( ) ;
        if ( cloneFlag )
        {
            size = _Namespace_VariableValueGet ( sns, ( byte* ) "size" ) ;
        }
        ns = _DObject_New ( name, 0, CPRIMITIVE | CLASS | IMMEDIATE | type, 0, type, ( byte* ) _DataObject_Run, 0, 0, sns, DICTIONARY ) ;
        _Namespace_DoNamespace ( ns, 1 ) ; // before "size", "this"
        _CfrTil_Variable_New ( ( byte* ) "size", size ) ; // start with size of the prototype for clone
        _Context_->Interpreter0->ThisNamespace = ns ;
        _Class_Object_New ( ( byte* ) "this", THIS | NAMESPACE_VARIABLE ) ;
    }
    else
    {
        Printf ( ( byte* ) "\nNamespace Error ? : class \"%s\" already exists!\n", ns->Name ) ;
        _Namespace_DoNamespace ( ns, 1 ) ;
    }
    //Stack_Init ( _Context_->Compiler0->WordStack ) ; // try to keep WordStack to a minimum
    List_Init ( _Context_->Compiler0->WordList ) ; // try to keep WordStack to a minimum
    return ns ;
}
Beispiel #5
0
int display(int flag,char *path)  //文件目录解析函数,获取当前目录所有文件
{
    int i=0,j,count=0;
    DIR *dir;
    struct dirent *ptr;
    char cwd[256];
    getcwd(cwd,256);
    chdir(path);
    str_node_t *newNode,*head;
    List_Init(head,str_node_t);
    if((dir=opendir(path))==NULL)
    {
        perror("opendir");
        return -1;
    }
    while((ptr=readdir(dir))!=NULL)
    {
        i++;
        newNode=(str_node_t *)malloc(sizeof(str_node_t));
        strcpy(newNode->str,ptr->d_name);
        List_AddHead(head,newNode); //头插法建立新链表
    }
    count=i;
    print_info_srv(count,flag,head);
    closedir(dir);
    chdir(cwd);
}
Beispiel #6
0
void
Fsconsist_ClientInit()
{
    Sync_LockInitDynamic(&clientLock, "Fs:clientLock");
    List_Init(&masterClientListHdr);
    masterClientList = &masterClientListHdr;
}
Beispiel #7
0
void
Timer_Init()
{
    static	Boolean	initialized	= FALSE;

    Sync_SemInitDynamic(&timerMutex,"Timer:timerMutex");

    if (initialized) {
	printf("Timer_Init: Timer module initialized more that once!\n");
    }
    initialized = TRUE;

    TimerTicksInit();

    bzero((Address) &timer_Statistics, sizeof(timer_Statistics));

    timerQueueList = (List_Links *) Vm_BootAlloc(sizeof(List_Links));
    List_Init(timerQueueList);

    /*
     * Initialized the time of day clock.
     */
    TimerClock_Init();
    Timer_TimerInit(TIMER_CALLBACK_TIMER);
    Timer_TimerStart(TIMER_CALLBACK_TIMER);
}
Beispiel #8
0
// -----------------------------------------------------------------------------
// IMPLEMENTATION
// -----------------------------------------------------------------------------
static int Imo2sproxy_Open(IMO2SPROXY *hInst)
{
	IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)hInst;
	WNDCLASS WndClass ={0}; 

	// Start Skype connection 
	if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
		fprintf (hProxy->pCfg->fpLog, "W32SkypeEmu:Open(Start)\n");
	if ((!m_ControlAPIAttach && !(m_ControlAPIAttach=RegisterWindowMessage("SkypeControlAPIAttach"))) || 
		(!m_ControlAPIDiscover && !(m_ControlAPIDiscover=RegisterWindowMessage("SkypeControlAPIDiscover")))) 
	{
		hProxy->pCfg->logerror (stderr, "Cannot register Window messages!");
		return -1;
	}
  
	// Create window class
	WndClass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS; 
	WndClass.lpfnWndProc = (WNDPROC)WndProc; 
	WndClass.hInstance =  GetModuleHandle(NULL);
	WndClass.lpszClassName = "Imo2SProxyDispatchWindow"; 
	RegisterClass(&WndClass);

	if (!(hProxy->hWndDispatch=CreateWindowEx( WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,
		WndClass.lpszClassName, "", WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX,
		CW_USEDEFAULT, CW_USEDEFAULT, 128, 128, NULL, 0, (HINSTANCE)WndClass.hInstance, (LPVOID)hProxy)))
	{
		hProxy->pCfg->logerror (stderr, "Unable to create dispatch window!");
		UnregisterClass (WndClass.lpszClassName, WndClass.hInstance);
		return -1;
	}

	hProxy->hClients = List_Init(32);
	return 0;
}
Beispiel #9
0
void
Net_ArpInit()
{
    int i;

    Sync_LockInitDynamic(&arpOutputQueueLock, "Net:arpOutputQueueLock");
    Sync_SemInitDynamic(&arpInputMutex, "Net:arpInputMutex");
    Sync_SemInitDynamic(&arpListMutex, "Net:arpListMutex"); 
    /*
     * Mark the arp output queue as all done (output).
     */
    for (i=0; i<ARP_OUTPUT_QUEUE_LEN ; i++) {
	arpOutputQueue[i].gather.done = TRUE;
    }
    List_Init(&arpList);
    List_Init(&revArpList);
}
Beispiel #10
0
void SymbolTable_Init(SymbolTable * stable, LPCSTR theName) {
	List_Init(&(stable->SymbolList));
	stable->nextSymbolCount = 0;
	if(theName)
		strcpy(stable->name, theName);
	else
		stable->name[0] = 0;
}
Beispiel #11
0
void ob_inittrans()
{
    transList = malloc(sizeof(List));
    List_Init(transList);
    if(!ob_loadtrans())
    {
        ob_termtrans();
    }
}
Beispiel #12
0
int Ticket_Srv_AddBatch(int schedule_id, int studio_id){
	int rtn,i,key;
	ticket_node_t *p;
	seat_node_t  *q;
	ticket_list_t ticket_list;
	seat_list_t   seat_list;
	
	schedule_t scd;
	play_t pld;
	
	Schedule_Srv_FetchByID(schedule_id, &scd);
	Play_Srv_FetchByID( scd.play_id,  &pld);
	
	
	//Seat_Number_Count(studio_id);
	 List_Init(ticket_list, ticket_node_t);
	 
	 List_Init(seat_list,seat_node_t);
	 
	 rtn=Seat_Srv_FetchValidByRoomID(seat_list, studio_id);
	 key=EntKey_Srv_CompNewKeys("ticket",rtn);
	 //Seat_Srv_FetchByRoomID(seat_list,studio_id);
	  
	
	 q=seat_list->next;
	for(i=1;i<=rtn;i++)
	{
	   
	   p=(ticket_node_t *)malloc(sizeof(ticket_node_t));
	   p->data.id=key;
	   p->data.schedule_id=schedule_id;
	  	p->data.seat_id=q->data.id;
	   	p->data.price=pld.price;
	   	p->data.status=TICKET_AVL;
	   	List_AddTail(ticket_list,p);
	   	key++;
	   	q=q->next;
	   
	 }
	 
	
	   Ticket_Perst_Insert(ticket_list);
       	   return 1;
}
Beispiel #13
0
/* Initialization is not thread-safe */
void Hash_Init(hash_t *hash, int buckets)
{
	hash->buckets = buckets;
	hash->bucket_list = malloc(sizeof(list_t)*buckets);

	while(--buckets >= 0)
	{
		List_Init(&hash->bucket_list[buckets]);
	}
}
Beispiel #14
0
void
MigPdev_Init()
{

    openStreamList = &openStreamListHdr;
    List_Init(openStreamList);
    if (migPdev_Debug > 5) {
	pdev_Trace = 1;
    }
}
Beispiel #15
0
int Studio_UI_Modify(int id) {
	studio_t rec;
	int rtn = 0;
	int newrow, newcolumn;
	seat_list_t list;
	int seatcount;

	/*Load record*/
	if (!Studio_Srv_FetchByID(id, &rec)) {
		printf("The room does not exist!\nPress [Enter] key to return!\n");
		getchar();
		return 0;
	}

	printf("\n=======================================================\n");
	printf("****************  Update Projection Room  ****************\n");
	printf("-------------------------------------------------------\n");
	printf("Room ID:%d\n", rec.id);
	printf("Room Name[%s]:", rec.name);
	fflush(stdin);
	gets(rec.name);

	List_Init(list, seat_node_t);
	seatcount = Seat_Srv_FetchByRoomID(list, rec.id);
	if(seatcount){
		do{			
			printf("Row Count of Seats should >= [%d]:", rec.rowsCount);
			scanf("%d", &(newrow));
			printf("Column Count of Seats should >= [%d]:", rec.colsCount);
			scanf("%d", &(newcolumn));
		}while(	newrow<rec.rowsCount||newcolumn<rec.colsCount);
		rec.rowsCount=newrow;
		rec.colsCount=newcolumn;
		rec.seatsCount=seatcount;
	}
	else{
		printf("Row Count of Seats:");
		scanf("%d", &rec.rowsCount);
		printf("Column Count of Seats:");
		scanf("%d", &rec.colsCount);
		rec.seatsCount=0;
	}

	printf("-------------------------------------------------------\n");

	if (Studio_Srv_Modify(&rec)) {
		rtn = 1;
		printf(
				"The room data updated successfully!\nPress [Enter] key to return!\n");
	} else
		printf("The room data updated failed!\nPress [Enter] key to return!\n");

	getchar();
	return rtn;
}
Beispiel #16
0
static void Imo2sproxy_Loop(IMO2SPROXY *hInst)
{
	struct sockaddr_in sock;
	int socklen;
	SOCKET new_fd;
	TYP_LIST *hConns = List_Init(32);
	CONNINST *pInst;
	IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)hInst;
	fd_set fdListen;

	if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
		fprintf (hProxy->pCfg->fpLog, "Socksproxy:Loop(Start)\n");
	hProxy->iRunning = 1;
	LockMutex(hProxy->loopmutex);
	while (hProxy->iRunning)
	{
		FD_ZERO(&fdListen);
		FD_SET(hProxy->listen_fd, &fdListen);
		socklen = sizeof(sock);
		if (select (0, &fdListen, NULL, NULL, NULL) != SOCKET_ERROR && FD_ISSET(hProxy->listen_fd, &fdListen))
		{
			new_fd = accept(hProxy->listen_fd, (struct sockaddr *) &sock, &socklen); 
			if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
			{
				fprintf (hProxy->pCfg->fpLog, "Connection from %s:%d -> Connection: %d\n", inet_ntoa(sock.sin_addr),
					ntohs(sock.sin_port), new_fd);
				fflush (hProxy->pCfg->fpLog);
			}
			if (new_fd != INVALID_SOCKET && (pInst = calloc (1, sizeof(CONNINST))))
			{
				CleanConnections (hConns);
				List_Push(hConns, pInst);
				pInst->hSock = new_fd;
				pInst->hProxy = hProxy;
				InitMutex(pInst->connected);
				LockMutex(pInst->connected);
				InitMutex(pInst->sendmutex);
				Dispatcher_Start(pInst);
			}
		}
	}
	if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
		fprintf (hProxy->pCfg->fpLog, "Socksproxy:Loop(End)\n");

	CleanConnections (hConns);
	while (pInst=List_Pop(hConns))
	{
		Dispatcher_Stop(pInst);
		FreeConnection(pInst);
		free (pInst);
	}
	List_Exit(hConns);
	UnlockMutex(hProxy->loopmutex);
}
Beispiel #17
0
/*
 * ----------------------------------------------------------------------------
 *
 * VmStackInit --
 *
 *      Allocate and initialize the stack stuff.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Stack information is allocated and initialization.
 *
 * ----------------------------------------------------------------------------
 */
void
VmStackInit()
{
    Address	addr;
    int		i;

    Sync_LockInitDynamic(&stackLock, "Vm:stackLock");
    stackListElements =
	    (StackList *)Vm_BootAlloc(vmMaxProcesses * sizeof(StackList));
    List_Init(activeList);
    List_Init(freeList);
    for (i = 0, addr = vmStackBaseAddr;
	 addr < vmStackEndAddr;
	 i++, addr += mach_KernStackSize) {
	 stackListElements[i].startAddr = (Address) addr;
	 List_Insert((List_Links *) &stackListElements[i], 
		     LIST_ATREAR(freeList));
    }
    numStackPages = mach_KernStackSize >> vmPageShift;
}
Beispiel #18
0
static void
addItem(int color, List_Links *list)
{
  Item *i;
  i = (Item *)malloc(sizeof(Item));
  assert(i);
  List_Init((List_Links *)i);
  i->color = color;
  List_Insert((List_Links *)i, LIST_ATREAR(list));
  assert(((Item *)List_Last(list))->color == color);
  return;
}
Beispiel #19
0
/* Initializes memory to sizeOfRegion, rounded up to nearest page
 * Calls List_Init to initialize array of freelists */
int Mem_Init(int sizeOfRegion) {
   int pagesize;
   int padsize;
   int fd;
   int alloc_size;
   void* space_ptr;
   static int allocated_once = 0;

   if(0 != allocated_once) {
      fprintf(stderr,"Error:mem.c: Mem_Init has allocated space during a previous call\n");
      return -1;
   }
   if(sizeOfRegion <= 0) {
      fprintf(stderr,"Error:mem.c: Requested block size is not positive\n");
      return -1;
   }

   /* Get the pagesize */
   pagesize = getpagesize();

   /* Calculate padsize as the padding required to round up sizeOfRegio to a multiple of pagesize */
   padsize = sizeOfRegion % pagesize;
   padsize = (pagesize - padsize) % pagesize;

   alloc_size = sizeOfRegion + padsize;
   MAX_ALLOC = pagesize; // Max assumed amount the user will allocate + hsize
   N_LISTS = alloc_size/MAX_ALLOC;

   /* Using mmap to allocate memory */
   fd = open("/dev/zero", O_RDWR);
   if(-1 == fd) {
      fprintf(stderr,"Error:mem.c: Cannot open /dev/zero\n");
      return -1;
   }
   space_ptr = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);

  if (MAP_FAILED == space_ptr) {
   fprintf(stderr,"Error:mem.c: mmap cannot allocate space\n");
   allocated_once = 0;
   return -1;
   }

   allocated_once = 1;
  
   /* Initialize a head block for each page */
   list_head = (block_header*)space_ptr;
   List_Init();
   

  /* Remember that the 'size' stored in block size excludes the space for the header */
  return 0;
}
Beispiel #20
0
/*
 *----------------------------------------------------------------------------
 *
 * Sync_Init --
 *
 *	This initializes the event hash chain.  The hash table is
 *	an array of list headers.
 *
 *	Instrumentation variables are also initialized.
 *
 * Results:
 *     None.
 *
 * Side effects:
 *	The hash chain headers are initialized to be dummy list elements
 *
 *----------------------------------------------------------------------------
 */
void
Sync_Init()
{
    register int i;

    for (i=0 ; i<PROC_HASHBUCKETS ; i++) {
	List_Init(&eventChainHeaders[i]);
    }
    bzero((Address) sync_Instrument, sizeof(sync_Instrument));
    for (i=0; i < MACH_MAX_NUM_PROCESSORS; i++) {
	sync_InstrumentPtr[i] = &sync_Instrument[i];
    }
}
Beispiel #21
0
int display_R(char *path) //专为ls -R 设计的用于递归的函数
{
    int i=0,j,count=0;
    char cpath[256]="./";
    DIR *dir;
    struct dirent *ptr;
    struct stat buf;
    char cwd[256];
    getcwd(cwd,256); //获得当前路径
    chdir(path);    //切换到path所代表的路径
    str_node_t *newNode,*head,*p,*q;
    List_Init(head,str_node_t);
    if((dir=opendir("./"))==NULL)
    {
        perror("opendir");
        return -1;
    }
    while((ptr=readdir(dir))!=NULL)
    {
        i++;
        newNode=(str_node_t *)malloc(sizeof(str_node_t));
        strcpy(newNode->str,ptr->d_name);
        List_AddHead(head,newNode);
    }
    count=i;
    sort(count,head);
    p=head;
    for(i=0; i<count; i++)
    {
        p=p->next;
        lstat(p->str,&buf);
        if(!strcmp(p->str,".")||!strcmp(p->str,"..")||p->str[0]=='.')  //去除掉此文件夹下的. .. 和.开头的隐藏文件
        {
            continue;
        }
        if(S_ISDIR(buf.st_mode)) //判断是否为目录
        {
            printf("\n\033[34m%s",cwd); //改变颜色为蓝色
            printf("%s/\033[0m\n",p->str);
            display_R(p->str);
        }
        else
        {
            printf("%-15s\t",p->str);
        }
    }
    printf("\n");
    closedir(dir);
    chdir(cwd);  //切换回原路径
    return 1;
}
Beispiel #22
0
int
crawl (char *start_url,
       int download_workers,
       int parse_workers,
       int queue_size,
       char *(*_fetch_fn) (char *url),
       void (*_edge_fn) (char *from, char *to))
{

  QUEUE_SIZE = queue_size;
  queue_links = (char **) malloc (sizeof (char *) * queue_size);
  queue_pages = (list_t *) malloc (sizeof (list_t));
  List_Init (queue_pages);
  urls = create_hash_table(65535); //hash set for unique urls

  //add start_url to bounded queue
  //printf("start url = %s\n", start_url);
  put (start_url);
  add_string(urls, start_url);

/*
  char *seed_url = NULL;
  lst_t *l = lookup_string(urls, start_url);  
  if(l!=NULL)
	  seed_url = l->string;
  if(seed_url != NULL)
	printf("seed url=%s\n",seed_url);
  else
	printf("not found\n");
*/
  //set sum_queue_lengths to 1
  sum_queue_lengths = 1;
 

  //create threads
  pthread_t downloaders[download_workers], parsers[parse_workers];
  int i;
  //printf("creating threads\n");

  for (i = 0; i < download_workers; i++)
    pthread_create (&downloaders[i], NULL, download, _fetch_fn);

  for (i = 0; i < parse_workers; i++)
    pthread_create (&parsers[i], NULL, parse, _edge_fn);

  //printf("created threads\n");
  thr_join ();
  
  printf ("crawler completed successfully\n");
  return 0;
}
Beispiel #23
0
int main()
{
    int element = 255;
    unsigned int key = 127;
    list_t lst;
    List_Init(&lst);
    List_Insert(&lst, (void*)&element, key);
    List_Delete(&lst, key);
    void *val = List_Lookup(&lst, key);
    if (!val)
	return 0;
    else
	return -1;
}
Beispiel #24
0
void
PC_Init(PC *pc, int cap, int maxColor)
{
  Lock_Init(&pc->lock);
  Cond_Init(&pc->spaceAvail, &pc->lock);
  Cond_Init(&pc->stuffAvail, &pc->lock);
  List_Init(&(pc->list));
  pc->capacity = cap;
  pc->used = 0;
  pc->maxColor = maxColor;
  pc->waitingP = 0;
  pc->waitingC = 0;
  return;
}
Beispiel #25
0
/*
===============
SV_CreateAreaNode

Builds a uniformly subdivided tree for the given world size
===============
*/
static areanode_t *SV_CreateAreaNode(int depth, vec3_t mins, vec3_t maxs)
{
    areanode_t  *anode;
    vec3_t      size;
    vec3_t      mins1, maxs1, mins2, maxs2;

    anode = &sv_areanodes[sv_numareanodes];
    sv_numareanodes++;

    List_Init(&anode->trigger_edicts);
    List_Init(&anode->solid_edicts);

    if (depth == AREA_DEPTH) {
        anode->axis = -1;
        anode->children[0] = anode->children[1] = NULL;
        return anode;
    }

    VectorSubtract(maxs, mins, size);
    if (size[0] > size[1])
        anode->axis = 0;
    else
        anode->axis = 1;

    anode->dist = 0.5 * (maxs[anode->axis] + mins[anode->axis]);
    VectorCopy(mins, mins1);
    VectorCopy(mins, mins2);
    VectorCopy(maxs, maxs1);
    VectorCopy(maxs, maxs2);

    maxs1[anode->axis] = mins2[anode->axis] = anode->dist;

    anode->children[0] = SV_CreateAreaNode(depth + 1, mins2, maxs2);
    anode->children[1] = SV_CreateAreaNode(depth + 1, mins1, maxs1);

    return anode;
}
Beispiel #26
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;
}
Beispiel #27
0
void DisplayQueryPlay(int flag)
{
       play_t data;
	play_node_t *p;
	play_list_t list;
	char choice,str[30]="\0";
	int id,type=2; //查询类型 0 id  1 name
	
	List_Init(list, play_node_t);
	
	while(1){
		system("clear");
       		
       		printf("\t\t=======================================================================================\n\n");
       		printf("\t\t------------------------------------查询 剧目-------------------------------------------\n\n");
       		printf("\t\t=======================================================================================\n\n");
		
		if(type==1){
			
			if(Play_Srv_FetchByName(list,str)){
				printf("\t\t该剧目信息如下:\n");
		       		printf("\t\t%5s \t %20s\t%8s \t %5s \t %10s \t %10s \t %5s \n", "ID", "名称", "地区",
						"时长", "上映日期","下线日期","票价");
				printf("\n\t\t=======================================================================================\n\n");
				List_ForEach(list, p){	
			       		printf("\t\t%5d %20s %10s %5d ",p->data.id,p->data.name,p->data.area,p->data.duration);
					printf("\t%4d-%02d-%02d ",p->data.start_date.year,p->data.start_date.month,p->data.start_date.day);
					printf("\t%4d-%02d-%02d ",p->data.end_date.year,p->data.end_date.month,p->data.end_date.day);
					printf("\t%5d\n", p->data.price);
				
				}
		       		printf("\n\t\t=======================================================================================\n\n");
       		
	       		}else{
	       		
	       		printf("\t\t未找到!\n\t\t按任意键返回!");
	       		getchar();
	       		
	       		}
	       	}
Beispiel #28
0
int  Main()
{
	studio_node_t *head;
	int listSize=0;
	int flag=2;
	char choice;
	do
	{
		printf("\n\t\t************************************\n");
		printf("\t\t**           [A]       演出厅管理              \n");
		printf("\t\t**           [B]        剧目管理                 \n");
		printf("\t\t**           [C]        售票管理                    \n");
		printf("\t\t**           [D]       查询菜单                     \n");
		printf("\t\t**           [E]        票房统计                   \n");
		printf("\t\t**           [f]        系统用户管理            \n");
		printf("\t\t**           [G]        推出                             \n");
		printf("\t\t*************************************\n");
		printf("Please Input: ");
		scanf("%d",&choice);
		getchar();
		switch(choice)
		{
			case 'a' :;
		 	case 'A' :  
					List_Init(head, studio_node_t);
					Studio_UI_MgtEntry(head);
					break;
			case 'b' :;
			case 'B' :
					Play_UI_MgtEntry(flag);
					break;
			case 'C' :;
			case 'c'  :
					Schedule_UI_ListAll();
				break;
		}
	}while(choice!='G' || choice!='g');
}
Beispiel #29
0
int  Chtbl_Init(CHTbl *htbl, int buckets, int (*h)(const void *key), int 
                (*match)(const void *key1, const void *key2), void (*destroy)(void *data))
{
    int i;

	//申请存放桶的数组
    if (NULL == (htbl->table = (List *)malloc(buckets * sizeof(List))))
        return ERR;

    htbl->buckets = buckets;
    /* 初始化哈希链的每个桶 */
    for (i = 0; i < htbl->buckets; i++)
    {
        List_Init(&htbl->table[i], destroy);
    }
    //求hash值的函数
    htbl->h = h;
    htbl->match = match;
    htbl->destroy = destroy;
    htbl->size = 0;

    return OK;
}
Beispiel #30
0
void
Sched_Init()
{
    int	cpu;

    sched_ProcessorStatus[0] = SCHED_PROCESSOR_ACTIVE;
    for(cpu = 0; cpu < MACH_MAX_NUM_PROCESSORS; cpu++) {
	sched_ProcessorStatus[cpu] = SCHED_PROCESSOR_NOT_STARTED;
	sched_OnDeck[cpu].procPtr = (Proc_ControlBlock *) NIL;
    }
    bzero((Address) &(sched_Instrument),sizeof(sched_Instrument));

    List_Init(schedReadyQueueHdrPtr);
    Sync_SemInitDynamic(sched_MutexPtr, "sched_Mutex");
    Sync_SemRegister(sched_MutexPtr);

    forgetUsageElement.routine		= Sched_ForgetUsage; 
    forgetUsageElement.clientData	= 0;
    forgetUsageElement.interval		= FORGET_INTERVAL;
    Timer_ScheduleRoutine(&forgetUsageElement, TRUE);

    init = TRUE;
}