summaryrefslogtreecommitdiff
path: root/core/state.c
blob: 8c3dea1da092ded90257701b0194491536a611ab (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
30
31
32
33
34
/*
 * Copyright (c) 2026, Apollo Telephone Laboratories.
 * Provided under the BSD-3 clause.
 */

#include <atas/state.h>
#include <errno.h>

int
atas_state_init(const char *in_file, struct atas_state *state)
{
    if (in_file == NULL || state == NULL) {
        errno = EINVAL;
        return -1;
    }

    state->in_file = fopen(in_file, "r");
    if (state->in_file == NULL) {
        return -1;
    }

    return 0;
}

void
atas_state_destroy(struct atas_state *state)
{
    if (state == NULL) {
        return;
    }

    fclose(state->in_file);
    state->in_file = NULL;
}