• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2 
3 /*
4  * Copyright © 2014 Rob Clark <robclark@freedesktop.org>
5  * SPDX-License-Identifier: MIT
6  *
7  * Authors:
8  *    Rob Clark <robclark@freedesktop.org>
9  */
10 
11 #ifndef IO_H_
12 #define IO_H_
13 
14 /* Simple API to abstract reading from file which might be compressed.
15  * Maybe someday I'll add writing..
16  */
17 
18 struct io;
19 
20 struct io *io_open(const char *filename);
21 struct io *io_openfd(int fd);
22 void io_close(struct io *io);
23 unsigned io_offset(struct io *io);
24 int io_readn(struct io *io, void *buf, int nbytes);
25 
26 static inline int
check_extension(const char * path,const char * ext)27 check_extension(const char *path, const char *ext)
28 {
29    return strcmp(path + strlen(path) - strlen(ext), ext) == 0;
30 }
31 
32 #endif /* IO_H_ */
33