2 * Copyright (c) 2013, Olivier MATZ <zer0@droids-corp.org>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the University of California, Berkeley nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * Confizery configuration node specific operations
32 * This file describes specific node operations, called internally by
33 * cfzy_confnode module.
36 #ifndef _CFZY_CONFNODE_OPS_H_
37 #define _CFZY_CONFNODE_OPS_H_
41 #include "cfzy_conftree_parser.h"
44 struct cfzy_token_list;
47 * Node operation to free the specific node data. Called by
48 * cfzy_confnode_free().
50 typedef void (confnode_free_t)(struct cfzy_confnode *n);
53 * Specific node operation to parse a conftree line, expecting a new
54 * attribute. Called by cfzy_confnode_add_attr().
56 typedef enum cfzy_parse_return
57 (confnode_add_attr_t)(struct cfzy_confnode *n,
58 const struct cfzy_token_list *tklist,
62 * Specific node operation to close a node beeing parsed. Called by
63 * cfzy_confnode_close().
65 typedef int (confnode_close_t)(struct cfzy_confnode *n);
68 * Specific node operation that writes the configuration in a
69 * file. Called by cfzy_confnode_dotconfig_write().
71 typedef int (confnode_dotconfig_write_t)(const struct cfzy_confnode *n, FILE *f);
74 * Specific node operation that writes the configuration in a C header
75 * file. Called by cfzy_confnode_c_hdr_write().
77 typedef int (confnode_c_hdr_write_t)(const struct cfzy_confnode *n, FILE *f);
80 * Specific node operation that returns the boolean value of the node
81 * given the string value. Called by cfzy_confnode_str2bool().
83 typedef int (confnode_str2bool_t)(const struct cfzy_confnode *n,
84 const char *strvalue);
87 * Specific node operation that returns a string identifying the node
88 * type. Called by cfzy_confnode_get_type_str().
90 typedef const char *(confnode_get_type_str_t)(const struct cfzy_confnode *n);
93 * Specific node operation to set user value of a configuration
94 * node. Called by cfzy_confnode_set_uservalue().
96 typedef int (confnode_set_uservalue_t)(struct cfzy_confnode *n,
97 const char *strvalue);
99 /* all node-specific operations */
100 struct cfzy_confnode_ops {
101 confnode_free_t *free; /**< free specific node data */
102 confnode_add_attr_t *add_attr; /**< try to parse specific attr */
103 confnode_close_t *close; /**< close node beeing parsed */
104 confnode_dotconfig_write_t *dotconfig_write; /**< write in dotconfig */
105 confnode_c_hdr_write_t *c_hdr_write; /**< write in C header file */
106 confnode_str2bool_t *str2bool; /**< check strvalue and
108 confnode_get_type_str_t *get_type_str; /**< return type string */
109 confnode_set_uservalue_t *set_uservalue; /**< check and set user val */
112 #endif /* _CFZY_CONFNODE_OPS_H_ */