/* This file is part of Lcrzo.
*/

int lcrzo_time_init_currenttime(lcrzo_time *ptime)
#if defined LCRZODEF_SYSTEM_Unix
{ struct timeval tv;
  int ret;

  /* parameters verification */
  if (ptime==NULL) return(LCRZO_ERR_PANULLPTR);

  ret=gettimeofday(&tv, NULL);
  if (ret)
  { return(LCRZO_ERR_FUGETTIMEOFDAY);
  }
  /* store values */
  ptime->sec=(lcrzo_uint32)tv.tv_sec;
  ptime->usec=(lcrzo_uint32)tv.tv_usec;
  return(LCRZO_ERR_OK);
}
#elif defined LCRZODEF_SYSTEM_Windows
{ struct _timeb tstruct;

  /* parameters verification */
  if (ptime==NULL) return(LCRZO_ERR_PANULLPTR);

  /* get current time */
  _ftime( &tstruct );

  /* store values */
  ptime->sec=tstruct.time;
  ptime->usec=tstruct.millitm*1000;

  return(LCRZO_ERR_OK);
}
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif

