
#include<stdio.h>
#include<unistd.h>
#include<netinet/in.h>
#include<string.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<time.h>
#include<pthread.h>

#include"zither.h"
#include<almemsys/almemsys.h>

/*
int life_check(private_data_t *);
*/


int life_check(private_data_t * pd)
{
int lostime;
long int intime = 0;
int count = 0;

lostime = 0;
intime = (long int)time(NULL);

for(count = (LIFE_HI - 1); 1 <= count; count = count-1){
   pd->life.in_life[count] = pd->life.in_life[count - 1];
   #ifdef LIFE_DEBUG
   printf("LIFE_DEBUG: life_check():  TIME_BUF> %s count=%d in_life=%ld\n",
     pd->rec.def_user, count, pd->life.in_life[count]);
   #endif
   }

pd->life.in_life[0] = intime;

if(pd->life.in_life[1] !=  0){
   lostime = (pd->life.in_life[0] - pd->life.in_life[1]) - pd->life.life_int;
   }
else {
   lostime = 0;
   }

#ifdef LIFE_DEBUG
printf("LIFE_DEBUG: life_check(): 0 %ld 1 %ld int %d L %d\n",
  pd->life.in_life[0], pd->life.in_life[1], pd->life.life_int, lostime);
#endif

return(lostime);
}






