Lexical Analyzer v0.1.0
 
Loading...
Searching...
No Matches
lexer_io.h
Go to the documentation of this file.
1#ifndef LEXER_IO_H
2#define LEXER_IO_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <ctype.h>
8#include <stdbool.h>
9
26
27
36typedef struct {
44 char *buff;
45
54 size_t chksz;
55} fchnk_t;
56
69
81void fchnk_dtor(fchnk_t *chnk);
82
83
99fchnk_t *fchnk_ptor(char *const buff, const size_t chksz);
100
101
115bool fwrite_fchnk(const char *fname, const fchnk_t *chnk);
116
136fchnk_t *get_fchnk(const char *fname);
137
138 // End of LexerIO group
140
141#endif
fchnk_t * fchnk_ctor()
Constructs a new file chunk object.
fchnk_t * get_fchnk(const char *fname)
Reads the contents of a binary file into a dynamically allocated buffer and stores it in a new fchnk_...
fchnk_t * fchnk_ptor(char *const buff, const size_t chksz)
Initializes and returns a file chunk object with provided buffer and size.
bool fwrite_fchnk(const char *fname, const fchnk_t *chnk)
Writes the contents of a file chunk to a specified file.
void fchnk_dtor(fchnk_t *chnk)
Destructor for the file chunk object.
A structure that represents a chunk of data from a file.
Definition lexer_io.h:36
char * buff
A pointer to a buffer that holds the content of the file chunk.
Definition lexer_io.h:44
size_t chksz
The size of the data stored in the buff buffer.
Definition lexer_io.h:54