<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>libburn: libburner.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>libburner.c</h1><a href="libburner_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00002"></a>00002 <span class="comment">/* test/libburner.c , API illustration of burning data or audio tracks to CD */</span> <a name="l00003"></a>00003 <span class="comment">/* Copyright (C) 2005 - 2009 Thomas Schmitt <scdbackup@gmx.net> */</span> <a name="l00004"></a>00004 <span class="comment">/* Provided under GPLv2,see also "License and copyright aspects" at file end */</span> <a name="l00005"></a>00005 <a name="l00006"></a>00006 <span class="comment"></span> <a name="l00007"></a>00007 <span class="comment">/** Overview </span> <a name="l00008"></a>00008 <span class="comment"> </span> <a name="l00009"></a>00009 <span class="comment"> libburner is a minimal demo application for the library libburn as provided</span> <a name="l00010"></a>00010 <span class="comment"> on http://libburnia-project.org . It can list the available devices, can</span> <a name="l00011"></a>00011 <span class="comment"> blank a CD-RW or DVD-RW, can format DVD-RW and BD, can burn to CD-R,</span> <a name="l00012"></a>00012 <span class="comment"> CD-RW, DVD-R, DVD+R, DVD+R/DL, DVD+RW, DVD-RW, DVD-RAM, BD-R, BD-RE. </span> <a name="l00013"></a>00013 <span class="comment"> Not supported yet: DVD-R/DL.</span> <a name="l00014"></a>00014 <span class="comment"></span> <a name="l00015"></a>00015 <span class="comment"> It's main purpose, nevertheless, is to show you how to use libburn and also</span> <a name="l00016"></a>00016 <span class="comment"> to serve the libburnia team as reference application. libburner.c does indeed</span> <a name="l00017"></a>00017 <span class="comment"> define the standard way how above three gestures can be implemented and</span> <a name="l00018"></a>00018 <span class="comment"> stay upward compatible for a good while.</span> <a name="l00019"></a>00019 <span class="comment"> </span> <a name="l00020"></a>00020 <span class="comment"> Before you can do anything, you have to initialize libburn by</span> <a name="l00021"></a>00021 <span class="comment"> burn_initialize()</span> <a name="l00022"></a>00022 <span class="comment"> and provide some signal and abort handling, e.g. by the builtin handler, by</span> <a name="l00023"></a>00023 <span class="comment"> burn_set_signal_handling() </span> <a name="l00024"></a>00024 <span class="comment"> as it is done in main() at the end of this file. Then you aquire a</span> <a name="l00025"></a>00025 <span class="comment"> drive in an appropriate way conforming to the API. The two main</span> <a name="l00026"></a>00026 <span class="comment"> approaches are shown here in application functions:</span> <a name="l00027"></a>00027 <span class="comment"> libburner_aquire_by_adr() demonstrates usage as of cdrecord traditions</span> <a name="l00028"></a>00028 <span class="comment"> libburner_aquire_by_driveno() demonstrates a scan-and-choose approach</span> <a name="l00029"></a>00029 <span class="comment"> With that aquired drive you can blank a CD-RW</span> <a name="l00030"></a>00030 <span class="comment"> libburner_blank_disc()</span> <a name="l00031"></a>00031 <span class="comment"> or you can format a DVD-RW to profile "Restricted Overwrite" (needed once)</span> <a name="l00032"></a>00032 <span class="comment"> or an unused BD to default size with spare blocks</span> <a name="l00033"></a>00033 <span class="comment"> libburner_format()</span> <a name="l00034"></a>00034 <span class="comment"> With the aquired drive you can burn to CD, DVD, BD</span> <a name="l00035"></a>00035 <span class="comment"> libburner_payload()</span> <a name="l00036"></a>00036 <span class="comment"> When everything is done, main() releases the drive and shuts down libburn:</span> <a name="l00037"></a>00037 <span class="comment"> burn_drive_release();</span> <a name="l00038"></a>00038 <span class="comment"> burn_finish()</span> <a name="l00039"></a>00039 <span class="comment"> </span> <a name="l00040"></a>00040 <span class="comment">*/</span> <a name="l00041"></a>00041 <span class="comment"></span> <a name="l00042"></a>00042 <span class="comment">/** See this for the decisive API specs . libburn.h is The Original */</span> <a name="l00043"></a>00043 <span class="comment">/* For using the installed header file : #include <libburn/libburn.h> */</span> <a name="l00044"></a>00044 <span class="comment">/* This program insists in the own headerfile. */</span> <a name="l00045"></a>00045 <span class="preprocessor">#include "../libburn/libburn.h"</span> <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">/* libburn is intended for Linux systems with kernel 2.4 or 2.6 for now */</span> <a name="l00048"></a>00048 <span class="preprocessor">#include <stdio.h></span> <a name="l00049"></a>00049 <span class="preprocessor">#include <ctype.h></span> <a name="l00050"></a>00050 <span class="preprocessor">#include <sys/types.h></span> <a name="l00051"></a>00051 <span class="preprocessor">#include <unistd.h></span> <a name="l00052"></a>00052 <span class="preprocessor">#include <string.h></span> <a name="l00053"></a>00053 <span class="preprocessor">#include <stdlib.h></span> <a name="l00054"></a>00054 <span class="preprocessor">#include <time.h></span> <a name="l00055"></a>00055 <span class="preprocessor">#include <errno.h></span> <a name="l00056"></a>00056 <span class="preprocessor">#include <sys/stat.h></span> <a name="l00057"></a>00057 <span class="preprocessor">#include <fcntl.h></span> <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="comment"></span> <a name="l00060"></a>00060 <span class="comment">/** For simplicity i use global variables to represent the drives.</span> <a name="l00061"></a>00061 <span class="comment"> Drives are systemwide global, so we do not give away much of good style.</span> <a name="l00062"></a>00062 <span class="comment">*/</span> <a name="l00063"></a>00063 <span class="comment"></span> <a name="l00064"></a>00064 <span class="comment">/** This list will hold the drives known to libburn. This might be all CD</span> <a name="l00065"></a>00065 <span class="comment"> drives of the system and thus might impose severe impact on the system.</span> <a name="l00066"></a>00066 <span class="comment">*/</span> <a name="l00067"></a><a class="code" href="libburner_8c.html#a271c6b9f59f56d3ac45a173461f3eeba">00067</a> <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structburn__drive__info.html" title="Information on a drive in the system.">burn_drive_info</a> *<a class="code" href="libburner_8c.html#a271c6b9f59f56d3ac45a173461f3eeba" title="Overview.">drive_list</a>; <a name="l00068"></a>00068 <span class="comment"></span> <a name="l00069"></a>00069 <span class="comment">/** If you start a long lasting operation with drive_count > 1 then you are</span> <a name="l00070"></a>00070 <span class="comment"> not friendly to the users of other drives on those systems. Beware. */</span> <a name="l00071"></a><a class="code" href="libburner_8c.html#a2ab10011f756aef24f3168d95a5b439b">00071</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a2ab10011f756aef24f3168d95a5b439b" title="If you start a long lasting operation with drive_count &gt; 1 then you are not friendly...">drive_count</a>; <a name="l00072"></a>00072 <span class="comment"></span> <a name="l00073"></a>00073 <span class="comment">/** This variable indicates wether the drive is grabbed and must be</span> <a name="l00074"></a>00074 <span class="comment"> finally released */</span> <a name="l00075"></a><a class="code" href="libburner_8c.html#aaee536e445f55d19bfeb431850ec90e4">00075</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#aaee536e445f55d19bfeb431850ec90e4" title="This variable indicates wether the drive is grabbed and must be finally released...">drive_is_grabbed</a> = 0; <a name="l00076"></a>00076 <span class="comment"></span> <a name="l00077"></a>00077 <span class="comment">/** A number and a text describing the type of media in aquired drive */</span> <a name="l00078"></a><a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043">00078</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a>= -1; <a name="l00079"></a><a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">00079</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>[80]= {<span class="stringliteral">""</span>}; <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">/* Some in-advance definitions to allow a more comprehensive ordering</span> <a name="l00083"></a>00083 <span class="comment"> of the functions and their explanations in here */</span> <a name="l00084"></a>00084 <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a3ed4822421dfb49c359b85accd952b56" title="If the persistent drive address is known, then this approach is much more un-obtrusive...">libburner_aquire_by_adr</a>(<span class="keywordtype">char</span> *<a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>); <a name="l00085"></a>00085 <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#aa2de071d4fb803b4a171dbc8dc14be5c" title="This method demonstrates how to use libburn without knowing a persistent drive address...">libburner_aquire_by_driveno</a>(<span class="keywordtype">int</span> *drive_no); <a name="l00086"></a>00086 <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="comment">/* ------------------------------- API gestures ---------------------------- */</span> <a name="l00089"></a>00089 <span class="comment"></span> <a name="l00090"></a>00090 <span class="comment">/** You need to aquire a drive before burning. The API offers this as one</span> <a name="l00091"></a>00091 <span class="comment"> compact call and alternatively as application controllable gestures of</span> <a name="l00092"></a>00092 <span class="comment"> whitelisting, scanning for drives and finally grabbing one of them.</span> <a name="l00093"></a>00093 <span class="comment"></span> <a name="l00094"></a>00094 <span class="comment"> If you have a persistent address of the drive, then the compact call is</span> <a name="l00095"></a>00095 <span class="comment"> to prefer because it only touches one drive. On modern Linux kernels,</span> <a name="l00096"></a>00096 <span class="comment"> there should be no fatal disturbance of ongoing burns of other libburn</span> <a name="l00097"></a>00097 <span class="comment"> instances with any of our approaches. We use open(O_EXCL) by default.</span> <a name="l00098"></a>00098 <span class="comment"> On /dev/hdX it should cooperate with growisofs and some cdrecord variants.</span> <a name="l00099"></a>00099 <span class="comment"> On /dev/sgN versus /dev/scdM expect it not to respect other programs.</span> <a name="l00100"></a>00100 <span class="comment">*/</span> <a name="l00101"></a><a class="code" href="libburner_8c.html#ab485e1b9ba9572fb7596ffa6d6ff67c7">00101</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#ab485e1b9ba9572fb7596ffa6d6ff67c7" title="You need to aquire a drive before burning.">libburner_aquire_drive</a>(<span class="keywordtype">char</span> *<a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>, <span class="keywordtype">int</span> *<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 <span class="keywordtype">int</span> ret; <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="keywordflow">if</span>(drive_adr != NULL && drive_adr[0] != 0) <a name="l00106"></a>00106 ret = <a class="code" href="libburner_8c.html#a3ed4822421dfb49c359b85accd952b56" title="If the persistent drive address is known, then this approach is much more un-obtrusive...">libburner_aquire_by_adr</a>(drive_adr); <a name="l00107"></a>00107 <span class="keywordflow">else</span> <a name="l00108"></a>00108 ret = <a class="code" href="libburner_8c.html#aa2de071d4fb803b4a171dbc8dc14be5c" title="This method demonstrates how to use libburn without knowing a persistent drive address...">libburner_aquire_by_driveno</a>(driveno); <a name="l00109"></a>00109 <span class="keywordflow">if</span> (ret <= 0 || *driveno <= 0) <a name="l00110"></a>00110 <span class="keywordflow">return</span> ret; <a name="l00111"></a>00111 <a class="code" href="libburn_8h.html#a1627c70c71ec5b6116f8d9d63d229285" title="Tells the MMC Profile identifier of the loaded media.">burn_disc_get_profile</a>(drive_list[0].<a class="code" href="structburn__drive__info.html#aa53408d48157a07e48b114e6c95550d0" title="The value by which this drive can be indexed when using functions in the library...">drive</a>, &<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a>, <a name="l00112"></a>00112 <a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>); <a name="l00113"></a>00113 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>[0]) <a name="l00114"></a>00114 printf(<span class="stringliteral">"Detected media type: %s\n"</span>, <a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>); <a name="l00115"></a>00115 <span class="keywordflow">return</span> 1; <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="comment"></span> <a name="l00119"></a>00119 <span class="comment">/** If the persistent drive address is known, then this approach is much</span> <a name="l00120"></a>00120 <span class="comment"> more un-obtrusive to the systemwide livestock of drives. Only the</span> <a name="l00121"></a>00121 <span class="comment"> given drive device will be opened during this procedure.</span> <a name="l00122"></a>00122 <span class="comment">*/</span> <a name="l00123"></a><a class="code" href="libburner_8c.html#a3ed4822421dfb49c359b85accd952b56">00123</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a3ed4822421dfb49c359b85accd952b56" title="If the persistent drive address is known, then this approach is much more un-obtrusive...">libburner_aquire_by_adr</a>(<span class="keywordtype">char</span> *<a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>) <a name="l00124"></a>00124 { <a name="l00125"></a>00125 <span class="keywordtype">int</span> ret; <a name="l00126"></a>00126 <span class="keywordtype">char</span> libburn_drive_adr[<a class="code" href="libburn_8h.html#a489ca2111726a034324275aca4ed069c" title="Maximum length+1 to expect with a persistent drive address string.">BURN_DRIVE_ADR_LEN</a>]; <a name="l00127"></a>00127 <a name="l00128"></a>00128 <span class="comment">/* Some not-so-harmless drive addresses get blocked in this demo */</span> <a name="l00129"></a>00129 <span class="keywordflow">if</span> (strncmp(drive_adr, <span class="stringliteral">"stdio:/dev/fd/"</span>, 14) == 0 || <a name="l00130"></a>00130 strcmp(drive_adr, <span class="stringliteral">"stdio:-"</span>) == 0) { <a name="l00131"></a>00131 fprintf(stderr, <span class="stringliteral">"Will not work with pseudo-drive '%s'\n"</span>, <a name="l00132"></a>00132 drive_adr); <a name="l00133"></a>00133 <span class="keywordflow">return</span> 0; <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="comment">/* This tries to resolve links or alternative device files */</span> <a name="l00137"></a>00137 ret = <a class="code" href="libburn_8h.html#a1b0e38d691eeb1da5f34a6ef0cc052bc" title="Try to convert a given existing filesystem address into a persistent drive address...">burn_drive_convert_fs_adr</a>(drive_adr, libburn_drive_adr); <a name="l00138"></a>00138 <span class="keywordflow">if</span> (ret<=0) { <a name="l00139"></a>00139 fprintf(stderr, <span class="stringliteral">"Address does not lead to a CD burner: '%s'\n"</span>, <a name="l00140"></a>00140 drive_adr); <a name="l00141"></a>00141 <span class="keywordflow">return</span> 0; <a name="l00142"></a>00142 } <a name="l00143"></a>00143 fprintf(stderr,<span class="stringliteral">"Aquiring drive '%s' ...\n"</span>, libburn_drive_adr); <a name="l00144"></a>00144 ret = <a class="code" href="libburn_8h.html#ae9c75e892e445ff73c38579210ba06a9" title="Aquire a drive with known persistent address.">burn_drive_scan_and_grab</a>(&drive_list, libburn_drive_adr, 1); <a name="l00145"></a>00145 <span class="keywordflow">if</span> (ret <= 0) { <a name="l00146"></a>00146 fprintf(stderr,<span class="stringliteral">"FAILURE with persistent drive address '%s'\n"</span>, <a name="l00147"></a>00147 libburn_drive_adr); <a name="l00148"></a>00148 } <span class="keywordflow">else</span> { <a name="l00149"></a>00149 fprintf(stderr,<span class="stringliteral">"Done\n"</span>); <a name="l00150"></a>00150 <a class="code" href="libburner_8c.html#aaee536e445f55d19bfeb431850ec90e4" title="This variable indicates wether the drive is grabbed and must be finally released...">drive_is_grabbed</a> = 1; <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <span class="keywordflow">return</span> ret; <a name="l00153"></a>00153 } <a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="comment"></span> <a name="l00156"></a>00156 <span class="comment">/** This method demonstrates how to use libburn without knowing a persistent</span> <a name="l00157"></a>00157 <span class="comment"> drive address in advance. It has to make sure that after assessing the list</span> <a name="l00158"></a>00158 <span class="comment"> of available drives, all unwanted drives get closed again. As long as they</span> <a name="l00159"></a>00159 <span class="comment"> are open, no other libburn instance can see them. This is an intended</span> <a name="l00160"></a>00160 <span class="comment"> locking feature. The application is responsible for giving up the locks</span> <a name="l00161"></a>00161 <span class="comment"> by either burn_drive_release() (only after burn_drive_grab() !),</span> <a name="l00162"></a>00162 <span class="comment"> burn_drive_info_forget(), burn_drive_info_free(), or burn_finish().</span> <a name="l00163"></a>00163 <span class="comment"> @param driveno the index number in libburn's drive list. This will get</span> <a name="l00164"></a>00164 <span class="comment"> set to 0 on success and will then be the drive index to</span> <a name="l00165"></a>00165 <span class="comment"> use in the further dourse of processing.</span> <a name="l00166"></a>00166 <span class="comment"> @return 1 success , <= 0 failure</span> <a name="l00167"></a>00167 <span class="comment">*/</span> <a name="l00168"></a><a class="code" href="libburner_8c.html#aa2de071d4fb803b4a171dbc8dc14be5c">00168</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#aa2de071d4fb803b4a171dbc8dc14be5c" title="This method demonstrates how to use libburn without knowing a persistent drive address...">libburner_aquire_by_driveno</a>(<span class="keywordtype">int</span> *<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>) <a name="l00169"></a>00169 { <a name="l00170"></a>00170 <span class="keywordtype">char</span> adr[<a class="code" href="libburn_8h.html#a489ca2111726a034324275aca4ed069c" title="Maximum length+1 to expect with a persistent drive address string.">BURN_DRIVE_ADR_LEN</a>]; <a name="l00171"></a>00171 <span class="keywordtype">int</span> ret, i; <a name="l00172"></a>00172 <a name="l00173"></a>00173 printf(<span class="stringliteral">"Beginning to scan for devices ...\n"</span>); <a name="l00174"></a>00174 <span class="keywordflow">while</span> (!<a class="code" href="libburn_8h.html#a21b480156713f0dbc8a254c24fa9689e" title="Scan for drives.">burn_drive_scan</a>(&drive_list, &<a class="code" href="libburner_8c.html#a2ab10011f756aef24f3168d95a5b439b" title="If you start a long lasting operation with drive_count &gt; 1 then you are not friendly...">drive_count</a>)) <a name="l00175"></a>00175 usleep(100002); <a name="l00176"></a>00176 <span class="keywordflow">if</span> (drive_count <= 0 && *driveno >= 0) { <a name="l00177"></a>00177 printf(<span class="stringliteral">"FAILED (no drives found)\n"</span>); <a name="l00178"></a>00178 <span class="keywordflow">return</span> 0; <a name="l00179"></a>00179 } <a name="l00180"></a>00180 printf(<span class="stringliteral">"Done\n"</span>); <a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="comment">/*</span> <a name="l00183"></a>00183 <span class="comment"> Interactive programs may choose the drive number at this moment.</span> <a name="l00184"></a>00184 <span class="comment"></span> <a name="l00185"></a>00185 <span class="comment"> drive[0] to drive[drive_count-1] are struct burn_drive_info</span> <a name="l00186"></a>00186 <span class="comment"> as defined in libburn/libburn.h . This structure is part of API</span> <a name="l00187"></a>00187 <span class="comment"> and thus will strive for future compatibility on source level.</span> <a name="l00188"></a>00188 <span class="comment"> Have a look at the info offered.</span> <a name="l00189"></a>00189 <span class="comment"> Caution: do not take .location for drive address. Always use</span> <a name="l00190"></a>00190 <span class="comment"> burn_drive_get_adr() or you might become incompatible</span> <a name="l00191"></a>00191 <span class="comment"> in future.</span> <a name="l00192"></a>00192 <span class="comment"> Note: bugs with struct burn_drive_info - if any - will not be</span> <a name="l00193"></a>00193 <span class="comment"> easy to fix. Please report them but also strive for</span> <a name="l00194"></a>00194 <span class="comment"> workarounds on application level.</span> <a name="l00195"></a>00195 <span class="comment"> */</span> <a name="l00196"></a>00196 printf(<span class="stringliteral">"\nOverview of accessible drives (%d found) :\n"</span>, <a name="l00197"></a>00197 <a class="code" href="libburner_8c.html#a2ab10011f756aef24f3168d95a5b439b" title="If you start a long lasting operation with drive_count &gt; 1 then you are not friendly...">drive_count</a>); <a name="l00198"></a>00198 printf(<span class="stringliteral">"-----------------------------------------------------------------------------\n"</span>); <a name="l00199"></a>00199 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="libburner_8c.html#a2ab10011f756aef24f3168d95a5b439b" title="If you start a long lasting operation with drive_count &gt; 1 then you are not friendly...">drive_count</a>; i++) { <a name="l00200"></a>00200 <span class="keywordflow">if</span> (<a class="code" href="libburn_8h.html#a1ccfaccc7c7b10aa7f25bec20cf1b1b2" title="Inquire the persistent address of a drive via a given drive_info object.">burn_drive_get_adr</a>(&(drive_list[i]), adr) <=0) <a name="l00201"></a>00201 strcpy(adr, <span class="stringliteral">"-get_adr_failed-"</span>); <a name="l00202"></a>00202 printf(<span class="stringliteral">"%d --drive '%s' : '%s' '%s'\n"</span>, <a name="l00203"></a>00203 i,adr,drive_list[i].<a class="code" href="structburn__drive__info.html#aff3ff7a51541d619f7f156ba58256992" title="Name of the vendor of the drive.">vendor</a>,drive_list[i].<a class="code" href="structburn__drive__info.html#a679639bfb29abb68d5b35269e935e88f" title="Name of the drive.">product</a>); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 printf(<span class="stringliteral">"-----------------------------------------------------------------------------\n\n"</span>); <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="comment">/*</span> <a name="l00208"></a>00208 <span class="comment"> On multi-drive systems save yourself from sysadmins' revenge.</span> <a name="l00209"></a>00209 <span class="comment"></span> <a name="l00210"></a>00210 <span class="comment"> Be aware that you hold reserved all available drives at this point.</span> <a name="l00211"></a>00211 <span class="comment"> So either make your choice quick enough not to annoy other system</span> <a name="l00212"></a>00212 <span class="comment"> users, or set free the drives for a while.</span> <a name="l00213"></a>00213 <span class="comment"></span> <a name="l00214"></a>00214 <span class="comment"> The tested way of setting free all drives is to shutdown the library</span> <a name="l00215"></a>00215 <span class="comment"> and to restart when the choice has been made. The list of selectable</span> <a name="l00216"></a>00216 <span class="comment"> drives should also hold persistent drive addresses as obtained</span> <a name="l00217"></a>00217 <span class="comment"> above by burn_drive_get_adr(). By such an address one may use</span> <a name="l00218"></a>00218 <span class="comment"> burn_drive_scan_and_grab() to finally aquire exactly one drive.</span> <a name="l00219"></a>00219 <span class="comment"></span> <a name="l00220"></a>00220 <span class="comment"> A not yet tested shortcut should be to call burn_drive_info_free()</span> <a name="l00221"></a>00221 <span class="comment"> and to call either burn_drive_scan() or burn_drive_scan_and_grab()</span> <a name="l00222"></a>00222 <span class="comment"> before accessing any drives again.</span> <a name="l00223"></a>00223 <span class="comment"></span> <a name="l00224"></a>00224 <span class="comment"> In both cases you have to be aware that the desired drive might get</span> <a name="l00225"></a>00225 <span class="comment"> aquired in the meantime by another user resp. libburn process.</span> <a name="l00226"></a>00226 <span class="comment"> */</span> <a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="comment">/* We already made our choice via command line. (default is 0)</span> <a name="l00229"></a>00229 <span class="comment"> So we just have to keep our desired drive and drop all others.</span> <a name="l00230"></a>00230 <span class="comment"> No other libburn instance will have a chance to steal our drive.</span> <a name="l00231"></a>00231 <span class="comment"> */</span> <a name="l00232"></a>00232 <span class="keywordflow">if</span> (*driveno < 0) { <a name="l00233"></a>00233 printf(<span class="stringliteral">"Pseudo-drive \"-\" given : bus scanning done.\n"</span>); <a name="l00234"></a>00234 <span class="keywordflow">return</span> 2; <span class="comment">/* the program will end after this */</span> <a name="l00235"></a>00235 } <a name="l00236"></a>00236 <span class="keywordflow">if</span> (drive_count <= *driveno) { <a name="l00237"></a>00237 fprintf(stderr, <a name="l00238"></a>00238 <span class="stringliteral">"Found only %d drives. Number %d not available.\n"</span>, <a name="l00239"></a>00239 drive_count, *driveno); <a name="l00240"></a>00240 <span class="keywordflow">return</span> 0; <span class="comment">/* the program will end after this */</span> <a name="l00241"></a>00241 } <a name="l00242"></a>00242 <a name="l00243"></a>00243 <span class="comment">/* Drop all drives which we do not want to use */</span> <a name="l00244"></a>00244 <span class="keywordflow">for</span> (i = 0; i < drive_count; i++) { <a name="l00245"></a>00245 <span class="keywordflow">if</span> (i == *driveno) <span class="comment">/* the one drive we want to keep */</span> <a name="l00246"></a>00246 <span class="keywordflow">continue</span>; <a name="l00247"></a>00247 ret = <a class="code" href="libburn_8h.html#a9ac4cfc83330f237b6b3824e58039775" title="Release memory about a single drive and any exclusive lock on it.">burn_drive_info_forget</a>(&(drive_list[i]),0); <a name="l00248"></a>00248 <span class="keywordflow">if</span> (ret != 1) <a name="l00249"></a>00249 fprintf(stderr, <span class="stringliteral">"Cannot drop drive %d. Please report \"ret=%d\" to libburn-hackers@pykix.org\n"</span>, <a name="l00250"></a>00250 i, ret); <a name="l00251"></a>00251 <span class="keywordflow">else</span> <a name="l00252"></a>00252 printf(<span class="stringliteral">"Dropped unwanted drive %d\n"</span>,i); <a name="l00253"></a>00253 } <a name="l00254"></a>00254 <span class="comment">/* Make the one we want ready for blanking or burning */</span> <a name="l00255"></a>00255 ret= <a class="code" href="libburn_8h.html#a392a1a309e906c35b8e2f31cc3f30969" title="Grab a drive.">burn_drive_grab</a>(drive_list[*driveno].<a class="code" href="structburn__drive__info.html#aa53408d48157a07e48b114e6c95550d0" title="The value by which this drive can be indexed when using functions in the library...">drive</a>, 1); <a name="l00256"></a>00256 <span class="keywordflow">if</span> (ret != 1) <a name="l00257"></a>00257 <span class="keywordflow">return</span> 0; <a name="l00258"></a>00258 <a class="code" href="libburner_8c.html#aaee536e445f55d19bfeb431850ec90e4" title="This variable indicates wether the drive is grabbed and must be finally released...">drive_is_grabbed</a> = 1; <a name="l00259"></a>00259 <span class="keywordflow">return</span> 1; <a name="l00260"></a>00260 } <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="comment"></span> <a name="l00263"></a>00263 <span class="comment">/** Makes a previously used CD-RW or unformatted DVD-RW ready for thorough</span> <a name="l00264"></a>00264 <span class="comment"> re-usal.</span> <a name="l00265"></a>00265 <span class="comment"></span> <a name="l00266"></a>00266 <span class="comment"> To our knowledge it is hardly possible to abort an ongoing blank operation</span> <a name="l00267"></a>00267 <span class="comment"> because after start it is entirely handled by the drive.</span> <a name="l00268"></a>00268 <span class="comment"> So expect signal handling to wait the normal blanking timespan until it</span> <a name="l00269"></a>00269 <span class="comment"> can allow the process to end. External kill -9 will not help the drive.</span> <a name="l00270"></a>00270 <span class="comment">*/</span> <a name="l00271"></a><a class="code" href="libburner_8c.html#a0d4b7dff006b3f1f2aac1acc48ba99df">00271</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a0d4b7dff006b3f1f2aac1acc48ba99df" title="Makes a previously used CD-RW or unformatted DVD-RW ready for thorough re-usal.">libburner_blank_disc</a>(<span class="keyword">struct</span> burn_drive *<a class="code" href="structburn__drive__info.html#aa53408d48157a07e48b114e6c95550d0" title="The value by which this drive can be indexed when using functions in the library...">drive</a>, <span class="keywordtype">int</span> blank_fast) <a name="l00272"></a>00272 { <a name="l00273"></a>00273 <span class="keyword">enum</span> <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54" title="Possible status of the drive in regard to the disc in it.">burn_disc_status</a> disc_state; <a name="l00274"></a>00274 <span class="keyword">struct </span><a class="code" href="structburn__progress.html" title="Operation progress report.">burn_progress</a> p; <a name="l00275"></a>00275 <span class="keywordtype">double</span> percent = 1.0; <a name="l00276"></a>00276 <a name="l00277"></a>00277 disc_state = <a class="code" href="libburn_8h.html#ac009cc9dfe07c8c0b67f528a369fd511" title="Returns what kind of disc a drive is holding.">burn_disc_get_status</a>(drive); <a name="l00278"></a>00278 printf( <a name="l00279"></a>00279 <span class="stringliteral">"Drive media status: %d (see libburn/libburn.h BURN_DISC_*)\n"</span>, <a name="l00280"></a>00280 disc_state); <a name="l00281"></a>00281 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x13) { <a name="l00282"></a>00282 ; <span class="comment">/* formatted DVD-RW will get blanked to sequential state */</span> <a name="l00283"></a>00283 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54a59c757934ef338281512efce4ab6fd93" title="The drive holds a blank disc.">BURN_DISC_BLANK</a>) { <a name="l00284"></a>00284 fprintf(stderr, <a name="l00285"></a>00285 <span class="stringliteral">"IDLE: Blank media detected. Will leave it untouched\n"</span>); <a name="l00286"></a>00286 <span class="keywordflow">return</span> 2; <a name="l00287"></a>00287 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54ae0ea0a584e319ee775062c88975c93cd" title="There is a disc with data on it in the drive.">BURN_DISC_FULL</a> || <a name="l00288"></a>00288 disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54acda6fac8462fa9affb4bff80daa2ab3f" title="There is an incomplete disc in the drive.">BURN_DISC_APPENDABLE</a>) { <a name="l00289"></a>00289 ; <span class="comment">/* this is what libburner is willing to blank */</span> <a name="l00290"></a>00290 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54a23eef5011f3aa95ce1858a2930c22c69" title="There is no disc at all in the drive.">BURN_DISC_EMPTY</a>) { <a name="l00291"></a>00291 fprintf(stderr,<span class="stringliteral">"FATAL: No media detected in drive\n"</span>); <a name="l00292"></a>00292 <span class="keywordflow">return</span> 0; <a name="l00293"></a>00293 } <span class="keywordflow">else</span> { <a name="l00294"></a>00294 fprintf(stderr, <a name="l00295"></a>00295 <span class="stringliteral">"FATAL: Unsuitable drive and media state\n"</span>); <a name="l00296"></a>00296 <span class="keywordflow">return</span> 0; <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <span class="keywordflow">if</span>(!<a class="code" href="libburn_8h.html#a7838224062ed72305f3c6b1055cb1a98" title="Tells whether a disc can be erased or not.">burn_disc_erasable</a>(drive)) { <a name="l00299"></a>00299 fprintf(stderr, <a name="l00300"></a>00300 <span class="stringliteral">"FATAL : Media is not of erasable type\n"</span>); <a name="l00301"></a>00301 <span class="keywordflow">return</span> 0; <a name="l00302"></a>00302 } <a name="l00303"></a>00303 printf( <a name="l00304"></a>00304 <span class="stringliteral">"Beginning to %s-blank media.\n"</span>, (blank_fast?<span class="stringliteral">"fast"</span>:<span class="stringliteral">"full"</span>)); <a name="l00305"></a>00305 <a class="code" href="libburn_8h.html#a86a5394e31ab522bca8cc5b7990f1923" title="Erase a disc in the drive.">burn_disc_erase</a>(drive, blank_fast); <a name="l00306"></a>00306 sleep(1); <a name="l00307"></a>00307 <span class="keywordflow">while</span> (<a class="code" href="libburn_8h.html#a992777abdf1f13f1e2c45271e43e9a3d" title="Returns the progress and status of a drive.">burn_drive_get_status</a>(drive, &p) != <a class="code" href="libburn_8h.html#a3cb9c75648e773f63911b0975f67802badcb522cf8ccf1349e3d69826c3e1757f" title="The drive is not in an operation.">BURN_DRIVE_IDLE</a>) { <a name="l00308"></a>00308 <span class="keywordflow">if</span>(p.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a>>0 && p.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>>=0) <span class="comment">/* display 1 to 99 percent */</span> <a name="l00309"></a>00309 percent = 1.0 + ((double) p.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>+1.0) <a name="l00310"></a>00310 / ((double) p.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a>) * 98.0; <a name="l00311"></a>00311 printf(<span class="stringliteral">"Blanking ( %.1f%% done )\n"</span>, percent); <a name="l00312"></a>00312 sleep(1); <a name="l00313"></a>00313 } <a name="l00314"></a>00314 printf(<span class="stringliteral">"Done\n"</span>); <a name="l00315"></a>00315 <span class="keywordflow">return</span> 1; <a name="l00316"></a>00316 } <a name="l00317"></a>00317 <a name="l00318"></a>00318 <span class="comment"></span> <a name="l00319"></a>00319 <span class="comment">/** Formats unformatted DVD-RW to profile 0013h "Restricted Overwrite"</span> <a name="l00320"></a>00320 <span class="comment"> which needs no blanking for re-use but is not capable of multi-session.</span> <a name="l00321"></a>00321 <span class="comment"> Expect a behavior similar to blanking with unusual noises from the drive.</span> <a name="l00322"></a>00322 <span class="comment"></span> <a name="l00323"></a>00323 <span class="comment"> Formats unformatted BD-RE to default size. This will allocate some</span> <a name="l00324"></a>00324 <span class="comment"> reserve space, test for bad blocks and make the media ready for writing.</span> <a name="l00325"></a>00325 <span class="comment"> Expect a very long run time.</span> <a name="l00326"></a>00326 <span class="comment"></span> <a name="l00327"></a>00327 <span class="comment"> Formats unformatted blank BD-R to hold a default amount of spare blocks</span> <a name="l00328"></a>00328 <span class="comment"> for eventual mishaps during writing. If BD-R get written without being</span> <a name="l00329"></a>00329 <span class="comment"> formatted, then they get no such reserve and will burn at full speed.</span> <a name="l00330"></a>00330 <span class="comment">*/</span> <a name="l00331"></a><a class="code" href="libburner_8c.html#a42f03141c04bc55410fdc8e93c4f0143">00331</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a42f03141c04bc55410fdc8e93c4f0143" title="Formats unformatted DVD-RW to profile 0013h &quot;Restricted Overwrite&quot; which...">libburner_format</a>(<span class="keyword">struct</span> burn_drive *drive) <a name="l00332"></a>00332 { <a name="l00333"></a>00333 <span class="keyword">struct </span><a class="code" href="structburn__progress.html" title="Operation progress report.">burn_progress</a> p; <a name="l00334"></a>00334 <span class="keywordtype">double</span> percent = 1.0; <a name="l00335"></a>00335 <span class="keywordtype">int</span> ret, status, num_formats, format_flag= 0; <a name="l00336"></a>00336 off_t size = 0; <a name="l00337"></a>00337 <span class="keywordtype">unsigned</span> dummy; <a name="l00338"></a>00338 <span class="keyword">enum</span> <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54" title="Possible status of the drive in regard to the disc in it.">burn_disc_status</a> disc_state; <a name="l00339"></a>00339 <a name="l00340"></a>00340 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x13) { <a name="l00341"></a>00341 fprintf(stderr, <span class="stringliteral">"IDLE: DVD-RW media is already formatted\n"</span>); <a name="l00342"></a>00342 <span class="keywordflow">return</span> 2; <a name="l00343"></a>00343 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x41 || <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x43) { <a name="l00344"></a>00344 disc_state = <a class="code" href="libburn_8h.html#ac009cc9dfe07c8c0b67f528a369fd511" title="Returns what kind of disc a drive is holding.">burn_disc_get_status</a>(drive); <a name="l00345"></a>00345 <span class="keywordflow">if</span> (disc_state != <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54a59c757934ef338281512efce4ab6fd93" title="The drive holds a blank disc.">BURN_DISC_BLANK</a> && <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x41) { <a name="l00346"></a>00346 fprintf(stderr, <a name="l00347"></a>00347 <span class="stringliteral">"FATAL: BD-R is not blank. Cannot format.\n"</span>); <a name="l00348"></a>00348 <span class="keywordflow">return</span> 0; <a name="l00349"></a>00349 } <a name="l00350"></a>00350 ret = <a class="code" href="libburn_8h.html#abe718b844984771afe7c38f44e7abbe6" title="Inquire the formatting status, the associated sizes and the number of available formats...">burn_disc_get_formats</a>(drive, &status, &size, &dummy, <a name="l00351"></a>00351 &num_formats); <a name="l00352"></a>00352 <span class="keywordflow">if</span> (ret > 0 && status != <a class="code" href="libburn_8h.html#a7b6978947a00d7f643003a1103b8a821" title="Possible formatting status values.">BURN_FORMAT_IS_UNFORMATTED</a>) { <a name="l00353"></a>00353 fprintf(stderr, <a name="l00354"></a>00354 <span class="stringliteral">"IDLE: BD media is already formatted\n"</span>); <a name="l00355"></a>00355 <span class="keywordflow">return</span> 2; <a name="l00356"></a>00356 } <a name="l00357"></a>00357 size = 0; <span class="comment">/* does not really matter */</span> <a name="l00358"></a>00358 format_flag = 3<<1; <span class="comment">/* format to default size, no quick */</span> <a name="l00359"></a>00359 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x14) { <span class="comment">/* sequential DVD-RW */</span> <a name="l00360"></a>00360 size = 128 * 1024 * 1024; <a name="l00361"></a>00361 format_flag = 1; <span class="comment">/* write initial 128 MiB */</span> <a name="l00362"></a>00362 } <span class="keywordflow">else</span> { <a name="l00363"></a>00363 fprintf(stderr, <span class="stringliteral">"FATAL: Can only format DVD-RW or BD\n"</span>); <a name="l00364"></a>00364 <span class="keywordflow">return</span> 0; <a name="l00365"></a>00365 } <a name="l00366"></a>00366 <a name="l00367"></a>00367 printf(<span class="stringliteral">"Beginning to format media.\n"</span>); <a name="l00368"></a>00368 <a class="code" href="libburn_8h.html#a1ac5250deb1dd13d7192f5e834fd5c4d" title="Format media for use with libburn.">burn_disc_format</a>(drive, size, format_flag); <a name="l00369"></a>00369 <a name="l00370"></a>00370 sleep(1); <a name="l00371"></a>00371 <span class="keywordflow">while</span> (<a class="code" href="libburn_8h.html#a992777abdf1f13f1e2c45271e43e9a3d" title="Returns the progress and status of a drive.">burn_drive_get_status</a>(drive, &p) != <a class="code" href="libburn_8h.html#a3cb9c75648e773f63911b0975f67802badcb522cf8ccf1349e3d69826c3e1757f" title="The drive is not in an operation.">BURN_DRIVE_IDLE</a>) { <a name="l00372"></a>00372 <span class="keywordflow">if</span>(p.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a>>0 && p.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>>=0) <span class="comment">/* display 1 to 99 percent */</span> <a name="l00373"></a>00373 percent = 1.0 + ((double) p.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>+1.0) <a name="l00374"></a>00374 / ((double) p.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a>) * 98.0; <a name="l00375"></a>00375 printf(<span class="stringliteral">"Formatting ( %.1f%% done )\n"</span>, percent); <a name="l00376"></a>00376 sleep(1); <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <a class="code" href="libburn_8h.html#a1627c70c71ec5b6116f8d9d63d229285" title="Tells the MMC Profile identifier of the loaded media.">burn_disc_get_profile</a>(drive_list[0].drive, &<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a>, <a name="l00379"></a>00379 <a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>); <a name="l00380"></a>00380 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x14 || <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x13) <a name="l00381"></a>00381 printf(<span class="stringliteral">"Media type now: %4.4xh \"%s\"\n"</span>, <a name="l00382"></a>00382 <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a>, <a class="code" href="libburner_8c.html#a14fb7b17efb56d94fb7d794053ae045b">current_profile_name</a>); <a name="l00383"></a>00383 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> == 0x14) { <a name="l00384"></a>00384 fprintf(stderr, <a name="l00385"></a>00385 <span class="stringliteral">"FATAL: Failed to change media profile to desired value\n"</span>); <a name="l00386"></a>00386 <span class="keywordflow">return</span> 0; <a name="l00387"></a>00387 } <a name="l00388"></a>00388 <span class="keywordflow">return</span> 1; <a name="l00389"></a>00389 } <a name="l00390"></a>00390 <a name="l00391"></a>00391 <span class="comment"></span> <a name="l00392"></a>00392 <span class="comment">/** Brings preformatted track images (ISO 9660, audio, ...) onto media.</span> <a name="l00393"></a>00393 <span class="comment"> To make sure a data image is fully readable on any Linux machine, this</span> <a name="l00394"></a>00394 <span class="comment"> function adds 300 kiB of padding to the (usualy single) track.</span> <a name="l00395"></a>00395 <span class="comment"> Audio tracks get padded to complete their last sector.</span> <a name="l00396"></a>00396 <span class="comment"> A fifo of 4 MB is installed between each track and its data source.</span> <a name="l00397"></a>00397 <span class="comment"> Each of the 4 MB buffers gets allocated automatically as soon as a track</span> <a name="l00398"></a>00398 <span class="comment"> begins to be processed and it gets freed as soon as the track is done.</span> <a name="l00399"></a>00399 <span class="comment"> The fifos do not wait for buffer fill but writing starts immediately.</span> <a name="l00400"></a>00400 <span class="comment"></span> <a name="l00401"></a>00401 <span class="comment"> In case of external signals expect abort handling of an ongoing burn to</span> <a name="l00402"></a>00402 <span class="comment"> last up to a minute. Wait the normal burning timespan before any kill -9.</span> <a name="l00403"></a>00403 <span class="comment"></span> <a name="l00404"></a>00404 <span class="comment"> For simplicity, this function allows memory leaks in case of failure.</span> <a name="l00405"></a>00405 <span class="comment"> In apps which do not abort immediately, one should clean up better.</span> <a name="l00406"></a>00406 <span class="comment">*/</span> <a name="l00407"></a><a class="code" href="libburner_8c.html#af9c2fc57ed6d8505b22d377daef4914b">00407</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#af9c2fc57ed6d8505b22d377daef4914b" title="Brings preformatted track images (ISO 9660, audio, .">libburner_payload</a>(<span class="keyword">struct</span> burn_drive *drive, <a name="l00408"></a>00408 <span class="keywordtype">char</span> <a class="code" href="libburner_8c.html#a20401aa73b1b1c04c3faddfd1647f302">source_adr</a>[][4096], <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a>, <a name="l00409"></a>00409 <span class="keywordtype">int</span> multi, <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">simulate_burn</a>, <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#acdd017f7636e63e635f981e11aca9a22">all_tracks_type</a>) <a name="l00410"></a>00410 { <a name="l00411"></a>00411 <span class="keyword">struct </span><a class="code" href="structburn__source.html" title="Data source interface for tracks.">burn_source</a> *data_src, *fifo_src[99]; <a name="l00412"></a>00412 <span class="keyword">struct </span>burn_disc *target_disc; <a name="l00413"></a>00413 <span class="keyword">struct </span>burn_session *session; <a name="l00414"></a>00414 <span class="keyword">struct </span>burn_write_opts *burn_options; <a name="l00415"></a>00415 <span class="keyword">enum</span> <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54" title="Possible status of the drive in regard to the disc in it.">burn_disc_status</a> disc_state; <a name="l00416"></a>00416 <span class="keyword">struct </span>burn_track *track, *tracklist[99]; <a name="l00417"></a>00417 <span class="keyword">struct </span><a class="code" href="structburn__progress.html" title="Operation progress report.">burn_progress</a> progress; <a name="l00418"></a>00418 time_t start_time; <a name="l00419"></a>00419 <span class="keywordtype">int</span> last_sector = 0, padding = 0, trackno, unpredicted_size = 0, fd; <a name="l00420"></a>00420 <span class="keywordtype">int</span> fifo_chunksize = 2352, fifo_chunks = 1783; <span class="comment">/* ~ 4 MB fifo */</span> <a name="l00421"></a>00421 off_t fixed_size; <a name="l00422"></a>00422 <span class="keywordtype">char</span> *adr, reasons[<a class="code" href="libburn_8h.html#a109ecdcd00fd30904a76c58040df9b79" title="The length of a rejection reasons string for burn_precheck_write() and burn_write_opts_auto_write_ty...">BURN_REASONS_LEN</a>]; <a name="l00423"></a>00423 <span class="keyword">struct </span>stat stbuf; <a name="l00424"></a>00424 <a name="l00425"></a>00425 <span class="keywordflow">if</span> (all_tracks_type != <a class="code" href="libburn_8h.html#af52cf0d05e7e207ef4a06c9caad94d9f" title="Track mode - audio 2352 bytes per sector.">BURN_AUDIO</a>) { <a name="l00426"></a>00426 all_tracks_type = <a class="code" href="libburn_8h.html#af2e861349cb91c0af3a482225e3326ae" title="Track mode - mode 1 data 2048 bytes user data, and all the LEC money can buy.">BURN_MODE1</a>; <a name="l00427"></a>00427 <span class="comment">/* a padding of 300 kiB helps to avoid the read-ahead bug */</span> <a name="l00428"></a>00428 padding = 300*1024; <a name="l00429"></a>00429 fifo_chunksize = 2048; <a name="l00430"></a>00430 fifo_chunks = 2048; <span class="comment">/* 4 MB fifo */</span> <a name="l00431"></a>00431 } <a name="l00432"></a>00432 <a name="l00433"></a>00433 target_disc = <a class="code" href="libburn_8h.html#a9514679bfc2d3c3079bb06f0ddfc2216" title="Create a new disc.">burn_disc_create</a>(); <a name="l00434"></a>00434 session = <a class="code" href="libburn_8h.html#a2dceb26e334833c240391cacfde555f7" title="Create a new session.">burn_session_create</a>(); <a name="l00435"></a>00435 <a class="code" href="libburn_8h.html#a77730a5108688fbee754fea7b56e048a" title="Add a session to a disc at a specific position, increasing the sessions&#39;s reference...">burn_disc_add_session</a>(target_disc, session, <a class="code" href="libburn_8h.html#a57aa6e45b0236acb5fbaa9f44280f6dc">BURN_POS_END</a>); <a name="l00436"></a>00436 <a name="l00437"></a>00437 <span class="keywordflow">for</span> (trackno = 0 ; trackno < source_adr_count; trackno++) { <a name="l00438"></a>00438 tracklist[trackno] = track = <a class="code" href="libburn_8h.html#aab87a2670415403982e499002fff0ca8" title="Create a track (for TAO recording, or to put in a session).">burn_track_create</a>(); <a name="l00439"></a>00439 <a class="code" href="libburn_8h.html#aef2fd880f00065082691a848edcaf01e" title="Define the data in a track.">burn_track_define_data</a>(track, 0, padding, 1, all_tracks_type); <a name="l00440"></a>00440 <a name="l00441"></a>00441 <span class="comment">/* Open file descriptor to source of track data */</span> <a name="l00442"></a>00442 adr = source_adr[trackno]; <a name="l00443"></a>00443 fixed_size = 0; <a name="l00444"></a>00444 <span class="keywordflow">if</span> (adr[0] == <span class="charliteral">'-'</span> && adr[1] == 0) { <a name="l00445"></a>00445 fd = 0; <a name="l00446"></a>00446 } <span class="keywordflow">else</span> { <a name="l00447"></a>00447 fd = open(adr, O_RDONLY); <a name="l00448"></a>00448 <span class="keywordflow">if</span> (fd>=0) <a name="l00449"></a>00449 <span class="keywordflow">if</span> (fstat(fd,&stbuf)!=-1) <a name="l00450"></a>00450 <span class="keywordflow">if</span>((stbuf.st_mode&S_IFMT)==S_IFREG) <a name="l00451"></a>00451 fixed_size = stbuf.st_size; <a name="l00452"></a>00452 } <a name="l00453"></a>00453 <span class="keywordflow">if</span> (fixed_size==0) <a name="l00454"></a>00454 unpredicted_size = 1; <a name="l00455"></a>00455 <a name="l00456"></a>00456 <span class="comment">/* Convert this filedescriptor into a burn_source object */</span> <a name="l00457"></a>00457 data_src = NULL; <a name="l00458"></a>00458 <span class="keywordflow">if</span> (fd>=0) <a name="l00459"></a>00459 data_src = <a class="code" href="libburn_8h.html#a2e1504f4c949b13cea988e31af9c150a" title="Creates a data source for an image file (a track) from an open readable filedescriptor...">burn_fd_source_new</a>(fd, -1, fixed_size); <a name="l00460"></a>00460 <span class="keywordflow">if</span> (data_src == NULL) { <a name="l00461"></a>00461 fprintf(stderr, <a name="l00462"></a>00462 <span class="stringliteral">"FATAL: Could not open data source '%s'.\n"</span>,adr); <a name="l00463"></a>00463 <span class="keywordflow">if</span>(errno!=0) <a name="l00464"></a>00464 fprintf(stderr,<span class="stringliteral">"(Most recent system error: %s )\n"</span>, <a name="l00465"></a>00465 strerror(errno)); <a name="l00466"></a>00466 <span class="keywordflow">return</span> 0; <a name="l00467"></a>00467 } <a name="l00468"></a>00468 <span class="comment">/* Install a fifo object on top of that data source object */</span> <a name="l00469"></a>00469 fifo_src[trackno] = <a class="code" href="libburn_8h.html#a2d7a2faac8565ddd40d9e6ddae0bd922" title="Creates a fifo which acts as proxy for an already existing data source.">burn_fifo_source_new</a>(data_src, <a name="l00470"></a>00470 fifo_chunksize, fifo_chunks, 0); <a name="l00471"></a>00471 <span class="keywordflow">if</span> (fifo_src[trackno] == NULL) { <a name="l00472"></a>00472 fprintf(stderr, <a name="l00473"></a>00473 <span class="stringliteral">"FATAL: Could not create fifo object of 4 MB\n"</span>); <a name="l00474"></a>00474 <span class="keywordflow">return</span> 0; <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <a name="l00477"></a>00477 <span class="comment">/* Use the fifo object as data source for the track */</span> <a name="l00478"></a>00478 <span class="keywordflow">if</span> (<a class="code" href="libburn_8h.html#a27400c91868946c04b013c2cc2ac632a" title="Set the track&#39;s data source.">burn_track_set_source</a>(track, fifo_src[trackno]) <a name="l00479"></a>00479 != <a class="code" href="libburn_8h.html#aa5ddf1fe21e47ff4d4a44262c1d7da9ba936b5414e25492f45a3f240941f3d9a1" title="The source is ok.">BURN_SOURCE_OK</a>) { <a name="l00480"></a>00480 fprintf(stderr, <a name="l00481"></a>00481 <span class="stringliteral">"FATAL: Cannot attach source object to track object\n"</span>); <a name="l00482"></a>00482 <span class="keywordflow">return</span> 0; <a name="l00483"></a>00483 } <a name="l00484"></a>00484 <a name="l00485"></a>00485 <a class="code" href="libburn_8h.html#a2062793258361e9e84e7ddbf5f9ab06a" title="Add a track to a session at specified position.">burn_session_add_track</a>(session, track, <a class="code" href="libburn_8h.html#a57aa6e45b0236acb5fbaa9f44280f6dc">BURN_POS_END</a>); <a name="l00486"></a>00486 printf(<span class="stringliteral">"Track %d : source is '%s'\n"</span>, trackno+1, adr); <a name="l00487"></a>00487 <a name="l00488"></a>00488 <span class="comment">/* Give up local reference to the data burn_source object */</span> <a name="l00489"></a>00489 <a class="code" href="libburn_8h.html#a1a03f8b3088b8ce6305e7a48c3e034eb" title="Free a burn_source (decrease its refcount and maybe free it).">burn_source_free</a>(data_src); <a name="l00490"></a>00490 <a name="l00491"></a>00491 } <span class="comment">/* trackno loop end */</span> <a name="l00492"></a>00492 <a name="l00493"></a>00493 <span class="comment">/* Evaluate drive and media */</span> <a name="l00494"></a>00494 disc_state = <a class="code" href="libburn_8h.html#ac009cc9dfe07c8c0b67f528a369fd511" title="Returns what kind of disc a drive is holding.">burn_disc_get_status</a>(drive); <a name="l00495"></a>00495 <span class="keywordflow">if</span> (disc_state != <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54a59c757934ef338281512efce4ab6fd93" title="The drive holds a blank disc.">BURN_DISC_BLANK</a> && <a name="l00496"></a>00496 disc_state != <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54acda6fac8462fa9affb4bff80daa2ab3f" title="There is an incomplete disc in the drive.">BURN_DISC_APPENDABLE</a>) { <a name="l00497"></a>00497 <span class="keywordflow">if</span> (disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54ae0ea0a584e319ee775062c88975c93cd" title="There is a disc with data on it in the drive.">BURN_DISC_FULL</a>) { <a name="l00498"></a>00498 fprintf(stderr, <span class="stringliteral">"FATAL: Closed media with data detected. Need blank or appendable media.\n"</span>); <a name="l00499"></a>00499 <span class="keywordflow">if</span> (<a class="code" href="libburn_8h.html#a7838224062ed72305f3c6b1055cb1a98" title="Tells whether a disc can be erased or not.">burn_disc_erasable</a>(drive)) <a name="l00500"></a>00500 fprintf(stderr, <span class="stringliteral">"HINT: Try --blank_fast\n\n"</span>); <a name="l00501"></a>00501 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (disc_state == <a class="code" href="libburn_8h.html#ad6002e7587373e7e9a9efbd22c1e6c54a23eef5011f3aa95ce1858a2930c22c69" title="There is no disc at all in the drive.">BURN_DISC_EMPTY</a>) <a name="l00502"></a>00502 fprintf(stderr,<span class="stringliteral">"FATAL: No media detected in drive\n"</span>); <a name="l00503"></a>00503 <span class="keywordflow">else</span> <a name="l00504"></a>00504 fprintf(stderr, <a name="l00505"></a>00505 <span class="stringliteral">"FATAL: Cannot recognize state of drive and media\n"</span>); <a name="l00506"></a>00506 <span class="keywordflow">return</span> 0; <a name="l00507"></a>00507 } <a name="l00508"></a>00508 <a name="l00509"></a>00509 burn_options = <a class="code" href="libburn_8h.html#ad62ba8f5344c36e2faa9aa6208751e0a" title="Creates a write_opts struct for burning to the specified drive.">burn_write_opts_new</a>(drive); <a name="l00510"></a>00510 <a class="code" href="libburn_8h.html#a8e4ed29facd80f19c866b3686dea125f" title="Sets whether to use opc or not with the write_opts struct.">burn_write_opts_set_perform_opc</a>(burn_options, 0); <a name="l00511"></a>00511 <a class="code" href="libburn_8h.html#ad04dc50d1223d78a8e8c3134df96fd82" title="Sets the multi flag which eventually marks the emerging session as not being the...">burn_write_opts_set_multi</a>(burn_options, !!multi); <a name="l00512"></a>00512 <span class="keywordflow">if</span>(simulate_burn) <a name="l00513"></a>00513 printf(<span class="stringliteral">"\n*** Will TRY to SIMULATE burning ***\n\n"</span>); <a name="l00514"></a>00514 <a class="code" href="libburn_8h.html#a05f68d91d1074a103fa8e17bb664b6d8" title="Sets the simulate value for the write_opts struct .">burn_write_opts_set_simulate</a>(burn_options, simulate_burn); <a name="l00515"></a>00515 <a class="code" href="libburn_8h.html#a62aa53e04ff9fb848178ab85d38a9c5a" title="Sets drive read and write speed Note: &quot;k&quot; is 1000, not 1024.">burn_drive_set_speed</a>(drive, 0, 0); <a name="l00516"></a>00516 <a class="code" href="libburn_8h.html#a3fdc2e3cc51bec2072ab91b99d4e52d9" title="Controls buffer underrun prevention.">burn_write_opts_set_underrun_proof</a>(burn_options, 1); <a name="l00517"></a>00517 <span class="keywordflow">if</span> (<a class="code" href="libburn_8h.html#a88a9d0adaf11e19cb4ed8b08f7740b5b" title="As an alternative to burn_write_opts_set_write_type() this function tries to find...">burn_write_opts_auto_write_type</a>(burn_options, target_disc, <a name="l00518"></a>00518 reasons, 0) == <a class="code" href="libburn_8h.html#a98506c0d72c878ea6cbecc4004451d9baf43fb685b48fdc83337465457eec54fd" title="In replies this indicates that not any writing will work.">BURN_WRITE_NONE</a>) { <a name="l00519"></a>00519 fprintf(stderr, <span class="stringliteral">"FATAL: Failed to find a suitable write mode with this media.\n"</span>); <a name="l00520"></a>00520 fprintf(stderr, <span class="stringliteral">"Reasons given:\n%s\n"</span>, reasons); <a name="l00521"></a>00521 <span class="keywordflow">return</span> 0; <a name="l00522"></a>00522 } <a name="l00523"></a>00523 <a name="l00524"></a>00524 printf(<span class="stringliteral">"Burning starts. With e.g. 4x media expect up to a minute of zero progress.\n"</span>); <a name="l00525"></a>00525 start_time = time(0); <a name="l00526"></a>00526 <a class="code" href="libburn_8h.html#a75d3d59e9c3cd7cd42c9735bee83bd91" title="Write a disc in the drive.">burn_disc_write</a>(burn_options, target_disc); <a name="l00527"></a>00527 <a name="l00528"></a>00528 <a class="code" href="libburn_8h.html#a1336283a8e59fe7ac187243350e21866" title="Frees a write_opts struct created with burn_write_opts_new.">burn_write_opts_free</a>(burn_options); <a name="l00529"></a>00529 <span class="keywordflow">while</span> (<a class="code" href="libburn_8h.html#a992777abdf1f13f1e2c45271e43e9a3d" title="Returns the progress and status of a drive.">burn_drive_get_status</a>(drive, NULL) == <a class="code" href="libburn_8h.html#a3cb9c75648e773f63911b0975f67802ba9c16cf7335531f54df68a0b280c75898" title="The library is spawning the processes to handle a pending operation (A read/write/etc...">BURN_DRIVE_SPAWNING</a>) <a name="l00530"></a>00530 usleep(100002); <a name="l00531"></a>00531 <span class="keywordflow">while</span> (<a class="code" href="libburn_8h.html#a992777abdf1f13f1e2c45271e43e9a3d" title="Returns the progress and status of a drive.">burn_drive_get_status</a>(drive, &progress) != <a class="code" href="libburn_8h.html#a3cb9c75648e773f63911b0975f67802badcb522cf8ccf1349e3d69826c3e1757f" title="The drive is not in an operation.">BURN_DRIVE_IDLE</a>) { <a name="l00532"></a>00532 <span class="keywordflow">if</span> (progress.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a> <= 0 || <a name="l00533"></a>00533 (progress.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a> >= progress.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a> - 1 && <a name="l00534"></a>00534 !unpredicted_size) || <a name="l00535"></a>00535 (unpredicted_size && progress.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a> == last_sector)) <a name="l00536"></a>00536 printf( <a name="l00537"></a>00537 <span class="stringliteral">"Thank you for being patient since %d seconds."</span>, <a name="l00538"></a>00538 (<span class="keywordtype">int</span>) (time(0) - start_time)); <a name="l00539"></a>00539 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(unpredicted_size) <a name="l00540"></a>00540 printf(<span class="stringliteral">"Track %d : sector %d"</span>, progress.<a class="code" href="structburn__progress.html#a93666a25e6d3611f9384e89fe2a2f65e" title="Current track.">track</a>+1, <a name="l00541"></a>00541 progress.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>); <a name="l00542"></a>00542 <span class="keywordflow">else</span> <a name="l00543"></a>00543 printf(<span class="stringliteral">"Track %d : sector %d of %d"</span>,progress.<a class="code" href="structburn__progress.html#a93666a25e6d3611f9384e89fe2a2f65e" title="Current track.">track</a>+1, <a name="l00544"></a>00544 progress.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>, progress.<a class="code" href="structburn__progress.html#af093a66f1ae097ba40eeac7e1c6ac5d9" title="On write: The number of sectors.">sectors</a>); <a name="l00545"></a>00545 last_sector = progress.<a class="code" href="structburn__progress.html#a7aa74bd989075ae02a5066003874c60d" title="On write: The current sector being processed.">sector</a>; <a name="l00546"></a>00546 <span class="keywordflow">if</span> (progress.<a class="code" href="structburn__progress.html#a93666a25e6d3611f9384e89fe2a2f65e" title="Current track.">track</a> >= 0 && progress.<a class="code" href="structburn__progress.html#a93666a25e6d3611f9384e89fe2a2f65e" title="Current track.">track</a> < source_adr_count) { <a name="l00547"></a>00547 <span class="keywordtype">int</span> size, free_bytes, ret; <a name="l00548"></a>00548 <span class="keywordtype">char</span> *status_text; <a name="l00549"></a>00549 <a name="l00550"></a>00550 ret = <a class="code" href="libburn_8h.html#af655df46b73a4d774cc1d27b0c57677d" title="Inquires state and fill parameters of a fifo burn_source which was created by burn_fifo_source_new()...">burn_fifo_inquire_status</a>( <a name="l00551"></a>00551 fifo_src[progress.<a class="code" href="structburn__progress.html#a93666a25e6d3611f9384e89fe2a2f65e" title="Current track.">track</a>], &size, &free_bytes, <a name="l00552"></a>00552 &status_text); <a name="l00553"></a>00553 <span class="keywordflow">if</span> (ret >= 0 ) <a name="l00554"></a>00554 printf(<span class="stringliteral">" [fifo %s, %2d%% fill]"</span>, status_text, <a name="l00555"></a>00555 (<span class="keywordtype">int</span>) (100.0 - 100.0 * <a name="l00556"></a>00556 ((<span class="keywordtype">double</span>) free_bytes) / <a name="l00557"></a>00557 (<span class="keywordtype">double</span>) size)); <a name="l00558"></a>00558 } <a name="l00559"></a>00559 printf(<span class="stringliteral">"\n"</span>); <a name="l00560"></a>00560 sleep(1); <a name="l00561"></a>00561 } <a name="l00562"></a>00562 printf(<span class="stringliteral">"\n"</span>); <a name="l00563"></a>00563 <a name="l00564"></a>00564 <span class="keywordflow">for</span> (trackno = 0 ; trackno < source_adr_count; trackno++) { <a name="l00565"></a>00565 <a class="code" href="libburn_8h.html#a1a03f8b3088b8ce6305e7a48c3e034eb" title="Free a burn_source (decrease its refcount and maybe free it).">burn_source_free</a>(fifo_src[trackno]); <a name="l00566"></a>00566 <a class="code" href="libburn_8h.html#a105c516de4f9242d91f7e92d0b399110" title="Free a track.">burn_track_free</a>(tracklist[trackno]); <a name="l00567"></a>00567 } <a name="l00568"></a>00568 <a class="code" href="libburn_8h.html#a21765aec4a5b1a9c21c027f855f9c2a0" title="Free a session (and decrease reference count on all tracks inside).">burn_session_free</a>(session); <a name="l00569"></a>00569 <a class="code" href="libburn_8h.html#aca06a415d81da71a3fd3aad31e83c698" title="Delete disc and decrease the reference count on all its sessions.">burn_disc_free</a>(target_disc); <a name="l00570"></a>00570 <span class="keywordflow">if</span> (multi && <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> != 0x1a && <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> != 0x13 && <a name="l00571"></a>00571 <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> != 0x12 && <a class="code" href="libburner_8c.html#aa1a3fe5ef89cfc5713ab70e8b3d41043" title="A number and a text describing the type of media in aquired drive.">current_profile</a> != 0x43) <a name="l00572"></a>00572 <span class="comment">/* not with DVD+RW, formatted DVD-RW, DVD-RAM, BD-RE */</span> <a name="l00573"></a>00573 printf(<span class="stringliteral">"NOTE: Media left appendable.\n"</span>); <a name="l00574"></a>00574 <span class="keywordflow">if</span> (simulate_burn) <a name="l00575"></a>00575 printf(<span class="stringliteral">"\n*** Did TRY to SIMULATE burning ***\n\n"</span>); <a name="l00576"></a>00576 <span class="keywordflow">return</span> 1; <a name="l00577"></a>00577 } <a name="l00578"></a>00578 <a name="l00579"></a>00579 <span class="comment"></span> <a name="l00580"></a>00580 <span class="comment">/** The setup parameters of libburner */</span> <a name="l00581"></a><a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1">00581</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>[<a class="code" href="libburn_8h.html#a489ca2111726a034324275aca4ed069c" title="Maximum length+1 to expect with a persistent drive address string.">BURN_DRIVE_ADR_LEN</a>] = {<span class="stringliteral">""</span>}; <a name="l00582"></a><a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">00582</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a> = 0; <a name="l00583"></a><a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">00583</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> = 0; <a name="l00584"></a><a class="code" href="libburner_8c.html#a20401aa73b1b1c04c3faddfd1647f302">00584</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="libburner_8c.html#a20401aa73b1b1c04c3faddfd1647f302">source_adr</a>[99][4096]; <a name="l00585"></a><a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">00585</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a> = 0; <a name="l00586"></a><a class="code" href="libburner_8c.html#a8e824cc51e6e6cfc91ac1df7830a70ed">00586</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a8e824cc51e6e6cfc91ac1df7830a70ed">do_multi</a> = 0; <a name="l00587"></a><a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">00587</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">simulate_burn</a> = 0; <a name="l00588"></a><a class="code" href="libburner_8c.html#acdd017f7636e63e635f981e11aca9a22">00588</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#acdd017f7636e63e635f981e11aca9a22">all_tracks_type</a> = <a class="code" href="libburn_8h.html#af2e861349cb91c0af3a482225e3326ae" title="Track mode - mode 1 data 2048 bytes user data, and all the LEC money can buy.">BURN_MODE1</a>; <a name="l00589"></a>00589 <a name="l00590"></a>00590 <span class="comment"></span> <a name="l00591"></a>00591 <span class="comment">/** Converts command line arguments into above setup parameters.</span> <a name="l00592"></a>00592 <span class="comment">*/</span> <a name="l00593"></a><a class="code" href="libburner_8c.html#a67980a9cee509cf714f67aa96a47c75d">00593</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a67980a9cee509cf714f67aa96a47c75d" title="Converts command line arguments into above setup parameters.">libburner_setup</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) <a name="l00594"></a>00594 { <a name="l00595"></a>00595 <span class="keywordtype">int</span> i, insuffient_parameters = 0, print_help = 0; <a name="l00596"></a>00596 <a name="l00597"></a>00597 <span class="keywordflow">for</span> (i = 1; i < argc; ++i) { <a name="l00598"></a>00598 <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--audio"</span>)) { <a name="l00599"></a>00599 <a class="code" href="libburner_8c.html#acdd017f7636e63e635f981e11aca9a22">all_tracks_type</a> = <a class="code" href="libburn_8h.html#af52cf0d05e7e207ef4a06c9caad94d9f" title="Track mode - audio 2352 bytes per sector.">BURN_AUDIO</a>; <a name="l00600"></a>00600 <a name="l00601"></a>00601 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--blank_fast"</span>)) { <a name="l00602"></a>00602 <a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> = 1; <a name="l00603"></a>00603 <a name="l00604"></a>00604 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--blank_full"</span>)) { <a name="l00605"></a>00605 <a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> = 2; <a name="l00606"></a>00606 <a name="l00607"></a>00607 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--burn_for_real"</span>)) { <a name="l00608"></a>00608 <a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">simulate_burn</a> = 0; <a name="l00609"></a>00609 <a name="l00610"></a>00610 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--drive"</span>)) { <a name="l00611"></a>00611 ++i; <a name="l00612"></a>00612 <span class="keywordflow">if</span> (i >= argc) { <a name="l00613"></a>00613 fprintf(stderr,<span class="stringliteral">"--drive requires an argument\n"</span>); <a name="l00614"></a>00614 <span class="keywordflow">return</span> 1; <a name="l00615"></a>00615 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(argv[i], <span class="stringliteral">"-"</span>) == 0) { <a name="l00616"></a>00616 <a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>[0] = 0; <a name="l00617"></a>00617 <a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a> = -1; <a name="l00618"></a>00618 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (isdigit(argv[i][0])) { <a name="l00619"></a>00619 <a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>[0] = 0; <a name="l00620"></a>00620 <a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a> = atoi(argv[i]); <a name="l00621"></a>00621 } <span class="keywordflow">else</span> { <a name="l00622"></a>00622 <span class="keywordflow">if</span>(strlen(argv[i]) >= <a class="code" href="libburn_8h.html#a489ca2111726a034324275aca4ed069c" title="Maximum length+1 to expect with a persistent drive address string.">BURN_DRIVE_ADR_LEN</a>) { <a name="l00623"></a>00623 fprintf(stderr,<span class="stringliteral">"--drive address too long (max. %d)\n"</span>, <a name="l00624"></a>00624 <a class="code" href="libburn_8h.html#a489ca2111726a034324275aca4ed069c" title="Maximum length+1 to expect with a persistent drive address string.">BURN_DRIVE_ADR_LEN</a>-1); <a name="l00625"></a>00625 <span class="keywordflow">return</span> 2; <a name="l00626"></a>00626 } <a name="l00627"></a>00627 strcpy(<a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>, argv[i]); <a name="l00628"></a>00628 } <a name="l00629"></a>00629 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((!strcmp(argv[i], <span class="stringliteral">"--format_overwrite"</span>)) || <a name="l00630"></a>00630 (!strcmp(argv[i], <span class="stringliteral">"--format"</span>))) { <a name="l00631"></a>00631 <a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> = 101; <a name="l00632"></a>00632 <a name="l00633"></a>00633 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--multi"</span>)) { <a name="l00634"></a>00634 <a class="code" href="libburner_8c.html#a8e824cc51e6e6cfc91ac1df7830a70ed">do_multi</a> = 1; <a name="l00635"></a>00635 <a name="l00636"></a>00636 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--stdin_size"</span>)) { <span class="comment">/* obsoleted */</span> <a name="l00637"></a>00637 i++; <a name="l00638"></a>00638 <a name="l00639"></a>00639 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--try_to_simulate"</span>)) { <a name="l00640"></a>00640 <a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">simulate_burn</a> = 1; <a name="l00641"></a>00641 <a name="l00642"></a>00642 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(argv[i], <span class="stringliteral">"--help"</span>)) { <a name="l00643"></a>00643 print_help = 1; <a name="l00644"></a>00644 <a name="l00645"></a>00645 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strncmp(argv[i], <span class="stringliteral">"--"</span>,2)) { <a name="l00646"></a>00646 fprintf(stderr, <span class="stringliteral">"Unidentified option: %s\n"</span>, argv[i]); <a name="l00647"></a>00647 <span class="keywordflow">return</span> 7; <a name="l00648"></a>00648 } <span class="keywordflow">else</span> { <a name="l00649"></a>00649 <span class="keywordflow">if</span>(strlen(argv[i]) >= 4096) { <a name="l00650"></a>00650 fprintf(stderr, <span class="stringliteral">"Source address too long (max. %d)\n"</span>, 4096-1); <a name="l00651"></a>00651 <span class="keywordflow">return</span> 5; <a name="l00652"></a>00652 } <a name="l00653"></a>00653 <span class="keywordflow">if</span>(<a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a> >= 99) { <a name="l00654"></a>00654 fprintf(stderr, <span class="stringliteral">"Too many tracks (max. 99)\n"</span>); <a name="l00655"></a>00655 <span class="keywordflow">return</span> 6; <a name="l00656"></a>00656 } <a name="l00657"></a>00657 strcpy(<a class="code" href="libburner_8c.html#a20401aa73b1b1c04c3faddfd1647f302">source_adr</a>[<a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a>], argv[i]); <a name="l00658"></a>00658 source_adr_count++; <a name="l00659"></a>00659 } <a name="l00660"></a>00660 } <a name="l00661"></a>00661 insuffient_parameters = 1; <a name="l00662"></a>00662 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a> < 0) <a name="l00663"></a>00663 insuffient_parameters = 0; <a name="l00664"></a>00664 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a> > 0) <a name="l00665"></a>00665 insuffient_parameters = 0; <a name="l00666"></a>00666 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a>) <a name="l00667"></a>00667 insuffient_parameters = 0; <a name="l00668"></a>00668 <span class="keywordflow">if</span> (print_help || insuffient_parameters ) { <a name="l00669"></a>00669 printf(<span class="stringliteral">"Usage: %s\n"</span>, argv[0]); <a name="l00670"></a>00670 printf(<span class="stringliteral">" [--drive <address>|<driveno>|\"-\"] [--audio]\n"</span>); <a name="l00671"></a>00671 printf(<span class="stringliteral">" [--blank_fast|--blank_full|--format] [--try_to_simulate]\n"</span>); <a name="l00672"></a>00672 printf(<span class="stringliteral">" [--multi] [<one or more imagefiles>|\"-\"]\n"</span>); <a name="l00673"></a>00673 printf(<span class="stringliteral">"Examples\n"</span>); <a name="l00674"></a>00674 printf(<span class="stringliteral">"A bus scan (needs rw-permissions to see a drive):\n"</span>); <a name="l00675"></a>00675 printf(<span class="stringliteral">" %s --drive -\n"</span>,argv[0]); <a name="l00676"></a>00676 printf(<span class="stringliteral">"Burn a file to drive chosen by number, leave appendable:\n"</span>); <a name="l00677"></a>00677 printf(<span class="stringliteral">" %s --drive 0 --multi my_image_file\n"</span>, argv[0]); <a name="l00678"></a>00678 printf(<span class="stringliteral">"Burn a file to drive chosen by persistent address, close:\n"</span>); <a name="l00679"></a>00679 printf(<span class="stringliteral">" %s --drive /dev/hdc my_image_file\n"</span>, argv[0]); <a name="l00680"></a>00680 printf(<span class="stringliteral">"Blank a used CD-RW (is combinable with burning in one run):\n"</span>); <a name="l00681"></a>00681 printf(<span class="stringliteral">" %s --drive /dev/hdc --blank_fast\n"</span>,argv[0]); <a name="l00682"></a>00682 printf(<span class="stringliteral">"Blank a used DVD-RW (is combinable with burning in one run):\n"</span>); <a name="l00683"></a>00683 printf(<span class="stringliteral">" %s --drive /dev/hdc --blank_full\n"</span>,argv[0]); <a name="l00684"></a>00684 printf(<span class="stringliteral">"Format a DVD-RW, BD-RE or BD-R:\n"</span>); <a name="l00685"></a>00685 printf(<span class="stringliteral">" %s --drive /dev/hdc --format\n"</span>, argv[0]); <a name="l00686"></a>00686 printf(<span class="stringliteral">"Burn two audio tracks (to CD only):\n"</span>); <a name="l00687"></a>00687 printf(<span class="stringliteral">" lame --decode -t /path/to/track1.mp3 track1.cd\n"</span>); <a name="l00688"></a>00688 printf(<span class="stringliteral">" test/dewav /path/to/track2.wav -o track2.cd\n"</span>); <a name="l00689"></a>00689 printf(<span class="stringliteral">" %s --drive /dev/hdc --audio track1.cd track2.cd\n"</span>, argv[0]); <a name="l00690"></a>00690 printf(<span class="stringliteral">"Burn a compressed afio archive on-the-fly:\n"</span>); <a name="l00691"></a>00691 printf(<span class="stringliteral">" ( cd my_directory ; find . -print | afio -oZ - ) | \\\n"</span>); <a name="l00692"></a>00692 printf(<span class="stringliteral">" %s --drive /dev/hdc -\n"</span>, argv[0]); <a name="l00693"></a>00693 printf(<span class="stringliteral">"To be read from *not mounted* media via: afio -tvZ /dev/hdc\n"</span>); <a name="l00694"></a>00694 <span class="keywordflow">if</span> (insuffient_parameters) <a name="l00695"></a>00695 <span class="keywordflow">return</span> 6; <a name="l00696"></a>00696 } <a name="l00697"></a>00697 <span class="keywordflow">return</span> 0; <a name="l00698"></a>00698 } <a name="l00699"></a>00699 <a name="l00700"></a>00700 <a name="l00701"></a><a class="code" href="libburner_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">00701</a> <span class="keywordtype">int</span> <a class="code" href="libburner_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) <a name="l00702"></a>00702 { <a name="l00703"></a>00703 <span class="keywordtype">int</span> ret; <a name="l00704"></a>00704 <a name="l00705"></a>00705 ret = <a class="code" href="libburner_8c.html#a67980a9cee509cf714f67aa96a47c75d" title="Converts command line arguments into above setup parameters.">libburner_setup</a>(argc, argv); <a name="l00706"></a>00706 <span class="keywordflow">if</span> (ret) <a name="l00707"></a>00707 exit(ret); <a name="l00708"></a>00708 <a name="l00709"></a>00709 printf(<span class="stringliteral">"Initializing libburnia-project.org ...\n"</span>); <a name="l00710"></a>00710 <span class="keywordflow">if</span> (<a class="code" href="libburn_8h.html#a53b82b88a6ebfa788ace50d890080bc6" title="Initialize the library.">burn_initialize</a>()) <a name="l00711"></a>00711 printf(<span class="stringliteral">"Done\n"</span>); <a name="l00712"></a>00712 <span class="keywordflow">else</span> { <a name="l00713"></a>00713 printf(<span class="stringliteral">"FAILED\n"</span>); <a name="l00714"></a>00714 fprintf(stderr,<span class="stringliteral">"\nFATAL: Failed to initialize.\n"</span>); <a name="l00715"></a>00715 exit(33); <a name="l00716"></a>00716 } <a name="l00717"></a>00717 <a name="l00718"></a>00718 <span class="comment">/* Print messages of severity SORRY or more directly to stderr */</span> <a name="l00719"></a>00719 <a class="code" href="libburn_8h.html#a634106ec331c7b7db40a142c467cfb48" title="Note: Above version numbers are also recorded in configure.ac because libtool wants...">burn_msgs_set_severities</a>(<span class="stringliteral">"NEVER"</span>, <span class="stringliteral">"SORRY"</span>, <span class="stringliteral">"libburner : "</span>); <a name="l00720"></a>00720 <a name="l00721"></a>00721 <span class="comment">/* Activate the default signal handler which eventually will try to</span> <a name="l00722"></a>00722 <span class="comment"> properly shutdown drive and library on aborting events. */</span> <a name="l00723"></a>00723 <a class="code" href="libburn_8h.html#a47b6e05ca3f53ca00f0ef4103eb5cd18" title="Control builtin signal handling.">burn_set_signal_handling</a>(<span class="stringliteral">"libburner : "</span>, NULL, 0); <a name="l00724"></a>00724 <span class="comment"></span> <a name="l00725"></a>00725 <span class="comment"> /** Note: driveno might change its value in this call */</span> <a name="l00726"></a>00726 ret = <a class="code" href="libburner_8c.html#ab485e1b9ba9572fb7596ffa6d6ff67c7" title="You need to aquire a drive before burning.">libburner_aquire_drive</a>(<a class="code" href="libburner_8c.html#adbe410a004b2aefa8868608beb2e5df1" title="The setup parameters of libburner.">drive_adr</a>, &<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>); <a name="l00727"></a>00727 <span class="keywordflow">if</span> (ret<=0) { <a name="l00728"></a>00728 fprintf(stderr,<span class="stringliteral">"\nFATAL: Failed to aquire drive.\n"</span>); <a name="l00729"></a>00729 { ret = 34; <span class="keywordflow">goto</span> finish_libburn; } <a name="l00730"></a>00730 } <a name="l00731"></a>00731 <span class="keywordflow">if</span> (ret == 2) <a name="l00732"></a>00732 { ret = 0; <span class="keywordflow">goto</span> release_drive; } <a name="l00733"></a>00733 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a>) { <a name="l00734"></a>00734 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> > 100) <a name="l00735"></a>00735 ret = <a class="code" href="libburner_8c.html#a42f03141c04bc55410fdc8e93c4f0143" title="Formats unformatted DVD-RW to profile 0013h &quot;Restricted Overwrite&quot; which...">libburner_format</a>(drive_list[<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>].drive); <a name="l00736"></a>00736 <span class="keywordflow">else</span> <a name="l00737"></a>00737 ret = <a class="code" href="libburner_8c.html#a0d4b7dff006b3f1f2aac1acc48ba99df" title="Makes a previously used CD-RW or unformatted DVD-RW ready for thorough re-usal.">libburner_blank_disc</a>(drive_list[<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>].drive, <a name="l00738"></a>00738 <a class="code" href="libburner_8c.html#aec8a1ef7e11653bc93fe1d5b2c63c9d3">do_blank</a> == 1); <a name="l00739"></a>00739 <span class="keywordflow">if</span> (ret<=0) <a name="l00740"></a>00740 { ret = 36; <span class="keywordflow">goto</span> release_drive; } <a name="l00741"></a>00741 } <a name="l00742"></a>00742 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a> > 0) { <a name="l00743"></a>00743 ret = <a class="code" href="libburner_8c.html#af9c2fc57ed6d8505b22d377daef4914b" title="Brings preformatted track images (ISO 9660, audio, .">libburner_payload</a>(drive_list[<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>].drive, <a name="l00744"></a>00744 <a class="code" href="libburner_8c.html#a20401aa73b1b1c04c3faddfd1647f302">source_adr</a>, <a class="code" href="libburner_8c.html#a896ce0b6e3a7f1c4aa381a351f45106b">source_adr_count</a>, <a name="l00745"></a>00745 <a class="code" href="libburner_8c.html#a8e824cc51e6e6cfc91ac1df7830a70ed">do_multi</a>, <a class="code" href="libburner_8c.html#a0987fdf0d2c39990a6de69c649f4d470">simulate_burn</a>, <a class="code" href="libburner_8c.html#acdd017f7636e63e635f981e11aca9a22">all_tracks_type</a>); <a name="l00746"></a>00746 <span class="keywordflow">if</span> (ret<=0) <a name="l00747"></a>00747 { ret = 38; <span class="keywordflow">goto</span> release_drive; } <a name="l00748"></a>00748 } <a name="l00749"></a>00749 ret = 0; <a name="l00750"></a>00750 release_drive:; <a name="l00751"></a>00751 <span class="keywordflow">if</span> (<a class="code" href="libburner_8c.html#aaee536e445f55d19bfeb431850ec90e4" title="This variable indicates wether the drive is grabbed and must be finally released...">drive_is_grabbed</a>) <a name="l00752"></a>00752 <a class="code" href="libburn_8h.html#a765bba03b9f40c07f159ff9ef7db0e09" title="Release a drive.">burn_drive_release</a>(drive_list[<a class="code" href="libburner_8c.html#ae62e41d8013871fadd6094bf505bf0e3">driveno</a>].drive, 0); <a name="l00753"></a>00753 <a name="l00754"></a>00754 finish_libburn:; <a name="l00755"></a>00755 <span class="comment">/* This app does not bother to know about exact scan state. </span> <a name="l00756"></a>00756 <span class="comment"> Better to accept a memory leak here. We are done anyway. */</span> <a name="l00757"></a>00757 <span class="comment">/* burn_drive_info_free(drive_list); */</span> <a name="l00758"></a>00758 <a name="l00759"></a>00759 <a class="code" href="libburn_8h.html#ab9b933537517c9fda9758a9f2b4af337" title="Shutdown the library.">burn_finish</a>(); <a name="l00760"></a>00760 exit(ret); <a name="l00761"></a>00761 } <a name="l00762"></a>00762 <a name="l00763"></a>00763 <a name="l00764"></a>00764 <span class="comment">/* License and copyright aspects:</span> <a name="l00765"></a>00765 <span class="comment"></span> <a name="l00766"></a>00766 <span class="comment">This all is provided under GPL.</span> <a name="l00767"></a>00767 <span class="comment">Read. Try. Think. Play. Write yourself some code. Be free of my copyright.</span> <a name="l00768"></a>00768 <span class="comment"></span> <a name="l00769"></a>00769 <span class="comment">Be also invited to study the code of cdrskin/cdrskin.c et al.</span> <a name="l00770"></a>00770 <span class="comment"></span> <a name="l00771"></a>00771 <span class="comment"></span> <a name="l00772"></a>00772 <span class="comment">Clarification in my name and in the name of Mario Danic, copyright holder</span> <a name="l00773"></a>00773 <span class="comment">on toplevel of libburnia. To be fully in effect after the remaining other</span> <a name="l00774"></a>00774 <span class="comment">copyrighted code has been replaced by ours and by copyright-free contributions</span> <a name="l00775"></a>00775 <span class="comment">of our friends:</span> <a name="l00776"></a>00776 <span class="comment"></span> <a name="l00777"></a>00777 <span class="comment">We, the copyright holders, agree on the interpretation that</span> <a name="l00778"></a>00778 <span class="comment">dynamical linking of our libraries constitutes "use of" and</span> <a name="l00779"></a>00779 <span class="comment">not "derivation from" our work in the sense of GPL, provided</span> <a name="l00780"></a>00780 <span class="comment">those libraries are compiled from our unaltered code.</span> <a name="l00781"></a>00781 <span class="comment"></span> <a name="l00782"></a>00782 <span class="comment">Thus you may link our libraries dynamically with applications</span> <a name="l00783"></a>00783 <span class="comment">which are not under GPL. You may distribute our libraries and</span> <a name="l00784"></a>00784 <span class="comment">application tools in binary form, if you fulfill the usual</span> <a name="l00785"></a>00785 <span class="comment">condition of GPL to offer a copy of the source code -altered</span> <a name="l00786"></a>00786 <span class="comment">or unaltered- under GPL.</span> <a name="l00787"></a>00787 <span class="comment"></span> <a name="l00788"></a>00788 <span class="comment">We ask you politely to use our work in open source spirit</span> <a name="l00789"></a>00789 <span class="comment">and with the due reference to the entire open source community.</span> <a name="l00790"></a>00790 <span class="comment"></span> <a name="l00791"></a>00791 <span class="comment">If there should really arise the case where above clarification</span> <a name="l00792"></a>00792 <span class="comment">does not suffice to fulfill a clear and neat request in open source</span> <a name="l00793"></a>00793 <span class="comment">spirit that would otherwise be declined for mere formal reasons,</span> <a name="l00794"></a>00794 <span class="comment">only in that case we will duely consider to issue a special license</span> <a name="l00795"></a>00795 <span class="comment">covering only that special case.</span> <a name="l00796"></a>00796 <span class="comment">It is the open source idea of responsible freedom which will be</span> <a name="l00797"></a>00797 <span class="comment">decisive and you will have to prove that you exhausted all own</span> <a name="l00798"></a>00798 <span class="comment">means to qualify for GPL.</span> <a name="l00799"></a>00799 <span class="comment"></span> <a name="l00800"></a>00800 <span class="comment">For now we are firmly committed to maintain one single license: GPL.</span> <a name="l00801"></a>00801 <span class="comment"></span> <a name="l00802"></a>00802 <span class="comment">History:</span> <a name="l00803"></a>00803 <span class="comment">libburner is a compilation of my own contributions to test/burniso.c and</span> <a name="l00804"></a>00804 <span class="comment">fresh code which replaced the remaining parts under copyright of</span> <a name="l00805"></a>00805 <span class="comment">Derek Foreman.</span> <a name="l00806"></a>00806 <span class="comment">My respect and my thanks to Derek for providing me a start back in 2005.</span> <a name="l00807"></a>00807 <span class="comment"></span> <a name="l00808"></a>00808 <span class="comment">*/</span> <a name="l00809"></a>00809 </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on 30 Sep 2009 for libburn by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>