[matroska] r725 - in trunk: . mkaencoder mkaencoder/doc mkaencoder/src

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: goldenear
Date: 2004-08-24 01:19:26 +0400 (Tue, 24 Aug 2004)
New Revision: 725

Added:
   trunk/mkaencoder/
   trunk/mkaencoder/COPYING.txt
   trunk/mkaencoder/doc/
   trunk/mkaencoder/doc/mkaenc.html
   trunk/mkaencoder/mkaencoder.vmp
   trunk/mkaencoder/src/
   trunk/mkaencoder/src/mkaenc.c
   trunk/mkaencoder/src/mkaenc.h
Removed:
   trunk/mkaenc/
Log:
Sources of mka encoder are now public :-)

Added: trunk/mkaencoder/COPYING.txt
===================================================================
--- trunk/mkaencoder/COPYING.txt	2004-08-23 20:50:48 UTC (rev 724)
+++ trunk/mkaencoder/COPYING.txt	2004-08-23 21:19:26 UTC (rev 725)
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 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.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, 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 or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+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 give any other recipients of the Program a copy of this License
+along with the Program.
+
+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 Program or any portion
+of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+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 Program, 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 Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) 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; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, 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 executable.  However, as a
+special exception, the source code 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.
+
+If distribution of executable or 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 counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program 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.
+
+  5. 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 Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program 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 to
+this License.
+
+  7. 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 Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program 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 Program.
+
+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.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program 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.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the 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 Program
+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 Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, 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
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), 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 Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  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 program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Added: trunk/mkaencoder/doc/mkaenc.html
===================================================================
--- trunk/mkaencoder/doc/mkaenc.html	2004-08-23 20:50:48 UTC (rev 724)
+++ trunk/mkaencoder/doc/mkaenc.html	2004-08-23 21:19:26 UTC (rev 725)
@@ -0,0 +1,262 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+	<TITLE></TITLE>
+	<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.1  (Win32)">
+	<META NAME="CREATED" CONTENT="20040715;11034090">
+	<META NAME="CHANGED" CONTENT="20040818;193044">
+	<STYLE>
+	<!--
+		@page { size: 21.01cm 29.69cm; margin: 2.01cm }
+		P { margin-bottom: 0.2cm }
+	-->
+	</STYLE>
+</HEAD>
+<BODY LANG="en-GB" DIR="LTR">
+<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=4><B><SPAN STYLE="background: transparent">mka
+encoder</SPAN></B></FONT></FONT></FONT></P>
+<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000">mka
+encoder version 1.0.0</FONT></FONT></FONT></SPAN> &ndash; utility to
+encode a wav file + a cue file to a single mka file.</P>
+<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">Copyright
+(C) 2004 Nicolas &quot;goldenear&quot; Le Guen</SPAN></FONT></FONT></FONT></P>
+<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=3><B><SPAN STYLE="background: transparent">Presentation:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000">This
+software interoperates with a ripping tool (especially <A HREF="http://www.exactaudiocopy.de/">Exact
+Audio Copy</A>) and acts as an external encoder. It permits to
+directly generate a singe .mka (matroska audio) file backup of a
+whole audio CD. To do so, it will successively process several
+operations:</FONT></FONT></FONT></SPAN></P>
+<OL>
+	<LI><P STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000">Get
+	file name, tags and parameters informations from the command line
+	generated by the CD ripping </FONT></FONT></FONT></SPAN>software.
+	For example, EAC will run mkaenc.exe with the following parameters :
+	-i &quot;%s&quot; -s &quot;%o&quot; -y &quot;%Y&quot; -g &quot;%m&quot;
+	-m -f</P>
+	<LI><P STYLE="margin-bottom: 0cm">Modify the .cue file (with -m)
+	adding missing parameters: Some informations such as DATE or GENRE
+	are not included in the .cue file generated by the ripping tool, so
+	mkaenc will automatically add this informations (get with -y &ldquo;%Y&rdquo;
+	-g&rdquo;%m&rdquo;)</P>
+	<LI><P STYLE="margin-bottom: 0cm">Rename the .wav file and the .cue
+	file according to the naming scheme (default -n &ldquo;/a - /t&rdquo;
+	will produce files artist &ndash; title.wav and artist &ndash;
+	title.cue)</P>
+	<LI><P STYLE="margin-bottom: 0cm">Encode the .wav file with an
+	external (preferably lossless) encoder (default is TTA)</P>
+	<LI><P STYLE="margin-bottom: 0cm">delete the .wav file when encoded
+	is completed (unless you use the -w option)</P>
+	<LI><P STYLE="margin-bottom: 0cm">merge the encoded file to a
+	matroska file, use the .cue file to tag chapters and attach this
+	.cue file to the .mka file (unless you use -b)</P>
+	<LI><P STYLE="margin-bottom: 0cm">delete the encoded file and the
+	cue file (unless you use -k)</P>
+	<LI><P STYLE="margin-bottom: 0cm">it's done!</P>
+</OL>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=3><B><SPAN STYLE="background: transparent">Options
+and command line parameters:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><B><SPAN STYLE="background: transparent">Required
+parameters:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-i
+</B>&lt;input file&gt; Give the wav file to encode with its full
+path. The cue file must be at the same place. </SPAN></FONT></FONT></FONT>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><B><SPAN STYLE="background: transparent">Optional
+parameters:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-s</B>
+&lt;filename&gt; Give the source file name from EAC: You must use &ldquo;-s
+%o&rdquo; </SPAN></FONT></FONT></FONT>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-n</B>
+&lt;naming scheme&gt; This is how you want the files to be named or
+renamed. Your can use the special commands:</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">/a
+= CD title /t = CD title /y = CD date /g =CD genre /d = DiscID /c =
+Comment</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">It
+uses the tags given by -a -t -y -g -d or -c (see after)</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">You
+can also specify a path. For example, -n &ldquo;D:\audio\/a\/a - /t&rdquo;
+will create the files &ldquo;d:\audio\artist\artist &ndash; title.*&rdquo;</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">The
+default is -n &ldquo;/a - /t&rdquo;. if you use the -u option, -n
+will be ignored.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-p</B>
+&lt;parameters&gt; Optional parameters for mkvmerge.exe</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-r</B>
+&lt;command&gt; This will specify a command or a script to launch
+after everything is done.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-e</B>
+&lt;encoder with full path&gt; Give the encoder executable with its
+full path. The default is &quot;C:\Program Files\TTA\ttaenc.exe&quot;.
+-e can also accept the short name of the encoder, i.e. &ldquo;FLAC&rdquo;,
+&ldquo;TTA&rdquo;, of &ldquo;WAV&rdquo;. This will set the default
+parameters for the specified encoder:</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">FLAC
+--&gt; executable &ldquo;C:\Program Files\FLAC\flac.exe&rdquo;,
+options &ldquo;--best -V&rdquo;, extension &ldquo;.flac&rdquo;</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">TTA
+--&gt; executable &ldquo;C:\Program Files\TTA\ttaenc.exe&rdquo;,
+options &ldquo;-e&rdquo;, extension &ldquo;.tta&rdquo;</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm">WAV --&gt; use the wav file directly,
+do not encode.</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-o</B>
+&lt;encoder options&gt; Specify the options given to the encoder. By
+default &quot;--best -V&quot;</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-x</B>
+&lt;extension&gt; Specify the encoded file extension. By default
+&quot;.flac&quot;</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><B><SPAN STYLE="background: transparent">Tags
+parameters:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-a</B>
+&lt;album artist&gt; Album artist. If not specified, the information
+if taken from the CUE sheet.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-t</B>
+&lt;album title&gt; Album title. If not specified, the information if
+taken from the CUE sheet.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-y</B>
+&lt;album date&gt; set DATE tag</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-g</B>
+&lt;album genre&gt; set GENRE tag</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-d</B>
+&lt;discID&gt; set DISCID tag</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-c</B>
+&lt;comment&gt; set COMMENT tag</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><B><SPAN STYLE="background: transparent">General
+options:</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000"><B>-m</B>
+Use this to modify the CUE file. This will add missing tags (for
+example GENRE or DATE) to the CUE sheet</FONT></FONT></FONT></SPAN>.</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-f
+</B>Fix EAC CUE file extension. EAC creates a cue file with a
+.mka.cue extension. This option permit to give only the &ldquo;.cue&rdquo;
+extension.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-j</B>
+Join the CUE file as an attachment to the mka file.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-u</B>
+Unchange base file name. If you use this option, the files wont be
+renamed. This cancels the -n option.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-w</B>
+Don't delete the WAV file after encoding. The cue file won't be
+deleted after merging.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-k</B>
+Don't delete the encoded file and the cue file after merging.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-b</B>
+Don't merge the CUE and encoded files. Use this if you only want to
+encode and modify the cue file.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-q</B>
+Quiet mode. Don't display anything except error messages. Encoder
+messages will still be displayed.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-h</B>
+Display the full help.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000"><B>-v</B>
+Display the software </FONT></FONT></FONT></SPAN>version.</P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent"><B>-l</B>
+Display licence informations.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=4><B><SPAN STYLE="background: transparent">History</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">version
+1.0.0 some optimisation in the code.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">version
+0.9.9 a few bug fix, TTA is now the default encoder, the cue file is
+no longer attached by default (you must use the -j option to do it),
+-e now accepts shortcuts (&ldquo;TTA &ldquo;FLAC&rdquo;), -p is now
+used to specify mkvmerge optional parameters.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">version
+0.9.5 a few bugs fix and code improvement.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">version
+0.9.4 first public release.</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=4><B><SPAN STYLE="background: transparent">General
+informations</SPAN></B></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><BR>
+</P>
+<P STYLE="margin-bottom: 0cm"><FONT COLOR="#000000"><FONT FACE="Arial, sans-serif"><FONT SIZE=2><SPAN STYLE="background: transparent">This
+program is under the Gnu Public License. Type mkaenc -l for more
+informations</SPAN></FONT></FONT></FONT></P>
+<P STYLE="margin-bottom: 0cm"><SPAN STYLE="background: transparent"><FONT SIZE=2><FONT FACE="Arial, sans-serif"><FONT COLOR="#000000">Please
+report bugs or comments to <A HREF="mailto:[email protected]">[email protected]</A></FONT></FONT></FONT></SPAN></P>
+</BODY>
+</HTML>
\ No newline at end of file

Added: trunk/mkaencoder/mkaencoder.vmp
===================================================================
--- trunk/mkaencoder/mkaencoder.vmp	2004-08-23 20:50:48 UTC (rev 724)
+++ trunk/mkaencoder/mkaencoder.vmp	2004-08-23 21:19:26 UTC (rev 725)
@@ -0,0 +1,85 @@
+;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+;
+;	Project file generated by Visual-MinGW 0.56 alpha.
+;	This file shouldn't be edited manually.
+;	More information: http://visual-mingw.sourceforge.net/
+;
+;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+[VmpHeader]
+Generator = VMinGW
+FileVersion = 102
+
+[Project]
+BuildMakefile = 1
+GenerateMakefile = 1
+WithinMsys = 0
+
+[Archives]
+Directory = .
+Flags = *.*
+
+[Makefile]
+Name = .\Makefile
+Edit = 0
+
+Build = 2
+Lang = 0
+ActiveConfig = Release
+
+[Config1]
+Name = Debug
+Target = .\mkaenc.exe
+Deffile = 
+Implib = 
+ObjDir = .
+DepDir = 
+CC = gcc
+CXX = g++
+RC = windres
+MAKEDEPEND = 
+CppFlags = 
+Warnings = -W -Wall
+Optimize = -O3
+CFlags = 
+CxxFlags = 
+Includes = 
+Debug = 1
+Strip = 0
+LdFlags = 
+LdLibs = 
+LdLibDirs = 
+
+[Config2]
+Name = Release
+Target = .\mkaenc.exe
+Deffile = 
+Implib = 
+ObjDir = .
+DepDir = 
+CC = gcc
+CXX = g++
+RC = windres
+MAKEDEPEND = 
+CppFlags = 
+Warnings = -W -Wall
+Optimize = -O2
+CFlags = 
+CxxFlags = 
+Includes = 
+Debug = 0
+Strip = 0
+LdFlags = 
+LdLibs = 
+LdLibDirs = 
+
+[File1]
+Name = .\src\mkaenc.c
+LastFocused = 1
+Edit = 1
+LinePosition = 30
+
+[File2]
+Name = .\src\mkaenc.h
+Edit = 0
+

Added: trunk/mkaencoder/src/mkaenc.c
===================================================================
--- trunk/mkaencoder/src/mkaenc.c	2004-08-23 20:50:48 UTC (rev 724)
+++ trunk/mkaencoder/src/mkaenc.c	2004-08-23 21:19:26 UTC (rev 725)
@@ -0,0 +1,1041 @@
+/*
+  mka encoder -- Encode wav + cue to single matroska audio file
+
+  mkaenc.c
+
+  Written by Nicolas "goldenear" Le Guen <[email protected]>
+
+  Distributed under the GPL
+  see the file COPYING for details
+  or visit http://www.gnu.org/copyleft/gpl.html
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
+char *meversion = "1.0.0";
+int debugflag = 0;
+int quietflag = 0;
+unsigned int i;
+int *tmp;
+
+int pause (){
+  // Make a pause and wait for [Enter]
+  int ch;
+  printf ("Press [Enter] to continue\n");
+  while ((ch = getchar()) != '\n' && ch != EOF);
+  return 0;
+}
+
+int fexists (char *f) {
+  // Verify if file exists
+  FILE *checkfile;
+  checkfile = fopen ( f,"r");
+  if ( checkfile) {
+    fclose ( checkfile);
+    return 1;
+  }
+  else
+    return 0;
+}
+
+int mkpath(char *path) {
+  // Check/Create the path
+  if (path[0] == '\\')
+    chdir("\\");
+  char *subdir;
+  subdir = strtok( path,"\\");
+  if (!quietflag)
+   printf ("\nPreparing directory \"");
+  while ( subdir) {
+  if (!quietflag)
+   printf ("%s\\", subdir);
+    if (chdir( subdir)){
+	  if (!mkdir( subdir)){
+	    if (chdir( subdir)){
+		  fprintf ( stderr,"\nError: Can't access directory \"%s\"", subdir);
+		  pause();
+		  return 1;
+		}
+	  }
+	  else {
+	    fprintf ( stderr,"\nError: Can't create directory \"%s\"", subdir);
+		pause();
+		return 1;
+	  }
+	}
+    subdir = strtok( NULL,"\\");
+  }
+  if (!quietflag)
+    printf ("\"\n");
+  _getcwd (path, _MAX_DIR);
+  strcat (path, "\\");
+  return 0;
+}
+
+void mbinfo (){
+  // Display informations about the software
+  printf("\nmka encoder version %s - Encode wav + cue to single matroska audio file\n", meversion);
+  printf("Copyright (C) 2004  Goldenear\n");
+}
+  
+void helpmsg (){
+  // Display a short help
+  fprintf (stderr, "\n Usage: mkaenc -i <inputfile> [options]\n");
+  fprintf (stderr, "\n To display all the options: mkaenc -h\n");
+}
+
+void gplmsg (){
+  // Display licence information
+  printf ("  \n");
+  printf ("  This program is free software; you can redistribute it and/or modify\n");
+  printf ("  it under the terms of the GNU General Public License as published by\n");
+  printf ("  the Free Software Foundation; either version 2 of the License, or any\n");
+  printf ("  later version.\n");
+  printf ("  \n");
+  printf ("  This program is distributed in the hope that it will be useful,\n");
+  printf ("  but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+  printf ("  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n");
+  printf ("  GNU General Public License for more details.\n");
+  printf ("  \n");
+  printf ("  You should have received a copy of the GNU General Public License\n");
+  printf ("  along with this program; if not, write to the Free Software\n");
+  printf ("  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n");
+  printf ("  \n");
+}
+  
+int mbhelp (){
+  // Display the full help
+  printf ("\n Usage: mkaenc -i <inputfile> [options]\n");
+  printf ("\n Optional parameters:\n");
+  printf ("   -s <filename>  Source filename (%%o for EAC)\n");
+  printf ("   -n <naming scheme>  By default \"/a - /t\"\n");
+  printf ("   -p <parameters>  Optional mkvmerge parameters\n");
+  printf ("   -r <command>  Run an external command after merging\n");
+  printf ("   -e <encoder with full path>  By default \"C:\\Program Files\\TTA\\ttaenc.exe\"\n");
+  printf ("   -o <encoder options>  By default \"-e\"\n");
+  printf ("   -x <.extension>  Encoded file extension, by default \".tta\"\n");
+  printf ("   \n");
+  printf ("\n Tags parameters:\n");
+  printf ("   -a <album artist>  Album artist\n");
+  printf ("   -t <album title>  Album title\n");
+  printf ("   -y <album date>  set DATE tag\n");
+  printf ("   -g <album genre>  set GENRE tag\n");
+  printf ("   -d <discID>  set DISCID tag\n");
+  printf ("   -c <comment>  set COMMENT tag\n");
+  printf ("   \n");
+  printf ("\n General options:\n");
+  printf ("   -m  Modify the CUE file (add tags to the CUE sheet)\n");
+  printf ("   -f  Fix EAC CUE file extension\n");
+  printf ("   -j  Join the CUE file as an attachment to the mka file\n");
+  printf ("   -u  Unchange base filename (don't rename the files)\n");
+  printf ("   -w  Don't delete WAV file after encoding\n");
+  printf ("   -k  Don't delete encoded file after merging\n");
+  printf ("   -b  Don't merge, only prepare the base files\n");
+  printf ("   -q  Quiet mode\n");
+  printf ("   -h  Display this help\n");
+  printf ("   -v  Display version\n");
+  printf ("   -l  Display licence informations\n");
+  printf ("   \n");
+  printf ("\n Please report bugs or comments to [email protected]\n");
+  printf ("   \n");
+  return 0;
+}
+
+
+int main (int argc, char **argv) {
+
+  // Initialize the main parameters
+  int wavflag = 0;
+  int keepflag = 0;
+  int mergeflag = 1;
+  int renflag = 1;
+  int cueflag = 0;
+  int eacflag = 0;
+  int attachflag = 0;
+  char *inputfile = NULL;
+  char *basefile = NULL;
+  char *encoder = "TTA";
+  char *encoderopt = NULL;
+  char *encoderext = NULL;
+  char *newfilename = "/a - /t";
+  char *mkvmergeopt = NULL;
+  char *extcommand = NULL;
+  char *albumartist = NULL;
+  char *albumtitle = NULL;
+  char *albumdate = NULL;
+  char *albumgenre = NULL;
+  char *albumdiscid = NULL;
+  char *albumcomment = NULL;
+  
+  // Parse command line parameters
+  if (argc < 2) {
+    mbinfo();
+    helpmsg();
+	pause();
+	return 1;
+  }
+  
+  int mbopt;
+  opterr = 0;
+
+  while ((mbopt = getopt ( argc, argv, "hvlqwkbumfji:s:e:o:x:n:p:r:a:t:y:g:d:c:z")) != -1)
+    switch ( mbopt) {
+      case 'h':
+        mbinfo();
+		mbhelp();
+		return 0;
+        break;
+      case 'l':
+	    mbinfo();
+        gplmsg();
+		return 0;
+        break;
+		case 'v':
+        printf ("\nmkaenc version %s\n", meversion);
+		return 0;
+        break;
+      case 'q':
+        quietflag = 1;
+        break;
+	  case 'w':
+        wavflag = 1;
+        break;
+	  case 'k':
+        keepflag = 1;
+        break;
+	  case 'b':
+        mergeflag = 0;
+        break;
+	  case 'u':
+        renflag = 0;
+        break;
+	  case 'f':
+        eacflag = 1;
+        break;
+      case 'm':
+        cueflag = 1;
+        break;
+	  case 'j':
+        attachflag = 1;
+        break;
+	  case 'i':
+        inputfile = optarg;
+        break;
+      case 's':
+        basefile = optarg;
+        break;
+      case 'e':
+        encoder = optarg;
+        break;
+      case 'o':
+        encoderopt = optarg;
+        break;
+      case 'x':
+        encoderext = optarg;
+        break;
+      case 'n':
+        newfilename = optarg;
+        break;
+      case 'p':
+        mkvmergeopt = optarg;
+        break;
+      case 'r':
+        extcommand = optarg;
+        break;
+      case 'a':
+        albumartist = optarg;
+        break;
+      case 't':
+        albumtitle = optarg;
+        break;
+      case 'y':
+        albumdate = optarg;
+        break;
+      case 'g':
+        albumgenre = optarg;
+        break;
+      case 'd':
+	    if (strlen ( optarg) > 1)
+          albumdiscid = optarg;
+        break;	
+      case 'c':
+        albumcomment = optarg;
+        break;	
+      case 'z':
+	    debugflag = 1;
+        break;	
+      case '?':
+        if (isprint ( optopt)){
+          fprintf (stderr, "\nError: Invalid option `-%c'.\n", optopt);
+		  helpmsg();
+		}
+        else {
+          fprintf (stderr, "\nError: Invalid option character `\\x%x'.\n", optopt);
+		  helpmsg();
+		}
+		pause();
+        return 1;
+      default:
+	    return 1;
+    }
+    
+  /* Start */
+
+  if ( debugflag)
+    quietflag = 0;
+  if (!quietflag)
+    mbinfo();
+  
+  /* Debug mode : display all the parameters */
+
+  if (debugflag) {
+    printf ("\nThe folowing parameters are set:\n");
+	if (quietflag)
+      printf (" quietflag is set\n");
+	if (wavflag)
+      printf (" wavflag is set\n");
+	if (keepflag)
+      printf (" keepflag is set\n");
+	if (mergeflag)
+      printf (" mergeflag is set\n");
+	if (renflag)
+      printf (" renflag is set\n");
+	if (cueflag)
+      printf (" cueflag is set\n");
+	if (eacflag)
+      printf (" eacflag is set\n");
+  	if(inputfile)
+      printf (" inputfile: %s\n", inputfile);
+  	if(basefile)
+      printf (" basefile: %s\n", basefile);
+	if(encoder)
+      printf (" encoder: %s\n", encoder);
+  	if(encoderopt)
+      printf (" encoderopt: %s\n", encoderopt);
+  	if(encoderext)
+      printf (" encoderext: %s\n", encoderext);
+  	if(mkvmergeopt)
+      printf (" mkvmergeopt: %s\n", mkvmergeopt);
+    if(extcommand)
+      printf (" extcommand: %s\n", extcommand);
+  	if(albumartist)
+      printf (" albumartist: %s\n", albumartist);
+  	if(albumtitle)
+      printf (" albumtitle: %s\n", albumtitle);
+  	if(albumdate)
+      printf (" albumdate: %s\n", albumdate);
+  	if(albumgenre)
+      printf (" albumgenre : %s\n", albumgenre);
+  	if(albumdiscid)
+      printf (" albumdiscid: %s\n", albumdiscid);
+  	if(albumcomment)
+      printf (" albumcomment: %s\n", albumcomment);
+  }
+	
+  // Check if all basic options are set
+ 
+  // Check inputfile
+  if (!inputfile) {
+    printf ("\nError: No input file specified!\n");
+	helpmsg();
+	pause();
+	return 1;
+  }
+  
+  // Set encoder
+  int encflag = 1;
+  if (!strcmp(encoder, "TTA")) {
+	  encoder = "C:\\Program Files\\TTA\\ttaenc.exe";
+      if (!encoderopt)
+        encoderopt = "-e";
+      if (!encoderext)
+	    encoderext = ".tta";
+  }
+  else if (!strcmp(encoder, "FLAC")) {
+      encoder = "C:\\Program Files\\FLAC\\flac.exe";
+      if (!encoderopt)
+	    encoderopt = "--best -V";
+      if (!encoderext)
+	    encoderext = ".flac";
+  }
+  else if (!strcmp(encoder, "WAV")) {
+      encflag = 0;
+	  encoder = "";
+	  encoderopt = "";
+	  encoderext = ".wav";
+  }
+  if (!encoderopt)
+    encoderopt = "";
+  if (!encoderext) {
+  fprintf ( stderr,"\nError: Encoded file extension is not set!\n");
+	pause();
+	return 1;
+  }
+  
+  // Generate additional strings
+  
+  // The path to the encoder
+  int encoderpathlen;
+  char *encoderpath;
+  if (strrchr( encoder, '\\')){
+    encoderpathlen = strrchr( encoder, '\\') - encoder + 1;
+	if ((encoderpath = calloc( encoderpathlen, sizeof(char))))
+	  strncat( encoderpath, encoder, encoderpathlen);
+	else {
+	  fprintf(stderr, "\nError: Out of memory for encoderpath!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  else {
+  encoderpath = "";
+  }
+  if (debugflag)
+    printf (" encoderpath: %s\n", encoderpath);
+
+  // Find the encoder command name
+  int encoderexelen = strlen( encoder) - strlen( encoderpath) + 1;
+  char *encoderexe;
+  if ((encoderexe = calloc( encoderexelen, sizeof(char)))){
+    for (i = strlen( encoderpath); i < strlen( encoder); i++)
+      encoderexe[i - strlen( encoderpath)] = encoder[i];
+    if (debugflag)
+      printf (" encoderexe: %s\n", encoderexe);
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for encoderexe!\n");
+	pause();
+	return 1;
+  }
+	
+  // Path where the files are created
+  int rippathlen;
+  char *rippath;
+  if (strrchr( inputfile, '\\')) {
+    rippathlen = strrchr( inputfile, '\\') - inputfile + 1;
+    if ((rippath = calloc( rippathlen, sizeof(char))))
+	  strncat( rippath, inputfile, rippathlen);
+	else {
+	  fprintf(stderr, "\nError: Out of memory for rippath!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  else {
+	rippath = "";
+  }
+  if (debugflag)
+    printf (" rippath: %s\n", rippath);
+	
+  // The base file name
+  if (!basefile) {
+    int basefilelen = strlen( inputfile) - strlen( rippath) + 1;
+    if ((basefile = calloc( basefilelen, sizeof(char)))){
+      for (i = strlen( rippath); i <= strlen( inputfile); i++)
+        basefile[i - strlen( rippath)] = inputfile[i];
+    }
+    else {
+	  fprintf(stderr, "\nError: Out of memory for basefile!\n");
+	  pause();
+	  return 1;
+    }
+  }
+  char *basefilename;
+  basefilename = strtok( basefile, ".");
+  
+  // The CUE file name
+  char cuefileext[10] = "";
+  if (eacflag)
+    strcat( cuefileext, ".mka.cue");
+  else
+    strcat( cuefileext, ".cue");
+  char *cuefilename;
+  if ((cuefilename = calloc( strlen( rippath) + strlen( basefilename) + strlen( cuefileext) + 1, sizeof(char)))){
+    strcat( cuefilename, rippath);
+    strcat( cuefilename, basefilename);
+    strcat( cuefilename, cuefileext);
+    if (debugflag)
+      printf (" cuefilename: %s\n", cuefilename);
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for cuefilename!\n");
+	pause();
+	return 1;
+  }
+  
+  // Set ARTIST and TITLE tags
+  FILE *cuefile;
+  cuefile = fopen( cuefilename,"r");
+  if (!cuefile) {
+    fprintf ( stderr,"\nUnable to open \" %s \".\n", cuefilename);
+	pause();
+    return 1;
+  }
+  char cueinfo[1024];
+  if (!albumartist) {
+    int q =0;
+	fseek( cuefile, 0, SEEK_SET);
+    while ((fgets( cueinfo,1024, cuefile) != NULL) && q != 1) {
+      if (strstr( cueinfo,"PERFORMER \"")) {
+        unsigned int startchr = strchr(cueinfo,'\"') - cueinfo + 1;
+        unsigned int endchr = strrchr(cueinfo,'\"') - cueinfo;
+	    if ((albumartist = calloc( endchr - startchr + 1, sizeof(char)))){
+	      for ( i = startchr; i < endchr; i++)
+	        albumartist[i - startchr] = cueinfo[i];
+	    }
+	    else {
+	      fprintf(stderr, "\nError: Out of memory for albumartist0!\n");
+		  pause();
+	      return 1;
+	    }
+	    q = 1;
+      }
+	}
+    printf (" albumartist: %s\n", albumartist);
+  }
+  if (!albumtitle) {
+    int q =0;
+	fseek( cuefile, 0, SEEK_SET);
+    while ((fgets( cueinfo,1024, cuefile) != NULL) && q != 1) {
+      if (strstr( cueinfo,"TITLE \"")) {
+        unsigned int startchr = strchr(cueinfo,'\"') - cueinfo + 1;
+        unsigned int endchr = strrchr(cueinfo,'\"') - cueinfo;
+	    if ((albumtitle = calloc( endchr - startchr + 1, sizeof(char)))){
+	      for ( i = startchr; i < endchr; i++)
+	        albumtitle[i - startchr] = cueinfo[i];
+	    }
+	    else {
+	      fprintf(stderr, "\nError: Out of memory for albumtitle!\n");
+		  pause();
+	      return 1;
+	    }
+	    q = 1;
+      }
+	}
+    printf (" albumtitle: %s\n", albumtitle);
+  }
+  fclose( cuefile);
+  
+  if (!albumartist)
+    albumartist = "";
+  if (!albumtitle)
+    albumtitle = "";
+  
+  if (!strcmp( albumartist, "various") || !strcmp( albumartist, "Various") || !strcmp( albumartist, "VARIOUS")) {
+    if ((tmp = realloc( albumartist,16 * sizeof(char))) == NULL) {
+      fprintf(stderr, "\nError: Out of memory for albumartist1!\n");
+	  pause();
+	  return 1;
+	}
+	else {
+      albumartist = "Various Artists";
+	}
+  }
+  
+  // Reformat the base file name
+  int newbasenamelen;
+  char *newbasename;
+  if (renflag) {
+    newbasenamelen = 512;
+	if ((newbasename = calloc( newbasenamelen, sizeof(char)))){
+	  for (i = 0; i < strlen( newfilename); i++){
+	    if (newfilename[i] != '/'){
+		  if ((tmp = realloc( newbasename, (strlen( newbasename) + 2) * sizeof(char))) == NULL) {
+           fprintf(stderr, "\nError: Out of memory for newbasename/albumartist0!\n");
+			pause();
+			return 1;
+		  }
+		  else {
+            char tmpchr[] = {newfilename[i],'\0'};
+            strcat ( newbasename, tmpchr);
+		  }
+        }
+        else {
+          i++;
+          switch (newfilename[i]) {
+		    case 'a':
+		      if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumartist) + 1) * sizeof(char))) == NULL) {
+                fprintf(stderr, "\nError: Out of memory for newbasename/albumartist1!\n");
+				pause();
+			    return 1;
+			  }
+			  else
+			    strcat ( newbasename, albumartist);
+	          break;
+            case 't':
+		      if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumtitle) + 1) * sizeof(char))) == NULL) {
+			    fprintf(stderr, "\nError: Out of memory for newbasename/albumtitle!\n");
+				pause();
+			    return 1;
+			  }
+			  else
+                strcat ( newbasename, albumtitle);
+	          break;
+            case 'y':
+		      if (albumdate) {
+			    if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumdate) + 1) * sizeof(char))) == NULL) {
+			      fprintf(stderr, "\nError: Out of memory for newbasename/albumdate!\n");
+				  pause();
+				  return 1;
+			    }
+			    else
+                  strcat ( newbasename, albumdate);
+			  }
+			  break;
+            case 'g':
+		      if (albumgenre) {
+                if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumgenre) + 1) * sizeof(char))) == NULL) {
+			      fprintf(stderr, "\nError: Out of memory for newbasename/albumgenre!\n");
+				  pause();
+				  return 1;
+			    }
+			    else
+			      strcat ( newbasename, albumgenre);
+			  }
+			  break;
+            case 'd':
+		      if (albumdiscid) {
+                if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumdiscid) + 1) * sizeof(char))) == NULL) {
+			      fprintf(stderr, "\nError: Out of memory for newbasename/albumdiscid!\n");
+				  pause();
+				  return 1;
+			    }
+			    else
+			      strcat ( newbasename, albumdiscid);
+	          }
+			  break;
+            case 'c':
+		      if (albumcomment) {
+                if ((tmp = realloc( newbasename, (strlen( newbasename) + strlen( albumcomment) + 1) * sizeof(char))) == NULL) {
+			      fprintf(stderr, "\nError: Out of memory for newbasename/albumcomment!\n");
+			      pause();
+				  return 1;
+			    }
+			    else
+			      strcat ( newbasename, albumcomment);
+			  }
+	          break;
+            default:
+              strcat ( newbasename, "");
+          }
+        }
+      }
+	  if ((tmp = realloc( newbasename, (strlen( newbasename) + 1) * sizeof(char))) == NULL) {
+	    fprintf(stderr, "\nError: Out of memory for newbasename0!\n");
+		pause();
+		return 1;
+	  }
+	  char badchr[] = "\"*/:<>\?|";
+      for (i = 0; i < strlen( newbasename); i++){
+        if (strchr( badchr, newbasename[i]))
+	      if (i != 1 || newbasename[i] != ':')
+            newbasename[i] = '_';
+      }
+      if (strlen( newbasename) < 1) {
+	    if ((tmp = realloc( newbasename, (strlen( basefilename) + 1) * sizeof(char))) == NULL) {
+		  fprintf(stderr, "\nError: Out of memory for newbasename0!\n");
+		  pause();
+		  return 1;
+		}
+		else
+		  strcpy ( newbasename, basefilename);
+	  }
+	}
+	else {
+	  fprintf(stderr, "\nError: Out of memory for newbasename1!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  else {
+    if (!(newbasename = calloc(strlen( basefilename) + 1, sizeof(char)))){
+	  fprintf(stderr, "\nError: Out of memory for newbasename2!\n");
+	  pause();
+	  return 1;
+	}
+	else
+	  strcpy ( newbasename, basefilename);
+  }
+  int mkapathlen;
+  char *mkapath;
+  if (strrchr( newbasename, '\\')) {
+    mkapathlen = strrchr( newbasename, '\\') - newbasename + 1;
+    if ((mkapath = calloc( mkapathlen, sizeof(char))))
+	  strncat( mkapath, newbasename, mkapathlen);
+	else {
+	  fprintf(stderr, "\nError: Out of memory for mkapath!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  else {
+	mkapath = "";
+  }
+  if (debugflag)
+    printf (" mkapath: %s\n", mkapath);
+  
+  int newbasefilenamelen = strlen( newbasename) - strlen( mkapath) +1;
+  char *newbasefilename;
+  if ((newbasefilename = calloc( newbasefilenamelen, sizeof(char)))){
+    for (i = strlen( mkapath); i <= strlen( newbasename); i++)
+      newbasefilename[i - strlen( mkapath)] = newbasename[i];
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for newbasefilename!\n");
+	pause();
+	return 1;
+  }
+  
+  free( newbasename);
+  
+  // Encoded file name
+  int encodedfilenamelen = strlen( rippath) + strlen( newbasefilename) + strlen( encoderext) + 1;
+  char *encodedfilename;
+  if ((encodedfilename = calloc( encodedfilenamelen, sizeof(char)))){
+    strcat( encodedfilename, rippath);
+    strcat( encodedfilename, newbasefilename);
+    strcat( encodedfilename, encoderext);
+    if (debugflag)
+      printf (" encodedfilename: %s\n", encodedfilename);
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for encodedfilename!\n");
+	pause();
+	return 1;
+  }
+  
+  // Check if everythink is correctly set
+  if (!fexists( inputfile)){
+    fprintf ( stderr,"\nError: Unable to find inputfile: \"%s\".\n", inputfile);
+	pause();
+	return 1;
+  }
+  if (!fexists( cuefilename)){
+    fprintf ( stderr,"\nError: Unable to find cuefile: \"%s\".\n", cuefilename);
+	pause();
+	return 1;
+  }
+  if (!fexists( encoder) && strlen( encoder) > 0){
+    fprintf ( stderr,"\nError: Unable to find encoder: \"%s\".\n", encoder);
+	pause();
+	return 1;
+  }
+  if (!fexists( "mkvmerge.exe")){
+    fprintf ( stderr,"\nError: Unable to find mkvmerge!\n");
+	pause();
+	return 1;
+  }
+  if (debugflag) {
+    printf ("\nAll necessary files found: OK!\n");
+	pause();
+  }
+  	
+  // Create the destination path
+  char runpath[_MAX_DIR]; 
+  _getcwd (runpath, _MAX_DIR);
+  if (strlen( mkapath) != 0)
+    mkpath( mkapath);
+  if (chdir( runpath)){
+    fprintf ( stderr,"Error: Can't access to \"%s\"", runpath);
+	pause();
+	return 1;
+  }
+  
+  // Process the CUE sheet
+  if (debugflag) {
+    printf ("\nThe CUE file \"%s\" will be processed ...\n", cuefilename);
+	pause();
+  }
+  
+  int newcuefilenamelen = strlen( rippath) + strlen( newbasefilename) + 5;
+  char *newcuefilename;
+  if ((newcuefilename = calloc( newcuefilenamelen, sizeof(char)))){
+    strcat( newcuefilename, rippath);
+    strcat( newcuefilename, newbasefilename);
+    strcat( newcuefilename, ".cue");
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for newcuefilename!\n");
+	pause();
+	return 1;
+  }
+  
+  // Open original CUE file and create the new one
+  cuefile = fopen( cuefilename,"r");
+  if (!cuefile) {
+    fprintf ( stderr,"\nUnable to open \"%s\".\n", cuefilename);
+	pause();
+    return 1;
+  }
+  FILE *newcuefile;
+  newcuefile = fopen( newcuefilename,"a+");
+  if (!newcuefile) {
+    fprintf ( stderr,"\nUnable to create \"%s\".\n", newcuefilename);
+	pause();
+    return 1;
+  }
+	
+  // Write CUE informations to the new CUE file
+  if (!quietflag)
+    printf ("\nWriting modified CUE sheet: ");
+  int q = 0;
+  fseek( cuefile, 0, SEEK_SET);
+  while ( fgets( cueinfo,1024, cuefile) != NULL ) {
+    if (!strcmp( albumartist,"Various Artists") && strstr( cueinfo,"PERFORMER \"") && q !=1) {
+	  printf ("PERFORMER \"Various Artists\"\n");
+	  fprintf ( newcuefile,"PERFORMER \"Various Artists\"\n");
+	  q = 1;
+	}
+    else if (strstr( cueinfo,"FILE \"")){
+	  if (albumdate && cueflag)
+        fprintf ( newcuefile,"REM DATE %s\n", albumdate);
+	  if (albumgenre && cueflag)
+        fprintf ( newcuefile,"REM GENRE %s\n", albumgenre);
+	  if (albumdiscid && cueflag)
+        fprintf ( newcuefile,"REM DISCID %s\n", albumdiscid);
+	  if (albumcomment && cueflag)
+        fprintf ( newcuefile,"REM COMMENT %s\n", albumcomment);
+      fprintf ( newcuefile,"FILE \"%s - %s%s\" WAVE\n", albumartist, albumtitle, encoderext);
+    }
+    else
+      fprintf ( newcuefile,"%s", cueinfo);
+  }
+  
+  // Close the CUE files and delete the old one
+  if (!fclose( cuefile) && !fclose( newcuefile)){
+    if (!remove( cuefilename)){
+	  if (!quietflag)
+	    printf ("Done.\n");
+    }
+	else {
+      fprintf ( stderr,"Error writing CUE!");
+	  pause();
+	  return 1;
+    }
+	free( cuefilename);
+  }
+  
+  // Rename the wav file
+  if (debugflag) {
+    printf ("\nThe WAV file \"%s\" will be renamed ...\n", inputfile);
+	pause();
+  }
+  if (!quietflag)
+    printf ("\nRenaming wav file: ");
+  
+  int wavefilelen = strlen( rippath) + strlen( newbasefilename) + 5;
+  char *wavfile;
+  if ((wavfile = calloc( wavefilelen, sizeof(char)))){
+    strcat( wavfile, rippath);
+    strcat( wavfile, newbasefilename);
+    strcat( wavfile, ".wav");
+    if (rename( inputfile, wavfile)){
+      fprintf ( stderr, "Error: Unable to rename the wav file!\n");
+	  pause();
+      return 1;
+    }
+    else
+      if (!quietflag)
+        printf ("Done, the WAV file is now \"%s\".\n", wavfile);
+  }
+  else {
+	fprintf(stderr, "\nError: Out of memory for wavfile!\n");
+	pause();
+	return 1;
+  }
+  
+  // Set the path
+  if (encflag && strlen( encoderpath) > 0) {
+    if (!quietflag)
+      printf ("\nSetting the encoder path ...\n");
+    char *envpath;
+    envpath = getenv("Path");
+    char *newpath;
+    if ((newpath = calloc(strlen( envpath) + strlen (encoderpath) + 8, sizeof(char)))){
+      strcat( newpath, "Path=");
+      strcat( newpath, envpath);
+      if (envpath[strlen( envpath) - 1] != ';')
+        strcat( newpath, ";");
+      strncat( newpath, encoderpath, strlen(encoderpath) - 1);
+      free( encoderpath);
+      putenv( newpath);
+      if (debugflag)
+        printf ("\n%s\n", newpath);
+      free( newpath);
+    }
+    else {
+	  fprintf(stderr, "\nError: Out of memory for newpath!\n");
+	  pause();
+	  return 1;
+    }
+  }
+  
+  // Encode using external encoder
+  if (encflag) {
+    if (chdir( rippath)){
+      fprintf ( stderr,"Error: Can't access to \"%s\"", rippath);
+      pause();
+	  return 1;
+    }
+    
+    if (!wavflag || mergeflag) {
+      char *commandline;
+	  if ((commandline = calloc( encoderexelen + strlen(encoderopt) + strlen( wavfile) + 5, sizeof(char)))){
+        strcat( commandline, encoderexe);
+        strcat( commandline, " ");
+        strcat( commandline, encoderopt);
+        strcat( commandline, " \"");
+        strcat( commandline, wavfile);
+        strcat( commandline, "\"");
+        free( encoderexe);
+        if (!quietflag)
+          printf ("\nEncoding WAV file to \"%s%s\".\n", newbasefilename, encoderext);
+        if (debugflag) {
+          printf ("\nNext command-line to be executed:\n%s\n", commandline);
+          pause();
+        }
+        if (!system ( commandline)) {
+	      if (!quietflag)
+            printf ("\nEncoding done.\n");
+        }
+	    else {
+          fprintf ( stderr,"\nError: Unable to encode!\n");
+	      pause();
+          return 1;
+	    }
+        free( commandline);
+      }
+	  else {
+	    fprintf(stderr, "\nError: Out of memory for commandline!\n");
+		pause();
+	    return 1;
+	  }
+    }
+  
+    if (chdir( runpath)) {
+      fprintf ( stderr,"Error: Can't access to \"%s\"", runpath);
+	  pause();
+	  return 1;
+    }
+  }
+  
+  // Delete the WAV file
+  if (!wavflag && encflag) {
+    if (!quietflag)
+      printf ("\nDeleting WAV file:\n");
+	if (!quietflag)
+      printf (" %s ", wavfile);
+    if (!remove( wavfile)) {
+	  if (!quietflag)
+	    printf ("deleted.\n");
+	}
+	else
+	  fprintf ( stderr,"\nWarning: Can't delete WAV file!\n");
+  }
+  free( wavfile);
+  
+  // Merge the files
+  if (mergeflag) {
+    if (!quietflag)
+      printf ("\nStart merging to \"%s.mka\".\n\n", newbasefilename);
+    int mergecmdlen;
+    if (mkvmergeopt)
+      mergecmdlen = strlen( rippath) + strlen( newbasefilename) + strlen( mkapath) + strlen( encodedfilename) + (strlen( newcuefilename) * 2) + strlen(mkvmergeopt) + 256;
+    else
+      mergecmdlen = strlen( rippath) + strlen( newbasefilename) + strlen( encodedfilename) + (strlen( newcuefilename) * 2) + 256;
+    char *mergecmd;
+	if ((mergecmd = calloc( mergecmdlen, sizeof(char)))){
+      strcat( mergecmd, "mkvmerge -o \"");
+      if (strlen( mkapath) == 0)
+        strcat( mergecmd, rippath);
+      else
+        strcat( mergecmd, mkapath);
+      strcat( mergecmd, newbasefilename);
+      strcat( mergecmd,".mka\" --command-line-charset UTF-8 -D -S \"");
+      strcat( mergecmd, encodedfilename);
+	  if (!attachflag) {
+        strcat( mergecmd,"\" --attachment-mime-type text/plain --attach-file \"");
+        strcat( mergecmd, newcuefilename);
+	  }
+      strcat( mergecmd,"\" --chapters \"");
+      strcat( mergecmd, newcuefilename);
+      strcat( mergecmd,"\"");
+      if (mkvmergeopt) {
+        strcat( mergecmd," ");
+        strcat( mergecmd, mkvmergeopt);
+      }
+      free( rippath);
+      free( newbasefilename);
+	  free( mkapath);
+      if (debugflag) {
+        printf ("\nNext command-line to be executed:\n%s\n", mergecmd);
+        pause();
+      }
+      if (!system ( mergecmd))
+        printf ("\nMerge done.\n");
+      else {
+        fprintf ( stderr,"\nError: Unable to merge!\n");
+	    pause();
+	    return 1;
+      }
+	  free( mergecmd);
+    }
+	else {
+	  fprintf(stderr, "\nError: Out of memory for mergecmd!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  
+  // Cleaning
+  if (!quietflag)
+    printf ("\nDeleting temporary files:\n");
+	if (!keepflag || (!wavflag && !mergeflag)) {
+	  if (!quietflag)
+        printf (" %s ", encodedfilename);
+      if (!remove( encodedfilename)) {
+	    if (!quietflag)
+	      printf ("deleted.\n");
+	  }
+	  else
+	    fprintf ( stderr,"\nWarning: Can't delete encoded file!\n");
+	}
+    if (!keepflag || !mergeflag) {
+	  if (!quietflag)
+        printf (" %s ", newcuefilename);
+	  if (!remove( newcuefilename)) {
+	    if (!quietflag)
+	      printf ("deleted.\n");
+	  }
+	  else
+	    fprintf ( stderr,"\nWarning: Can't delete CUE file!\n");
+    }
+  free( encodedfilename);
+  free( newcuefilename);
+  
+  // Run extarnal command
+  if (extcommand) {
+    if (!quietflag)
+	  printf ("\nRunning external command ...\n");
+	if (debugflag) {
+	  printf ("%s\n", extcommand);
+	  pause();
+	}
+	if (system ( extcommand)) {
+      fprintf ( stderr,"\nExternal command error!\n");
+	  pause();
+	  return 1;
+	}
+  }
+  
+  // Terminating
+  if (!quietflag)
+    printf ("\nAll done!\n");
+  if (debugflag)
+    pause();
+  return 0;
+}

Added: trunk/mkaencoder/src/mkaenc.h
===================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.