File: settimespec.cc

package info (click to toggle)
natlog 3.01.00-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,912 kB
  • sloc: cpp: 3,691; fortran: 201; sh: 133; ansic: 123; makefile: 110
file content (41 lines) | stat: -rw-r--r-- 889 bytes parent folder | download | duplicates (5)
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
30
31
32
33
34
35
36
37
38
39
40
41
#include "options.ih"

void Options::setTimeSpec()
{
    string value;
    if (not d_arg.option(&value, 't'))
        d_time = s_time.find("raw");
    else 
        setTimeType(value);

    if (d_mode == CONNTRACK)                // no TTL for conntrack
        d_ttl = ::time(0);

    else if (d_arg.option(&value, 'T'))
    {
        istringstream in{ value };
        for (size_t count = 0; count != 2; ++count)
        {
            size_t seconds;
            in >> seconds;

            switch (in.get())
            {
                case 'u':
                    d_ttl = seconds;
                break;

                case 't':
                    d_ttlTCP = seconds;
                break;

                case EOF:
                return;

                default:
                throw Exception{} << "`--ttl " << value << "' not supported";
            }
        }
    }
}