libdebian-installer
|
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, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef DEBIAN_INSTALLER__PARSER_H 00021 #define DEBIAN_INSTALLER__PARSER_H 00022 00023 #include <debian-installer/hash.h> 00024 #include <debian-installer/slist.h> 00025 #include <debian-installer/string.h> 00026 00027 #include <stdbool.h> 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include <string.h> 00031 00032 typedef struct di_parser_info di_parser_info; 00033 typedef struct di_parser_fieldinfo di_parser_fieldinfo; 00034 00049 typedef void di_parser_fields_function_read (void **data, const di_parser_fieldinfo *fip, di_rstring *field_modifier, di_rstring *value, void *user_data); 00050 00058 typedef void di_parser_fields_function_write_callback (const di_rstring *field, const di_rstring *value, void *data); 00059 00070 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); 00071 00076 typedef void *di_parser_read_entry_new (void *user_data); 00077 00082 typedef int di_parser_read_entry_finish (void *data, void *user_data); 00083 00088 typedef void *di_parser_write_entry_next (void **state_data, void *user_data); 00089 00093 struct di_parser_info 00094 { 00095 di_hash_table *table; 00096 di_slist list; 00097 bool modifier; 00098 bool wildcard; 00099 }; 00100 00104 struct di_parser_fieldinfo 00105 { 00106 di_rstring key; 00107 di_parser_fields_function_read *read; 00108 di_parser_fields_function_write *write; 00109 unsigned int integer; 00111 }; 00112 00116 #define DI_PARSER_FIELDINFO(name, read, write, integer) \ 00117 { { name, sizeof (name) - 1 }, read, write, integer } 00118 00119 di_parser_fields_function_read 00123 di_parser_read_boolean, 00127 di_parser_read_int, 00131 di_parser_read_rstring, 00135 di_parser_read_string; 00136 00137 di_parser_fields_function_write 00141 di_parser_write_boolean, 00145 di_parser_write_int, 00149 di_parser_write_rstring, 00153 di_parser_write_string; 00154 00155 di_parser_info *di_parser_info_alloc (void); 00156 void di_parser_info_free (di_parser_info *info); 00157 00158 void di_parser_info_add (di_parser_info *info, const di_parser_fieldinfo *fieldinfo[]); 00159 00161 #endif