summaryrefslogtreecommitdiff
path: root/wrudf
diff options
context:
space:
mode:
Diffstat (limited to 'wrudf')
-rw-r--r--wrudf/Makefile.am9
-rw-r--r--wrudf/Makefile.in16
-rw-r--r--wrudf/wrudf-cmnd.c11
-rw-r--r--wrudf/wrudf.c21
-rw-r--r--wrudf/wrudf.h6
5 files changed, 47 insertions, 16 deletions
diff --git a/wrudf/Makefile.am b/wrudf/Makefile.am
index fe1c269..4224b13 100644
--- a/wrudf/Makefile.am
+++ b/wrudf/Makefile.am
@@ -1,5 +1,10 @@
bin_PROGRAMS = wrudf
-wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la -lreadline
+wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la
wrudf_SOURCES = wrudf.c wrudf-cmnd.c wrudf-desc.c wrudf-cdrw.c wrudf-cdr.c ide-pc.c wrudf.h ide-pc.h ../include/ecma_167.h ../include/osta_udf.h ../include/bswap.h
-AM_CPPFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE -DDEBUG
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+if USE_READLINE
+wrudf_LDADD += -lreadline
+AM_CPPFLAGS += -DUSE_READLINE
+endif
diff --git a/wrudf/Makefile.in b/wrudf/Makefile.in
index bb55fa1..b27abea 100644
--- a/wrudf/Makefile.in
+++ b/wrudf/Makefile.in
@@ -89,6 +89,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = wrudf$(EXEEXT)
+@USE_READLINE_TRUE@am__append_1 = -lreadline
+@USE_READLINE_TRUE@am__append_2 = -DUSE_READLINE
subdir = wrudf
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@@ -105,7 +107,9 @@ am_wrudf_OBJECTS = wrudf.$(OBJEXT) wrudf-cmnd.$(OBJEXT) \
wrudf-desc.$(OBJEXT) wrudf-cdrw.$(OBJEXT) wrudf-cdr.$(OBJEXT) \
ide-pc.$(OBJEXT)
wrudf_OBJECTS = $(am_wrudf_OBJECTS)
-wrudf_DEPENDENCIES = $(top_builddir)/libudffs/libudffs.la
+am__DEPENDENCIES_1 =
+wrudf_DEPENDENCIES = $(top_builddir)/libudffs/libudffs.la \
+ $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
@@ -229,11 +233,17 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+UDEVDIR = @UDEVDIR@
+UDEV_CFLAGS = @UDEV_CFLAGS@
+UDEV_LIBS = @UDEV_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
@@ -288,9 +298,9 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la -lreadline
+wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la $(am__append_1)
wrudf_SOURCES = wrudf.c wrudf-cmnd.c wrudf-desc.c wrudf-cdrw.c wrudf-cdr.c ide-pc.c wrudf.h ide-pc.h ../include/ecma_167.h ../include/osta_udf.h ../include/bswap.h
-AM_CPPFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE -DDEBUG
+AM_CPPFLAGS = -I$(top_srcdir)/include $(am__append_2)
all: all-am
.SUFFIXES:
diff --git a/wrudf/wrudf-cmnd.c b/wrudf/wrudf-cmnd.c
index bfa8136..e861d82 100644
--- a/wrudf/wrudf-cmnd.c
+++ b/wrudf/wrudf-cmnd.c
@@ -1097,12 +1097,17 @@ int
questionOverwrite(Directory *dir, struct fileIdentDesc *fid, char* name)
{
printf("File %s already exists. Overwrite ? (y/N) : ", name);
-#ifdef _GNU_SOURCE
+#ifdef USE_READLINE
readLine(NULL);
#else
- fgets(line, 256, stdin);
+ if (!fgets(line, 256, stdin))
+ line[0] = 0;
#endif
- if( !line || line[0] != 'y' )
+#ifdef USE_READLINE
+ if( !line )
+ return 1;
+#endif
+ if( line[0] != 'y' )
return 1;
deleteFID(dir, fid);
return 0;
diff --git a/wrudf/wrudf.c b/wrudf/wrudf.c
index 74dcdaf..27ba7a9 100644
--- a/wrudf/wrudf.c
+++ b/wrudf/wrudf.c
@@ -13,6 +13,10 @@
#include <locale.h>
#include <sys/resource.h>
+#ifdef USE_READLINE
+#include <readline/readline.h>
+#endif
+
#include "wrudf.h"
char *devicename; /* "/dev/cdrom" or disk image filename */
@@ -21,12 +25,12 @@ int devicetype;
enum MEDIUM medium;
int ignoreReadError; /* used while reading VRS which may be absent on open CDR */
-#ifdef _GNU_SOURCE
+#ifdef USE_READLINE
char *line;
#define GETLINE(prompt) readLine(prompt);
#else
char line[256];
-#define GETLINE(prompt) printf(prompt); fgets(line, 256, stdin); *strchr(line, '\n') = 0;
+#define GETLINE(prompt) do { printf("%s", prompt); if (fgets(line, 256, stdin)) *strchr(line, '\n') = 0; else line[0] = 0; } while (0)
#endif
@@ -74,12 +78,14 @@ struct sparingTable *st;
int spaceMapDirty, usdDirty, sparingTableDirty;
+#ifdef USE_READLINE
char* readLine(char* prompt) {
if( line ) {
free(line);
}
return line = readline(prompt);
}
+#endif
void
@@ -310,9 +316,14 @@ initialise(char *devicename)
fsdOut[0] = 0;
printf("You are going to update fileset '%s'\nProceed (y/N) : ", fsdOut);
- readLine(NULL);
+ GETLINE("");
+
+#ifdef USE_READLINE
+ if( !line )
+ fail("wrudf terminated\n");
+#endif
- if( !line || line[0] != 'y' )
+ if( line[0] != 'y' )
fail("wrudf terminated\n");
/* Read Logical Volume Integrity sequence */
@@ -632,7 +643,7 @@ parseCmnd(char* line)
int show_help()
{
char *msg =
- "Interactive tool to maintain an UDF filesystem.\n"
+ "Interactive tool to maintain a UDF filesystem.\n"
"Usage:\n"
"\twrudf [device]\n"
"Available commands:\n"
diff --git a/wrudf/wrudf.h b/wrudf/wrudf.h
index d9edba6..5d6a7f9 100644
--- a/wrudf/wrudf.h
+++ b/wrudf/wrudf.h
@@ -46,9 +46,7 @@ extern enum MEDIUM medium;
extern uint32_t trackSize;
-#ifdef _GNU_SOURCE
-/* I appear not to have readline.h */
-char* readline(char* prompt);
+#ifdef USE_READLINE
extern char *line;
#else
extern char line[256];
@@ -99,7 +97,9 @@ extern Directory *rootDir, *curDir;
/*wrudf.c */
+#ifdef USE_READLINE
char* readLine(char *prompt);
+#endif
/* wrudf-cmnd.c */
int updateDirectory(Directory* dir);