2 * UCW Library -- FastIO on files with run-time parametrization
4 * (c) 2007 Pavel Charvat <pchar@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 #include "lib/fastbuf.h"
14 static struct fb_params fbpar_defaults = {
18 struct cf_section fbpar_cf = {
19 # define F(x) PTR_TO(struct fb_params, x)
20 CF_TYPE(struct fb_params),
23 CF_UNS("DirectIO", F(odirect)),
24 CF_UNS("BufSize", F(buffer_size)),
30 static struct cf_section fbpar_global_cf = {
32 CF_SECTION("Defaults", &fbpar_defaults, &fbpar_cf),
37 static void CONSTRUCTOR
38 fbpar_global_init(void)
40 cf_declare_section("FBParam", &fbpar_global_cf, 0);
44 fbpar_open(byte *name, int mode, struct fb_params *params)
46 params = params ? : &fbpar_defaults;
48 return bopen(name, mode, params->buffer_size);
50 return fbdir_open(name, mode, NULL);
54 fbpar_open_try(byte *name, int mode, struct fb_params *params)
56 params = params ? : &fbpar_defaults;
58 return bopen_try(name, mode, params->buffer_size);
60 return fbdir_open_try(name, mode, NULL);
64 fbpar_open_fd(int fd, struct fb_params *params)
66 params = params ? : &fbpar_defaults;
68 return bfdopen(fd, params->buffer_size);
70 return fbdir_open_fd(fd, NULL);
74 fbpar_open_tmp(struct fb_params *params)
76 params = params ? : &fbpar_defaults;
78 return bopen_tmp(params->buffer_size);
80 return fbdir_open_tmp(NULL);