[prev in list] [next in list] [prev in thread] [next in thread] 

List:       samba
Subject:    Minimal Readline support for smbclient (samba-2.0.4b)
From:       Xenitellis S <S.Xenitellis () rhbnc ! ac ! uk>
Date:       1999-06-30 14:39:33
[Download RAW message or body]


[SHORT STORY: This e-mail is about a minimal libredline
support patch for smbclient (samba-2.0.4b). Conditional
directives have been setup so that without readline library support,
one would get the exact previous functionality without breaking anything.]

Hello!
	Having checked the mailling lists for readline support
for "smbclient", I found one posting about a patch that went 
as far to include smart command completion (complete on
remote/local files based on names etc.). 
	However, in samba-2.0.4b, I see that smbclient has still no
readline support and I assume that that patch has been rejected.

	I have produced a very minimal readline patch for smbclient.

	First, it essentialy declares the name "smbclient" for readline 
so that someone can add smbclient-specific commands to /etc/inputrc or
~/.inputrc. Read the readline-4.0.tar.gz documentation for more.

	Secondly, it adds a new "smbclient" command, called "history"
that prints the command history as in the shells.

	And of course, it allows the standard keystroke bindings
of readline. For example, Ctrl-L clears the screen, arrow keys work etc.

	A thing that has not been tested is "smbclient" being
used in scirpts like "smbprint" that pipe files to the
application to send them for printing. Maybe "readline" gets into
the way and produces problems.

Regards,
Simos Xenitellis


Patch for samba-2.0.4b/source/client/client.c

1572a1573,1592
> #if defined(HAVE_LIBREADLINE)
> #  if defined(HAVE_READLINE_HISTORY_H) || defined(HAVE_HISTORY_H)
>
/***************************************************************************
*
> history
>
****************************************************************************
/
> static void cmd_history(void)
> {
> 	HIST_ENTRY **hlist;
> 	register int i;
> 
> 	hlist = history_list ();	/* Get pointer to history list */
> 	
> 	if (hlist)			/* If list not empty */
> 	{
> 		for (i = 0; hlist[i]; i++)	/* then display it */
> 			DEBUG(0, ("%d: %s\n", i, hlist[i]->line));
> 	}
> }
> #  endif 
> #endif
1628a1649,1651
> #ifdef HAVE_LIBREADLINE
>   {"history",cmd_history,"displays the command
history",{COMPL_NONE,COMPL_NONE}},
> #endif
1765a1789,1796
> #ifdef HAVE_LIBREADLINE
> /* Minimal readline support, 29Jun1999, S.Xenitellis@rhbnc.ac.uk */
> 	const int PromptSize = 2048;
> 	char prompt[PromptSize];	/* This holds the buffer "smb:
\dir1\> " */
> 	
>         char *temp;			/* Gets the buffer from readline()
*/
> 	temp = (char *)NULL;
> #endif
1768a1800,1807
> #ifdef HAVE_LIBREADLINE
> 		if ( temp != (char *)NULL )
> 		{
> 			free( temp );	/* Free memory allocated every time
by readline() */
> 			temp = (char *)NULL;
> 		}
> 
> 		snprintf( prompt, PromptSize - 1, "smb: %s> ",
CNV_LANG(cur_dir) );
1769a1809,1818
> 		temp = readline( prompt );		/* We read the line
here */
> 
> 		if ( !temp )
> 			break;		/* EOF occured */
> 
> 		if ( *temp )		/* If non-empty line, save to
history */
> 			add_history (temp);
> 	
> 		strncpy( line, temp, 1023 ); /* Maximum size of
(pstring)line. Null is guarranteed. */
> #else 
1778a1828
> #endif
2123a2174,2177
> #ifdef HAVE_LIBREADLINE
> 	/* Allow conditional parsing of the ~/.inputrc file. */
> 	rl_readline_name = "smbclient";
> #endif    

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic