File: stream.h

package info (click to toggle)
wl-mirror 0.18.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 688 kB
  • sloc: ansic: 4,886; xml: 2,062; sh: 284; makefile: 54
file content (40 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (2)
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
#ifndef WL_MIRROR_STREAM_H_
#define WL_MIRROR_STREAM_H_

#include <stddef.h>
#include <stdbool.h>

#include <wlm/event.h>

struct ctx;

typedef struct ctx_stream {
    // holds stream input lines prior to being parsed as options
    // holds partial input lines between calls to stream::on_stream_data()
    //
    // ownership:
    // - resized in stream::input_reserve()
    // - written in stream::on_stream_data()
    // - written in stream::on_line() (passed line partially overwritten)
    char * input;
    size_t input_len;
    size_t input_cap;

    // holds parsed argv array that will be parsed as options
    // empty between calls to stream::on_line()
    //
    // ownership:
    // - resized in stream::args_push()
    // - written in stream::on_line()
    char ** args;
    size_t args_len;
    size_t args_cap;

    event_handler_t event_handler;
    bool initialized;
} ctx_stream_t;

void wlm_stream_init(struct ctx * ctx);
void wlm_stream_cleanup(struct ctx * ctx);

#endif