File: vnlog-parser.h

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 (37 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download
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
#pragma once

typedef struct
{
    char* key;
    char* value;
} vnlog_keyvalue_t;

typedef struct
{
    int               Ncolumns;
    vnlog_keyvalue_t* record;

    // This is aliased to vnlog_parser_internal_t.
    //
    // More space than needed today. For future binary compatibility. I ask for
    // this structure to create an aligned buffer
    struct {size_t a; int* b;} _internal[8];

} vnlog_parser_t;

typedef enum
{
    VNL_OK, VNL_EOF, VNL_ERROR
} vnlog_parser_result_t;

vnlog_parser_result_t vnlog_parser_init(vnlog_parser_t* ctx, FILE* fp);

// Call vnlog_parser_free() when done. Even if vnlog_parser_read_record() failed
void vnlog_parser_free(vnlog_parser_t* ctx);

vnlog_parser_result_t vnlog_parser_read_record(vnlog_parser_t* ctx, FILE* fp);

// pointer to the pointer to the string for the record corresponding to the
// given key in the most-recently-parsed row. NULL if the given key isn't found
const char*const* vnlog_parser_record_from_key(vnlog_parser_t* ctx, const char* key);