Allow output file name to be up to PATH_MAX characters long.
This commit is contained in:
parent
9a4c5ee836
commit
687bface02
|
|
@ -1,3 +1,7 @@
|
|||
0.8.5 / unreleased Fabian Kurz <fabian@fkurz.net>
|
||||
* Allow output file names to be up to PATH_MAX (typ. 4096)
|
||||
characters long (tnx SQ6JNX)
|
||||
|
||||
0.8.4 / 2021-04-07 Fabian Kurz <fabian@fkurz.net>
|
||||
* If chapter separator is empty (-c "") or starts with
|
||||
a dash (-c "-"), do not append a chapter number to filenames
|
||||
|
|
@ -5,7 +9,6 @@
|
|||
* Fix Farnsworth CW timing (tnx DM4SG for the patch)
|
||||
* Location of configuration file can be specified with -E option
|
||||
|
||||
|
||||
0.8.3 / 2020-05-23 Fabian Kurz <fabian@fkurz.net>
|
||||
* Added lowercase Greek alphabet
|
||||
* Added multiple language support by GNU gettext.
|
||||
|
|
|
|||
15
ebook2cw.c
15
ebook2cw.c
|
|
@ -57,6 +57,11 @@ source code looks properly indented with ts=4
|
|||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h> /* PATH_MAX */
|
||||
#ifndef PATH_MAX /* Not defined e.g. on GNU/hurd */
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#include "codetables.h"
|
||||
|
||||
#ifndef VERSION
|
||||
|
|
@ -141,8 +146,8 @@ typedef struct {
|
|||
unsigned char *mp3buffer;
|
||||
/* Chapter splitting */
|
||||
char chapterstr[80], /* split chapters by this string */
|
||||
chapterfilename[80], /* Prefix, e.g. "Chapter-" */
|
||||
outfilename[256]; /* Full name of current outputfile */
|
||||
chapterfilename[PATH_MAX-8], /* Prefix, e.g. "Chapter-" */
|
||||
outfilename[PATH_MAX]; /* Full name of current outputfile */
|
||||
/* time based splitting, seconds */
|
||||
int chaptertime;
|
||||
/* word based splitting */
|
||||
|
|
@ -925,11 +930,11 @@ void openfile (int chapter, CWP *cw) {
|
|||
|
||||
/* If we have a chapter separator string, use format Chapter0001.mp3 */
|
||||
if (strlen(cw->chapterstr) && cw->chapterstr[0] != '-') {
|
||||
snprintf(cw->outfilename, 80, "%s%04d.%s", cw->chapterfilename,
|
||||
snprintf(cw->outfilename, PATH_MAX, "%s%04d.%s", cw->chapterfilename,
|
||||
chapter, (cw->encoder == MP3) ? "mp3" : "ogg");
|
||||
}
|
||||
else { /* otherwise just Chapter.mp3 */
|
||||
snprintf(cw->outfilename, 80, "%s.%s", cw->chapterfilename,
|
||||
snprintf(cw->outfilename, PATH_MAX, "%s.%s", cw->chapterfilename,
|
||||
(cw->encoder == MP3) ? "mp3" : "ogg");
|
||||
}
|
||||
printf(_("Starting %s\n"), cw->outfilename);
|
||||
|
|
@ -1287,7 +1292,7 @@ void setparameter (char i, char *value, CWP *cw) {
|
|||
strncpy(cw->chapterstr, value, 78);
|
||||
break;
|
||||
case 'o':
|
||||
strncpy(cw->chapterfilename, value, 78);
|
||||
strncpy(cw->chapterfilename, value, PATH_MAX - 10);
|
||||
break;
|
||||
case 'a':
|
||||
strncpy(cw->id3_author, value, 78);
|
||||
|
|
|
|||
Loading…
Reference in New Issue