parser.h
/*
* parser.h
*
* Copyright (C) 2003 Bastian Blank <waldi@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEBIAN_INSTALLER__PARSER_H
#define DEBIAN_INSTALLER__PARSER_H
#include <debian-installer/hash.h>
#include <debian-installer/slist.h>
#include <debian-installer/string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct di_parser_info di_parser_info;
typedef struct di_parser_fieldinfo di_parser_fieldinfo;
typedef void di_parser_fields_function_read (void **data, const di_parser_fieldinfo *fip, di_rstring *field_modifier, di_rstring *value, void *user_data);
typedef void di_parser_fields_function_write_callback (const di_rstring *field, const di_rstring *value, void *data);
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);
typedef void *di_parser_read_entry_new (void *user_data);
typedef int di_parser_read_entry_finish (void *data, void *user_data);
typedef void *di_parser_write_entry_next (void **state_data, void *user_data);
struct di_parser_info
{
di_hash_table *table;
di_slist list;
bool modifier;
bool wildcard;
};
struct di_parser_fieldinfo
{
di_rstring key;
di_parser_fields_function_read *read;
di_parser_fields_function_write *write;
unsigned int integer;
};
#define DI_PARSER_FIELDINFO(name, read, write, integer) \
{ { name, sizeof (name) - 1 }, read, write, integer }
di_parser_fields_function_read
di_parser_read_boolean,
di_parser_read_int,
di_parser_read_rstring,
di_parser_read_string;
di_parser_fields_function_write
di_parser_write_boolean,
di_parser_write_int,
di_parser_write_rstring,
di_parser_write_string;
di_parser_info *di_parser_info_alloc (void);
void di_parser_info_free (di_parser_info *info);
void di_parser_info_add (di_parser_info *info, const di_parser_fieldinfo *fieldinfo[]);
#endif
di_parser_write_rstring
di_parser_fields_function_write di_parser_write_rstring
Definition parser.h:149
di_parser_write_int
di_parser_fields_function_write di_parser_write_int
Definition parser.h:145
di_parser_read_boolean
di_parser_fields_function_read di_parser_read_boolean
Definition parser.h:123
di_parser_read_entry_finish
int di_parser_read_entry_finish(void *data, void *user_data)
Definition parser.h:82
di_parser_read_entry_new
void * di_parser_read_entry_new(void *user_data)
Definition parser.h:76
di_parser_write_string
di_parser_fields_function_write di_parser_write_string
Definition parser.h:153
di_parser_fields_function_write
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)
Definition parser.h:70
di_parser_fields_function_read
void di_parser_fields_function_read(void **data, const di_parser_fieldinfo *fip, di_rstring *field_modifier, di_rstring *value, void *user_data)
Definition parser.h:49
di_parser_write_entry_next
void * di_parser_write_entry_next(void **state_data, void *user_data)
Definition parser.h:88
di_parser_read_int
di_parser_fields_function_read di_parser_read_int
Definition parser.h:127
di_parser_read_rstring
di_parser_fields_function_read di_parser_read_rstring
Definition parser.h:131
di_parser_read_string
di_parser_fields_function_read di_parser_read_string
Definition parser.h:135
di_parser_write_boolean
di_parser_fields_function_write di_parser_write_boolean
Definition parser.h:141
di_parser_fields_function_write_callback
void di_parser_fields_function_write_callback(const di_rstring *field, const di_rstring *value, void *data)
Definition parser.h:58
di_hash_table
Hash table.
Definition hash.c:42
di_parser_fieldinfo
Info about a parser field.
Definition parser.h:105
di_parser_fieldinfo::write
di_parser_fields_function_write * write
Definition parser.h:108
di_parser_fieldinfo::integer
unsigned int integer
Definition parser.h:109
di_parser_fieldinfo::read
di_parser_fields_function_read * read
Definition parser.h:107
di_parser_fieldinfo::key
di_rstring key
Definition parser.h:106
di_parser_info
Parse info.
Definition parser.h:94
di_parser_info::list
di_slist list
Definition parser.h:96
di_parser_info::modifier
bool modifier
Definition parser.h:97
di_parser_info::wildcard
bool wildcard
Definition parser.h:98
di_parser_info::table
di_hash_table * table
Definition parser.h:95
di_rstring
raw string
Definition string.h:38
di_slist
Single-linked list.
Definition slist.h:37