/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */12/*3* Copyright (C) 2014 Rob Clark <[email protected]>4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice (including the next13* paragraph) shall be included in all copies or substantial portions of the14* Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE22* SOFTWARE.23*24* Authors:25* Rob Clark <[email protected]>26*/2728#ifndef IO_H_29#define IO_H_3031/* Simple API to abstract reading from file which might be compressed.32* Maybe someday I'll add writing..33*/3435struct io;3637struct io *io_open(const char *filename);38struct io *io_openfd(int fd);39void io_close(struct io *io);40unsigned io_offset(struct io *io);41int io_readn(struct io *io, void *buf, int nbytes);4243static inline int44check_extension(const char *path, const char *ext)45{46return strcmp(path + strlen(path) - strlen(ext), ext) == 0;47}4849#endif /* IO_H_ */505152