Debian Codegraph @

debian/patches/nice

raw symbols SCIP
1 Description: <short summary of the patch>
2 TODO: Put a short summary on the line above and replace this paragraph
3 with a longer explanation of this change. Complete the meta-information
4 with other relevant fields (see below for details). To make it easier, the
5 information below has been extracted from the changelog. Adjust it or drop
6 it.
7 .
8 bchunk (1.2.2+git20220715+ds-1) unstable; urgency=medium
9 .
10 * New upstream version from fork. (Closes: #261278, #271285)
11 * Bump standards version to 4.6.1.
12 * Bump debhelper version to 13, drop d/compat.
13 * Update maintainer address.
14 Author: Gürkan Myczko <[email protected]>
15 Bug-Debian: https://bugs.debian.org/261278
16 Bug-Debian: https://bugs.debian.org/271285
17
18 ---
19 The information above should follow the Patch Tagging Guidelines, please
20 checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
21 are templates for supplementary fields that you might want to add:
22
23 Origin: <vendor|upstream|other>, <url of original patch>
24 Bug: <url in upstream bugtracker>
25 Bug-Debian: https://bugs.debian.org/<bugnumber>
26 Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
27 Forwarded: <no|not-needed|url proving that it has been forwarded>
28 Reviewed-By: <name and email of someone who approved the patch>
29 Last-Update: 2022-07-15
30
31 --- bchunk-1.2.2+git20220715+ds.orig/COPYING
32 +++ bchunk-1.2.2+git20220715+ds/COPYING
33 @@ -1,12 +1,13 @@
34 - GNU GENERAL PUBLIC LICENSE
35 - Version 2, June 1991
36
37 - Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
38 - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
39 + GNU GENERAL PUBLIC LICENSE
40 + Version 2, June 1991
41 +
42 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
43 + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44 Everyone is permitted to copy and distribute verbatim copies
45 of this license document, but changing it is not allowed.
46
47 - Preamble
48 + Preamble
49
50 The licenses for most software are designed to take away your
51 freedom to share and change it. By contrast, the GNU General Public
52 @@ -15,7 +16,7 @@ software--to make sure the software is f
53 General Public License applies to most of the Free Software
54 Foundation's software and to any other program whose authors commit to
55 using it. (Some other Free Software Foundation software is covered by
56 -the GNU Lesser General Public License instead.) You can apply it to
57 +the GNU Library General Public License instead.) You can apply it to
58 your programs, too.
59
60 When we speak of free software, we are referring to freedom, not
61 @@ -55,8 +56,8 @@ patent must be licensed for everyone's f
62
63 The precise terms and conditions for copying, distribution and
64 modification follow.
65 -
66 - GNU GENERAL PUBLIC LICENSE
67 +
68 + GNU GENERAL PUBLIC LICENSE
69 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
70
71 0. This License applies to any program or other work which contains
72 @@ -110,7 +111,7 @@ above, provided that you also meet all o
73 License. (Exception: if the Program itself is interactive but
74 does not normally print such an announcement, your work based on
75 the Program is not required to print an announcement.)
76 -
77 +
78 These requirements apply to the modified work as a whole. If
79 identifiable sections of that work are not derived from the Program,
80 and can be reasonably considered independent and separate works in
81 @@ -168,7 +169,7 @@ access to copy from a designated place,
82 access to copy the source code from the same place counts as
83 distribution of the source code, even though third parties are not
84 compelled to copy the source along with the object code.
85 -
86 +
87 4. You may not copy, modify, sublicense, or distribute the Program
88 except as expressly provided under this License. Any attempt
89 otherwise to copy, modify, sublicense or distribute the Program is
90 @@ -225,7 +226,7 @@ impose that choice.
91
92 This section is intended to make thoroughly clear what is believed to
93 be a consequence of the rest of this License.
94 -
95 +
96 8. If the distribution and/or use of the Program is restricted in
97 certain countries either by patents or by copyrighted interfaces, the
98 original copyright holder who places the Program under this License
99 @@ -255,7 +256,7 @@ make exceptions for this. Our decision
100 of preserving the free status of all derivatives of our free software and
101 of promoting the sharing and reuse of software generally.
102
103 - NO WARRANTY
104 + NO WARRANTY
105
106 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
107 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
108 @@ -277,9 +278,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE
109 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
110 POSSIBILITY OF SUCH DAMAGES.
111
112 - END OF TERMS AND CONDITIONS
113 -
114 - How to Apply These Terms to Your New Programs
115 + END OF TERMS AND CONDITIONS
116 +
117 + How to Apply These Terms to Your New Programs
118
119 If you develop a new program, and you want it to be of the greatest
120 possible use to the public, the best way to achieve this is to make it
121 @@ -291,7 +292,7 @@ convey the exclusion of warranty; and ea
122 the "copyright" line and a pointer to where the full notice is found.
123
124 <one line to give the program's name and a brief idea of what it does.>
125 - Copyright (C) <year> <name of author>
126 + Copyright (C) 19yy <name of author>
127
128 This program is free software; you can redistribute it and/or modify
129 it under the terms of the GNU General Public License as published by
130 @@ -303,16 +304,17 @@ the "copyright" line and a pointer to wh
131 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132 GNU General Public License for more details.
133
134 - You should have received a copy of the GNU General Public License along
135 - with this program; if not, write to the Free Software Foundation, Inc.,
136 - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
137 + You should have received a copy of the GNU General Public License
138 + along with this program; if not, write to the Free Software
139 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
140 +
141
142 Also add information on how to contact you by electronic and paper mail.
143
144 If the program is interactive, make it output a short notice like this
145 when it starts in an interactive mode:
146
147 - Gnomovision version 69, Copyright (C) year name of author
148 + Gnomovision version 69, Copyright (C) 19yy name of author
149 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
150 This is free software, and you are welcome to redistribute it
151 under certain conditions; type `show c' for details.
152 @@ -335,5 +337,5 @@ necessary. Here is a sample; alter the
153 This General Public License does not permit incorporating your program into
154 proprietary programs. If your program is a subroutine library, you may
155 consider it more useful to permit linking proprietary applications with the
156 -library. If this is what you want to do, use the GNU Lesser General
157 +library. If this is what you want to do, use the GNU Library General
158 Public License instead of this License.
159 --- bchunk-1.2.2+git20220715+ds.orig/ChangeLog
160 +++ bchunk-1.2.2+git20220715+ds/ChangeLog
161 @@ -63,19 +63,3 @@
162 Clarify manual page for input/output file types
163 Improvement from Reuben Thomas, debian bug: #503151
164
165 -1.2.3 - Jun 30 2022 - twojstaryzdomu
166 -
167 - Added support for track # and multiple bin FILEs in cue sheet.
168 - The output files are now named after the FILE with the appropriate
169 - output extension added, without a track # inserted in between the
170 - basename and the extension. The -t option includes the track # in
171 - the output filenames as done by default in earlier releases.
172 -
173 - Sealed various memory leaks. Refactored exit statements.
174 -
175 - Abort further processing if output file already exists.
176 -
177 - Added support for ## as track # replacement token in the basename
178 - parameter.
179 -
180 - Added support for splitting WAV files into individual tracks.
181 --- bchunk-1.2.2+git20220715+ds.orig/Makefile
182 +++ bchunk-1.2.2+git20220715+ds/Makefile
183 @@ -12,9 +12,6 @@ CFLAGS = -Wall -Wstrict-prototypes -O2
184
185 # For BSD install: Which install to use and where to put the files
186 INSTALL = install
187 -INSTALL_DIR = $(INSTALL) -d -m 0755
188 -INSTALL_DATA = $(INSTALL) -m 0644
189 -INSTALL_EXEC = $(INSTALL) -m 0755
190 PREFIX = /usr/local
191 BIN_DIR = $(PREFIX)/bin
192 MAN_DIR = $(PREFIX)/man
193 @@ -29,16 +26,14 @@ distclean: clean
194
195 install: installbin installman
196 installbin:
197 - $(INSTALL_DIR) $(DESTDIR)$(BIN_DIR)
198 - $(INSTALL_EXEC) -s bchunk $(DESTDIR)$(BIN_DIR)
199 + $(INSTALL) -m 755 -s bchunk $(BIN_DIR)
200 installman:
201 - $(INSTALL_DIR) $(DESTDIR)$(MAN_DIR)/man1
202 - $(INSTALL_DATA) bchunk.1 $(DESTDIR)$(MAN_DIR)/man1
203 + $(INSTALL) -m 644 bchunk.1 $(MAN_DIR)/man1
204
205 BITS = bchunk.o
206
207 bchunk: $(BITS)
208 - $(LD) -o bchunk $(BITS) $(LDFLAGS)
209 + $(LD) $(LDFLAGS) -o bchunk $(BITS)
210
211 bchunk.o: bchunk.c
212
213 --- bchunk-1.2.2+git20220715+ds.orig/README
214 +++ bchunk-1.2.2+git20220715+ds/README
215 @@ -1,5 +1,5 @@
216
217 - binchunker for Unix, version 1.2.3
218 + binchunker for Unix, version 1.2.2
219 Copyright (C) 1998-2004 Heikki Hannikainen <[email protected]>
220
221 Enhancements provided by:
222 @@ -9,7 +9,6 @@
223 Piotr Kaczuba <[email protected]>, 2009
224 Reuben Thomas <[email protected]>, 2008
225 Yegor Timoshenko <[email protected]>, 2017
226 - twojstaryzdomu <@github.com>, 2022
227
228
229 http://he.fi/bchunk/
230 @@ -53,7 +52,7 @@
231 Colas Nahaboo <[email protected]> and Godmar Back <[email protected]>
232 added support for MODE2/2352 ISO data tracks in bchunk 1.1.0.
233 Matthew Green implemented the -r option for raw MODE2/2352
234 - extraction for bchunk 1.2.0.
235 + exctraction for bchunk 1.2.0.
236
237 ---
238
239 @@ -62,9 +61,6 @@
240 binchunker converts a CD image in a ".bin / .cue" format
241 (sometimes ".raw / .cue") to a set of .iso and .cdr tracks.
242
243 - It also allows to split uncompressed PCM audio files in the
244 - WAV format into individual tracks.
245 -
246 The bin/cue format is used by some non-Unix cd-writing
247 software, but is not supported on most other cd-writing
248 programs.
249 @@ -89,8 +85,8 @@
250
251 How to install this stuff:
252
253 - $ gzip -d -c bchunk-1.2.3.tar.gz | tar xvf -
254 - $ cd bchunk-1.2.3
255 + $ gzip -d -c bchunk-1.2.2.tar.gz | tar xvf -
256 + $ cd bchunk-1.2.2
257 $ make
258 # make install
259
260 @@ -120,23 +116,13 @@
261
262 How to use this stuff:
263
264 - bchunk [-t] [-v] [-p (PSX)] [-r (raw)] [-w (wav)] [-s (swabaudio)]
265 - <image.bin | image.wav | track # | '*'> <image.cue> [ <basename> ]
266 + bchunk [-v] [-p (PSX)] [-r (raw)] [-w (wav)] [-s (swabaudio)]
267 + <image.bin> <image.cue> <basename>
268
269 - image.bin is a source raw cd image file and image.wav is an
270 - uncompressed PCM audio file, either listed in the
271 - cue sheet file as a FILE. track # identifies the track listed
272 - in the cue sheet as a TRACK. The wildcard '*' (quoted)
273 - selects all tracks for conversion. image.cue is the cue sheet
274 - file containing filenames, track types and offsets. The optional
275 - basename is used for the leading part of the output filenames.
276 - By default, the output files are now named after the basename
277 - of the source image file or the track #, ending with the
278 - appropriate format extension. basename may contain the track
279 - token ## which will be replaced by the track number.
280 -
281 - The -t flag adds the track # in the output filename between
282 - the basename & the extension, as in versions prior to 1.2.3.
283 + image.bin is the raw cd image file. image.cue is the
284 + track index file containing track types and offsets.
285 + basename is used for the beginning part of the created
286 + track files.
287
288 The -v flag makes binchunker print some more unnecessary
289 messages, which should not be of interest for anyone.
290 @@ -151,7 +137,7 @@
291 The -p and -r flags works only with MODE2/2352 input (if input
292 is in PSX mode pass -p flag or if it is in raw format pass
293 -r flag).
294 -
295 +
296 The -w flag makes binchunker write audio tracks in WAV format.
297
298 The -s flag makes binchunker swap byte order in the samples of
299 --- bchunk-1.2.2+git20220715+ds.orig/bchunk.1
300 +++ bchunk-1.2.2+git20220715+ds/bchunk.1
301 @@ -1,10 +1,8 @@
302 -.TH BCHUNK 1 "v1.2.3 30 Jun 2022" "Heikki Hannikainen"
303 +.TH BCHUNK 1 "v1.2.2 14 Nov 2017" "Heikki Hannikainen"
304 .SH NAME
305 bchunk \- CD image format conversion from bin/cue to iso/cdr
306 -and WAV file splitter
307 .SH SYNOPSIS
308 -.B bchunk [-t] [-v] [-p] [-r] [-w] [-s]
309 -<image.bin | image.wav | track # | '*'> <image.cue> [ <basename> ]
310 +.B bchunk [-v] [-p] [-r] [-w] [-s] <image.bin> <image.cue> <basename>
311 .SH DESCRIPTION
312 .LP
313 .B bchunk
314 @@ -15,19 +13,10 @@ The bin/cue format is used by some non-U
315 software, but is not supported on most other cd-writing
316 programs.
317 .LP
318 -It also allows to split uncompressed PCM audio files in the
319 -WAV format into individual tracks.
320 -.LP
321 -\fIimage.bin\fP is a raw cd image file and \fIimage.wav\fP is an
322 -uncompressed PCM audio file, either listed in the cue sheet file
323 -as a FILE. \fItrack #\fP is the track number listed in the cue sheet
324 -as a TRACK. \fItrack #\fP may omit the leading 0s. The wildcard
325 -'\fI*\fP' (single quoted to prevent shell expansion) selects all
326 -tracks from a cue sheet for conversion. \fIimage.cue\fP is the cue
327 -sheet file containing track types and offsets. \fIbasename\fP is
328 -optionally used for the leading part of output filenames.
329 -\fIbasename\fP may contain the track token '##' which will be
330 -replaced by the track number.
331 +image.bin is the raw cd image file. image.cue is the
332 +track index file containing track types and offsets.
333 +basename is used for the beginning part of the created
334 +track files.
335 .LP
336 The produced .iso track contains an ISO file system, which can be
337 mounted through a loop device on Linux systems, or
338 @@ -49,12 +38,6 @@ The format itself does not contain this
339 case it can only guess.
340 .SH OPTIONS
341 .TP 10
342 -.BI \-t
343 -Adds the track # in the output filename between the basename &
344 -the extension, as in
345 -.B bchunk
346 -releases prior to 1.2.3.
347 -.TP 10
348 .BI \-v
349 Makes binchunker print some more unnecessary messages, which should
350 not be of interest for anyone.
351 @@ -78,14 +61,10 @@ raw format.
352 .LP
353 .TP 5
354 .B image.bin
355 -Raw CD image file, listed in the cue sheet as a FILE.
356 -.TP 5
357 -.B image.wav
358 -WAV file with uncompressed PCM audio, listed in the cue sheet
359 -as a FILE.
360 +Raw CD image file
361 .TP 5
362 .B image.cue
363 -Cue sheet, TOC (Track index, Table Of Contents) file.
364 +TOC (Track index, Table Of Contents) file
365 .TP 5
366 .B *.iso
367 Tracks in ISO9660 CD filesystem format. Can be either written on a
368 @@ -116,5 +95,3 @@ Godmar Back <[email protected]>
369 .br
370 Matthew Green <[email protected]>
371 .br
372 -twojstaryzdomu <@github.com>
373 -.br
374 --- bchunk-1.2.2+git20220715+ds.orig/bchunk.c
375 +++ bchunk-1.2.2+git20220715+ds/bchunk.c
376 @@ -19,22 +19,17 @@
377 */
378
379 #define _GNU_SOURCE
380 -#include <stdarg.h>
381 #include <stdio.h>
382 #include <stdlib.h>
383 #include <string.h>
384 #include <errno.h>
385 #include <unistd.h>
386
387 -#define VERSION "1.2.3"
388 -#define USAGE "Usage: bchunk [-t] [-v] [-r] [-p (PSX)] [-w (wav)] [-s (swabaudio)]\n" \
389 - " <image.bin | image.wav | track # | '*'> <image.cue> [ <basename> ]\n" \
390 +#define VERSION "1.2.2"
391 +#define USAGE "Usage: bchunk [-v] [-r] [-p (PSX)] [-w (wav)] [-s (swabaudio)]\n" \
392 + " <image.bin> <image.cue> <basename>\n" \
393 "Example: bchunk foo.bin foo.cue foo\n" \
394 - " bchunk foo.bin foo.cue\n" \
395 - " bchunk 2 foo.cue foo\n" \
396 - " -t Insert track # in between the basename and the format extension\n" \
397 " -v Verbose mode\n" \
398 - " -d Debug mode\n" \
399 " -r Raw mode for MODE2/2352: write all 2352 bytes from offset 0 (VCD/MPEG)\n" \
400 " -p PSX mode for MODE2/2352: write 2336 bytes from offset 24\n" \
401 " (default MODE2/2352 mode writes 2048 bytes from offset 24)\n"\
402 @@ -46,11 +41,8 @@
403 "\tpartly based on his Pascal (Delphi) implementation.\n" \
404 "\tSupport for MODE2/2352 ISO tracks thanks to input from\n" \
405 "\tGodmar Back <[email protected]>, Colas Nahaboo <[email protected]>\n" \
406 - "\tMatthew Green <[email protected]> & twojstaryzdomu <@github.com>.\n" \
407 + "\tand Matthew Green <[email protected]>.\n" \
408 "\tReleased under the GNU GPL, version 2 or later (at your option).\n\n"
409 -
410 -#define HINT "\nUse '-t' to include track # in output filename. " \
411 - "Remaining tracks were not processed\n"
412
413 #define CUELLEN 1024
414 #define SECTLEN 2352
415 @@ -58,12 +50,7 @@
416 #define WAV_RIFF_HLEN 12
417 #define WAV_FORMAT_HLEN 24
418 #define WAV_DATA_HLEN 8
419 -#define WAV_DATA_FOURCC "data"
420 -#define WAV_DATA_FLEN sizeof(WAV_DATA_FOURCC) - 1
421 #define WAV_HEADER_LEN WAV_RIFF_HLEN + WAV_FORMAT_HLEN + WAV_DATA_HLEN
422 -#define WAV_HEADER_MAX WAV_HEADER_LEN + 100
423 -
424 -#define TRACK_TOKEN "##"
425
426 /*
427 * Ugly way to convert integers to little-endian format.
428 @@ -72,11 +59,7 @@
429 */
430
431 #include <inttypes.h>
432 -#ifdef _WIN32
433 -#include <winsock2.h>
434 -#else
435 #include <netinet/in.h>
436 -#endif
437
438 #define bswap_16(x) \
439 ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
440 @@ -93,13 +76,10 @@ struct track_t {
441 int num;
442 int mode;
443 int audio;
444 - char *file;
445 - char *output;
446 char *modes;
447 char *extension;
448 int bstart;
449 int bsize;
450 - long dataoffs;
451 long startsect;
452 long stopsect;
453 long start;
454 @@ -110,65 +90,11 @@ struct track_t {
455 char *basefile = NULL;
456 char *binfile = NULL;
457 char *cuefile = NULL;
458 -char *bname = NULL;
459 -char *file = NULL;
460 int verbose = 0;
461 -int debug = 0;
462 int psxtruncate = 0;
463 int raw = 0;
464 int swabaudio = 0;
465 int towav = 0;
466 -int trackadd = 0;
467 -FILE *binf, *cuef;
468 -struct track_t *tracks = NULL;
469 -struct track_t *track = NULL;
470 -
471 -void free_all(void)
472 -{
473 - if (binf)
474 - fclose(binf);
475 - if (cuef)
476 - fclose(cuef);
477 - struct track_t *next;
478 - for (track = tracks; (track); track = next) {
479 - next = track->next;
480 - free(track->file);
481 - free(track->output);
482 - free(track->modes);
483 - free(track);
484 - }
485 - free(basefile);
486 - free(binfile);
487 - free(cuefile);
488 - free(file);
489 - free(bname);
490 -}
491 -
492 -void die_format(int status, char *format, ...)
493 -{
494 - va_list args;
495 - va_start(args, format);
496 - vfprintf(stderr, format, args);
497 - va_end(args);
498 - free_all();
499 - exit(status);
500 -}
501 -#define die(status, error) die_format(status, "%s", error)
502 -
503 -/*
504 - * Copy a string until the final '.'
505 - */
506 -
507 -char* prune_ext(char *src)
508 -{
509 - char *dst;
510 - char *e = strrchr(src, '.');
511 - int l = e ? e - src : strlen(src);
512 - if (!(dst = malloc(l + 1)))
513 - die(4, "prune_ext(): malloc() failed, out of memory\n");
514 - dst[l] = '\0';
515 - return strncpy(dst, src, l);
516 -}
517
518 /*
519 * Parse arguments
520 @@ -178,7 +104,7 @@ void parse_args(int argc, char *argv[])
521 {
522 int s;
523
524 - while ((s = getopt(argc, argv, "swvp?hrtd")) != -1) {
525 + while ((s = getopt(argc, argv, "swvp?hr")) != -1) {
526 switch (s) {
527 case 'r':
528 raw = 1;
529 @@ -186,9 +112,6 @@ void parse_args(int argc, char *argv[])
530 case 'v':
531 verbose = 1;
532 break;
533 - case 'd':
534 - debug = 1;
535 - break;
536 case 'w':
537 towav = 1;
538 break;
539 @@ -198,32 +121,34 @@ void parse_args(int argc, char *argv[])
540 case 's':
541 swabaudio = 1;
542 break;
543 - case 't':
544 - trackadd = 1;
545 - break;
546 case '?':
547 case 'h':
548 - die_format(0, "%s", USAGE);
549 + fprintf(stderr, "%s", USAGE);
550 + exit(0);
551 }
552 }
553
554 - if (argc - optind < 2)
555 - die_format(1, "%s", USAGE);
556 + if (argc - optind != 3) {
557 + fprintf(stderr, "%s", USAGE);
558 + exit(1);
559 + }
560
561 - for (int i = optind; i < argc; i++) {
562 - switch (i - optind) {
563 - case 0:
564 - binfile = strdup(argv[i]);
565 - break;
566 - case 1:
567 - cuefile = strdup(argv[i]);
568 + while (optind < argc) {
569 + switch (argc - optind) {
570 + case 3:
571 + binfile = strdup(argv[optind]);
572 break;
573 case 2:
574 - basefile = strdup(argv[i]);
575 + cuefile = strdup(argv[optind]);
576 + break;
577 + case 1:
578 + basefile = strdup(argv[optind]);
579 break;
580 default:
581 - die_format(1, "Gratuitous argument %s\n%s", argv[i], USAGE);
582 + fprintf(stderr, "%s", USAGE);
583 + exit(1);
584 }
585 + optind++;
586 }
587 }
588
589 @@ -254,44 +179,6 @@ long time2frames(char *s)
590 }
591
592 /*
593 - * Check WAV file name extension
594 - */
595 -
596 -int is_wav_file(struct track_t *track) {
597 - static char ext_wav[] = ".wav";
598 - return !strcasecmp(track->file + strlen(track->file) - strlen(ext_wav), ext_wav);
599 -}
600 -
601 -/*
602 - * Set WAV data header offset
603 - */
604 -
605 -int set_wav_data_offset(FILE *bf, struct track_t *track) {
606 - char s[WAV_DATA_FLEN+1];
607 - s[WAV_DATA_FLEN] = '\0';
608 - for (int offset = WAV_HEADER_LEN; offset < WAV_HEADER_MAX; offset++) {
609 - if (fseek(binf, offset, SEEK_SET) == -1)
610 - die_format(4, " Could not fseek to offset %d: %s\n", offset, strerror(errno));
611 - fread(s, WAV_DATA_FLEN, 1, binf);
612 - if (strcmp(WAV_DATA_FOURCC, s) == 0) {
613 - track->dataoffs = offset + WAV_DATA_HLEN;
614 - if (debug) {
615 - fseek(binf, offset + WAV_DATA_FLEN, SEEK_SET);
616 - uint32_t w;
617 - fread(&w, WAV_DATA_FLEN, 1, binf);
618 - fprintf(stderr, " data header at %d\n"
619 - " WAV data at %ld\n"
620 - " WAV data bytes %u\n",
621 - offset, track->dataoffs, w);
622 - }
623 - return 1;
624 - }
625 - }
626 - printf("No WAV data header found in %s for track %d\n", track->file, track->num);
627 - return 0;
628 -}
629 -
630 -/*
631 * Parse the mode string
632 */
633
634 @@ -333,7 +220,7 @@ void gettrackmode(struct track_t *track,
635 track->bsize = 2336;
636 track->extension = ext_iso;
637
638 - } else if (!strcasecmp(modes, "AUDIO") || is_wav_file(track)) {
639 + } else if (!strcasecmp(modes, "AUDIO")) {
640 track->bstart = 0;
641 track->bsize = 2352;
642 track->audio = 1;
643 @@ -374,8 +261,9 @@ char *progressbar(float f, int l)
644 * Write a track
645 */
646
647 -int writetrack(FILE *bf, struct track_t *track)
648 +int writetrack(FILE *bf, struct track_t *track, char *bname)
649 {
650 + char *fname;
651 FILE *f;
652 char buf[SECTLEN+10];
653 long sz, sect, realsz, reallen;
654 @@ -384,29 +272,30 @@ int writetrack(FILE *bf, struct track_t
655 int16_t i;
656 float fl;
657
658 - if (!(f = fopen(track->output, "wbx"))) {
659 - if (errno == EEXIST)
660 - die_format(5, "%2d: skipped: output file %s already exists, aborting\n%s",
661 - track->num, track->output, HINT);
662 - else
663 - die_format(4, " Could not fopen track file: %s\n", strerror(errno));
664 + if (asprintf(&fname, "%s%2.2d.%s", bname, track->num, track->extension) == -1) {
665 + fprintf(stderr, "writetrack(): asprintf() failed, out of memory\n");
666 + exit(4);
667 }
668
669 - printf("%2d: %s ", track->num, track->output);
670 + printf("%2d: %s ", track->num, fname);
671
672 - if (fseek(bf, track->start + track->dataoffs, SEEK_SET))
673 - die_format(4, " Could not fseek to track location: %s\n", strerror(errno));
674 + if (!(f = fopen(fname, "w"))) {
675 + fprintf(stderr, " Could not fopen track file: %s\n", strerror(errno));
676 + exit(4);
677 + }
678 +
679 + if (fseek(bf, track->start, SEEK_SET)) {
680 + fprintf(stderr, " Could not fseek to track location: %s\n", strerror(errno));
681 + exit(4);
682 + }
683
684 reallen = (track->stopsect - track->startsect + 1) * track->bsize;
685 if (verbose) {
686 - printf( "\n mmc sectors %ld->%ld (%ld)"
687 - "\n mmc bytes %ld->%ld (%ld)"
688 - "\n sector data at %d, %d bytes per sector"
689 - "\n real data %ld bytes\n",
690 - track->startsect, track->stopsect, track->stopsect - track->startsect + 1,
691 - track->start, track->stop, track->stop - track->start + 1,
692 - track->bstart, track->bsize,
693 - reallen);
694 + printf("\n mmc sectors %ld->%ld (%ld)", track->startsect, track->stopsect, track->stopsect - track->startsect + 1);
695 + printf("\n mmc bytes %ld->%ld (%ld)", track->start, track->stop, track->stop - track->start + 1);
696 + printf("\n sector data at %d, %d bytes per sector", track->bstart, track->bsize);
697 + printf("\n real data %ld bytes", (track->stopsect - track->startsect + 1) * track->bsize);
698 + printf("\n");
699 }
700
701 printf(" ");
702 @@ -434,7 +323,7 @@ int writetrack(FILE *bf, struct track_t
703 i = htoles(2*8); // bits per channel
704 fwrite(&i, 2, 1, f);
705 // DATA header
706 - fputs(WAV_DATA_FOURCC, f);
707 + fputs("data", f);
708 l = htolel(reallen);
709 fwrite(&l, 4, 1, f);
710 }
711 @@ -443,7 +332,6 @@ int writetrack(FILE *bf, struct track_t
712 sz = track->start;
713 sect = track->startsect;
714 fl = 0;
715 -
716 while ((sect <= track->stopsect) && (fread(buf, SECTLEN, 1, bf) > 0)) {
717 if (track->audio) {
718 if (swabaudio) {
719 @@ -459,8 +347,10 @@ int writetrack(FILE *bf, struct track_t
720 }
721 }
722 }
723 - if (fwrite(&buf[track->bstart], track->bsize, 1, f) < 1)
724 - die_format(4, " Could not write to track: %s\n", strerror(errno));
725 + if (fwrite(&buf[track->bstart], track->bsize, 1, f) < 1) {
726 + fprintf(stderr, " Could not write to track: %s\n", strerror(errno));
727 + exit(4);
728 + }
729 sect++;
730 sz += SECTLEN;
731 realsz += track->bsize;
732 @@ -475,131 +365,79 @@ int writetrack(FILE *bf, struct track_t
733 printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b%4ld/%-4ld MB [%s] %3.0f %%", realsz/1024/1024, reallen/1024/1024, progressbar(1, 20), fl * 100);
734 fflush(stdout);
735
736 - if (ferror(bf))
737 - die_format(4, " Could not read from %s: %s\n", binfile, strerror(errno));
738 - if (fclose(f))
739 - die_format(4, " Could not fclose track file: %s\n", strerror(errno));
740 + if (ferror(bf)) {
741 + fprintf(stderr, " Could not read from %s: %s\n", binfile, strerror(errno));
742 + exit(4);
743 + }
744 +
745 + if (fclose(f)) {
746 + fprintf(stderr, " Could not fclose track file: %s\n", strerror(errno));
747 + exit(4);
748 + }
749
750 printf("\n");
751 return 0;
752 }
753
754 /*
755 - * Sets output filename
756 - */
757 -
758 -int set_output(struct track_t *track, char *binfile, char *basefile, int trackadd) {
759 - char *e, *s, *t;
760 - if (strchr(binfile, '*')) {
761 - if (!basefile)
762 - bname = prune_ext(track->file);
763 - else
764 - if (asprintf(&bname, "%s", basefile) == -1)
765 - die(4, "set_output(): asprintf() failed, out of memory\n");
766 - } else if (strcmp(track->file, binfile) != 0) {
767 - long num = strtol(binfile, &t, 10);
768 - if (strlen(t) || num != track->num) {
769 - printf("%2d: skipped: %s not matching FILE or TRACK from cuesheet\n", track->num, binfile);
770 - return 0;
771 - }
772 - }
773 - if (!bname) {
774 - if (!basefile)
775 - bname = prune_ext(binfile);
776 - else
777 - if (asprintf(&bname, "%s", basefile) == -1)
778 - die(4, "set_output(): asprintf() failed, out of memory\n");
779 - }
780 - if (basefile)
781 - if ((e = strstr(basefile, TRACK_TOKEN))) {
782 - int l = e - basefile;
783 - if (!(s = calloc(l + 1, 1)))
784 - die(4, "set_output(): calloc() failed, out of memory\n");
785 - strncpy(s, basefile, l);
786 - if (bname)
787 - t = bname;
788 - if (asprintf(&bname, "%s%.2d%s", s, track->num, e + strlen(TRACK_TOKEN)) == -1)
789 - die(4, "set_output(): asprintf() failed, out of memory\n");
790 - free(s);
791 - free(t);
792 - }
793 - if (trackadd) {
794 - if (bname)
795 - t = bname;
796 - if (asprintf(&bname, "%s%2.2d", bname ? bname : "", track->num) == -1)
797 - die(4, "set_output(): asprintf() failed, out of memory\n");
798 - free(t);
799 - }
800 - if (asprintf(&track->output, "%s.%s", bname, track->extension) == -1)
801 - die(4, "set_output(): asprintf() failed, out of memory\n");
802 - free(bname);
803 - bname = NULL;
804 - if (strcmp(track->output, track->file) == 0)
805 - die_format(5, "%2d: skipped: output file %s same as input file, aborting\n%s",
806 - track->num, track->output, HINT);
807 - return 1;
808 -}
809 -
810 -/*
811 * Main
812 */
813
814 int main(int argc, char **argv)
815 {
816 char s[CUELLEN+1];
817 - char *b, *e, *i, *p, *t, *u;
818 + char *p, *t;
819 + struct track_t *tracks = NULL;
820 + struct track_t *track = NULL;
821 struct track_t *prevtrack = NULL;
822 struct track_t **prevp = &tracks;
823
824 + FILE *binf, *cuef;
825 +
826 printf("%s", VERSTR);
827
828 parse_args(argc, argv);
829
830 - if (!((cuef = fopen(cuefile, "r"))))
831 - die_format(2, "Could not open CUE %s: %s\n", cuefile, strerror(errno));
832 + if (!((binf = fopen(binfile, "r")))) {
833 + fprintf(stderr, "Could not open BIN %s: %s\n", binfile, strerror(errno));
834 + return 2;
835 + }
836
837 - if (verbose)
838 - printf("Include track # in output filename: %s\n\n", trackadd ? "yes" : "no");
839 + if (!((cuef = fopen(cuefile, "r")))) {
840 + fprintf(stderr, "Could not open CUE %s: %s\n", cuefile, strerror(errno));
841 + return 2;
842 + }
843
844 printf("Reading the CUE file:\n");
845
846 + /* We don't really care about the first line. */
847 + if (!fgets(s, CUELLEN, cuef)) {
848 + fprintf(stderr, "Could not read first line from %s: %s\n", cuefile, strerror(errno));
849 + return 3;
850 + }
851 +
852 while (fgets(s, CUELLEN, cuef)) {
853 while ((p = strchr(s, '\r')) || (p = strchr(s, '\n')))
854 *p = '\0';
855
856 - if ((p = strstr(s, "FILE"))) {
857 - if (!(b = strchr(p, ' ')))
858 - die(3, "... ouch, no space after FILE.\n");
859 - if (!(e = strrchr(p, ' ')))
860 - die(3, "... ouch, no space after filename.\n");
861 - if (e == b)
862 - die(3, "... ouch, no filename after FILE.\n");
863 - ++b;
864 - if (b == strchr(b, '"'))
865 - b++;
866 - --e;
867 - if (e == strrchr(e, '"'))
868 - *e = '\0';
869 - if (e == b)
870 - die(3, "... ouch, empty filename entry.\n");
871 - if (file)
872 - free(file);
873 - if (asprintf(&file, "%s", b) == -1)
874 - die(4, "main(): asprintf() failed, out of memory\n");
875 - printf("\nFile: %s", file);
876 - }
877 if ((p = strstr(s, "TRACK"))) {
878 printf("\nTrack ");
879 - if (!(p = strchr(p, ' ')))
880 - die(3, "... ouch, no space after TRACK.\n");
881 + if (!(p = strchr(p, ' '))) {
882 + fprintf(stderr, "... ouch, no space after TRACK.\n");
883 + exit(3);
884 + }
885 p++;
886 - if (!(t = strchr(p, ' ')))
887 - die(3, "... ouch, no space after track number.\n");
888 + if (!(t = strchr(p, ' '))) {
889 + fprintf(stderr, "... ouch, no space after track number.\n");
890 + exit(3);
891 + }
892 *t = '\0';
893
894 prevtrack = track;
895 - if (!(track = malloc(sizeof(struct track_t))))
896 - die(4, "main(): malloc() failed, out of memory\n");
897 + if (!(track = malloc(sizeof(struct track_t)))) {
898 + fprintf(stderr, "main(): malloc() failed, out of memory\n");
899 + exit(4);
900 + }
901 *prevp = track;
902 prevp = &track->next;
903 track->next = NULL;
904 @@ -607,14 +445,10 @@ int main(int argc, char **argv)
905
906 p = t + 1;
907 printf("%2d: %-12.12s ", track->num, p);
908 - if (asprintf(&track->file, "%s", file) == -1)
909 - die(4, "main(): asprintf() failed, out of memory\n");
910 track->modes = strdup(p);
911 track->extension = NULL;
912 - track->output = NULL;
913 track->mode = 0;
914 track->audio = 0;
915 - track->dataoffs = 0;
916 track->bsize = track->bstart = -1;
917 track->bsize = -1;
918 track->startsect = track->stopsect = -1;
919 @@ -622,70 +456,45 @@ int main(int argc, char **argv)
920 gettrackmode(track, p);
921
922 } else if ((p = strstr(s, "INDEX"))) {
923 - if (!(p = strchr(p, ' ')))
924 - die(3, "... ouch, no space after INDEX.\n");
925 + if (!(p = strchr(p, ' '))) {
926 + printf("... ouch, no space after INDEX.\n");
927 + exit(3);
928 + }
929 p++;
930 - if (!(t = strchr(p, ' ')))
931 - die(3, "... ouch, no space after index number.\n");
932 + if (!(t = strchr(p, ' '))) {
933 + printf("... ouch, no space after index number.\n");
934 + exit(3);
935 + }
936 *t = '\0';
937 t++;
938 printf(" %s %s", p, t);
939 - long index = strtol(p, &i, 10);
940 - if (strlen(i))
941 - die_format(3, "... ouch, non-digit found in INDEX %s: %s\n", p, i);
942 - u = strdupa(t);
943 - int ss;
944 - // handle unordered pregap, ignore subtracks
945 - for (ss = time2frames(t); ss > track->startsect && index < 2;) {
946 - track->startsect = ss;
947 - track->start = track->startsect * SECTLEN;
948 - }
949 - if (debug)
950 - fprintf(stderr, "INDEX %s%s: %s startsect %d\n",
951 - p, track->startsect + 1 ? "" : " updating",
952 - u, ss);
953 + track->startsect = time2frames(t);
954 + track->start = track->startsect * SECTLEN;
955 if (verbose)
956 - printf(" (%sstartsect %ld ofs %ld)",
957 - index == 0 ? "" :
958 - index == 1 ? "pregap " : "subtrack ",
959 - track->startsect, track->start);
960 - if (prevtrack) {
961 - // only when files match, ignore subtracks
962 - if (!(strcmp(prevtrack->file,track->file)) && index < 2) {
963 - prevtrack->stopsect = track->startsect - 1;
964 - prevtrack->stop = track->start - 1;
965 - }
966 - if (debug)
967 - fprintf(stderr, "TRACK %.2d: stopsect %ld\n",
968 - prevtrack->num, prevtrack->stopsect);
969 + printf(" (startsect %ld ofs %ld)", track->startsect, track->start);
970 + if ((prevtrack) && (prevtrack->stopsect < 0)) {
971 + prevtrack->stopsect = track->startsect - 1;
972 + prevtrack->stop = track->start - 1;
973 }
974 }
975 }
976
977 - printf("\n\nWriting tracks:\n\n");
978 -
979 - for (track = tracks; (track); track = track->next) {
980 - if (!set_output(track, binfile, basefile, trackadd))
981 - continue;
982 - if (!(binf = fopen(track->file, "rb"))) {
983 - fprintf(stderr, "Could not open BIN %s: %s\n", track->file, strerror(errno));
984 - continue;
985 - }
986 - if (is_wav_file(track))
987 - if (!set_wav_data_offset(binf, track))
988 - continue;
989 - if (track->stopsect < 0) { // if not set yet
990 - if (fseek(binf, 0, SEEK_END) == -1)
991 - die_format(4, "main(): fseek failure in %s\n", track->file);
992 - track->stop = ftell(binf) - track->dataoffs - 1;
993 - track->stopsect = track->stop / SECTLEN;
994 - }
995 - writetrack(binf, track);
996 - fclose(binf);
997 - binf = NULL;
998 + if (track) {
999 + fseek(binf, 0, SEEK_END);
1000 + track->stop = ftell(binf) - 1;
1001 + track->stopsect = track->stop / SECTLEN;
1002 }
1003
1004 - free_all();
1005 + printf("\n\n");
1006 +
1007 +
1008 + printf("Writing tracks:\n\n");
1009 + for (track = tracks; (track); track = track->next)
1010 + writetrack(binf, track, basefile);
1011 +
1012 + fclose(binf);
1013 + fclose(cuef);
1014 +
1015 return 0;
1016 }
1017
1018 --- bchunk-1.2.2+git20220715+ds.orig/bchunk.spec
1019 +++ bchunk-1.2.2+git20220715+ds/bchunk.spec
1020 @@ -1,5 +1,5 @@
1021 %define name bchunk
1022 -%define version 1.2.3
1023 +%define version 1.2.2
1024 %define release 0
1025
1026 Summary: A CD image format converter from .bin/.cue to .iso/.cdr/.wav.
1027 @@ -43,9 +43,6 @@ rm -r $RPM_BUILD_ROOT
1028 %{_mandir}/man1/bchunk.1.gz
1029
1030 %changelog
1031 -* Tue Jun 30 2022 twojstaryzdomu
1032 -- updated to 1.2.3
1033 -
1034 * Tue Nov 14 2017 Hessu <[email protected]>
1035 - updated to 1.2.2
1036