2 * Copyright (C) 2007 - Renzo Davoli, Luca Bigliardi
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * @brief finite state automata for communication and parsing
21 * @author Renzo Davoli, Luca Bigliardi
28 /** A state of automata */
33 struct utmstate
*head
;
37 /** Automata buffer containing data read but not parsed yet.
38 * State machine has finished to chomp whole parse buffer
48 * In a parse machine is possible to build a list of outputs,
49 * each element can be tagged.
59 * @brief utmout_alloc - create an empty automata output buffer
61 * @return pointer to the empty buffer, NULL if error
63 struct utm_out
*utmout_alloc(void);
66 * @brief utmout_free - safe destroy output buffer list
68 * @param out automata output buffer list to free
70 void utmout_free(struct utm_out
*out
);
73 * @brief utm_alloc - create finite state automata
75 * @param conf configuration file containing the list of states
77 * @return finite state automata on success, NULL on error
79 struct utm
*utm_alloc(char *conf
);
82 * @brief utm_free - free finite state automata structure
84 * @param utm finite state automata to destroy
86 void utm_free(struct utm
*utm
);
91 * @param utm finite state automata
92 * @param buf automata buffer (related to fd)
93 * @param fd file descriptor to read and write to
94 * @param argc number of arguments in argv
95 * @param argv NULL terminated list of arguments
96 * @param out output buffer of machine
97 * @param debug run machine in verbose mode
99 * @return exit value of machine, it depends to configuration
101 int utm_run(struct utm
*utm
, struct utm_buf
*buf
, int fd
, int argc
, char **argv
, struct utm_out
*out
, int debug
);