[multipathd] readline support for daemon control shell
authorroot <root@xa-s05.(none)>
Mon, 20 Jun 2005 07:57:20 +0000 (09:57 +0200)
committerroot <root@xa-s05.(none)>
Mon, 20 Jun 2005 07:57:20 +0000 (09:57 +0200)
... with history

multipathd/Makefile
multipathd/uxclnt.c

index 5af3f83..cca8b0f 100644 (file)
@@ -15,7 +15,7 @@ rcdir = /etc/init.d
 #
 CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes \
         -DDAEMON -I$(multipathdir) -I$(checkersdir)
-LDFLAGS = -lpthread -ldevmapper -lsysfs
+LDFLAGS = -lpthread -ldevmapper -lsysfs -lreadline
 
 #
 # debuging stuff
index fc019dc..d6f1f65 100644 (file)
@@ -8,6 +8,8 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/poll.h>
+#include <readline/readline.h>
+#include <readline/history.h>
 
 #include <uxsock.h>
 
  */
 static void process(int fd)
 {
-       char line[1000];
+       char *line;
        char *reply;
 
-       while (fgets(line, sizeof(line), stdin)) {
+       while (line = readline("multipathd> ")) {
                size_t len = strlen(line);
 
-               if (line[len-1] == '\n') {
-                       line[len-1] = 0;
-                       len--;
-               }
-               
                if (send_packet(fd, line, strlen(line)) != 0) break;
                if (recv_packet(fd, &reply, &len) != 0) break;
 
                printf("%*.*s\n", (int)len, (int)len, reply);
+               add_history(line);
+               free(line);
                free(reply);
        }
 }