File: test1.c

package info (click to toggle)
vnlog 1.42-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 992 kB
  • sloc: perl: 4,682; ansic: 752; python: 462; sh: 116; makefile: 7
file content (43 lines) | stat: -rw-r--r-- 1,075 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
42
43
#include <string.h>

#include "vnlog_fields_generated1.h"

void test2(void);

int main()
{
    vnlog_emit_legend();

    vnlog_set_field_value__w(-10);
    vnlog_set_field_value__x(40);
    vnlog_set_field_value__y("asdf");
    vnlog_emit_record();

    vnlog_set_field_value__w(55);

    const char* str = "123\x01\x02\x03";
    vnlog_set_field_value__d(str, strlen(str));

    // we just set some fields in this record, and in the middle of filling this
    // record we write other records, and other vnlog sessions
    {
        struct vnlog_context_t ctx;
        vnlog_init_child_ctx(&ctx, NULL); // child of the global context
        for(int i=0; i<3; i++)
        {
            vnlog_set_field_value_ctx__w(&ctx, i + 5);
            vnlog_set_field_value_ctx__x(&ctx, i + 6);
            vnlog_emit_record_ctx(&ctx);
        }
        vnlog_free_ctx(&ctx);
        test2();
    }

    // Now we resume the previous record. We still remember that w == 55
    vnlog_set_field_value__x(77);
    vnlog_set_field_value__z(0.3);

    vnlog_emit_record();

    return 0;
}