Browse Source

Compilation of tclish. The libclish don't contain tcl functions. The tclish is compilable but don't know anything about tcl so I don't know is current tclish is usefull.

git-svn-id: https://klish.googlecode.com/svn/trunk@289 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
944eb52bd1
12 changed files with 127 additions and 141 deletions
  1. 28 57
      Makefile.in
  2. 7 2
      bin/module.am
  3. 20 0
      bin/tcl_private.h
  4. 58 40
      bin/tclish.cpp
  5. 1 1
      bin/tclish_fini_callback.c
  6. 1 2
      bin/tclish_init_callback.c
  7. 3 3
      bin/tclish_script_callback.c
  8. 1 2
      bin/tclish_show_result.c
  9. 2 18
      clish/internal.h
  10. 0 4
      clish/module.am
  11. 4 7
      configure
  12. 2 5
      configure.ac

+ 28 - 57
Makefile.in

@@ -197,10 +197,6 @@ am__dirstamp = $(am__leading_dot)dirstamp
 am_libclish_la_OBJECTS = clish/libclish_la-clish_access_callback.lo \
 	clish/libclish_la-clish_script_callback.lo \
 	clish/libclish_la-clish_config_callback.lo \
-	clish/libclish_la-tclish_fini_callback.lo \
-	clish/libclish_la-tclish_init_callback.lo \
-	clish/libclish_la-tclish_script_callback.lo \
-	clish/libclish_la-tclish_show_result.lo \
 	clish/command/libclish_la-command.lo \
 	clish/command/libclish_la-command_dump.lo \
 	clish/param/libclish_la-param.lo \
@@ -452,7 +448,11 @@ am__bin_lubheap_SOURCES_DIST = bin/lubheap.c
 @LUBHEAP_TRUE@am_bin_lubheap_OBJECTS = bin/lubheap.$(OBJEXT)
 bin_lubheap_OBJECTS = $(am_bin_lubheap_OBJECTS)
 bin_lubheap_DEPENDENCIES =
-am_bin_tclish@TCL_VERSION@_OBJECTS = bin/tclish.$(OBJEXT)
+am_bin_tclish@TCL_VERSION@_OBJECTS = bin/tclish.$(OBJEXT) \
+	bin/tclish_fini_callback.$(OBJEXT) \
+	bin/tclish_init_callback.$(OBJEXT) \
+	bin/tclish_script_callback.$(OBJEXT) \
+	bin/tclish_show_result.$(OBJEXT)
 bin_tclish@TCL_VERSION@_OBJECTS =  \
 	$(am_bin_tclish@TCL_VERSION@_OBJECTS)
 bin_tclish@TCL_VERSION@_DEPENDENCIES = libclish.la
@@ -747,10 +747,15 @@ bin_konf_LDADD = \
     @KONF_LIBS@ \
     @LUB_LIBS@
 
-bin_tclish@TCL_VERSION@_SOURCES = bin/tclish.cpp
+bin_tclish@TCL_VERSION@_SOURCES = bin/tclish.cpp \
+    bin/tclish_fini_callback.c   \
+    bin/tclish_init_callback.c   \
+    bin/tclish_script_callback.c \
+    bin/tclish_show_result.c
+
 bin_tclish@TCL_VERSION@_LDADD = \
     libclish.la                   \
-    @KONF_LIBS@ \
+    @KONF_LIBS@                   \
     @TINYRL_LIBS@                 \
     @TINYXML_LIBS@                \
     @TCL_LIBS@                    \
@@ -768,8 +773,6 @@ bin_tclish@TCL_VERSION@_LDADD = \
 
 libclish_la_SOURCES = clish/clish_access_callback.c \
 	clish/clish_script_callback.c clish/clish_config_callback.c \
-	clish/tclish_fini_callback.c clish/tclish_init_callback.c \
-	clish/tclish_script_callback.c clish/tclish_show_result.c \
 	clish/private.h clish/command/command.c \
 	clish/command/command_dump.c clish/command/private.h \
 	clish/param/param.c clish/param/param_dump.c \
@@ -1024,14 +1027,6 @@ clish/libclish_la-clish_script_callback.lo: clish/$(am__dirstamp) \
 	clish/$(DEPDIR)/$(am__dirstamp)
 clish/libclish_la-clish_config_callback.lo: clish/$(am__dirstamp) \
 	clish/$(DEPDIR)/$(am__dirstamp)
-clish/libclish_la-tclish_fini_callback.lo: clish/$(am__dirstamp) \
-	clish/$(DEPDIR)/$(am__dirstamp)
-clish/libclish_la-tclish_init_callback.lo: clish/$(am__dirstamp) \
-	clish/$(DEPDIR)/$(am__dirstamp)
-clish/libclish_la-tclish_script_callback.lo: clish/$(am__dirstamp) \
-	clish/$(DEPDIR)/$(am__dirstamp)
-clish/libclish_la-tclish_show_result.lo: clish/$(am__dirstamp) \
-	clish/$(DEPDIR)/$(am__dirstamp)
 clish/command/$(am__dirstamp):
 	@$(MKDIR_P) clish/command
 	@: > clish/command/$(am__dirstamp)
@@ -1664,6 +1659,14 @@ bin/lubheap$(EXEEXT): $(bin_lubheap_OBJECTS) $(bin_lubheap_DEPENDENCIES) bin/$(a
 	$(LINK) $(bin_lubheap_OBJECTS) $(bin_lubheap_LDADD) $(LIBS)
 bin/tclish.$(OBJEXT): bin/$(am__dirstamp) \
 	bin/$(DEPDIR)/$(am__dirstamp)
+bin/tclish_fini_callback.$(OBJEXT): bin/$(am__dirstamp) \
+	bin/$(DEPDIR)/$(am__dirstamp)
+bin/tclish_init_callback.$(OBJEXT): bin/$(am__dirstamp) \
+	bin/$(DEPDIR)/$(am__dirstamp)
+bin/tclish_script_callback.$(OBJEXT): bin/$(am__dirstamp) \
+	bin/$(DEPDIR)/$(am__dirstamp)
+bin/tclish_show_result.$(OBJEXT): bin/$(am__dirstamp) \
+	bin/$(DEPDIR)/$(am__dirstamp)
 bin/tclish@TCL_VERSION@$(EXEEXT): $(bin_tclish@TCL_VERSION@_OBJECTS) $(bin_tclish@TCL_VERSION@_DEPENDENCIES) bin/$(am__dirstamp)
 	@rm -f bin/tclish@TCL_VERSION@$(EXEEXT)
 	$(CXXLINK) $(bin_tclish@TCL_VERSION@_OBJECTS) $(bin_tclish@TCL_VERSION@_LDADD) $(LIBS)
@@ -1706,6 +1709,10 @@ mostlyclean-compile:
 	-rm -f bin/konfd.$(OBJEXT)
 	-rm -f bin/lubheap.$(OBJEXT)
 	-rm -f bin/tclish.$(OBJEXT)
+	-rm -f bin/tclish_fini_callback.$(OBJEXT)
+	-rm -f bin/tclish_init_callback.$(OBJEXT)
+	-rm -f bin/tclish_script_callback.$(OBJEXT)
+	-rm -f bin/tclish_show_result.$(OBJEXT)
 	-rm -f clish/command/libclish_la-command.$(OBJEXT)
 	-rm -f clish/command/libclish_la-command.lo
 	-rm -f clish/command/libclish_la-command_dump.$(OBJEXT)
@@ -1716,14 +1723,6 @@ mostlyclean-compile:
 	-rm -f clish/libclish_la-clish_config_callback.lo
 	-rm -f clish/libclish_la-clish_script_callback.$(OBJEXT)
 	-rm -f clish/libclish_la-clish_script_callback.lo
-	-rm -f clish/libclish_la-tclish_fini_callback.$(OBJEXT)
-	-rm -f clish/libclish_la-tclish_fini_callback.lo
-	-rm -f clish/libclish_la-tclish_init_callback.$(OBJEXT)
-	-rm -f clish/libclish_la-tclish_init_callback.lo
-	-rm -f clish/libclish_la-tclish_script_callback.$(OBJEXT)
-	-rm -f clish/libclish_la-tclish_script_callback.lo
-	-rm -f clish/libclish_la-tclish_show_result.$(OBJEXT)
-	-rm -f clish/libclish_la-tclish_show_result.lo
 	-rm -f clish/nspace/libclish_la-nspace.$(OBJEXT)
 	-rm -f clish/nspace/libclish_la-nspace.lo
 	-rm -f clish/nspace/libclish_la-nspace_dump.$(OBJEXT)
@@ -2070,13 +2069,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/konfd.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/lubheap.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/tclish.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/tclish_fini_callback.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/tclish_init_callback.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/tclish_script_callback.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bin/$(DEPDIR)/tclish_show_result.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-clish_access_callback.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-clish_config_callback.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-clish_script_callback.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-tclish_fini_callback.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-tclish_init_callback.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-tclish_script_callback.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@clish/$(DEPDIR)/libclish_la-tclish_show_result.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/command/$(DEPDIR)/libclish_la-command.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/command/$(DEPDIR)/libclish_la-command_dump.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@clish/nspace/$(DEPDIR)/libclish_la-nspace.Plo@am__quote@
@@ -2296,34 +2295,6 @@ clish/libclish_la-clish_config_callback.lo: clish/clish_config_callback.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -c -o clish/libclish_la-clish_config_callback.lo `test -f 'clish/clish_config_callback.c' || echo '$(srcdir)/'`clish/clish_config_callback.c
 
-clish/libclish_la-tclish_fini_callback.lo: clish/tclish_fini_callback.c
-@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -MT clish/libclish_la-tclish_fini_callback.lo -MD -MP -MF clish/$(DEPDIR)/libclish_la-tclish_fini_callback.Tpo -c -o clish/libclish_la-tclish_fini_callback.lo `test -f 'clish/tclish_fini_callback.c' || echo '$(srcdir)/'`clish/tclish_fini_callback.c
-@am__fastdepCC_TRUE@	$(am__mv) clish/$(DEPDIR)/libclish_la-tclish_fini_callback.Tpo clish/$(DEPDIR)/libclish_la-tclish_fini_callback.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='clish/tclish_fini_callback.c' object='clish/libclish_la-tclish_fini_callback.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -c -o clish/libclish_la-tclish_fini_callback.lo `test -f 'clish/tclish_fini_callback.c' || echo '$(srcdir)/'`clish/tclish_fini_callback.c
-
-clish/libclish_la-tclish_init_callback.lo: clish/tclish_init_callback.c
-@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -MT clish/libclish_la-tclish_init_callback.lo -MD -MP -MF clish/$(DEPDIR)/libclish_la-tclish_init_callback.Tpo -c -o clish/libclish_la-tclish_init_callback.lo `test -f 'clish/tclish_init_callback.c' || echo '$(srcdir)/'`clish/tclish_init_callback.c
-@am__fastdepCC_TRUE@	$(am__mv) clish/$(DEPDIR)/libclish_la-tclish_init_callback.Tpo clish/$(DEPDIR)/libclish_la-tclish_init_callback.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='clish/tclish_init_callback.c' object='clish/libclish_la-tclish_init_callback.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -c -o clish/libclish_la-tclish_init_callback.lo `test -f 'clish/tclish_init_callback.c' || echo '$(srcdir)/'`clish/tclish_init_callback.c
-
-clish/libclish_la-tclish_script_callback.lo: clish/tclish_script_callback.c
-@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -MT clish/libclish_la-tclish_script_callback.lo -MD -MP -MF clish/$(DEPDIR)/libclish_la-tclish_script_callback.Tpo -c -o clish/libclish_la-tclish_script_callback.lo `test -f 'clish/tclish_script_callback.c' || echo '$(srcdir)/'`clish/tclish_script_callback.c
-@am__fastdepCC_TRUE@	$(am__mv) clish/$(DEPDIR)/libclish_la-tclish_script_callback.Tpo clish/$(DEPDIR)/libclish_la-tclish_script_callback.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='clish/tclish_script_callback.c' object='clish/libclish_la-tclish_script_callback.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -c -o clish/libclish_la-tclish_script_callback.lo `test -f 'clish/tclish_script_callback.c' || echo '$(srcdir)/'`clish/tclish_script_callback.c
-
-clish/libclish_la-tclish_show_result.lo: clish/tclish_show_result.c
-@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -MT clish/libclish_la-tclish_show_result.lo -MD -MP -MF clish/$(DEPDIR)/libclish_la-tclish_show_result.Tpo -c -o clish/libclish_la-tclish_show_result.lo `test -f 'clish/tclish_show_result.c' || echo '$(srcdir)/'`clish/tclish_show_result.c
-@am__fastdepCC_TRUE@	$(am__mv) clish/$(DEPDIR)/libclish_la-tclish_show_result.Tpo clish/$(DEPDIR)/libclish_la-tclish_show_result.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='clish/tclish_show_result.c' object='clish/libclish_la-tclish_show_result.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -c -o clish/libclish_la-tclish_show_result.lo `test -f 'clish/tclish_show_result.c' || echo '$(srcdir)/'`clish/tclish_show_result.c
-
 clish/command/libclish_la-command.lo: clish/command/command.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclish_la_CFLAGS) $(CFLAGS) -MT clish/command/libclish_la-command.lo -MD -MP -MF clish/command/$(DEPDIR)/libclish_la-command.Tpo -c -o clish/command/libclish_la-command.lo `test -f 'clish/command/command.c' || echo '$(srcdir)/'`clish/command/command.c
 @am__fastdepCC_TRUE@	$(am__mv) clish/command/$(DEPDIR)/libclish_la-command.Tpo clish/command/$(DEPDIR)/libclish_la-command.Plo

+ 7 - 2
bin/module.am

@@ -24,10 +24,15 @@ bin_konf_LDADD  = \
 
 bin_PROGRAMS += bin/tclish@TCL_VERSION@
 
-bin_tclish@TCL_VERSION@_SOURCES = bin/tclish.cpp
+bin_tclish@TCL_VERSION@_SOURCES = bin/tclish.cpp \
+    bin/tclish_fini_callback.c   \
+    bin/tclish_init_callback.c   \
+    bin/tclish_script_callback.c \
+    bin/tclish_show_result.c
+
 bin_tclish@TCL_VERSION@_LDADD   = \
     libclish.la                   \
-    @KONF_LIBS@ \
+    @KONF_LIBS@                   \
     @TINYRL_LIBS@                 \
     @TINYXML_LIBS@                \
     @TCL_LIBS@                    \

+ 20 - 0
bin/tcl_private.h

@@ -0,0 +1,20 @@
+#include "clish/shell.h"
+
+_BEGIN_C_DECL
+
+struct Tcl_Interp;
+
+typedef struct tclish_cookie_s tclish_cookie_t;
+struct tclish_cookie_s {
+	struct Tcl_Interp *interp;
+};
+
+/* tclish callback functions */
+extern void tclish_show_result(struct Tcl_Interp *interp);
+extern clish_shell_init_fn_t tclish_init_callback;
+extern clish_shell_access_fn_t tclish_access_callback;
+extern clish_shell_script_fn_t tclish_script_callback;
+extern clish_shell_fini_fn_t tclish_fini_callback;
+
+_END_C_DECL
+

+ 58 - 40
bin/tclish.cpp

@@ -19,12 +19,13 @@
 #ifdef HAVE_LIBTCL
 #include <assert.h>
 #include <stdlib.h>
-
 #include <unistd.h>
+#include <tcl.h>
 
-#include "tcl.h"
+#include "clish/shell.h"
+#include "clish/internal.h"
+#include "tcl_private.h"
 
-#include "clish/private.h"
 //---------------------------------------------------------
 static clish_shell_hooks_t my_hooks = 
 {
@@ -33,6 +34,7 @@ static clish_shell_hooks_t my_hooks =
     NULL, /* don't worry about cmd_line callback */
     tclish_script_callback,
     tclish_fini_callback,
+    NULL, /* don't worry about config callback */
     NULL
 };
 //---------------------------------------------------------
@@ -61,45 +63,61 @@ tclish_cookie_new(const char *argv0)
 int 
 main(int argc, const char **argv)
 {
-    int              status = 0;
-	tclish_cookie_t *cookie; 
-    
-    clish_startup(argc,argv);
-    
-    if(argc > 1)
-    {
-        int i = 1;
-        while((0 == status) && argc--)
-        {
-            cookie = tclish_cookie_new(argv[0]);
-            /* run the commands in the file */
-            status = clish_shell_spawn_from_file(&my_hooks,cookie,argv[i++]);
-        }
-    }
-    else
-    {
-        pthread_t pthread;
-        void     *dummy;
-        
-        cookie = tclish_cookie_new(argv[0]);
-        /* spawn the shell */
-        status = clish_shell_spawn(&pthread,NULL,&my_hooks,cookie);
+	tclish_cookie_t *cookie;
+	bool_t running;
+	int result = -1;
+	clish_shell_t * shell;
+	bool_t lockless = BOOL_FALSE;
+	bool_t stop_on_error = BOOL_FALSE;
+	const char *xml_path = getenv("CLISH_PATH");
+	const char *view = getenv("CLISH_VIEW");
+	const char *viewid = getenv("CLISH_VIEWID");
 
-        if(-1 != status)
-        {
-            pthread_join(pthread,&dummy);
-        }
-    }
-    if(-1 == status)
-    {
-        /* something went wrong */
-        free(cookie);
-    }
-    
-    (void)Tcl_FinalizeThread();
-    clish_shutdown();
+	cookie = tclish_cookie_new(argv[0]);
+	/* Create shell instance */
+	shell = clish_shell_new(&my_hooks, cookie, NULL, stdout, stop_on_error);
+	if (!shell) {
+		fprintf(stderr, "Cannot run clish.\n");
+		return -1;
+	}
+	/* Load the XML files */
+	clish_shell_load_scheme(shell, xml_path);
+	/* Set communication to the konfd */
+//	clish_shell__set_socket(shell, socket_path);
+	/* Set lockless mode */
+	if (lockless)
+		clish_shell__set_lockfile(shell, NULL);
+	/* Set startup view */
+	if (view)
+		clish_shell__set_startup_view(shell, view);
+	/* Set startup viewid */
+	if (viewid)
+		clish_shell__set_startup_viewid(shell, viewid);
+	/* Execute startup */
+	running = clish_shell_startup(shell);
+	if (!running) {
+		fprintf(stderr, "Cannot startup clish.\n");
+		clish_shell_delete(shell);
+		return -1;
+	}
+
+	if(argc > 1) {
+		int i;
+		/* Run the commands from the files */
+		for (i = argc - 1; i >= 1; i--)
+			clish_shell_push_file(shell, argv[i], stop_on_error);
+	} else {
+		/* The interactive shell */
+		clish_shell_push_fd(shell, fdopen(dup(fileno(stdin)), "r"), stop_on_error);
+	}
+	result = clish_shell_loop(shell);
+
+	/* Cleanup */
+	clish_shell_delete(shell);
+	free(cookie);
+	(void)Tcl_FinalizeThread();
 
- 	return status;
+	return result ? 0 : -1;
 }
 //---------------------------------------------------------
 #else /* not HAVE_LIBTCL */

+ 1 - 1
clish/tclish_fini_callback.c → bin/tclish_fini_callback.c

@@ -11,7 +11,7 @@
 #include <stdlib.h>
 #include <tcl.h>
 
-#include "private.h"
+#include "tcl_private.h"
 /*--------------------------------------------------------- */
 void tclish_fini_callback(const clish_shell_t * shell)
 {

+ 1 - 2
clish/tclish_init_callback.c → bin/tclish_init_callback.c

@@ -10,10 +10,9 @@
 
 #ifdef HAVE_LIBTCL
 #include <assert.h>
-
 #include <tcl.h>
 
-#include "private.h"
+#include "tcl_private.h"
 /*--------------------------------------------------------- */
 bool_t tclish_init_callback(const clish_shell_t * shell)
 {

+ 3 - 3
clish/tclish_script_callback.c → bin/tclish_script_callback.c

@@ -13,12 +13,12 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-
 #include <tcl.h>
 
-#include "private.h"
+#include "tcl_private.h"
 /*--------------------------------------------------------- */
-bool_t tclish_script_callback(const clish_shell_t * shell, const char *script)
+bool_t tclish_script_callback(clish_shell_t * shell,
+	const clish_command_t * cmd, const char *script, char ** out)
 {
 	bool_t result = BOOL_TRUE;
 	tclish_cookie_t *this = clish_shell__get_client_cookie(shell);

+ 1 - 2
clish/tclish_show_result.c → bin/tclish_show_result.c

@@ -9,10 +9,9 @@
 
 #ifdef HAVE_LIBTCL
 #include <assert.h>
-
 #include <tcl.h>
 
-#include "private.h"
+#include "tcl_private.h"
 /*--------------------------------------------------------- */
 void tclish_show_result(Tcl_Interp * interp)
 {

+ 2 - 18
clish/internal.h

@@ -4,31 +4,15 @@
 #include "lub/c_decl.h"
 #include "clish/shell.h"
 
-_BEGIN_C_DECL struct Tcl_Interp;
-
-typedef struct tclish_cookie_s tclish_cookie_t;
-struct tclish_cookie_s {
-	struct Tcl_Interp *interp;
-};
-
-/* utility functions */
-extern void clish_startup(int argc, const char **argv);
-extern void clish_shutdown(void);
-extern void tclish_show_result(struct Tcl_Interp *interp);
+_BEGIN_C_DECL
 
 /* storage */
 extern struct termios clish_default_tty_termios;
 
-/* clish callback functions */
+/* Standard clish callback functions */
 extern clish_shell_access_fn_t clish_access_callback;
 extern clish_shell_script_fn_t clish_script_callback;
 extern clish_shell_script_fn_t clish_dryrun_callback;
 extern clish_shell_config_fn_t clish_config_callback;
 
-/* tclish callback functions */
-extern clish_shell_init_fn_t tclish_init_callback;
-extern clish_shell_access_fn_t tclish_access_callback;
-extern clish_shell_script_fn_t tclish_script_callback;
-extern clish_shell_fini_fn_t tclish_fini_callback;
-
 _END_C_DECL

+ 0 - 4
clish/module.am

@@ -4,10 +4,6 @@ libclish_la_SOURCES              = \
     clish/clish_access_callback.c  \
     clish/clish_script_callback.c  \
     clish/clish_config_callback.c  \
-    clish/tclish_fini_callback.c   \
-    clish/tclish_init_callback.c   \
-    clish/tclish_script_callback.c \
-    clish/tclish_show_result.c     \
     clish/private.h
 
 libclish_la_CFLAGS = @LUB_CFLAGS@ @LUBHEAP_CFLAGS@ $(DEBUG_CFLAGS)

+ 4 - 7
configure

@@ -15177,23 +15177,20 @@ fi
 $as_echo "$ac_cv_lib_tcl_Tcl_CreateInterp" >&6; }
 if test "x$ac_cv_lib_tcl_Tcl_CreateInterp" = x""yes; then :
 
-            tcl_found="yes"
 
-fi
+$as_echo "#define HAVE_LIBTCL /**/" >>confdefs.h
 
 
-fi
 
-done
 
-    if test "x${tcl_found}" != "x"; then
 
-$as_echo "#define HAVE_LIBTCL /**/" >>confdefs.h
+fi
 
 
+fi
 
+done
 
-    fi
 fi
 
 fi

+ 2 - 5
configure.ac

@@ -165,15 +165,12 @@ if test -e $TCL_CONFIG; then
     CPPFLAGS="$CPPFLAGS $TCL_CFLAGS"
     AC_CHECK_HEADERS(tcl.h,
         AC_CHECK_LIB(tcl, Tcl_CreateInterp, [
-            tcl_found="yes"
-        ])
-    )
-    if test "x${tcl_found}" != "x"; then
             AC_DEFINE([HAVE_LIBTCL], [], [Have TCL library])
             AC_SUBST(TCL_CFLAGS)
             AC_SUBST(TCL_LIBS)
             AC_SUBST(TCL_VERSION)
-    fi
+        ])
+    )
 fi
 )