Exemple #1
0
static void get_current_time(struct TINYCLR_SSL_TIMEVAL *t)
{
#ifdef OPENSSL_SYS_WIN32
	struct _timeb tb;
	_ftime(&tb);
	t->tv_sec = (long)tb.time;
	t->tv_usec = (long)tb.millitm * 1000;
#elif defined(OPENSSL_SYS_VMS)
	struct timeb tb;
	ftime(&tb);
	t->tv_sec = (long)tb.time;
	t->tv_usec = (long)tb.millitm * 1000;
#else
	TINYCLR_SSL_GETTIMEOFDAY(t, NULL);
#endif
}
/* Use the gettimeofday function call. */
static int def_time_cb(struct TS_resp_ctx *ctx, void *data, 
		       long *sec, long *usec)
	{
	struct TINYCLR_SSL_TIMEVAL tv;
	if (TINYCLR_SSL_GETTIMEOFDAY(&tv, NULL) != 0) 
		{
		TSerr(TS_F_DEF_TIME_CB, TS_R_TIME_SYSCALL_ERROR);
		TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
					    "Time is not available.");
		TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE);
		return 0;
		}
	/* Return time to caller. */
	*sec = tv.tv_sec;
	*usec = tv.tv_usec;

	return 1;
	}