Readline support in 2.0.6 w/Solaris

Albert Chin-A-Young china at thewrittenword.com
Sun Dec 5 01:27:20 GMT 1999


On Solaris, the readline library needs to be linked with additional
libraries for -lreadline to be detected correctly. The patch below
fixes configure.

Also, source/client/client.c contains the following which I do not
think is valid ANSI C:
 #ifdef HAVE_LIBREADLINE
 /* Minimal readline support, 29Jun1999, s.xenitellis at rhbnc.ac.uk */
        const int PromptSize = 2048;
        char prompt_str[PromptSize];    /* This holds the buffer "smb: \dir1\> " */
        
        char *temp;                     /* Gets the buffer from readline() */
        temp = (char *)NULL;
 #endif

The possibly invalid line is:
	char prompt_str[PromptSize];

The second patch fixes this.

In lib/username.c, get_home_dir() is defined. However, readline 4.0
exports this symbol so trying to link lib/smbclient errors with this
symbol multiply defined. The third patch fixes this.

Is anyone using compiling in readline support?

-- 
albert chin (china at thewrittenword.com)

-- snip snip
--- source/configure.in.orig	Fri Dec  3 06:42:09 1999
+++ source/configure.in	Sat Dec  4 16:30:31 1999
@@ -298,6 +298,10 @@
 # test for where we get readline() from
 if test "$ac_cv_header_readline_h" = "yes" ||
    test "$ac_cv_header_readline_readline_h" = "yes"; then
+  for termlib in ncurses curses termcap terminfo termlib; do
+    AC_CHECK_LIB(${termlib}, tgetent,
+    [LIBS="-l${termlib} $LIBS"; break])
+  done
   AC_CHECK_LIB(readline,readline)
 fi
 
--- source/client/client.c.orig	Wed Nov 10 20:35:59 1999
+++ source/client/client.c	Sat Dec  4 18:25:21 1999
@@ -1809,10 +1809,15 @@
 #ifdef HAVE_LIBREADLINE
 /* Minimal readline support, 29Jun1999, s.xenitellis at rhbnc.ac.uk */
 	const int PromptSize = 2048;
-	char prompt_str[PromptSize];	/* This holds the buffer "smb: \dir1\> " */
+	char *prompt_str;		/* This holds the buffer "smb: \dir1\> " */
 	
         char *temp;			/* Gets the buffer from readline() */
 	temp = (char *)NULL;
+	prompt_str = malloc (PromptSize);
+	if(!(prompt_str = malloc(PromptSize))) { 
+		DEBUG(0,("malloc fail for size %d\n", PromptSize));
+		return;
+	}
 #endif
 	while (!feof(stdin)) {
 		fstring tok;
@@ -1868,6 +1873,9 @@
 			DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
 		}
 	}
+#ifdef HAVE_LIBREADLINE
+	free (prompt_str);
+#endif
 }
 
 
--- source/lib/username.c.orig	Sat Dec  4 18:39:09 1999
+++ source/lib/username.c	Sat Dec  4 18:39:26 1999
@@ -26,6 +26,7 @@
 static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (char *), int N);
 static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (char *), int N);
 
+#ifndef HAVE_LIBREADLINE
 /****************************************************************************
  Get a users home directory.
 ****************************************************************************/
@@ -39,7 +40,7 @@
   if (!pass) return(NULL);
   return(pass->pw_dir);      
 }
-
+#endif
 
 /*******************************************************************
  Map a username from a dos name to a unix name by looking in the username


More information about the samba-technical mailing list