aboutsummaryrefslogtreecommitdiff
path: root/miragextract.c
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 /miragextract.c
parentf6dca658d5c04c53a5542d3e16244566261f1c39 (diff)
downloadmiragextract-8dda4bc4f4fdb5d79af90022d44cd0e568b84899.tar.gz
add -p password option
Diffstat (limited to 'miragextract.c')
-rw-r--r--miragextract.c17
1 files changed, 16 insertions, 1 deletions
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;