aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2020-05-09 05:04:44 -0400
committerB. Watson <yalhcru@gmail.com>2020-05-09 05:04:44 -0400
commit8dda4bc4f4fdb5d79af90022d44cd0e568b84899 (patch)
tree547469f2bc2fa25711b6e55f07143d5263c849c7
parentf6dca658d5c04c53a5542d3e16244566261f1c39 (diff)
downloadmiragextract-8dda4bc4f4fdb5d79af90022d44cd0e568b84899.tar.gz
add -p password option
-rw-r--r--Makefile2
-rw-r--r--README4
-rw-r--r--miragextract.156
-rw-r--r--miragextract.c17
-rw-r--r--miragextract.html58
-rw-r--r--miragextract.rst45
6 files changed, 115 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index 45ab4ea..0cb352c 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ RST2HTML=rst2html4.py
# Hopefully, no user-serviceable parts below this line.
PROJ=miragextract
-VERSION=0.0.1
+VERSION=0.1.0
DOCS=README FAQ ChangeLog LICENSE $(PROJ).html
diff --git a/README b/README
index 48b0f0f..2f4f79d 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for miragextract v0.0.1
+README for miragextract v0.1.0
==============================
Description
@@ -9,7 +9,7 @@ or converted to wav, flag, or ogg/vorbis (via libsndfile).
Prerequisites
-------------
-Requires GNU make, libmirage >= 3.0.0 and libsndfile (tested with 1.0.26,
+Requires GNU make, libmirage >= 3.0.5 and libsndfile (tested with 1.0.26,
other recent-ish versions should work). Since libmirage uses glib2,
you'll need that as well.
diff --git a/miragextract.1 b/miragextract.1
index a5e4730..a1842aa 100644
--- a/miragextract.1
+++ b/miragextract.1
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
-.TH MIRAGEXTRACT 1 "2020-05-07" "0.0.1" "Urchlay"
+.TH MIRAGEXTRACT 1 "2020-05-09" "0.1.0" "Urchlay"
.SH NAME
miragextract \- extract audio and data tracks from CD images
.
@@ -42,7 +42,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.
.SH SYNOPSIS
.sp
-miragextract [\fB\-l\fP] [\fB\-s\fP] [\fB\-t\fP track] [\fB\-b\fP base] [\fB\-f\fP fmt] [\fB\-q\fP quality ] \fBimage\-file\fP
+miragextract [\fB\-l\fP] [\fB\-s\fP] [\fB\-t\fP track] [\fB\-b\fP base] [\fB\-f\fP fmt] [\fB\-p\fP passwd] [\fB\-q\fP quality ] \fBimage\-file\fP
.SH DESCRIPTION
.sp
Extracts data and audio tracks from any CD image supported by libmirage.
@@ -54,22 +54,8 @@ converted to wav, flac, or ogg/vorbis (via libsndfile).
.B \-\-help
Print short usage string.
.TP
-.B \-l
-Lists the tracks in the image without extracting them.
-.TP
.B \-a
-Extract only audio tracks.
-.TP
-.B \-d
-Extract only data tracks.
-.TP
-.B \-s
-Swaps bytes in audio tracks. Use this if your audio files sound
-like white noise or gibberish.
-.TP
-.B \-t
-Takes a track number (1\-99), and extracts only that one track.
-Default behaviour is to extract all tracks.
+Extract only audio tracks. Default is to extract all tracks.
.TP
.B \-b
Sets the base filename for the output files. Default is \(aqtrack\(aq.
@@ -77,6 +63,16 @@ Can be prefixed with a directory to write files in that dir,
but the dir must already exist (example: \-b extracted/track). See
also the \-n option.
.TP
+.B \-d
+Extract only data tracks. Default is to extract all tracks.
+.TP
+.B \-f
+Sets the format and filename extension for the output files.
+Choices are \fBwav\fP, \fBogg\fP, \fBflac\fP, \fBcdda\fP (raw CD audio). Default is \fBwav\fP\&.
+.TP
+.B \-l
+Lists the tracks in the image without extracting them.
+.TP
.B \-n
Set the base filename to the input filename, minus its extension.
E.g. for foo.cue, this is the same as saying "\-b foo". Beware of
@@ -84,14 +80,24 @@ using input filenames with directory separators in them: the output files
will be written in the same dir as the input file. Hopefully you
have permission to write there.
.TP
-.B \-f
-Sets the format and filename extension for the output files.
-Choices are \fBwav\fP, \fBogg\fP, \fBflac\fP, \fBcdda\fP (raw CD audio). Default is \fBwav\fP\&.
+.B \-p
+Password for encrypted images. Note that anyone who can run \fBps(1)\fP
+on your system can view the password. Also note that password
+support in miragextract is \fIcompletely\fP untested: I have no
+encrypted images to test with.
.TP
.B \-q
Quality setting for ogg and flac output files. Integer from 0
to 10. Default is 7. Has very little effect on flac, and no effect on
wav or cdda output.
+.TP
+.B \-s
+Swaps bytes in audio tracks. Use this if your audio files sound
+like white noise or gibberish.
+.TP
+.B \-t
+Takes a track number (1\-99), and extracts only that one track.
+Default behaviour is to extract all tracks.
.UNINDENT
.sp
Always include a space between an option and its argument (e.g. \fB\-b foo\fP, not \fB\-bfoo\fP).
@@ -147,8 +153,14 @@ play \-x \-t cdda track01.cdda
As usual, 0 for success, non\-zero for failure.
.SH BUGS
.sp
-There\(aqs not enough error checking. It\(aqs probably possible to make
-miragextract segfault under some circumstances.
+The \-p option should prompt for a password.
+.sp
+Not exactly a bug, per se, but miragextract can\(aqt deal with multi\-file
+images where one of the files is missing or truncated. This is because
+libmirage validates the image when it\(aqs loaded, and is unlikely to change.
+.sp
+Related to the above, there\(aqs no attempt to recover from
+errors. miragextract exits as soon as it encounters an error of any kind.
.\" EXAMPLES
.
.\" ========
diff --git a/miragextract.c b/miragextract.c
index e9d570d..8e80529 100644
--- a/miragextract.c
+++ b/miragextract.c
@@ -28,6 +28,7 @@ int swap_bytes = 0;
int autoname = 0;
int want_data = 1;
int want_audio = 1;
+char *password = NULL;
/* CD image state */
MirageContext *mirage = NULL;
@@ -236,11 +237,16 @@ void usage(void) {
printf(
"miragextract v" VERSION " by B. Watson, WTFPL\n"
"Usage: %s [-l] [-s] [-n] [-a] [-d] [-t track] [-b base]\n"
- "%s[-f fmt] [-q quality] image-file\n"
+ "%s[-f fmt] [-q quality] [-p password] image-file\n"
"See man page for details\n", self, spaces);
exit(0);
}
+gchar *password_callback(gpointer user_data) {
+ if(!password) return NULL;
+ return g_strdup(password);
+}
+
/* this should probably use something like getopts(), but I'm trying
to avoid GNU extensions. */
void parse_args(int argc, char **argv) {
@@ -290,6 +296,13 @@ void parse_args(int argc, char **argv) {
} else
die("-f option requires format argument");
break;
+ case 'p':
+ if(nextarg) {
+ argv++, argc--;
+ password = nextarg;
+ } else
+ die("-p option requires password");
+ break;
case 'q':
if(nextarg) {
argv++, argc--;
@@ -339,6 +352,8 @@ int main(int argc, char **argv) {
if(!mirage_initialize(&gerr))
die(NULL);
+ mirage_context_set_password_function(mirage, password_callback, NULL, NULL);
+
/* TODO: find out what image formats require multiple filenames, if any */
fn[0] = (gchar *)imagefile;
fn[1] = NULL;
diff --git a/miragextract.html b/miragextract.html
index c657461..3fe03ad 100644
--- a/miragextract.html
+++ b/miragextract.html
@@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>miragextract</title>
-<meta name="date" content="2020-05-07" />
+<meta name="date" content="2020-05-09" />
<style type="text/css">
/*
@@ -373,9 +373,9 @@ ul.auto-toc {
<tr class="manual-group field"><th class="docinfo-name">Manual group:</th><td class="field-body">Urchlay</td>
</tr>
<tr><th class="docinfo-name">Date:</th>
-<td>2020-05-07</td></tr>
+<td>2020-05-09</td></tr>
<tr><th class="docinfo-name">Version:</th>
-<td>0.0.1</td></tr>
+<td>0.1.0</td></tr>
</tbody>
</table>
<!-- RST source for miragextract(1) man page. Convert with: -->
@@ -385,7 +385,7 @@ ul.auto-toc {
<!-- into git since we don't want to require our users to have rst2man.py. -->
<div class="section" id="synopsis">
<h1>SYNOPSIS</h1>
-<p>miragextract [<strong>-l</strong>] [<strong>-s</strong>] [<strong>-t</strong> track] [<strong>-b</strong> base] [<strong>-f</strong> fmt] [<strong>-q</strong> quality ] <strong>image-file</strong></p>
+<p>miragextract [<strong>-l</strong>] [<strong>-s</strong>] [<strong>-t</strong> track] [<strong>-b</strong> base] [<strong>-f</strong> fmt] [<strong>-p</strong> passwd] [<strong>-q</strong> quality ] <strong>image-file</strong></p>
</div>
<div class="section" id="description">
<h1>DESCRIPTION</h1>
@@ -403,22 +403,8 @@ converted to wav, flac, or ogg/vorbis (via libsndfile).</p>
<kbd><span class="option">--help</span></kbd></td>
<td>Print short usage string.</td></tr>
<tr><td class="option-group">
-<kbd><span class="option">-l</span></kbd></td>
-<td>Lists the tracks in the image without extracting them.</td></tr>
-<tr><td class="option-group">
<kbd><span class="option">-a</span></kbd></td>
-<td>Extract only audio tracks.</td></tr>
-<tr><td class="option-group">
-<kbd><span class="option">-d</span></kbd></td>
-<td>Extract only data tracks.</td></tr>
-<tr><td class="option-group">
-<kbd><span class="option">-s</span></kbd></td>
-<td>Swaps bytes in audio tracks. Use this if your audio files sound
-like white noise or gibberish.</td></tr>
-<tr><td class="option-group">
-<kbd><span class="option">-t</span></kbd></td>
-<td>Takes a track number (1-99), and extracts only that one track.
-Default behaviour is to extract all tracks.</td></tr>
+<td>Extract only audio tracks. Default is to extract all tracks.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-b</span></kbd></td>
<td>Sets the base filename for the output files. Default is 'track'.
@@ -426,6 +412,16 @@ Can be prefixed with a directory to write files in that dir,
but the dir must already exist (example: -b extracted/track). See
also the -n option.</td></tr>
<tr><td class="option-group">
+<kbd><span class="option">-d</span></kbd></td>
+<td>Extract only data tracks. Default is to extract all tracks.</td></tr>
+<tr><td class="option-group">
+<kbd><span class="option">-f</span></kbd></td>
+<td>Sets the format and filename extension for the output files.
+Choices are <strong>wav</strong>, <strong>ogg</strong>, <strong>flac</strong>, <strong>cdda</strong> (raw CD audio). Default is <strong>wav</strong>.</td></tr>
+<tr><td class="option-group">
+<kbd><span class="option">-l</span></kbd></td>
+<td>Lists the tracks in the image without extracting them.</td></tr>
+<tr><td class="option-group">
<kbd><span class="option">-n</span></kbd></td>
<td>Set the base filename to the input filename, minus its extension.
E.g. for foo.cue, this is the same as saying &quot;-b foo&quot;. Beware of
@@ -433,14 +429,24 @@ using input filenames with directory separators in them: the output files
will be written in the same dir as the input file. Hopefully you
have permission to write there.</td></tr>
<tr><td class="option-group">
-<kbd><span class="option">-f</span></kbd></td>
-<td>Sets the format and filename extension for the output files.
-Choices are <strong>wav</strong>, <strong>ogg</strong>, <strong>flac</strong>, <strong>cdda</strong> (raw CD audio). Default is <strong>wav</strong>.</td></tr>
+<kbd><span class="option">-p</span></kbd></td>
+<td>Password for encrypted images. Note that anyone who can run <strong>ps(1)</strong>
+on your system can view the password. Also note that password
+support in miragextract is <em>completely</em> untested: I have no
+encrypted images to test with.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-q</span></kbd></td>
<td>Quality setting for ogg and flac output files. Integer from 0
to 10. Default is 7. Has very little effect on flac, and no effect on
wav or cdda output.</td></tr>
+<tr><td class="option-group">
+<kbd><span class="option">-s</span></kbd></td>
+<td>Swaps bytes in audio tracks. Use this if your audio files sound
+like white noise or gibberish.</td></tr>
+<tr><td class="option-group">
+<kbd><span class="option">-t</span></kbd></td>
+<td>Takes a track number (1-99), and extracts only that one track.
+Default behaviour is to extract all tracks.</td></tr>
</tbody>
</table>
<p>Always include a space between an option and its argument (e.g. <strong>-b foo</strong>, not <strong>-bfoo</strong>).</p>
@@ -481,8 +487,12 @@ play -x -t cdda track01.cdda
</div>
<div class="section" id="bugs">
<h1>BUGS</h1>
-<p>There's not enough error checking. It's probably possible to make
-miragextract segfault under some circumstances.</p>
+<p>The -p option should prompt for a password.</p>
+<p>Not exactly a bug, per se, but miragextract can't deal with multi-file
+images where one of the files is missing or truncated. This is because
+libmirage validates the image when it's loaded, and is unlikely to change.</p>
+<p>Related to the above, there's no attempt to recover from
+errors. miragextract exits as soon as it encounters an error of any kind.</p>
<!-- EXAMPLES -->
<!-- ======== -->
</div>
diff --git a/miragextract.rst b/miragextract.rst
index 2a477aa..b2cb9ff 100644
--- a/miragextract.rst
+++ b/miragextract.rst
@@ -5,7 +5,7 @@
.. note to self: don't forget to check the generated man and html pages
.. into git since we don't want to require our users to have rst2man.py.
-.. |version| replace:: 0.0.1
+.. |version| replace:: 0.1.0
.. |date| date::
============
@@ -24,7 +24,7 @@ extract audio and data tracks from CD images
SYNOPSIS
========
-miragextract [**-l**] [**-s**] [**-t** track] [**-b** base] [**-f** fmt] [**-q** quality ] **image-file**
+miragextract [**-l**] [**-s**] [**-t** track] [**-b** base] [**-f** fmt] [**-p** passwd] [**-q** quality ] **image-file**
DESCRIPTION
===========
@@ -39,36 +39,41 @@ OPTIONS
--help
Print short usage string.
--l Lists the tracks in the image without extracting them.
-
--a Extract only audio tracks.
-
--d Extract only data tracks.
-
--s Swaps bytes in audio tracks. Use this if your audio files sound
- like white noise or gibberish.
-
--t Takes a track number (1-99), and extracts only that one track.
- Default behaviour is to extract all tracks.
+-a Extract only audio tracks. Default is to extract all tracks.
-b Sets the base filename for the output files. Default is 'track'.
Can be prefixed with a directory to write files in that dir,
but the dir must already exist (example: -b extracted/track). See
also the -n option.
+-d Extract only data tracks. Default is to extract all tracks.
+
+-f Sets the format and filename extension for the output files.
+ Choices are **wav**, **ogg**, **flac**, **cdda** (raw CD audio). Default is **wav**.
+
+-l Lists the tracks in the image without extracting them.
+
-n Set the base filename to the input filename, minus its extension.
E.g. for foo.cue, this is the same as saying "-b foo". Beware of
using input filenames with directory separators in them: the output files
will be written in the same dir as the input file. Hopefully you
have permission to write there.
--f Sets the format and filename extension for the output files.
- Choices are **wav**, **ogg**, **flac**, **cdda** (raw CD audio). Default is **wav**.
+-p Password for encrypted images. Note that anyone who can run **ps(1)**
+ on your system can view the password. Also note that password
+ support in miragextract is *completely* untested: I have no
+ encrypted images to test with.
-q Quality setting for ogg and flac output files. Integer from 0
to 10. Default is 7. Has very little effect on flac, and no effect on
wav or cdda output.
+-s Swaps bytes in audio tracks. Use this if your audio files sound
+ like white noise or gibberish.
+
+-t Takes a track number (1-99), and extracts only that one track.
+ Default behaviour is to extract all tracks.
+
Always include a space between an option and its argument (e.g. **-b foo**, not **-bfoo**).
NOTES
@@ -118,8 +123,14 @@ As usual, 0 for success, non-zero for failure.
BUGS
====
-There's not enough error checking. It's probably possible to make
-miragextract segfault under some circumstances.
+The -p option should prompt for a password.
+
+Not exactly a bug, per se, but miragextract can't deal with multi-file
+images where one of the files is missing or truncated. This is because
+libmirage validates the image when it's loaded, and is unlikely to change.
+
+Related to the above, there's no attempt to recover from
+errors. miragextract exits as soon as it encounters an error of any kind.
.. EXAMPLES
.. ========