blob: 37399ae94f945d4fdaa31debadcc57f9f1512766 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/*
* 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);
size_t get_char_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
|