Root/eeshow/file/file.h

1/*
2 * file/file.h - Open and read a file
3 *
4 * Written 2016 by Werner Almesberger
5 * Copyright 2016 by Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef FILE_FILE_H
14#define FILE_FILE_H
15
16#include <stdbool.h>
17#include <stdio.h>
18
19
20struct file {
21    FILE *file; /* NULL if using a version control system */
22    void *vcs; /* VCS descriptor or NULL */
23    const char *name; /* name/designator given to file_open */
24    unsigned lineno;
25    const struct file *related; /* NULL if not related to anything */
26};
27
28
29void *file_oid(const struct file *file);
30bool file_oid_eq(const void *a, const void *b);
31
32bool file_cat(const struct file *file, void *user, const char *line);
33
34char *file_graft_relative(const char *base, const char *name);
35
36bool file_open(struct file *file, const char *name,
37    const struct file *related);
38bool file_open_revision(struct file *file, const char *rev, const char *name,
39    const struct file *related);
40bool file_read(struct file *file,
41    bool (*parse)(const struct file *file, void *user, const char *line),
42    void *user);
43void file_close(struct file *file);
44
45#endif /* !FILE_FILE_H */
46

Archive Download this file

Branches:
master



interactive