00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2010 Petter Urkedal <paurkedal@eideticdew.org> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CUTEXT_BUFSOURCE_H 00019 #define CUTEXT_BUFSOURCE_H 00020 00021 #include <cutext/source.h> 00022 #include <cu/inherit.h> 00023 #include <cu/buffer.h> 00024 00025 CU_BEGIN_DECLARATIONS 00026 /** \defgroup cutext_bufsource_h cutext/bufsource.h: Buffer Source 00027 ** @{ \ingroup cutext_mod 00028 ** 00029 ** For most purposes, \ref cutext_source_stack_buffer should be sufficient, 00030 ** but some details of the buffer sources are exposed here to facilitate 00031 ** inlining and better control. 00032 **/ 00033 00034 struct cutext_bufsource 00035 { 00036 cu_inherit (cutext_source); 00037 cutext_source_t subsrc; 00038 struct cu_buffer buf; 00039 }; 00040 00041 void cutext_bufsource_init(cutext_bufsource_t bsrc, cutext_source_t subsrc); 00042 00043 size_t cutext_bufsource_read(cutext_bufsource_t bsrc, void *buf, size_t size); 00044 00045 void const *cutext_bufsource_look(cutext_bufsource_t bsrc, 00046 size_t req_size, size_t *act_size); 00047 00048 CU_SINLINE void cutext_bufsource_close(cutext_bufsource_t bsrc) 00049 { cutext_source_close(bsrc->subsrc); } 00050 00051 /** @} */ 00052 CU_END_DECLARATIONS 00053 00054 #endif