Files
quip/include/common/state.h
2026-03-21 07:15:54 -04:00

51 lines
1.1 KiB
C

/*
* Copyright (c) 2026, Mirocom Laboratories
* Provided under the BSD-3 clause
*
* Abstract:
* This header defines the quip state machine
* Author:
* Ian M. Moffett <ian@mirocom.org>
*/
#ifndef COMMON_STATE_H
#define COMMON_STATE_H 1
#include <stdint.h>
#include <stddef.h>
#include "common/knobs.h"
/*
* Represents the build state machine
*
* @in_fd: Input file descriptor of build file
* @line_num: Current line number
* @lex_buf: Used to reduce system call frequency
* @lex_buf_cap: Lexer buffer capacity
* @lex_buf_i: Lexer buffer index
*/
struct quip_state {
int in_fd;
size_t line_num;
char lex_buf[LEX_FILEBUF_LEN];
size_t lex_buf_cap;
size_t lex_buf_i;
};
/*
* Initialize the quip state machine
*
* @build_file: Path to build file
* @state: State instance to initialize
*
* Returns zero on success
*/
int quip_state_init(const char *build_file, struct quip_state *state);
/*
* Destroy a quip state
*/
void quip_state_destroy(struct quip_state *state);
#endif /* !COMMON_STATE_H */