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

📄 cms_wtptimer.c

📁 wap 协议栈 包括1.2 和2.0 由c开发 基于brew平台
💻 C
字号:
/****************************************************************************/
/*                                                                          */
/*   MOBILESOFT CHINA (CMS) SYSTEMS, INC.                                   */
/*                WIRELESS APPLICATION DESIGN CENTER (NANJING CHINA)        */
/*                                                                          */
/****************************************************************************/
/*                                                                          */
/*   CMS CONFIDENTIAL AND PROPRIETARY                                       */
/*                                                                          */
/*   This source is the sole property of CMS Systems, Inc. Reproduction     */
/*   or utilization of this source in whole or in part is forbidden without */
/*   the written consent of CMS Systems, Inc.                               */
/*                                                                          */
/*   (c) Copyright CMS Systems, Inc., 2000.  All Rights Reserved.           */
/*                                                                          */
/****************************************************************************/
/*                                                                          */
/*   wtp_timer.cpp                                                          */
/*                                                                          */
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/*   Date       |  author         |   Description |   version               */
/*--------------------------------------------------------------------------*/
/*   06/12/00   |  Xiaogang Xu    |   Creation    |   1.2                   */
/*--------------------------------------------------------------------------*/
/****************************************************************************/
#ifndef TRACE
#define TRACE 0
#endif

//#include "c_wtp_timer.h"
#include "Cms_WTPTimer.h"
//#include "c_gwlib.h"

/* Wtp timers queue, contains all active timers.  The list's lock is
 * used for operations on its elements.  No list operations should be
 * done without explicit list_lock and list_unlock. */

/* The events triggered by elapsed timers are collected in these
 * structures, so that they can be handled in a separate loop.
 * (That avoids the problem of wtp_handle_event wanting to modify
 * the timers while wtp_timer_check is scanning the list).
 
struct pending_event {
	WTPMachine *machine;
	WTPEvent *event;
};
*/
WTPTimer *wtp_timer_create(void) 
{
	WTPTimer *timer = NULL;
	
	timer = (WTPTimer *)malloc(sizeof(WTPTimer));
	timer->start_time = 0;
	timer->interval = 0;
	timer->event = NULL;
	timer->machine = NULL;
	return timer;
}


void wtp_timer_destroy(WTPTimer *timer) 
{
	
	if (timer == NULL)
		return;
	
	
	free(timer);
}


void wtp_timer_start(WTPTimer *timer, long interval) 
{
	/*timer->start_time = (long) time(NULL);*/
	timer->interval = interval;
}


void wtp_timer_stop(WTPTimer *timer) {

	timer->start_time=0;
	timer->interval = -1;
}


int wtp_timer_check(WTPTimer *timer) 
{
	/*now = (long) time(NULL);*/
	if (timer->interval == -1) return 0;
	/* 检查三个时钟是否超时		*/
		if (timer->interval == 0/*timer->start_time + timer->interval <= now*/)
		{
               
			timer->interval = -1;

			return 1;
		} else {
			timer->interval--;
		}          

	return 0;
}

#ifdef __SELECTIVE_RETRANSMISSION__
int wtp_timer_timeleft(WTPTimer *timer)
{
	return timer->interval;
}
#endif
/*
void wtp_timer_dump(WTPTimer *timer){


	debug("wap.wtp.timer", 0, "Timer dump starts.");
	debug("wap.wtp.timer", 0, "Starting time was %ld.", timer->start_time);
	debug("wap.wtp.timer", 0, "Checking interval was %ld.",
					timer->interval);
	debug("wap.wtp.timer", 0, "Timer belonged to a machine:");
	wtp_machine_dump(timer->machine);
	debug("wap.wtp.timer", 0, "Timer event was:");
	wtp_event_dump(timer->event);
	debug("wap.wtp.timer", 0, "Timer dump ends.");

}



void wtp_timer_shutdown(void) {
}
*/

⌨️ 快捷键说明

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