aboutsummaryrefslogtreecommitdiff
path: root/libwmc
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-02-05 08:38:30 +0100
committerGuido Günther <agx@sigxcpu.org>2014-02-05 08:38:30 +0100
commit13ed135b9ae78c692dc359976eb8b54d0a3629b8 (patch)
treeae2ea713ad51d73980cf83db1411d6589dac5e8b /libwmc
parent14d771b90f5a7d3887e5e900d1fb4737477ad305 (diff)
Imported Upstream version 0.7.991upstream/0.7.991
Diffstat (limited to 'libwmc')
-rw-r--r--libwmc/AUTHORS0
-rw-r--r--libwmc/ChangeLog0
-rw-r--r--libwmc/Makefile.am2
-rw-r--r--libwmc/Makefile.in679
-rw-r--r--libwmc/NEWS0
-rw-r--r--libwmc/README0
-rw-r--r--libwmc/src/Makefile.am23
-rw-r--r--libwmc/src/Makefile.in709
-rw-r--r--libwmc/src/com.c56
-rw-r--r--libwmc/src/com.h23
-rw-r--r--libwmc/src/commands.c467
-rw-r--r--libwmc/src/commands.h116
-rw-r--r--libwmc/src/errors.c58
-rw-r--r--libwmc/src/errors.h78
-rw-r--r--libwmc/src/protocol.h462
-rw-r--r--libwmc/src/result-private.h38
-rw-r--r--libwmc/src/result.c298
-rw-r--r--libwmc/src/result.h42
-rw-r--r--libwmc/src/utils.c460
-rw-r--r--libwmc/src/utils.h88
-rw-r--r--libwmc/tests/Makefile.am35
-rw-r--r--libwmc/tests/Makefile.in758
-rw-r--r--libwmc/tests/test-wmc-com.c505
-rw-r--r--libwmc/tests/test-wmc-com.h37
-rw-r--r--libwmc/tests/test-wmc-crc.c65
-rw-r--r--libwmc/tests/test-wmc-crc.h25
-rw-r--r--libwmc/tests/test-wmc-escaping.c165
-rw-r--r--libwmc/tests/test-wmc-escaping.h28
-rw-r--r--libwmc/tests/test-wmc-utils.c223
-rw-r--r--libwmc/tests/test-wmc-utils.h34
-rw-r--r--libwmc/tests/test-wmc.c115
31 files changed, 5589 insertions, 0 deletions
diff --git a/libwmc/AUTHORS b/libwmc/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libwmc/AUTHORS
diff --git a/libwmc/ChangeLog b/libwmc/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libwmc/ChangeLog
diff --git a/libwmc/Makefile.am b/libwmc/Makefile.am
new file mode 100644
index 0000000..77f28d7
--- /dev/null
+++ b/libwmc/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS=src tests
+
diff --git a/libwmc/Makefile.in b/libwmc/Makefile.in
new file mode 100644
index 0000000..2943087
--- /dev/null
+++ b/libwmc/Makefile.in
@@ -0,0 +1,679 @@
+# Makefile.in generated by automake 1.13.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = libwmc
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am AUTHORS \
+ ChangeLog NEWS README
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+ALL_LINGUAS = @ALL_LINGUAS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DBUS_SYS_DIR = @DBUS_SYS_DIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
+INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
+INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
+INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@
+LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@
+LIBMM_LIBS = @LIBMM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MBIM_CFLAGS = @MBIM_CFLAGS@
+MBIM_LIBS = @MBIM_LIBS@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MMCLI_CFLAGS = @MMCLI_CFLAGS@
+MMCLI_LIBS = @MMCLI_LIBS@
+MM_CFLAGS = @MM_CFLAGS@
+MM_LIBS = @MM_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
+POLKIT_CFLAGS = @POLKIT_CFLAGS@
+POLKIT_LIBS = @POLKIT_LIBS@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
+QMI_CFLAGS = @QMI_CFLAGS@
+QMI_LIBS = @QMI_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@
+UDEV_BASE_DIR = @UDEV_BASE_DIR@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+intltool__v_merge_options_ = @intltool__v_merge_options_@
+intltool__v_merge_options_0 = @intltool__v_merge_options_0@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = src tests
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libwmc/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu libwmc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(am__recursive_targets) install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+ check-am clean clean-generic clean-libtool cscopelist-am ctags \
+ ctags-am distclean distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libwmc/NEWS b/libwmc/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libwmc/NEWS
diff --git a/libwmc/README b/libwmc/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libwmc/README
diff --git a/libwmc/src/Makefile.am b/libwmc/src/Makefile.am
new file mode 100644
index 0000000..4620501
--- /dev/null
+++ b/libwmc/src/Makefile.am
@@ -0,0 +1,23 @@
+noinst_LTLIBRARIES = libwmc.la
+
+
+libwmc_la_CPPFLAGS = \
+ $(MM_CFLAGS)
+
+libwmc_la_SOURCES = \
+ protocol.h \
+ result-private.h \
+ errors.c \
+ errors.h \
+ utils.c \
+ utils.h \
+ result.c \
+ result.h \
+ com.c \
+ com.h \
+ commands.c \
+ commands.h
+
+libwmc_la_LIBADD = \
+ $(MM_LIBS)
+
diff --git a/libwmc/src/Makefile.in b/libwmc/src/Makefile.in
new file mode 100644
index 0000000..5ae8b42
--- /dev/null
+++ b/libwmc/src/Makefile.in
@@ -0,0 +1,709 @@
+# Makefile.in generated by automake 1.13.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = libwmc/src
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libwmc_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libwmc_la_OBJECTS = libwmc_la-errors.lo libwmc_la-utils.lo \
+ libwmc_la-result.lo libwmc_la-com.lo libwmc_la-commands.lo
+libwmc_la_OBJECTS = $(am_libwmc_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libwmc_la_SOURCES)
+DIST_SOURCES = $(libwmc_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALL_LINGUAS = @ALL_LINGUAS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DBUS_SYS_DIR = @DBUS_SYS_DIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
+INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
+INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
+INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@
+LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@
+LIBMM_LIBS = @LIBMM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MBIM_CFLAGS = @MBIM_CFLAGS@
+MBIM_LIBS = @MBIM_LIBS@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MMCLI_CFLAGS = @MMCLI_CFLAGS@
+MMCLI_LIBS = @MMCLI_LIBS@
+MM_CFLAGS = @MM_CFLAGS@
+MM_LIBS = @MM_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
+POLKIT_CFLAGS = @POLKIT_CFLAGS@
+POLKIT_LIBS = @POLKIT_LIBS@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
+QMI_CFLAGS = @QMI_CFLAGS@
+QMI_LIBS = @QMI_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@
+UDEV_BASE_DIR = @UDEV_BASE_DIR@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+intltool__v_merge_options_ = @intltool__v_merge_options_@
+intltool__v_merge_options_0 = @intltool__v_merge_options_0@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libwmc.la
+libwmc_la_CPPFLAGS = \
+ $(MM_CFLAGS)
+
+libwmc_la_SOURCES = \
+ protocol.h \
+ result-private.h \
+ errors.c \
+ errors.h \
+ utils.c \
+ utils.h \
+ result.c \
+ result.h \
+ com.c \
+ com.h \
+ commands.c \
+ commands.h
+
+libwmc_la_LIBADD = \
+ $(MM_LIBS)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libwmc/src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu libwmc/src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+libwmc.la: $(libwmc_la_OBJECTS) $(libwmc_la_DEPENDENCIES) $(EXTRA_libwmc_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(libwmc_la_OBJECTS) $(libwmc_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwmc_la-com.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwmc_la-commands.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwmc_la-errors.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwmc_la-result.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwmc_la-utils.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libwmc_la-errors.lo: errors.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libwmc_la-errors.lo -MD -MP -MF $(DEPDIR)/libwmc_la-errors.Tpo -c -o libwmc_la-errors.lo `test -f 'errors.c' || echo '$(srcdir)/'`errors.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libwmc_la-errors.Tpo $(DEPDIR)/libwmc_la-errors.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='errors.c' object='libwmc_la-errors.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libwmc_la-errors.lo `test -f 'errors.c' || echo '$(srcdir)/'`errors.c
+
+libwmc_la-utils.lo: utils.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libwmc_la-utils.lo -MD -MP -MF $(DEPDIR)/libwmc_la-utils.Tpo -c -o libwmc_la-utils.lo `test -f 'utils.c' || echo '$(srcdir)/'`utils.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libwmc_la-utils.Tpo $(DEPDIR)/libwmc_la-utils.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utils.c' object='libwmc_la-utils.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libwmc_la-utils.lo `test -f 'utils.c' || echo '$(srcdir)/'`utils.c
+
+libwmc_la-result.lo: result.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libwmc_la-result.lo -MD -MP -MF $(DEPDIR)/libwmc_la-result.Tpo -c -o libwmc_la-result.lo `test -f 'result.c' || echo '$(srcdir)/'`result.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libwmc_la-result.Tpo $(DEPDIR)/libwmc_la-result.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='result.c' object='libwmc_la-result.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libwmc_la-result.lo `test -f 'result.c' || echo '$(srcdir)/'`result.c
+
+libwmc_la-com.lo: com.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libwmc_la-com.lo -MD -MP -MF $(DEPDIR)/libwmc_la-com.Tpo -c -o libwmc_la-com.lo `test -f 'com.c' || echo '$(srcdir)/'`com.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libwmc_la-com.Tpo $(DEPDIR)/libwmc_la-com.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='com.c' object='libwmc_la-com.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libwmc_la-com.lo `test -f 'com.c' || echo '$(srcdir)/'`com.c
+
+libwmc_la-commands.lo: commands.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libwmc_la-commands.lo -MD -MP -MF $(DEPDIR)/libwmc_la-commands.Tpo -c -o libwmc_la-commands.lo `test -f 'commands.c' || echo '$(srcdir)/'`commands.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libwmc_la-commands.Tpo $(DEPDIR)/libwmc_la-commands.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands.c' object='libwmc_la-commands.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libwmc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libwmc_la-commands.lo `test -f 'commands.c' || echo '$(srcdir)/'`commands.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libwmc/src/com.c b/libwmc/src/com.c
new file mode 100644
index 0000000..2f4d3b3
--- /dev/null
+++ b/libwmc/src/com.c
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "com.h"
+#include "errors.h"
+
+int
+wmc_port_setup (int fd)
+{
+ struct termios stbuf;
+
+ errno = 0;
+ memset (&stbuf, 0, sizeof (stbuf));
+ if (tcgetattr (fd, &stbuf) != 0) {
+ wmc_err (0, "tcgetattr() error: %d", errno);
+ return -WMC_ERROR_SERIAL_CONFIG_FAILED;
+ }
+
+ stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
+ stbuf.c_iflag &= ~(HUPCL | IUTF8 | IUCLC | ISTRIP | IXON | IXOFF | IXANY | ICRNL);
+ stbuf.c_oflag &= ~(OPOST | OCRNL | ONLCR | OLCUC | ONLRET);
+ stbuf.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO | ECHOE | ECHOK | ECHONL);
+ stbuf.c_lflag &= ~(NOFLSH | XCASE | TOSTOP | ECHOPRT | ECHOCTL | ECHOKE);
+ stbuf.c_cc[VMIN] = 1;
+ stbuf.c_cc[VTIME] = 0;
+ stbuf.c_cc[VEOF] = 1;
+ stbuf.c_cflag |= (B115200 | CS8 | CREAD | 0 | 0); /* No parity, 1 stop bit */
+
+ errno = 0;
+ if (tcsetattr (fd, TCSANOW, &stbuf) < 0) {
+ wmc_err (0, "tcgetattr() error: %d", errno);
+ return -WMC_ERROR_SERIAL_CONFIG_FAILED;
+ }
+
+ return 0;
+}
+
diff --git a/libwmc/src/com.h b/libwmc/src/com.h
new file mode 100644
index 0000000..219a016
--- /dev/null
+++ b/libwmc/src/com.h
@@ -0,0 +1,23 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_COM_H
+#define LIBWMC_COM_H
+
+int wmc_port_setup (int fd);
+
+#endif /* LIBWMC_COM_H */
diff --git a/libwmc/src/commands.c b/libwmc/src/commands.c
new file mode 100644
index 0000000..d3567e8
--- /dev/null
+++ b/libwmc/src/commands.c
@@ -0,0 +1,467 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+#include <time.h>
+
+#include "commands.h"
+#include "errors.h"
+#include "result-private.h"
+#include "utils.h"
+#include "protocol.h"
+
+
+/**********************************************************************/
+
+static int
+check_command (const char *buf, size_t len, u_int8_t cmd, size_t min_len)
+{
+ if (len < 1) {
+ wmc_err (0, "Zero-length response");
+ return -WMC_ERROR_RESPONSE_BAD_LENGTH;
+ }
+
+ if ((u_int8_t) buf[0] != WMC_CMD_MARKER) {
+ wmc_err (0, "Missing WMC command marker (expected 0x%02X, got 0x%02X)",
+ WMC_CMD_MARKER, (u_int8_t) buf[0]);
+ return -WMC_ERROR_RESPONSE_UNEXPECTED;
+ }
+
+ if ((u_int8_t) buf[1] != cmd) {
+ wmc_err (0, "Unexpected WMC command response (expected 0x%02X, got 0x%02X)",
+ (u_int8_t) cmd, (u_int8_t) buf[1]);
+ return -WMC_ERROR_RESPONSE_UNEXPECTED;
+ }
+
+ if (len < min_len) {
+ wmc_err (0, "WMC command %d response not long enough (got %zu, expected "
+ "at least %zu).", cmd, len, min_len);
+ return -WMC_ERROR_RESPONSE_BAD_LENGTH;
+ }
+
+ return 0;
+}
+
+/**********************************************************************/
+
+/**
+ * wmc_cmd_init_new:
+ * @buf: buffer in which to store constructed command
+ * @buflen: size of @buf
+ * @wmc2: if %TRUE add additional data that later-model devices (UML290) want
+ *
+ * Returns: size of the constructed command on success, or 0 on failure
+ */
+size_t
+wmc_cmd_init_new (char *buf, size_t buflen, int wmc2)
+{
+ wmc_return_val_if_fail (buf != NULL, 0);
+
+ if (wmc2) {
+ WmcCmdInit2 *cmd = (WmcCmdInit2 *) buf;
+ time_t now;
+ struct tm *tm;
+
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+
+ now = time (NULL);
+ tm = localtime (&now);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->hdr.marker = WMC_CMD_MARKER;
+ cmd->hdr.cmd = WMC_CMD_INIT;
+ cmd->year = htole16 (tm->tm_year + 1900);
+ cmd->month = tm->tm_mon + 1;
+ cmd->day = htobe16 (tm->tm_mday);
+ cmd->hours = htobe16 (tm->tm_hour);
+ cmd->minutes = htobe16 (tm->tm_min);
+ cmd->seconds = htobe16 (tm->tm_sec);
+ return sizeof (*cmd);
+ } else {
+ WmcCmdHeader *cmd = (WmcCmdHeader *) buf;
+
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->marker = WMC_CMD_MARKER;
+ cmd->cmd = WMC_CMD_INIT;
+ return sizeof (*cmd);
+ }
+}
+
+WmcResult *
+wmc_cmd_init_result (const char *buf, size_t buflen, int wmc2)
+{
+ wmc_return_val_if_fail (buf != NULL, NULL);
+
+ if (wmc2) {
+ if (check_command (buf, buflen, WMC_CMD_INIT, sizeof (WmcCmdInit2Rsp)) < 0)
+ return NULL;
+ } else {
+ if (check_command (buf, buflen, WMC_CMD_INIT, sizeof (WmcCmdHeader)) < 0)
+ return NULL;
+ }
+
+ return wmc_result_new ();
+}
+
+/**********************************************************************/
+
+size_t
+wmc_cmd_device_info_new (char *buf, size_t buflen)
+{
+ WmcCmdHeader *cmd = (WmcCmdHeader *) buf;
+
+ wmc_return_val_if_fail (buf != NULL, 0);
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->marker = WMC_CMD_MARKER;
+ cmd->cmd = WMC_CMD_DEVICE_INFO;
+ return sizeof (*cmd);
+}
+
+WmcResult *
+wmc_cmd_device_info_result (const char *buf, size_t buflen)
+{
+ WmcResult *r = NULL;
+ WmcCmdDeviceInfoRsp *rsp = (WmcCmdDeviceInfoRsp *) buf;
+ WmcCmdDeviceInfo2Rsp *rsp2 = (WmcCmdDeviceInfo2Rsp *) buf;
+ WmcCmdDeviceInfo3Rsp *rsp3 = (WmcCmdDeviceInfo3Rsp *) buf;
+ char tmp[65];
+
+ wmc_return_val_if_fail (buf != NULL, NULL);
+
+ if (check_command (buf, buflen, WMC_CMD_DEVICE_INFO, sizeof (WmcCmdDeviceInfo3Rsp)) < 0) {
+ rsp3 = NULL;
+ if (check_command (buf, buflen, WMC_CMD_DEVICE_INFO, sizeof (WmcCmdDeviceInfo2Rsp)) < 0) {
+ rsp2 = NULL;
+ if (check_command (buf, buflen, WMC_CMD_DEVICE_INFO, sizeof (WmcCmdDeviceInfoRsp)) < 0)
+ return NULL;
+ }
+ }
+
+ r = wmc_result_new ();
+
+ /* Manf */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp->manf) <= sizeof (tmp));
+ memcpy (tmp, rsp->manf, sizeof (rsp->manf));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MANUFACTURER, tmp);
+
+ /* Model */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp->model) <= sizeof (tmp));
+ memcpy (tmp, rsp->model, sizeof (rsp->model));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MODEL, tmp);
+
+ /* Firmware revision */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp->fwrev) <= sizeof (tmp));
+ memcpy (tmp, rsp->fwrev, sizeof (rsp->fwrev));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_FW_REVISION, tmp);
+
+ /* Hardware revision */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp->hwrev) <= sizeof (tmp));
+ memcpy (tmp, rsp->hwrev, sizeof (rsp->hwrev));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_HW_REVISION, tmp);
+
+ /* MIN */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp->min) <= sizeof (tmp));
+ memcpy (tmp, rsp->min, sizeof (rsp->min));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_CDMA_MIN, tmp);
+
+ wmc_result_add_u32 (r, WMC_CMD_DEVICE_INFO_ITEM_HOME_SID, le16toh (rsp->home_sid));
+ wmc_result_add_u32 (r, WMC_CMD_DEVICE_INFO_ITEM_PRL_VERSION, le16toh (rsp->prlver));
+ wmc_result_add_u32 (r, WMC_CMD_DEVICE_INFO_ITEM_ERI_VERSION, le16toh (rsp->eriver));
+
+ if (rsp2) {
+ /* MEID */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp2->meid) <= sizeof (tmp));
+ memcpy (tmp, rsp2->meid, sizeof (rsp2->meid));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MEID, tmp);
+
+ /* IMEI */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp2->imei) <= sizeof (tmp));
+ memcpy (tmp, rsp2->imei, sizeof (rsp2->imei));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_IMEI, tmp);
+
+ /* IMSI */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp2->iccid) <= sizeof (tmp));
+ memcpy (tmp, rsp2->iccid, sizeof (rsp2->iccid));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_ICCID, tmp);
+ }
+
+ if (rsp3) {
+ /* MCC */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp3->mcc) <= sizeof (tmp));
+ memcpy (tmp, rsp3->mcc, sizeof (rsp3->mcc));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MCC, tmp);
+
+ /* MNC */
+ memset (tmp, 0, sizeof (tmp));
+ wmc_assert (sizeof (rsp3->mnc) <= sizeof (tmp));
+ memcpy (tmp, rsp3->mnc, sizeof (rsp3->mnc));
+ wmc_result_add_string (r, WMC_CMD_DEVICE_INFO_ITEM_MNC, tmp);
+ }
+
+ return r;
+}
+
+/**********************************************************************/
+
+size_t
+wmc_cmd_network_info_new (char *buf, size_t buflen)
+{
+ WmcCmdHeader *cmd = (WmcCmdHeader *) buf;
+
+ wmc_return_val_if_fail (buf != NULL, 0);
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->marker = WMC_CMD_MARKER;
+ cmd->cmd = WMC_CMD_NET_INFO;
+ return sizeof (*cmd);
+}
+
+static wmcbool
+is_gsm_service (u_int8_t service)
+{
+ return (service == WMC_SERVICE_GSM || service == WMC_SERVICE_GPRS || service == WMC_SERVICE_EDGE);
+}
+
+static wmcbool
+is_umts_service (u_int8_t service)
+{
+ return (service == WMC_SERVICE_UMTS || service == WMC_SERVICE_HSDPA
+ || service == WMC_SERVICE_HSUPA || service == WMC_SERVICE_HSPA);
+}
+
+static wmcbool
+is_cdma_service (u_int8_t service)
+{
+ return (service == WMC_SERVICE_IS95A || service == WMC_SERVICE_IS95B || service == WMC_SERVICE_1XRTT);
+}
+
+static wmcbool
+is_evdo_service (u_int8_t service)
+{
+ return (service == WMC_SERVICE_EVDO_0 || service == WMC_SERVICE_EVDO_A || service == WMC_SERVICE_EVDO_A_EHRPD);
+}
+
+static wmcbool
+is_lte_service (u_int8_t service)
+{
+ return (service == WMC_SERVICE_LTE);
+}
+
+static u_int8_t
+sanitize_dbm (u_int8_t in_dbm, u_int8_t service)
+{
+ u_int8_t cutoff;
+
+ /* 0x6A (-106 dBm) = no signal for GSM/GPRS/EDGE */
+ /* 0x7D (-125 dBm) = no signal for everything else */
+ cutoff = is_gsm_service (service) ? 0x6A : 0x7D;
+
+ return in_dbm >= cutoff ? 0 : in_dbm;
+}
+
+
+WmcResult *
+wmc_cmd_network_info_result (const char *buf, size_t buflen)
+{
+ WmcResult *r = NULL;
+ WmcCmdNetworkInfoRsp *rsp = (WmcCmdNetworkInfoRsp *) buf;
+ WmcCmdNetworkInfo2Rsp *rsp2 = (WmcCmdNetworkInfo2Rsp *) buf;
+ WmcCmdNetworkInfo3Rsp *rsp3 = (WmcCmdNetworkInfo3Rsp *) buf;
+ char tmp[65];
+ int err;
+ u_int32_t mccmnc = 0, mcc, mnc;
+
+ wmc_return_val_if_fail (buf != NULL, NULL);
+
+ err = check_command (buf, buflen, WMC_CMD_NET_INFO, sizeof (WmcCmdNetworkInfo3Rsp));
+ if (err != WMC_SUCCESS) {
+ if (err != -WMC_ERROR_RESPONSE_BAD_LENGTH)
+ return NULL;
+ rsp3 = NULL;
+
+ err = check_command (buf, buflen, WMC_CMD_NET_INFO, sizeof (WmcCmdNetworkInfo2Rsp));
+ if (err != WMC_SUCCESS) {
+ if (err != -WMC_ERROR_RESPONSE_BAD_LENGTH)
+ return NULL;
+ rsp2 = NULL;
+
+ err = check_command (buf, buflen, WMC_CMD_NET_INFO, sizeof (WmcCmdNetworkInfoRsp));
+ if (err != WMC_SUCCESS)
+ return NULL;
+ }
+ }
+
+ r = wmc_result_new ();
+
+ wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_SERVICE, rsp->service);
+
+ if (rsp2) {
+ wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_2G_DBM, sanitize_dbm (rsp2->two_g_dbm, rsp->service));
+ wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_3G_DBM, sanitize_dbm (rsp2->three_g_dbm, WMC_SERVICE_NONE));
+
+ memset (tmp, 0, sizeof (tmp));
+ if ( (is_cdma_service (rsp->service) && sanitize_dbm (rsp2->two_g_dbm, rsp->service))
+ || (is_evdo_service (rsp->service) && sanitize_dbm (rsp2->three_g_dbm, rsp->service))) {
+ /* CDMA2000 operator name */
+ wmc_assert (sizeof (rsp2->cdma_opname) <= sizeof (tmp));
+ memcpy (tmp, rsp2->cdma_opname, sizeof (rsp2->cdma_opname));
+ wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, tmp);
+ } else {
+ if ( (is_gsm_service (rsp->service) && sanitize_dbm (rsp2->two_g_dbm, rsp->service))
+ || (is_umts_service (rsp->service) && sanitize_dbm (rsp2->three_g_dbm, rsp->service))) {
+ /* GSM/UMTS operator name */
+ wmc_assert (sizeof (rsp2->tgpp_opname) <= sizeof (tmp));
+ memcpy (tmp, rsp2->tgpp_opname, sizeof (rsp2->tgpp_opname));
+ wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, tmp);
+ }
+ }
+
+ /* MCC/MNC */
+ mccmnc = le32toh (rsp2->mcc_mnc);
+ if (mccmnc < 100000)
+ mccmnc *= 10; /* account for possible 2-digit MNC */
+ mcc = mccmnc / 1000;
+ mnc = mccmnc - (mcc * 1000);
+
+ if (mcc > 100) {
+ memset (tmp, 0, sizeof (tmp));
+ snprintf (tmp, sizeof (tmp), "%u", mccmnc / 1000);
+ wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_MCC, tmp);
+
+ memset (tmp, 0, sizeof (tmp));
+ snprintf (tmp, sizeof (tmp), "%03u", mnc);
+ wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_MNC, tmp);
+ }
+ } else {
+ /* old format */
+ wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_2G_DBM, sanitize_dbm (rsp->two_g_dbm, rsp->service));
+ }
+
+ if (rsp3) {
+ wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM, sanitize_dbm (rsp3->lte_dbm, WMC_SERVICE_NONE));
+
+ memset (tmp, 0, sizeof (tmp));
+ if (is_lte_service (rsp->service) && sanitize_dbm (rsp3->lte_dbm, rsp->service)) {
+ /* LTE operator name */
+ wmc_assert (sizeof (rsp2->tgpp_opname) <= sizeof (tmp));
+ memcpy (tmp, rsp2->tgpp_opname, sizeof (rsp2->tgpp_opname));
+ wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, tmp);
+ }
+ }
+
+ return r;
+}
+
+/**********************************************************************/
+
+size_t
+wmc_cmd_get_global_mode_new (char *buf, size_t buflen)
+{
+ WmcCmdGetGlobalMode *cmd = (WmcCmdGetGlobalMode *) buf;
+
+ wmc_return_val_if_fail (buf != NULL, 0);
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->hdr.marker = WMC_CMD_MARKER;
+ cmd->hdr.cmd = WMC_CMD_GET_GLOBAL_MODE;
+ return sizeof (*cmd);
+}
+
+WmcResult *
+wmc_cmd_get_global_mode_result (const char *buf, size_t buflen)
+{
+ WmcResult *r = NULL;
+ WmcCmdGetGlobalModeRsp *rsp = (WmcCmdGetGlobalModeRsp *) buf;
+
+ wmc_return_val_if_fail (buf != NULL, NULL);
+
+ if (check_command (buf, buflen, WMC_CMD_GET_GLOBAL_MODE, sizeof (WmcCmdGetGlobalModeRsp)) < 0)
+ return NULL;
+
+ r = wmc_result_new ();
+ wmc_result_add_u8 (r, WMC_CMD_GET_GLOBAL_MODE_ITEM_MODE, rsp->mode);
+ return r;
+}
+
+/**********************************************************************/
+
+static wmcbool
+validate_mode (u_int8_t mode)
+{
+ switch (mode) {
+ case WMC_NETWORK_MODE_AUTO_CDMA:
+ case WMC_NETWORK_MODE_CDMA_ONLY:
+ case WMC_NETWORK_MODE_EVDO_ONLY:
+ case WMC_NETWORK_MODE_AUTO_GSM:
+ case WMC_NETWORK_MODE_GPRS_ONLY:
+ case WMC_NETWORK_MODE_UMTS_ONLY:
+ case WMC_NETWORK_MODE_AUTO:
+ case WMC_NETWORK_MODE_LTE_ONLY:
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+size_t
+wmc_cmd_set_global_mode_new (char *buf, size_t buflen, u_int8_t mode)
+{
+ WmcCmdSetGlobalMode *cmd = (WmcCmdSetGlobalMode *) buf;
+
+ wmc_return_val_if_fail (buf != NULL, 0);
+ wmc_return_val_if_fail (buflen >= sizeof (*cmd), 0);
+ wmc_return_val_if_fail (validate_mode (mode) == TRUE, 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->hdr.marker = WMC_CMD_MARKER;
+ cmd->hdr.cmd = WMC_CMD_SET_GLOBAL_MODE;
+ cmd->_unknown1 = 0x01;
+ cmd->mode = mode;
+ cmd->_unknown2 = 0x05;
+ cmd->_unknown3 = 0x00;
+ return sizeof (*cmd);
+}
+
+WmcResult *
+wmc_cmd_set_global_mode_result (const char *buf, size_t buflen)
+{
+ wmc_return_val_if_fail (buf != NULL, NULL);
+
+ if (check_command (buf, buflen, WMC_CMD_SET_GLOBAL_MODE, sizeof (WmcCmdGetGlobalModeRsp)) < 0)
+ return NULL;
+
+ return wmc_result_new ();
+}
+
+/**********************************************************************/
+
diff --git a/libwmc/src/commands.h b/libwmc/src/commands.h
new file mode 100644
index 0000000..3e5a483
--- /dev/null
+++ b/libwmc/src/commands.h
@@ -0,0 +1,116 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_COMMANDS_H
+#define LIBWMC_COMMANDS_H
+
+#include "result.h"
+
+/**********************************************************************/
+
+/* Generic enums */
+
+/**********************************************************************/
+
+size_t wmc_cmd_init_new (char *buf, size_t buflen, int wmc2);
+
+WmcResult * wmc_cmd_init_result (const char *buf, size_t len, int wmc2);
+
+/**********************************************************************/
+
+#define WMC_CMD_DEVICE_INFO_ITEM_MANUFACTURER "manufacturer"
+#define WMC_CMD_DEVICE_INFO_ITEM_MODEL "model"
+#define WMC_CMD_DEVICE_INFO_ITEM_FW_REVISION "firmware-revision"
+#define WMC_CMD_DEVICE_INFO_ITEM_HW_REVISION "hardware-revision"
+#define WMC_CMD_DEVICE_INFO_ITEM_CDMA_MIN "cdma-min"
+#define WMC_CMD_DEVICE_INFO_ITEM_HOME_SID "home-sid"
+#define WMC_CMD_DEVICE_INFO_ITEM_PRL_VERSION "prl-version"
+#define WMC_CMD_DEVICE_INFO_ITEM_ERI_VERSION "eri-version"
+#define WMC_CMD_DEVICE_INFO_ITEM_MEID "meid"
+#define WMC_CMD_DEVICE_INFO_ITEM_IMEI "imei"
+#define WMC_CMD_DEVICE_INFO_ITEM_ICCID "iccid"
+#define WMC_CMD_DEVICE_INFO_ITEM_MCC "mcc"
+#define WMC_CMD_DEVICE_INFO_ITEM_MNC "mnc"
+
+size_t wmc_cmd_device_info_new (char *buf, size_t buflen);
+
+WmcResult * wmc_cmd_device_info_result (const char *buf, size_t len);
+
+/**********************************************************************/
+
+enum {
+ WMC_NETWORK_SERVICE_NONE = 0,
+ WMC_NETWORK_SERVICE_AMPS = 1,
+ WMC_NETWORK_SERVICE_IS95A = 2,
+ WMC_NETWORK_SERVICE_IS95B = 3,
+ WMC_NETWORK_SERVICE_GSM = 4,
+ WMC_NETWORK_SERVICE_GPRS = 5,
+ WMC_NETWORK_SERVICE_1XRTT = 6,
+ WMC_NETWORK_SERVICE_EVDO_0 = 7,
+ WMC_NETWORK_SERVICE_UMTS = 8,
+ WMC_NETWORK_SERVICE_EVDO_A = 9,
+ WMC_NETWORK_SERVICE_EDGE = 10,
+ WMC_NETWORK_SERVICE_HSDPA = 11,
+ WMC_NETWORK_SERVICE_HSUPA = 12,
+ WMC_NETWORK_SERVICE_HSPA = 13,
+ WMC_NETWORK_SERVICE_LTE = 14,
+ WMC_NETWORK_SERVICE_EVDO_A_EHRPD = 15
+};
+
+/* One of WMC_NETWORK_SERVICE_* */
+#define WMC_CMD_NETWORK_INFO_ITEM_SERVICE "service"
+
+#define WMC_CMD_NETWORK_INFO_ITEM_2G_DBM "2g-dbm"
+#define WMC_CMD_NETWORK_INFO_ITEM_3G_DBM "3g-dbm"
+#define WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM "lte-dbm"
+#define WMC_CMD_NETWORK_INFO_ITEM_OPNAME "opname"
+#define WMC_CMD_NETWORK_INFO_ITEM_MCC "mcc"
+#define WMC_CMD_NETWORK_INFO_ITEM_MNC "mnc"
+
+size_t wmc_cmd_network_info_new (char *buf, size_t buflen);
+
+WmcResult * wmc_cmd_network_info_result (const char *buf, size_t len);
+
+/**********************************************************************/
+
+enum {
+ WMC_NETWORK_MODE_AUTO_CDMA = 0x00,
+ WMC_NETWORK_MODE_CDMA_ONLY = 0x01,
+ WMC_NETWORK_MODE_EVDO_ONLY = 0x02,
+ WMC_NETWORK_MODE_AUTO_GSM = 0x0A,
+ WMC_NETWORK_MODE_GPRS_ONLY = 0x0B,
+ WMC_NETWORK_MODE_UMTS_ONLY = 0x0C,
+ WMC_NETWORK_MODE_AUTO = 0x14,
+ WMC_NETWORK_MODE_LTE_ONLY = 0x1E,
+};
+
+/* One of WMC_NETWORK_MODE_* */
+#define WMC_CMD_GET_GLOBAL_MODE_ITEM_MODE "mode"
+
+size_t wmc_cmd_get_global_mode_new (char *buf, size_t buflen);
+
+WmcResult * wmc_cmd_get_global_mode_result (const char *buf, size_t len);
+
+/**********************************************************************/
+
+size_t wmc_cmd_set_global_mode_new (char *buf, size_t buflen, u_int8_t mode);
+
+WmcResult * wmc_cmd_set_global_mode_result (const char *buf, size_t len);
+
+/**********************************************************************/
+
+#endif /* LIBWMC_COMMANDS_H */
diff --git a/libwmc/src/errors.c b/libwmc/src/errors.c
new file mode 100644
index 0000000..0403b22
--- /dev/null
+++ b/libwmc/src/errors.c
@@ -0,0 +1,58 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "errors.h"
+#include <stdlib.h>
+#include <string.h>
+
+void
+_wmc_log (const char *file,
+ int line,
+ const char *func,
+ int level,
+ int domain,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char *message = NULL;
+ int n;
+ const char *prefix = "info";
+
+ wmc_return_if_fail (format != NULL);
+ wmc_return_if_fail (format[0] != '\0');
+
+ /* level & domain ignored for now */
+
+ if (getenv ("WMC_DEBUG") == NULL)
+ return;
+
+ va_start (args, format);
+ n = vasprintf (&message, format, args);
+ va_end (args);
+
+ if (level & LOGL_ERR)
+ prefix = "err";
+ else if (level & LOGL_DEBUG)
+ prefix = "dbg";
+
+ if (n >= 0) {
+ fprintf (stderr, "<%s> [%s:%u] %s(): %s\n", prefix, file, line, func, message);
+ free (message);
+ }
+}
+
diff --git a/libwmc/src/errors.h b/libwmc/src/errors.h
new file mode 100644
index 0000000..18a9979
--- /dev/null
+++ b/libwmc/src/errors.h
@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_ERRORS_H
+#define LIBWMC_ERRORS_H
+
+#include <config.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+enum {
+ LOGL_ERR = 0x00000001,
+ LOGL_WARN = 0x00000002,
+ LOGL_INFO = 0x00000004,
+ LOGL_DEBUG = 0x00000008
+};
+
+enum {
+ WMC_SUCCESS = 0,
+ WMC_ERROR_INVALID_ARGUMENTS = 1,
+ WMC_ERROR_SERIAL_CONFIG_FAILED = 2,
+ WMC_ERROR_VALUE_NOT_FOUND = 3,
+ WMC_ERROR_RESPONSE_UNEXPECTED = 4,
+ WMC_ERROR_RESPONSE_BAD_LENGTH = 5,
+};
+
+#define wmc_assert assert
+
+#define wmc_return_if_fail(e) \
+{ \
+ if (!(e)) { \
+ wmc_warn (0, "failed: " #e "\n"); \
+ return; \
+ } \
+}
+
+#define wmc_return_val_if_fail(e, v) \
+{ \
+ if (!(e)) { \
+ wmc_warn (0, "failed: " #e "\n"); \
+ return v; \
+ } \
+}
+
+void _wmc_log (const char *file,
+ int line,
+ const char *func,
+ int domain,
+ int level,
+ const char *format,
+ ...) __attribute__((__format__ (__printf__, 6, 7)));
+
+#define wmc_dbg(domain, ...) \
+ _wmc_log (__FILE__, __LINE__, __func__, domain, LOGL_DEBUG, ## __VA_ARGS__ )
+
+#define wmc_warn(domain, ...) \
+ _wmc_log (__FILE__, __LINE__, __func__, domain, LOGL_WARN, ## __VA_ARGS__ )
+
+#define wmc_err(domain, ...) \
+ _wmc_log (__FILE__, __LINE__, __func__, domain, LOGL_ERR, ## __VA_ARGS__ )
+
+#endif /* LIBWMC_ERRORS_H */
diff --git a/libwmc/src/protocol.h b/libwmc/src/protocol.h
new file mode 100644
index 0000000..e341f56
--- /dev/null
+++ b/libwmc/src/protocol.h
@@ -0,0 +1,462 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_PROTOCOL_H
+#define LIBWMC_PROTOCOL_H
+
+#define WMC_CMD_MARKER ((u_int8_t) 0xC8)
+
+enum {
+ WMC_CMD_GET_GLOBAL_MODE = 0x03,
+ WMC_CMD_SET_GLOBAL_MODE = 0x04,
+ WMC_CMD_DEVICE_INFO = 0x06,
+ WMC_CMD_CONNECTION_INFO = 0x0A,
+ WMC_CMD_NET_INFO = 0x0B,
+ WMC_CMD_INIT = 0x0D,
+ WMC_CMD_FIELD_TEST = 0x0F,
+ WMC_CMD_SET_OPERATOR = 0x33,
+ WMC_CMD_GET_FIRST_OPERATOR = 0x34,
+ WMC_CMD_GET_NEXT_OPERATOR = 0x35,
+ WMC_CMD_GET_APN = 0x4D,
+};
+
+/* MCC/MNC representation
+ *
+ * Various commands accept or return an MCC/MNC. When sending, convert
+ * the MCC/MNC into a number using eg. atoi() and store it as an LE 32-bit
+ * value. 3-digit MNCs appear to be sent as 3-digit only if the firmware
+ * reports them as 3-digit. For example:
+ *
+ * T-Mobile US: 310-260
+ * mcc_mnc = 0x00007932 = 31026 (note the 2-digit-only MNC)
+ *
+ * AT&T: 310-410
+ * mcc_mnc = 0x0004bc8a = 310410
+ */
+
+
+/* Generic WMC command header */
+struct WmcCmdHeader {
+ u_int8_t marker; /* Always 0xC8 */
+ u_int8_t cmd;
+} __attribute__ ((packed));
+typedef struct WmcCmdHeader WmcCmdHeader;
+
+/* Used on newer devices like the UML190 and later */
+struct WmcCmdInit2 {
+ WmcCmdHeader hdr;
+ u_int16_t year;
+ u_int8_t month;
+ u_int16_t day; /* big endian */
+ u_int16_t hours; /* big endian */
+ u_int16_t minutes; /* big endian */
+ u_int16_t seconds; /* big endian */
+ u_int8_t _unknown1[3];
+} __attribute__ ((packed));
+typedef struct WmcCmdInit2 WmcCmdInit2;
+
+struct WmcCmdInit2Rsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1[4];
+} __attribute__ ((packed));
+typedef struct WmcCmdInit2Rsp WmcCmdInit2Rsp;
+
+struct WmcCmdDeviceInfoRsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1[27];
+ char manf[64];
+ char model[64];
+ char fwrev[64];
+ char hwrev[64];
+ u_int8_t _unknown2[64];
+ u_int8_t _unknown3[64];
+ char min[10]; /* CDMA2000/IS-95 MIN */
+ u_int8_t _unknown4[12];
+ u_int16_t home_sid;
+ u_int8_t _unknown5[2];
+ u_int16_t prlver;
+ u_int8_t _unknown6[2];
+ u_int16_t eriver;
+ u_int8_t _unknown7[4];
+} __attribute__ ((packed));
+typedef struct WmcCmdDeviceInfoRsp WmcCmdDeviceInfoRsp;
+
+struct WmcCmdDeviceInfo2Rsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1[27];
+ char manf[64];
+ char model[64];
+ char fwrev[64];
+ char hwrev[64];
+ u_int8_t _unknown2[64];
+ u_int8_t _unknown3[64];
+ u_int8_t min[10]; /* CDMA2000/IS-95 MIN */
+ u_int8_t _unknown4[12];
+ u_int16_t home_sid;
+ u_int8_t _unknown5[2];
+ u_int16_t prlver;
+ u_int8_t _unknown6[2];
+ u_int16_t eriver;
+ u_int8_t _unknown7[4];
+ u_int8_t _unknown8[64];
+ u_int8_t meid[14];
+ u_int8_t _unknown10[6]; /* always zero */
+ u_int8_t imei[16];
+ u_int8_t _unknown11[6]; /* always zero */
+ u_int8_t _unknown12[16];
+ u_int8_t iccid[20];
+ u_int8_t _unknown13[6];
+} __attribute__ ((packed));
+typedef struct WmcCmdDeviceInfo2Rsp WmcCmdDeviceInfo2Rsp;
+
+struct WmcCmdDeviceInfo3Rsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1[27];
+ char manf[64];
+ char model[64];
+ char fwrev[64];
+ char hwrev[64];
+ u_int8_t _unknown2[64];
+ u_int8_t _unknown3[64];
+ u_int8_t min[10]; /* CDMA2000/IS-95 MIN */
+ u_int8_t _unknown4[12];
+ u_int16_t home_sid;
+ u_int8_t _unknown5[2];
+ u_int16_t prlver;
+ u_int8_t _unknown6[2];
+ u_int16_t eri_ver;
+ u_int8_t _unknown7[4];
+ u_int8_t _unknown8[64];
+ u_int8_t meid[14];
+ u_int8_t _unknown10[6]; /* always zero */
+ u_int8_t imei[16];
+ u_int8_t _unknown11[6]; /* always zero */
+ u_int8_t _unknown12[16];
+ u_int8_t iccid[20];
+ u_int8_t _unknown13[6];
+ u_int8_t mcc[16];
+ u_int8_t mnc[16];
+ u_int8_t _unknown14[4];
+ u_int8_t _unknown15[4];
+ u_int8_t _unknown16[4];
+} __attribute__ ((packed));
+typedef struct WmcCmdDeviceInfo3Rsp WmcCmdDeviceInfo3Rsp;
+
+/*****************************************************/
+
+enum {
+ WMC_SERVICE_NONE = 0,
+ WMC_SERVICE_AMPS = 1,
+ WMC_SERVICE_IS95A = 2,
+ WMC_SERVICE_IS95B = 3,
+ WMC_SERVICE_GSM = 4,
+ WMC_SERVICE_GPRS = 5,
+ WMC_SERVICE_1XRTT = 6,
+ WMC_SERVICE_EVDO_0 = 7,
+ WMC_SERVICE_UMTS = 8,
+ WMC_SERVICE_EVDO_A = 9,
+ WMC_SERVICE_EDGE = 10,
+ WMC_SERVICE_HSDPA = 11,
+ WMC_SERVICE_HSUPA = 12,
+ WMC_SERVICE_HSPA = 13,
+ WMC_SERVICE_LTE = 14,
+ WMC_SERVICE_EVDO_A_EHRPD = 15,
+};
+
+/* PC5740 response */
+struct WmcCmdNetworkInfoRsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1;
+ u_int8_t _unknown2[3]; /* Always zero */
+ u_int8_t service; /* One of WMC_SERVICE_* */
+ u_int8_t _unknown3; /* Either 0x00 or 0x01 */
+ u_int16_t ts_year;
+ u_int8_t ts_month;
+ u_int16_t ts_day; /* BE */
+ u_int16_t ts_hours; /* BE */
+ u_int16_t ts_minutes; /* BE */
+ u_int16_t ts_seconds; /* BE */
+ u_int16_t counter1; /* A timestamp/counter? */
+ u_int16_t _unknown4;
+ u_int8_t _unknown5[3]; /* Always 0xFE 0xFF 0xFF */
+ u_int8_t two_g_dbm; /* 0x7D = no signal */
+ u_int8_t _unknown6[37]; /* Always zero */
+} __attribute__ ((packed));
+typedef struct WmcCmdNetworkInfoRsp WmcCmdNetworkInfoRsp;
+
+/* UML190 response */
+struct WmcCmdNetworkInfo2Rsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* 0x00 on LTE, 0x07 or 0x1F on CDMA */
+ u_int8_t _unknown2[3]; /* Always zero */
+ u_int8_t service; /* One of WMC_SERVICE_* */
+ u_int8_t _unknown3;
+ u_int16_t ts_year;
+ u_int8_t ts_month;
+ u_int16_t ts_day; /* BE */
+ u_int16_t ts_hours; /* BE */
+ u_int16_t ts_minutes; /* BE */
+ u_int16_t ts_seconds; /* BE */
+ u_int8_t _unknown4; /* always zero */
+ u_int16_t uptime_secs;
+ u_int8_t _unknown5;
+ u_int8_t _unknown6[3]; /* always zero on LTE, 0xFE 0xFF 0xFF on CDMA */
+ u_int8_t two_g_dbm; /* 0x7D = no CDMA signal, 0x6a = no GSM signal */
+ u_int8_t _unknown7[3]; /* Always zero */
+ u_int8_t cdma_opname[16]; /* Zero terminated? */
+ u_int8_t _unknown8[18]; /* Always zero */
+ u_int8_t three_g_dbm; /* 0x7D = no signal */
+ u_int8_t _unknown9[3]; /* Always zero */
+ u_int8_t _unknown10; /* 0x01 on LTE, 0x40 on CDMA */
+ u_int8_t _unknown11[3]; /* Always zero */
+ u_int8_t _unknown12; /* Always 0x01 */
+ u_int8_t tgpp_opname[8]; /* 3GPP operator name (Zero terminated? Sometimes "MCC MNC" too */
+ u_int8_t _unknown13[4]; /* Always zero */
+ u_int32_t _unknown14; /* 43 75 3a 00 on GSM/WCDMA mode, zero on others */
+ u_int32_t _unknown15; /* 49 7d 3a 00 on GSM/WCDMA mode, zero on others */
+ u_int8_t _unknown16[44]; /* Always zero */
+ u_int32_t mcc_mnc; /* GSM/WCDMA only, see MCC/MNC format note */
+} __attribute__ ((packed));
+typedef struct WmcCmdNetworkInfo2Rsp WmcCmdNetworkInfo2Rsp;
+
+/* UML290 response */
+struct WmcCmdNetworkInfo3Rsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* 0x00 on LTE, 0x07 or 0x1F on CDMA */
+ u_int8_t _unknown2[3]; /* Always zero */
+ u_int8_t service; /* One of WMC_SERVICE_* */
+ u_int8_t _unknown3;
+ u_int16_t ts_year;
+ u_int8_t ts_month;
+ u_int16_t ts_day; /* BE */
+ u_int16_t ts_hours; /* BE */
+ u_int16_t ts_minutes; /* BE */
+ u_int16_t ts_seconds; /* BE */
+ u_int8_t _unknown4; /* always zero */
+ u_int16_t uptime_secs;
+ u_int8_t _unknown5;
+ u_int8_t _unknown6[3]; /* always zero on LTE, 0xFE 0xFF 0xFF on CDMA */
+ u_int8_t two_g_dbm; /* 0x7D = no CDMA signal, 0x6a = no GSM signal */
+ u_int8_t _unknown7[3]; /* Always zero */
+ u_int8_t cdma_opname[16]; /* Zero terminated? */
+ u_int8_t _unknown8[18]; /* Always zero */
+ u_int8_t three_g_dbm; /* 0x7D = no signal */
+ u_int8_t _unknown9[3]; /* Always zero */
+ u_int8_t _unknown10; /* 0x01 on LTE, 0x40 on CDMA */
+ u_int8_t _unknown11[3]; /* Always zero */
+ u_int8_t _unknown12; /* Always 0x01 */
+ u_int8_t tgpp_opname[8]; /* Zero terminated? Sometimes "MCC MNC" too */
+ u_int8_t _unknown13[4]; /* Always zero */
+ u_int32_t _unknown14; /* 43 75 3a 00 on GSM/WCDMA mode, zero on others */
+ u_int32_t _unknown15; /* 49 7d 3a 00 on GSM/WCDMA mode, zero on others */
+ u_int8_t _unknown16[44]; /* Always zero */
+ u_int32_t mcc_mnc; /* GSM/WCDMA only, see MCC/MNC format note */
+ u_int8_t lte_dbm; /* 0x00 if not in LTE mode */
+ u_int8_t _unknown17[3]; /* Always zero */
+ u_int8_t _unknown18[4];
+} __attribute__ ((packed));
+typedef struct WmcCmdNetworkInfo3Rsp WmcCmdNetworkInfo3Rsp;
+
+/*****************************************************/
+
+enum {
+ WMC_CONNECTION_STATE_UNKNOWN = 0,
+ WMC_CONNECTION_STATE_IDLE = 1,
+ WMC_CONNECTION_STATE_CONNECTING = 2,
+ WMC_CONNECTION_STATE_AUTHENTICATING = 3,
+ WMC_CONNECTION_STATE_CONNECTED = 4,
+ WMC_CONNECTION_STATE_DORMANT = 5,
+ WMC_CONNECTION_STATE_UPDATING_NAM = 6,
+ WMC_CONNECTION_STATE_UPDATING_PRL = 7,
+ WMC_CONNECTION_STATE_DISCONNECTING = 8,
+ WMC_CONNECTION_STATE_ERROR = 9,
+ WMC_CONNECTION_STATE_UPDATING_UICC = 10,
+ WMC_CONNECTION_STATE_UPDATING_PLMN = 11
+};
+
+/* Used on UML190 */
+struct WmcCmdConnectionInfoRsp {
+ WmcCmdHeader hdr;
+ u_int32_t rx_bytes;
+ u_int32_t tx_bytes;
+ u_int8_t _unknown1[8];
+ u_int8_t state; /* One of WMC_CONNECTION_STATE_* */
+ u_int8_t _unknown2[3]; /* Always 0xc0 0x0b 0x00 */
+} __attribute__ ((packed));
+typedef struct WmcCmdConnectionInfoRsp WmcCmdConnectionInfoRsp;
+
+/* Used on UML290 */
+struct WmcCmdConnectionInfo2Rsp {
+ WmcCmdHeader hdr;
+ u_int32_t rx_bytes;
+ u_int32_t tx_bytes;
+ u_int8_t _unknown1[8];
+ u_int8_t state; /* One of WMC_CONNECTION_STATE_* */
+ u_int8_t _unknown2[3]; /* Always 0xc0 0x0b 0x00 */
+ u_int8_t _unknown3[4]; /* Always 0x01 0x00 0x00 0x00 */
+ u_int8_t ip4_address[16]; /* String format, ie "10.156.45.3" */
+ u_int8_t _unknown4[8]; /* Netmask? */
+ u_int8_t ip6_address[40]; /* String format */
+} __attribute__ ((packed));
+typedef struct WmcCmdConnection2InfoRsp WmcCmdConnection2InfoRsp;
+
+/*****************************************************/
+
+enum {
+ WMC_GLOBAL_MODE_AUTO_CDMA = 0x00,
+ WMC_GLOBAL_MODE_CDMA_ONLY = 0x01,
+ WMC_GLOBAL_MODE_EVDO_ONLY = 0x02,
+ WMC_GLOBAL_MODE_AUTO_GSM = 0x0A,
+ WMC_GLOBAL_MODE_GPRS_ONLY = 0x0B,
+ WMC_GLOBAL_MODE_UMTS_ONLY = 0x0C,
+ WMC_GLOBAL_MODE_AUTO = 0x14,
+ WMC_GLOBAL_MODE_LTE_ONLY = 0x1E,
+};
+
+struct WmcCmdGetGlobalMode {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* always 0 */
+} __attribute__ ((packed));
+typedef struct WmcCmdGetGlobalMode WmcCmdGetGlobalMode;
+
+struct WmcCmdGetGlobalModeRsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* always 0x01 */
+ u_int8_t mode; /* one of WMC_GLOBAL_MODE_* */
+ u_int8_t _unknown2; /* always 0x05 */
+ u_int8_t _unknown3; /* always 0x00 */
+} __attribute__ ((packed));
+typedef struct WmcCmdGetGlobalModeRsp WmcCmdGetGlobalModeRsp;
+
+/*****************************************************/
+
+struct WmcCmdSetGlobalMode {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* always 0x01 */
+ u_int8_t mode; /* one of WMC_GLOBAL_MODE_* */
+ u_int8_t _unknown2; /* always 0x05 */
+ u_int8_t _unknown3; /* always 0x00 */
+} __attribute__ ((packed));
+typedef struct WmcCmdSetGlobalMode WmcCmdSetGlobalMode;
+
+struct WmcCmdSetGlobalModeRsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* always 0x01 */
+ u_int32_t _unknown2; /* always zero */
+} __attribute__ ((packed));
+typedef struct WmcCmdSetGlobalModeRsp WmcCmdSetGlobalModeRsp;
+
+/*****************************************************/
+
+struct WmcCmdSetOperator {
+ WmcCmdHeader hdr;
+ u_int8_t automatic; /* 0x00 = manual, 0x01 = auto */
+ u_int8_t _unknown1; /* always 0x50 */
+ u_int8_t _unknown2[3]; /* always zero */
+ u_int32_t mcc_mnc; /* MCC/MNC for manual reg (see format note), zero for auto */
+ u_int8_t _unknown3[56]; /* always zero */
+} __attribute__ ((packed));
+typedef struct WmcCmdSetOperator WmcCmdSetOperator;
+
+enum {
+ WMC_SET_OPERATOR_STATUS_OK = 0,
+ WMC_SET_OPERATOR_STATUS_REGISTERING = 0x63,
+ WMC_SET_OPERATOR_STATUS_FAILED = 0x68,
+};
+
+struct WmcCmdSetOperatorRsp {
+ WmcCmdHeader hdr;
+ u_int8_t status; /* one of WMC_SET_OPERATOR_STATUS_* */
+ u_int8_t _unknown1[3]; /* always zero */
+} __attribute__ ((packed));
+typedef struct WmcCmdSetOperatorRsp WmcCmdSetOperatorRsp;
+
+/*****************************************************/
+
+enum {
+ WMC_OPERATOR_SERVICE_UNKNOWN = 0,
+ WMC_OPERATOR_SERVICE_GSM = 1,
+ WMC_OPERATOR_SERVICE_UMTS = 2,
+};
+
+/* Response for both GET_FIRST_OPERATOR and GET_NEXT_OPERATOR */
+struct WmcCmdGetOperatorRsp {
+ WmcCmdHeader hdr;
+ u_int8_t _unknown1; /* Usually 0x50, sometimes 0x00 */
+ u_int8_t _unknown2[3]; /* always zero */
+ u_int32_t mcc_mnc; /* see format note */
+ u_int8_t opname[8];
+ u_int8_t _unknown3[56]; /* always zero */
+ u_int8_t stat; /* follows 3GPP TS27.007 +COPS <stat> ? */
+ u_int8_t _unknown4[3]; /* always zero */
+ u_int8_t service; /* one of WMC_OPERATOR_SERVICE_* */
+ u_int8_t _unknown5[3]; /* always zero */
+ u_int8_t _unknown6; /* 0x63 (GET_FIRST_OP) might mean "wait" */
+ u_int8_t _unknown7; /* 0x00 or 0x01 */
+ u_int8_t _unknown8[2]; /* always zero */
+} __attribute__ ((packed));
+typedef struct WmcCmdGetOperatorRsp WmcCmdGetOperatorRsp;
+
+/*****************************************************/
+
+enum {
+ WMC_FIELD_TEST_MOBILE_IP_MODE_MIP_OFF = 0,
+ WMC_FIELD_TEST_MOBILE_IP_MODE_MIP_PREF = 1,
+ WMC_FIELD_TEST_MOBILE_IP_MODE_MIP_ONLY = 2
+};
+
+/* Later devices return all zeros for this command */
+struct WmcCmdFieldTestRsp {
+ WmcCmdHeader hdr;
+ u_int8_t prl_requirements;
+ u_int8_t eri_support;
+ char nam_name[7];
+ u_int8_t _unknown1; /* always zero */
+ u_int8_t _unknown2[3]; /* always 0x0A 0x0A 0x0A */
+ u_int8_t _unknown3[5]; /* always zero */
+ u_int8_t _unknown4[10]; /* all 0x0F */
+ u_int16_t home_sid;
+ u_int16_t home_nid;
+ char min1[7];
+ char min2[3];
+ char mcc[3];
+ char imsi_s[10];
+ char mnc[2];
+ u_int16_t primary_cdma_chan_a;
+ u_int16_t secondary_cdma_chan_a;
+ u_int16_t primary_cdma_chan_b;
+ u_int16_t secondary_cdma_chan_b;
+ u_int8_t accolc;
+ char sw_version[64];
+ char hw_version[64];
+ u_int16_t prlver;
+ u_int16_t eriver;
+ u_int16_t nid;
+ u_int8_t last_call_end_reason; /* ? */
+ u_int8_t rssi;
+ u_int16_t channel;
+ u_int8_t prev;
+ u_int16_t pn_offset;
+ u_int8_t sys_select_pref;
+ u_int8_t mip_pref;
+ u_int8_t hybrid_pref;
+} __attribute__ ((packed));
+typedef struct WmcCmdFieldTestRsp WmcCmdFieldTestRsp;
+
+/*****************************************************/
+
+#endif /* LIBWMC_PROTOCOL_H */
diff --git a/libwmc/src/result-private.h b/libwmc/src/result-private.h
new file mode 100644
index 0000000..32a3fcb
--- /dev/null
+++ b/libwmc/src/result-private.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_RESULT_PRIVATE_H
+#define LIBWMC_RESULT_PRIVATE_H
+
+#include "result.h"
+
+WmcResult *wmc_result_new (void);
+
+void wmc_result_add_string (WmcResult *result,
+ const char *key,
+ const char *str);
+
+void wmc_result_add_u8 (WmcResult *result,
+ const char *key,
+ u_int8_t num);
+
+void wmc_result_add_u32 (WmcResult *result,
+ const char *key,
+ u_int32_t num);
+
+#endif /* LIBWMC_RESULT_PRIVATE_H */
+
diff --git a/libwmc/src/result.c b/libwmc/src/result.c
new file mode 100644
index 0000000..b66f864
--- /dev/null
+++ b/libwmc/src/result.c
@@ -0,0 +1,298 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "result.h"
+#include "result-private.h"
+#include "errors.h"
+
+/*********************************************************/
+
+typedef struct Val Val;
+
+typedef enum {
+ VAL_TYPE_NONE = 0,
+ VAL_TYPE_STRING = 1,
+ VAL_TYPE_U8 = 2,
+ VAL_TYPE_U32 = 3
+} ValType;
+
+struct Val {
+ char *key;
+ ValType type;
+ union {
+ char *s;
+ u_int8_t u8;
+ u_int32_t u32;
+ } u;
+ Val *next;
+};
+
+static void
+val_free (Val *v)
+{
+ if (v->type == VAL_TYPE_STRING) {
+ if (v->u.s)
+ free (v->u.s);
+ }
+ free (v->key);
+ memset (v, 0, sizeof (*v));
+ free (v);
+}
+
+static Val *
+val_new_string (const char *key, const char *value)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (key != NULL, NULL);
+ wmc_return_val_if_fail (key[0] != '\0', NULL);
+ wmc_return_val_if_fail (value != NULL, NULL);
+
+ v = calloc (sizeof (Val), 1);
+ if (v == NULL)
+ return NULL;
+
+ v->key = strdup (key);
+ v->type = VAL_TYPE_STRING;
+ v->u.s = strdup (value);
+ return v;
+}
+
+static Val *
+val_new_u8 (const char *key, u_int8_t u)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (key != NULL, NULL);
+ wmc_return_val_if_fail (key[0] != '\0', NULL);
+
+ v = calloc (sizeof (Val), 1);
+ if (v == NULL)
+ return NULL;
+
+ v->key = strdup (key);
+ v->type = VAL_TYPE_U8;
+ v->u.u8 = u;
+ return v;
+}
+
+static Val *
+val_new_u32 (const char *key, u_int32_t u)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (key != NULL, NULL);
+ wmc_return_val_if_fail (key[0] != '\0', NULL);
+
+ v = calloc (sizeof (Val), 1);
+ if (v == NULL)
+ return NULL;
+
+ v->key = strdup (key);
+ v->type = VAL_TYPE_U32;
+ v->u.u32 = u;
+ return v;
+}
+
+/*********************************************************/
+
+struct WmcResult {
+ u_int32_t refcount;
+ Val *first;
+};
+
+WmcResult *
+wmc_result_new (void)
+{
+ WmcResult *r;
+
+ r = calloc (sizeof (WmcResult), 1);
+ if (r)
+ r->refcount = 1;
+ return r;
+}
+
+WmcResult *
+wmc_result_ref (WmcResult *r)
+{
+ wmc_return_val_if_fail (r != NULL, NULL);
+ wmc_return_val_if_fail (r->refcount > 0, NULL);
+
+ r->refcount++;
+ return r;
+}
+
+static void
+wmc_result_free (WmcResult *r)
+{
+ Val *v, *n;
+
+ v = r->first;
+ while (v) {
+ n = v->next;
+ val_free (v);
+ v = n;
+ }
+ memset (r, 0, sizeof (*r));
+ free (r);
+}
+
+void
+wmc_result_unref (WmcResult *r)
+{
+ wmc_return_if_fail (r != NULL);
+ wmc_return_if_fail (r->refcount > 0);
+
+ r->refcount--;
+ if (r->refcount == 0)
+ wmc_result_free (r);
+}
+
+static Val *
+find_val (WmcResult *r, const char *key, ValType expected_type)
+{
+ Val *v, *n;
+
+ v = r->first;
+ while (v) {
+ n = v->next;
+ if (strcmp (v->key, key) == 0) {
+ /* Check type */
+ wmc_return_val_if_fail (v->type == expected_type, NULL);
+ return v;
+ }
+ v = n;
+ }
+ return NULL;
+}
+
+void
+wmc_result_add_string (WmcResult *r,
+ const char *key,
+ const char *str)
+{
+ Val *v;
+
+ wmc_return_if_fail (r != NULL);
+ wmc_return_if_fail (r->refcount > 0);
+ wmc_return_if_fail (key != NULL);
+ wmc_return_if_fail (str != NULL);
+
+ v = val_new_string (key, str);
+ wmc_return_if_fail (v != NULL);
+ v->next = r->first;
+ r->first = v;
+}
+
+int
+wmc_result_get_string (WmcResult *r,
+ const char *key,
+ const char **out_val)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (r != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (r->refcount > 0, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (key != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (out_val != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (*out_val == NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+
+ v = find_val (r, key, VAL_TYPE_STRING);
+ if (v == NULL)
+ return -WMC_ERROR_VALUE_NOT_FOUND;
+
+ *out_val = v->u.s;
+ return 0;
+}
+
+void
+wmc_result_add_u8 (WmcResult *r,
+ const char *key,
+ u_int8_t num)
+{
+ Val *v;
+
+ wmc_return_if_fail (r != NULL);
+ wmc_return_if_fail (r->refcount > 0);
+ wmc_return_if_fail (key != NULL);
+
+ v = val_new_u8 (key, num);
+ wmc_return_if_fail (v != NULL);
+ v->next = r->first;
+ r->first = v;
+}
+
+int
+wmc_result_get_u8 (WmcResult *r,
+ const char *key,
+ u_int8_t *out_val)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (r != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (r->refcount > 0, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (key != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (out_val != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+
+ v = find_val (r, key, VAL_TYPE_U8);
+ if (v == NULL)
+ return -WMC_ERROR_VALUE_NOT_FOUND;
+
+ *out_val = v->u.u8;
+ return 0;
+}
+
+void
+wmc_result_add_u32 (WmcResult *r,
+ const char *key,
+ u_int32_t num)
+{
+ Val *v;
+
+ wmc_return_if_fail (r != NULL);
+ wmc_return_if_fail (r->refcount > 0);
+ wmc_return_if_fail (key != NULL);
+
+ v = val_new_u32 (key, num);
+ wmc_return_if_fail (v != NULL);
+ v->next = r->first;
+ r->first = v;
+}
+
+int
+wmc_result_get_u32 (WmcResult *r,
+ const char *key,
+ u_int32_t *out_val)
+{
+ Val *v;
+
+ wmc_return_val_if_fail (r != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (r->refcount > 0, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (key != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+ wmc_return_val_if_fail (out_val != NULL, -WMC_ERROR_INVALID_ARGUMENTS);
+
+ v = find_val (r, key, VAL_TYPE_U32);
+ if (v == NULL)
+ return -WMC_ERROR_VALUE_NOT_FOUND;
+
+ *out_val = v->u.u32;
+ return 0;
+}
+
diff --git a/libwmc/src/result.h b/libwmc/src/result.h
new file mode 100644
index 0000000..516f0ba
--- /dev/null
+++ b/libwmc/src/result.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_RESULT_H
+#define LIBWMC_RESULT_H
+
+#include <sys/types.h>
+
+typedef struct WmcResult WmcResult;
+
+int wmc_result_get_string (WmcResult *r,
+ const char *key,
+ const char **out_val);
+
+int wmc_result_get_u8 (WmcResult *r,
+ const char *key,
+ u_int8_t *out_val);
+
+int wmc_result_get_u32 (WmcResult *r,
+ const char *key,
+ u_int32_t *out_val);
+
+WmcResult *wmc_result_ref (WmcResult *r);
+
+void wmc_result_unref (WmcResult *r);
+
+#endif /* LIBWMC_RESULT_H */
+
diff --git a/libwmc/src/utils.c b/libwmc/src/utils.c
new file mode 100644
index 0000000..408e107
--- /dev/null
+++ b/libwmc/src/utils.c
@@ -0,0 +1,460 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "utils.h"
+#include "errors.h"
+
+/* QCDM protocol frames are pseudo Async HDLC frames which end with a 3-byte
+ * trailer. This trailer consists of the 16-bit CRC of the frame plus an ending
+ * "async control character" whose value is 0x7E. The frame *and* the CRC are
+ * escaped before adding the trailing control character so that the control
+ * character (0x7E) and the escape marker (0x7D) are never seen in the frame.
+ */
+
+/* Table of CRCs for each possible byte, with a generator polynomial of 0x8408 */
+static const u_int16_t crc_table[256] = {
+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+};
+
+/* Calculate the CRC for a buffer using a seed of 0xffff */
+u_int16_t
+wmc_crc16 (const char *buffer, size_t len, u_int16_t seed)
+{
+ u_int16_t crc = seed ? seed : 0xFFFF;
+
+ while (len--)
+ crc = crc_table[(crc ^ *buffer++) & 0xff] ^ (crc >> 8);
+ return ~crc;
+}
+
+#define DIAG_ESC_CHAR 0x7D /* Escape sequence 1st character value */
+#define DIAG_ESC_MASK 0x20 /* Escape sequence complement value */
+
+/* Performs DM escaping on inbuf putting the result into outbuf, and returns
+ * the final length of the buffer.
+ */
+size_t
+hdlc_escape (const char *inbuf,
+ size_t inbuf_len,
+ wmcbool escape_all_ctrl,
+ char *outbuf,
+ size_t outbuf_len)
+{
+ const char *src = inbuf;
+ char *dst = outbuf;
+ size_t i = inbuf_len;
+
+ wmc_return_val_if_fail (inbuf != NULL, 0);
+ wmc_return_val_if_fail (inbuf_len > 0, 0);
+ wmc_return_val_if_fail (outbuf != NULL, 0);
+ wmc_return_val_if_fail (outbuf_len > inbuf_len, 0);
+
+ /* Since escaping potentially doubles the # of bytes, short-circuit the
+ * length check if destination buffer is clearly large enough. Note the
+ *
+ */
+ if (outbuf_len <= inbuf_len << 1) {
+ size_t outbuf_required = inbuf_len + 1; /* +1 for the trailing control char */
+
+ /* Each escaped character takes up two bytes in the output buffer */
+ while (i--) {
+ if ( *src == DIAG_CONTROL_CHAR
+ || *src == DIAG_ESC_CHAR
+ || (escape_all_ctrl && *src <= 0x20))
+ outbuf_required++;
+ src++;
+ }
+
+ if (outbuf_len < outbuf_required)
+ return 0;
+ }
+
+ /* Do the actual escaping. Replace both the control character and
+ * the escape character in the source buffer with the following sequence:
+ *
+ * <escape_char> <src_byte ^ escape_mask>
+ */
+ src = inbuf;
+ i = inbuf_len;
+ while (i--) {
+ u_int8_t byte = (u_int8_t) *src++;
+
+ if ( byte == DIAG_CONTROL_CHAR
+ || byte == DIAG_ESC_CHAR
+ || (escape_all_ctrl && byte <= 0x20)) {
+ *dst++ = DIAG_ESC_CHAR;
+ *dst++ = byte ^ DIAG_ESC_MASK;
+ } else
+ *dst++ = byte;
+ }
+
+ return (dst - outbuf);
+}
+
+size_t
+hdlc_unescape (const char *inbuf,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ wmcbool *escaping)
+{
+ size_t i, outsize;
+
+ wmc_return_val_if_fail (inbuf_len > 0, 0);
+ wmc_return_val_if_fail (outbuf_len >= inbuf_len, 0);
+ wmc_return_val_if_fail (escaping != NULL, 0);
+
+ for (i = 0, outsize = 0; i < inbuf_len; i++) {
+ if (*escaping) {
+ outbuf[outsize++] = inbuf[i] ^ DIAG_ESC_MASK;
+ *escaping = FALSE;
+ } else if (inbuf[i] == DIAG_ESC_CHAR)
+ *escaping = TRUE;
+ else
+ outbuf[outsize++] = inbuf[i];
+
+ /* About to overrun output buffer size */
+ if (outsize >= outbuf_len)
+ return 0;
+ }
+
+ return outsize;
+}
+
+/**
+ * hdlc_encapsulate_buffer:
+ * @inbuf: data buffer to encapsulate
+ * @cmd_len: size of the data contained in @inbuf
+ * @inbuf_len: total size of @inbuf itself (not just the data)
+ * @crc_seed: if non-zero, CRC-16 seed to use; if 0, uses standard 0xFFFF
+ * @add_trailer: if %TRUE, adds trailing 0x7E
+ * @escape_all_ctrl: if %TRUE, escapes all control characters instead of only
+ * special HDLC escape characters 0x7D and 0x7E
+ * @outbuf: buffer in which to put the encapsulated data
+ * @outbuf_len: total size of @outbuf
+ *
+ * Escapes and CRCs given data using HDLC-style mechanisms, and optionally adds
+ * the trailing control character that denotes the end of the HDLC frame.
+ *
+ * Returns: size of the encapsulated data writted to @outbuf.
+ **/
+size_t
+hdlc_encapsulate_buffer (char *inbuf,
+ size_t cmd_len,
+ size_t inbuf_len,
+ u_int16_t crc_seed,
+ wmcbool add_trailer,
+ wmcbool escape_all_ctrl,
+ char *outbuf,
+ size_t outbuf_len)
+{
+ u_int16_t crc;
+ size_t escaped_len;
+
+ wmc_return_val_if_fail (inbuf != NULL, 0);
+ wmc_return_val_if_fail (cmd_len >= 1, 0);
+ wmc_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
+ wmc_return_val_if_fail (outbuf != NULL, 0);
+
+ /* Add the CRC */
+ crc = wmc_crc16 (inbuf, cmd_len, crc_seed ? crc_seed : 0xFFFF);
+ inbuf[cmd_len++] = crc & 0xFF;
+ inbuf[cmd_len++] = (crc >> 8) & 0xFF;
+
+ escaped_len = hdlc_escape (inbuf, cmd_len, escape_all_ctrl, outbuf, outbuf_len);
+ wmc_return_val_if_fail (outbuf_len > escaped_len, 0);
+
+ if (add_trailer)
+ outbuf[escaped_len++] = DIAG_CONTROL_CHAR;
+
+ return escaped_len;
+}
+
+#define AT_WMC_PREFIX "AT*WMC="
+
+/**
+ * uml290_wmc_encapsulate:
+ * @inbuf: data buffer to encapsulate
+ * @cmd_len: size of the data contained in @inbuf
+ * @inbuf_len: total size of @inbuf itself (not just the data)
+ * @outbuf: buffer in which to put the encapsulated data
+ * @outbuf_len: total size of @outbuf
+ *
+ * Escapes and CRCs given data using HDLC-style mechanisms with UML290 specific
+ * quirks.
+ *
+ * Returns: size of the encapsulated data writted to @outbuf.
+ */
+static size_t
+uml290_wmc_encapsulate (char *inbuf,
+ size_t cmd_len,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len)
+{
+ size_t encap_len;
+ size_t estimated_out_len;
+
+ wmc_return_val_if_fail (inbuf != NULL, 0);
+ wmc_return_val_if_fail (cmd_len >= 1, 0);
+ wmc_return_val_if_fail (inbuf_len >= cmd_len + 2, 0); /* space for CRC */
+ wmc_return_val_if_fail (outbuf != NULL, 0);
+
+ estimated_out_len = cmd_len + strlen (AT_WMC_PREFIX);
+ estimated_out_len += 3; /* CRC + trailer */
+ estimated_out_len += cmd_len * 2; /* escaping */
+ wmc_return_val_if_fail (outbuf_len > estimated_out_len, 0);
+
+ memcpy (outbuf, AT_WMC_PREFIX, strlen (AT_WMC_PREFIX));
+
+ encap_len = hdlc_encapsulate_buffer (inbuf, cmd_len, inbuf_len, 0xAAFE,
+ FALSE, TRUE,
+ outbuf + strlen (AT_WMC_PREFIX),
+ outbuf_len);
+ if (encap_len > 0) {
+ encap_len += strlen (AT_WMC_PREFIX);
+ outbuf[encap_len++] = 0x0D; /* trailer */
+ }
+
+ return encap_len;
+}
+
+/**
+ * wmc_encapsulate:
+ * @inbuf: data buffer to encapsulate
+ * @cmd_len: size of the data contained in @inbuf
+ * @inbuf_len: total size of @inbuf itself (not just the data)
+ * @outbuf: buffer in which to put the encapsulated data
+ * @outbuf_len: total size of @outbuf
+ * @uml290: if %TRUE return buffer suitable for sending to UML290 devices
+ *
+ * Escapes and CRCs given data using HDLC-style mechanisms.
+ *
+ * Returns: size of the encapsulated data writted to @outbuf.
+ */
+size_t
+wmc_encapsulate (char *inbuf,
+ size_t cmd_len,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ wmcbool uml290)
+{
+ wmc_return_val_if_fail (inbuf != NULL, 0);
+ wmc_return_val_if_fail (cmd_len >= 1, 0);
+ wmc_return_val_if_fail (inbuf_len >= cmd_len + 3, 0); /* space for CRC + trailer */
+ wmc_return_val_if_fail (outbuf != NULL, 0);
+
+ if (uml290)
+ return uml290_wmc_encapsulate (inbuf, cmd_len, inbuf_len, outbuf, outbuf_len);
+
+ /* Otherwise do normal WMC */
+ return hdlc_encapsulate_buffer (inbuf, cmd_len, inbuf_len,
+ 0, TRUE, FALSE, outbuf, outbuf_len);
+}
+
+/**
+ * hdlc_decapsulate_buffer:
+ * @inbuf: buffer in which to look for an HDLC frame
+ * @inbuf_len: length of valid data in @inbuf
+ * @check_known_crc: if %TRUE, validate the CRC using @known_crc if the normal
+ * CRC check fails
+ * @known_crc: if @check_known_crc is %TRUE, compare the frame's CRC against
+ * @known_crc if the normal CRC check fails. @known_crc must be in Little
+ * Endian (LE) byte order.
+ * @outbuf: buffer in which to put decapsulated data from the HDLC frame
+ * @outbuf_len: max size of @outbuf
+ * @out_decap_len: on success, size of the decapsulated data
+ * @out_used: on either success or failure, amount of data used; caller should
+ * discard this much data from @inbuf before the next call to this function
+ * @out_need_more: when TRUE, indicates that more data is required before
+ * a determination about a valid HDLC frame can be made; caller should add
+ * more data to @inbuf before calling this function again.
+ *
+ * Attempts to retrieve, unescape, and CRC-check an HDLC frame from the given
+ * buffer.
+ *
+ * Returns: FALSE on error (packet was invalid or malformed, or the CRC check
+ * failed, etc) and places number of bytes to discard from @inbuf in @out_used.
+ * When TRUE, either more data is required (in which case @out_need_more will
+ * be TRUE), or a data packet was successfully retrieved from @inbuf and the
+ * decapsulated packet of length @out_decap_len was placed into @outbuf. In
+ * all cases the caller should advance the buffer by the number of bytes
+ * returned in @out_used before calling this function again.
+ **/
+wmcbool
+hdlc_decapsulate_buffer (const char *inbuf,
+ size_t inbuf_len,
+ wmcbool check_known_crc,
+ u_int16_t known_crc,
+ char *outbuf,
+ size_t outbuf_len,
+ size_t *out_decap_len,
+ size_t *out_used,
+ wmcbool *out_need_more)
+{
+ wmcbool escaping = FALSE;
+ size_t i, pkt_len = 0, unesc_len;
+ u_int16_t crc, pkt_crc;
+
+ wmc_return_val_if_fail (inbuf != NULL, FALSE);
+ wmc_return_val_if_fail (outbuf != NULL, FALSE);
+ wmc_return_val_if_fail (outbuf_len > 0, FALSE);
+ wmc_return_val_if_fail (out_decap_len != NULL, FALSE);
+ wmc_return_val_if_fail (out_used != NULL, FALSE);
+ wmc_return_val_if_fail (out_need_more != NULL, FALSE);
+
+ *out_decap_len = 0;
+ *out_used = 0;
+ *out_need_more = FALSE;
+
+ if (inbuf_len < 4) {
+ *out_need_more = TRUE;
+ return TRUE;
+ }
+
+ /* Find the async control character */
+ for (i = 0; i < inbuf_len; i++) {
+ if (inbuf[i] == DIAG_CONTROL_CHAR) {
+ /* If the control character shows up in a position before a valid
+ * QCDM packet length (4), the packet is malformed.
+ */
+ if (i < 3) {
+ /* Tell the caller to advance the buffer past the control char */
+ *out_used = i + 1;
+ return FALSE;
+ }
+
+ pkt_len = i;
+ break;
+ }
+ }
+
+ /* No control char yet, need more data */
+ if (!pkt_len) {
+ *out_need_more = TRUE;
+ return TRUE;
+ }
+
+ /* Unescape first; note that pkt_len */
+ unesc_len = hdlc_unescape (inbuf, pkt_len, outbuf, outbuf_len, &escaping);
+ if (!unesc_len) {
+ /* Tell the caller to advance the buffer past the control char */
+ *out_used = pkt_len + 1;
+ return FALSE;
+ }
+
+ if (escaping) {
+ *out_need_more = TRUE;
+ return TRUE;
+ }
+
+ /* Check the CRC of the packet's data */
+ crc = wmc_crc16 (outbuf, unesc_len - 2, 0);
+ pkt_crc = outbuf[unesc_len - 2] & 0xFF;
+ pkt_crc |= (outbuf[unesc_len - 1] & 0xFF) << 8;
+ if (crc != pkt_crc) {
+ if (!check_known_crc || (pkt_crc != known_crc)) {
+ *out_used = pkt_len + 1; /* packet + CRC + 0x7E */
+ return FALSE;
+ }
+ }
+
+ *out_used = pkt_len + 1; /* packet + CRC + 0x7E */
+ *out_decap_len = unesc_len - 2; /* decap_len should not include the CRC */
+ return TRUE;
+}
+
+/**
+ * wmc_decapsulate:
+ * @inbuf: buffer in which to look for an HDLC frame
+ * @inbuf_len: length of valid data in @inbuf
+ * @outbuf: buffer in which to put decapsulated data from the HDLC frame
+ * @outbuf_len: max size of @outbuf
+ * @out_decap_len: on success, size of the decapsulated data
+ * @out_used: on either success or failure, amount of data used; caller should
+ * discard this much data from @inbuf before the next call to this function
+ * @out_need_more: when TRUE, indicates that more data is required before
+ * a determination about a valid HDLC frame can be made; caller should add
+ * more data to @inbuf before calling this function again.
+ * @uml290: if %TRUE decapsulate response from UML290 devices
+ *
+ * Attempts to retrieve, unescape, and CRC-check an HDLC frame from the given
+ * buffer.
+ *
+ * Returns: FALSE on error (packet was invalid or malformed, or the CRC check
+ * failed, etc) and places number of bytes to discard from @inbuf in @out_used.
+ * When TRUE, either more data is required (in which case @out_need_more will
+ * be TRUE), or a data packet was successfully retrieved from @inbuf and the
+ * decapsulated packet of length @out_decap_len was placed into @outbuf. In
+ * all cases the caller should advance the buffer by the number of bytes
+ * returned in @out_used before calling this function again.
+ **/
+wmcbool
+wmc_decapsulate (const char *inbuf,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ size_t *out_decap_len,
+ size_t *out_used,
+ wmcbool *out_need_more,
+ wmcbool uml290)
+{
+ return hdlc_decapsulate_buffer (inbuf, inbuf_len,
+ uml290, uml290 ? 0x3030 : 0,
+ outbuf, outbuf_len,
+ out_decap_len, out_used, out_need_more);
+}
+
diff --git a/libwmc/src/utils.h b/libwmc/src/utils.h
new file mode 100644
index 0000000..f1fc423
--- /dev/null
+++ b/libwmc/src/utils.h
@@ -0,0 +1,88 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBWMC_UTILS_H
+#define LIBWMC_UTILS_H
+
+#include <sys/types.h>
+
+typedef u_int8_t wmcbool;
+#ifndef TRUE
+#define TRUE ((u_int8_t) 1)
+#endif
+#ifndef FALSE
+#define FALSE ((u_int8_t) 0)
+#endif
+
+#define DIAG_CONTROL_CHAR 0x7E
+#define DIAG_TRAILER_LEN 3
+
+/* Utility and testcase functions */
+
+u_int16_t wmc_crc16 (const char *buffer, size_t len, u_int16_t seed);
+
+size_t hdlc_escape (const char *inbuf,
+ size_t inbuf_len,
+ wmcbool escape_all_ctrl,
+ char *outbuf,
+ size_t outbuf_len);
+
+size_t hdlc_unescape (const char *inbuf,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ wmcbool *escaping);
+
+size_t hdlc_encapsulate_buffer (char *inbuf,
+ size_t cmd_len,
+ size_t inbuf_len,
+ u_int16_t crc_seed,
+ wmcbool add_trailer,
+ wmcbool escape_all_ctrl,
+ char *outbuf,
+ size_t outbuf_len);
+
+wmcbool hdlc_decapsulate_buffer (const char *inbuf,
+ size_t inbuf_len,
+ wmcbool check_known_crc,
+ u_int16_t known_crc,
+ char *outbuf,
+ size_t outbuf_len,
+ size_t *out_decap_len,
+ size_t *out_used,
+ wmcbool *out_need_more);
+
+/* Functions for actual communication */
+
+size_t wmc_encapsulate (char *inbuf,
+ size_t cmd_len,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ wmcbool uml290);
+
+wmcbool wmc_decapsulate (const char *inbuf,
+ size_t inbuf_len,
+ char *outbuf,
+ size_t outbuf_len,
+ size_t *out_decap_len,
+ size_t *out_used,
+ wmcbool *out_need_more,
+ wmcbool uml290);
+
+#endif /* LIBWMC_UTILS_H */
+
diff --git a/libwmc/tests/Makefile.am b/libwmc/tests/Makefile.am
new file mode 100644
index 0000000..ee98887
--- /dev/null
+++ b/libwmc/tests/Makefile.am
@@ -0,0 +1,35 @@
+if WITH_TESTS
+
+INCLUDES = \
+ -I$(top_srcdir)/libwmc/src \
+ -I$(top_srcdir)/src
+
+noinst_PROGRAMS = test-wmc
+
+test_wmc_SOURCES = \
+ test-wmc-crc.c \
+ test-wmc-crc.h \
+ test-wmc-escaping.c \
+ test-wmc-escaping.h \
+ test-wmc-utils.c \
+ test-wmc-utils.h \
+ test-wmc-com.c \
+ test-wmc-com.h \
+ test-wmc.c
+
+test_wmc_CPPFLAGS = \
+ $(MM_CFLAGS)
+
+test_wmc_LDADD = $(MM_LIBS)
+
+if WMC_STANDALONE
+test_wmc_LDADD += $(top_builddir)/src/libwmc.la
+else
+test_wmc_LDADD += $(top_builddir)/libwmc/src/libwmc.la
+endif
+
+check-local: test-wmc
+ $(abs_builddir)/test-wmc
+
+endif
+
diff --git a/libwmc/tests/Makefile.in b/libwmc/tests/Makefile.in
new file mode 100644
index 0000000..c6cb279
--- /dev/null
+++ b/libwmc/tests/Makefile.in
@@ -0,0 +1,758 @@
+# Makefile.in generated by automake 1.13.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@WITH_TESTS_TRUE@noinst_PROGRAMS = test-wmc$(EXEEXT)
+@WITH_TESTS_TRUE@@WMC_STANDALONE_TRUE@am__append_1 = $(top_builddir)/src/libwmc.la
+@WITH_TESTS_TRUE@@WMC_STANDALONE_FALSE@am__append_2 = $(top_builddir)/libwmc/src/libwmc.la
+subdir = libwmc/tests
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am__test_wmc_SOURCES_DIST = test-wmc-crc.c test-wmc-crc.h \
+ test-wmc-escaping.c test-wmc-escaping.h test-wmc-utils.c \
+ test-wmc-utils.h test-wmc-com.c test-wmc-com.h test-wmc.c
+@WITH_TESTS_TRUE@am_test_wmc_OBJECTS = \
+@WITH_TESTS_TRUE@ test_wmc-test-wmc-crc.$(OBJEXT) \
+@WITH_TESTS_TRUE@ test_wmc-test-wmc-escaping.$(OBJEXT) \
+@WITH_TESTS_TRUE@ test_wmc-test-wmc-utils.$(OBJEXT) \
+@WITH_TESTS_TRUE@ test_wmc-test-wmc-com.$(OBJEXT) \
+@WITH_TESTS_TRUE@ test_wmc-test-wmc.$(OBJEXT)
+test_wmc_OBJECTS = $(am_test_wmc_OBJECTS)
+am__DEPENDENCIES_1 =
+@WITH_TESTS_TRUE@test_wmc_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+@WITH_TESTS_TRUE@ $(am__append_1) $(am__append_2)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(test_wmc_SOURCES)
+DIST_SOURCES = $(am__test_wmc_SOURCES_DIST)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALL_LINGUAS = @ALL_LINGUAS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DBUS_SYS_DIR = @DBUS_SYS_DIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
+INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
+INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
+INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBMM_GLIB_CFLAGS = @LIBMM_GLIB_CFLAGS@
+LIBMM_GLIB_LIBS = @LIBMM_GLIB_LIBS@
+LIBMM_LIBS = @LIBMM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MBIM_CFLAGS = @MBIM_CFLAGS@
+MBIM_LIBS = @MBIM_LIBS@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MMCLI_CFLAGS = @MMCLI_CFLAGS@
+MMCLI_LIBS = @MMCLI_LIBS@
+MM_CFLAGS = @MM_CFLAGS@
+MM_LIBS = @MM_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
+POLKIT_CFLAGS = @POLKIT_CFLAGS@
+POLKIT_LIBS = @POLKIT_LIBS@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
+QMI_CFLAGS = @QMI_CFLAGS@
+QMI_LIBS = @QMI_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@
+UDEV_BASE_DIR = @UDEV_BASE_DIR@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+intltool__v_merge_options_ = @intltool__v_merge_options_@
+intltool__v_merge_options_0 = @intltool__v_merge_options_0@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+@WITH_TESTS_TRUE@INCLUDES = \
+@WITH_TESTS_TRUE@ -I$(top_srcdir)/libwmc/src \
+@WITH_TESTS_TRUE@ -I$(top_srcdir)/src
+
+@WITH_TESTS_TRUE@test_wmc_SOURCES = \
+@WITH_TESTS_TRUE@ test-wmc-crc.c \
+@WITH_TESTS_TRUE@ test-wmc-crc.h \
+@WITH_TESTS_TRUE@ test-wmc-escaping.c \
+@WITH_TESTS_TRUE@ test-wmc-escaping.h \
+@WITH_TESTS_TRUE@ test-wmc-utils.c \
+@WITH_TESTS_TRUE@ test-wmc-utils.h \
+@WITH_TESTS_TRUE@ test-wmc-com.c \
+@WITH_TESTS_TRUE@ test-wmc-com.h \
+@WITH_TESTS_TRUE@ test-wmc.c
+
+@WITH_TESTS_TRUE@test_wmc_CPPFLAGS = \
+@WITH_TESTS_TRUE@ $(MM_CFLAGS)
+
+@WITH_TESTS_TRUE@test_wmc_LDADD = $(MM_LIBS) $(am__append_1) \
+@WITH_TESTS_TRUE@ $(am__append_2)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libwmc/tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu libwmc/tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+test-wmc$(EXEEXT): $(test_wmc_OBJECTS) $(test_wmc_DEPENDENCIES) $(EXTRA_test_wmc_DEPENDENCIES)
+ @rm -f test-wmc$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_wmc_OBJECTS) $(test_wmc_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wmc-test-wmc-com.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wmc-test-wmc-crc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wmc-test-wmc-escaping.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wmc-test-wmc-utils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wmc-test-wmc.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+test_wmc-test-wmc-crc.o: test-wmc-crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-crc.o -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-crc.Tpo -c -o test_wmc-test-wmc-crc.o `test -f 'test-wmc-crc.c' || echo '$(srcdir)/'`test-wmc-crc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-crc.Tpo $(DEPDIR)/test_wmc-test-wmc-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-crc.c' object='test_wmc-test-wmc-crc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-crc.o `test -f 'test-wmc-crc.c' || echo '$(srcdir)/'`test-wmc-crc.c
+
+test_wmc-test-wmc-crc.obj: test-wmc-crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-crc.obj -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-crc.Tpo -c -o test_wmc-test-wmc-crc.obj `if test -f 'test-wmc-crc.c'; then $(CYGPATH_W) 'test-wmc-crc.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-crc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-crc.Tpo $(DEPDIR)/test_wmc-test-wmc-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-crc.c' object='test_wmc-test-wmc-crc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-crc.obj `if test -f 'test-wmc-crc.c'; then $(CYGPATH_W) 'test-wmc-crc.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-crc.c'; fi`
+
+test_wmc-test-wmc-escaping.o: test-wmc-escaping.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-escaping.o -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-escaping.Tpo -c -o test_wmc-test-wmc-escaping.o `test -f 'test-wmc-escaping.c' || echo '$(srcdir)/'`test-wmc-escaping.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-escaping.Tpo $(DEPDIR)/test_wmc-test-wmc-escaping.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-escaping.c' object='test_wmc-test-wmc-escaping.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-escaping.o `test -f 'test-wmc-escaping.c' || echo '$(srcdir)/'`test-wmc-escaping.c
+
+test_wmc-test-wmc-escaping.obj: test-wmc-escaping.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-escaping.obj -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-escaping.Tpo -c -o test_wmc-test-wmc-escaping.obj `if test -f 'test-wmc-escaping.c'; then $(CYGPATH_W) 'test-wmc-escaping.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-escaping.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-escaping.Tpo $(DEPDIR)/test_wmc-test-wmc-escaping.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-escaping.c' object='test_wmc-test-wmc-escaping.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-escaping.obj `if test -f 'test-wmc-escaping.c'; then $(CYGPATH_W) 'test-wmc-escaping.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-escaping.c'; fi`
+
+test_wmc-test-wmc-utils.o: test-wmc-utils.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-utils.o -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-utils.Tpo -c -o test_wmc-test-wmc-utils.o `test -f 'test-wmc-utils.c' || echo '$(srcdir)/'`test-wmc-utils.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-utils.Tpo $(DEPDIR)/test_wmc-test-wmc-utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-utils.c' object='test_wmc-test-wmc-utils.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-utils.o `test -f 'test-wmc-utils.c' || echo '$(srcdir)/'`test-wmc-utils.c
+
+test_wmc-test-wmc-utils.obj: test-wmc-utils.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-utils.obj -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-utils.Tpo -c -o test_wmc-test-wmc-utils.obj `if test -f 'test-wmc-utils.c'; then $(CYGPATH_W) 'test-wmc-utils.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-utils.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-utils.Tpo $(DEPDIR)/test_wmc-test-wmc-utils.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-utils.c' object='test_wmc-test-wmc-utils.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-utils.obj `if test -f 'test-wmc-utils.c'; then $(CYGPATH_W) 'test-wmc-utils.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-utils.c'; fi`
+
+test_wmc-test-wmc-com.o: test-wmc-com.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-com.o -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-com.Tpo -c -o test_wmc-test-wmc-com.o `test -f 'test-wmc-com.c' || echo '$(srcdir)/'`test-wmc-com.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-com.Tpo $(DEPDIR)/test_wmc-test-wmc-com.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-com.c' object='test_wmc-test-wmc-com.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-com.o `test -f 'test-wmc-com.c' || echo '$(srcdir)/'`test-wmc-com.c
+
+test_wmc-test-wmc-com.obj: test-wmc-com.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc-com.obj -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc-com.Tpo -c -o test_wmc-test-wmc-com.obj `if test -f 'test-wmc-com.c'; then $(CYGPATH_W) 'test-wmc-com.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-com.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc-com.Tpo $(DEPDIR)/test_wmc-test-wmc-com.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc-com.c' object='test_wmc-test-wmc-com.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc-com.obj `if test -f 'test-wmc-com.c'; then $(CYGPATH_W) 'test-wmc-com.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc-com.c'; fi`
+
+test_wmc-test-wmc.o: test-wmc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc.o -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc.Tpo -c -o test_wmc-test-wmc.o `test -f 'test-wmc.c' || echo '$(srcdir)/'`test-wmc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc.Tpo $(DEPDIR)/test_wmc-test-wmc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc.c' object='test_wmc-test-wmc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc.o `test -f 'test-wmc.c' || echo '$(srcdir)/'`test-wmc.c
+
+test_wmc-test-wmc.obj: test-wmc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_wmc-test-wmc.obj -MD -MP -MF $(DEPDIR)/test_wmc-test-wmc.Tpo -c -o test_wmc-test-wmc.obj `if test -f 'test-wmc.c'; then $(CYGPATH_W) 'test-wmc.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_wmc-test-wmc.Tpo $(DEPDIR)/test_wmc-test-wmc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-wmc.c' object='test_wmc-test-wmc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_wmc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_wmc-test-wmc.obj `if test -f 'test-wmc.c'; then $(CYGPATH_W) 'test-wmc.c'; else $(CYGPATH_W) '$(srcdir)/test-wmc.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+@WITH_TESTS_FALSE@check-local:
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \
+ clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \
+ ctags ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am
+
+
+@WITH_TESTS_TRUE@check-local: test-wmc
+@WITH_TESTS_TRUE@ $(abs_builddir)/test-wmc
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libwmc/tests/test-wmc-com.c b/libwmc/tests/test-wmc-com.c
new file mode 100644
index 0000000..8b4b01d
--- /dev/null
+++ b/libwmc/tests/test-wmc-com.c
@@ -0,0 +1,505 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "test-wmc-com.h"
+#include "com.h"
+#include "utils.h"
+#include "errors.h"
+#include "commands.h"
+
+/************************************************************/
+
+typedef struct {
+ char *port;
+ int fd;
+ struct termios old_t;
+ wmcbool debug;
+ wmcbool uml290;
+} TestComData;
+
+gpointer
+test_com_setup (const char *port, wmcbool uml290, wmcbool debug)
+{
+ TestComData *d;
+ int ret;
+
+ d = g_malloc0 (sizeof (TestComData));
+ g_assert (d);
+ d->uml290 = uml290;
+ d->debug = debug;
+
+ if (getenv ("SERIAL_DEBUG"))
+ d->debug = TRUE;
+
+ errno = 0;
+ d->fd = open (port, O_RDWR | O_EXCL | O_NONBLOCK | O_NOCTTY);
+ if (d->fd < 0)
+ g_warning ("%s: open failed: %d", port, errno);
+ g_assert (d->fd >= 0);
+
+ ret = ioctl (d->fd, TIOCEXCL);
+ if (ret) {
+ g_warning ("%s: lock failed: %d", port, errno);
+ close (d->fd);
+ d->fd = -1;
+ }
+ g_assert (ret == 0);
+
+ ret = ioctl (d->fd, TCGETA, &d->old_t);
+ if (ret) {
+ g_warning ("%s: old termios failed: (%d) %s", port, errno, strerror (errno));
+ close (d->fd);
+ d->fd = -1;
+ }
+ g_assert (ret == 0);
+
+ d->port = g_strdup (port);
+ return d;
+}
+
+void
+test_com_teardown (gpointer user_data)
+{
+ TestComData *d = user_data;
+
+ g_assert (d);
+
+ g_free (d->port);
+ close (d->fd);
+ g_free (d);
+}
+
+static void
+print_buf (const char *detail, const char *buf, size_t len)
+{
+ int i = 0, z;
+ wmcbool newline = FALSE;
+ char *f;
+ guint flen;
+
+ f = g_strdup_printf ("%s (%zu) ", detail, len);
+ flen = strlen (f);
+ g_print ("%s", f);
+ for (i = 0; i < len; i++) {
+ g_print ("%02x ", buf[i] & 0xFF);
+ if (((i + 1) % 16) == 0) {
+ g_print ("\n");
+ z = flen;
+ while (z--)
+ g_print (" ");
+ newline = TRUE;
+ } else
+ newline = FALSE;
+ }
+
+ if (!newline)
+ g_print ("\n");
+}
+
+static wmcbool
+send_command (TestComData *d,
+ char *inbuf,
+ size_t inbuf_len,
+ size_t cmd_len)
+{
+ int status;
+ int eagain_count = 1000;
+ size_t i = 0, sendlen;
+ char sendbuf[600];
+
+ if (d->debug)
+ print_buf ("\nRAW>>>", inbuf, cmd_len);
+
+ /* Encapsulate the data for the device */
+ sendlen = wmc_encapsulate (inbuf, cmd_len, inbuf_len, sendbuf, sizeof (sendbuf), d->uml290);
+ if (sendlen <= 0) {
+ g_warning ("Failed to encapsulate WMC command");
+ return FALSE;
+ }
+
+ if (d->debug)
+ print_buf ("ENC>>>", sendbuf, sendlen);
+
+ while (i < sendlen) {
+ errno = 0;
+ status = write (d->fd, &sendbuf[i], 1);
+ if (status < 0) {
+ if (errno == EAGAIN) {
+ eagain_count--;
+ if (eagain_count <= 0)
+ return FALSE;
+ } else
+ g_assert (errno == 0);
+ } else
+ i++;
+
+ usleep (1000);
+ }
+
+ return TRUE;
+}
+
+static size_t
+wait_reply (TestComData *d, char *buf, size_t len)
+{
+ fd_set in;
+ int result;
+ struct timeval timeout = { 1, 0 };
+ char readbuf[2048];
+ ssize_t bytes_read;
+ int total = 0, retries = 0;
+ size_t decap_len = 0;
+
+ FD_ZERO (&in);
+ FD_SET (d->fd, &in);
+ result = select (d->fd + 1, &in, NULL, NULL, &timeout);
+ if (result != 1 || !FD_ISSET (d->fd, &in))
+ return 0;
+
+ do {
+ errno = 0;
+ bytes_read = read (d->fd, &readbuf[total], 1);
+ if ((bytes_read == 0) || (errno == EAGAIN)) {
+ /* Haven't gotten the async control char yet */
+ if (retries > 20)
+ return 0; /* 2 seconds, give up */
+
+ /* Otherwise wait a bit and try again */
+ usleep (100000);
+ retries++;
+ continue;
+ } else if (bytes_read == 1) {
+ wmcbool more = FALSE, success;
+ size_t used = 0;
+
+ total++;
+ decap_len = 0;
+ success = wmc_decapsulate (readbuf, total, buf, len, &decap_len, &used, &more, d->uml290);
+
+ if (success && !more && d->debug)
+ print_buf ("RAW<<<", readbuf, total);
+
+ /* Discard used data */
+ if (used > 0) {
+ total -= used;
+ memmove (readbuf, &readbuf[used], total);
+ }
+
+ if (success && !more) {
+ /* Success; we have a packet */
+ break;
+ }
+ } else {
+ /* Some error occurred */
+ return 0;
+ }
+ } while (total < sizeof (readbuf));
+
+ if (d->debug)
+ print_buf ("DCP<<<", buf, decap_len);
+
+ return decap_len;
+}
+
+void
+test_com_port_init (void *f, void *data)
+{
+ TestComData *d = data;
+ int ret;
+
+ ret = wmc_port_setup (d->fd);
+ if (ret < 0)
+ g_warning ("%s: error setting up serial port: (%d)", d->port, ret);
+ g_assert_cmpint (ret, ==, 0);
+}
+
+void
+test_com_init (void *f, void *data)
+{
+ TestComData *d = data;
+ wmcbool success;
+ char buf[512];
+ gint len;
+ WmcResult *result;
+ size_t reply_len;
+
+ len = wmc_cmd_init_new (buf, sizeof (buf), d->uml290);
+ g_assert (len);
+
+ /* Send the command */
+ success = send_command (d, buf, sizeof (buf), len);
+ g_assert (success);
+
+ /* Get a response */
+ reply_len = wait_reply (d, buf, sizeof (buf));
+
+ /* Parse the response into a result structure */
+ result = wmc_cmd_init_result (buf, reply_len, d->uml290);
+ g_assert (result);
+
+ wmc_result_unref (result);
+}
+
+void
+test_com_device_info (void *f, void *data)
+{
+ TestComData *d = data;
+ wmcbool success;
+ char buf[2048];
+ const char *str, *str2;
+ gint len;
+ WmcResult *result;
+ size_t reply_len;
+ guint32 u32;
+
+ len = wmc_cmd_device_info_new (buf, sizeof (buf));
+ g_assert (len == 2);
+
+ /* Send the command */
+ success = send_command (d, buf, sizeof (buf), len);
+ g_assert (success);
+
+ /* Get a response */
+ reply_len = wait_reply (d, buf, sizeof (buf));
+
+ /* Parse the response into a result structure */
+ result = wmc_cmd_device_info_result (buf, reply_len);
+ g_assert (result);
+
+ g_print ("\n");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_MANUFACTURER, &str);
+ g_message ("%s: Manuf: %s", __func__, str);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_MODEL, &str);
+ g_message ("%s: Model: %s", __func__, str);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_FW_REVISION, &str);
+ g_message ("%s: FW Rev: %s", __func__, str);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_HW_REVISION, &str);
+ g_message ("%s: HW Rev: %s", __func__, str);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_CDMA_MIN, &str);
+ g_message ("%s: CDMA MIN: %s", __func__, str);
+
+ u32 = 0;
+ wmc_result_get_u32 (result, WMC_CMD_DEVICE_INFO_ITEM_HOME_SID, &u32);
+ g_message ("%s: Home SID: %d", __func__, u32);
+
+ u32 = 0;
+ wmc_result_get_u32 (result, WMC_CMD_DEVICE_INFO_ITEM_PRL_VERSION, &u32);
+ g_message ("%s: PRL Ver: %d", __func__, u32);
+
+ u32 = 0;
+ wmc_result_get_u32 (result, WMC_CMD_DEVICE_INFO_ITEM_ERI_VERSION, &u32);
+ g_message ("%s: ERI Ver: %d", __func__, u32);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_MEID, &str);
+ g_message ("%s: MEID: %s", __func__, str ? str : "(none)");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_IMEI, &str);
+ g_message ("%s: IMEI: %s", __func__, str ? str : "(none)");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_ICCID, &str);
+ g_message ("%s: ICCID: %s", __func__, str ? str : "(none)");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_MCC, &str);
+ str2 = NULL;
+ wmc_result_get_string (result, WMC_CMD_DEVICE_INFO_ITEM_MNC, &str2);
+ g_message ("%s: MCC/MNC: %s %s", __func__,
+ str ? str : "(none)",
+ str2 ? str2 : "(none)");
+
+ wmc_result_unref (result);
+}
+
+static const char *
+service_to_string (u_int8_t service)
+{
+ switch (service) {
+ case WMC_NETWORK_SERVICE_NONE:
+ return "none";
+ case WMC_NETWORK_SERVICE_AMPS:
+ return "AMPS";
+ case WMC_NETWORK_SERVICE_IS95A:
+ return "IS95-A";
+ case WMC_NETWORK_SERVICE_IS95B:
+ return "IS95-B";
+ case WMC_NETWORK_SERVICE_GSM:
+ return "GSM";
+ case WMC_NETWORK_SERVICE_GPRS:
+ return "GPRS";
+ case WMC_NETWORK_SERVICE_1XRTT:
+ return "1xRTT";
+ case WMC_NETWORK_SERVICE_EVDO_0:
+ return "EVDO r0";
+ case WMC_NETWORK_SERVICE_UMTS:
+ return "UMTS";
+ case WMC_NETWORK_SERVICE_EVDO_A:
+ return "EVDO rA";
+ case WMC_NETWORK_SERVICE_EDGE:
+ return "EDGE";
+ case WMC_NETWORK_SERVICE_HSDPA:
+ return "HSDPA";
+ case WMC_NETWORK_SERVICE_HSUPA:
+ return "HSUPA";
+ case WMC_NETWORK_SERVICE_HSPA:
+ return "HSPA";
+ case WMC_NETWORK_SERVICE_LTE:
+ return "LTE";
+ default:
+ return "unknown";
+ }
+}
+
+void
+test_com_network_info (void *f, void *data)
+{
+ TestComData *d = data;
+ wmcbool success;
+ char buf[1024];
+ const char *str;
+ u_int8_t dbm, service;
+ gint len;
+ WmcResult *result;
+ size_t reply_len;
+
+ len = wmc_cmd_network_info_new (buf, sizeof (buf));
+ g_assert (len == 2);
+
+ /* Send the command */
+ success = send_command (d, buf, sizeof (buf), len);
+ g_assert (success);
+
+ /* Get a response */
+ reply_len = wait_reply (d, buf, sizeof (buf));
+
+ /* Parse the response into a result structure */
+ result = wmc_cmd_network_info_result (buf, reply_len);
+ g_assert (result);
+
+ g_print ("\n");
+
+ service = 0;
+ wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_SERVICE, &service);
+ g_message ("%s: Service: %d (%s)", __func__, service, service_to_string (service));
+
+ dbm = 0;
+ wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_2G_DBM, &dbm);
+ g_message ("%s: 2G dBm: -%d", __func__, dbm);
+
+ dbm = 0;
+ wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_3G_DBM, &dbm);
+ g_message ("%s: 3G dBm: -%d", __func__, dbm);
+
+ dbm = 0;
+ wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM, &dbm);
+ g_message ("%s: LTE dBm: -%d", __func__, dbm);
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, &str);
+ g_message ("%s: Operator Name: %s", __func__, str ? str : "(none)");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_NETWORK_INFO_ITEM_MCC, &str);
+ g_message ("%s: MCC: %s", __func__, str ? str : "(none)");
+
+ str = NULL;
+ wmc_result_get_string (result, WMC_CMD_NETWORK_INFO_ITEM_MNC, &str);
+ g_message ("%s: MNC: %s", __func__, str ? str : "(none)");
+
+ wmc_result_unref (result);
+}
+
+static const char *
+mode_to_string (u_int8_t service)
+{
+ switch (service) {
+ case WMC_NETWORK_MODE_AUTO_CDMA:
+ return "CDMA/EVDO";
+ case WMC_NETWORK_MODE_CDMA_ONLY:
+ return "CDMA only";
+ case WMC_NETWORK_MODE_EVDO_ONLY:
+ return "EVDO only";
+ case WMC_NETWORK_MODE_AUTO_GSM:
+ return "GSM/UMTS";
+ case WMC_NETWORK_MODE_GPRS_ONLY:
+ return "GSM/GPRS/EDGE only";
+ case WMC_NETWORK_MODE_UMTS_ONLY:
+ return "UMTS/HSPA only";
+ case WMC_NETWORK_MODE_AUTO:
+ return "Auto";
+ case WMC_NETWORK_MODE_LTE_ONLY:
+ return "LTE only";
+ default:
+ return "unknown";
+ }
+}
+
+void
+test_com_get_global_mode (void *f, void *data)
+{
+ TestComData *d = data;
+ wmcbool success;
+ char buf[1024];
+ u_int8_t mode;
+ gint len;
+ WmcResult *result;
+ size_t reply_len;
+
+ len = wmc_cmd_get_global_mode_new (buf, sizeof (buf));
+ g_assert (len == 3);
+
+ /* Send the command */
+ success = send_command (d, buf, sizeof (buf), len);
+ g_assert (success);
+
+ /* Get a response */
+ reply_len = wait_reply (d, buf, sizeof (buf));
+
+ /* Parse the response into a result structure */
+ result = wmc_cmd_get_global_mode_result (buf, reply_len);
+ g_assert (result);
+
+ g_print ("\n");
+
+ mode = 0;
+ wmc_result_get_u8 (result, WMC_CMD_GET_GLOBAL_MODE_ITEM_MODE, &mode);
+ g_message ("%s: Mode: %d (%s)", __func__, mode, mode_to_string (mode));
+
+ wmc_result_unref (result);
+}
+
diff --git a/libwmc/tests/test-wmc-com.h b/libwmc/tests/test-wmc-com.h
new file mode 100644
index 0000000..3dc0a0d
--- /dev/null
+++ b/libwmc/tests/test-wmc-com.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEST_WMC_COM_H
+#define TEST_WMC_COM_H
+
+#include "utils.h"
+
+gpointer test_com_setup (const char *port, wmcbool uml290, wmcbool debug);
+void test_com_teardown (gpointer d);
+
+void test_com_port_init (void *f, void *data);
+
+void test_com_init (void *f, void *data);
+
+void test_com_device_info (void *f, void *data);
+
+void test_com_network_info (void *f, void *data);
+
+void test_com_get_global_mode (void *f, void *data);
+
+#endif /* TEST_WMC_COM_H */
+
diff --git a/libwmc/tests/test-wmc-crc.c b/libwmc/tests/test-wmc-crc.c
new file mode 100644
index 0000000..2965011
--- /dev/null
+++ b/libwmc/tests/test-wmc-crc.c
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "test-wmc-crc.h"
+#include "utils.h"
+
+void
+test_crc16_2 (void *f, void *data)
+{
+ static const char buf[] = {
+ 0x26, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00
+ };
+ guint16 crc;
+ guint16 expected = 0x6D69;
+
+ /* CRC check */
+ crc = wmc_crc16 (buf, sizeof (buf), 0);
+ g_assert (crc == expected);
+}
+
+void
+test_crc16_1 (void *f, void *data)
+{
+ static const char buf[] = {
+ 0x4b, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
+ };
+ guint16 crc;
+ guint16 expected = 0x097A;
+
+ /* CRC check */
+ crc = wmc_crc16 (buf, sizeof (buf), 0);
+ g_assert (crc == expected);
+}
+
diff --git a/libwmc/tests/test-wmc-crc.h b/libwmc/tests/test-wmc-crc.h
new file mode 100644
index 0000000..4ce2871
--- /dev/null
+++ b/libwmc/tests/test-wmc-crc.h
@@ -0,0 +1,25 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEST_WMC_CRC_H
+#define TEST_WMC_CRC_H
+
+void test_crc16_2 (void *f, void *data);
+void test_crc16_1 (void *f, void *data);
+
+#endif /* TEST_WMC_CRC_H */
+
diff --git a/libwmc/tests/test-wmc-escaping.c b/libwmc/tests/test-wmc-escaping.c
new file mode 100644
index 0000000..3c4cd21
--- /dev/null
+++ b/libwmc/tests/test-wmc-escaping.c
@@ -0,0 +1,165 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "test-wmc-escaping.h"
+#include "utils.h"
+
+static const char data1[] = {
+ 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65,
+ 0x0a, 0x6e, 0x6f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x74, 0x6f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x0a, 0x70, 0x68, 0x6f,
+ 0x6e, 0x7e, 0x7e, 0x7e, 0x7d, 0x7d, 0x7e, 0x7d, 0x7e, 0x7d, 0x7e, 0x6e,
+ 0x6b, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x0a, 0x6f, 0x70,
+ 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x6c,
+ 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72,
+ 0x74, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e,
+ 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66,
+ 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72,
+ 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b,
+ 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d,
+ 0x6e, 0x6f, 0x74, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, 0x0a,
+ 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72,
+ 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65, 0x71,
+ 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x66, 0x61, 0x69,
+ 0x6c, 0x75, 0x72, 0x65, 0x0a, 0x73, 0x69, 0x6d, 0x62, 0x75, 0x73, 0x79,
+ 0x0a, 0x73, 0x69, 0x6d, 0x77, 0x72, 0x6f, 0x6e, 0x67, 0x0a, 0x69, 0x6e,
+ 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x70, 0x61, 0x73, 0x73, 0x77,
+ 0x6f, 0x72, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x32, 0x72,
+ 0x65, 0x71, 0x75, 0x69
+};
+
+static const char expected1[] = {
+ 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65,
+ 0x0a, 0x6e, 0x6f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x74, 0x6f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x0a, 0x70, 0x68, 0x6f,
+ 0x6e, 0x7d, 0x5e, 0x7d, 0x5e, 0x7d, 0x5e, 0x7d, 0x5d, 0x7d, 0x5d, 0x7d,
+ 0x5e, 0x7d, 0x5d, 0x7d, 0x5e, 0x7d, 0x5d, 0x7d, 0x5e, 0x6e, 0x6b, 0x72,
+ 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72,
+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x6c, 0x6c, 0x6f,
+ 0x77, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
+ 0x6e, 0x6e, 0x6f, 0x74, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65,
+ 0x64, 0x0a, 0x70, 0x68, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65,
+ 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69,
+ 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64,
+ 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65,
+ 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x6e, 0x6f,
+ 0x74, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, 0x0a, 0x73, 0x69,
+ 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64,
+ 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65, 0x71, 0x75, 0x69,
+ 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x66, 0x61, 0x69, 0x6c, 0x75,
+ 0x72, 0x65, 0x0a, 0x73, 0x69, 0x6d, 0x62, 0x75, 0x73, 0x79, 0x0a, 0x73,
+ 0x69, 0x6d, 0x77, 0x72, 0x6f, 0x6e, 0x67, 0x0a, 0x69, 0x6e, 0x63, 0x6f,
+ 0x72, 0x72, 0x65, 0x63, 0x74, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
+ 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x32, 0x72, 0x65, 0x71,
+ 0x75, 0x69
+};
+
+void
+test_escape1 (void *f, void *data)
+{
+ char escaped[1024];
+ size_t len;
+
+ /* Ensure that escaping in general works */
+ len = hdlc_escape (data1, sizeof (data1), FALSE, escaped, sizeof (escaped));
+ g_assert (len == 266);
+ g_assert (len == sizeof (expected1));
+ g_assert (memcmp (escaped, expected1, len) == 0);
+}
+
+static const char data2[] = {
+ 0x4b, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
+};
+
+void
+test_escape2 (void *f, void *data)
+{
+ char escaped[1024];
+ size_t len;
+
+ /* Ensure that escaping data that doesn't need escaping works */
+ len = hdlc_escape (data2, sizeof (data2), FALSE, escaped, sizeof (escaped));
+ g_assert (len == sizeof (data2));
+ g_assert (memcmp (escaped, data2, len) == 0);
+}
+
+static const char data_ctrl_src[] = {
+ 0xc8, 0x0d, 0xda, 0x07, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x19, 0x00,
+ 0x04, 0x00, 0x01, 0x00, 0x07, 0x88
+};
+
+static const char data_ctrl_expected[] = {
+ 0xc8, 0x7d, 0x2d, 0xda, 0x7d, 0x27, 0x7d, 0x2c, 0x7d, 0x20, 0x7d, 0x34,
+ 0x7d, 0x20, 0x7d, 0x30, 0x7d, 0x20, 0x7d, 0x39, 0x7d, 0x20, 0x7d, 0x24,
+ 0x7d, 0x20, 0x7d, 0x21, 0x7d, 0x20, 0x7d, 0x27, 0x88
+};
+
+void
+test_escape_ctrl (void *f, void *data)
+{
+ char escaped[1024];
+ size_t len;
+
+ len = hdlc_escape (data_ctrl_src, sizeof (data_ctrl_src), TRUE, escaped, sizeof (escaped));
+ g_assert (len == sizeof (data_ctrl_expected));
+ g_assert (memcmp (escaped, data_ctrl_expected, len) == 0);
+}
+
+void
+test_escape_unescape (void *f, void *data)
+{
+ char escaped[512];
+ char unescaped[512];
+ size_t len, unlen;
+ wmcbool escaping = FALSE;
+
+ /* Ensure that escaping data that needs escaping, and then unescaping it,
+ * produces the exact same data as was originally escaped.
+ */
+ len = hdlc_escape (data1, sizeof (data1), FALSE, escaped, sizeof (escaped));
+ unlen = hdlc_unescape (escaped, len, unescaped, sizeof (unescaped), &escaping);
+
+ g_assert (unlen == sizeof (data1));
+ g_assert (memcmp (unescaped, data1, unlen) == 0);
+}
+
+void
+test_escape_unescape_ctrl (void *f, void *data)
+{
+ char escaped[512];
+ char unescaped[512];
+ size_t len, unlen;
+ wmcbool escaping = FALSE;
+
+ /* Ensure that escaping data that needs escaping, and then unescaping it,
+ * produces the exact same data as was originally escaped.
+ */
+ len = hdlc_escape (data_ctrl_src, sizeof (data_ctrl_src), TRUE, escaped, sizeof (escaped));
+ g_assert (memcmp (escaped, data_ctrl_expected, len) == 0);
+
+ unlen = hdlc_unescape (escaped, len, unescaped, sizeof (unescaped), &escaping);
+ g_assert (unlen == sizeof (data_ctrl_src));
+ g_assert (memcmp (unescaped, data_ctrl_src, unlen) == 0);
+}
+
diff --git a/libwmc/tests/test-wmc-escaping.h b/libwmc/tests/test-wmc-escaping.h
new file mode 100644
index 0000000..144c37b
--- /dev/null
+++ b/libwmc/tests/test-wmc-escaping.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEST_WMC_ESCAPING_H
+#define TEST_WMC_ESCAPING_H
+
+void test_escape1 (void *f, void *data);
+void test_escape2 (void *f, void *data);
+void test_escape_ctrl (void *f, void *data);
+void test_escape_unescape (void *f, void *data);
+void test_escape_unescape_ctrl (void *f, void *data);
+
+#endif /* TEST_WMC_ESCAPING_H */
+
diff --git a/libwmc/tests/test-wmc-utils.c b/libwmc/tests/test-wmc-utils.c
new file mode 100644
index 0000000..49d7351
--- /dev/null
+++ b/libwmc/tests/test-wmc-utils.c
@@ -0,0 +1,223 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "test-wmc-utils.h"
+#include "utils.h"
+
+static const char decap_inbuf[] = {
+ 0x40, 0x03, 0x00, 0x01, 0x00, 0x19, 0xf0, 0x00, 0x16, 0x00, 0x21, 0x00,
+ 0x1c, 0x00, 0xd8, 0x00, 0x3f, 0x00, 0x56, 0x01, 0x3f, 0x00, 0x15, 0x00,
+ 0x1a, 0x00, 0x11, 0x01, 0x3f, 0x00, 0x92, 0x01, 0x3f, 0x00, 0x39, 0x00,
+ 0x3f, 0x00, 0x95, 0x01, 0x3f, 0x00, 0x12, 0x00, 0x3f, 0x00, 0x23, 0x01,
+ 0x3f, 0x00, 0x66, 0x00, 0x3f, 0x00, 0x0b, 0x01, 0x3f, 0x00, 0xae, 0x00,
+ 0x3f, 0x00, 0x02, 0x01, 0x3f, 0x00, 0xa8, 0x00, 0x3f, 0x00, 0x50, 0x01,
+ 0x3f, 0x00, 0xf8, 0x01, 0x3f, 0x00, 0x57, 0x00, 0x3f, 0x00, 0x7d, 0x5e,
+ 0x00, 0x3f, 0x00, 0x93, 0x00, 0x3f, 0x00, 0xbd, 0x00, 0x3f, 0x00, 0x77,
+ 0x01, 0x3f, 0x00, 0xb7, 0x00, 0x3f, 0x00, 0xab, 0x00, 0x3f, 0x00, 0x33,
+ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xad, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13,
+ 0x13, 0x50, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xaa, 0x19, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0xc4, 0x7d, 0x5e,
+ 0x7d, 0x5e, 0x7d, 0x5d, 0x5d, 0x04, 0x58, 0x1b, 0x5b, 0x1b, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x65, 0x69, 0x7e
+};
+
+void
+test_utils_decapsulate_basic_buffer (void *f, void *data)
+{
+ wmcbool success;
+ char outbuf[512];
+ size_t decap_len = 0;
+ size_t used = 0;
+ wmcbool more = FALSE;
+
+ success = hdlc_decapsulate_buffer (decap_inbuf, sizeof (decap_inbuf),
+ FALSE, 0, outbuf, sizeof (outbuf),
+ &decap_len, &used, &more);
+ g_assert (success);
+ g_assert (decap_len == 214);
+ g_assert (used == 221);
+ g_assert (more == FALSE);
+}
+
+
+static const char encap_outbuf[] = {
+ 0x4b, 0x05, 0x08, 0x00, 0x01, 0xdd, 0x7e
+};
+
+void
+test_utils_encapsulate_basic_buffer (void *f, void *data)
+{
+ char cmdbuf[10];
+ char outbuf[512];
+ size_t encap_len = 0;
+
+ cmdbuf[0] = 0x4B; /* DIAG_CMD_SUBSYS */
+ cmdbuf[1] = 0x05; /* DIAG_SUBSYS_HDR */
+ cmdbuf[2] = 0x08; /* first byte of DIAG_SUBSYS_HDR_STATE_INFO in LE */
+ cmdbuf[3] = 0x00; /* second byte of DIAG_SUBSYS_HDR_STATE_INFO in LE */
+
+ encap_len = hdlc_encapsulate_buffer (cmdbuf, 4, sizeof (cmdbuf),
+ 0, TRUE, FALSE,
+ &outbuf[0], sizeof (outbuf));
+ g_assert (encap_len == sizeof (encap_outbuf));
+ g_assert (memcmp (outbuf, encap_outbuf, encap_len) == 0);
+}
+
+static const char cns_inbuf[] = {
+ 0x00, 0x0a, 0x6b, 0x74, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7e
+};
+
+void
+test_utils_decapsulate_sierra_cns (void *f, void *data)
+{
+ wmcbool success;
+ char outbuf[512];
+ size_t decap_len = 0;
+ size_t used = 0;
+ wmcbool more = FALSE;
+
+ success = hdlc_decapsulate_buffer (cns_inbuf, sizeof (cns_inbuf),
+ FALSE, 0, outbuf, sizeof (outbuf),
+ &decap_len, &used, &more);
+ g_assert (success == FALSE);
+}
+
+
+static const char uml290_encap_src[] = {
+ 0xc8, 0x0d, 0xda, 0x07, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x19, 0x00,
+ 0x04, 0x00, 0x01, 0x00, 0x07, 0x88
+};
+
+static const char uml290_encap_outbuf[] = {
+ 0x41, 0x54, 0x2a, 0x57, 0x4d, 0x43, 0x3d, 0xc8, 0x7d, 0x2d, 0xda, 0x7d,
+ 0x27, 0x7d, 0x2c, 0x7d, 0x20, 0x7d, 0x34, 0x7d, 0x20, 0x7d, 0x30, 0x7d,
+ 0x20, 0x7d, 0x39, 0x7d, 0x20, 0x7d, 0x24, 0x7d, 0x20, 0x7d, 0x21, 0x7d,
+ 0x20, 0x7d, 0x27, 0x88, 0x0d
+};
+
+void
+test_utils_encapsulate_uml290_wmc1 (void *f, void *data)
+{
+ char inbuf[512];
+ char outbuf[512];
+ size_t encap_len = 0;
+
+ memcpy (inbuf, uml290_encap_src, sizeof (uml290_encap_src));
+ encap_len = wmc_encapsulate (inbuf, sizeof (uml290_encap_src),
+ sizeof (inbuf), outbuf, sizeof (outbuf), TRUE);
+ g_assert (encap_len == sizeof (encap_outbuf));
+ g_assert (memcmp (outbuf, encap_outbuf, encap_len) == 0);
+}
+
+static const char uml290_src[] = {
+ 0xc8, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xda, 0x07, 0x0c, 0x00,
+ 0x14, 0x00, 0x12, 0x00, 0x19, 0x00, 0x06, 0x00, 0xc2, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x7d, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0x5d, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x01, 0x56, 0x65, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39,
+ 0x00, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00, 0x30, 0x30, 0x7e
+};
+
+static const char uml290_expected[] = {
+ 0xc8, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xda, 0x07, 0x0c, 0x00,
+ 0x14, 0x00, 0x12, 0x00, 0x19, 0x00, 0x06, 0x00, 0xc2, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x56, 0x65, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00,
+ 0x00, 0x40, 0x06, 0x00, 0x00
+};
+
+void
+test_utils_decapsulate_uml290_wmc1 (void *f, void *data)
+{
+ wmcbool success;
+ char outbuf[512];
+ size_t decap_len = 0;
+ size_t used = 0;
+ wmcbool more = FALSE;
+
+ success = hdlc_decapsulate_buffer (uml290_src, sizeof (uml290_src),
+ TRUE, 0x3030, outbuf, sizeof (outbuf),
+ &decap_len, &used, &more);
+ g_assert (success == TRUE);
+ g_assert (more == 0);
+ g_assert_cmpint (used, ==, sizeof (uml290_src));
+ g_assert_cmpint (decap_len, ==, sizeof (uml290_expected));
+ g_assert_cmpint (memcmp (outbuf, uml290_expected, decap_len), ==, 0);
+}
+
+
+static const char pc5740_src[] = {
+ 0xc8, 0x0b, 0x17, 0x00, 0x00, 0x00, 0x06, 0x00, 0xdb, 0x07, 0x06, 0x00,
+ 0x11, 0x00, 0x0d, 0x00, 0x2d, 0x00, 0x10, 0x00, 0xe4, 0x03, 0xd4, 0xfe,
+ 0xff, 0xff, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0e, 0x92, 0x7e
+};
+
+static const char pc5740_expected[] = {
+ 0xc8, 0x0b, 0x17, 0x00, 0x00, 0x00, 0x06, 0x00, 0xdb, 0x07, 0x06, 0x00,
+ 0x11, 0x00, 0x0d, 0x00, 0x2d, 0x00, 0x10, 0x00, 0xe4, 0x03, 0xd4, 0xfe,
+ 0xff, 0xff, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+void
+test_utils_decapsulate_pc5740_wmc1 (void *f, void *data)
+{
+ wmcbool success;
+ char outbuf[512];
+ size_t decap_len = 0;
+ size_t used = 0;
+ wmcbool more = FALSE;
+
+ success = hdlc_decapsulate_buffer (pc5740_src, sizeof (pc5740_src),
+ FALSE, 0, outbuf, sizeof (outbuf),
+ &decap_len, &used, &more);
+ g_assert (success == TRUE);
+ g_assert (more == 0);
+ g_assert_cmpint (used, ==, sizeof (pc5740_src));
+ g_assert_cmpint (decap_len, ==, sizeof (pc5740_expected));
+ g_assert_cmpint (memcmp (outbuf, pc5740_expected, decap_len), ==, 0);
+}
+
diff --git a/libwmc/tests/test-wmc-utils.h b/libwmc/tests/test-wmc-utils.h
new file mode 100644
index 0000000..9642706
--- /dev/null
+++ b/libwmc/tests/test-wmc-utils.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEST_WMC_UTILS_H
+#define TEST_WMC_UTILS_H
+
+void test_utils_decapsulate_basic_buffer (void *f, void *data);
+
+void test_utils_encapsulate_basic_buffer (void *f, void *data);
+
+void test_utils_decapsulate_sierra_cns (void *f, void *data);
+
+void test_utils_encapsulate_uml290_wmc1 (void *f, void *data);
+
+void test_utils_decapsulate_uml290_wmc1 (void *f, void *data);
+
+void test_utils_decapsulate_pc5740_wmc1 (void *f, void *data);
+
+#endif /* TEST_WMC_UTILS_H */
+
diff --git a/libwmc/tests/test-wmc.c b/libwmc/tests/test-wmc.c
new file mode 100644
index 0000000..a0e2e9e
--- /dev/null
+++ b/libwmc/tests/test-wmc.c
@@ -0,0 +1,115 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "test-wmc-crc.h"
+#include "test-wmc-escaping.h"
+#include "test-wmc-utils.h"
+#include "test-wmc-com.h"
+
+typedef struct {
+ gpointer com_data;
+} TestData;
+
+#if GLIB_CHECK_VERSION(2,25,12)
+typedef GTestFixtureFunc TCFunc;
+#else
+typedef void (*TCFunc)(void);
+#endif
+
+#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
+
+static TestData *
+test_data_new (const char *port, gboolean uml290, gboolean debug)
+{
+ TestData *d;
+
+ d = g_malloc0 (sizeof (TestData));
+ g_assert (d);
+
+ if (port)
+ d->com_data = test_com_setup (port, uml290, debug);
+
+ return d;
+}
+
+static void
+test_data_free (TestData *d)
+{
+ if (d->com_data)
+ test_com_teardown (d->com_data);
+
+ g_free (d);
+}
+
+int main (int argc, char **argv)
+{
+ GTestSuite *suite;
+ TestData *data;
+ int i;
+ const char *port = NULL;
+ gint result;
+ gboolean uml290 = FALSE, debug = FALSE;
+
+ g_test_init (&argc, &argv, NULL);
+
+ /* See if we got passed a serial port for live testing */
+ for (i = 0; i < argc; i++) {
+ if (!strcmp (argv[i], "--port")) {
+ /* Make sure there's actually a port in the next arg */
+ g_assert (argc > i + 1);
+ port = argv[++i];
+ } else if (!strcmp (argv[i], "--uml290"))
+ uml290 = TRUE;
+ else if (!strcmp (argv[i], "--debug"))
+ debug = TRUE;
+ }
+
+ data = test_data_new (port, uml290, debug);
+
+ suite = g_test_get_root ();
+ g_test_suite_add (suite, TESTCASE (test_crc16_1, NULL));
+ g_test_suite_add (suite, TESTCASE (test_crc16_2, NULL));
+ g_test_suite_add (suite, TESTCASE (test_escape1, NULL));
+ g_test_suite_add (suite, TESTCASE (test_escape2, NULL));
+ g_test_suite_add (suite, TESTCASE (test_escape_ctrl, NULL));
+ g_test_suite_add (suite, TESTCASE (test_escape_unescape, NULL));
+ g_test_suite_add (suite, TESTCASE (test_escape_unescape_ctrl, NULL));
+ g_test_suite_add (suite, TESTCASE (test_utils_decapsulate_basic_buffer, NULL));
+ g_test_suite_add (suite, TESTCASE (test_utils_encapsulate_basic_buffer, NULL));
+ g_test_suite_add (suite, TESTCASE (test_utils_decapsulate_sierra_cns, NULL));
+ g_test_suite_add (suite, TESTCASE (test_utils_decapsulate_uml290_wmc1, NULL));
+ g_test_suite_add (suite, TESTCASE (test_utils_decapsulate_pc5740_wmc1, NULL));
+
+ /* Live tests */
+ if (port) {
+ g_test_suite_add (suite, TESTCASE (test_com_port_init, data->com_data));
+ g_test_suite_add (suite, TESTCASE (test_com_init, data->com_data));
+ g_test_suite_add (suite, TESTCASE (test_com_device_info, data->com_data));
+ g_test_suite_add (suite, TESTCASE (test_com_network_info, data->com_data));
+ g_test_suite_add (suite, TESTCASE (test_com_get_global_mode, data->com_data));
+ }
+
+ result = g_test_run ();
+
+ test_data_free (data);
+
+ return result;
+}
+