/*\ * 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_H #define _LB_H #include #include #include "strings.h" typedef struct _lb_context_tag LBContext; #include "devices.h" typedef enum { STRING, DOUBLE, HANDLE, } Type; typedef struct _label_tag { jmp_buf jmp; LBString name; } Label; typedef struct _handle_tag { LBDevice *dev; void *data; } LBHandle; typedef struct _variable_tag { Type type; LBString name; union { double db; double *db_v; LBString str; LBString *str_v; LBHandle hnd; LBHandle *hnd_v; } data; int rows; int columns; } Variable; typedef enum { VA_END_SOFT, VA_END_HARD, VA_END_COMMA } LBVarArgEnd; typedef struct _lb_var_arg_tag { int reference; union { Type var_type; LBVarArgEnd end_type; } type; union { LBString str; double db; Variable *var; } data; struct _lb_var_arg_tag *next; } LBVarArg; typedef struct _lb_context_tag { char *source; Variable *vars; int vars_size; int vars_capacity; Label *labels; int labels_size; int labels_capacity; LBDevice *devs; int devs_size; int devs_capacity; LBDeviceClass *dev_class; int dev_class_size; int dev_class_capacity; jmp_buf *jmps; int jmps_size; int jmps_capacity; } _LBContext; void lb_init_cxt(LBContext *cxt, int argc, char **argv, int num_vars, int num_labels, char *source); void lb_free_cxt(LBContext *cxt); int lb_add_var(LBContext *cxt, char *name, Type type, int rows, int columns); int lb_add_label(LBContext *cxt, char *name); Variable *lb_lookup_var(LBContext *cxt, char *name); Label *lb_lookup_label(LBContext *cxt, char *name); void lb_debug_break(LBContext *cxt, int c_line); void lb_push_label(LBContext *cxt, jmp_buf *jmp); void lb_pop_label(LBContext *cxt, jmp_buf *jmp); // VarArg functions LBVarArg *lb_va_adds(LBString str, LBVarArg *list); LBVarArg *lb_va_addd(double d, LBVarArg *list); LBVarArg *lb_va_addv(Variable *var, LBVarArg *list); LBVarArg *lb_va_end(LBVarArgEnd type); void lb_va_destroy(LBVarArg *list); #include "functions.h" #include "statements.h" #endif