Article delegate-en/960 of [1-5110] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:]  
Re: enhanced time access control
Mon, 15 Jan 2001     Yutaka Sato

The enclosed patch for DeleGate/7.0.0 will extend the format of "-T"
like follows:

  -T.HH[MM][-HH[MM]]
  -T.wWHH[MM][-HH[MM]]  ... W=[0-6]
  -T.uUHH[MM][-HH[MM]]  ... U=[1-7]

For example, -T.w6-0 or -T.u6-7 means weekend (saturday through sunday),
-T.u51730-10830 means from 5:30pm on friday to 8:30am on monday.

This modification will be applied to the next release, DeleGate/7.0.1.

Cheers,
Yutaka
--
Yutaka Sato http://www.delegate.org/~ysato/   @ @ 
Computer Science Division, Electrotechnical Laboratory            ( - )
1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan                  _<   >_

*** ../../delegate7.0.0/src/hostlist.c	Fri Jan  5 16:45:16 2001
--- hostlist.c	Sun Jan 14 23:19:43 2001
***************
*** 252,262 ****
--- 252,275 ----
  	Mask->I3 = mask1;
  	return 1;
  }
+ 
+ static WHMtoi(st,dflt)
+ 	char *st,*dflt;
+ {	char buf[8],sc;
+ 	int si;
+ 
+ 	strcpy(buf,dflt);
+ 	for( si = 0; sc = st[si]; si++ )
+ 		buf[si] = sc;
+ 	return atoi(buf);
+ }
  static matchTimePeriod(period,mask)
  	char *period;
  {	char hour[8];
  	int hc,h1,h2;
  	int mc,m1,m2;
+ 	char *pp,*fmt,*smin,*smax,sh1[32],sh2[32];
+ 	int min,max;
  
  	/*
  	 * -T.000-000/0006
***************
*** 270,287 ****
  		else	return 0;
  	}
  
! 	StrftimeLocal(hour,sizeof(hour),"%H",(int)CurrentTime);
  	hc = atoi(hour);
  
! 	h1 = 0;
! 	h2 = 23;
! 	sscanf(period,"%d-%d",&h1,&h2);
  
  	if( h1 <= h2 ){
  		if( h1 <= hc && hc <= h2 )
  			return 1; 
  	}else{
! 		if( h1 <= hc && hc <= 23 || 0 <= hc && hc <= h2 )
  			return 1;
  	}
  	return 0;
--- 283,312 ----
  		else	return 0;
  	}
  
! 	pp = period;
! 	switch( *pp ){
! 	 case 'w': fmt = "%w%H%M"; smin = "00000"; smax = "62359"; pp++; break;
! 	 case 'u': fmt = "%u%H%M"; smin = "10000"; smax = "72359"; pp++; break;
! 	 default:  fmt =   "%H%M"; smin =  "0000"; smax =  "2359"; break;
! 	}
! 	switch( sscanf(pp,"%[0-9]-%[0-9]",sh1,sh2) ){
! 		case 0: return 0;
! 		case 1: h1 = WHMtoi(sh1,smin); h2 = WHMtoi(sh1,smax); break;
! 		case 2: h1 = WHMtoi(sh1,smin); h2 = WHMtoi(sh2,smax); break;
! 	}
! 	min = atoi(smin);
! 	max = atoi(smax);
! 
! 	StrftimeLocal(hour,sizeof(hour),fmt,(int)CurrentTime);
  	hc = atoi(hour);
  
! 	Verbose("-T %d < %d-[%d]-%d < %d ?\n",min,h1,hc,h2,max);
  
  	if( h1 <= h2 ){
  		if( h1 <= hc && hc <= h2 )
  			return 1; 
  	}else{
! 		if( h1 <= hc && hc <= max || min <= hc && hc <= h2 )
  			return 1;
  	}
  	return 0;
  search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V