[Pkg-voip-commits] r2233 - asterisk/trunk/debian/patches
Tzafrir Cohen
tzafrir-guest at costa.debian.org
Sat Aug 12 17:08:57 UTC 2006
Author: tzafrir-guest
Date: 2006-08-12 17:08:57 +0000 (Sat, 12 Aug 2006)
New Revision: 2233
Modified:
asterisk/trunk/debian/patches/sys_readline.dpatch
Log:
The readline patch is now functional and ready for prime-time.
In fact, the readline support is much simpler than the editline support.
Modified: asterisk/trunk/debian/patches/sys_readline.dpatch
===================================================================
--- asterisk/trunk/debian/patches/sys_readline.dpatch 2006-08-12 15:43:00 UTC (rev 2232)
+++ asterisk/trunk/debian/patches/sys_readline.dpatch 2006-08-12 17:08:57 UTC (rev 2233)
@@ -5,9 +5,9 @@
## DP: Use readline for the CLI. partially works.
@DPATCH@
-diff -urNad asterisk-1.2.7.1.dfsg/asterisk.c /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/asterisk.c
---- asterisk-1.2.7.1.dfsg/asterisk.c 2006-05-16 10:34:54.818659487 +0300
-+++ /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/asterisk.c 2006-05-16 10:37:29.595033197 +0300
+diff -urNad asterisk-1.2.9.1.dfsg/asterisk.c /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/asterisk.c
+--- asterisk-1.2.9.1.dfsg/asterisk.c 2006-08-11 10:31:42.000000000 +0300
++++ /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/asterisk.c 2006-08-11 10:28:15.000000000 +0300
@@ -114,7 +114,12 @@
#include "asterisk/file.h"
#include "asterisk/io.h"
@@ -21,7 +21,7 @@
#include "asterisk/config.h"
#include "asterisk/version.h"
#include "asterisk/linkedlists.h"
-@@ -198,8 +203,12 @@
+@@ -198,17 +203,23 @@
time_t ast_startuptime;
time_t ast_lastreloadtime;
@@ -34,7 +34,18 @@
static char *remotehostname;
struct console consoles[AST_MAX_CONNECTS];
-@@ -717,6 +726,15 @@
+
+ char defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;
+
++#ifndef SYS_READLINE
+ static int ast_el_add_history(char *);
+ static int ast_el_read_history(char *);
+ static int ast_el_write_history(char *);
++#endif /* SYS_READLINE */
+
+ char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];
+ char ast_config_AST_CONFIG_FILE[AST_CONFIG_MAX_PATH];
+@@ -719,6 +730,15 @@
ast_log(LOG_WARNING, "Unable to create socket: %s\n", strerror(errno));
return 0;
}
@@ -50,7 +61,7 @@
memset(&sunaddr, 0, sizeof(sunaddr));
sunaddr.sun_family = AF_LOCAL;
ast_copy_string(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path));
-@@ -889,11 +907,15 @@
+@@ -891,11 +911,15 @@
if (getenv("HOME"))
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
if (!ast_strlen_zero(filename))
@@ -66,7 +77,7 @@
}
if (option_verbose)
ast_verbose("Executing last minute cleanups\n");
-@@ -1001,7 +1023,11 @@
+@@ -1003,7 +1027,11 @@
fflush(stdout);
/* Called when readline data is available */
if (s && !ast_all_zeros(s))
@@ -78,7 +89,7 @@
/* Give the console access to the shell */
if (s) {
/* The real handler for bang */
-@@ -1021,7 +1047,11 @@
+@@ -1023,7 +1051,11 @@
int ret = 0;
/* Called when readline data is available */
if (s && !ast_all_zeros(s))
@@ -90,7 +101,7 @@
/* Give the console access to the shell */
if (s) {
/* The real handler for bang */
-@@ -1253,7 +1283,76 @@
+@@ -1255,7 +1287,73 @@
#endif /* ! LOW_MEMORY */
};
@@ -144,9 +155,6 @@
+ /* Let's assume we always get complete lines in read-s */
+ fputc('\r', rl_outstream); /* to beginning of line... */
+ /* suppress an excessive linefeed: */
-+ if (buf[res-1] == '\n') {
-+ buf[res-1] = '\0';
-+ }
+ fputs(buf, rl_outstream); /* The text itself */
+ if (option_exec)
+ return 0;
@@ -167,7 +175,7 @@
{
int num_read=0;
int lastpos=0;
-@@ -1332,13 +1431,15 @@
+@@ -1334,13 +1432,15 @@
return (0);
}
@@ -184,15 +192,53 @@
if ((pfmt = getenv("ASTERISK_PROMPT"))) {
char *t = pfmt, *p = prompt;
memset(prompt, 0, sizeof(prompt));
-@@ -1477,6 +1578,7 @@
+@@ -1479,6 +1579,45 @@
return(prompt);
}
-+#ifndef SYS_READLINE
++#ifdef SYS_READLINE
++#define AST_RL_COMPL_BUFLEN (2048)
++static char* ast_rl_completion_function(const char *text, int state)
++{
++ char buf[AST_RL_COMPL_BUFLEN];
++ int len, res;
++ char *resbuf;
++
++ //fprintf(stderr, "\nINPUT: %3d, \"%s\"\n", state, text);
++ if (! option_remote )
++ return ast_cli_generator(rl_line_buffer, (char*)text, state);
++
++ /* option_remote is set */
++ snprintf(buf, sizeof(buf),"_command complete \"%s\" \"%s\" %d",
++ rl_line_buffer, text, state);
++ //fprintf(stderr, "\nSEND: \"%s\"\n", buf);
++ fdprint(ast_consock, buf);
++ res = read(ast_consock, buf, sizeof(buf));
++ if (res <= 0) {
++ //fprintf(stderr,"\nREAD ERROR: %d, (%d: %s)\n",
++ // res, errno, strerror(errno));
++ return NULL;
++ }
++ buf[res] = '\0';
++ if (! strncmp(buf,"NULL\n",5))
++ return NULL;
++ if (buf[0] == '\0')
++ return NULL;
++ //fprintf(stderr, "\nGOT: %3d, \"%s\"\n", res, buf);
++
++ /* buf now contains the result word */
++ len = strlen(buf)+1;
++ resbuf = malloc(len);
++ if (!resbuf)
++ return NULL;
++ ast_copy_string(resbuf, buf, len);
++ return resbuf;
++}
++#else /* SYS_READLINE */
static char **ast_el_strtoarr(char *buf)
{
char **match_list = NULL, *retstr;
-@@ -1754,6 +1856,20 @@
+@@ -1756,6 +1895,23 @@
return ret;
}
@@ -204,8 +250,11 @@
+ /* ignore races for the moment */
+ if (!initilized) {
+ rl_initialize();
-+ rl_set_prompt(cli_prompt());
++ //rl_set_prompt(cli_prompt());
++ rl_readline_name = cli_prompt();
+ rl_event_hook = ast_rl_event_hook;
++ //rl_attempted_completion_function = ast_rl_completion_function;
++ rl_completion_entry_function = ast_rl_completion_function;
+ //fprintf(stderr, "===INITILIZING READLINE==[%s]====\n", cli_prompt());
+ initilized = 1;
+ }
@@ -213,7 +262,7 @@
static void ast_remotecontrol(char * data)
{
-@@ -1768,7 +1884,7 @@
+@@ -1770,7 +1926,7 @@
char *stringp=NULL;
char *ebuf;
@@ -222,7 +271,7 @@
read(ast_consock, buf, sizeof(buf));
if (data)
-@@ -1793,6 +1909,9 @@
+@@ -1795,6 +1951,9 @@
remotehostname = hostname;
if (getenv("HOME"))
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
@@ -232,7 +281,7 @@
if (el_hist == NULL || el == NULL)
ast_el_initialize();
-@@ -1800,7 +1919,8 @@
+@@ -1802,7 +1961,8 @@
if (!ast_strlen_zero(filename))
ast_el_read_history(filename);
@@ -241,30 +290,29 @@
+
if (option_exec && data) { /* hack to print output then exit if asterisk -rx is used */
char tempchar;
- struct pollfd fds[0];
-@@ -1808,12 +1928,21 @@
- fds[0].events = POLLIN;
- fds[0].revents = 0;
- while(poll(fds, 1, 100) > 0) {
-+#ifdef SYS_READLINE
-+ //ast_rl_read_char(&tempchar);
-+ ast_rl_event_hook();
-+#else
+ #ifdef __Darwin__
+@@ -1814,12 +1974,20 @@
ast_el_read_char(el, &tempchar);
-+#endif
}
+ #else
++#ifdef SYS_READLINE
++ while (!ast_rl_read_char(&tempchar));
++#else /* SYS_READLINE */
+ while (!ast_el_read_char(el, &tempchar));
++#endif /* SYS_READLINE */
+ #endif
return;
}
for(;;) {
+#ifdef SYS_READLINE
+ ebuf = readline(cli_prompt());
-+#else
++#else /* SYS_READLINE */
ebuf = (char *)el_gets(el, &num);
-+#endif
++#endif /* SYS_READLINE */
if (!ast_strlen_zero(ebuf)) {
if (ebuf[strlen(ebuf)-1] == '\n')
-@@ -2023,7 +2152,7 @@
+@@ -2029,7 +2197,7 @@
int x;
FILE *f;
sigset_t sigs;
@@ -273,7 +321,7 @@
int is_child_of_nonroot=0;
char *buf;
char *runuser=NULL, *rungroup=NULL;
-@@ -2221,6 +2350,10 @@
+@@ -2227,6 +2395,10 @@
ast_log(LOG_WARNING, "Unable to initialize supplementary group list for %s\n", runuser);
exit(1);
}
@@ -284,7 +332,7 @@
if (setuid(pw->pw_uid)) {
ast_log(LOG_WARNING, "Unable to setuid to %d (%s)\n", (int)pw->pw_uid, runuser);
exit(1);
-@@ -2254,11 +2387,15 @@
+@@ -2260,11 +2432,15 @@
if (option_console) {
@@ -300,7 +348,7 @@
}
if (ast_tryconnect()) {
-@@ -2435,7 +2573,8 @@
+@@ -2442,7 +2619,8 @@
set_title(title);
for (;;) {
@@ -310,9 +358,9 @@
if (buf) {
if (buf[strlen(buf)-1] == '\n')
buf[strlen(buf)-1] = '\0';
-diff -urNad asterisk-1.2.7.1.dfsg/cli.c /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/cli.c
---- asterisk-1.2.7.1.dfsg/cli.c 2006-05-16 10:34:54.045457773 +0300
-+++ /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/cli.c 2006-05-16 10:34:55.592861462 +0300
+diff -urNad asterisk-1.2.9.1.dfsg/cli.c /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/cli.c
+--- asterisk-1.2.9.1.dfsg/cli.c 2006-08-11 10:31:41.000000000 +0300
++++ /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/cli.c 2006-08-11 10:31:45.000000000 +0300
@@ -44,7 +44,15 @@
#include "asterisk/utils.h"
#include "asterisk/lock.h"
@@ -329,10 +377,10 @@
/* For module directory */
#include "asterisk/version.h"
-diff -urNad asterisk-1.2.7.1.dfsg/Makefile /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/Makefile
---- asterisk-1.2.7.1.dfsg/Makefile 2006-05-16 10:34:54.818659487 +0300
-+++ /tmp/dpep.yLtN9f/asterisk-1.2.7.1.dfsg/Makefile 2006-05-16 10:34:55.850928786 +0300
-@@ -307,7 +307,11 @@
+diff -urNad asterisk-1.2.9.1.dfsg/Makefile /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/Makefile
+--- asterisk-1.2.9.1.dfsg/Makefile 2006-08-11 10:31:42.000000000 +0300
++++ /tmp/dpep.eom8T2/asterisk-1.2.9.1.dfsg/Makefile 2006-08-11 10:31:45.000000000 +0300
+@@ -306,7 +306,11 @@
endif # WITHOUT_ZAPTEL
@@ -345,7 +393,7 @@
ifneq ($(wildcard .version),)
ASTERISKVERSION:=$(shell cat .version)
-@@ -515,7 +519,7 @@
+@@ -511,7 +515,7 @@
cygwin_a:
$(MAKE) -C cygwin all
More information about the Pkg-voip-commits
mailing list