Exemplo n.º 1
0
/* This function determines the year that syslog-ng would find out
 * given the timestamp has no year information. Then returns the UTC
 * representation of "January 1st 00:00:00" of that year. This is to
 * be used for testcases that lack year information. ts_month is the 0
 * based month in the timestamp being parsed.
 */
time_t
get_bsd_year_utc(int ts_month)
{
  struct tm *tm;
  time_t t;

  time(&t);
  tm = localtime(&t);

  tm->tm_year = determine_year_for_month(ts_month, tm);

  tm->tm_hour = 0;
  tm->tm_min = 0;
  tm->tm_sec = 0;
  tm->tm_mday = 1;
  tm->tm_mon = 0;
  tm->tm_isdst = -1;
  return mktime(tm);
}
Exemplo n.º 2
0
static time_t
_get_epoch_with_bsd_year(int ts_month, int d, int h, int m, int s)
{
  struct tm *tm;
  time_t t;

  time(&t);
  tm = localtime(&t);

  tm->tm_year = determine_year_for_month(ts_month, tm);

  tm->tm_hour = h;
  tm->tm_min = m;
  tm->tm_sec = s;
  tm->tm_mday = d;
  tm->tm_mon = ts_month;
  tm->tm_isdst = -1;
  return mktime(tm);
}
Exemplo n.º 3
0
static gboolean
__parse_bsd_timestamp(const guchar **data, gint *length, const GTimeVal *now, struct tm* tm, glong *usec)
{
  gint left = *length;
  const guchar *src = *data;
  time_t now_tv_sec = (time_t) now->tv_sec;
  cached_localtime(&now_tv_sec, tm);

  if (__is_bsd_pix_or_asa(src, left))
    {
      if (!scan_pix_timestamp((const gchar **) &src, &left, tm))
        return FALSE;

      if (*src == ':')
        {
          src++;
          left--;
        }
    }
  else if (__is_bsd_linksys(src, left))
    {
      if (!scan_linksys_timestamp((const gchar **) &src, &left, tm))
        return FALSE;
    }
  else if (__is_bsd_rfc_3164(src, left))
    {
      if (!scan_bsd_timestamp((const gchar **) &src, &left, tm))
        return FALSE;

      *usec = __parse_usec(&src, &left);

      tm->tm_year = determine_year_for_month(tm->tm_mon, tm);
    }
  else
    {
      return FALSE;
    }
  *data = src;
  *length = left;
  return TRUE;
}