All pastes #25003 Raw Edit

Anonymous

public text v1 · immutable
#25003 ·published 2005-10-09 03:36 UTC
rendered paste body
Index: openpbx.c
===================================================================
--- openpbx.c	(revision 275)
+++ openpbx.c	(working copy)
@@ -70,7 +70,7 @@
 #include "openpbx/file.h"
 #include "openpbx/io.h"
 #include "openpbx/lock.h"
-#include "editline/histedit.h"
+/*#include "editline/histedit.h" */
 #include "openpbx/config.h"
 #include "openpbx/version.h"
 #include "openpbx/build.h"
@@ -132,8 +132,10 @@
 time_t opbx_startuptime;
 time_t opbx_lastreloadtime;
 
-static History *el_hist = NULL;
+/* static History *el_hist = NULL;
 static EditLine *el = NULL;
+*/
+static int *el = NULL;
 static char *remotehostname;
 
 struct console consoles[OPBX_MAX_CONNECTS];
@@ -816,10 +818,12 @@
 			snprintf(filename, sizeof(filename), "%s/.openpbx_history", getenv("HOME"));
 		if (!opbx_strlen_zero(filename))
 			opbx_el_write_history(filename);
+		/*
 		if (el != NULL)
 			el_end(el);
 		if (el_hist != NULL)
 			history_end(el_hist);
+		*/
 	}
 	if (option_verbose)
 		opbx_verbose("Executing last minute cleanups\n");
@@ -1104,8 +1108,9 @@
 #endif /* ! LOW_MEMORY */
 };
 
-static int opbx_el_read_char(EditLine *el, char *cp)
+static int opbx_el_read_char(int *el, char *cp)
 {
+#ifdef USE_CLI
 	int num_read=0;
 	int lastpos=0;
 	struct pollfd fds[2];
@@ -1181,10 +1186,13 @@
 
 	*cp = '\0';
 	return (0);
+#endif
+	return (0);
 }
 
-static char *cli_prompt(EditLine *el)
+static char *cli_prompt(void)
 {
+#ifdef USE_CLI
 	static char prompt[200];
 	char *pfmt;
 	int color_used=0;
@@ -1326,6 +1334,8 @@
 		snprintf(prompt, sizeof(prompt), OPENPBX_PROMPT);
 
 	return(prompt);	
+#endif
+	return (0);
 }
 
 static char **opbx_el_strtoarr(char *buf)
@@ -1416,8 +1426,9 @@
 }
 
 
-static char *cli_complete(EditLine *el, int ch)
+static char *cli_complete(int *el, int ch)
 {
+#ifdef USE_CLI
 	int len=0;
 	char *ptr;
 	int nummatches = 0;
@@ -1522,10 +1533,14 @@
 	}
 
 	return (char *)(long)retval;
+#endif
+
+	return NULL;
 }
 
 static int opbx_el_initialize(void)
 {
+#ifdef USE_CLI
 	HistEvent ev;
 	char *editor = getenv("OPBX_EDITOR");
 
@@ -1557,10 +1572,13 @@
 	el_set(el, EL_BIND, "^D", "ed-redisplay", NULL);
 
 	return 0;
+#endif
+	return 0; 
 }
 
 static int opbx_el_add_history(char *buf)
 {
+#ifdef USE_CLI
 	HistEvent ev;
 
 	if (el_hist == NULL || el == NULL)
@@ -1568,20 +1586,26 @@
 	if (strlen(buf) > 256)
 		return 0;
 	return (history(el_hist, &ev, H_ENTER, buf));
+#endif
+	return 0;
 }
 
 static int opbx_el_write_history(char *filename)
 {
+#ifdef USE_CLI
 	HistEvent ev;
 
 	if (el_hist == NULL || el == NULL)
 		opbx_el_initialize();
 
 	return (history(el_hist, &ev, H_SAVE, filename));
+#endif 
+	return 0;
 }
 
 static int opbx_el_read_history(char *filename)
 {
+#ifdef USE_CLI
 	char buf[256];
 	FILE *f;
 	int ret = -1;
@@ -1604,6 +1628,8 @@
 	fclose(f);
 
 	return ret;
+#endif
+	return 0 ;
 }
 
 static void opbx_remotecontrol(char * data)
@@ -1644,6 +1670,8 @@
 	remotehostname = hostname;
 	if (getenv("HOME")) 
 		snprintf(filename, sizeof(filename), "%s/.openpbx_history", getenv("HOME"));
+
+#ifdef USE_CLI
 	if (el_hist == NULL || el == NULL)
 		opbx_el_initialize();
 
@@ -1652,6 +1680,7 @@
 	if (!opbx_strlen_zero(filename))
 		opbx_el_read_history(filename);
 
+
 	if (option_exec && data) {  /* hack to print output then exit if openpbx -rx is used */
 		char tempchar;
 		struct pollfd fds[0];
@@ -1679,6 +1708,8 @@
 		}
 	}
 	printf("\nDisconnected from OpenPBX server\n");
+#endif
+	printf("\nSorry no CLI\n");
 }
 
 static int show_version(void)
@@ -2049,6 +2080,8 @@
 	read_config_maps();
 	
 
+#ifdef USE_CLI
+
 	if (option_console) {
 		if (el_hist == NULL || el == NULL)
 			opbx_el_initialize();
@@ -2056,6 +2089,7 @@
 		if (!opbx_strlen_zero(filename))
 			opbx_el_read_history(filename);
 	}
+#endif
 
 	if (opbx_tryconnect()) {
 		/* One is already running */
@@ -2216,6 +2250,8 @@
 	__opbx_mm_init();
 #endif	
 	time(&opbx_startuptime);
+
+#ifdef USE_CLI
 	opbx_cli_register_multiple(core_cli, sizeof(core_cli) / sizeof(core_cli[0]));
 	if (option_console) {
 		/* Console stuff now... */
@@ -2249,6 +2285,7 @@
 		}
 
 	}
+#endif
 	/* Do nothing */
 	for(;;)  {	/* apparently needed for the MACos */
 		struct pollfd p = { -1 /* no descriptor */, 0, 0 };
Index: Makefile
===================================================================
--- Makefile	(revision 275)
+++ Makefile	(working copy)
@@ -257,7 +257,7 @@
   ASTCFLAGS+=-DZAPTEL_OPTIMIZATIONS
 endif
 
-LIBEDIT=editline/libedit.a
+#LIBEDIT=editline/libedit.a
 
 ifneq ($(wildcard .version),)
   OPENPBXVERSION=$(shell cat .version)
@@ -371,12 +371,12 @@
 
 noclean: depend openpbx subdirs
 
-editline/config.h:
-	cd editline && unset CFLAGS LIBS && ./configure ; \
+#editline/config.h:
+#	cd editline && unset CFLAGS LIBS && ./configure ; \
 
-editline/libedit.a: FORCE
-	cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
-	$(MAKE) -C editline libedit.a
+#editline/libedit.a: FORCE
+#	cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
+#	$(MAKE) -C editline libedit.a
 
 db1-ast/libdb1.a: FORCE
 	@if [ -d db1-ast ]; then \
@@ -460,7 +460,7 @@
 		exit 1; \
 	fi
 
-openpbx: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
+openpbx: db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
 	$(CC) $(DEBUG) -o openpbx $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
 
 muted: muted.o
@@ -476,7 +476,7 @@
 	rm -f include/openpbx/build.h
 	rm -f include/openpbx/version.h
 	rm -f .tags-depend .tags-sources tags TAGS
-	@if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
+#	@if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
 	@if [ -d mpg123-0.59r ]; then $(MAKE) -C mpg123-0.59r clean; fi
 	$(MAKE) -C db1-ast clean
 	$(MAKE) -C stdtime clean
Index: cli.c
===================================================================
--- cli.c	(revision 262)
+++ cli.c	(working copy)
@@ -44,7 +44,7 @@
 #include "openpbx/utils.h"
 #include "openpbx/lock.h"
 /* For rl_filename_completion */
-#include "editline/readline/readline.h"
+/* #include "editline/readline/readline.h" */
 /* For module directory */
 #include "openpbx/version.h"
 #include "openpbx/build.h"
@@ -850,6 +850,7 @@
 
 static char *complete_fn(char *line, char *word, int pos, int state)
 {
+#ifdef USE_CLI
 	char *c;
 	char filename[256];
 	if (pos != 1)
@@ -862,6 +863,8 @@
 	if (c && word[0] != '/')
 		c += (strlen((char*)opbx_config_OPBX_MODULE_DIR) + 1);
 	return c ? strdup(c) : c;
+#endif
+	return NULL;
 }
 
 static int handle_help(int fd, int argc, char *argv[]);