|
From: Peter K. <pk...@us...> - 2001-03-10 12:47:41
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
Makefile 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
bttest.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Support for compiling without readline (by Matthias Fuchs).
The diff of the modified file(s):
--- Makefile 2001/03/02 13:14:29 1.1
+++ Makefile 2001/03/10 12:49:32 1.2
@@ -7,33 +7,38 @@
=20
PROGS =3D btdm memul bti btinq btcon btsend btdisc
=20
+# Define HAVE_READLINE_READLINE if you have readline support, with the inc=
lude
+# files in $(include_dir)/readline. Define HAVE_READLINE if you have the
+# include files in $(include_dir). Define neither if you do not want to use
+# readline.
+HAVE_READLINE_READLINE =3D 1
+#HAVE_READLINE =3D 1
+
INSTDIR =3D $(prefix)/bin/
INSTMODE =3D 0755
INSTOWNER =3D root
INSTGROUP =3D root
-
-SRCS =3D btd.c
-
-OBJS =3D btd.o
-
-LDLIBS +=3D -lreadline -ltermcap
-
-CFLAGS +=3D -I$(prefix)/include=20
=20
-BTDOBJS =3D bt_vendor.o bt_misc.o bt_if.o bttest.o bt_ipa.o btd.o
-
+BTDOBJS =3D btd.o bttest.o bt_ipa.o bt_vendor.o bt_if.o bt_misc.o
MEMULOBJS =3D modememul.o bt_misc.o
-
-BTINITOBJS =3D bt_vendor.o bt_misc.o bt_if.o btinit.o
-
+BTINITOBJS =3D btinit.o bt_vendor.o bt_if.o bt_misc.o
BTCONOBJS =3D btcon.o bt_if.o bt_misc.o
-
BTSENDOBJS =3D btsend.o bt_if.o bt_misc.o
-
BTDISCOBJS =3D btdisc.o bt_if.o
-
BTINQOBJS =3D btinq.o bt_if.o
=20
+ifdef HAVE_READLINE_READLINE
+LDLIBS +=3D -lreadline -ltermcap
+CFLAGS +=3D -DHAVE_READLINE_READLINE -I$(prefix)/include
+endif
+
+ifdef HAVE_READLINE
+LDLIBS +=3D -lreadline -ltermcap
+CFLAGS +=3D -DHAVE_READLINE -I$(prefix)/include
+endif
+
+CFLAGS +=3D -MD
+
all: $(PROGS)
=20
# 'btdm' =3D> 'multipoint btd' instead of btd to differentiate from=20
@@ -65,13 +70,6 @@
$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) $(PROGS) $(INST=
DIR)
=20
clean:
- rm -f $(PROGS) *.o core
-
-depend:
- makedepend -Y $(SRCS) 2>/dev/null
-
-# -------------------------------------------------------------------------
-# The following is used to automatically generate dependencies.
-# DO NOT DELETE
+ rm -f $(PROGS) *.o *.d core
=20
-btd.o: btd.h
+-include *.d
--- bttest.c 2001/03/02 10:59:57 1.1
+++ bttest.c 2001/03/10 12:49:32 1.2
@@ -63,8 +63,14 @@
#include <signal.h>
#include <getopt.h>
=20
+#if defined(HAVE_READLINE_READLINE)
#include <readline/readline.h>
#include <readline/history.h>
+#elif defined(HAVE_READLINE)
+#include <readline.h>
+#include <history.h>
+#endif
+
#include "btd.h"
#include "bttest.h"
#include "bt_if.h"
@@ -124,6 +130,13 @@
NULL
};
=20
+#if !defined(HAVE_READLINE) && !defined(HAVE_READLINE_READLINE)
+static void read_history(char *hist_file_name);
+static void write_history(char *hist_file_name);
+static void add_history(char *command);
+static char *readline(char *promt);
+#endif=20
+
void
show_menu(void)
{
@@ -165,6 +178,13 @@
{
int tmp;
char *line =3D (char*) readline("> ");
+
+ if (!line)
+ {
+ start_ppp =3D 0;
+ break;
+ }
+
add_history(line);
=20=20=20=20=20=20=20
tmp =3D process_cmd(line, bt_cfd);
@@ -183,14 +203,8 @@
}
write_history(BTD_HISTORY_FILE);
}=20=20
-
}
=20
-
-
-
-
-
int
process_cmd(char *buf, int bt_cfd)
{
@@ -565,8 +579,41 @@
return 0;
}
=20
+/* readline replacement - mfuchs */
+#if !defined(HAVE_READLINE) && !defined(HAVE_READLINE_READLINE)
+#define MAXLINE 100
=20
+static void read_history(char *hist_file_name)
+{
+}
+
+static void write_history(char *hist_file_name)
+{
+}
+
+static void add_history(char *command)
+{
+}
+
+static char *readline(char *promt)
+{
+ int len;
+ char *line;
=20
+ if ((line =3D malloc(MAXLINE)))
+ {
+ printf("%s", promt);
+ fflush(stdout);
+ *line =3D 0;
+ if ((len =3D read(STDIN_FILENO, line, MAXLINE-1)) >=3D 0)
+ {
+ line[len] =3D 0;
+ }
+ }
+
+ return line;
+}
+#endif /* !HAVE_READLINE */
=20
/* bttest.c */
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
|