Root/
| 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 | |
| 20 | struct 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 | |
| 29 | void *file_oid(const struct file *file); |
| 30 | bool file_oid_eq(const void *a, const void *b); |
| 31 | |
| 32 | bool file_cat(const struct file *file, void *user, const char *line); |
| 33 | |
| 34 | char *file_graft_relative(const char *base, const char *name); |
| 35 | |
| 36 | bool file_open(struct file *file, const char *name, |
| 37 | const struct file *related); |
| 38 | bool file_open_revision(struct file *file, const char *rev, const char *name, |
| 39 | const struct file *related); |
| 40 | bool file_read(struct file *file, |
| 41 | bool (*parse)(const struct file *file, void *user, const char *line), |
| 42 | void *user); |
| 43 | void file_close(struct file *file); |
| 44 | |
| 45 | #endif /* !FILE_FILE_H */ |
| 46 |
Branches:
master
