summaryrefslogtreecommitdiff
path: root/core/state.c
diff options
context:
space:
mode:
authorIan M. <ian@aptel.org>2026-10-03 04:02:54 +0000
committerIan M. <ian@aptel.org>2026-10-03 04:02:54 +0000
commit8e838a73368d5f26fee796d6ddb065e21449e989 (patch)
tree656757670ad91f0fa52b87eb71599a36e56fadae /core/state.c
initial commit
Signed-off-by: Ian M. <ian@aptel.org>
Diffstat (limited to 'core/state.c')
-rw-r--r--core/state.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/state.c b/core/state.c
new file mode 100644
index 0000000..8c3dea1
--- /dev/null
+++ b/core/state.c
@@ -0,0 +1,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;
+}