summaryrefslogtreecommitdiff
path: root/community/mdf2iso/lfs.patch
blob: 5ff62c0ba977d544b578c690d1e8ef657b7aa6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
Only in mdf2iso/src: .deps
Only in mdf2iso.new/src: .kdbgrc.mdf2iso
diff -bur mdf2iso/src/Makefile.am mdf2iso.new/src/Makefile.am
--- mdf2iso/src/Makefile.am	2005-05-19 11:24:11.000000000 +0200
+++ mdf2iso.new/src/Makefile.am	2005-07-31 17:47:36.000000000 +0200
@@ -1,2 +1,3 @@
 bin_PROGRAMS = mdf2iso
 mdf2iso_SOURCES = mdf2iso.c
+AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wall
diff -bur mdf2iso/src/Makefile.in mdf2iso.new/src/Makefile.in
--- mdf2iso/src/Makefile.in	2005-05-22 21:42:09.000000000 +0200
+++ mdf2iso.new/src/Makefile.in	2005-07-31 17:49:16.000000000 +0200
@@ -136,6 +136,7 @@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 mdf2iso_SOURCES = mdf2iso.c
+AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wall
 all: all-am
 
 .SUFFIXES:
@@ -149,9 +150,9 @@
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/Makefile
+	  $(AUTOMAKE) --gnu  src/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff -bur mdf2iso/src/mdf2iso.c mdf2iso.new/src/mdf2iso.c
--- mdf2iso/src/mdf2iso.c	2005-05-22 21:52:08.000000000 +0200
+++ mdf2iso.new/src/mdf2iso.c	2005-07-31 19:41:56.000000000 +0200
@@ -1,4 +1,4 @@
- /*  $Id: mdf2iso.c, 22/05/05 
+/*  $Id: mdf2iso.c, 22/05/05 
 
     Copyright (C) 2004,2005 Salvatore Santagati <salvatore.santagati@gmail.com>   
 
@@ -16,19 +16,14 @@
     along with this program; if not, write to the                         
     Free Software Foundation, Inc.,                                       
     59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.        
-  */
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
-#define VERSION "0.3.0"
-
-/* Support Large File */
-
-#define _FILE_OFFSET_BITS 64
-
+#define VERSION "0.3.1"
 
 
 const char SYNC_HEADER[12] = { (char) 0x00,
@@ -83,14 +78,21 @@
   (char) 0x00
 };
 
+#define ISO9660 0
+#define SYNC 1
+#define SYNC_MDF 2
+#define MDF_AUDIO 3
+#define UNKNOWN -1
 
-void
-toc_file (char *destfilename, int sub)
+int toc_file (char *destfilename, int sub)
 {
-  char destfiletoc[1024], destfiledat[1024];
+  int ret=0;
+  char *destfiletoc;
+  char *destfiledat;
   FILE *ftoc;
-  strcpy (destfiletoc, destfilename);
-  strcpy (destfiledat, destfilename);
+  
+  destfiletoc=strdup(destfilename);
+  destfiledat=strdup(destfilename);
   strcpy (destfiletoc + strlen (destfilename) - 4, ".toc");
   strcpy (destfiledat + strlen (destfilename) - 4, ".dat");
 
@@ -100,11 +102,8 @@
       fprintf (ftoc, "// Track 1\n");
       fprintf (ftoc, "TRACK MODE1_RAW");
 
-      if (sub == 1)
-	fprintf (ftoc, " RW_RAW\n");
-
-      else
-	fprintf (ftoc, "\n");
+    if (sub == 1) fprintf (ftoc, " RW_RAW\n");
+    else fprintf (ftoc, "\n");
 
       fprintf (ftoc, "NO COPY\n");
       fprintf (ftoc, "DATAFILE \"%s\"\n", destfiledat);
@@ -114,26 +113,27 @@
     }
   else
     {
-      printf ("%s\n", strerror (errno));
-      exit (EXIT_FAILURE);
+    printf ("Error opening %s for output: %s\n",destfiletoc,strerror(errno));
+    ret=-1;
     };
-
+  free(destfiletoc);
+  free(destfiledat);
+  return ret;
 }
 
-int
-number_file (char *destfilename)
+/*
+int number_file (char *destfilename)
 {
   int i = 1, test_mdf = 0;
   int n_mdf;
   char mdf[2], destfilemdf[2354];
   FILE *fsource;
+  
   strcpy (destfilemdf, destfilename);
   strcpy (destfilemdf + strlen (destfilename) - 1, ".0");
   for (i = 0; test_mdf == 0; i++)
-
     {
       if ((fsource = fopen (destfilemdf, "rb")) != NULL)
-
 	{
 	  printf ("\nCheck : ");
 	  sprintf (mdf, "md%d", i);
@@ -141,203 +141,219 @@
 	  printf ("%s, ", destfilemdf);
 	  fclose (fsource);
 	}
-
       else
 	{
 	  test_mdf = 1;
 	}
-    };
+  }
   printf ("\r                                   \n");
   n_mdf = i - 1;
   return (n_mdf);
 }
+*/
 
-void
-cuesheets (char *destfilename)
+int cuesheets (char *destfilename)
 {
-  char destfilecue[1024], destfilebin[1024];
+  int ret=0;
+  char *destfilecue;
+  char *destfilebin;
   FILE *fcue;
-  strcpy (destfilecue, destfilename);
-  strcpy (destfilebin, destfilename);
+  
+  destfilecue=strdup(destfilename);
+  destfilebin=strdup(destfilename);
   strcpy (destfilecue + strlen (destfilename) - 4, ".cue");
   strcpy (destfilebin + strlen (destfilename) - 4, ".bin");
-  fcue = fopen (destfilecue, "w");
+  if ((fcue = fopen (destfilecue, "w"))!=NULL)
+  {
   fprintf (fcue, "FILE \"%s\" BINARY\n", destfilebin);
   fprintf (fcue, "TRACK 1 MODE1/2352\n");
   fprintf (fcue, "INDEX 1 00:00:00\n");
   rename (destfilename, destfilebin);
   printf ("Create Cuesheets : %s\n", destfilecue);
   fclose (fcue);
+  }
+  else
+  {
+    printf ("Error opening %s for output: %s\n",destfilecue,strerror(errno));
+    ret=-1;
+  }
+  return ret;
 }
 
-void
-main_percent (int percent_bar)
+int previous_percent=-1;
+void main_percent (int percent_bar)
+// Prints a progress bar, takes a percentage as argument.
 {
-  int progress_bar, progress_space;
+  //int progress_bar, progress_space;
+ 
+  if (percent_bar==previous_percent) return;  // Nothing changed, don't waste CPU cycles.
+  
+  printf("%3d%% [:%.*s>%.*s:]\r",percent_bar,20-(percent_bar/5),"                    ",
+                                                  percent_bar/5,"====================");
+  /*
   printf ("%d%% [:", percent_bar);
-  for (progress_bar = 1; progress_bar <= (int) (percent_bar / 5);
-       progress_bar++)
+  for (progress_bar = 1; progress_bar <= (int) (percent_bar / 5); progress_bar++)
     printf ("=");
   printf (">");
 
-  for (progress_space = 0; progress_space < (20 - progress_bar);
-       progress_space++)
-    printf (" ");
+  for (; progress_bar <= 20; ++progress_bar) printf (" ");
   printf (":]\r");
+  */
 }
 
-void
-usage ()
+void usage ()
+// Prints the command line syntax
 {
-  printf ("mdf2iso v%s by Salvatore Santagati\n", VERSION);
-  printf ("Web     : http//mdf2iso.berlios.de\n");
-  printf ("Email   : salvatore.santagati@gmail.com\n");
-  printf ("Irc     : irc.freenode.net #ignus\n");
-  printf ("Note	: iodellavitanonhocapitouncazzo\n");
-  printf ("License : released under the GNU GPL v2 or later\n\n");
+  printf (" Web     : http//mdf2iso.berlios.de\n");
+  printf (" Email   : salvatore.santagati@gmail.com\n");
+  printf (" Irc     : irc.freenode.net #ignus\n");
+  printf (" Note    : iodellavitanonhocapitouncazzo\n\n");
   printf ("Usage :\n");
-  printf ("mdf2iso [OPTION] [BASENAME.MDF] [DESTINATION]\n\n");
-  printf ("OPTION\n");
-  printf ("\t--toc    Generate toc file\n");
-  printf ("\t--cue    Generate cue file\n");
-  printf ("\t--help   display this notice\n\n");
+  printf ("mdf2iso [--cue|--toc|--help] <sourcefile> [destfile]\n\n");
+  printf ("Options:\n");
+  printf ("  --toc    Generate toc/dat files\n");
+  printf ("  --cue    Generate cue/bin files\n");
+  printf ("  --help   Display this notice\n");
+  printf (" sourcefile\tFilename of the .mdf file to be converted\n");
+  printf (" destfile\tFilename of the target ISO9660 file.\n"\
+          "\t\tIf none given, one is derived from sourcefile.\n\n");
 }
 
-int
-main (int argc, char **argv)
+char mdftype(FILE *f)
+/* returns 
+   -1 for unknown
+   0 for ISO9660
+   1 for SYNC
+   2 for SYNC MDF
+   3 for MDF Audio
+   (see #defines above)
+*/
 {
-  int seek_ecc, sector_size, seek_head, sector_data, n_mdf;
+  char buf[12];
+  
+  fseek(f, 32768, SEEK_SET);
+  fread(buf, sizeof (char), 8, f);
+  if (!memcmp (ISO_9660, buf, 8)) return ISO9660; // File is ISO9660
+  
+  fseek(f, 0L, SEEK_SET);
+  fread(buf, sizeof (char), 12, f);
+  
+  fseek (f, 2352, SEEK_SET);
+  
+  if (!memcmp (SYNC_HEADER, buf, 12))  // Has SYNC_HEADER
+  {
+    fread (buf, sizeof (char), 12, f);
+    if (!memcmp (SYNC_HEADER_MDF, buf, 12)) return SYNC_MDF;   // File is SYNC MDF
+    if (!memcmp (SYNC_HEADER, buf, 12)) return SYNC;       // File is SYNC
+  }
+  else  // Does not have SYNC_HEADER
+  {
+    fread(buf, sizeof (char), 12, f);
+    if (!memcmp (SYNC_HEADER_MDF_AUDIO, buf, 12)) return MDF_AUDIO; // File is MDF Audio
+  }
+
+  // Reached a point where nothing else matters.  
+  return UNKNOWN;  // Unknown format
+}
+
+
+// === Main program code ===
+
+int main (int argc, char **argv)
+{
+  int seek_ecc, sector_size, seek_head, sector_data;//, n_mdf;
   int cue = 0, cue_mode = 0, sub = 1, toc = 0, sub_toc = 0;
   int opts = 0;
-  double size_iso, write_iso;
-  long percent = 0;
-  long i, source_length, progressbar;
-  char buf[2448], destfilename[2354];
+  long i, source_length;
+  char buf[2448];
+  char *destfilename=NULL;
+  char *basefilename=NULL;
   FILE *fdest, *fsource;
 
+  // Print identification
+  printf ("mdf2iso v%s by Salvatore Santagati\n", VERSION);
+  printf ("Licensed under GPL v2 or later\n");
 
-  if (argc < 2)
 
+  // *** Process command line options ***
+  
+  if (argc < 2)
     {
-      usage ();
-      exit (EXIT_FAILURE);
+    // Not enough parameters; print help
+    usage();
+    exit(EXIT_FAILURE);
     }
 
-  else
-
-    {
+  // Search for options --cue and --toc
       for (i = 0; i < argc; i++)
-
 	{
-
 	  if (!strcmp (argv[i], "--help"))
-
 	    {
 	      usage ();
 	      exit (EXIT_SUCCESS);
 	    }
 	  if (!strcmp (argv[i], "--cue"))
-
 	    {
 	      cue = 1;
 	      opts++;
 	    }
 	  if (!strcmp (argv[i], "--toc"))
-
 	    {
 	      toc = 1;
 	      opts++;
 	    }
 	}
 
-      if ((cue == 1) && (toc == 1))
-
-	{
-	  usage ();
-	  exit (EXIT_FAILURE);
-	}
-      if ((opts == 1) && (argc <= 2))
-
+  // Catch impossible parameter combinations
+  if (((cue == 1) && (toc == 1)) ||
+     ((opts == 1) && (argc <= 2)))
 	{
-	  usage ();
-	  exit (EXIT_FAILURE);
+    usage();
+    exit(EXIT_FAILURE);
 	}
 
+  // Get the base filename
+  basefilename=argv[1+opts];  // simple pointer, but makes life easier.
 
+  // Get the destination filename
       if (argc >= (3 + opts))
-	strcpy (destfilename, argv[2 + opts]);
-
-      else
-
-	{
-	  strcpy (destfilename, argv[1 + opts]);
-	  if (strlen (argv[1 + cue]) < 5
-	      || strcmp (destfilename + strlen (argv[1 + opts]) - 4, ".mdf"))
-	    strcpy (destfilename + strlen (argv[1 + opts]), ".iso");
-
+    // The destination filename is explicitly entered at the prompt
+    destfilename=strdup(argv[2 + opts]);
 	  else
-	    strcpy (destfilename + strlen (argv[1 + opts]) - 4, ".iso");
-	}
-      if ((fsource = fopen (argv[1 + opts], "rb")) != NULL)
-
 	{
-	  fseek (fsource, 32768, SEEK_CUR);
-	  fread (buf, sizeof (char), 8, fsource);
-	  if (memcmp (ISO_9660, buf, 8))
-
+    // Derive destination filename from the basename:
+    //  If basename is "*.mdf" use "*.iso" als destname
+    //  otherwise simply append ".iso" to the basename to create destname.
+    destfilename=strdup(basefilename);
+    i=strlen(destfilename);  // Reusing 'i' here as temporary variable
+    if (i < 5 || strcmp(destfilename + i - 4, ".mdf"))
 	    {
-	      fseek (fsource, 0L, SEEK_SET);
-	      fread (buf, sizeof (char), 12, fsource);
-	      if (!memcmp (SYNC_HEADER, buf, 12))
-
-		{
-		  fseek (fsource, 0L, SEEK_SET);
-		  fseek (fsource, 2352, SEEK_CUR);
-		  fread (buf, sizeof (char), 12, fsource);
-		  if (!memcmp (SYNC_HEADER_MDF, buf, 12))
-
-		    {
-		      if (cue == 1)
-			{
-			  cue_mode = 1;
-
-			  /* BAD SECTOR TO NORMAL IMAGE */
-			  seek_ecc = 96;
-			  sector_size = 2448;
-			  sector_data = 2352;
-			  seek_head = 0;
-			}
-
-		      else if (toc == 0)
-
-			{
-
-			  /*BAD SECTOR */
-			  seek_ecc = 384;
-			  sector_size = 2448;
-			  sector_data = 2048;
-			  seek_head = 16;
+      destfilename=realloc(destfilename,i+5); 
+      strcat(destfilename, ".iso");
 			}
-
 		      else
-
-			{
-
-			  /*BAD SECTOR */
-			  seek_ecc = 0;
-			  sector_size = 2448;
-			  sector_data = 2448;
-			  seek_head = 0;
-			  sub_toc = 1;
-			}
+      strcpy(destfilename + i - 3, "iso");
 		    }
 
-		  else
+  // *** Preprocess basefile ***
 
+  // Try opening basefile
+  if ((fsource = fopen(basefilename, "rb")) == NULL)
 		    {
-		      if (!memcmp (SYNC_HEADER, buf, 12))
+    free(destfilename);
+    printf ("Could not open %s: %s\n", basefilename, strerror(errno));
+    exit (EXIT_FAILURE);
+  }
 
+  // Determine filetype & set some stuff accordingly (or exit)
+  switch (mdftype(fsource))
 			{
+    case ISO9660:
+            printf("%s is already ISO9660.\n",basefilename);
+            fclose(fsource);
+            free(destfilename);
+            exit(EXIT_SUCCESS);
+    case SYNC: 
 			  if (cue == 1)
 			    {
 			      cue_mode = 1;
@@ -348,129 +364,134 @@
 			      seek_head = 0;
 			    }
 			  if (toc == 0)
-
 			    {
-
 			      /*NORMAL IMAGE */
 			      seek_ecc = 288;
 			      sector_size = 2352;
 			      sector_data = 2048;
 			      seek_head = 16;
 			    }
-
 			  else
-
 			    {
 			      seek_ecc = 0;
 			      sector_size = 2352;
 			      sector_data = 2352;
 			      seek_head = 0;
 			    }
-			}
-
-		      else
-
-			{
-			  printf ("Sorry I don't know this format :(\n");
-			  exit (EXIT_FAILURE);
-			}
-		    }
-		}
-
-	      else
-
+            break;
+    case SYNC_MDF:
+            if (cue == 1)
 		{
-		  fseek (fsource, 0L, SEEK_SET);
-		  fseek (fsource, 2352, SEEK_CUR);
-		  fread (buf, sizeof (char), 12, fsource);
-		  if (memcmp (SYNC_HEADER_MDF_AUDIO, buf, 12))
+              cue_mode = 1;
 
+              /* BAD SECTOR TO NORMAL IMAGE */
+              seek_ecc = 96;
+              sector_size = 2448;
+              sector_data = 2352;
+              seek_head = 0;
+            }
+            else if (toc == 0)
 		    {
-		      printf ("Sorry I don't know this format :(\n");
-		      exit (EXIT_FAILURE);
+              /*BAD SECTOR */
+              seek_ecc = 384;
+              sector_size = 2448;
+              sector_data = 2048;
+              seek_head = 16;
 		    }
-
 		  else
-
 		    {
-
+              /*BAD SECTOR */
+              seek_ecc = 0;
+              sector_size = 2448;
+              sector_data = 2448;
+              seek_head = 0;
+              sub_toc = 1;
+            }
+            break;
+    case MDF_AUDIO:
 		      /*BAD SECTOR AUDIO */
 		      seek_head = 0;
 		      sector_size = 2448;
 		      seek_ecc = 96;
 		      sector_data = 2352;
 		      cue = 0;
+            break;
+    default:printf("Unknown format for %s.\n",basefilename);
+            fclose(fsource);
+            free(destfilename);
+            exit (EXIT_FAILURE);
 		    }
-		}
-	      if ((fdest = fopen (destfilename, "wb")) != NULL);
 
-	      else
+  //  *** Create destination file ***
+    
+  // Try opening the destination file for output
+  if ((fdest = fopen (destfilename, "wb")) == NULL)
 		{
-		  printf ("%s\n", strerror (errno));
+    printf ("Unable to open %s for output: %s\n",destfilename,strerror(errno));
+    free(destfilename);
+    fclose(fsource);
 		  exit (EXIT_FAILURE);
-		};
+  }
+
+    
 	      fseek (fsource, 0L, SEEK_END);
 	      source_length = ftell (fsource) / sector_size;
-	      size_iso = (int) (source_length * sector_data);
-	      progressbar = 100 / source_length;
 	      fseek (fsource, 0L, SEEK_SET);
-
 	      {
 		for (i = 0; i < source_length; i++)
-
 		  {
 		    fseek (fsource, seek_head, SEEK_CUR);
-		    if (fread (buf, sizeof (char), sector_data, fsource));
-
-		    else
+      if (fread(buf, sizeof (char), sector_data, fsource)!=sector_data)
 		      {
-			printf ("%s\n", strerror (errno));
+        printf ("Error reading from %s: %s\n",basefilename, strerror (errno));
+        fclose(fsource);
+        fclose(fdest);
+        remove(destfilename);
+        free(destfilename);
 			exit (EXIT_FAILURE);
-		      };
-		    if (fwrite (buf, sizeof (char), sector_data, fdest));
-
-		    else
+      }
+      if (fwrite (buf, sizeof (char), sector_data, fdest)!=sector_data)
 		      {
-			printf ("%s\n", strerror (errno));
+        printf ("Error writing to %s: %s\n",destfilename, strerror (errno));
+        fclose(fsource);
+        fclose(fdest);
+        remove(destfilename);
+        free(destfilename);
 			exit (EXIT_FAILURE);
-		      };
+      }
 		    fseek (fsource, seek_ecc, SEEK_CUR);
-		    write_iso = (int) (sector_data * i);
-		    if (i != 0)
-		      percent = (int) (write_iso * 100 / size_iso);
-		    main_percent (percent);
-	      }} printf ("100%%[:====================:]\n");
+      main_percent(i*100/source_length);
+    }
+  } printf ("100%% [:=====================:]\n");
 
 	      fclose (fsource);
 	      fclose (fdest);
 
-	      if (cue == 1)
-		cuesheets (destfilename);
-	      if (toc == 1)
-		toc_file (destfilename, sub_toc);
+  // *** create Toc or Cue file is requested ***
+  if (cue == 1) if (cuesheets(destfilename))
+  {
+    free(destfilename);
+    exit(EXIT_FAILURE);
+  }
+  if (toc == 1) if (toc_file(destfilename, sub_toc))
+  {
+    free(destfilename);
+    exit(EXIT_FAILURE);
+  }
 	      if ((toc == 0) && (cue == 0))
-		printf ("Create iso9660: %s\n", destfilename);
+    printf("Created iso9660: %s\n", destfilename);
+
+  free(destfilename);
 
 	      exit (EXIT_SUCCESS);
-	    }
 
-	  else
-	    printf ("This is file iso9660 ;)\n");
+/*
 	  n_mdf = number_file (destfilename) - 1;
-	  /* if (n_mdf > 1)
-
+  / * if (n_mdf > 1) 
 	     {
 	     printf ("\rDetect %d md* file and now emerge this\n", n_mdf);
 	     }
-	   */
+  * /
 	  fclose (fsource);
-	  exit (EXIT_SUCCESS);
-	}
-
-      else
-	{
-	  printf ("%s\n", strerror (errno));
-	  exit (EXIT_FAILURE);
-	};
-    }
+  exit (EXIT_SUCCESS);*/
 }