/*
* compute the next time after t
* that has hour hr and is not on
* day in bitpattern --
* for automatic dumps
*/
Timet
nextime(Timet t, int hr, int day)
{
int nhr;
Tm *tm;
if(hr < 0 || hr >= 24)
hr = 5;
if((day&0x7f) == 0x7f)
day = 0;
for (;;) {
tm = localtime(t);
t -= tm->sec;
t -= tm->min*60;
nhr = tm->hour;
do {
t += 60*60;
nhr++;
} while(nhr%24 != hr);
tm = localtime(t);
if(tm->hour != hr) {
t += 60*60;
tm = localtime(t);
if(tm->hour != hr) {
t -= 60*60;
tm = localtime(t);
}
}
if(day & (1<<tm->wday))
t += 12*60*60;
else
return t;
}
}
/*
* delay for l milliseconds more or less.
*/
void
delay(int l)
{
sleep(l);
}