/*\ * libLB - The LBPP support library * Copyright (C) 2001 Anthony Liguori * * libLB is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * libLB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \*/ #ifndef _LB_DEVICES_H #define _LB_DEVICES_H #ifndef _LB_H #error This file is not meant to be included directly #endif #define MAX_DEV_NAME 128 #define LB_DEV_NONE 0x00 #define LB_DEV_RANDOM 0x01 #define LB_DEV_STREAM 0x02 #define LB_DEV_READ 0x04 #define LB_DEV_WRITE 0x08 #define LB_DEV_RDONLY (LB_DEV_READ) #define LB_DEV_RDWR (LB_DEV_READ | LB_DEV_WRITE) #define LB_DEV_CHAR (LB_DEV_STREAM) #define LB_DEV_BLOCK (LB_DEV_STREAM | LB_DEV_RANDOM) typedef int (*LBDevOpen)(LBContext *, char *open, void *); typedef void (*LBDevClose)(LBContext *, void *); typedef int (*LBDevEOF)(LBContext *, void *); typedef int (*LBDevLOF)(LBContext *, void *); typedef LBString (*LBDevReadStr)(LBContext *, void *, size_t); typedef int (*LBDevWriteStr)(LBContext *, void *, LBString); typedef double (*LBDevReadDb)(LBContext *, void *); typedef int (*LBDevWriteDb)(LBContext *, void *, double); typedef LBString (*LBDevReadStrFrom)(LBContext *, void *, int, size_t); typedef int (*LBDevWriteStrTo)(LBContext *, void *, int, LBString); typedef double (*LBDevReadDbFrom)(LBContext *, void *, int); typedef int (*LBDevWriteDbTo)(LBContext *, void *, int, double); typedef struct _lb_device_class_tag { char name[MAX_DEV_NAME]; } LBDeviceClass; typedef struct _lb_device_tag { char name[MAX_DEV_NAME]; int dev_type; int cid; LBDevOpen open; LBDevClose close; LBDevEOF eof; LBDevLOF lof; // Stream functions LBDevReadStr read_str; LBDevWriteStr write_str; LBDevReadDb read_db; LBDevWriteDb write_db; // Random access functions LBDevReadStrFrom read_str_from; LBDevWriteStrTo write_str_to; LBDevReadDbFrom read_db_from; LBDevWriteDbTo write_db_to; } LBDevice; LBDevice *lb_register_dev(LBContext *cxt, char *name, char *class); LBDevice *lb_get_dev(LBContext *cxt, char *name); int lb_register_dev_cid(LBContext *cxt, char *name); int lb_get_dev_cid(LBContext *cxt, char *name); #endif