gfsmAutomatonIO.h
Go to the documentation of this file.
1 
2 /*=============================================================================*\
3  * File: gfsmAutomatonIO.h
4  * Author: Bryan Jurish <moocow.bovine@gmail.com>
5  * Description: finite state machine library: automata: I/O
6  *
7  * Copyright (c) 2004-2007 Bryan Jurish.
8  *
9  * For information on usage and redistribution, and for a DISCLAIMER
10  * OF ALL WARRANTIES, see the file "COPYING" in this distribution.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 3 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *=============================================================================*/
26 
31 #ifndef _GFSM_AUTOMATON_IO_H
32 #define _GFSM_AUTOMATON_IO_H
33 
34 #include <gfsmAutomaton.h>
35 #include <gfsmVersion.h>
36 
37 /*======================================================================
38  * Types
39  */
41 typedef struct {
42  gchar magic[16];
49  guint32 srtype;
50  guint32 unused1;
51  guint32 unused2;
52  guint32 unused3;
54 
56 typedef struct {
57  guint32 is_valid : 1;
58  guint32 is_final : 1;
59  guint32 unused : 30;
60  guint32 n_arcs;
62 
63 
65 //typedef gfsmArc gfsmStoredArc;
66 typedef struct {
72 
73 /*======================================================================
74  * Constants
75  */
76 /* Scanner config for gfsm_automaton_compile() */
77 //extern const GScannerConfig gfsm_automaton_scanner_config;
78 
80 extern const gchar gfsm_header_magic[16];
81 
84 
87 
88 /*======================================================================
89  * Methods: Binary I/O
90  */
92 
93 
96 
99 
101 gboolean gfsm_automaton_load_bin_file(gfsmAutomaton *fsm, FILE *f, gfsmError **errp);
102 
104 gboolean gfsm_automaton_load_bin_filename(gfsmAutomaton *fsm, const gchar *filename, gfsmError **errp);
105 
107 gboolean gfsm_automaton_load_bin_gstring(gfsmAutomaton *fsm, GString *gs, gfsmError **errp);
108 
109 
112 
114 gboolean gfsm_automaton_save_bin_file(gfsmAutomaton *fsm, FILE *f, gfsmError **errp);
115 
117 gboolean gfsm_automaton_save_bin_filename_nc(gfsmAutomaton *fsm, const gchar *filename, gfsmError **errp);
118 
123 gboolean gfsm_automaton_save_bin_filename(gfsmAutomaton *fsm, const gchar *filename, int zlevel, gfsmError **errp);
124 
126 gboolean gfsm_automaton_save_bin_gstring(gfsmAutomaton *fsm, GString *gs, gfsmError **errp);
127 
129 
130 /*======================================================================
131  * Automaton Methods: Text I/O
132  */
134 
135 
138  gfsmIOHandle *ioh,
139  gfsmAlphabet *lo_alphabet,
140  gfsmAlphabet *hi_alphabet,
141  gfsmAlphabet *state_alphabet,
142  gfsmError **errp);
143 
144 
147  FILE *f,
148  gfsmAlphabet *lo_alphabet,
149  gfsmAlphabet *hi_alphabet,
150  gfsmAlphabet *state_alphabet,
151  gfsmError **errp);
152 
154 #define gfsm_automaton_compile_file(fsm,filep,errp) \
155  gfsm_automaton_compile_file_full((fsm),(filep),NULL,NULL,NULL,(errp))
156 
159  const gchar *filename,
160  gfsmAlphabet *lo_alphabet,
161  gfsmAlphabet *hi_alphabet,
162  gfsmAlphabet *state_alphabet,
163  gfsmError **errp);
164 
166 #define gfsm_automaton_compile_filename(fsm,filename,errp) \
167  gfsm_automaton_compile_filename_full((fsm),(filename),NULL,NULL,NULL,(errp))
168 
171  GString *gs,
172  gfsmAlphabet *lo_alphabet,
173  gfsmAlphabet *hi_alphabet,
174  gfsmAlphabet *state_alphabet,
175  gfsmError **errp);
176 
177 
178 /*-----------------------*/
179 
182  gfsmIOHandle *ioh,
183  gfsmAlphabet *lo_alphabet,
184  gfsmAlphabet *hi_alphabet,
185  gfsmAlphabet *state_alphabet,
186  gfsmError **errp);
187 
188 
191  FILE *f,
192  gfsmAlphabet *lo_alphabet,
193  gfsmAlphabet *hi_alphabet,
194  gfsmAlphabet *state_alphabet,
195  int zlevel,
196  gfsmError **errp);
197 
199 #define gfsm_automaton_print_file(fsm,filep,errp) \
200  gfsm_automaton_print_file_full((fsm),(filep),NULL,NULL,NULL,0,(errp))
201 
204  const gchar *filename,
205  gfsmAlphabet *lo_alphabet,
206  gfsmAlphabet *hi_alphabet,
207  gfsmAlphabet *state_alphabet,
208  int zlevel,
209  gfsmError **errp);
210 
212 #define gfsm_automaton_print_filename(fsm,filep,errp) \
213  gfsm_automaton_print_filename_full((fsm),(filep),NULL,NULL,NULL,0,(errp))
214 
217  GString *gs,
218  gfsmAlphabet *lo_alphabet,
219  gfsmAlphabet *hi_alphabet,
220  gfsmAlphabet *state_alphabet,
221  gfsmError **errp);
222 
224 
225 #endif /* _GFSM_AUTOMATON_IO_H */