diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-16 19:35:43 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-16 19:41:28 -0700 |
| commit | 6c237850e90dce317ede7b0d4e53125df15ab62b (patch) | |
| tree | c783ab61954de0b3120727245327843a82233542 /file_loader.h | |
| parent | 3483cd75cb0a67d50bdcf9d03a15dc5af67a1986 (diff) | |
WIP
Diffstat (limited to 'file_loader.h')
| -rw-r--r-- | file_loader.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/file_loader.h b/file_loader.h new file mode 100644 index 0000000..cb49373 --- /dev/null +++ b/file_loader.h @@ -0,0 +1,22 @@ +/* + * file_loader.h - Definitions of an API for loading files. + */ +#ifndef FILE_LOADER__H +#define FILE_LOADER__H + +#include <stdio.h> + +typedef struct { + const char *filename; + char *contents, **lines; + size_t length, nlines; + unsigned int mmapped:1; +} file_t; + +file_t *load_file(const char *filename); +void destroy_file(file_t **f); +size_t get_line_number(file_t *f, const char *p); +const char *get_line(file_t *f, size_t line_number); +void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, const char *msg); + +#endif |
