Commit 148a0a91 authored by Yann Diorcet's avatar Yann Diorcet

Add XML2LPC lib/tool

parent 4c346156
......@@ -4,7 +4,7 @@
ACLOCAL_AMFLAGS = -I m4 $(ACLOCAL_MACOS_FLAGS)
SUBDIRS = build m4 pixmaps po @ORTP_DIR@ @MS2_DIR@ \
coreapi console gtk share scripts
coreapi console gtk share scripts tools
......
......@@ -140,6 +140,33 @@ AC_ARG_ENABLE(console_ui,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-console_ui) ;;
esac],[console_ui=true])
dnl conditionnal build of tools.
AC_ARG_ENABLE(tools,
[AS_HELP_STRING([--enable-tools=[yes/no]], [Turn on or off compilation of console interface (default=yes)])],
[case "${enableval}" in
yes) build_tools=true ;;
no) build_tools=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
esac],[build_tools=check])
dnl check libxml2 (needed for tools)
if test "$build_tools" != "false" ; then
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0],[],
[
if test "$build_tools" = "true" ; then
AC_MSG_ERROR([Could not found libxml2, tools cannot be compiled.])
else
build_tools=false
fi
])
fi
AM_CONDITIONAL(BUILD_TOOLS, test x$build_tools != xfalse)
if test "$build_tools" != "false" ; then
build_tools=true
AC_DEFINE(BUILD_TOOLS, 1, [Define if tools enabled] )
fi
dnl conditionnal build of gtk interface.
AC_ARG_ENABLE(gtk_ui,
[AS_HELP_STRING([--enable-gtk_ui=[yes/no]], [Turn on or off compilation of gtk interface (default=yes)])],
......@@ -418,8 +445,10 @@ AC_ARG_ENABLE(portaudio,
dnl build console if required
AM_CONDITIONAL(BUILD_CONSOLE, test x$console_ui = xtrue)
dnl special things for arm-linux cross compilation toolchain
AM_CONDITIONAL(ARMBUILD, test x$use_arm_toolchain = xyes)
dnl compilation of gtk user interface
AM_CONDITIONAL(BUILD_GTK_UI, [test x$gtk_ui = xtrue ] )
AM_CONDITIONAL(BUILD_WIN32, test x$mingw_found = xyes )
......@@ -642,9 +671,11 @@ share/fr/Makefile
share/it/Makefile
share/ja/Makefile
share/cs/Makefile
share/xml/Makefile
share/linphone.pc
share/linphone.desktop
scripts/Makefile
tools/Makefile
linphone.spec
linphone.iss
])
......@@ -657,6 +688,7 @@ printf "* Video support\t\t\t%s\n" $video
printf "* GTK interface\t\t\t%s\n" $gtk_ui
printf "* Account assistant\t\t%s\n" $build_wizard
printf "* Console interface\t\t%s\n" $console_ui
printf "* Tools\t\t\t\t%s\n" $build_tools
printf "* zRTP encryption (GPLv3)\t%s\n" $zrtp
if test "$enable_tunnel" = "true" ; then
......
......@@ -25,6 +25,8 @@
#ifndef LPCONFIG_H
#define LPCONFIG_H
#include <ortp/port.h>
/**
* The LpConfig object is used to manipulate a configuration file.
*
......
SUBDIRS=C fr it ja cs
SUBDIRS=C fr it ja cs xml
LINPHONE_SOUNDS=ringback.wav hello8000.wav hello16000.wav
LINPHONE_RINGS=rings/orig.wav \
......
EXTRA_DIST=lpconfig.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.linphone.org/xsds/lpconfig.xsd"
xmlns:tns="http://www.linphone.org/xsds/lpconfig.xsd"
elementFormDefault="qualified">
<xs:element name="config" type="tns:LPConfig"></xs:element>
<xs:complexType name="LPConfig">
<xs:sequence>
<xs:element name="section" type="tns:LPSection" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LPSection">
<xs:sequence>
<xs:element name="entry" type="tns:LPEntry" maxOccurs="unbounded" minOccurs="0">
</xs:element>
</xs:sequence>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"></xs:minLength>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="LPEntry">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="overwrite" type="xs:boolean"
use="optional" default="false">
</xs:attribute>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"></xs:minLength>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS=\
-I$(top_srcdir) \
-I$(top_srcdir)/coreapi \
-I$(top_srcdir)/exosip
COMMON_CFLAGS=\
-DIN_LINPHONE \
$(LIBXML2_CFLAGS) \
$(ORTP_CFLAGS) \
$(STRICT_OPTIONS)
if BUILD_TOOLS
lib_LTLIBRARIES=libxml2lpc.la
libxml2lpc_la_SOURCES=xml2lpc.c xml2lpc.h
libxml2lpc_la_CFLAGS=$(COMMON_CFLAGS)
libxml2lpc_la_LIBADD=\
$(LIBXML2_LIBS)
bin_PROGRAMS=xml2lpc_test
xml2lpc_test_SOURCES=xml2lpc_test.c
xml2lpc_test_CFLAGS=$(COMMON_CFLAGS)
xml2lpc_test_LDADD=$(top_builddir)/coreapi/liblinphone.la libxml2lpc.la
endif
This diff is collapsed.
/*
linphone
Copyright (C) 2012 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef XML2LPC_H_
#define XML2LPC_H_
#include "lpconfig.h"
typedef struct _xml2lpc_context xml2lpc_context;
typedef enum _xml2lpc_log_level {
XML2LPC_DEBUG = 0,
XML2LPC_MESSAGE,
XML2LPC_WARNING,
XML2LPC_ERROR
} xml2lpc_log_level;
typedef void(*xml2lpc_function)(void *ctx, xml2lpc_log_level level, const char *fmt, va_list list);
xml2lpc_context* xml2lpc_context_new(xml2lpc_function cbf, void *ctx);
void xml2lpc_context_destroy(xml2lpc_context*);
int xml2lpc_set_xml_file(xml2lpc_context* context, const char *filename);
int xml2lpc_set_xml_fd(xml2lpc_context* context, int fd);
int xml2lpc_set_xml_string(xml2lpc_context* context, const char *content);
int xml2lpc_set_xsd_file(xml2lpc_context* context, const char *filename);
int xml2lpc_set_xsd_fd(xml2lpc_context* context, int fd);
int xml2lpc_set_xsd_string(xml2lpc_context* context, const char *content);
int xml2lpc_validate(xml2lpc_context *context);
int xml2lpc_convert(xml2lpc_context *context, LpConfig *lpc);
#endif //XML2LPC_H_
/*
linphone
Copyright (C) 2012 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include "xml2lpc.h"
void cb_function(void *ctx, xml2lpc_log_level level, const char *msg, va_list list) {
const char *header;
switch(level) {
case XML2LPC_DEBUG:
header = "DEBUG";
break;
case XML2LPC_MESSAGE:
header = "MESSAGE";
break;
case XML2LPC_WARNING:
header = "WARNING";
break;
case XML2LPC_ERROR:
header = "ERROR";
break;
}
fprintf(stdout, "%s - ", header);
vfprintf(stdout, msg, list);
fprintf(stdout, "\n");
}
void show_usage(int argc, char *argv[]) {
fprintf(stderr, "usage %s convert <xml_file> <lpc_file>\n"
" %s validate <xml_file> <xsd_file>\n",
argv[0], argv[0]);
}
int main(int argc, char *argv[]) {
if(argc != 4) {
show_usage(argc, argv);
return -1;
}
xml2lpc_context *ctx = xml2lpc_context_new(cb_function, NULL);
xml2lpc_set_xml_file(ctx, argv[2]);
if(strcmp("convert", argv[1]) == 0) {
LpConfig *lpc = lp_config_new(argv[3]);
xml2lpc_convert(ctx, lpc);
lp_config_sync(lpc);
lp_config_destroy(lpc);
} else if(strcmp("validate", argv[1]) == 0) {
xml2lpc_set_xsd_file(ctx, argv[3]);
xml2lpc_validate(ctx);
} else {
show_usage(argc, argv);
}
xml2lpc_context_destroy(ctx);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment