aboutsummaryrefslogtreecommitdiffstats
path: root/src/ragel/smtp_date_parser.rl
blob: bc6e5c8f06f9018abb36cccf7cf9140e22f9a2c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%%{

  machine smtp_date_parser;
  include smtp_whitespace "smtp_whitespace.rl";
  include smtp_date "smtp_date.rl";

  main := date_time;
}%%

#include "smtp_parsers.h"
#include "util.h"

%% write data;

guint64
rspamd_parse_smtp_date (const char *data, size_t len)
{
  const gchar *p = data, *pe = data + len, *eof = data + len, *tmp = data;
  struct tm tm;
  glong tz = 0;
  gint cs = 0;

  memset (&tm, 0, sizeof (tm));

  %% write init;
  %% write exec;

  return rspamd_tm_to_time (&tm, tz);
}