diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-08-04 18:53:25 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-08-06 16:38:39 -0500 |
commit | 83820c88b2353c5df5badd7e509d43fc7ea4ae28 (patch) | |
tree | dda9b906697ff314a4a8ad2389c1f766a03e2785 /gatchat/gatsyntax.h | |
parent | 239ab461f72e50d830a984a790b7e5a2d1495c6a (diff) | |
download | ofono-83820c88b2353c5df5badd7e509d43fc7ea4ae28.tar.bz2 |
Refactor GAtChat to accept user-provided parsers
Intended for really broken modems. A default 27.007 compliant
parser is provided.
Diffstat (limited to 'gatchat/gatsyntax.h')
-rw-r--r-- | gatchat/gatsyntax.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/gatchat/gatsyntax.h b/gatchat/gatsyntax.h new file mode 100644 index 00000000..57edeade --- /dev/null +++ b/gatchat/gatsyntax.h @@ -0,0 +1,75 @@ +/* + * + * AT chat library with GLib integration + * + * Copyright (C) 2008-2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GATSYNTAX_H +#define __GATSYNTAX_H + +#ifdef __cplusplus +extern "C" { +#endif + +enum _GAtSyntaxExpectHint { + G_AT_SYNTAX_EXPECT_PDU, + G_AT_SYNTAX_EXPECT_MULTILINE, + G_AT_SYNTAX_EXPECT_PROMPT +}; + +typedef enum _GAtSyntaxExpectHint GAtSyntaxExpectHint; + +enum _GAtSyntaxResult { + G_AT_SYNTAX_RESULT_UNRECOGNIZED, + G_AT_SYNTAX_RESULT_UNSURE, + G_AT_SYNTAX_RESULT_LINE, + G_AT_SYNTAX_RESULT_MULTILINE, + G_AT_SYNTAX_RESULT_PDU, + G_AT_SYNTAX_RESULT_PROMPT, +}; + +typedef enum _GAtSyntaxResult GAtSyntaxResult; + +typedef struct _GAtSyntax GAtSyntax; + +typedef void (*GAtSyntaxSetHintFunc)(GAtSyntax *syntax, + GAtSyntaxExpectHint hint); +typedef GAtSyntaxResult (*GAtSyntaxFeedFunc)(GAtSyntax *syntax, + const char *bytes, gsize *len); + +struct _GAtSyntax { + gint ref_count; + int state; + GAtSyntaxSetHintFunc set_hint; + GAtSyntaxFeedFunc feed; +}; + + +GAtSyntax *g_at_syntax_new_full(GAtSyntaxFeedFunc feed, + GAtSyntaxSetHintFunc hint, + int initial_state); +GAtSyntax *g_at_syntax_new_gsmv1(); + +GAtSyntax *g_at_syntax_ref(GAtSyntax *syntax); +void g_at_syntax_unref(GAtSyntax *syntax); + +#ifdef __cplusplus +} +#endif + +#endif /* __GATSYNTAX_H */ |