move the sources from the dead coreforge server

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@1 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-02-18 08:13:06 +00:00
commit 0a891b23be
72 changed files with 11265 additions and 0 deletions

1547
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

504
LICENSE.LGPL Normal file
View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

156
debian/changelog vendored Normal file
View File

@ -0,0 +1,156 @@
libebml (0.7.8-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 5 Mar 2008 12:04:07 +0100
libebml (0.7.7-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 31 Mar 2006 14:28:30 +0200
libebml (0.7.6-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 18 Oct 2005 19:54:16 +0200
libebml (0.7.5-2) unstable; urgency=low
* Rebuilt with g++ 4.0.2.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 15 Oct 2005 14:20:24 +0200
libebml (0.7.5-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 20 May 2005 16:27:42 +0200
libebml (0.7.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 16 Apr 2005 13:05:06 +0200
libebml (0.7.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 10 Nov 2004 21:47:35 +0100
libebml (0.7.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 26 Sep 2004 12:16:57 +0200
libebml (0.7.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 25 Jul 2004 12:15:48 +0200
libebml (0.7.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 23 Apr 2004 18:38:00 +0200
libebml (0.6.5-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 9 Mar 2004 21:32:18 +0100
libebml (0.6.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 19 Jan 2004 11:28:42 +0100
libebml (0.6.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Thu, 25 Dec 2003 13:27:27 +0100
libebml (0.6.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Fri, 31 Oct 2003 09:34:13 +0100
libebml (0.6.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 28 Oct 2003 22:45:25 +0100
libebml (0.6.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 17 Sep 2003 22:28:18 +0200
libebml (0.5.1-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 1 Sep 2003 13:27:54 +0200
libebml (0.5.0-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 28 Jul 2003 10:48:35 +0200
libebml (0.4.4-2) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Sat, 14 Jun 2003 17:41:43 +0200
libebml (0.4.4-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 11 Jun 2003 20:27:01 +0200
libebml (0.4.3-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 21 May 2003 22:34:46 +0200
libebml (0.4.2-1) unstable; urgency=low
* New version.
-- Moritz Bunkus <moritz@bunkus.org> Tue, 6 May 2003 22:21:09 +0200
libebml (0.4.0-2) unstable; urgency=low
* Compiled with gcc 3.2.3.
-- Moritz Bunkus <moritz@bunkus.org> Sun, 04 May 2003 22:14:26 +0200
libebml (0.4.0-1) unstable; urgency=low
* First official alpha release.
-- Moritz Bunkus <moritz@bunkus.org> Wed, 30 Apr 2003 10:27:26 +0200
libebml (0.2.0.20030424-1) unstable; urgency=low
* New version with bugfixes from Steve.
-- Moritz Bunkus <moritz@bunkus.org> Thu, 24 Apr 2003 19:57:48 +0200
libebml (0.2.0.20030421-1) unstable; urgency=low
* Initial Release.
-- Moritz Bunkus <moritz@bunkus.org> Mon, 21 Apr 2003 12:49:33 +0200

14
debian/control vendored Normal file
View File

@ -0,0 +1,14 @@
Source: libebml
Priority: optional
Maintainer: Moritz Bunkus <moritz@bunkus.org>
Build-Depends: debhelper (>> 3.0.0)
Standards-Version: 3.5.8
Package: libebml-dev
Section: devel
Architecture: any
Depends: ${shlibs:Depends}
Description: Extensible Binary Meta Language access library
A library for reading and writing files with the Extensible Binary
Meta Language, a binary pendant to XML.

27
debian/copyright vendored Normal file
View File

@ -0,0 +1,27 @@
This package was debianized by Moritz Bunkus <moritz@bunkus.org> on
Mon, 21 Apr 2003 12:49:33 +0200.
It was downloaded from http://www.matroska.org/
Upstream Author: Steve Lhomme <steve.lhomme@free.fr>
Copyright (C) 2002-2003 Steve Lhomme. All rights reserved.
This file may be distributed under the terms of the Q Public License
as defined by Trolltech AS of Norway and appearing in the file
LICENSE.QPL included in the packaging of this file.
This proram is also licensed under the GPL. See
/usr/share/common-licenses/GPL for details.
Licensees holding an other license may use this file in accordance with
the Agreement provided with the Software.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
See http://www.matroska.org/license/qpl/ for QPL licensing information.
Contact license@matroska.org if any conditions of this licensing are
not clear to you.

2
debian/dirs vendored Normal file
View File

@ -0,0 +1,2 @@
usr/bin
usr/sbin

0
debian/docs vendored Normal file
View File

2
debian/libebml-dev.dirs vendored Normal file
View File

@ -0,0 +1,2 @@
usr/lib
usr/include

2
debian/libebml-dev.files vendored Normal file
View File

@ -0,0 +1,2 @@
usr/include/*
usr/lib/lib*.a

96
debian/rules vendored Normal file
View File

@ -0,0 +1,96 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This is the debhelper compatibility version to use.
export DH_COMPAT=4
# shared library versions, option 1
version=2.0.5
major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
$(MAKE) $(DEB_BUILD_OPTIONS) -C make/linux staticlib
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
-$(MAKE) $(DEB_BUILD_OPTIONS) -C make/linux clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
$(MAKE) $(DEB_BUILD_OPTIONS) \
-C make/linux prefix=$(CURDIR)/debian/tmp/usr \
install_staticlib install_headers
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_movefiles
# dh_installdebconf
dh_installdocs
# dh_installexamples
# dh_installmenu
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installman
# dh_installinfo
# dh_undocumented
dh_installchangelogs ChangeLog
dh_link
# dh_strip
dh_compress
dh_fixperms
dh_makeshlibs
dh_installdeb
# dh_perl
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

170
ebml/Debug.h Normal file
View File

@ -0,0 +1,170 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: Debug.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#ifndef LIBEBML_DEBUG_H
#define LIBEBML_DEBUG_H
#include <stdarg.h> // va_list
#include <string.h>
#ifdef WIN32
#include <windows.h>
#else
#include <stdio.h>
#endif // WIN32
#include "EbmlConfig.h"
START_LIBEBML_NAMESPACE
static const int MAX_PREFIX_LENGTH = 128;
#if !defined(NDEBUG)
// define the working debugging class
class EBML_DLL_API ADbg
{
public:
ADbg(int level = 0);
virtual ~ADbg();
/// \todo make an inline function to test the level first and the process
int OutPut(int level, const char * format,...) const;
int OutPut(const char * format,...) const;
inline int setLevel(const int level) {
return my_level = level;
}
inline bool setIncludeTime(const bool included = true) {
return my_time_included = included;
}
bool setDebugFile(const char * NewFilename);
bool unsetDebugFile();
inline bool setUseFile(const bool usefile = true) {
return my_use_file = usefile;
}
inline const char * setPrefix(const char * string) {
return strncpy(prefix, string, MAX_PREFIX_LENGTH);
}
private:
int my_level;
bool my_time_included;
bool my_use_file;
bool my_debug_output;
int _OutPut(const char * format,va_list params) const;
char prefix[MAX_PREFIX_LENGTH];
#ifdef WIN32
HANDLE hFile;
#else
FILE *hFile;
#endif // WIN32
};
#else // !defined(NDEBUG)
// define a class that does nothing (no output)
class EBML_DLL_API ADbg
{
public:
ADbg(int level = 0){}
virtual ~ADbg() {}
inline int OutPut(int level, const char * format,...) const {
return 0;
}
inline int OutPut(const char * format,...) const {
return 0;
}
inline int setLevel(const int level) {
return level;
}
inline bool setIncludeTime(const bool included = true) {
return true;
}
inline bool setDebugFile(const char * NewFilename) {
return true;
}
inline bool unsetDebugFile() {
return true;
}
inline bool setUseFile(const bool usefile = true) {
return true;
}
inline const char * setPrefix(const char * string) {
return string;
}
};
#endif // !defined(NDEBUG)
extern class EBML_DLL_API ADbg globalDebug;
#ifdef LIBEBML_DEBUG
#define EBML_TRACE globalDebug.OutPut
#else
#define EBML_TRACE
#endif
// Unfortunately the Visual C++ new operator doesn't throw a std::bad_alloc. One solution is to
// define out own new operator. But we can't do this globally, since we allow static linking.
// The other is to check every new allocation with an MATROSKA_ASSERT_NEW.
#ifdef _MSC_VER
#define EBML_ASSERT_NEW(p) if(p==0)throw std::bad_alloc()
#else
#define EBML_ASSERT_NEW(p) assert(p!=0)
#endif
END_LIBEBML_NAMESPACE
#endif

102
ebml/EbmlBinary.h Normal file
View File

@ -0,0 +1,102 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlBinary.h 1298 2008-02-21 22:14:18Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
*/
#ifndef LIBEBML_BINARY_H
#define LIBEBML_BINARY_H
#include <string>
#include <cstring>
#include "EbmlTypes.h"
#include "EbmlElement.h"
// ----- Added 10/15/2003 by jcsston from Zen -----
#if defined (__BORLANDC__) //Maybe other compilers?
#include <mem.h>
#endif //__BORLANDC__
// ------------------------------------------------
START_LIBEBML_NAMESPACE
/*!
\class EbmlBinary
\brief Handle all operations on an EBML element that contains "unknown" binary data
\todo handle fix sized elements (like UID of CodecID)
*/
class EBML_DLL_API EbmlBinary : public EbmlElement {
public:
EbmlBinary();
EbmlBinary(const EbmlBinary & ElementToClone);
virtual ~EbmlBinary(void);
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
void SetBuffer(const binary *Buffer, const uint32 BufferSize) {
Data = (binary *) Buffer;
Size = BufferSize;
bValueIsSet = true;
}
binary *GetBuffer() const {return Data;}
void CopyBuffer(const binary *Buffer, const uint32 BufferSize) {
if (Data != NULL)
free(Data);
Data = (binary *)malloc(BufferSize * sizeof(binary));
memcpy(Data, Buffer, BufferSize);
Size = BufferSize;
bValueIsSet = true;
}
uint64 GetSize() const {return Size;}
operator const binary &() const {return *Data;}
bool IsDefaultValue() const {
return false;
}
bool operator==(const EbmlBinary & ElementToCompare) const;
protected:
binary *Data; // the binary data inside the element
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_BINARY_H

110
ebml/EbmlConfig.h Normal file
View File

@ -0,0 +1,110 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlConfig.h 1241 2006-01-25 00:59:45Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#ifndef LIBEBML_CONFIG_H
#define LIBEBML_CONFIG_H
// automatic endianess detection working on GCC
#if !defined(WORDS_BIGENDIAN)
#if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) || defined (__amd64__) || defined (__x86_64__)
#undef WORDS_BIGENDIAN
#elif defined (__sparc__) || defined (__alpha__) || defined (__PPC__) || defined (__mips__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
#define WORDS_BIGENDIAN 1
#else
// not automatically detected, put it yourself
#undef WORDS_BIGENDIAN // for my testing platform (x86)
#endif
#endif // not autoconf
#define LIBEBML_NAMESPACE libebml
#if defined(NO_NAMESPACE) // for older GCC
# define START_LIBEBML_NAMESPACE
# define END_LIBEBML_NAMESPACE
#else // NO_NAMESPACE
# define START_LIBEBML_NAMESPACE namespace LIBEBML_NAMESPACE {
# define END_LIBEBML_NAMESPACE };
#endif // NO_NAMESPACE
// There are special implementations for certain platforms. For example on Windows
// we use the Win32 file API. here we set the appropriate macros.
#if defined(_WIN32)||defined(WIN32)
# if defined(EBML_DLL)
# if defined(EBML_DLL_EXPORT)
# define EBML_DLL_API __declspec(dllexport)
# else // EBML_DLL_EXPORT
# define EBML_DLL_API __declspec(dllimport)
# endif // EBML_DLL_EXPORT
# else // EBML_DLL
# define EBML_DLL_API
# endif // EBML_DLL
# ifdef _MSC_VER
# pragma warning(disable:4786) // length of internal identifiers
# endif // _MSC_VER
#else
# define EBML_DLL_API
#endif // WIN32 || _WIN32
#ifndef countof
#define countof(x) (sizeof(x)/sizeof(x[0]))
#endif
// The LIBEBML_DEBUG symbol is defined, when we are creating a debug build. In this
// case the debug logging code is compiled in.
#if (defined(DEBUG)||defined(_DEBUG))&&!defined(LIBEBML_DEBUG)
#define LIBEBML_DEBUG
#endif
// For compilers that don't define __TIMESTAMP__ (e.g. gcc 2.95, gcc 3.2)
#ifndef __TIMESTAMP__
#define __TIMESTAMP__ __DATE__ " " __TIME__
#endif
#ifdef __GNUC__
#define EBML_PRETTYLONGINT(c) (c ## ll)
#else // __GNUC__
#define EBML_PRETTYLONGINT(c) (c)
#endif // __GNUC__
#if __BORLANDC__ >= 0x0581 //Borland C++ Builder 2006 preview
#include <stdlib.h> //malloc(), free()
#include <memory.h> //memcpy()
#endif //__BORLANDC__
#endif // LIBEBML_CONFIG_H

59
ebml/EbmlContexts.h Normal file
View File

@ -0,0 +1,59 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlContexts.h 736 2004-08-28 14:05:09Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_CONTEXTS_H
#define LIBEBML_CONTEXTS_H
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
extern const EbmlSemanticContext EBML_DLL_API EbmlHead_Context;
extern const EbmlSemanticContext EBML_DLL_API EVersion_Context;
extern const EbmlSemanticContext EBML_DLL_API EReadVersion_Context;
extern const EbmlSemanticContext EBML_DLL_API EMaxIdLength_Context;
extern const EbmlSemanticContext EBML_DLL_API EMaxSizeLength_Context;
extern const EbmlSemanticContext EBML_DLL_API EDocType_Context;
extern const EbmlSemanticContext EBML_DLL_API EDocTypeVersion_Context;
extern const EbmlSemanticContext EBML_DLL_API EDocTypeReadVersion_Context;
// global elements
extern const EbmlSemanticContext EBML_DLL_API EbmlVoid_Context;
extern const EbmlSemanticContext EBML_DLL_API & GetEbmlGlobal_Context();
END_LIBEBML_NAMESPACE
#endif // LIBEBML_CONTEXTS_H

157
ebml/EbmlCrc32.h Normal file
View File

@ -0,0 +1,157 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlCrc32.h 1326 2009-08-23 00:47:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
#ifndef LIBEBML_CRC32_H
#define LIBEBML_CRC32_H
#include "EbmlTypes.h"
#include "EbmlBinary.h"
START_LIBEBML_NAMESPACE
const uint32 CRC32_NEGL = 0xffffffffL;
#ifdef WORDS_BIGENDIAN
# define CRC32_INDEX(c) (c >> 24)
# define CRC32_SHIFTED(c) (c << 8)
#else
# define CRC32_INDEX(c) (c & 0xff)
# define CRC32_SHIFTED(c) (c >> 8)
#endif
class EBML_DLL_API EbmlCrc32 : public EbmlBinary {
public:
EbmlCrc32();
EbmlCrc32(const EbmlCrc32 & ElementToClone);
static EbmlElement & Create() {return *(new EbmlCrc32);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
bool ValidateSize() const {return (Size == 4);}
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
// uint64 UpdateSize(bool bKeepIntact = false);
static const EbmlCallbacks ClassInfos;
bool IsDefaultValue() const {
return false;
}
operator const EbmlId &() const {return ClassInfos.GlobalId;}
bool IsYourId(const EbmlId & TestId) const;
void AddElementCRC32(EbmlElement &ElementToCRC);
bool CheckElementCRC32(EbmlElement &ElementToCRC);
/*!
CRC Checksum Calculation
*/
enum {DIGESTSIZE = 4};
/*!
Use this to quickly check a CRC32 with some data
\return True if inputCRC matches CRC32 generated from input data
*/
static bool CheckCRC(uint32 inputCRC, const binary *input, uint32 length);
/*!
Calls Update() and Finalize(), use to create a CRC32 in one go
*/
void FillCRC32(const binary *input, uint32 length);
/*!
Add data to the CRC table, in other words process some data bit by bit
*/
void Update(const binary *input, uint32 length);
/*!
Use this with Update() to Finalize() or Complete the CRC32
*/
void Finalize();
/*!
Returns a uint32 that has the value of the CRC32
*/
uint32 GetCrc32() const {
return m_crc_final;
};
void ForceCrc32(uint32 NewValue) { m_crc_final = NewValue; bValueIsSet = true;}
EbmlElement * Clone() const;
protected:
void ResetCRC() {m_crc = CRC32_NEGL;}
void UpdateByte(binary b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
static const uint32 m_tab[256];
uint32 m_crc;
uint32 m_crc_final;
};
template <class T>
inline unsigned int GetAlignment(T *dummy=NULL) // VC60 workaround
{
#if (_MSC_VER >= 1300)
return __alignof(T);
#elif defined(__GNUC__)
return __alignof__(T);
#else
return sizeof(T);
#endif
}
template <class T>
inline bool IsPowerOf2(T n)
{
return n > 0 && (n & (n-1)) == 0;
}
template <class T1, class T2>
inline T2 ModPowerOf2(T1 a, T2 b)
{
assert(IsPowerOf2(b));
return T2(a) & (b-1);
}
inline bool IsAlignedOn(const void *p, unsigned int alignment)
{
return IsPowerOf2(alignment) ? ModPowerOf2((uintptr_t)p, alignment) == 0 : (uintptr_t)p % alignment == 0;
}
template <class T>
inline bool IsAligned(const void *p, T *dummy=NULL) // VC60 workaround
{
return IsAlignedOn(p, GetAlignment<T>());
}
END_LIBEBML_NAMESPACE
#endif // LIBEBML_CRC32_H

94
ebml/EbmlDate.h Normal file
View File

@ -0,0 +1,94 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_DATE_H
#define LIBEBML_DATE_H
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
/*!
\class EbmlDate
\brief Handle all operations related to an EBML date
*/
class EBML_DLL_API EbmlDate : public EbmlElement {
public:
EbmlDate() :EbmlElement(8, false), myDate(0) {}
EbmlDate(const EbmlDate & ElementToClone);
/*!
\brief set the date with a UNIX/C/EPOCH form
\param NewDate UNIX/C date in UTC (no timezone)
*/
void SetEpochDate(int32 NewDate) {bValueIsSet = true; myDate = int64(NewDate - UnixEpochDelay) * 1000000000; bValueIsSet = true;}
/*!
\brief get the date with a UNIX/C/EPOCH form
\note the date is in UTC (no timezone)
*/
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
bool ValidateSize() const {return ((Size == 8) || (Size == 0));}
/*!
\note no Default date handled
*/
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) {
if(!bValueIsSet)
Size = 0;
else
Size = 8;
return Size;
}
bool operator<(const EbmlDate & EltCmp) const {return myDate < EltCmp.myDate;}
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
bool IsDefaultValue() const {
return false;
}
protected:
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
int64 myDate; ///< internal format of the date
static const uint64 UnixEpochDelay;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_DATE_H

66
ebml/EbmlDummy.h Normal file
View File

@ -0,0 +1,66 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlDummy.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_DUMMY_H
#define LIBEBML_DUMMY_H
#include "EbmlBinary.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EbmlDummy : public EbmlBinary {
public:
EbmlDummy() :DummyId(DummyRawId) {}
EbmlDummy(const EbmlId & aId) :EbmlBinary(), DummyId(aId) {}
EbmlDummy(const EbmlDummy & ElementToClone):EbmlBinary(ElementToClone), DummyId(ElementToClone.DummyId) {}
static EbmlElement & Create() {return *(new EbmlDummy);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return DummyId;}
bool ValidateSize() const {return true;}
bool IsDummy() const {return true;}
bool IsDefaultValue() const {return true;}
EbmlElement * Clone() const {return new EbmlDummy(*this);}
protected:
const EbmlId DummyId;
static const EbmlId DummyRawId;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_DUMMY_H

280
ebml/EbmlElement.h Normal file
View File

@ -0,0 +1,280 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlElement.h 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_ELEMENT_H
#define LIBEBML_ELEMENT_H
#include <cassert>
#include "EbmlTypes.h"
#include "EbmlId.h"
#include "IOCallback.h"
START_LIBEBML_NAMESPACE
/*!
\brief The size of the EBML-coded length
*/
int EBML_DLL_API CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeIsFinite = true);
/*!
\brief The coded value of the EBML-coded length
\note The size of OutBuffer must be 8 octets at least
*/
int EBML_DLL_API CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer);
/*!
\brief Read an EBML-coded value from a buffer
\return the value read
*/
uint64 EBML_DLL_API ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
/*!
\brief The size of the EBML-coded signed length
*/
int EBML_DLL_API CodedSizeLengthSigned(int64 Length, unsigned int SizeLength);
/*!
\brief The coded value of the EBML-coded signed length
\note the size of OutBuffer must be 8 octets at least
*/
int EBML_DLL_API CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer);
/*!
\brief Read a signed EBML-coded value from a buffer
\return the value read
*/
int64 EBML_DLL_API ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
class EbmlStream;
class EbmlSemanticContext;
class EbmlElement;
// functions for generic handling of data (should be static to all classes)
/*!
\todo Handle default value
*/
class EBML_DLL_API EbmlCallbacks {
public:
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext)
:Create(Creator)
,GlobalId(aGlobalId)
,DebugName(aDebugName)
,Context(aContext)
{}
EbmlElement & (*Create)();
const EbmlId & GlobalId;
const char * DebugName;
const EbmlSemanticContext & Context;
};
/*!
\brief contains the semantic informations for a given level and all sublevels
\todo move the ID in the element class
*/
class EBML_DLL_API EbmlSemantic {
public:
EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
:Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {}
bool Mandatory; ///< wether the element is mandatory in the context or not
bool Unique;
const EbmlCallbacks & GetCallbacks;
};
typedef const class EbmlSemanticContext & (*_GetSemanticContext)();
/*!
Context of the element
\todo allow more than one parent ?
*/
class EBML_DLL_API EbmlSemanticContext {
public:
EbmlSemanticContext(unsigned int aSize,
const EbmlSemantic *aMyTable,
const EbmlSemanticContext *aUpTable,
const _GetSemanticContext aGetGlobalContext,
const EbmlCallbacks *aMasterElt)
:Size(aSize), MyTable(aMyTable), UpTable(aUpTable),
GetGlobalContext(aGetGlobalContext), MasterElt(aMasterElt) {}
bool operator!=(const EbmlSemanticContext & aElt) const {
return ((Size != aElt.Size) || (MyTable != aElt.MyTable) ||
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
(MasterElt != aElt.MasterElt));
}
unsigned int Size; ///< number of elements in the table
const EbmlSemantic *MyTable; ///< First element in the table
const EbmlSemanticContext *UpTable; ///< Parent element
/// \todo replace with the global context directly
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
const EbmlCallbacks *MasterElt;
};
/*!
\class EbmlElement
\brief Hold basic informations about an EBML element (ID + length)
*/
class EBML_DLL_API EbmlElement {
public:
EbmlElement(const uint64 aDefaultSize, bool bValueSet = false);
virtual ~EbmlElement() {assert(!bLocked);}
/// Set the minimum length that will be used to write the element size (-1 = optimal)
void SetSizeLength(const int NewSizeLength) {SizeLength = NewSizeLength;}
int GetSizeLength() const {return SizeLength;}
static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
/*!
\brief find the next element with the same ID
*/
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize);
EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false);
/*!
\brief Give a copy of the element, all data inside the element is copied
\return NULL if there is not enough memory
*/
virtual EbmlElement * Clone() const = 0;
virtual operator const EbmlId &() const = 0;
// by default only allow to set element as finite (override when needed)
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;}
virtual bool ValidateSize() const = 0;
uint64 GetElementPosition() const {
return ElementPosition;
}
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing
uint32 Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
virtual uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
virtual uint64 GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
virtual uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA);
/// return the generic callback to monitor a derived class
virtual const EbmlCallbacks & Generic() const = 0;
bool IsLocked() const {return bLocked;}
void Lock(bool bLock = true) { bLocked = bLock;}
/*!
\brief default comparison for elements that can't be compared
*/
virtual bool operator<(const EbmlElement & EltB) const {
return true;
}
static bool CompareElements(const EbmlElement *A, const EbmlElement *B);
virtual bool IsDummy() const {return false;}
virtual bool IsMaster() const {return false;}
uint8 HeadSize() const {
return EbmlId(*this).Length + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
} /// return the size of the head, on reading/writing
/*!
\brief Force the size of an element
\warning only possible if the size is "undefined"
*/
bool ForceSize(uint64 NewSize);
uint32 OverwriteHead(IOCallback & output, bool bKeepPosition = false);
/*!
\brief void the content of the element (replace by EbmlVoid)
*/
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false);
bool DefaultISset() const {return DefaultIsSet;}
virtual bool IsDefaultValue() const = 0;
bool IsFiniteSize() const {return bSizeIsFinite;}
/*!
\brief set the default size of an element
*/
virtual void SetDefaultSize(const uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
bool ValueIsSet() const {return bValueIsSet;}
inline uint64 GetEndPosition() const {
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
}
protected:
uint64 Size; ///< the size of the data to write
uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
int SizeLength; /// the minimum size on which the size will be written (0 = optimal)
bool bSizeIsFinite;
uint64 ElementPosition;
uint64 SizePosition;
bool bValueIsSet;
bool DefaultIsSet;
bool bLocked;
/*!
\brief find any element in the stream
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed
*/
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1);
uint32 RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false);
uint32 MakeRenderHead(IOCallback & output, bool bKeepPosition);
/*!
\brief prepare the data before writing them (in case it's not already done by default)
*/
virtual uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0;
/*!
\brief special constructor for cloning
*/
EbmlElement(const EbmlElement & ElementToClone);
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_ELEMENT_H

120
ebml/EbmlEndian.h Normal file
View File

@ -0,0 +1,120 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlEndian.h 1298 2008-02-21 22:14:18Z mosu $
\author Ingo Ralf Blum <ingoralfblum @ users.sf.net>
\author Lasse Kärkkäinen <tronic @ users.sf.net>
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_ENDIAN_H
#define LIBEBML_ENDIAN_H
#include <algorithm>
#include <cstring>
#include "EbmlConfig.h" // contains _ENDIANESS_
START_LIBEBML_NAMESPACE
enum endianess {
big_endian, ///< PowerPC, Alpha, 68000
little_endian ///< Intel x86 platforms
};
/*!
\class Endian
\brief general class to handle endian-specific buffers
\note don't forget to define/undefine _ENDIANESS_ to BIG_ENDIAN depending on your machine
*/
template<class TYPE, endianess ENDIAN> class Endian
{
public:
Endian() {}
Endian(const TYPE value)
{
memcpy(&platform_value, &value, sizeof(TYPE));
process_endian();
}
inline Endian & Eval(const binary *endian_buffer)
{
//endian_value = *(TYPE *)(endian_buffer);
memcpy(&endian_value, endian_buffer, sizeof(TYPE)); // Some (all?) RISC processors do not allow reading objects bigger than 1 byte from non-aligned addresses, and endian_buffer may point to a non-aligned address.
process_platform();
return *this;
}
inline void Fill(binary *endian_buffer) const
{
//*(TYPE*)endian_buffer = endian_value;
memcpy(endian_buffer, &endian_value, sizeof(TYPE)); // See above.
}
inline operator const TYPE&() const { return platform_value; }
// inline TYPE endian() const { return endian_value; }
inline const TYPE &endian() const { return endian_value; }
inline size_t size() const { return sizeof(TYPE); }
inline bool operator!=(const binary *buffer) const {return *((TYPE*)buffer) == platform_value;}
protected:
TYPE platform_value;
TYPE endian_value;
inline void process_endian()
{
endian_value = platform_value;
#ifdef WORDS_BIGENDIAN
if (ENDIAN == little_endian)
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
#else // _ENDIANESS_
if (ENDIAN == big_endian)
std::reverse(reinterpret_cast<uint8*>(&endian_value),reinterpret_cast<uint8*>(&endian_value+1));
#endif // _ENDIANESS_
}
inline void process_platform()
{
platform_value = endian_value;
#ifdef WORDS_BIGENDIAN
if (ENDIAN == little_endian)
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
#else // _ENDIANESS_
if (ENDIAN == big_endian)
std::reverse(reinterpret_cast<uint8*>(&platform_value),reinterpret_cast<uint8*>(&platform_value+1));
#endif // _ENDIANESS_
}
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_ENDIAN_H

100
ebml/EbmlFloat.h Normal file
View File

@ -0,0 +1,100 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlFloat.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_FLOAT_H
#define LIBEBML_FLOAT_H
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
/*!
\class EbmlFloat
\brief Handle all operations on a float EBML element
*/
class EBML_DLL_API EbmlFloat : public EbmlElement {
public:
enum Precision {
FLOAT_32
,FLOAT_64
};
EbmlFloat(const Precision prec = FLOAT_32);
EbmlFloat(const double DefaultValue, const Precision prec = FLOAT_32);
EbmlFloat(const EbmlFloat & ElementToClone);
bool ValidateSize() const
{
return (Size == 4 || Size == 8);
}
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32)
{
if (prec == FLOAT_64)
Size = 8;
else
Size = 4; // default size
}
// EbmlFloat & operator=(const float NewValue) { Value = NewValue; return *this;}
EbmlFloat & operator=(const double NewValue) { Value = NewValue; bValueIsSet = true; return *this;}
bool operator<(const EbmlFloat & EltCmp) const {return Value < EltCmp.Value;}
operator const float() const {return float(Value);}
operator const double() const {return double(Value);}
void SetDefaultValue(double aValue) {assert(!DefaultIsSet); DefaultValue = aValue; DefaultIsSet = true;}
const double DefaultVal() const {assert(DefaultIsSet); return DefaultValue;}
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);
}
protected:
double Value; /// The actual value of the element
double DefaultValue;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_FLOAT_H

59
ebml/EbmlHead.h Normal file
View File

@ -0,0 +1,59 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlHead.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_HEAD_H
#define LIBEBML_HEAD_H
#include "EbmlTypes.h"
#include "EbmlMaster.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EbmlHead : public EbmlMaster {
public:
EbmlHead();
EbmlHead(const EbmlHead & ElementToClone) : EbmlMaster(ElementToClone) {}
static EbmlElement & Create() {return *(new EbmlHead);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
bool IsYourId(const EbmlId & TestId) const;
EbmlElement * Clone() const {return new EbmlHead(*this);}
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_HEAD_H

84
ebml/EbmlId.h Normal file
View File

@ -0,0 +1,84 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlId.h 936 2004-11-10 20:46:28Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_ID_H
#define LIBEBML_ID_H
#include "EbmlTypes.h"
START_LIBEBML_NAMESPACE
/*!
\class EbmlId
*/
class EBML_DLL_API EbmlId {
public:
uint32 Value;
unsigned int Length;
EbmlId(const binary aValue[4], const unsigned int aLength)
:Length(aLength)
{
Value = 0;
unsigned int i;
for (i=0; i<aLength; i++) {
Value <<= 8;
Value += aValue[i];
}
}
EbmlId(const uint32 aValue, const unsigned int aLength)
:Value(aValue), Length(aLength) {}
inline bool operator==(const EbmlId & TestId) const
{
return ((TestId.Length == Length) && (TestId.Value == Value));
}
inline bool operator!=(const EbmlId & TestId) const
{
return !(*this == TestId);
}
inline void Fill(binary * Buffer) const {
unsigned int i;
for (i = 0; i<Length; i++) {
Buffer[i] = (Value >> (8*(Length-i-1))) & 0xFF;
}
}
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_ID_H

208
ebml/EbmlMaster.h Normal file
View File

@ -0,0 +1,208 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlMaster.h 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_MASTER_H
#define LIBEBML_MASTER_H
#include <string>
#include <vector>
#include "EbmlTypes.h"
#include "EbmlElement.h"
#include "EbmlCrc32.h"
START_LIBEBML_NAMESPACE
const bool bChecksumUsedByDefault = false;
/*!
\class EbmlMaster
\brief Handle all operations on an EBML element that contains other EBML elements
*/
class EBML_DLL_API EbmlMaster : public EbmlElement {
public:
EbmlMaster(const EbmlSemanticContext & aContext, bool bSizeIsKnown = true);
EbmlMaster(const EbmlMaster & ElementToClone);
bool ValidateSize() const {return true;}
/*!
\warning be carefull to clear the memory allocated in the ElementList elsewhere
*/
virtual ~EbmlMaster();
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
/*!
\brief Set wether the size is finite (size is known in advance when writing, or infinite size is not known on writing)
*/
bool SetSizeInfinite(bool aIsInfinite = true) {bSizeIsFinite = !aIsInfinite; return true;}
bool PushElement(EbmlElement & element);
uint64 GetSize() const {
if (bSizeIsFinite)
return Size;
else
return (0-1);
}
uint64 GetDataStart() const {
return ElementPosition + EbmlId(*this).Length + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
}
/*!
\brief find the element corresponding to the ID of the element, NULL if not found
*/
EbmlElement *FindElt(const EbmlCallbacks & Callbacks) const;
/*!
\brief find the first element corresponding to the ID of the element
*/
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks, const bool bCreateIfNull);
EbmlElement *FindFirstElt(const EbmlCallbacks & Callbacks) const;
/*!
\brief find the element of the same type of PasElt following in the list of elements
*/
EbmlElement *FindNextElt(const EbmlElement & PastElt, const bool bCreateIfNull);
EbmlElement *FindNextElt(const EbmlElement & PastElt) const;
EbmlElement *AddNewElt(const EbmlCallbacks & Callbacks);
/*!
\brief add an element at a specified location
*/
bool InsertElement(EbmlElement & element, size_t position = 0);
bool InsertElement(EbmlElement & element, const EbmlElement & before);
/*!
\brief Read the data and keep the known children
*/
void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully = SCOPE_ALL_DATA);
/*!
\brief sort Data when they can
*/
void Sort();
size_t ListSize() const {return ElementList.size();}
EbmlElement * operator[](unsigned int position) {return ElementList[position];}
const EbmlElement * operator[](unsigned int position) const {return ElementList[position];}
bool IsDefaultValue() const {
return (ElementList.size() == 0);
}
virtual bool IsMaster() const {return true;}
/*!
\brief verify that all mandatory elements are present
\note usefull after reading or before writing
*/
bool CheckMandatory() const;
/*!
\brief Remove an element from the list of the master
*/
void Remove(size_t Index);
/*!
\brief remove all elements, even the mandatory ones
*/
void RemoveAll() {ElementList.clear();}
/*!
\brief facility for Master elements to write only the head and force the size later
\warning
*/
uint32 WriteHead(IOCallback & output, int SizeLength, bool bKeepIntact = false);
void EnableChecksum(bool bIsEnabled = true) { bChecksumUsed = bIsEnabled; }
bool HasChecksum() const {return bChecksumUsed;}
bool VerifyChecksum() const;
uint32 GetCrc32() const {return Checksum.GetCrc32();}
void ForceChecksum(uint32 NewChecksum) {
Checksum.ForceCrc32(NewChecksum);
bChecksumUsed = true;
}
/*!
\brief drill down all sub-elements, finding any missing elements
*/
std::vector<std::string> FindAllMissingElements();
protected:
std::vector<EbmlElement *> ElementList;
const EbmlSemanticContext & Context;
bool bChecksumUsed;
EbmlCrc32 Checksum;
private:
/*!
\brief Add all the mandatory elements to the list
*/
bool ProcessMandatory();
};
///< \todo add a restriction to only elements legal in the context
template <typename Type>
Type & GetChild(EbmlMaster & Master)
{
return *(static_cast<Type *>(Master.FindFirstElt(Type::ClassInfos, true)));
}
// call with
// MyDocType = GetChild<EDocType>(TestHead);
template <typename Type>
Type * FindChild(EbmlMaster & Master)
{
return static_cast<Type *>(Master.FindFirstElt(Type::ClassInfos, false));
}
template <typename Type>
Type & GetNextChild(EbmlMaster & Master, const Type & PastElt)
{
return *(static_cast<Type *>(Master.FindNextElt(PastElt, true)));
}
template <typename Type>
Type & AddNewChild(EbmlMaster & Master)
{
return *(static_cast<Type *>(Master.AddNewElt(Type::ClassInfos)));
}
END_LIBEBML_NAMESPACE
#endif // LIBEBML_MASTER_H

92
ebml/EbmlSInteger.h Normal file
View File

@ -0,0 +1,92 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlSInteger.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#ifndef LIBEBML_SINTEGER_H
#define LIBEBML_SINTEGER_H
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
const int DEFAULT_INT_SIZE = 1; ///< optimal size stored
/*!
\class EbmlSInteger
\brief Handle all operations on a signed integer EBML element
*/
class EBML_DLL_API EbmlSInteger : public EbmlElement {
public:
EbmlSInteger();
EbmlSInteger(const int64 DefaultValue);
EbmlSInteger(const EbmlSInteger & ElementToClone);
EbmlSInteger & operator=(const int64 NewValue) {Value = NewValue; bValueIsSet = true; return *this;}
/*!
Set the default size of the integer (usually 1,2,4 or 8)
*/
void SetDefaultSize(const int nDefaultSize = DEFAULT_INT_SIZE) {Size = nDefaultSize;}
bool ValidateSize() const {return (Size <= 8);}
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
bool operator<(const EbmlSInteger & EltCmp) const {return Value < EltCmp.Value;}
operator int8() {return int8(Value);}
operator int16() {return int16(Value);}
operator int32() {return int32(Value);}
operator int64() {return Value;}
void SetDefaultValue(int64 aValue) {assert(!DefaultIsSet); DefaultValue = aValue; DefaultIsSet = true;}
const int64 DefaultVal() const {assert(DefaultIsSet); return DefaultValue;}
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);
}
protected:
int64 Value; /// The actual value of the element
int64 DefaultValue;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_SINTEGER_H

71
ebml/EbmlStream.h Normal file
View File

@ -0,0 +1,71 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlStream.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_STREAM_H
#define LIBEBML_STREAM_H
#include "EbmlTypes.h"
#include "IOCallback.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
/*!
\class EbmlStream
\brief Handle an input/output stream of EBML elements
*/
class EBML_DLL_API EbmlStream {
public:
EbmlStream(IOCallback & output);
~EbmlStream();
/*!
\brief Find a possible next ID in the data stream
\param MaxDataSize The maximum possible of the data in the element (for sanity checks)
\note the user will have to delete that element later
*/
EbmlElement * FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
EbmlElement * FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
inline IOCallback & I_O() {return Stream;}
protected:
IOCallback & Stream;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_STREAM_H

81
ebml/EbmlString.h Normal file
View File

@ -0,0 +1,81 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlString.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_STRING_H
#define LIBEBML_STRING_H
#include <string>
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
/*!
\class EbmlString
\brief Handle all operations on a printable string EBML element
*/
class EBML_DLL_API EbmlString : public EbmlElement {
public:
EbmlString();
EbmlString(const std::string & aDefaultValue);
EbmlString(const EbmlString & ElementToClone);
virtual ~EbmlString() {}
bool ValidateSize() const {return true;} // any size is possible
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
EbmlString & operator=(const std::string);
operator const std::string &() const {return Value;}
void SetDefaultValue(std::string & aValue) {assert(!DefaultIsSet); DefaultValue = aValue; DefaultIsSet = true;}
const std::string DefaultVal() const {assert(DefaultIsSet); return DefaultValue;}
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);
}
protected:
std::string Value; /// The actual value of the element
std::string DefaultValue;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_STRING_H

125
ebml/EbmlSubHead.h Normal file
View File

@ -0,0 +1,125 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlSubHead.h 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_SUBHEAD_H
#define LIBEBML_SUBHEAD_H
#include <string>
#include "EbmlUInteger.h"
#include "EbmlString.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EVersion : public EbmlUInteger {
public:
EVersion() :EbmlUInteger(1) {}
EVersion(const EVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EVersion);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EVersion(*this);}
};
class EBML_DLL_API EReadVersion : public EbmlUInteger {
public:
EReadVersion() :EbmlUInteger(1) {}
EReadVersion(const EReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EReadVersion);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EReadVersion(*this);}
};
class EBML_DLL_API EMaxIdLength : public EbmlUInteger {
public:
EMaxIdLength() :EbmlUInteger(4) {}
EMaxIdLength(const EMaxIdLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EMaxIdLength);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EMaxIdLength(*this);}
};
class EBML_DLL_API EMaxSizeLength : public EbmlUInteger {
public:
EMaxSizeLength() :EbmlUInteger(8) {}
EMaxSizeLength(const EMaxSizeLength & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EMaxSizeLength);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EMaxSizeLength(*this);}
};
class EBML_DLL_API EDocType : public EbmlString {
public:
EDocType() {}
EDocType(const EDocType & ElementToClone) : EbmlString(ElementToClone) {}
static EbmlElement & Create() {return *(new EDocType);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EDocType(*this);}
};
class EBML_DLL_API EDocTypeVersion : public EbmlUInteger {
public:
EDocTypeVersion() {}
EDocTypeVersion(const EDocTypeVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EDocTypeVersion);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EDocTypeVersion(*this);}
};
class EBML_DLL_API EDocTypeReadVersion : public EbmlUInteger {
public:
EDocTypeReadVersion() {}
EDocTypeReadVersion(const EDocTypeReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {}
static EbmlElement & Create() {return *(new EDocTypeReadVersion);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
EbmlElement * Clone() const {return new EDocTypeReadVersion(*this);}
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_SUBHEAD_H

75
ebml/EbmlTypes.h Normal file
View File

@ -0,0 +1,75 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlTypes.h 639 2004-07-09 20:59:14Z mosu $
*/
#ifndef LIBEBML_TYPES_H
#define LIBEBML_TYPES_H
#include <clocale>
#include <string>
#include "ebml/c/libebml_t.h"
#include "ebml/EbmlConfig.h"
#include "EbmlEndian.h" // binary needs to be defined
START_LIBEBML_NAMESPACE
typedef wchar_t utf16;
typedef uint32 utf32;
typedef char utf8;
typedef binary bits80[10];
typedef Endian<int16,little_endian> lil_int16;
typedef Endian<int32,little_endian> lil_int32;
typedef Endian<int64,little_endian> lil_int64;
typedef Endian<uint16,little_endian> lil_uint16;
typedef Endian<uint32,little_endian> lil_uint32;
typedef Endian<uint64,little_endian> lil_uint64;
typedef Endian<int16,big_endian> big_int16;
typedef Endian<int32,big_endian> big_int32;
typedef Endian<int64,big_endian> big_int64;
typedef Endian<uint16,big_endian> big_uint16;
typedef Endian<uint32,big_endian> big_uint32;
typedef Endian<uint64,big_endian> big_uint64;
typedef Endian<uint32,big_endian> checksum;
typedef Endian<bits80,big_endian> big_80bits;
enum ScopeMode {
SCOPE_PARTIAL_DATA = 0,
SCOPE_ALL_DATA,
SCOPE_NO_DATA
};
END_LIBEBML_NAMESPACE
#endif

92
ebml/EbmlUInteger.h Normal file
View File

@ -0,0 +1,92 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlUInteger.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#ifndef LIBEBML_UINTEGER_H
#define LIBEBML_UINTEGER_H
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
const int DEFAULT_UINT_SIZE = 0; ///< optimal size stored
/*!
\class EbmlUInteger
\brief Handle all operations on an unsigned integer EBML element
*/
class EBML_DLL_API EbmlUInteger : public EbmlElement {
public:
EbmlUInteger();
EbmlUInteger(const uint64 DefaultValue);
EbmlUInteger(const EbmlUInteger & ElementToClone);
EbmlUInteger & operator=(const uint64 NewValue) {Value = NewValue; bValueIsSet = true; return *this;}
/*!
Set the default size of the integer (usually 1,2,4 or 8)
*/
void SetDefaultSize(const int nDefaultSize = DEFAULT_UINT_SIZE) {Size = nDefaultSize;}
bool ValidateSize() const {return (Size <= 8);}
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
bool operator<(const EbmlUInteger & EltCmp) const {return Value < EltCmp.Value;}
operator uint8() const {return uint8(Value); }
operator uint16() const {return uint16(Value);}
operator uint32() const {return uint32(Value);}
operator uint64() const {return Value;}
void SetDefaultValue(uint64 aValue) {assert(!DefaultIsSet); DefaultValue = aValue; DefaultIsSet = true;}
const uint64 DefaultVal() const {assert(DefaultIsSet); return DefaultValue;}
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);
}
protected:
uint64 Value; /// The actual value of the element
uint64 DefaultValue;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_UINTEGER_H

126
ebml/EbmlUnicodeString.h Normal file
View File

@ -0,0 +1,126 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlUnicodeString.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
\author Jory Stone <jcsston @ toughguy.net>
*/
#ifndef LIBEBML_UNICODE_STRING_H
#define LIBEBML_UNICODE_STRING_H
#include <string>
#include "EbmlTypes.h"
#include "EbmlElement.h"
START_LIBEBML_NAMESPACE
/*!
\class UTFstring
A class storing strings in a wchar_t (ie, in UCS-2 or UCS-4)
\note inspired by wstring which is not available everywhere
*/
class EBML_DLL_API UTFstring {
public:
typedef wchar_t value_type;
UTFstring();
UTFstring(const wchar_t *); // should be NULL terminated
UTFstring(const UTFstring &);
virtual ~UTFstring();
bool operator==(const UTFstring&) const;
inline bool operator!=(const UTFstring &cmp) const
{
return !(*this == cmp);
}
UTFstring & operator=(const UTFstring &);
UTFstring & operator=(const wchar_t *);
UTFstring & operator=(wchar_t);
/// Return length of string
size_t length() const {return _Length;}
operator const wchar_t*() const {return _Data;}
const wchar_t* c_str() const {return _Data;}
const std::string & GetUTF8() const {return UTF8string;}
void SetUTF8(const std::string &);
protected:
size_t _Length; ///< length of the UCS string excluding the \0
wchar_t* _Data; ///< internal UCS representation
std::string UTF8string;
static bool wcscmp_internal(const wchar_t *str1, const wchar_t *str2);
void UpdateFromUTF8();
void UpdateFromUCS2();
};
/*!
\class EbmlUnicodeString
\brief Handle all operations on a Unicode string EBML element
\note internally treated as a string made of wide characters (ie UCS-2 or UCS-4 depending on the machine)
*/
class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
public:
EbmlUnicodeString();
EbmlUnicodeString(const UTFstring & DefaultValue);
EbmlUnicodeString(const EbmlUnicodeString & ElementToClone);
virtual ~EbmlUnicodeString() {}
bool ValidateSize() const {return true;} // any size is possible
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false);
EbmlUnicodeString & operator=(const UTFstring &); ///< platform dependant code
operator const UTFstring &() const {return Value;}
void SetDefaultValue(UTFstring & aValue) {assert(!DefaultIsSet); DefaultValue = aValue; DefaultIsSet = true;}
UTFstring DefaultVal() const {assert(DefaultIsSet); return DefaultValue;}
bool IsDefaultValue() const {
return (DefaultISset() && Value == DefaultValue);
}
protected:
UTFstring Value; /// The actual value of the element
UTFstring DefaultValue;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_UNICODE_STRING_H

56
ebml/EbmlVersion.h Normal file
View File

@ -0,0 +1,56 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlVersion.h 1326 2009-08-23 00:47:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_VERSION_H
#define LIBEBML_VERSION_H
#include <string>
#include "EbmlConfig.h"
START_LIBEBML_NAMESPACE
#define LIBEBML_VERSION 0x000709
static const std::string EbmlCodeVersion = "0.7.9";
static const std::string EbmlCodeDate = __TIMESTAMP__;
/*!
\todo Closer relation between an element and the context it comes from (context is an element attribute ?)
*/
END_LIBEBML_NAMESPACE
#endif // LIBEBML_VERSION_H

81
ebml/EbmlVoid.h Normal file
View File

@ -0,0 +1,81 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlVoid.h 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_VOID_H
#define LIBEBML_VOID_H
#include "EbmlTypes.h"
#include "EbmlBinary.h"
START_LIBEBML_NAMESPACE
class EBML_DLL_API EbmlVoid : public EbmlBinary {
public:
EbmlVoid();
EbmlVoid(const EbmlVoid & ElementToClone) :EbmlBinary(ElementToClone){}
static EbmlElement & Create() {return *(new EbmlVoid);}
const EbmlCallbacks & Generic() const {return ClassInfos;}
bool ValidateSize() const {return true;} // any void element is accepted
static const EbmlCallbacks ClassInfos;
operator const EbmlId &() const {return ClassInfos.GlobalId;}
bool IsYourId(const EbmlId & TestId) const;
/*!
\brief Set the size of the data (not the complete size of the element)
*/
void SetSize(uint64 aSize) {Size = aSize;}
/*!
\note overwrite to write fake data
*/
uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
/*!
\brief Replace the void element content (written) with this one
*/
uint64 ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
/*!
\brief Void the content of an element
*/
uint64 Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward = true, bool bKeepIntact = false);
EbmlElement * Clone() const {return new EbmlVoid(*this);}
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_VOID_H

116
ebml/IOCallback.h Normal file
View File

@ -0,0 +1,116 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Ingo Ralf Blum. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: IOCallback.h 639 2004-07-09 20:59:14Z mosu $
*/
#ifndef MATROSKA_IOCALLBACK_H
#define MATROSKA_IOCALLBACK_H
#include "EbmlTypes.h"
#include <exception>
#include <cstdio>
// #include <iostream>
START_LIBEBML_NAMESPACE
enum seek_mode
{
seek_beginning=SEEK_SET
,seek_end=SEEK_END
,seek_current=SEEK_CUR
};
class EBML_DLL_API IOCallback
{
public:
virtual ~IOCallback(){}
// The read callback works like most other read functions. You specify the
// file, the buffer and the size and the function returns the bytes read.
// If an error occurs or the file pointer points to the end of the file 0 is returned.
// Users are encouraged to throw a descriptive exception, when an error occurs.
virtual uint32 read(void*Buffer,size_t Size)=0;
// Seek to the specified position. The mode can have either SEEK_SET, SEEK_CUR
// or SEEK_END. The callback should return true(1) if the seek operation succeeded
// or false (0), when the seek fails.
virtual void setFilePointer(int64 Offset,seek_mode Mode=seek_beginning)=0;
// This callback just works like its read pendant. It returns the number of bytes written.
virtual size_t write(const void*Buffer,size_t Size)=0;
// Although the position is always positive, the return value of this callback is signed to
// easily allow negative values for returning errors. When an error occurs, the implementor
// should return -1 and the file pointer otherwise.
//
// If an error occurs, an exception should be thrown.
virtual uint64 getFilePointer()=0;
// The close callback flushes the file buffers to disk and closes the file. When using the stdio
// library, this is equivalent to calling fclose. When the close is not successful, an exception
// should be thrown.
virtual void close()=0;
// The readFully is made virtual to allow derived classes to use another
// implementation for this method, which e.g. does not read any data
// unlike this does
void readFully(void*Buffer,size_t Size);
template<class STRUCT> void readStruct(STRUCT&Struct){readFully(&Struct,sizeof(Struct));}
void writeFully(const void*Buffer,size_t Size);
template<class STRUCT> void writeStruct(const STRUCT&Struct){writeFully(&Struct,sizeof(Struct));}
};
/* cygwin incompatible
template<class TRAITS> std::basic_ostream<char,TRAITS>&operator<<(std::basic_ostream<char,TRAITS>&Stream,seek_mode Mode)
{
switch(Mode)
{
#define x(y) case seek_##y: Stream<<"seek_" #y; break
x(beginning);
x(current);
x(end);
#undef x
default:
assert(false);
}
return Stream;
}
*/
END_LIBEBML_NAMESPACE
#endif // MATROSKA_IOCALLBACK_H

118
ebml/MemIOCallback.h Normal file
View File

@ -0,0 +1,118 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2003-2004 Jory Stone. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: MemIOCallback.h 1298 2008-02-21 22:14:18Z mosu $
\author Jory Stone <jcsston @ toughguy.net>
*/
#ifndef LIBEBML_MEMIOCALLBACK_H
#define LIBEBML_MEMIOCALLBACK_H
#include "IOCallback.h"
#include <string>
#ifndef __BEOS__
#include <sstream>
#else
#include <strstream>
#define stringstream strstream
#endif
START_LIBEBML_NAMESPACE
class EBML_DLL_API MemIOCallback : public IOCallback
{
public:
MemIOCallback(uint64 DefaultSize = 128);
~MemIOCallback();
/*!
Use this to copy some data to the Buffer from this classes data
*/
uint32 read(void *Buffer, size_t Size);
/*!
Seek to the specified position. The mode can have either SEEK_SET, SEEK_CUR
or SEEK_END. The callback should return true(1) if the seek operation succeeded
or false (0), when the seek fails.
*/
void setFilePointer(int64 Offset, seek_mode Mode=seek_beginning);
/*!
This callback just works like its read pendant. It returns the number of bytes written.
*/
size_t write(const void *Buffer, size_t Size);
/*!
Although the position is always positive, the return value of this callback is signed to
easily allow negative values for returning errors. When an error occurs, the implementor
should return -1 and the file pointer otherwise.
If an error occurs, an exception should be thrown.
*/
virtual uint64 getFilePointer() {return dataBufferPos;};
/*!
The close callback flushes the file buffers to disk and closes the file. When using the stdio
library, this is equivalent to calling fclose. When the close is not successful, an exception
should be thrown.
*/
void close() {};
binary *GetDataBuffer() const {return dataBuffer;};
uint64 GetDataBufferSize() {return dataBufferTotalSize;};
void SetDataBufferSize(uint64 newDataBufferSize) {dataBufferTotalSize = newDataBufferSize;};
/*!
Use this to write some data from another IOCallback
*/
uint32 write(IOCallback & IOToRead, size_t Size);
bool IsOk() { return mOk; };
const std::string &GetLastErrorStr() { return mLastErrorStr; };
protected:
bool mOk;
std::string mLastErrorStr;
binary *dataBuffer;
/*!
Postion where we start 'writing' to the dataBuffer
*/
uint64 dataBufferPos;
/*!
Size of the data in the dataBuffer
*/
uint64 dataBufferTotalSize;
/*!
Size of the memory malloc()/realloc()
*/
uint64 dataBufferMemorySize;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_MEMIOCALLBACK_H

101
ebml/StdIOCallback.h Normal file
View File

@ -0,0 +1,101 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Ingo Ralf Blum. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: StdIOCallback.h 1090 2005-03-16 12:47:59Z robux4 $
*/
#ifndef LIBEBML_STDIOCALLBACK_H
#define LIBEBML_STDIOCALLBACK_H
#include "IOCallback.h"
#include <stdexcept>
#include <cerrno>
// ----- Added 10/15/2003 by jcsston from Zen -----
#if defined (__BORLANDC__) //Maybe other compilers?
#include <errno.h>
#include <stdio.h>
#endif //__BORLANDC__
// ------------------------------------------------
START_LIBEBML_NAMESPACE
class EBML_DLL_API CRTError:public std::runtime_error
{
// Variablen...
private:
int Error;
// Methoden...
public:
CRTError(int Error,const std::string&Description);
CRTError(const std::string&Description,int Error=errno);
int getError()const throw(){return Error;}
};
// This class is currently private to the library, so there's no MATROSKA_EXPORT.
class EBML_DLL_API StdIOCallback:public IOCallback
{
private:
FILE*File;
uint64 mCurrentPosition;
public:
// StdIOCallback(const char*Path,const char*Mode);
StdIOCallback(const char*Path, const open_mode Mode);
virtual ~StdIOCallback()throw();
virtual uint32 read(void*Buffer,size_t Size);
// Seek to the specified position. The mode can have either SEEK_SET, SEEK_CUR
// or SEEK_END. The callback should return true(1) if the seek operation succeeded
// or false (0), when the seek fails.
virtual void setFilePointer(int64 Offset,seek_mode Mode=seek_beginning);
// This callback just works like its read pendant. It returns the number of bytes written.
virtual size_t write(const void*Buffer,size_t Size);
// Although the position is always positive, the return value of this callback is signed to
// easily allow negative values for returning errors. When an error occurs, the implementor
// should return -1 and the file pointer otherwise.
//
// If an error occurs, an exception should be thrown.
virtual uint64 getFilePointer();
// The close callback flushes the file buffers to disk and closes the file. When using the stdio
// library, this is equivalent to calling fclose. When the close is not successful, an exception
// should be thrown.
virtual void close();
};
END_LIBEBML_NAMESPACE
#endif

132
ebml/c/libebml_t.h Normal file
View File

@ -0,0 +1,132 @@
/****************************************************************************
** LIBEBML : parse EBML files, see http://ebml.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2003 Steve Lhomme. All rights reserved.
**
** This file is part of LIBEBML.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file libebml_t.h
\version \$Id: libebml_t.h 1298 2008-02-21 22:14:18Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Ingo Ralf Blum <ingoralfblum @ users.sf.net>
\author Moritz Bunkus <moritz@bunkus.org>
\brief Misc type definitions for the C API of LIBEBML
\note These types should be compiler/language independant (just platform dependant)
\todo recover the sized types (uint16, int32, etc) here too (or maybe here only)
*/
#ifndef _LIBEBML_T_H_INCLUDED_
#define _LIBEBML_T_H_INCLUDED_
#ifdef __cplusplus
extern "C" {
#endif
// Changed char is unsigned now (signedness was causing trouble in endil)
#if defined(_WIN32)
# if !defined(__GNUC__) // Microsoft Visual C++
typedef signed __int64 int64;
typedef signed __int32 int32;
typedef signed __int16 int16;
typedef signed __int8 int8;
typedef __int8 character;
typedef unsigned __int64 uint64;
typedef unsigned __int32 uint32;
typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
# else // __GNUC__, this is mingw
# include <stdint.h>
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef int8_t character;
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
# endif // __GNUC__
#elif defined(__BEOS__)
#include <SupportDefs.h>
#elif defined(DJGPP) /* SL : DJGPP doesn't support POSIX types ???? */
typedef signed long long int64;
typedef signed long int32;
typedef signed short int16;
typedef signed char int8;
typedef char character;
typedef unsigned long long uint64;
typedef unsigned long uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
#elif defined(__sun) && (defined(__svr4__) || defined(__SVR4)) // SOLARIS
# include <inttypes.h>
# ifdef _NO_LONGLONG
# error This compiler does not support 64bit integers.
# endif
typedef long long int64; // int64_t is not always defined :(
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef int8_t character;
typedef unsigned long long uint64; // uint64_t is not always defined :(
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
#elif defined(__BEOS__)
# include <support/SupportDefs.h>
#else // anything else (Linux, BSD, ...)
# include <sys/types.h>
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef int8_t character;
typedef u_int64_t uint64;
typedef u_int32_t uint32;
typedef u_int16_t uint16;
typedef u_int8_t uint8;
#endif /* anything else */
typedef uint8 binary;
typedef enum open_mode {
MODE_READ,
MODE_WRITE,
MODE_CREATE,
MODE_SAFE
} open_mode;
#define EBML_MIN(x,y) ((x)<(y) ? (x) : (y))
#ifdef __cplusplus
}
#endif
#endif /* _LIBEBML_T_H_INCLUDED_ */

64
libebml.proj Normal file
View File

@ -0,0 +1,64 @@
Include "*/*.proj"
LIB ebml
{
PROJECT_VERSION 0.7.9
INCLUDE .
// OPTIMIZE_GLOBALLY .
FAVOR_MAX_SPEED .
REDUCE_SIZE .
FASTER_FLOAT .
// SOURCE src/Debug.cpp
SOURCE src/EbmlBinary.cpp
SOURCE src/EbmlContexts.cpp
SOURCE src/EbmlCrc32.cpp
SOURCE src/EbmlDate.cpp
SOURCE src/EbmlDummy.cpp
SOURCE src/EbmlElement.cpp
SOURCE src/EbmlFloat.cpp
SOURCE src/EbmlHead.cpp
SOURCE src/EbmlMaster.cpp
SOURCE src/EbmlSInteger.cpp
SOURCE src/EbmlStream.cpp
SOURCE src/EbmlString.cpp
SOURCE src/EbmlSubHead.cpp
SOURCE src/EbmlUInteger.cpp
SOURCE src/EbmlUnicodeString.cpp
SOURCE src/EbmlVersion.cpp
SOURCE src/EbmlVoid.cpp
SOURCE src/IOCallback.cpp
SOURCE src/MemIOCallback.cpp
SOURCE src/StdIOCallback.cpp
SOURCE(TARGET_WIN) src/platform/win32/WinIOCallback.cpp
HEADER(TARGET_WIN) src/platform/win32/WinIOCallback.h
// HEADER ebml/Debug.h
HEADER ebml/EbmlBinary.h
HEADER ebml/EbmlConfig.h
HEADER ebml/EbmlContexts.h
HEADER ebml/EbmlCrc32.h
HEADER ebml/EbmlDate.h
HEADER ebml/EbmlDummy.h
HEADER ebml/EbmlElement.h
HEADER ebml/EbmlEndian.h
HEADER ebml/EbmlFloat.h
HEADER ebml/EbmlHead.h
HEADER ebml/EbmlId.h
HEADER ebml/EbmlMaster.h
HEADER ebml/EbmlSInteger.h
HEADER ebml/EbmlStream.h
HEADER ebml/EbmlString.h
HEADER ebml/EbmlSubHead.h
HEADER ebml/EbmlTypes.h
HEADER ebml/EbmlUInteger.h
HEADER ebml/EbmlUnicodeString.h
HEADER ebml/EbmlVersion.h
HEADER ebml/EbmlVoid.h
HEADER ebml/IOCallback.h
HEADER ebml/MemIOCallback.h
HEADER ebml/StdIOCallback.h
HEADER ebml/c/libebml_t.h
}

152
make/linux/Makefile Normal file
View File

@ -0,0 +1,152 @@
# libebml Makefile
# $Id: Makefile,v 1.8 2004/05/11 20:27:38 mosu Exp $
# Author: Steve Lhomme <robux4 @ users.sf.net>
# Author: Moritz Bunkus <moritz @ bunkus.org>
#
# The library is built without debug information. If you want
# debug information to be included then compile with
# 'make DEBUG=yes'.
#
# Paths
# BeOS wants the libs and headers in /boot/home/config
ifeq (BeOS,$(shell uname -s))
prefix=/boot/home/config
else
prefix=/usr/local
endif
libdir=$(prefix)/lib
includedir=$(prefix)/include/ebml
# Programs
CXX=g++
LD=$(CXX)
AR = ar rcvu
RANLIB = ranlib
INSTALL = install
INSTALL_OPTS = -m 644
INSTALL_OPTS_LIB = -m 644
INSTALL_DIR_OPTS = -m 755
# Options
EXTENSION=.cpp
ifeq (yes,$(DEBUG))
DEBUGFLAGS=-g -DDEBUG
endif
ifneq (,$(shell $(CXX) -v 2>&1 | tail -n 1 | grep -i mingw))
$(error Please use the Makefile in ../mingw32)
endif
CWD=$(shell pwd)
SRC_DIR=$(CWD)/../../src/
INCLUDE_DIR=$(CWD)/../../ebml
# Librarires
INCLUDE=-I$(CWD)/../..
LIBS=
# Names
LIBRARY=libebml.a
LIBRARY_SO=libebml.so
LIBRARY_SO_VER=libebml.so.0
# source-files
sources:=$(wildcard ${SRC_DIR}*$(EXTENSION))
# header files; replace .cxx extension with .h
headers:=$(patsubst %$(EXTENSION),%.h,$(sources))
# object files; replace .cxx extension with .o
objects:=$(patsubst %$(EXTENSION),%.o,$(sources))
objects_so:=$(patsubst %$(EXTENSION),%.lo,$(sources))
WARNINGFLAGS=-Wall -Wno-unknown-pragmas -ansi -fno-gnu-keywords -Wshadow
COMPILEFLAGS=$(WARNINGFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) $(INCLUDE)
DEPENDFLAGS = $(CXXFLAGS) $(INCLUDE)
ifeq (Darwin,$(shell uname -s))
all: staticlib
else
all: staticlib sharedlib
endif
staticlib: $(LIBRARY)
sharedlib: $(LIBRARY_SO)
lib:
@echo "Use the 'staticlib', 'sharedlib' or 'all' targets."
@false
# Build rules
%.o: %$(EXTENSION)
$(CXX) -c $(COMPILEFLAGS) -o $@ $<
%.lo: %$(EXTENSION)
$(CXX) -c $(COMPILEFLAGS) -fPIC -o $@ $<
$(LIBRARY): $(objects)
$(AR) $@ $(objects)
$(RANLIB) $@
$(LIBRARY_SO): $(objects_so)
$(CXX) -shared -Wl,-soname,$(LIBRARY_SO_VER) -o $(LIBRARY_SO_VER) $(objects_so)
rm -f $(LIBRARY_SO)
ln -s $(LIBRARY_SO_VER) $(LIBRARY_SO)
clean:
rm -f $(objects) $(objects_so)
rm -f $(LIBRARY)
rm -f $(LIBRARY_SO)
rm -f $(LIBRARY_SO_VER)
rm -f CORE
distclean dist-clean: clean
rm -f .depend
depend:
@echo Calculating dependecies:
@rm -f .depend
@touch .depend
@for i in $(sources); do \
o="`echo $$i | sed -e 's/\.c$$/.o/' -e 's/\.cpp$$/.o/'`" ; \
echo ' ' $$i: $$o ; \
$(CXX) $(DEPENDFLAGS) -MM -MT $$o $$i >> .depend ; \
done
ifeq (Darwin,$(shell uname -s))
install: install_staticlib install_headers
else
install: install_staticlib install_sharedlib install_headers
endif
install_headers:
$(INSTALL) $(INSTALL_DIR_OPTS) -d $(includedir)
for i in $(INCLUDE_DIR)/*.h; do \
$(INSTALL) $(INSTALL_OPTS) $$i $(includedir) ; \
done
$(INSTALL) $(INSTALL_DIR_OPTS) -d $(includedir)/c
for i in $(INCLUDE_DIR)/c/*.h; do \
$(INSTALL) $(INSTALL_OPTS) $$i $(includedir)/c ; \
done
install_staticlib: $(LIBRARY)
$(INSTALL) $(INSTALL_DIR_OPTS) -d $(libdir)
$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY) $(libdir)
install_sharedlib: $(LIBRARY_SO)
$(INSTALL) $(INSTALL_DIR_OPTS) -d $(libdir)
$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY_SO_VER) $(libdir)
ln -fs $(LIBRARY_SO_VER) $(libdir)/$(LIBRARY_SO)
ifneq ($(wildcard .depend),)
include .depend
endif
# DO NOT DELETE

View File

@ -0,0 +1,67 @@
# SPEC file for libebml on (at least) Fedora Core 1, 2, 3
Name: libebml
Version: 0.7.5
Release: 1
License: LGPL
Summary: Extensible Binary Meta Language
Group: System Environment/Libraries
URL: http://ebml.sourceforge.net/
Vendor: Moritz Bunkus <moritz@bunkus.org>
Source: http://dl.matroska.org/downloads/%{name}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-root
%description
EBML was designed to be a simplified binary extension of XML for
the purpose of storing and manipulating data in a hierarchical
form with variable field lengths.
It uses the same paradigms as XML files, ie syntax and semantic
are separated. So a generic EBML library could read any format
based on it. The interpretation of data is up to a specific
application that knows how each elements (equivalent of XML tag)
has to be handled.
%package devel
Summary: Extensible Binary Meta Language headers/development files
Group: Development/Libraries
%description devel
EBML was designed to be a simplified binary extension of XML for
the purpose of storing and manipulating data in a hierarchical
form with variable field lengths.
It uses the same paradigms as XML files, ie syntax and semantic
are separated. So a generic EBML library could read any format
based on it. The interpretation of data is up to a specific
application that knows how each elements (equivalent of XML tag)
has to be handled.
%prep
%setup -q
%build
cd make/linux
CFLAGS="$RPM_OPT_FLAGS" \
make \
prefix="%{_prefix}" staticlib
cd ../..
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
cd make/linux
make prefix=$RPM_BUILD_ROOT/%{_prefix} install_staticlib install_headers
cd ../..
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%files devel
%defattr(-, root, root)
%{_includedir}/ebml/*.h
%{_includedir}/ebml/c/*.h
%{_libdir}/libebml.a
%changelog
* Sat Apr 16 2005 Moritz Bunkus <moritz@bunkus.org>
- updated for the new libebml build targets
* Fri May 15 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
- create spec file

View File

@ -0,0 +1,14 @@
--- libebml-0.7.1/make/linux/Makefile~ 2004-09-01 22:24:12.520218192 +0200
+++ libebml-0.7.1/make/linux/Makefile 2004-09-01 22:25:30.976291056 +0200
@@ -14,9 +14,9 @@
ifeq (BeOS,$(shell uname -s))
prefix=/boot/home/config
else
-prefix=/usr/local
+prefix=$(PREFIX)
endif
-libdir=$(prefix)/lib
+libdir=$(LIBDIR)
includedir=$(prefix)/include/ebml
# Programs

71
make/linux/suse.spec Normal file
View File

@ -0,0 +1,71 @@
#
# spec file for package libebml for (at least) SuSE Linux 9.0, 9.1
#
# Copyright (c) 2004 SUSE LINUX AG, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://www.suse.de/feedback/
#
# neededforbuild gcc-c++ libstdc++-devel
BuildRequires: bzip2 cpp libebml make patch tar zlib zlib-devel binutils gcc gcc-c++ libstdc++-devel perl rpm
Name: libebml
URL: http://sourceforge.net/projects/ebml
Version: 0.7.8
Release: 1
Summary: libary to parse EBML files.
License: LGPL
Group: Development/Libraries/Other
Source: %{name}-%{version}.tar.bz2
Patch: suse-libebml-makefile.diff
Summary: libary to parse EBML files.
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Prefix: /usr
%description
libebml is a C++ libary to parse EBML files. See the EBML RFV at
http://www.matroska.org/technical/specs/rfc/
Authors:
--------
Steve Lhomme <steve.lhomme@free.fr>
Moritz Bunkus <moritz@bunkus.org>
%prep
rm -rf $RPM_BUILD_ROOT
%setup
%patch -p1
%build
export CFLAGS="$RPM_OPT_FLAGS"
cd make/linux
make PREFIX=$RPM_BUILD_ROOT/usr LIBDIR=%{_libdir} staticlib
%install
cd make/linux
make install_staticlib install_headers PREFIX=$RPM_BUILD_ROOT/usr LIBDIR=$RPM_BUILD_ROOT/%{_libdir}
%clean
rm -rf $RPM_BUILD_ROOT
%post
%run_ldconfig
%postun
%run_ldconfig
%files
%defattr (-,root,root)
%{_libdir}/libebml.a
/usr/include/ebml
%changelog -n libebml
* Sat Apr 16 2005 - moritz@bunkus.org
- modified for the new libebml build targets
* Wed Sep 01 2004 - seife@suse.de
- initial submission

71
make/mingw32/Makefile Normal file
View File

@ -0,0 +1,71 @@
# Project: libebml
# Makefile created by Dev-C++ 4.9.7.0
# Normally libebml is built as a static library.
# Uncomment this if you want a shared library instead.
# ATTENTION: If your app uses this DLL you have to define EBML_DLL !
SHARED = yes
# Compile with debug information?
#DEBUG = yes
#
# Don't change anything below this line.
#
ifeq (yes,$(DEBUG))
DEBUGFLAGS=-g -DDEBUG
endif
CXX = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
SRC = $(wildcard ../../src/*.cpp)
OBJ = $(patsubst %.cpp,%.o,$(SRC))
ifeq (yes,$(SHARED))
LIBS = libebml.dll
CXXFLAGS = -DEBML_DLL -DEBML_DLL_EXPORT
else
LIBS = libebml.a
endif
INCS = -I../..
CXXFLAGS += $(DEBUGFLAGS) $(INCS)
.PHONY: all all-before all-after clean clean-custom
.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ $<
all: lib
lib: $(LIBS)
clean:
rm -f $(OBJ) libebml.a libebml.dll libebml.dll.a
distclean dist-clean: clean
rm -f .depend
libebml.a: $(OBJ)
ar r $@ $(OBJ)
ranlib $@
libebml.dll: $(OBJ)
$(CXX) -shared -Wl,--export-all -Wl,--out-implib=$@.a -o $@ $(OBJ)
depend:
@echo Calculating dependecies:
@rm -f .depend
@touch .depend
@for i in $(SRC); do \
o="`echo $$i | sed -e 's/\.c$$/.o/' -e 's/\.cpp$$/.o/'`" ; \
echo ' ' $$i: $$o ; \
$(CXX) $(CXXFLAGS) -MM -MT $$o $$i >> .depend ; \
done
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif

390
make/mingw32/libebml.dev Normal file
View File

@ -0,0 +1,390 @@
[Project]
FileName=libebml.dev
Name=libebml
UnitCount=43
Type=2
Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Resources=
Compiler=
Linker=
IsCpp=1
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
OverrideOutputName=
HostApplication=
Folders=
CommandLine=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=
[Unit1]
FileName=..\..\src\StdIOCallback.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit2]
FileName=..\..\src\Debug.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit3]
FileName=..\..\src\EbmlBinary.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit4]
FileName=..\..\src\EbmlBinary.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit5]
FileName=..\..\src\EbmlConfig.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit6]
FileName=..\..\src\EbmlContexts.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit7]
FileName=..\..\src\EbmlContexts.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit8]
FileName=..\..\src\EbmlCrc32.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit9]
FileName=..\..\src\EbmlCrc32.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit10]
FileName=..\..\src\EbmlDate.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit11]
FileName=..\..\src\EbmlDate.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit12]
FileName=..\..\src\EbmlElement.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit13]
FileName=..\..\src\EbmlElement.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit14]
FileName=..\..\src\EbmlEndian.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit15]
FileName=..\..\src\EbmlFloat.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit16]
FileName=..\..\src\EbmlFloat.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit17]
FileName=..\..\src\EbmlHead.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit18]
FileName=..\..\src\EbmlHead.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit19]
FileName=..\..\src\EbmlId.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit20]
FileName=..\..\src\EbmlMaster.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit21]
FileName=..\..\src\EbmlMaster.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit22]
FileName=..\..\src\EbmlSInteger.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit23]
FileName=..\..\src\EbmlSInteger.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit24]
FileName=..\..\src\EbmlStream.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit25]
FileName=..\..\src\EbmlStream.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit26]
FileName=..\..\src\EbmlString.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit27]
FileName=..\..\src\EbmlString.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit28]
FileName=..\..\src\EbmlSubHead.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit29]
FileName=..\..\src\EbmlSubHead.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit30]
FileName=..\..\src\EbmlTypes.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit31]
FileName=..\..\src\EbmlUInteger.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit32]
FileName=..\..\src\EbmlUInteger.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit33]
FileName=..\..\src\EbmlUnicodeString.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit34]
FileName=..\..\src\EbmlUnicodeString.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit35]
FileName=..\..\src\EbmlVersion.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit36]
FileName=..\..\src\EbmlVersion.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit37]
FileName=..\..\src\EbmlVoid.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit38]
FileName=..\..\src\EbmlVoid.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit39]
FileName=..\..\src\IOCallback.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit40]
FileName=..\..\src\IOCallback.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit41]
FileName=..\..\src\StdInclude.h
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit42]
FileName=..\..\src\StdIOCallback.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[Unit43]
FileName=..\..\src\Debug.cpp
Folder=libebml
Compile=1
CompileCpp=1
OverrideBuildCmd=0
BuildCmd=
[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=

View File

@ -0,0 +1,276 @@
# Microsoft Developer Studio Project File - Name="libebml" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=libebml - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "libebml.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "libebml.mak" CFG="libebml - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "libebml - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "libebml - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "libebml - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../.." /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "WRITE_EVEN_UNSET_DATA" /YX /FD /c
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "libebml - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "../../../.." /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "WRITE_EVEN_UNSET_DATA" /YX /FD /GZ /c
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "libebml - Win32 Release"
# Name "libebml - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\Debug.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlBinary.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlContexts.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlCrc32.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlDate.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlDummy.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlElement.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlFloat.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlHead.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlMaster.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlSInteger.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlStream.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlString.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlSubHead.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlUInteger.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlUnicodeString.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlVersion.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\EbmlVoid.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\IOCallback.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\MemIOCallback.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\StdIOCallback.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\ebml\Debug.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlBinary.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlConfig.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlContexts.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlCrc32.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlDate.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlDummy.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlElement.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlEndian.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlFloat.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlHead.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlId.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlMaster.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlSInteger.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlStream.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlString.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlSubHead.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlUInteger.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlUnicodeString.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlVersion.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\EbmlVoid.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\IOCallback.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\MemIOCallback.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\ebml\StdIOCallback.h
# End Source File
# End Group
# End Target
# End Project

29
make/vc6/libebml.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "libebml"=".\lib\static\libebml.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

57
make/vc7/Makefile Normal file
View File

@ -0,0 +1,57 @@
# Project: libebml
# Makefile to use the Free Visual C++ 2003 compiler from Microsoft with GNU Make
# Compile with debug information?
#DEBUG = yes
#
# Don't change anything below this line.
#
CXX = cl /Tp
CC = cl /Tc
SRC = $(wildcard ../../src/*.cpp)
OBJ = $(patsubst %.cpp,%.obj,$(SRC))
INCS = /I../..
LDFLAGS = /NOLOGO /DLL /MAP:libebml.map /VERSION:0.7
OPTMIZ = /G6 /O2 /Oi /Wp64 /GL
CXXFLAGS = $(INCS) /DWIN32 /nologo /DEBML_DLL /DEBML_DLL_EXPORT
ifeq (yes,$(DEBUG))
CXXFLAGS += /Zi /DDEBUG /D_DEBUG /MTd /RTC1
LDFLAGS += /DEBUG
else
CXXFLAGS += /MT
LDFLAGS += /OPT:REF
endif
LIBS = libebml.dll
.PHONY: all all-before all-after clean clean-custom
%.obj : %.cpp
$(CXX) $< /c $(CXXFLAGS) /Fo$@
all: lib
lib: $(LIBS)
clean:
$(RM) $(OBJ) libebml.lib libebml.dll
libebml.lib: $(OBJ)
lib /OUT:$@ /NODEFAULTLIB $(OBJ)
libebml.dll: $(OBJ)
link $(LDFLAGS) /OUT:$@ $(OBJ) user32.lib
depend:
$(CXX) $(CXXFLAGS) -MM $(SRC) > .depend
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif

View File

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="libebmldll"
ProjectGUID="{83136D19-2749-4640-AC38-33E0B1F0DCC2}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EBML_DLL;EBML_DLL_EXPORT"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libebml.dll"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/libebml.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/libebml.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EBML_DLL;EBML_DLL_EXPORT"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libebml.dll"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/libebml.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\..\..\src\Debug.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlBinary.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlContexts.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlCrc32.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDate.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDummy.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlElement.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlFloat.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlMaster.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlStream.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSubHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUnicodeString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVersion.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVoid.cpp">
</File>
<File
RelativePath="..\..\..\src\IOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\MemIOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\StdIOCallback.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\..\..\ebml\Debug.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlBinary.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlConfig.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlContexts.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlCrc32.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDate.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDummy.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlElement.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlEndian.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlFloat.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlId.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlMaster.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlStream.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSubHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlTypes.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUnicodeString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVersion.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVoid.h">
</File>
<File
RelativePath="..\..\..\ebml\IOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\MemIOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\StdIOCallback.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,276 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="libebml"
ProjectGUID="{168C0F0D-9975-4D24-885C-87A9B018617E}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WRITE_EVEN_UNSET_DATA"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/libebml.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\libebml.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WRITE_EVEN_UNSET_DATA"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/libebml.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\libebml.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\..\..\src\Debug.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlBinary.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlContexts.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlCrc32.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDate.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDummy.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlElement.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlFloat.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlMaster.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlStream.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSubHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUnicodeString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVersion.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVoid.cpp">
</File>
<File
RelativePath="..\..\..\src\IOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\MemIOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\StdIOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\platform\win32\WinIOCallback.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\..\..\ebml\Debug.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlBinary.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlConfig.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlContexts.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlCrc32.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDate.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDummy.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlElement.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlEndian.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlFloat.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlId.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlMaster.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlStream.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSubHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlTypes.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUnicodeString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVersion.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVoid.h">
</File>
<File
RelativePath="..\..\..\ebml\IOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\MemIOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\StdInclude.h">
</File>
<File
RelativePath="..\..\..\ebml\StdIOCallback.h">
</File>
<File
RelativePath="..\..\..\src\platform\win32\WinIOCallback.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

262
make/vc7/lib/libebml.vcproj Normal file
View File

@ -0,0 +1,262 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="libebml"
ProjectGUID="{168C0F0D-9975-4D24-885C-87A9B018617E}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WRITE_EVEN_UNSET_DATA"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/libebml.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\libebml.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WRITE_EVEN_UNSET_DATA"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/libebml.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\libebml.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\..\..\src\Debug.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlBinary.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlContexts.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlCrc32.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDate.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlDummy.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlElement.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlFloat.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlMaster.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlStream.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlSubHead.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUInteger.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlUnicodeString.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVersion.cpp">
</File>
<File
RelativePath="..\..\..\src\EbmlVoid.cpp">
</File>
<File
RelativePath="..\..\..\src\IOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\MemIOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\StdIOCallback.cpp">
</File>
<File
RelativePath="..\..\..\src\platform\win32\WinIOCallback.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\..\..\ebml\Debug.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlBinary.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlConfig.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlContexts.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlCrc32.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDate.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlDummy.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlElement.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlEndian.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlFloat.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlId.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlMaster.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlStream.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlSubHead.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlTypes.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUInteger.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlUnicodeString.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVersion.h">
</File>
<File
RelativePath="..\..\..\ebml\EbmlVoid.h">
</File>
<File
RelativePath="..\..\..\ebml\IOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\MemIOCallback.h">
</File>
<File
RelativePath="..\..\..\ebml\StdInclude.h">
</File>
<File
RelativePath="..\..\..\ebml\StdIOCallback.h">
</File>
<File
RelativePath="..\..\..\src\platform\win32\WinIOCallback.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

237
src/Debug.cpp Normal file
View File

@ -0,0 +1,237 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: Debug.cpp 1268 2007-01-19 10:15:08Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <stdio.h>
#ifdef WIN32
#include <windows.h> // For OutputDebugString
#else
#include <time.h>
#include <sys/time.h>
#endif // WIN32
#include "ebml/Debug.h"
START_LIBEBML_NAMESPACE
class ADbg globalDebug;
#if !defined(NDEBUG)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ADbg::ADbg(int level)
:my_level(level)
,my_time_included(false)
,my_use_file(false)
,my_debug_output(true)
,hFile(NULL)
{
prefix[0] = '\0';
OutPut(-1,"ADbg Creation at debug level = %d (0x%08X)",my_level,this);
}
ADbg::~ADbg()
{
unsetDebugFile();
OutPut(-1,"ADbg Deletion (0x%08X)",this);
}
inline int ADbg::_OutPut(const char * format,va_list params) const
{
int result;
char tst[1000];
char myformat[256];
#ifdef WIN32
if (my_time_included) {
SYSTEMTIME time;
GetSystemTime(&time);
if (prefix[0] == '\0')
wsprintfA(myformat,"%04d/%02d/%02d %02d:%02d:%02d.%03d UTC : %s\r\n",
time.wYear,
time.wMonth,
time.wDay,
time.wHour,
time.wMinute,
time.wSecond,
time.wMilliseconds,
format);
else
wsprintfA(myformat,"%04d/%02d/%02d %02d:%02d:%02d.%03d UTC : %s - %s\r\n",
time.wYear,
time.wMonth,
time.wDay,
time.wHour,
time.wMinute,
time.wSecond,
time.wMilliseconds,
prefix,
format);
} else {
if (prefix[0] == '\0')
wsprintfA( myformat, "%s\r\n", format);
else
wsprintfA( myformat, "%s - %s\r\n", prefix, format);
}
result = vsprintf(tst,myformat,params);
if (my_debug_output)
OutputDebugStringA(tst);
if (my_use_file && (hFile != NULL)) {
SetFilePointer( hFile, 0, 0, FILE_END );
DWORD written;
WriteFile( hFile, tst, lstrlenA(tst), &written, NULL );
}
#else
if (my_time_included) {
time_t nowSecs;
struct tm *now;
struct timeval tv;
nowSecs = time(NULL);
gettimeofday(&tv, NULL);
now = gmtime(&nowSecs);
if (prefix[0] == '\0')
sprintf(myformat,"%04d/%02d/%02d %02d:%02d:%02ld.%03ld UTC : %s\r\n",
now->tm_year, now->tm_mon, now->tm_mday,
now->tm_hour, now->tm_min, tv.tv_sec,
(long)tv.tv_usec / 1000, format);
else
sprintf(myformat,"%04d/%02d/%02d %02d:%02d:%02ld.%03ld UTC : %s - %s\r\n",
now->tm_year, now->tm_mon, now->tm_mday,
now->tm_hour, now->tm_min, tv.tv_sec,
(long)tv.tv_usec / 1000, prefix, format);
} else {
if (prefix[0] == '\0')
sprintf( myformat, "%s\r\n", format);
else
sprintf( myformat, "%s - %s\r\n", prefix, format);
}
result = vsprintf(tst,myformat,params);
if (my_debug_output)
fputs(tst, stderr);
if (my_use_file && (hFile != NULL))
fputs(tst, hFile);
#endif
return result;
}
int ADbg::OutPut(int forLevel, const char * format,...) const
{
int result=0;
if (forLevel >= my_level) {
va_list tstlist;
va_start(tstlist, format);
result = _OutPut(format,tstlist);
}
return result;
}
int ADbg::OutPut(const char * format,...) const
{
va_list tstlist;
va_start(tstlist, format);
return _OutPut(format,tstlist);
}
bool ADbg::setDebugFile(const char * NewFilename) {
bool result;
result = unsetDebugFile();
if (result) {
result = false;
#ifdef WIN32
hFile = CreateFileA(NewFilename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile != INVALID_HANDLE_VALUE) {
SetFilePointer( hFile, 0, 0, FILE_END );
result = true;
#else
hFile = fopen(NewFilename, "w+");
if (hFile != NULL) {
fseek(hFile, 0, SEEK_END);
#endif
OutPut(-1,"Debug hFile Opening succeeded");
}
else
OutPut(-1,"Debug hFile %s Opening failed",NewFilename);
}
return result;
}
bool ADbg::unsetDebugFile() {
bool result = (hFile == NULL);
#ifdef WIN32
if (hFile != NULL) {
result = (CloseHandle(hFile) != 0);
#else
if (hFile != NULL) {
result = (fclose(hFile) == 0);
#endif
if (result) {
OutPut(-1,"Debug hFile Closing succeeded");
hFile = NULL;
}
}
return result;
}
#endif // !defined(NDEBUG)
END_LIBEBML_NAMESPACE

101
src/EbmlBinary.cpp Normal file
View File

@ -0,0 +1,101 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlBinary.cpp 1112 2005-03-28 09:55:50Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlBinary.h"
START_LIBEBML_NAMESPACE
EbmlBinary::EbmlBinary()
:EbmlElement(0, false), Data(NULL)
{}
EbmlBinary::EbmlBinary(const EbmlBinary & ElementToClone)
:EbmlElement(ElementToClone)
{
if (ElementToClone.Data == NULL)
Data = NULL;
else {
Data = (binary *)malloc(Size * sizeof(binary));
assert(Data != NULL);
memcpy(Data, ElementToClone.Data, Size);
}
}
EbmlBinary::~EbmlBinary(void) {
if(Data)
free(Data);
}
uint32 EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
output.writeFully(Data,Size);
return Size;
}
/*!
\note no Default binary value handled
*/
uint64 EbmlBinary::UpdateSize(bool bKeepIntact, bool bForceRender)
{
return Size;
}
uint64 EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (Data != NULL)
free(Data);
if (ReadFully == SCOPE_NO_DATA)
{
Data = NULL;
return Size;
}
Data = (binary *)malloc(Size * sizeof(binary));
assert(Data != NULL);
bValueIsSet = true;
return input.read(Data, Size);
}
bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
{
return ((Size == ElementToCompare.Size) && !memcmp(Data, ElementToCompare.Data, Size));
}
END_LIBEBML_NAMESPACE

57
src/EbmlContexts.cpp Normal file
View File

@ -0,0 +1,57 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlContexts.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlContexts.h"
#include "ebml/EbmlCrc32.h"
#include "ebml/EbmlVoid.h"
START_LIBEBML_NAMESPACE
const EbmlSemantic EbmlGlobal_ContextList[2] =
{
EbmlSemantic(false, false, EbmlCrc32::ClassInfos), ///< EbmlCrc32
EbmlSemantic(false, false, EbmlVoid::ClassInfos), ///< EbmlVoid
};
const EbmlSemanticContext EbmlVoid_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, NULL);
static const EbmlSemanticContext EbmlGlobal_Context = EbmlSemanticContext(countof(EbmlGlobal_ContextList), EbmlGlobal_ContextList, NULL, *GetEbmlGlobal_Context, NULL);
const EbmlSemanticContext & GetEbmlGlobal_Context()
{
return EbmlGlobal_Context;
}
END_LIBEBML_NAMESPACE

339
src/EbmlCrc32.cpp Normal file
View File

@ -0,0 +1,339 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlCrc32.cpp 1155 2005-05-06 11:43:38Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
#include "ebml/EbmlCrc32.h"
#include "ebml/EbmlContexts.h"
#include "ebml/MemIOCallback.h"
START_LIBEBML_NAMESPACE
EbmlId EbmlCrc32_TheId(0xBF, 1);
const EbmlCallbacks EbmlCrc32::ClassInfos(EbmlCrc32::Create, EbmlCrc32_TheId, "EBMLCrc32\0ratamadabapa", EbmlVoid_Context);
const uint32 EbmlCrc32::m_tab[] = {
#ifdef WORDS_BIGENDIAN
0x00000000L, 0x96300777L, 0x2c610eeeL, 0xba510999L, 0x19c46d07L,
0x8ff46a70L, 0x35a563e9L, 0xa395649eL, 0x3288db0eL, 0xa4b8dc79L,
0x1ee9d5e0L, 0x88d9d297L, 0x2b4cb609L, 0xbd7cb17eL, 0x072db8e7L,
0x911dbf90L, 0x6410b71dL, 0xf220b06aL, 0x4871b9f3L, 0xde41be84L,
0x7dd4da1aL, 0xebe4dd6dL, 0x51b5d4f4L, 0xc785d383L, 0x56986c13L,
0xc0a86b64L, 0x7af962fdL, 0xecc9658aL, 0x4f5c0114L, 0xd96c0663L,
0x633d0ffaL, 0xf50d088dL, 0xc8206e3bL, 0x5e10694cL, 0xe44160d5L,
0x727167a2L, 0xd1e4033cL, 0x47d4044bL, 0xfd850dd2L, 0x6bb50aa5L,
0xfaa8b535L, 0x6c98b242L, 0xd6c9bbdbL, 0x40f9bcacL, 0xe36cd832L,
0x755cdf45L, 0xcf0dd6dcL, 0x593dd1abL, 0xac30d926L, 0x3a00de51L,
0x8051d7c8L, 0x1661d0bfL, 0xb5f4b421L, 0x23c4b356L, 0x9995bacfL,
0x0fa5bdb8L, 0x9eb80228L, 0x0888055fL, 0xb2d90cc6L, 0x24e90bb1L,
0x877c6f2fL, 0x114c6858L, 0xab1d61c1L, 0x3d2d66b6L, 0x9041dc76L,
0x0671db01L, 0xbc20d298L, 0x2a10d5efL, 0x8985b171L, 0x1fb5b606L,
0xa5e4bf9fL, 0x33d4b8e8L, 0xa2c90778L, 0x34f9000fL, 0x8ea80996L,
0x18980ee1L, 0xbb0d6a7fL, 0x2d3d6d08L, 0x976c6491L, 0x015c63e6L,
0xf4516b6bL, 0x62616c1cL, 0xd8306585L, 0x4e0062f2L, 0xed95066cL,
0x7ba5011bL, 0xc1f40882L, 0x57c40ff5L, 0xc6d9b065L, 0x50e9b712L,
0xeab8be8bL, 0x7c88b9fcL, 0xdf1ddd62L, 0x492dda15L, 0xf37cd38cL,
0x654cd4fbL, 0x5861b24dL, 0xce51b53aL, 0x7400bca3L, 0xe230bbd4L,
0x41a5df4aL, 0xd795d83dL, 0x6dc4d1a4L, 0xfbf4d6d3L, 0x6ae96943L,
0xfcd96e34L, 0x468867adL, 0xd0b860daL, 0x732d0444L, 0xe51d0333L,
0x5f4c0aaaL, 0xc97c0dddL, 0x3c710550L, 0xaa410227L, 0x10100bbeL,
0x86200cc9L, 0x25b56857L, 0xb3856f20L, 0x09d466b9L, 0x9fe461ceL,
0x0ef9de5eL, 0x98c9d929L, 0x2298d0b0L, 0xb4a8d7c7L, 0x173db359L,
0x810db42eL, 0x3b5cbdb7L, 0xad6cbac0L, 0x2083b8edL, 0xb6b3bf9aL,
0x0ce2b603L, 0x9ad2b174L, 0x3947d5eaL, 0xaf77d29dL, 0x1526db04L,
0x8316dc73L, 0x120b63e3L, 0x843b6494L, 0x3e6a6d0dL, 0xa85a6a7aL,
0x0bcf0ee4L, 0x9dff0993L, 0x27ae000aL, 0xb19e077dL, 0x44930ff0L,
0xd2a30887L, 0x68f2011eL, 0xfec20669L, 0x5d5762f7L, 0xcb676580L,
0x71366c19L, 0xe7066b6eL, 0x761bd4feL, 0xe02bd389L, 0x5a7ada10L,
0xcc4add67L, 0x6fdfb9f9L, 0xf9efbe8eL, 0x43beb717L, 0xd58eb060L,
0xe8a3d6d6L, 0x7e93d1a1L, 0xc4c2d838L, 0x52f2df4fL, 0xf167bbd1L,
0x6757bca6L, 0xdd06b53fL, 0x4b36b248L, 0xda2b0dd8L, 0x4c1b0aafL,
0xf64a0336L, 0x607a0441L, 0xc3ef60dfL, 0x55df67a8L, 0xef8e6e31L,
0x79be6946L, 0x8cb361cbL, 0x1a8366bcL, 0xa0d26f25L, 0x36e26852L,
0x95770cccL, 0x03470bbbL, 0xb9160222L, 0x2f260555L, 0xbe3bbac5L,
0x280bbdb2L, 0x925ab42bL, 0x046ab35cL, 0xa7ffd7c2L, 0x31cfd0b5L,
0x8b9ed92cL, 0x1daede5bL, 0xb0c2649bL, 0x26f263ecL, 0x9ca36a75L,
0x0a936d02L, 0xa906099cL, 0x3f360eebL, 0x85670772L, 0x13570005L,
0x824abf95L, 0x147ab8e2L, 0xae2bb17bL, 0x381bb60cL, 0x9b8ed292L,
0x0dbed5e5L, 0xb7efdc7cL, 0x21dfdb0bL, 0xd4d2d386L, 0x42e2d4f1L,
0xf8b3dd68L, 0x6e83da1fL, 0xcd16be81L, 0x5b26b9f6L, 0xe177b06fL,
0x7747b718L, 0xe65a0888L, 0x706a0fffL, 0xca3b0666L, 0x5c0b0111L,
0xff9e658fL, 0x69ae62f8L, 0xd3ff6b61L, 0x45cf6c16L, 0x78e20aa0L,
0xeed20dd7L, 0x5483044eL, 0xc2b30339L, 0x612667a7L, 0xf71660d0L,
0x4d476949L, 0xdb776e3eL, 0x4a6ad1aeL, 0xdc5ad6d9L, 0x660bdf40L,
0xf03bd837L, 0x53aebca9L, 0xc59ebbdeL, 0x7fcfb247L, 0xe9ffb530L,
0x1cf2bdbdL, 0x8ac2bacaL, 0x3093b353L, 0xa6a3b424L, 0x0536d0baL,
0x9306d7cdL, 0x2957de54L, 0xbf67d923L, 0x2e7a66b3L, 0xb84a61c4L,
0x021b685dL, 0x942b6f2aL, 0x37be0bb4L, 0xa18e0cc3L, 0x1bdf055aL,
0x8def022dL
#else
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
#endif
};
EbmlCrc32::EbmlCrc32()
{
ResetCRC();
DefaultSize = DIGESTSIZE;
m_crc_final = 0;
Size = 4;
//This EbmlElement has been set
// bValueIsSet = true;
}
EbmlCrc32::EbmlCrc32(const EbmlCrc32 & ElementToClone)
:EbmlBinary(ElementToClone)
{
m_crc = ElementToClone.m_crc;
m_crc_final = ElementToClone.m_crc_final;
}
EbmlElement * EbmlCrc32::Clone() const
{
return new EbmlCrc32(*this);
}
void EbmlCrc32::AddElementCRC32(EbmlElement &ElementToCRC)
{
// Use a special IOCallback class that Render's to memory instead of to disk
MemIOCallback memoryBuffer;
ElementToCRC.Render(memoryBuffer, true, true);
Update(memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
// Finalize();
};
bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC)
{
MemIOCallback memoryBuffer;
ElementToCRC.Render(memoryBuffer);
return CheckCRC(m_crc_final, memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
};
uint32 EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result = DIGESTSIZE;
if (Result != 0) {
output.writeFully(&m_crc_final, Result);
}
if (Result < DefaultSize) {
// pad the rest with 0
binary *Pad = new binary[DefaultSize - Result];
if (Pad != NULL) {
memset(Pad, 0x00, DefaultSize - Result);
output.writeFully(Pad, DefaultSize - Result);
Result = DefaultSize;
delete [] Pad;
}
}
return Result;
}
uint64 EbmlCrc32::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary *Buffer = new binary[Size];
if (Buffer == NULL) {
// impossible to read, skip it
input.setFilePointer(Size, seek_current);
} else {
input.readFully(Buffer, Size);
memcpy((void *)&m_crc_final, Buffer, 4);
delete [] Buffer;
bValueIsSet = true;
}
}
return Size;
}
bool EbmlCrc32::CheckCRC(uint32 inputCRC, const binary *input, uint32 length)
{
uint32 crc = CRC32_NEGL;
for(; !IsAligned<uint32>(input) && length > 0; length--)
crc = m_tab[CRC32_INDEX(crc) ^ *input++] ^ CRC32_SHIFTED(crc);
while (length >= 4)
{
crc ^= *(const uint32 *)input;
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
length -= 4;
input += 4;
}
while (length--)
crc = m_tab[CRC32_INDEX(crc) ^ *input++] ^ CRC32_SHIFTED(crc);
//Now we finalize the CRC32
crc ^= CRC32_NEGL;
if (crc == inputCRC)
return true;
return false;
};
void EbmlCrc32::FillCRC32(const binary *s, uint32 n)
{
ResetCRC();
Update(s, n);
Finalize();
/*uint32 crc = CRC32_NEGL;
for(; !IsAligned<uint32>(s) && n > 0; n--)
crc = m_tab[CRC32_INDEX(crc) ^ *s++] ^ CRC32_SHIFTED(crc);
while (n >= 4)
{
crc ^= *(const uint32 *)s;
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
n -= 4;
s += 4;
}
while (n--)
crc = m_tab[CRC32_INDEX(crc) ^ *s++] ^ CRC32_SHIFTED(crc);
m_crc = crc;
//Now we finalize the CRC32
m_crc ^= CRC32_NEGL;
//for (unsigned int i = 0; i < 4; i++)
// (&last_crc32)[i] = GetCrcByte(i);*/
}
void EbmlCrc32::Update(const binary *input, uint32 length)
{
uint32 crc = m_crc;
for(; !IsAligned<uint32>(input) && length > 0; length--)
crc = m_tab[CRC32_INDEX(crc) ^ *input++] ^ CRC32_SHIFTED(crc);
while (length >= 4)
{
crc ^= *(const uint32 *)input;
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = m_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
length -= 4;
input += 4;
}
while (length--)
crc = m_tab[CRC32_INDEX(crc) ^ *input++] ^ CRC32_SHIFTED(crc);
m_crc = crc;
}
void EbmlCrc32::Finalize()
{
//Finalize the CRC32
m_crc ^= CRC32_NEGL;
//Copy it over to completed CRC32 memeber
m_crc_final = m_crc;
//Reset the holding CRC member (m_crc)
ResetCRC();
//This EbmlElement has been set
bValueIsSet = true;
}
END_LIBEBML_NAMESPACE

80
src/EbmlDate.cpp Normal file
View File

@ -0,0 +1,80 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlDate.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlDate.h"
START_LIBEBML_NAMESPACE
const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
EbmlDate::EbmlDate(const EbmlDate & ElementToClone)
:EbmlElement(ElementToClone)
{
myDate = ElementToClone.myDate;
}
uint64 EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (Size != 0) {
assert(Size == 8);
binary Buffer[8];
input.readFully(Buffer, Size);
big_int64 b64;
b64.Eval(Buffer);
myDate = b64;
bValueIsSet = true;
}
}
return Size;
}
uint32 EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
if (Size != 0) {
assert(Size == 8);
big_int64 b64(myDate);
output.writeFully(&b64.endian(),Size);
}
return Size;
}
END_LIBEBML_NAMESPACE

45
src/EbmlDummy.cpp Normal file
View File

@ -0,0 +1,45 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlDummy.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlDummy.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlId EbmlDummy::DummyRawId(0xFF, 1);
const EbmlSemanticContext EbmlDummy_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, &EbmlDummy::ClassInfos);
const EbmlCallbacks EbmlDummy::ClassInfos(NULL, DummyRawId, "DummyElement", EbmlDummy_Context);
END_LIBEBML_NAMESPACE

674
src/EbmlElement.cpp Normal file
View File

@ -0,0 +1,674 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlElement.cpp 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlElement.h"
#include "ebml/EbmlMaster.h"
#include "ebml/EbmlStream.h"
#include "ebml/EbmlVoid.h"
#include "ebml/EbmlDummy.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
/*!
\todo handle more than CodedSize of 5
*/
int CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeFinite)
{
int CodedSize;
if (bSizeFinite) {
// prepare the head of the size (000...01xxxxxx)
// optimal size
if (Length < 127) // 2^7 - 1
CodedSize = 1;
else if (Length < 16383) // 2^14 - 1
CodedSize = 2;
else if (Length < 2097151L) // 2^21 - 1
CodedSize = 3;
else if (Length < 268435455L) // 2^28 - 1
CodedSize = 4;
else CodedSize = 5;
} else {
if (Length <= 127) // 2^7 - 1
CodedSize = 1;
else if (Length <= 16383) // 2^14 - 1
CodedSize = 2;
else if (Length <= 2097151L) // 2^21 - 1
CodedSize = 3;
else if (Length <= 268435455L) // 2^28 - 1
CodedSize = 4;
else CodedSize = 5;
}
if (SizeLength > 0 && CodedSize < SizeLength) {
// defined size
CodedSize = SizeLength;
}
return CodedSize;
}
/*!
\todo handle more than CodedSize of 5
*/
int CodedSizeLengthSigned(int64 Length, unsigned int SizeLength)
{
unsigned int CodedSize;
// prepare the head of the size (000...01xxxxxx)
// optimal size
if (Length > -64 && Length < 64) // 2^6
CodedSize = 1;
else if (Length > -8192 && Length < 8192) // 2^13
CodedSize = 2;
else if (Length > -1048576L && Length < 1048576L) // 2^20
CodedSize = 3;
else if (Length > -134217728L && Length < 134217728L) // 2^27
CodedSize = 4;
else CodedSize = 5;
if (SizeLength > 0 && CodedSize < SizeLength) {
// defined size
CodedSize = SizeLength;
}
return CodedSize;
}
int CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer)
{
int _SizeMask = 0xFF;
OutBuffer[0] = 1 << (8 - CodedSize);
for (int i=1; i<CodedSize; i++) {
OutBuffer[CodedSize-i] = Length & 0xFF;
Length >>= 8;
_SizeMask >>= 1;
}
// first one use a OR with the "EBML size head"
OutBuffer[0] |= Length & 0xFF & _SizeMask;
return CodedSize;
}
int CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer)
{
if (Length > -64 && Length < 64) // 2^6
Length += 63;
else if (Length > -8192 && Length < 8192) // 2^13
Length += 8191;
else if (Length > -1048576L && Length < 1048576L) // 2^20
Length += 1048575L;
else if (Length > -134217728L && Length < 134217728L) // 2^27
Length += 134217727L;
return CodedValueLength(Length, CodedSize, OutBuffer);
}
uint64 ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown)
{
binary SizeBitMask = 1 << 7;
uint64 Result = 0x7F;
unsigned int SizeIdx, PossibleSizeLength = 0;
binary PossibleSize[8];
SizeUnknown = 0x7F; // the last bit is discarded when computing the size
for (SizeIdx = 0; SizeIdx < BufferSize && SizeIdx < 8; SizeIdx++) {
if (InBuffer[0] & (SizeBitMask >> SizeIdx)) {
// ID found
PossibleSizeLength = SizeIdx + 1;
SizeBitMask >>= SizeIdx;
for (SizeIdx = 0; SizeIdx < PossibleSizeLength; SizeIdx++) {
PossibleSize[SizeIdx] = InBuffer[SizeIdx];
}
for (SizeIdx = 0; SizeIdx < PossibleSizeLength - 1; SizeIdx++) {
Result <<= 7;
Result |= 0xFF;
}
Result = 0;
Result |= PossibleSize[0] & ~SizeBitMask;
for (unsigned int i = 1; i<PossibleSizeLength; i++) {
Result <<= 8;
Result |= PossibleSize[i];
}
BufferSize = PossibleSizeLength;
return Result;
}
SizeUnknown <<= 7;
SizeUnknown |= 0xFF;
}
BufferSize = 0;
return 0;
}
int64 ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown)
{
int64 Result = ReadCodedSizeValue(InBuffer, BufferSize, SizeUnknown);
if (BufferSize != 0)
{
switch (BufferSize)
{
case 1:
Result -= 63;
break;
case 2:
Result -= 8191;
break;
case 3:
Result -= 1048575L;
break;
case 4:
Result -= 134217727L;
break;
}
}
return Result;
}
EbmlElement::EbmlElement(const uint64 aDefaultSize, bool bValueSet)
:DefaultSize(aDefaultSize)
,SizeLength(0) ///< write optimal size by default
,bSizeIsFinite(true)
,ElementPosition(0)
,SizePosition(0)
,bValueIsSet(bValueSet)
,DefaultIsSet(false)
,bLocked(false)
{
Size = DefaultSize;
}
EbmlElement::EbmlElement(const EbmlElement & ElementToClone)
:Size(ElementToClone.Size)
,DefaultSize(ElementToClone.DefaultSize)
,SizeLength(ElementToClone.SizeLength)
,bSizeIsFinite(ElementToClone.bSizeIsFinite)
,ElementPosition(ElementToClone.ElementPosition)
,SizePosition(ElementToClone.SizePosition)
,bValueIsSet(ElementToClone.bValueIsSet)
,DefaultIsSet(ElementToClone.DefaultIsSet)
,bLocked(ElementToClone.bLocked)
{
}
/*!
\todo this method is deprecated and should be called FindThisID
\todo replace the new RawElement with the appropriate class (when known)
*/
EbmlElement * EbmlElement::FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize)
{
binary PossibleId[4];
int PossibleID_Length = 0;
binary PossibleSize[8]; // we don't support size stored in more than 64 bits
uint32 PossibleSizeLength = 0;
uint64 SizeUnknown;
uint64 SizeFound;
bool bElementFound = false;
binary BitMask;
uint64 aElementPosition, aSizePosition;
while (!bElementFound) {
// read ID
aElementPosition = DataStream.getFilePointer();
uint32 ReadSize = 0;
BitMask = 1 << 7;
while (1) {
ReadSize += DataStream.read(&PossibleId[PossibleID_Length], 1);
if (ReadSize == uint32(PossibleID_Length)) {
return NULL; // no more data ?
}
if (++PossibleID_Length > 4) {
return NULL; // we don't support element IDs over class D
}
if (PossibleId[0] & BitMask) {
// this is the last octet of the ID
// check wether that's the one we're looking for
/* if (PossibleID == ClassInfos.GlobalId) {
break;
} else {
/// \todo This element should be skipped (use a context ?)
}*/
bElementFound = true; /// \todo not exactly the one we're looking for
break;
}
BitMask >>= 1;
}
// read the data size
aSizePosition = DataStream.getFilePointer();
uint32 _SizeLength;
do {
if (PossibleSizeLength >= 8)
// Size is larger than 8 bytes
return NULL;
ReadSize += DataStream.read(&PossibleSize[PossibleSizeLength++], 1);
_SizeLength = PossibleSizeLength;
SizeFound = ReadCodedSizeValue(&PossibleSize[0], _SizeLength, SizeUnknown);
} while (_SizeLength == 0);
}
EbmlElement *Result = NULL;
EbmlId PossibleID(PossibleId, PossibleID_Length);
if (PossibleID == ClassInfos.GlobalId) {
// the element is the one expected
Result = &ClassInfos.Create();
} else {
/// \todo find the element in the context
Result = new EbmlDummy(PossibleID);
}
Result->SetSizeLength(PossibleSizeLength);
Result->Size = SizeFound;
if (!Result->ValidateSize() || (SizeFound != SizeUnknown && MaxDataSize < Result->Size)) {
delete Result;
return NULL;
}
// check if the size is not all 1s
if (SizeFound == SizeUnknown) {
// Size of this element is unknown
// only possible for Master elements
if (!Result->SetSizeInfinite()) {
/// \todo the element is not allowed to be infinite
delete Result;
return NULL;
}
} else Result->SetSizeInfinite(false);
Result->ElementPosition = aElementPosition;
Result->SizePosition = aSizePosition;
return Result;
}
/*!
\todo replace the new RawElement with the appropriate class (when known)
\todo skip data for Dummy elements when they are not allowed
\todo better check of the size checking for upper elements (using a list of size for each level)
\param LowLevel Will be returned with the level of the element found compared to the context given
*/
EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel,
uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel)
{
int PossibleID_Length = 0;
binary PossibleIdNSize[16];
int PossibleSizeLength;
uint64 SizeUnknown;
int ReadIndex = 0; // trick for the algo, start index at 0
uint32 ReadSize = 0;
uint64 SizeFound;
int SizeIdx;
bool bFound;
int UpperLevel_original = UpperLevel;
do {
// read a potential ID
do {
assert(ReadIndex < 16);
// build the ID with the current Read Buffer
bFound = false;
binary IdBitMask = 1 << 7;
for (SizeIdx = 0; SizeIdx < ReadIndex && SizeIdx < 4; SizeIdx++) {
if (PossibleIdNSize[0] & (IdBitMask >> SizeIdx)) {
// ID found
PossibleID_Length = SizeIdx + 1;
IdBitMask >>= SizeIdx;
bFound = true;
break;
}
}
if (bFound) {
break;
}
if (ReadIndex >= 4) {
// ID not found
// shift left the read octets
memmove(&PossibleIdNSize[0],&PossibleIdNSize[1], --ReadIndex);
}
if (DataStream.read(&PossibleIdNSize[ReadIndex++], 1) == 0) {
return NULL; // no more data ?
}
ReadSize++;
} while (!bFound && MaxDataSize > ReadSize);
SizeIdx = ReadIndex;
ReadIndex -= PossibleID_Length;
// read the data size
uint32 _SizeLength;
PossibleSizeLength = ReadIndex;
while (1)
{
_SizeLength = PossibleSizeLength;
SizeFound = ReadCodedSizeValue(&PossibleIdNSize[PossibleID_Length], _SizeLength, SizeUnknown);
if (_SizeLength != 0) {
bFound = true;
break;
}
if (PossibleSizeLength >= 8) {
bFound = false;
break;
}
ReadSize += DataStream.read(&PossibleIdNSize[SizeIdx++], 1);
PossibleSizeLength++;
}
if (bFound) {
// find the element in the context and use the correct creator
EbmlId PossibleID(PossibleIdNSize, PossibleID_Length);
EbmlElement * Result = CreateElementUsingContext(PossibleID, Context, UpperLevel, false, AllowDummyElt, MaxLowerLevel);
///< \todo continue is misplaced
if (Result != NULL) {
if (AllowDummyElt || !Result->IsDummy()) {
Result->SetSizeLength(_SizeLength);
Result->Size = SizeFound;
// UpperLevel values
// -1 : global element
// 0 : child
// 1 : same level
// + : further parent
if (Result->ValidateSize() && (UpperLevel > 0 || MaxDataSize == 0 || MaxDataSize >= (PossibleID_Length + PossibleSizeLength + SizeFound))) {
if (SizeFound == SizeUnknown) {
Result->SetSizeInfinite();
}
Result->SizePosition = DataStream.getFilePointer() - SizeIdx + PossibleID.Length;
Result->ElementPosition = Result->SizePosition - PossibleID.Length;
// place the file at the beggining of the data
DataStream.setFilePointer(Result->SizePosition + _SizeLength);
return Result;
}
}
delete Result;
}
}
// recover all the data in the buffer minus one byte
ReadIndex = SizeIdx - 1;
memmove(&PossibleIdNSize[0], &PossibleIdNSize[1], ReadIndex);
UpperLevel = UpperLevel_original;
} while ( MaxDataSize > DataStream.getFilePointer() - SizeIdx + PossibleID_Length );
return NULL;
}
/*!
\todo what happens if we are in a upper element with a known size ?
*/
EbmlElement * EbmlElement::SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt, bool AllowDummyElt)
{
EbmlElement * Result = NULL;
if (bSizeIsFinite) {
assert(TestReadElt == NULL);
assert(ElementPosition < SizePosition);
DataStream.I_O().setFilePointer(SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size, seek_beginning);
// DataStream.I_O().setFilePointer(Size, seek_current);
} else {
/////////////////////////////////////////////////
// read elements until an upper element is found
/////////////////////////////////////////////////
bool bEndFound = false;
while (!bEndFound && Result == NULL) {
// read an element
/// \todo 0xFF... and true should be configurable
// EbmlElement * NewElt;
if (TestReadElt == NULL) {
int bUpperElement = 0; // trick to call FindNextID correctly
Result = DataStream.FindNextElement(Context, bUpperElement, 0xFFFFFFFFL, AllowDummyElt);
} else {
Result = TestReadElt;
}
if (Result != NULL) {
unsigned int EltIndex;
// data known in this Master's context
for (EltIndex = 0; EltIndex < Context.Size; EltIndex++) {
if (EbmlId(*Result) == Context.MyTable[EltIndex].GetCallbacks.GlobalId) {
// skip the data with its own context
Result = Result->SkipData(DataStream, Context.MyTable[EltIndex].GetCallbacks.Context, NULL);
break; // let's go to the next ID
}
}
if (EltIndex >= Context.Size) {
if (Context.UpTable != NULL) {
Result = SkipData(DataStream, *Context.UpTable, Result);
} else {
assert(Context.GetGlobalContext != NULL);
if (Context != Context.GetGlobalContext()) {
Result = SkipData(DataStream, Context.GetGlobalContext(), Result);
} else {
bEndFound = true;
}
}
}
} else {
bEndFound = true;
}
}
}
return Result;
}
EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context,
int & LowLevel, bool IsGlobalContext, bool bAllowDummy, unsigned int MaxLowerLevel)
{
unsigned int ContextIndex;
EbmlElement *Result = NULL;
// elements at the current level
for (ContextIndex = 0; ContextIndex < Context.Size; ContextIndex++) {
if (aID == Context.MyTable[ContextIndex].GetCallbacks.GlobalId) {
return &Context.MyTable[ContextIndex].GetCallbacks.Create();
}
}
// global elements
assert(Context.GetGlobalContext != NULL); // global should always exist, at least the EBML ones
const EbmlSemanticContext & tstContext = Context.GetGlobalContext();
if (tstContext != Context) {
LowLevel--;
MaxLowerLevel--;
// recursive is good, but be carefull...
Result = CreateElementUsingContext(aID, tstContext, LowLevel, true, bAllowDummy, MaxLowerLevel);
if (Result != NULL) {
return Result;
}
LowLevel++;
MaxLowerLevel++;
} else {
return NULL;
}
// parent elements
if (Context.MasterElt != NULL && aID == Context.MasterElt->GlobalId) {
LowLevel++; // already one level up (same as context)
return &Context.MasterElt->Create();
}
// check wether it's not part of an upper context
if (Context.UpTable != NULL) {
LowLevel++;
MaxLowerLevel++;
return CreateElementUsingContext(aID, *Context.UpTable, LowLevel, IsGlobalContext, bAllowDummy, MaxLowerLevel);
}
if (!IsGlobalContext && bAllowDummy) {
LowLevel = 0;
Result = new EbmlDummy(aID);
}
return Result;
}
/*!
\todo verify that the size written is the same as the data written
*/
uint32 EbmlElement::Render(IOCallback & output, bool bKeepIntact, bool bKeepPosition, bool bForceRender)
{
assert(bValueIsSet || (bKeepIntact && DefaultISset())); // an element is been rendered without a value set !!!
// it may be a mandatory element without a default value
try {
if (!bKeepIntact && IsDefaultValue()) {
return 0;
}
#if defined(_DEBUG) || defined(DEBUG)
uint64 SupposedSize = UpdateSize(bKeepIntact, bForceRender);
#endif // _DEBUG
uint32 result = RenderHead(output, bForceRender, bKeepIntact, bKeepPosition);
uint64 WrittenSize = RenderData(output, bForceRender, bKeepIntact);
#if defined(_DEBUG) || defined(DEBUG)
if (SupposedSize != (0-1)) assert(WrittenSize == SupposedSize);
#endif // DEBUG
result += WrittenSize;
return result;
} catch (std::exception & ex) {
// const char * What = ex.what();
assert(false); // we should never be here !
return 0;
}
}
/*!
\todo store the position of the Size writing for elements with unknown size
\todo handle exceptions on errors
\todo handle CodeSize bigger than 5 bytes
*/
uint32 EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact, bool bKeepPosition)
{
if (EbmlId(*this).Length <= 0 || EbmlId(*this).Length > 4)
return 0;
UpdateSize(bKeepIntact, bForceRender);
return MakeRenderHead(output, bKeepPosition);
}
uint32 EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
{
binary FinalHead[4+8]; // Class D + 64 bits coded size
unsigned int FinalHeadSize;
FinalHeadSize = EbmlId(*this).Length;
EbmlId(*this).Fill(FinalHead);
int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite);
CodedValueLength(Size, CodedSize, &FinalHead[FinalHeadSize]);
FinalHeadSize += CodedSize;
output.writeFully(FinalHead, FinalHeadSize);
if (!bKeepPosition) {
ElementPosition = output.getFilePointer() - FinalHeadSize;
SizePosition = ElementPosition + EbmlId(*this).Length;
}
return FinalHeadSize;
}
uint64 EbmlElement::ElementSize(bool bKeepIntact) const
{
if (!bKeepIntact && IsDefaultValue())
return 0; // won't be saved
return Size + EbmlId(*this).Length + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
}
bool EbmlElement::CompareElements(const EbmlElement *A, const EbmlElement *B)
{
if (EbmlId(*A) == EbmlId(*B))
return *A < *B;
else
return false;
}
void EbmlElement::Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully)
{
ReadData(inDataStream.I_O(), ReadFully);
}
bool EbmlElement::ForceSize(uint64 NewSize)
{
if (bSizeIsFinite) {
return false;
}
int OldSizeLen = CodedSizeLength(Size, SizeLength, bSizeIsFinite);
uint64 OldSize = Size;
Size = NewSize;
if (CodedSizeLength(Size, SizeLength, bSizeIsFinite) == OldSizeLen) {
bSizeIsFinite = true;
return true;
}
Size = OldSize;
return false;
}
uint32 EbmlElement::OverwriteHead(IOCallback & output, bool bKeepPosition)
{
if (ElementPosition == 0) {
return 0; // the element has not been written
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
uint32 Result = MakeRenderHead(output, bKeepPosition);
output.setFilePointer(CurrentPosition);
return Result;
}
uint32 EbmlElement::VoidMe(IOCallback & output, bool bKeepIntact)
{
if (ElementPosition == 0) {
return 0; // the element has not been written
}
EbmlVoid Dummy;
return Dummy.Overwrite(*this, output, bKeepIntact);
}
END_LIBEBML_NAMESPACE

128
src/EbmlFloat.cpp Normal file
View File

@ -0,0 +1,128 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlFloat.cpp 1243 2006-03-30 19:33:22Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlFloat.h"
START_LIBEBML_NAMESPACE
EbmlFloat::EbmlFloat(const EbmlFloat::Precision prec)
:EbmlElement(0, false)
{
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const double aDefaultValue, const EbmlFloat::Precision prec)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
DefaultIsSet = true;
SetPrecision(prec);
}
EbmlFloat::EbmlFloat(const EbmlFloat & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
\todo handle 10 bits precision
*/
uint32 EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
assert(Size == 4 || Size == 8);
if (Size == 4) {
float val = Value;
int Tmp;
memcpy(&Tmp, &val, 4);
big_int32 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), Size);
} else if (Size == 8) {
double val = Value;
int64 Tmp;
memcpy(&Tmp, &val, 8);
big_int64 TmpToWrite(Tmp);
output.writeFully(&TmpToWrite.endian(), Size);
}
return Size;
}
uint64 EbmlFloat::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
return Size;
}
/*!
\todo remove the hack for possible endianess pb (test on little & big endian)
*/
uint64 EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[20];
assert(Size <= 20);
input.readFully(Buffer, Size);
if (Size == 4) {
big_int32 TmpRead;
TmpRead.Eval(Buffer);
int32 tmpp = int32(TmpRead);
float val;
memcpy(&val, &tmpp, 4);
Value = val;
bValueIsSet = true;
} else if (Size == 8) {
big_int64 TmpRead;
TmpRead.Eval(Buffer);
int64 tmpp = int64(TmpRead);
double val;
memcpy(&val, &tmpp, 8);
Value = val;
bValueIsSet = true;
}
}
return Size;
}
END_LIBEBML_NAMESPACE

62
src/EbmlHead.cpp Normal file
View File

@ -0,0 +1,62 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlHead.cpp 1096 2005-03-17 09:14:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlHead.h"
#include "ebml/EbmlSubHead.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
const EbmlSemantic EbmlHead_ContextList[] =
{
EbmlSemantic(true, true, EVersion::ClassInfos), ///< EBMLVersion
EbmlSemantic(true, true, EReadVersion::ClassInfos), ///< EBMLReadVersion
EbmlSemantic(true, true, EMaxIdLength::ClassInfos), ///< EBMLMaxIdLength
EbmlSemantic(true, true, EMaxSizeLength::ClassInfos), ///< EBMLMaxSizeLength
EbmlSemantic(true, true, EDocType::ClassInfos), ///< DocType
EbmlSemantic(true, true, EDocTypeVersion::ClassInfos), ///< DocTypeVersion
EbmlSemantic(true, true, EDocTypeReadVersion::ClassInfos), ///< DocTypeReadVersion
};
const EbmlSemanticContext EbmlHead_Context = EbmlSemanticContext(countof(EbmlHead_ContextList), EbmlHead_ContextList, NULL, *GetEbmlGlobal_Context, &EbmlHead::ClassInfos);
EbmlId EbmlHead_TheId(0x1A45DFA3, 4);
const EbmlCallbacks EbmlHead::ClassInfos(EbmlHead::Create, EbmlHead_TheId, "EBMLHead\0ratamapaga", EbmlHead_Context);
EbmlHead::EbmlHead()
:EbmlMaster(EbmlHead_Context)
{}
END_LIBEBML_NAMESPACE

528
src/EbmlMaster.cpp Normal file
View File

@ -0,0 +1,528 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlMaster.cpp 1178 2005-05-19 15:47:11Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include <algorithm>
#include "ebml/EbmlMaster.h"
#include "ebml/EbmlStream.h"
#include "ebml/EbmlContexts.h"
#include "ebml/MemIOCallback.h"
START_LIBEBML_NAMESPACE
EbmlMaster::EbmlMaster(const EbmlSemanticContext & aContext, const bool bSizeIsknown)
:EbmlElement(0), Context(aContext), bChecksumUsed(bChecksumUsedByDefault)
{
bSizeIsFinite = bSizeIsknown;
bValueIsSet = true;
ProcessMandatory();
}
EbmlMaster::EbmlMaster(const EbmlMaster & ElementToClone)
:EbmlElement(ElementToClone)
,ElementList(ElementToClone.ListSize())
,Context(ElementToClone.Context)
,bChecksumUsed(ElementToClone.bChecksumUsed)
,Checksum(ElementToClone.Checksum)
{
// add a clone of the list
std::vector<EbmlElement *>::const_iterator Itr = ElementToClone.ElementList.begin();
std::vector<EbmlElement *>::iterator myItr = ElementList.begin();
while (Itr != ElementToClone.ElementList.end())
{
*myItr = (*Itr)->Clone();
Itr++; myItr++;
}
}
EbmlMaster::~EbmlMaster()
{
assert(!bLocked); // you're trying to delete a locked element !!!
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if (!(*ElementList[Index]).IsLocked()) {
delete ElementList[Index];
}
}
}
/*!
\todo handle exception on errors
\todo write all the Mandatory elements in the Context, otherwise assert
*/
uint32 EbmlMaster::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result = 0;
size_t Index;
if (!bForceRender) {
assert(CheckMandatory());
}
if (!bChecksumUsed) { // old school
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue())
continue;
Result += (ElementList[Index])->Render(output, bKeepIntact, false ,bForceRender);
}
} else { // new school
MemIOCallback TmpBuf(Size - 6);
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue())
continue;
(ElementList[Index])->Render(TmpBuf, bKeepIntact, false ,bForceRender);
}
Checksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += Checksum.Render(output, true, false ,bForceRender);
output.writeFully(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
Result += TmpBuf.GetDataBufferSize();
}
return Result;
}
/*!
\todo We might be able to forbid elements that don't exist in the context
*/
bool EbmlMaster::PushElement(EbmlElement & element)
{
ElementList.push_back(&element);
return true;
}
uint64 EbmlMaster::UpdateSize(bool bKeepIntact, bool bForceRender)
{
Size = 0;
if (!bSizeIsFinite)
return (0-1);
if (!bForceRender) {
assert(CheckMandatory());
}
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if (!bKeepIntact && (ElementList[Index])->IsDefaultValue())
continue;
(ElementList[Index])->UpdateSize(bKeepIntact, bForceRender);
uint64 SizeToAdd = (ElementList[Index])->ElementSize(bKeepIntact);
#if defined(_DEBUG) || defined(DEBUG)
if (SizeToAdd == (0-1))
return (0-1);
#endif // DEBUG
Size += SizeToAdd;
}
if (bChecksumUsed) {
Size += Checksum.ElementSize();
}
return Size;
}
uint32 EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bKeepIntact)
{
SetSizeLength(nSizeLength);
return RenderHead(output, false, bKeepIntact);
}
/*!
\todo this code is very suspicious !
*/
uint64 EbmlMaster::ReadData(IOCallback & input, ScopeMode ReadFully)
{
input.setFilePointer(Size, seek_current);
return Size;
}
/*!
\note Hopefully no global element is mandatory
\todo should be called for ALL EbmlMaster element on construction
*/
bool EbmlMaster::ProcessMandatory()
{
if (Context.Size == 0)
{
return true;
}
assert(Context.MyTable != NULL);
unsigned int EltIdx;
for (EltIdx = 0; EltIdx < Context.Size; EltIdx++) {
if (Context.MyTable[EltIdx].Mandatory && Context.MyTable[EltIdx].Unique) {
assert(Context.MyTable[EltIdx].GetCallbacks.Create != NULL);
PushElement(Context.MyTable[EltIdx].GetCallbacks.Create());
}
}
return true;
}
bool EbmlMaster::CheckMandatory() const
{
assert(Context.MyTable != NULL);
unsigned int EltIdx;
for (EltIdx = 0; EltIdx < Context.Size; EltIdx++) {
if (Context.MyTable[EltIdx].Mandatory) {
if (FindElt(Context.MyTable[EltIdx].GetCallbacks) == NULL) {
#if defined(_DEBUG) || defined(DEBUG)
// you are missing this Mandatory element
// const char * MissingName = Context.MyTable[EltIdx].GetCallbacks.DebugName;
#endif // DEBUG
return false;
}
}
}
return true;
}
std::vector<std::string> EbmlMaster::FindAllMissingElements()
{
assert(Context.MyTable != NULL);
std::vector<std::string> missingElements;
for (size_t ChildElementNo = 0; ChildElementNo < ElementList.size(); ChildElementNo++) {
EbmlElement *childElement = ElementList[ChildElementNo];
if (!childElement->ValueIsSet()) {
std::string missingValue;
missingValue = "The Child Element \"";
missingValue.append(childElement->Generic().DebugName);
missingValue.append("\" of EbmlMaster \"");
missingValue.append(this->Generic().DebugName);
missingValue.append("\", does not have a value set.");
missingElements.push_back(missingValue);
}
if (childElement->IsMaster()) {
EbmlMaster *childMaster = (EbmlMaster *)childElement;
std::vector<std::string> childMissingElements = childMaster->FindAllMissingElements();
for (size_t s = 0; s < childMissingElements.size(); s++)
missingElements.push_back(childMissingElements[s]);
}
}
unsigned int EltIdx;
for (EltIdx = 0; EltIdx < Context.Size; EltIdx++) {
if (Context.MyTable[EltIdx].Mandatory) {
if (FindElt(Context.MyTable[EltIdx].GetCallbacks) == NULL) {
std::string missingElement;
missingElement = "Missing element \"";
missingElement.append(Context.MyTable[EltIdx].GetCallbacks.DebugName);
missingElement.append("\" in EbmlMaster \"");
missingElement.append(Context.MasterElt->DebugName);
missingElement.append("\"");
missingElements.push_back(missingElement);
}
}
}
return missingElements;
}
EbmlElement *EbmlMaster::FindElt(const EbmlCallbacks & Callbacks) const
{
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
EbmlElement * tmp = ElementList[Index];
if (EbmlId(*tmp) == Callbacks.GlobalId)
return tmp;
}
return NULL;
}
EbmlElement *EbmlMaster::FindFirstElt(const EbmlCallbacks & Callbacks, const bool bCreateIfNull)
{
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if (EbmlId(*(ElementList[Index])) == Callbacks.GlobalId)
return ElementList[Index];
}
if (bCreateIfNull && Callbacks.Create != NULL) {
// add the element
EbmlElement *NewElt = &(Callbacks.Create());
if (NewElt == NULL)
return NULL;
if (!PushElement(*NewElt)) {
delete NewElt;
NewElt = NULL;
}
return NewElt;
}
return NULL;
}
EbmlElement *EbmlMaster::FindFirstElt(const EbmlCallbacks & Callbacks) const
{
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if (EbmlId(*(ElementList[Index])) == Callbacks.GlobalId)
return ElementList[Index];
}
return NULL;
}
/*!
\todo only return elements that are from the same type !
\todo the element might be the unique in the context !
*/
EbmlElement *EbmlMaster::FindNextElt(const EbmlElement & PastElt, const bool bCreateIfNull)
{
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if ((ElementList[Index]) == &PastElt) {
// found past element, new one is :
Index++;
break;
}
}
while (Index < ElementList.size()) {
if (PastElt.Generic().GlobalId == ElementList[Index]->Generic().GlobalId)
break;
Index++;
}
if (Index != ElementList.size())
return ElementList[Index];
if (bCreateIfNull && PastElt.Generic().Create != NULL) {
// add the element
EbmlElement *NewElt = &(PastElt.Generic().Create());
if (NewElt == NULL)
return NULL;
if (!PushElement(*NewElt)) {
delete NewElt;
NewElt = NULL;
}
return NewElt;
}
return NULL;
}
EbmlElement *EbmlMaster::FindNextElt(const EbmlElement & PastElt) const
{
size_t Index;
for (Index = 0; Index < ElementList.size(); Index++) {
if ((ElementList[Index]) == &PastElt) {
// found past element, new one is :
Index++;
break;
}
}
while (Index < ElementList.size()) {
if (PastElt.Generic().GlobalId == ElementList[Index]->Generic().GlobalId)
return ElementList[Index];
Index++;
}
return NULL;
}
EbmlElement *EbmlMaster::AddNewElt(const EbmlCallbacks & Callbacks)
{
// add the element
EbmlElement *NewElt = &(Callbacks.Create());
if (NewElt == NULL)
return NULL;
if (!PushElement(*NewElt)) {
delete NewElt;
NewElt = NULL;
}
return NewElt;
}
void EbmlMaster::Sort()
{
std::sort(ElementList.begin(), ElementList.end(), EbmlElement::CompareElements);
}
/*!
\brief Method to help reading a Master element and all subsequent children quickly
\todo add an option to discard even unknown elements
\todo handle when a mandatory element is not found
*/
void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sContext, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
EbmlElement * ElementLevelA;
// remove all existing elements, including the mandatory ones...
size_t Index;
for (Index=0; Index<ElementList.size(); Index++) {
if (!(*ElementList[Index]).IsLocked()) {
delete ElementList[Index];
}
}
ElementList.clear();
uint64 MaxSizeToRead = Size;
// read blocks and discard the ones we don't care about
if (MaxSizeToRead > 0) {
inDataStream.I_O().setFilePointer(SizePosition + SizeLength, seek_beginning);
ElementLevelA = inDataStream.FindNextElement(sContext, UpperEltFound, MaxSizeToRead, AllowDummyElt);
while (ElementLevelA != NULL && MaxSizeToRead > 0 && UpperEltFound <= 0) {
MaxSizeToRead = GetEndPosition() - ElementLevelA->GetEndPosition(); // even if it's the default value
if (!AllowDummyElt && ElementLevelA->IsDummy()) {
ElementLevelA->SkipData(inDataStream, sContext);
delete ElementLevelA; // forget this unknown element
} else {
// more logical to do it afterward
ElementList.push_back(ElementLevelA);
ElementLevelA->Read(inDataStream, ElementLevelA->Generic().Context, UpperEltFound, FoundElt, AllowDummyElt, ReadFully);
// just in case
ElementLevelA->SkipData(inDataStream, ElementLevelA->Generic().Context);
}
if (UpperEltFound > 0) {
UpperEltFound--;
if (UpperEltFound > 0 || MaxSizeToRead <= 0)
goto processCrc;
ElementLevelA = FoundElt;
continue;
}
if (UpperEltFound < 0) {
UpperEltFound++;
if (UpperEltFound < 0)
goto processCrc;
}
if (MaxSizeToRead <= 0) {
goto processCrc;// this level is finished
}
ElementLevelA = inDataStream.FindNextElement(sContext, UpperEltFound, MaxSizeToRead, AllowDummyElt);
}
if (UpperEltFound > 0) {
FoundElt = ElementLevelA;
}
}
processCrc:
for (Index=0; Index<ElementList.size(); Index++) {
if (ElementList[Index]->Generic().GlobalId == EbmlCrc32::ClassInfos.GlobalId) {
bChecksumUsed = true;
// remove the element
Checksum = *(static_cast<EbmlCrc32*>(ElementList[Index]));
delete ElementList[Index];
Remove(Index--);
}
}
bValueIsSet = true;
}
}
void EbmlMaster::Remove(size_t Index)
{
if (Index < ElementList.size()) {
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
while (Index-- > 0) {
Itr++;
}
ElementList.erase(Itr);
}
}
bool EbmlMaster::VerifyChecksum() const
{
if (!bChecksumUsed)
return true;
EbmlCrc32 aChecksum;
/// \todo remove the Checksum if it's in the list
/// \todo find another way when not all default values are saved or (unknown from the reader !!!)
MemIOCallback TmpBuf(Size - 6);
for (size_t Index = 0; Index < ElementList.size(); Index++) {
(ElementList[Index])->Render(TmpBuf, true, false, true);
}
aChecksum.FillCRC32(TmpBuf.GetDataBuffer(), TmpBuf.GetDataBufferSize());
return (aChecksum.GetCrc32() == Checksum.GetCrc32());
}
bool EbmlMaster::InsertElement(EbmlElement & element, size_t position)
{
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
while (Itr != ElementList.end() && position--)
{
Itr++;
}
if ((Itr == ElementList.end()) && position)
return false;
ElementList.insert(Itr, &element);
return true;
}
bool EbmlMaster::InsertElement(EbmlElement & element, const EbmlElement & before)
{
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
while (Itr != ElementList.end() && *Itr != &before)
{
Itr++;
}
if (Itr == ElementList.end())
return false;
ElementList.insert(Itr, &element);
return true;
}
END_LIBEBML_NAMESPACE

136
src/EbmlSInteger.cpp Normal file
View File

@ -0,0 +1,136 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlSInteger.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlSInteger.h"
START_LIBEBML_NAMESPACE
EbmlSInteger::EbmlSInteger()
:EbmlElement(DEFAULT_INT_SIZE, false)
{}
EbmlSInteger::EbmlSInteger(const int64 aDefaultValue)
:EbmlElement(DEFAULT_INT_SIZE, true), Value(aDefaultValue)
{
DefaultIsSet = true;
}
EbmlSInteger::EbmlSInteger(const EbmlSInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
unsigned int i;
if (SizeLength > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
int64 TempValue = Value;
for (i=0; i<Size;i++) {
FinalData[Size-i-1] = binary(TempValue & 0xFF);
TempValue >>= 8;
}
output.writeFully(FinalData,Size);
return Size;
}
uint64 EbmlSInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0x7F && Value >= (-0x80)) {
Size = 1;
} else if (Value <= 0x7FFF && Value >= (-0x8000)) {
Size = 2;
} else if (Value <= 0x7FFFFF && Value >= (-0x800000)) {
Size = 3;
} else if (Value <= 0x7FFFFFFF && Value >= (-0x80000000)) {
Size = 4;
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x8000000000)) {
Size = 5;
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x800000000000)) {
Size = 6;
} else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFFFF) &&
Value >= EBML_PRETTYLONGINT(-0x80000000000000)) {
Size = 7;
} else {
Size = 8;
}
if (DefaultSize > Size) {
Size = DefaultSize;
}
return Size;
}
uint64 EbmlSInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, Size);
if (Buffer[0] & 0x80)
Value = -1; // this is a negative value
else
Value = 0; // this is a positive value
for (unsigned int i=0; i<Size; i++)
{
Value <<= 8;
Value |= Buffer[i];
}
bValueIsSet = true;
}
return Size;
}
END_LIBEBML_NAMESPACE

57
src/EbmlStream.cpp Normal file
View File

@ -0,0 +1,57 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlStream.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlStream.h"
START_LIBEBML_NAMESPACE
EbmlStream::EbmlStream(IOCallback & DataStream)
:Stream(DataStream)
{}
EbmlStream::~EbmlStream()
{}
EbmlElement * EbmlStream::FindNextID(const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize)
{
return EbmlElement::FindNextID(Stream, ClassInfos, MaxDataSize);
}
EbmlElement * EbmlStream::FindNextElement(const EbmlSemanticContext & Context, int & UpperLevel, const uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel)
{
return EbmlElement::FindNextElement(Stream, Context, UpperLevel, MaxDataSize, AllowDummyElt, MaxLowerLevel);
}
END_LIBEBML_NAMESPACE

149
src/EbmlString.cpp Normal file
View File

@ -0,0 +1,149 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlString.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include <cassert>
#include "ebml/EbmlString.h"
START_LIBEBML_NAMESPACE
EbmlString::EbmlString()
:EbmlElement(0, false)
{
DefaultSize = 0;
/* done automatically
Size = Value.length();
if (DefaultSize > Size)
Size = DefaultSize;*/
}
EbmlString::EbmlString(const std::string & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
DefaultSize = 0;
DefaultIsSet = true;
/* done automatically
Size = Value.length();
if (DefaultSize > Size)
Size = DefaultSize;*/
}
/*!
\todo Cloning should be on the same exact type !
*/
EbmlString::EbmlString(const EbmlString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result;
output.writeFully(Value.c_str(), Value.length());
Result = Value.length();
if (Result < DefaultSize) {
// pad the rest with 0
binary *Pad = new binary[DefaultSize - Result];
if (Pad == NULL)
{
return Result;
}
memset(Pad, 0x00, DefaultSize - Result);
output.writeFully(Pad, DefaultSize - Result);
Result = DefaultSize;
delete [] Pad;
}
return Result;
}
EbmlString & EbmlString::operator=(const std::string NewString)
{
Value = NewString;
bValueIsSet = true;
/* done automatically
Size = Value.length();
if (DefaultSize > Size)
Size = DefaultSize;*/
return *this;
}
uint64 EbmlString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value.length() < DefaultSize) {
Size = DefaultSize;
} else {
Size = Value.length();
}
return Size;
}
uint64 EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (Size == 0) {
Value = "";
bValueIsSet = true;
} else {
char *Buffer = new char[Size + 1];
if (Buffer == NULL) {
// unable to store the data, skip it
input.setFilePointer(Size, seek_current);
} else {
input.readFully(Buffer, Size);
if (Buffer[Size-1] != '\0') {
Buffer[Size] = '\0';
}
Value = Buffer;
delete [] Buffer;
bValueIsSet = true;
}
}
}
return Size;
}
END_LIBEBML_NAMESPACE

65
src/EbmlSubHead.cpp Normal file
View File

@ -0,0 +1,65 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlSubHead.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlSubHead.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
EbmlId EVersion_TheId (0x4286, 2);
EbmlId EReadVersion_TheId (0x42F7, 2);
EbmlId EMaxIdLength_TheId (0x42F2, 2);
EbmlId EMaxSizeLength_TheId (0x42F3, 2);
EbmlId EDocType_TheId (0x4282, 2);
EbmlId EDocTypeVersion_TheId (0x4287, 2);
EbmlId EDocTypeReadVersion_TheId (0x4285, 2);
const EbmlCallbacks EVersion::ClassInfos(EVersion::Create, EVersion_TheId, "EBMLVersion", EVersion_Context);
const EbmlCallbacks EReadVersion::ClassInfos(EReadVersion::Create, EReadVersion_TheId, "EBMLReadVersion", EReadVersion_Context);
const EbmlCallbacks EMaxIdLength::ClassInfos(EMaxIdLength::Create, EMaxIdLength_TheId, "EBMLMaxIdLength", EMaxIdLength_Context);
const EbmlCallbacks EMaxSizeLength::ClassInfos(EMaxSizeLength::Create, EMaxSizeLength_TheId, "EBMLMaxSizeLength", EMaxSizeLength_Context);
const EbmlCallbacks EDocType::ClassInfos(EDocType::Create, EDocType_TheId, "EBMLDocType", EDocType_Context);
const EbmlCallbacks EDocTypeVersion::ClassInfos(EDocTypeVersion::Create, EDocTypeVersion_TheId, "EBMLDocTypeVersion", EDocTypeVersion_Context);
const EbmlCallbacks EDocTypeReadVersion::ClassInfos(EDocTypeReadVersion::Create, EDocTypeReadVersion_TheId, "EBMLDocTypeReadVersion", EDocTypeReadVersion_Context);
const EbmlSemanticContext EVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EVersion::ClassInfos);
const EbmlSemanticContext EReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EReadVersion::ClassInfos);
const EbmlSemanticContext EMaxIdLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EMaxIdLength::ClassInfos);
const EbmlSemanticContext EMaxSizeLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EMaxSizeLength::ClassInfos);
const EbmlSemanticContext EDocType_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocType::ClassInfos);
const EbmlSemanticContext EDocTypeVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocTypeVersion::ClassInfos);
const EbmlSemanticContext EDocTypeReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocTypeReadVersion::ClassInfos);
END_LIBEBML_NAMESPACE

130
src/EbmlUInteger.cpp Normal file
View File

@ -0,0 +1,130 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlUInteger.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include "ebml/EbmlUInteger.h"
START_LIBEBML_NAMESPACE
EbmlUInteger::EbmlUInteger()
:EbmlElement(DEFAULT_UINT_SIZE, false)
{}
EbmlUInteger::EbmlUInteger(const uint64 aDefaultValue)
:EbmlElement(DEFAULT_UINT_SIZE, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
DefaultIsSet = true;
}
EbmlUInteger::EbmlUInteger(const EbmlUInteger & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\todo handle exception on errors
*/
uint32 EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
binary FinalData[8]; // we don't handle more than 64 bits integers
if (SizeLength > 8)
return 0; // integer bigger coded on more than 64 bits are not supported
uint64 TempValue = Value;
for (unsigned int i=0; i<Size;i++) {
FinalData[Size-i-1] = TempValue & 0xFF;
TempValue >>= 8;
}
output.writeFully(FinalData,Size);
return Size;
}
uint64 EbmlUInteger::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
if (Value <= 0xFF) {
Size = 1;
} else if (Value <= 0xFFFF) {
Size = 2;
} else if (Value <= 0xFFFFFF) {
Size = 3;
} else if (Value <= 0xFFFFFFFF) {
Size = 4;
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFF)) {
Size = 5;
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFF)) {
Size = 6;
} else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFF)) {
Size = 7;
} else {
Size = 8;
}
if (DefaultSize > Size) {
Size = DefaultSize;
}
return Size;
}
uint64 EbmlUInteger::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
binary Buffer[8];
input.readFully(Buffer, Size);
Value = 0;
for (unsigned int i=0; i<Size; i++)
{
Value <<= 8;
Value |= Buffer[i];
}
bValueIsSet = true;
}
return Size;
}
END_LIBEBML_NAMESPACE

307
src/EbmlUnicodeString.cpp Normal file
View File

@ -0,0 +1,307 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlUnicodeString.cpp 1079 2005-03-03 13:18:14Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
#include <cassert>
#if __GNUC__ == 2 && ! defined ( __OpenBSD__ )
#include <wchar.h>
#endif
#include "ebml/EbmlUnicodeString.h"
START_LIBEBML_NAMESPACE
// ===================== UTFstring class ===================
UTFstring::UTFstring()
:_Length(0)
,_Data(NULL)
{}
UTFstring::UTFstring(const wchar_t * _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf;
}
UTFstring::~UTFstring()
{
delete [] _Data;
}
UTFstring::UTFstring(const UTFstring & _aBuf)
:_Length(0)
,_Data(NULL)
{
*this = _aBuf.c_str();
}
UTFstring & UTFstring::operator=(const UTFstring & _aBuf)
{
*this = _aBuf.c_str();
return *this;
}
UTFstring & UTFstring::operator=(const wchar_t * _aBuf)
{
delete [] _Data;
if (_aBuf == NULL) {
_Data = new wchar_t[1];
_Data[0] = 0;
UpdateFromUCS2();
return *this;
}
size_t aLen;
for (aLen=0; _aBuf[aLen] != 0; aLen++);
_Length = aLen;
_Data = new wchar_t[_Length+1];
for (aLen=0; _aBuf[aLen] != 0; aLen++) {
_Data[aLen] = _aBuf[aLen];
}
_Data[aLen] = 0;
UpdateFromUCS2();
return *this;
}
UTFstring & UTFstring::operator=(wchar_t _aChar)
{
delete [] _Data;
_Data = new wchar_t[2];
_Length = 1;
_Data[0] = _aChar;
_Data[1] = 0;
UpdateFromUCS2();
return *this;
}
bool UTFstring::operator==(const UTFstring& _aStr) const
{
if ((_Data == NULL) && (_aStr._Data == NULL))
return true;
if ((_Data == NULL) || (_aStr._Data == NULL))
return false;
return wcscmp_internal(_Data, _aStr._Data);
}
void UTFstring::SetUTF8(const std::string & _aStr)
{
UTF8string = _aStr;
UpdateFromUTF8();
}
/*!
\see RFC 2279
*/
void UTFstring::UpdateFromUTF8()
{
delete [] _Data;
// find the size of the final UCS-2 string
size_t i;
for (_Length=0, i=0; i<UTF8string.length(); _Length++) {
if ((UTF8string[i] & 0x80) == 0) {
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
i += 3;
}
}
_Data = new wchar_t[_Length+1];
size_t j;
for (j=0, i=0; i<UTF8string.length(); j++) {
if ((UTF8string[i] & 0x80) == 0) {
_Data[j] = UTF8string[i];
i++;
} else if ((UTF8string[i] & 0x20) == 0) {
_Data[j] = ((UTF8string[i] & 0x1F) << 6) + (UTF8string[i+1] & 0x3F);
i += 2;
} else if ((UTF8string[i] & 0x10) == 0) {
_Data[j] = ((UTF8string[i] & 0x0F) << 12) + ((UTF8string[i+1] & 0x3F) << 6) + (UTF8string[i+2] & 0x3F);
i += 3;
}
}
_Data[j] = 0;
}
void UTFstring::UpdateFromUCS2()
{
// find the size of the final UTF-8 string
size_t i,Size=0;
for (i=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
Size++;
} else if (_Data[i] < 0x800) {
Size += 2;
} else if (_Data[i] < 0x10000) {
Size += 3;
}
}
std::string::value_type *tmpStr = new std::string::value_type[Size+1];
for (i=0, Size=0; i<_Length; i++)
{
if (_Data[i] < 0x80) {
tmpStr[Size++] = _Data[i];
} else if (_Data[i] < 0x800) {
tmpStr[Size++] = 0xC0 | (_Data[i] >> 6);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
} else if (_Data[i] < 0x10000) {
tmpStr[Size++] = 0xE0 | (_Data[i] >> 12);
tmpStr[Size++] = 0x80 | ((_Data[i] >> 6) & 0x3F);
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
}
}
tmpStr[Size] = 0;
UTF8string = tmpStr; // implicit conversion
delete [] tmpStr;
}
bool UTFstring::wcscmp_internal(const wchar_t *str1, const wchar_t *str2)
{
size_t Index=0;
while (str1[Index] == str2[Index] && str1[Index] != 0) {
Index++;
}
return (str1[Index] == str2[Index]);
}
// ===================== EbmlUnicodeString class ===================
EbmlUnicodeString::EbmlUnicodeString()
:EbmlElement(0, false)
{
DefaultSize = 0;
}
EbmlUnicodeString::EbmlUnicodeString(const UTFstring & aDefaultValue)
:EbmlElement(0, true), Value(aDefaultValue), DefaultValue(aDefaultValue)
{
DefaultSize = 0;
DefaultIsSet = true;
}
EbmlUnicodeString::EbmlUnicodeString(const EbmlUnicodeString & ElementToClone)
:EbmlElement(ElementToClone)
,Value(ElementToClone.Value)
,DefaultValue(ElementToClone.DefaultValue)
{
}
/*!
\note limited to UCS-2
\todo handle exception on errors
*/
uint32 EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
uint32 Result = Value.GetUTF8().length();
if (Result != 0) {
output.writeFully(Value.GetUTF8().c_str(), Result);
}
if (Result < DefaultSize) {
// pad the rest with 0
binary *Pad = new binary[DefaultSize - Result];
if (Pad != NULL) {
memset(Pad, 0x00, DefaultSize - Result);
output.writeFully(Pad, DefaultSize - Result);
Result = DefaultSize;
delete [] Pad;
}
}
return Result;
}
EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
{
Value = NewString;
bValueIsSet = true;
return *this;
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::UpdateSize(bool bKeepIntact, bool bForceRender)
{
if (!bKeepIntact && IsDefaultValue())
return 0;
Size = Value.GetUTF8().length();
if (Size < DefaultSize)
Size = DefaultSize;
return Size;
}
/*!
\note limited to UCS-2
*/
uint64 EbmlUnicodeString::ReadData(IOCallback & input, ScopeMode ReadFully)
{
if (ReadFully != SCOPE_NO_DATA)
{
if (Size == 0) {
Value = UTFstring::value_type(0);
bValueIsSet = true;
} else {
char *Buffer = new char[Size+1];
if (Buffer == NULL) {
// impossible to read, skip it
input.setFilePointer(Size, seek_current);
} else {
input.readFully(Buffer, Size);
if (Buffer[Size-1] != 0) {
Buffer[Size] = 0;
}
Value.SetUTF8(Buffer); // implicit conversion to std::string
delete [] Buffer;
bValueIsSet = true;
}
}
}
return Size;
}
END_LIBEBML_NAMESPACE

41
src/EbmlVersion.cpp Normal file
View File

@ -0,0 +1,41 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlVersion.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVersion.h"
START_LIBEBML_NAMESPACE
END_LIBEBML_NAMESPACE

139
src/EbmlVoid.cpp Normal file
View File

@ -0,0 +1,139 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: EbmlVoid.cpp 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#include "ebml/EbmlVoid.h"
#include "ebml/EbmlContexts.h"
START_LIBEBML_NAMESPACE
EbmlId EbmlVoid_TheId(0xEC, 1);
const EbmlCallbacks EbmlVoid::ClassInfos(EbmlVoid::Create, EbmlVoid_TheId, "EBMLVoid", EbmlVoid_Context);
EbmlVoid::EbmlVoid()
{
bValueIsSet = true;
}
uint32 EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
{
// write dummy data by 4KB chunks
static binary DummyBuf[4*1024];
uint64 SizeToWrite = Size;
while (SizeToWrite > 4*1024)
{
output.writeFully(DummyBuf, 4*1024);
SizeToWrite -= 4*1024;
}
output.writeFully(DummyBuf, SizeToWrite);
return Size;
}
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
EltToReplaceWith.UpdateSize(bKeepIntact);
if (HeadSize() + Size < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
// the element can't be written here !
return 0;
}
if (HeadSize() + Size - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
// there is not enough space to put a filling element
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(GetElementPosition());
EltToReplaceWith.Render(output, bKeepIntact);
if (HeadSize() + Size - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
// fill the rest with another void element
EbmlVoid aTmp;
aTmp.SetSize(HeadSize() + Size - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
int HeadBefore = aTmp.HeadSize();
aTmp.SetSize(aTmp.GetSize() - CodedSizeLength(aTmp.Size, aTmp.SizeLength, aTmp.bSizeIsFinite));
int HeadAfter = aTmp.HeadSize();
if (HeadBefore != HeadAfter) {
aTmp.SetSizeLength(CodedSizeLength(aTmp.Size, aTmp.SizeLength, aTmp.bSizeIsFinite) - (HeadAfter - HeadBefore));
}
aTmp.RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return Size + HeadSize();
}
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bKeepIntact)
{
// EltToVoid.UpdateSize(bKeepIntact);
if (EltToVoid.GetElementPosition() == 0) {
// this element has never been written
return 0;
}
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
// the element can't be written here !
return 0;
}
uint64 CurrentPosition = output.getFilePointer();
output.setFilePointer(EltToVoid.GetElementPosition());
// compute the size of the voided data based on the original one
Size = EltToVoid.GetSize() + EltToVoid.HeadSize() - 1; // 1 for the ID
Size -= CodedSizeLength(Size, SizeLength, bSizeIsFinite);
// make sure we handle even the strange cases
//uint32 A1 = Size + HeadSize();
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
if (Size + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
Size--;
SetSizeLength(CodedSizeLength(Size, SizeLength, bSizeIsFinite) + 1);
}
if (Size != 0) {
RenderHead(output, false, bKeepIntact); // the rest of the data is not rewritten
}
if (ComeBackAfterward) {
output.setFilePointer(CurrentPosition);
}
return EltToVoid.GetSize() + EltToVoid.HeadSize();
}
END_LIBEBML_NAMESPACE

83
src/IOCallback.cpp Normal file
View File

@ -0,0 +1,83 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Ingo Ralf Blum. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: IOCallback.cpp 639 2004-07-09 20:59:14Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#if !defined(__GNUC__) || (__GNUC__ > 2)
#include <sstream>
#endif // GCC2
#include <stdexcept>
#include "ebml/IOCallback.h"
using namespace std;
START_LIBEBML_NAMESPACE
void IOCallback::writeFully(const void*Buffer,size_t Size)
{
if (Size == 0)
return;
if (Buffer == NULL)
throw;
if(write(Buffer,Size) != Size)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
stringstream Msg;
Msg<<"EOF in writeFully("<<Buffer<<","<<Size<<")";
throw runtime_error(Msg.str());
#endif // GCC2
}
}
void IOCallback::readFully(void*Buffer,size_t Size)
{
if(Buffer == NULL)
throw;
if(read(Buffer,Size) != Size)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
stringstream Msg;
Msg<<"EOF in readFully("<<Buffer<<","<<Size<<")";
throw runtime_error(Msg.str());
#endif // GCC2
}
}
END_LIBEBML_NAMESPACE

123
src/MemIOCallback.cpp Normal file
View File

@ -0,0 +1,123 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2003 Jory Stone. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: MemIOCallback.cpp 693 2004-07-31 08:56:28Z robux4 $
\author Jory Stone <jcsston @ toughguy.net>
*/
#include "ebml/MemIOCallback.h"
#include "ebml/Debug.h"
#include "ebml/EbmlConfig.h"
START_LIBEBML_NAMESPACE
MemIOCallback::MemIOCallback(uint64 DefaultSize)
{
//The default size of the buffer is 128 bytes
dataBuffer = (binary *)malloc(DefaultSize);
if (dataBuffer == NULL) {
mOk = false;
std::stringstream Msg;
Msg << "Failed to alloc memory block of size ";
// not working with VC6 Msg << DefaultSize;
mLastErrorStr = Msg.str();
return;
}
dataBufferMemorySize = DefaultSize;
dataBufferPos = 0;
dataBufferTotalSize = 0;
mOk = true;
}
MemIOCallback::~MemIOCallback()
{
if (dataBuffer != NULL)
free(dataBuffer);
}
uint32 MemIOCallback::read(void *Buffer, size_t Size)
{
if (Buffer == NULL || Size < 1)
return 0;
//If the size is larger than than the amount left in the buffer
if (Size + dataBufferPos > dataBufferTotalSize)
{
//We will only return the remaining data
memcpy(Buffer, dataBuffer + dataBufferPos, dataBufferTotalSize - dataBufferPos);
dataBufferPos = dataBufferTotalSize;
return dataBufferTotalSize - dataBufferPos;
}
//Well... We made it here, so do a quick and simple copy
memcpy(Buffer, dataBuffer+dataBufferPos, Size);
dataBufferPos += Size;
return Size;
}
void MemIOCallback::setFilePointer(int64 Offset, seek_mode Mode)
{
if (Mode == seek_beginning)
dataBufferPos = Offset;
else if (Mode == seek_current)
dataBufferPos = dataBufferPos + Offset;
else if (Mode == seek_end)
dataBufferPos = dataBufferTotalSize + Offset;
}
size_t MemIOCallback::write(const void *Buffer, size_t Size)
{
if (dataBufferMemorySize < dataBufferPos + Size)
{
//We need more memory!
dataBuffer = (binary *)realloc((void *)dataBuffer, dataBufferPos + Size);
}
memcpy(dataBuffer+dataBufferPos, Buffer, Size);
dataBufferPos += Size;
if (dataBufferPos > dataBufferTotalSize)
dataBufferTotalSize = dataBufferPos;
return Size;
}
uint32 MemIOCallback::write(IOCallback & IOToRead, size_t Size)
{
if (dataBufferMemorySize < dataBufferPos + Size)
{
//We need more memory!
dataBuffer = (binary *)realloc((void *)dataBuffer, dataBufferPos + Size);
}
IOToRead.readFully(&dataBuffer[dataBufferPos], Size);
dataBufferTotalSize = Size;
return Size;
}
END_LIBEBML_NAMESPACE

201
src/StdIOCallback.cpp Normal file
View File

@ -0,0 +1,201 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Ingo Ralf Blum. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: StdIOCallback.cpp 1298 2008-02-21 22:14:18Z mosu $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <cassert>
#include <climits>
#if !defined(__GNUC__) || (__GNUC__ > 2)
#include <sstream>
#endif // GCC2
#include "ebml/StdIOCallback.h"
#include "ebml/Debug.h"
#include "ebml/EbmlConfig.h"
using namespace std;
START_LIBEBML_NAMESPACE
CRTError::CRTError(int nError, const std::string & Description)
:std::runtime_error(Description+": "+strerror(nError))
,Error(Error)
{
}
CRTError::CRTError(const std::string & Description,int nError)
:std::runtime_error(Description+": "+strerror(nError))
,Error(Error)
{
}
StdIOCallback::StdIOCallback(const char*Path, const open_mode aMode)
{
assert(Path!=0);
const char *Mode;
switch (aMode)
{
case MODE_READ:
Mode = "rb";
break;
case MODE_SAFE:
Mode = "rb+";
break;
case MODE_WRITE:
Mode = "wb";
break;
case MODE_CREATE:
Mode = "wb+";
break;
default:
throw 0;
}
File=fopen(Path,Mode);
if(File==0)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
stringstream Msg;
Msg<<"Can't open stdio file \""<<Path<<"\" in mode \""<<Mode<<"\"";
throw CRTError(Msg.str());
#endif // GCC2
}
mCurrentPosition = 0;
}
StdIOCallback::~StdIOCallback()throw()
{
close();
}
uint32 StdIOCallback::read(void*Buffer,size_t Size)
{
assert(File!=0);
size_t result = fread(Buffer, 1, Size, File);
mCurrentPosition += result;
return result;
}
void StdIOCallback::setFilePointer(int64 Offset,seek_mode Mode)
{
assert(File!=0);
// There is a numeric cast in the boost library, which would be quite nice for this checking
/*
SL : replaced because unknown class in cygwin
assert(Offset <= numeric_limits<long>::max());
assert(Offset >= numeric_limits<long>::min());
*/
assert(Offset <= LONG_MAX);
assert(Offset >= LONG_MIN);
assert(Mode==SEEK_CUR||Mode==SEEK_END||Mode==SEEK_SET);
if(fseek(File,Offset,Mode)!=0)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
ostringstream Msg;
Msg<<"Failed to seek file "<<File<<" to offset "<<(unsigned long)Offset<<" in mode "<<Mode;
throw CRTError(Msg.str());
#endif // GCC2
mCurrentPosition = ftell(File);
}
else
{
switch ( Mode )
{
case SEEK_CUR:
mCurrentPosition += Offset;
break;
case SEEK_END:
mCurrentPosition = ftell(File);
break;
case SEEK_SET:
mCurrentPosition = Offset;
break;
}
}
}
size_t StdIOCallback::write(const void*Buffer,size_t Size)
{
assert(File!=0);
uint32 Result = fwrite(Buffer,1,Size,File);
mCurrentPosition += Result;
return Result;
}
uint64 StdIOCallback::getFilePointer()
{
assert(File!=0);
#if 0
long Result=ftell(File);
if(Result<0)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
stringstream Msg;
Msg<<"Can't tell the current file pointer position for "<<File;
throw CRTError(Msg.str());
#endif // GCC2
}
#endif
return mCurrentPosition;
}
void StdIOCallback::close()
{
if(File==0)
return;
if(fclose(File)!=0)
{
#if !defined(__GNUC__) || (__GNUC__ > 2)
stringstream Msg;
Msg<<"Can't close file "<<File;
throw CRTError(Msg.str());
#endif // GCC2
}
File=0;
}
END_LIBEBML_NAMESPACE

View File

@ -0,0 +1,283 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2003 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: WinIOCallback.cpp 1092 2005-03-16 13:01:15Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
\author Cyrius <suiryc @ users.sf.net>
*/
#include <cassert>
#include "WinIOCallback.h"
#include "ebml/Debug.h"
#ifndef INVALID_SET_FILE_POINTER // found in newer platform SDKs
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif // INVALID_SET_FILE_POINTER
START_LIBEBML_NAMESPACE
WinIOCallback::WinIOCallback(const char* Path, const open_mode aMode, DWORD dwFlags)
:mFile(NULL), mOk(false)
{
mOk = open(Path, aMode, dwFlags);
}
WinIOCallback::WinIOCallback(const wchar_t* Path, const open_mode aMode, DWORD dwFlags)
:mFile(NULL), mOk(false)
{
mOk = open(Path, aMode, dwFlags);
}
WinIOCallback::~WinIOCallback()
{
close();
}
bool WinIOCallback::open(const char* Path, const open_mode aMode, DWORD dwFlags)
{
assert(Path!=0);
DWORD AccessMode, ShareMode, Disposition;
switch (aMode)
{
case MODE_READ:
AccessMode = GENERIC_READ;
ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
Disposition = OPEN_EXISTING;
break;
case MODE_WRITE:
AccessMode = GENERIC_WRITE;
ShareMode = 0;
Disposition = OPEN_ALWAYS;
break;
case MODE_SAFE:
AccessMode = GENERIC_WRITE|GENERIC_READ;
ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
Disposition = OPEN_ALWAYS;
break;
case MODE_CREATE:
AccessMode = GENERIC_WRITE;
ShareMode = 0;
Disposition = CREATE_ALWAYS;
break;
default:
assert(false);
}
mFile = CreateFileA(Path, AccessMode, ShareMode, NULL, Disposition, dwFlags, NULL);
if ((mFile == INVALID_HANDLE_VALUE) || ((long)mFile == 0xffffffff))
{
//File was not opened
char err_msg[256];
DWORD error_code = GetLastError();
// An error message about the file already existing is not really an error message :P
if (error_code != ERROR_ALREADY_EXISTS) {
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, error_code, 0, err_msg, 255, NULL);
EBML_TRACE("Failed to open file \"%hs\" in mode %d.", Path, aMode);
mLastErrorStr = err_msg;
return mOk = false;
}
}
mCurrentPosition = 0;
EBML_TRACE("Successfully opened file \"%hs\" in mode %d. The handle is %p\n", Path, aMode, mFile);
return mOk = true;
};
bool WinIOCallback::open(const wchar_t* Path, const open_mode aMode, DWORD dwFlags)
{
assert(Path!=0);
DWORD AccessMode, ShareMode, Disposition;
switch (aMode)
{
case MODE_READ:
AccessMode = GENERIC_READ;
ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
Disposition = OPEN_EXISTING;
break;
case MODE_WRITE:
AccessMode = GENERIC_WRITE;
ShareMode = 0;
Disposition = OPEN_ALWAYS;
break;
case MODE_SAFE:
AccessMode = GENERIC_WRITE|GENERIC_READ;
ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
Disposition = OPEN_ALWAYS;
break;
case MODE_CREATE:
AccessMode = GENERIC_WRITE;
ShareMode = 0;
Disposition = CREATE_ALWAYS;
break;
default:
assert(false);
}
if ((LONG)GetVersion() >= 0) {
mFile = CreateFileW(Path, AccessMode, ShareMode, NULL, Disposition, dwFlags, NULL);
} else {
int errCode;
unsigned int bufferSize = wcslen(Path) + sizeof(wchar_t) * 2;
std::string PathA;
PathA.resize(bufferSize);
errCode = WideCharToMultiByte(CP_ACP, 0, Path, wcslen(Path), (char *)PathA.c_str(), bufferSize, NULL, NULL);
if (errCode == 0)
errCode = GetLastError();
#ifdef _DEBUG
if (errCode == ERROR_INSUFFICIENT_BUFFER) OutputDebugString(TEXT("WinIOCallback::WideCharToMultiByte::ERROR_INSUFFICIENT_BUFFER"));
if (errCode == ERROR_INVALID_FLAGS) OutputDebugString(TEXT("WinIOCallback::WideCharToMultiByte::ERROR_INVALID_FLAGS"));
if (errCode == ERROR_INVALID_PARAMETER) OutputDebugString(TEXT("WinIOCallback::WideCharToMultiByte::ERROR_INVALID_PARAMETER"));
#endif
while (errCode == ERROR_INSUFFICIENT_BUFFER) {
// Increase the buffer size
bufferSize += MAX_PATH;
PathA.resize(bufferSize);
errCode = WideCharToMultiByte(CP_ACP, WC_SEPCHARS, Path, wcslen(Path), (char *)PathA.c_str(), bufferSize, NULL, NULL);
if (errCode == 0)
errCode = GetLastError();
}
if (errCode != 0) {
mFile = CreateFileA(PathA.c_str(), AccessMode, ShareMode, NULL, Disposition, dwFlags, NULL);
} else {
mLastErrorStr = "Couldn't convert Unicode filename to ANSI.";
return mOk = false;
}
}
if ((mFile == INVALID_HANDLE_VALUE) || ((long)mFile == 0xffffffff))
{
//File was not opened
char err_msg[256];
DWORD error_code = GetLastError();
// An error message about the file already existing is not really an error message :P
if (error_code != ERROR_ALREADY_EXISTS) {
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, error_code, 0, err_msg, 255, NULL);
EBML_TRACE("Failed to open file \"%S\" in mode %d.", Path, aMode);
mLastErrorStr = err_msg;
return mOk = false;
}
}
mCurrentPosition = 0;
EBML_TRACE("Successfully opened file \"%S\" in mode %d. The handle is %p\n", Path, aMode, mFile);
return mOk = true;
}
void WinIOCallback::close()
{
if (mFile) {
CloseHandle(mFile);
mFile = NULL;
}
}
uint64 WinIOCallback::getFilePointer()
{
if (!mFile) {
return 0;
}
return mCurrentPosition;
#if 0
LONG High = 0;
DWORD Low = SetFilePointer(mFile, 0, &High, FILE_CURRENT);
if ( (Low==INVALID_SET_FILE_POINTER) && (GetLastError()!=NO_ERROR) )
return static_cast<uint64>(-1);
return ((uint64(High)<<32) | Low);
#endif
}
void WinIOCallback::setFilePointer(int64 Offset, seek_mode Mode)
{
DWORD Method;
switch(Mode)
{
case seek_beginning:
Method=FILE_BEGIN;
break;
case seek_current:
Method=FILE_CURRENT;
break;
case seek_end:
Method=FILE_END;
break;
default:
assert(false);
break;
}
LONG High = LONG(Offset>>32);
mCurrentPosition = SetFilePointer(mFile, LONG(Offset & 0xffffffff), &High, Method);
if ( mCurrentPosition == INVALID_SET_FILE_POINTER )
{
High = 0;
DWORD Low = SetFilePointer(mFile, 0, &High, FILE_CURRENT);
mCurrentPosition = ((uint64(High)<<32) | Low);
}
else
{
mCurrentPosition |= uint64(High<<32);
}
}
uint32 WinIOCallback::read(void*Buffer,size_t Size)
{
DWORD BytesRead;
if (!ReadFile(mFile, Buffer, Size, &BytesRead, NULL)) {
return 0;
}
mCurrentPosition += BytesRead;
return BytesRead;
}
size_t WinIOCallback::write(const void*Buffer,size_t Size)
{
DWORD BytesWriten;
if (!WriteFile(mFile, Buffer, Size, &BytesWriten, NULL)) {
return 0;
}
mCurrentPosition += BytesWriten;
return BytesWriten;
}
bool WinIOCallback::SetEOF()
{
return SetEndOfFile(mFile) != 0;
}
END_LIBEBML_NAMESPACE

View File

@ -0,0 +1,75 @@
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2003 Steve Lhomme. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id: WinIOCallback.h 1090 2005-03-16 12:47:59Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
\author Cyrius <suiryc @ users.sf.net>
*/
#ifndef LIBEBML_WINIOCALLBACK_H
#define LIBEBML_WINIOCALLBACK_H
#include <windows.h>
#include <stdexcept>
#include <string>
#include "ebml/IOCallback.h"
START_LIBEBML_NAMESPACE
class WinIOCallback: public IOCallback
{
public:
WinIOCallback(const wchar_t* Path, const open_mode aMode, DWORD dwFlags=0);
WinIOCallback(const char* Path, const open_mode aMode, DWORD dwFlags=0);
virtual ~WinIOCallback();
bool open(const wchar_t* Path, const open_mode Mode, DWORD dwFlags=0);
bool open(const char* Path, const open_mode Mode, DWORD dwFlags=0);
virtual uint32 read(void*Buffer,size_t Size);
virtual size_t write(const void*Buffer,size_t Size);
virtual void setFilePointer(int64 Offset,seek_mode Mode=seek_beginning);
virtual uint64 getFilePointer();
virtual void close();
bool IsOk() { return mOk; };
const std::string &GetLastErrorStr() { return mLastErrorStr; };
bool SetEOF();
protected:
bool mOk;
std::string mLastErrorStr;
uint64 mCurrentPosition;
HANDLE mFile;
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_WINIOCALLBACK_H