From a8da4e1ba4bedf036bcc1d59a103fda67855697b Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
Date: Wed, 30 Jun 2010 12:54:49 -0400
Subject: [PATCH] [#2524] Add libyaml in configure and makefile

---
 sflphone-common/configure.ac              | 18 +++++++++++++++++-
 sflphone-common/src/config/Makefile.am    | 19 ++++++++++++++++++-
 sflphone-common/src/config/yamlengine.h   |  7 ++++---
 sflphone-common/src/config/yamlparser.cpp |  6 +++---
 sflphone-common/src/config/yamlparser.h   |  4 ++--
 5 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/sflphone-common/configure.ac b/sflphone-common/configure.ac
index 0cf89b3821..e057d6f955 100644
--- a/sflphone-common/configure.ac
+++ b/sflphone-common/configure.ac
@@ -265,9 +265,24 @@ fi
 xml_CFLAGS=
 xml_LIBS=-lexpat
 
-	AC_SUBST(xml_CFLAGS)
+AC_SUBST(xml_CFLAGS)
 AC_SUBST(xml_LIBS)
 
+AC_CHECK_LIB([yaml], yaml_parser_initialize,
+	       [AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false)],
+	       have_yaml = false)
+
+if ! $have_yaml; then
+AC_MSG_ERROR([You need the eXpat xml parser]
+		[http://expat.sourceforge.net/])
+fi
+
+yaml_CFLAGS=
+yaml_LIBS=lyaml
+
+AC_SUBST(yaml_CFLAGS)
+AC_SUBST(yaml_LIBS)
+
 AC_CHECK_LIB([pthread], pthread_create,
 		[AC_CHECK_HEADERS(pthread.h, have_pthread=true, have_pthread=false)],
 		have_pthread=false)
@@ -292,6 +307,7 @@ AC_SUBST(PCRE_CFLAGS)
 
 
 
+
 # For the tools/, we need libdbus-c++ for the "build" architecture as well
 
 	AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = "yes")
diff --git a/sflphone-common/src/config/Makefile.am b/sflphone-common/src/config/Makefile.am
index d72225850f..d3c2bb709a 100644
--- a/sflphone-common/src/config/Makefile.am
+++ b/sflphone-common/src/config/Makefile.am
@@ -3,4 +3,21 @@ SUBDIRS =
 noinst_LTLIBRARIES = libconfig.la
 
 libconfig_la_SOURCES = \
-	config.cpp config.h
+	config.cpp \
+	yamlengine.cpp \
+	yamlemitter.cpp \
+	yamlparser.cpp
+
+noinst_HEADERS = \
+	config.h \
+	engine.h \
+	serializable.h \
+	yamlengine.h \
+	yamlemitter.h \
+	yamlparser.h
+
+libconfig_la_LDFLAGS = \
+	${yaml_LIBS}
+
+libconfig_la_CFLAGS = \
+	${yaml_CFLAGS}
\ No newline at end of file
diff --git a/sflphone-common/src/config/yamlengine.h b/sflphone-common/src/config/yamlengine.h
index 22cb6198d8..665330be88 100644
--- a/sflphone-common/src/config/yamlengine.h
+++ b/sflphone-common/src/config/yamlengine.h
@@ -31,10 +31,11 @@
 #ifndef __YAMLENGINE_H__
 #define __YAMLENGINE_H__
 
+#include "engine.h"
 #include "yamlparser.h"
-#include "yamlemiter.h"
+#include "yamlemitter.h"
 
-class YamlEngine : Engine {
+class YamlEngine : public Engine {
 
  public:
 
@@ -54,7 +55,7 @@ class YamlEngine : Engine {
 
   YamlParser *parser;
 
-  YamlEmiter *emiter;
+  YamlEmitter *emitter;
 
 };
 
diff --git a/sflphone-common/src/config/yamlparser.cpp b/sflphone-common/src/config/yamlparser.cpp
index 8a30402343..0d34db1760 100644
--- a/sflphone-common/src/config/yamlparser.cpp
+++ b/sflphone-common/src/config/yamlparser.cpp
@@ -34,7 +34,7 @@
 
 YamlParser::YamlParser() 
 {
-  memset(buffer, 0, BUFFER_SIZE);
+  memset(buffer, 0, PARSER_BUFFERSIZE);
 
   open();
 }
@@ -69,12 +69,12 @@ void YamlParser::close()
 
 void YamlParser::parse() 
 {
-  bool done;
+  bool done = false;
   yaml_event_t event;
 
   while(!done) {
 
-    if(!yaml_parser_parse(&parse, &event))
+    if(!yaml_parser_parse(&parser, &event))
       throw 20;
 
     done = (event.type == YAML_STREAM_END_EVENT);
diff --git a/sflphone-common/src/config/yamlparser.h b/sflphone-common/src/config/yamlparser.h
index b1e8dcef7e..510cf00f8b 100644
--- a/sflphone-common/src/config/yamlparser.h
+++ b/sflphone-common/src/config/yamlparser.h
@@ -43,7 +43,7 @@ class YamlParser {
 
   YamlParser();
 
-  ~YamlParsere();
+  ~YamlParser();
 
   void open();
 
@@ -68,7 +68,7 @@ class YamlParser {
   /**
    * The event structure array.
    */ 
-  yaml_event_t event[PARSER_MAXEVENT];
+  yaml_event_t events[PARSER_MAXEVENT];
 
   /**
    * 
-- 
GitLab