parser.h

00001 /*
00002  * parser.h
00003  *
00004  * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * $Id: parser.h 29603 2005-07-31 16:10:46Z cjwatson $
00021  */
00022 
00023 #ifndef DEBIAN_INSTALLER__PARSER_H
00024 #define DEBIAN_INSTALLER__PARSER_H
00025 
00026 #include <debian-installer/hash.h>
00027 #include <debian-installer/slist.h>
00028 #include <debian-installer/string.h>
00029 
00030 #include <stdbool.h>
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <string.h>
00034 
00035 typedef struct di_parser_info di_parser_info;
00036 typedef struct di_parser_fieldinfo di_parser_fieldinfo;
00037 
00052 typedef void di_parser_fields_function_read (void **data, const di_parser_fieldinfo *fip, di_rstring *field_modifier, di_rstring *value, void *user_data);
00053 
00061 typedef void di_parser_fields_function_write_callback (const di_rstring *field, const di_rstring *value, void *data);
00062 
00073 typedef void di_parser_fields_function_write (void **data, const di_parser_fieldinfo *fip, di_parser_fields_function_write_callback callback, void *callback_data, void *user_data);
00074 
00079 typedef void *di_parser_read_entry_new (void *user_data);
00080 
00085 typedef int di_parser_read_entry_finish (void *data, void *user_data);
00086 
00091 typedef void *di_parser_write_entry_next (void **state_data, void *user_data);
00092 
00096 struct di_parser_info
00097 {
00098   di_hash_table *table;                                 
00099   di_slist list;                                        
00100   bool modifier;                                        
00101   bool wildcard;                                        
00102 };
00103 
00107 struct di_parser_fieldinfo
00108 {
00109   di_rstring key;                                       
00110   di_parser_fields_function_read *read;                 
00111   di_parser_fields_function_write *write;               
00112   unsigned int integer;                                 
00114 };
00115 
00119 #define DI_PARSER_FIELDINFO(name, read, write, integer) \
00120   { { name, sizeof (name) - 1 }, read, write, integer }
00121 
00122 di_parser_fields_function_read
00126   di_parser_read_boolean,
00130   di_parser_read_int,
00134   di_parser_read_rstring,
00138   di_parser_read_string;
00139 
00140 di_parser_fields_function_write
00144   di_parser_write_boolean,
00148   di_parser_write_int,
00152   di_parser_write_rstring,
00156   di_parser_write_string;
00157 
00158 di_parser_info *di_parser_info_alloc (void);
00159 void di_parser_info_free (di_parser_info *info);
00160 
00161 void di_parser_info_add (di_parser_info *info, const di_parser_fieldinfo *fieldinfo[]);
00162 
00164 #endif

Generated on Sat Sep 29 08:45:16 2007 for libdebian-installer by  doxygen 1.5.1