Commit 0baabf87 authored by Steve Lhomme's avatar Steve Lhomme

libebml2: add a wrapper for Unicode/nonUnicode strings reading (into tchar_t)

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@217 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 5792096e
......@@ -250,6 +250,7 @@ EBML_DLL err_t EBML_StringSetValue(ebml_string *Element,const char *Value);
#if defined(CONFIG_EBML_UNICODE)
EBML_DLL err_t EBML_UniStringSetValue(ebml_string *Element,const tchar_t *Value);
#endif
EBML_DLL void EBML_StringGet(ebml_string *Element,tchar_t *Out, size_t OutLen);
EBML_DLL datetime_t EBML_DateTime(const ebml_date *Element);
EBML_DLL err_t EBML_DateSetDateTime(ebml_date *Element, datetime_t Date);
......
......@@ -49,6 +49,16 @@ err_t EBML_StringSetValue(ebml_string *Element,const char *Value)
return ERR_NONE;
}
void EBML_StringGet(ebml_string *Element,tchar_t *Out, size_t OutLen)
{
#if defined(CONFIG_EBML_UNICODE)
if (Node_IsPartOf(Element,EBML_UNISTRING_CLASS))
Node_FromUTF8(Element,Out,OutLen,Element->Buffer);
else
#endif
Node_FromStr(Element,Out,OutLen,Element->Buffer);
}
static err_t ReadData(ebml_string *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
{
err_t Result;
......
......@@ -3,7 +3,7 @@
GROUP ebml2_group
{
PROJECT_NAME "libebml2"
PROJECT_VERSION 0.9.3
PROJECT_VERSION 0.9.4
PROJECT_VENDOR "Matroska Foundation"
INCLUDE .
......
......@@ -28,6 +28,7 @@
#include <stdio.h>
#define CONFIG_EBML_UNICODE
#include "matroska/matroska.h"
#include "mkvtree_stdafx.h"
......
......@@ -27,6 +27,7 @@
*/
#include "mkclean_stdafx.h"
#include "mkclean_project.h"
#define CONFIG_EBML_UNICODE
#include "matroska/matroska.h"
/*!
......@@ -289,7 +290,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
}
else
{
Node_FromStr(Input,String,TSIZEOF(String),((ebml_string*)SubElement)->Buffer);
EBML_StringGet((ebml_string*)SubElement,String,TSIZEOF(String));
if (tcscmp(String,T("matroska"))!=0)
{
TextPrintf(StdErr,T("EBML DocType %s not supported"),(long)((ebml_integer*)SubElement)->Value);
......@@ -751,11 +752,11 @@ int main(int argc, const char *argv[])
// change the library names & app name
LibName = (ebml_string*)EBML_MasterFindFirstElt(RSegmentInfo, &MATROSKA_ContextMuxingApp, 1, 0);
stprintf_s(String,TSIZEOF(String),T("%s + %s"),Node_GetDataStr((node*)&p,CONTEXT_LIBEBML_VERSION),Node_GetDataStr((node*)&p,CONTEXT_LIBMATROSKA_VERSION));
Node_FromUTF8(RSegmentInfo,Original,TSIZEOF(Original),LibName->Buffer);
EBML_StringGet(LibName,Original,TSIZEOF(Original));
EBML_UniStringSetValue(LibName,String);
AppName = (ebml_string*)EBML_MasterFindFirstElt(RSegmentInfo, &MATROSKA_ContextWritingApp, 1, 0);
Node_FromUTF8(RSegmentInfo,String,TSIZEOF(String),AppName->Buffer);
EBML_StringGet(AppName,String,TSIZEOF(String));
if (!tcsisame_ascii(String,Original)) // libavformat writes the same twice, we only need one
{
tcscat_s(Original,TSIZEOF(Original),T(" + "));
......
......@@ -27,6 +27,7 @@
*/
#include "mkvalidator_stdafx.h"
#include "mkvalidator_project.h"
#define CONFIG_EBML_UNICODE
#include "matroska/matroska.h"
/*!
......@@ -170,7 +171,7 @@ static int CheckCodecs(ebml_element *Tracks, int ProfileNum)
Result |= OutputError(0x302,T("Track #%d type %d not supported for profile '%s'"),(long)EBML_IntegerValue(TrackNum),(long)EBML_IntegerValue(TrackType),Profile[ProfileNum]);
if (CodecID)
{
Node_FromStr(Tracks,CodecName,TSIZEOF(CodecName),CodecID->Buffer);
EBML_StringGet(CodecID,CodecName,TSIZEOF(CodecName));
if (EBML_IntegerValue(TrackType) == TRACK_TYPE_AUDIO)
{
if (!tcsisame_ascii(CodecName,T("A_VORBIS")))
......@@ -463,7 +464,7 @@ int main(int argc, const char *argv[])
OutputError(7,T("The EBML max size length is not supported: %d"),(int)EBML_IntegerValue(RLevel1));
RLevel1 = EBML_MasterFindFirstElt(EbmlHead,&EBML_ContextDocType,1,1);
Node_FromStr(Input,String,TSIZEOF(String),((ebml_string*)RLevel1)->Buffer);
EBML_StringGet((ebml_string*)RLevel1,String,TSIZEOF(String));
if (tcscmp(String,T("matroska"))!=0 && memcmp(((ebml_string*)RLevel1)->Buffer,Test,5)!=0)
{
Result = OutputError(8,T("The EBML doctype is not supported: %s"),String);
......@@ -720,12 +721,12 @@ exit:
AppName = (ebml_string*)EBML_MasterFindFirstElt(RSegmentInfo,&MATROSKA_ContextWritingApp,0,0);
if (AppName)
{
Node_FromUTF8(AppName,String,TSIZEOF(String),AppName->Buffer);
EBML_StringGet(AppName,String,TSIZEOF(String));
tcscat_s(App,TSIZEOF(App),String);
}
if (LibName)
{
Node_FromUTF8(AppName,String,TSIZEOF(String),LibName->Buffer);
EBML_StringGet(LibName,String,TSIZEOF(String));
if (App[0])
tcscat_s(App,TSIZEOF(App),T(" + "));
tcscat_s(App,TSIZEOF(App),String);
......
CONFIG_FILE config.h
PLATFORM_FILES corec/tools/coremake
WORKSPACE matroska
{
USE matroska2
USE mkvtests
}
WORKSPACE ebml
{
USE ebml2
USE ebmltests
}
WORKSPACE matroska
{
USE matroska2
USE mkvtests
USE mkclean
USE mkvalidator
}
#include "*/*.proj"
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