summaryrefslogtreecommitdiff
path: root/gatchat/gatsyntax.h
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-08-04 18:53:25 -0500
committerMarcel Holtmann <marcel@holtmann.org>2009-08-06 17:48:48 -0700
commit82ccfae22a5d1638870d283ecf953d9b2a8a184f (patch)
treeaf398913ad121db85a0179d8c1081cc4eb45b10f /gatchat/gatsyntax.h
parentacfb52bb7e18a227a5c141af9e112ad8f4255a0b (diff)
downloadconnman-82ccfae22a5d1638870d283ecf953d9b2a8a184f.tar.gz
connman-82ccfae22a5d1638870d283ecf953d9b2a8a184f.tar.bz2
connman-82ccfae22a5d1638870d283ecf953d9b2a8a184f.zip
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.h75
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 */