Index: src/helper/configuration.h
===================================================================
--- src/helper/configuration.h	(revision 753)
+++ src/helper/configuration.h	(working copy)
@@ -27,7 +27,7 @@
 extern int parse_config_file(struct command_context_s *cmd_ctx);
 extern void add_config_command (const char *cfg);
 extern void add_script_search_dir (const char *dir);
-extern int configuration_output_handler(struct command_context_s *context, char* line);
+extern int configuration_output_handler(struct command_context_s *context, const char* line);
 extern FILE *open_file_from_path (char *file, char *mode);
 extern char *find_file(char *name);
 
Index: src/helper/command.c
===================================================================
--- src/helper/command.c	(revision 753)
+++ src/helper/command.c	(working copy)
@@ -302,6 +302,13 @@
 	return nwords;
 }
 
+void command_output_text( command_context_t *context, const char *data )
+{
+	if( context && context->output_handler && data  ){
+		context->output_handler( context, data );
+	}
+}
+
 void command_print_n(command_context_t *context, char *format, ...)
 {
 	char *string;
@@ -619,7 +626,7 @@
     return command_print_help_match(context, context->commands, name, args, argc);
 }
 
-void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, char* line), void *priv)
+void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv)
 {
 	context->output_handler = output_handler;
 	context->output_handler_priv = priv;
@@ -718,3 +725,10 @@
 
 	return retval;
 }
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/helper/command.h
===================================================================
--- src/helper/command.h	(revision 753)
+++ src/helper/command.h	(working copy)
@@ -48,7 +48,7 @@
 	 * Returning ERROR_COMMAND_SYNTAX_ERROR will have the effect of
 	 * printing out the syntax of the command.
 	 */
-	int (*output_handler)(struct command_context_s *context, char* line);
+	int (*output_handler)(struct command_context_s *context, const char* line);
 	void *output_handler_priv;
 } command_context_t;
 
@@ -67,7 +67,7 @@
 extern command_t* register_command(command_context_t *context, command_t *parent, char *name, int (*handler)(struct command_context_s *context, char* name, char** args, int argc), enum command_mode mode, char *help);
 extern int unregister_command(command_context_t *context, char *name);
 extern int unregister_all_commands(command_context_t *context);
-extern void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, char* line), void *priv);
+extern void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv);
 extern command_context_t* copy_command_context(command_context_t* context);
 extern command_context_t* command_init();
 extern int command_done(command_context_t *context);
@@ -86,3 +86,11 @@
 extern int fast_and_dangerous;
 
 #endif /* COMMAND_H */
+
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/helper/options.c
===================================================================
--- src/helper/options.c	(revision 753)
+++ src/helper/options.c	(working copy)
@@ -45,7 +45,7 @@
 	{0, 0, 0, 0}
 };
 
-int configuration_output_handler(struct command_context_s *context, char* line)
+int configuration_output_handler(struct command_context_s *context, const char* line)
 {
 	LOG_INFO_N(line);
 
Index: src/jim.c
===================================================================
--- src/jim.c	(revision 753)
+++ src/jim.c	(working copy)
@@ -363,7 +363,7 @@
 #else
     *widePtr = strtol(str, &endptr, base);
 #endif
-    if (str[0] == '\0')
+    if ((str[0] == '\0') || (str == endptr) )
         return JIM_ERR;
     if (endptr[0] != '\0') {
         while(*endptr) {
@@ -380,7 +380,7 @@
     char *endptr;
 
     *intPtr = strtol(str, &endptr, 10);
-    if (str[0] == '\0')
+    if ( (str[0] == '\0') || (str == endptr) )
         return JIM_ERR;
     if (endptr[0] != '\0') {
         while(*endptr) {
@@ -437,7 +437,7 @@
     char *endptr;
 
     *doublePtr = strtod(str, &endptr);
-    if (str[0] == '\0' || endptr[0] != '\0')
+    if (str[0] == '\0' || endptr[0] != '\0' || (str == endptr) )
         return JIM_ERR;
     return JIM_OK;
 }
@@ -460,13 +460,16 @@
 void Jim_Panic(Jim_Interp *interp, const char *fmt, ...)
 {
     va_list ap;
-    FILE *fp = interp ? interp->stderr_ : stderr;
 
     va_start(ap, fmt);
-    fprintf(fp, JIM_NL "JIM INTERPRETER PANIC: ");
-    vfprintf(fp, fmt, ap);
-    fprintf(fp, JIM_NL JIM_NL);
+	/* 
+	 * Send it here first.. Assuming STDIO still works
+	 */
+    fprintf(stderr, JIM_NL "JIM INTERPRETER PANIC: ");
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, JIM_NL JIM_NL);
     va_end(ap);
+
 #ifdef HAVE_BACKTRACE
     {
         void *array[40];
@@ -481,6 +484,13 @@
         fprintf(fp,"[backtrace] of 'nm <executable>' in the bug report." JIM_NL);
     }
 #endif
+	
+	/* This may actually crash... we do it last */
+	if( interp && interp->cookie_stderr ){
+		Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL "JIM INTERPRETER PANIC: ");
+		Jim_vfprintf( interp, interp->cookie_stderr, fmt, ap );
+		Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL JIM_NL );
+	}
     abort();
 }
 
@@ -2136,21 +2146,36 @@
 }
 
 /* This is the core of the [format] command.
- * TODO: Export it, make it real... for now only %s and %%
- * specifiers supported. */
+ * TODO: Lots of things work - via a hack
+ *       However, no format item can be >= JIM_MAX_FMT 
+ */
 Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
         int objc, Jim_Obj *const *objv)
 {
-    const char *fmt;
+    const char *fmt, *_fmt;
     int fmtLen;
     Jim_Obj *resObjPtr;
+    
 
     fmt = Jim_GetString(fmtObjPtr, &fmtLen);
+	_fmt = fmt;
     resObjPtr = Jim_NewStringObj(interp, "", 0);
     while (fmtLen) {
         const char *p = fmt;
         char spec[2], c;
         jim_wide wideValue;
+		double doubleValue;
+		/* we cheat and use Sprintf()! */
+#define JIM_MAX_FMT 2048
+		char sprintf_buf[JIM_MAX_FMT];
+		char fmt_str[100];
+		char *cp;
+		int width;
+		int ljust;
+		int zpad;
+		int spad;
+		int altfm;
+		int forceplus;
 
         while (*fmt != '%' && fmtLen) {
             fmt++; fmtLen--;
@@ -2159,38 +2184,191 @@
         if (fmtLen == 0)
             break;
         fmt++; fmtLen--; /* skip '%' */
-        if (*fmt != '%') {
+		zpad = 0;
+		spad = 0;
+		width = -1;
+		ljust = 0;
+		altfm = 0;
+		forceplus = 0;
+    next_fmt:
+		if( fmtLen <= 0 ){
+			break;
+		}
+		switch( *fmt ){
+			/* terminals */
+        case 'b': /* binary - not all printfs() do this */
+		case 's': /* string */
+		case 'i': /* integer */
+		case 'd': /* decimal */
+		case 'x': /* hex */
+		case 'X': /* CAP hex */
+		case 'c': /* char */
+		case 'o': /* octal */
+		case 'u': /* unsigned */
+		case 'f': /* float */
+			break;
+			
+			/* non-terminals */
+		case '0': /* zero pad */
+			zpad = 1;
+			*fmt++;  fmtLen--;
+			goto next_fmt;
+			break;
+		case '+':
+			forceplus = 1;
+			*fmt++;  fmtLen--;
+			goto next_fmt;
+			break;
+		case ' ': /* sign space */
+			spad = 1;
+			*fmt++;  fmtLen--;
+			goto next_fmt;
+			break;
+		case '-':
+			ljust = 1;
+			*fmt++;  fmtLen--;
+			goto next_fmt;
+			break;
+		case '#':
+			altfm = 1;
+			*fmt++; fmtLen--;
+ 			goto next_fmt;
+			
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+		case '6':
+		case '7':
+		case '8':
+		case '9':
+			width = 0;
+			while( isdigit(*fmt) && (fmtLen > 0) ){
+				width = (width * 10) + (*fmt - '0');
+				fmt++;  fmtLen--;
+			}
+			goto next_fmt;
+		case '*':
+			/* suck up the next item as an integer */
+			*fmt++;  fmtLen--;
+			objc--;
+			if( objc <= 0 ){
+				goto not_enough_args;
+			}
+			if( Jim_GetWide(interp,objv[0],&wideValue )== JIM_ERR ){
+				Jim_FreeNewObj(interp, resObjPtr );
+				return NULL;
+			}
+			width = wideValue;
+			if( width < 0 ){
+				ljust = 1;
+				width = -width;
+			}
+			objv++;
+			goto next_fmt;
+			break;
+		}
+		
+		
+		if (*fmt != '%') {
             if (objc == 0) {
+			not_enough_args:
                 Jim_FreeNewObj(interp, resObjPtr);
                 Jim_SetResultString(interp,
-                        "not enough arguments for all format specifiers", -1);
+									"not enough arguments for all format specifiers", -1);
                 return NULL;
             } else {
                 objc--;
             }
         }
+		
+		/*
+		 * Create the formatter
+		 * cause we cheat and use sprintf()
+		 */
+		cp = fmt_str;
+		*cp++ = '%';
+		if( altfm ){
+			*cp++ = '#';
+		}
+		if( forceplus ){
+			*cp++ = '+';
+		} else if( spad ){
+			/* PLUS overrides */
+			*cp++ = ' ';
+		}
+		if( ljust ){
+			*cp++ = '-';
+		}
+		if( zpad  ){
+			*cp++ = '0';
+		}
+		if( width > 0 ){
+			sprintf( cp, "%d", width );
+			/* skip ahead */
+			cp = strchr(cp,0);
+		}
+		*cp = 0;
+
+		/* here we do the work */
+		/* actually - we make sprintf() do it for us */
         switch(*fmt) {
         case 's':
-            Jim_AppendObj(interp, resObjPtr, objv[0]);
-            objv++;
+			*cp++ = 's';
+			*cp   = 0;
+			/* BUG: we do not handled embeded NULLs */
+			snprintf( sprintf_buf, JIM_MAX_FMT, fmt_str, Jim_GetString( objv[0], NULL ));
             break;
         case 'c':
+			*cp++ = 'c';
+			*cp   = 0;
             if (Jim_GetWide(interp, objv[0], &wideValue) == JIM_ERR) {
                 Jim_FreeNewObj(interp, resObjPtr);
                 return NULL;
             }
             c = (char) wideValue;
-            Jim_AppendString(interp, resObjPtr, &c, 1);
+			snprintf( sprintf_buf, JIM_MAX_FMT, fmt_str, c );
             break;
+		case 'f':
+		case 'F':
+		case 'g':
+		case 'G':
+		case 'e':
+		case 'E':
+			*cp++ = *fmt;
+			*cp   = 0;
+			if( Jim_GetDouble( interp, objv[0], &doubleValue ) == JIM_ERR ){
+				Jim_FreeNewObj( interp, resObjPtr );
+				return NULL;
+			}
+			snprintf( sprintf_buf, JIM_MAX_FMT, fmt_str, doubleValue );
+			break;
+        case 'b':
         case 'd':
+		case 'i':
+		case 'u':
+		case 'x':
+		case 'X':
+			/* jim widevaluse are 64bit */
+			if( sizeof(jim_wide) == sizeof(long long) ){
+				*cp++ = 'l'; 
+				*cp++ = 'l';
+			} else {
+				*cp++ = 'l';
+			}
+			*cp++ = *fmt;
+			*cp   = 0;
             if (Jim_GetWide(interp, objv[0], &wideValue) == JIM_ERR) {
                 Jim_FreeNewObj(interp, resObjPtr);
                 return NULL;
             }
-            Jim_AppendObj(interp, resObjPtr, objv[0]);
+			snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, wideValue );
             break;
         case '%':
-            Jim_AppendString(interp, resObjPtr, "%" , 1);
+			sprintf_buf[0] = '%';
+			sprintf_buf[1] = 0;
+			objv--; /* undo the objv++ below */
             break;
         default:
             spec[0] = *fmt; spec[1] = '\0';
@@ -2200,6 +2378,16 @@
                     "bad field specifier \"",  spec, "\"", NULL);
             return NULL;
         }
+		/* force terminate */
+#if 0
+		printf("FMT was: %s\n", fmt_str );
+		printf("RES was: |%s|\n", sprintf_buf );
+#endif
+		
+		sprintf_buf[ JIM_MAX_FMT - 1] = 0;
+		Jim_AppendString( interp, resObjPtr, sprintf_buf, strlen(sprintf_buf) );
+		/* next obj */
+		objv++;
         fmt++;
         fmtLen--;
     }
@@ -3910,7 +4098,7 @@
                 Jim_AddHashEntry(&marks,
                     &objPtr->internalRep.refValue.id, NULL);
 #ifdef JIM_DEBUG_GC
-                fprintf(interp->stdout_,
+                Jim_fprintf(interp,interp->cookie_stdout,
                     "MARK (reference): %d refcount: %d" JIM_NL, 
                     (int) objPtr->internalRep.refValue.id,
                     objPtr->refCount);
@@ -3949,7 +4137,7 @@
                  * was found. Mark it. */
                 Jim_AddHashEntry(&marks, &id, NULL);
 #ifdef JIM_DEBUG_GC
-                fprintf(interp->stdout_,"MARK: %d" JIM_NL, (int)id);
+                Jim_fprintf(interp,interp->cookie_stdout,"MARK: %d" JIM_NL, (int)id);
 #endif
                 p += JIM_REFERENCE_SPACE;
             }
@@ -3969,7 +4157,7 @@
          * this reference. */
         if (Jim_FindHashEntry(&marks, refId) == NULL) {
 #ifdef JIM_DEBUG_GC
-            fprintf(interp->stdout_,"COLLECTING %d" JIM_NL, (int)*refId);
+            Jim_fprintf(interp,interp->cookie_stdout,"COLLECTING %d" JIM_NL, (int)*refId);
 #endif
             collected++;
             /* Drop the reference, but call the
@@ -4057,9 +4245,14 @@
     i->freeFramesList = NULL;
     i->prngState = NULL;
     i->evalRetcodeLevel = -1;
-    i->stdin_ = stdin;
-    i->stdout_ = stdout;
-    i->stderr_ = stderr;
+    i->cookie_stdin = stdin;
+    i->cookie_stdout = stdout;
+    i->cookie_stderr = stderr;
+	i->cb_fwrite   = ((size_t (*)( const void *, size_t, size_t, void *))(fwrite));
+	i->cb_fread    = ((size_t (*)(       void *, size_t, size_t, void *))(fread));
+	i->cb_vfprintf = ((int    (*)( void *, const char *fmt, va_list ))(vfprintf));
+	i->cb_fflush   = ((int    (*)( void *))(fflush));
+	i->cb_fgets    = ((char * (*)( char *, int, void *))(fgets));
 
     /* Note that we can create objects only after the
      * interpreter liveList and freeList pointers are
@@ -4128,23 +4321,23 @@
     if (i->liveList != NULL) {
         Jim_Obj *objPtr = i->liveList;
     
-        fprintf(i->stdout_,JIM_NL "-------------------------------------" JIM_NL);
-        fprintf(i->stdout_,"Objects still in the free list:" JIM_NL);
+        Jim_fprintf( i, i->cookie_stdout,JIM_NL "-------------------------------------" JIM_NL);
+        Jim_fprintf( i, i->cookie_stdout,"Objects still in the free list:" JIM_NL);
         while(objPtr) {
             const char *type = objPtr->typePtr ?
                 objPtr->typePtr->name : "";
-            fprintf(i->stdout_,"%p \"%-10s\": '%.20s' (refCount: %d)" JIM_NL,
+            Jim_fprintf( i, i->cookie_stdout,"%p \"%-10s\": '%.20s' (refCount: %d)" JIM_NL,
                     objPtr, type,
                     objPtr->bytes ? objPtr->bytes
                     : "(null)", objPtr->refCount);
             if (objPtr->typePtr == &sourceObjType) {
-                fprintf(i->stdout_, "FILE %s LINE %d" JIM_NL,
+                Jim_fprintf( i, i->cookie_stdout, "FILE %s LINE %d" JIM_NL,
                 objPtr->internalRep.sourceValue.fileName,
                 objPtr->internalRep.sourceValue.lineNumber);
             }
             objPtr = objPtr->nextObjPtr;
         }
-        fprintf(stdout, "-------------------------------------" JIM_NL JIM_NL);
+        Jim_fprintf( i, i->cookie_stdout, "-------------------------------------" JIM_NL JIM_NL);
         Jim_Panic(i,"Live list non empty freeing the interpreter! Leak?");
     }
     /* Free all the freed objects. */
@@ -4330,22 +4523,22 @@
     return interp->exitCode;
 }
 
-FILE *Jim_SetStdin(Jim_Interp *interp, FILE *fp)
+void *Jim_SetStdin(Jim_Interp *interp, void *fp)
 {
-    if (fp != NULL) interp->stdin_ = fp;
-    return interp->stdin_;
+    if (fp != NULL) interp->cookie_stdin = fp;
+    return interp->cookie_stdin;
 }
 
-FILE *Jim_SetStdout(Jim_Interp *interp, FILE *fp)
+void *Jim_SetStdout(Jim_Interp *interp, void *fp)
 {
-    if (fp != NULL) interp->stdout_ = fp;
-    return interp->stdout_;
+    if (fp != NULL) interp->cookie_stdout = fp;
+    return interp->cookie_stdout;
 }
 
-FILE *Jim_SetStderr(Jim_Interp *interp, FILE *fp)
+void *Jim_SetStderr(Jim_Interp *interp, void  *fp)
 {
-    if (fp != NULL) interp->stderr_ = fp;
-    return interp->stderr_;
+    if (fp != NULL) interp->cookie_stderr = fp;
+    return interp->cookie_stderr;
 }
 
 /* -----------------------------------------------------------------------------
@@ -8478,7 +8671,7 @@
         Jim_IncrRefCount(objv[1]);
         if (Jim_EvalObjVector(interp, 2, objv) != JIM_OK) {
             /* Report the error to stderr. */
-            fprintf(interp->stderr_, "Background error:" JIM_NL);
+            Jim_fprintf( interp, interp->cookie_stderr, "Background error:" JIM_NL);
             Jim_PrintErrorMessage(interp);
         }
         Jim_DecrRefCount(interp, objv[0]);
@@ -8509,10 +8702,12 @@
             maxlen = totread+buflen+1;
             prg = Jim_Realloc(prg, maxlen);
         }
+		/* do not use Jim_fread() - this is really a file */
         if ((nread = fread(prg+totread, 1, buflen, fp)) == 0) break;
         totread += nread;
     }
     prg[totread] = '\0';
+	/* do not use Jim_fclose() - this is really a file */
     fclose(fp);
 
     scriptObjPtr = Jim_NewStringObjNoAlloc(interp, prg, totread);
@@ -9011,8 +9206,8 @@
         }
     }
     str = Jim_GetString(argv[1], &len);
-    fwrite(str, 1, len, interp->stdout_);
-    if (!nonewline) fprintf(interp->stdout_, JIM_NL);
+    Jim_fwrite(interp, str, 1, len, interp->cookie_stdout);
+    if (!nonewline) Jim_fprintf( interp, interp->cookie_stdout, JIM_NL);
     return JIM_OK;
 }
 
@@ -11744,9 +11939,9 @@
 {
     int len, i;
 
-    fprintf(interp->stderr_, "Runtime error, file \"%s\", line %d:" JIM_NL,
-            interp->errorFileName, interp->errorLine);
-    fprintf(interp->stderr_, "    %s" JIM_NL,
+    Jim_fprintf(interp, interp->cookie_stderr, "Runtime error, file \"%s\", line %d:" JIM_NL,
+				interp->errorFileName, interp->errorLine);
+    Jim_fprintf(interp,interp->cookie_stderr, "    %s" JIM_NL,
             Jim_GetString(interp->result, NULL));
     Jim_ListLength(interp, interp->stackTrace, &len);
     for (i = 0; i < len; i+= 3) {
@@ -11761,7 +11956,7 @@
         Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr,
                 JIM_NONE);
         line = Jim_GetString(objPtr, NULL);
-        fprintf(interp->stderr_,
+		Jim_fprintf( interp, interp->cookie_stderr,
                 "In procedure '%s' called at file \"%s\", line %s" JIM_NL,
                 proc, file, line);
     }
@@ -11772,7 +11967,7 @@
     int retcode = JIM_OK;
     Jim_Obj *scriptObjPtr;
 
-    fprintf(interp->stdout_, "Welcome to Jim version %d.%d, "
+    Jim_fprintf(interp,interp->cookie_stdout, "Welcome to Jim version %d.%d, "
            "Copyright (c) 2005-8 Salvatore Sanfilippo" JIM_NL,
            JIM_VERSION / 100, JIM_VERSION % 100);
      Jim_SetVariableStrWithStr(interp, "jim_interactive", "1");
@@ -11786,12 +11981,12 @@
 
         if (retcode != 0) {
             if (retcode >= 2 && retcode <= 6)
-                fprintf(interp->stdout_, "[%s] . ", retcodestr[retcode]);
+                Jim_fprintf(interp,interp->cookie_stdout, "[%s] . ", retcodestr[retcode]);
             else
-                fprintf(interp->stdout_, "[%d] . ", retcode);
+                Jim_fprintf(interp,interp->cookie_stdout, "[%d] . ", retcode);
         } else
-            fprintf(interp->stdout_, ". ");
-        fflush(interp->stdout_);
+            Jim_fprintf( interp, interp->cookie_stdout, ". ");
+        Jim_fflush( interp, interp->cookie_stdout);
         scriptObjPtr = Jim_NewStringObj(interp, "", 0);
         Jim_IncrRefCount(scriptObjPtr);
         while(1) {
@@ -11799,7 +11994,7 @@
             char state;
             int len;
 
-            if (fgets(buf, 1024, interp->stdin_) == NULL) {
+            if ( Jim_fgets(interp, buf, 1024, interp->cookie_stdin) == NULL) {
                 Jim_DecrRefCount(interp, scriptObjPtr);
                 goto out;
             }
@@ -11807,8 +12002,8 @@
             str = Jim_GetString(scriptObjPtr, &len);
             if (Jim_ScriptIsComplete(str, len, &state))
                 break;
-            fprintf(interp->stdout_, "%c> ", state);
-            fflush(stdout);
+            Jim_fprintf( interp, interp->cookie_stdout, "%c> ", state);
+            Jim_fflush( interp, interp->cookie_stdout);
         }
         retcode = Jim_EvalObj(interp, scriptObjPtr);
         Jim_DecrRefCount(interp, scriptObjPtr);
@@ -11819,11 +12014,91 @@
             exit(Jim_GetExitCode(interp));
         } else {
             if (reslen) {
-                fwrite(result, 1, reslen, interp->stdout_);
-                fprintf(interp->stdout_, JIM_NL);
+				Jim_fwrite( interp, result, 1, reslen, interp->cookie_stdout);
+				Jim_fprintf( interp,interp->cookie_stdout, JIM_NL);
             }
         }
     }
 out:
     return 0;
 }
+
+/* -----------------------------------------------------------------------------
+ * Jim's idea of STDIO..
+ * ---------------------------------------------------------------------------*/
+
+int
+Jim_fprintf( Jim_Interp *interp, void *cookie, const char *fmt, ... )
+{
+	int r;
+
+	va_list ap;
+	va_start(ap,fmt);
+	r = Jim_vfprintf( interp, cookie, fmt,ap );
+	va_end(ap);
+	return r;
+}
+	
+
+int 
+Jim_vfprintf( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap )
+{
+	if( (interp == NULL) || (interp->cb_vfprintf == NULL) ){
+		errno = ENOTSUP;
+		return -1;
+	}
+	return (*(interp->cb_vfprintf))( cookie, fmt, ap );
+}
+
+size_t
+Jim_fwrite( Jim_Interp *interp, const void *ptr, size_t size, size_t n, void *cookie )
+{
+	if( (interp == NULL) || (interp->cb_fwrite == NULL) ){
+		errno = ENOTSUP;
+		return 0;
+	}
+	return (*(interp->cb_fwrite))( ptr, size, n, cookie);
+}
+
+size_t
+Jim_fread( Jim_Interp *interp, void *ptr, size_t size, size_t n, void *cookie )
+{
+	if( (interp == NULL) || (interp->cb_fread == NULL) ){
+		errno = ENOTSUP;
+		return 0;
+	}
+	return (*(interp->cb_fread))( ptr, size, n, cookie);
+}
+
+int
+Jim_fflush( Jim_Interp *interp, void *cookie )
+{
+	if( (interp == NULL) || (interp->cb_fflush == NULL) ){
+		/* pretend all is well */
+		return 0;
+	}
+	return (*(interp->cb_fflush))( cookie );
+}
+
+char *  
+Jim_fgets( Jim_Interp *interp, char *s, int size, void *cookie )
+{
+	if( (interp == NULL) || (interp->cb_fgets == NULL) ){
+		errno = ENOTSUP;
+		return NULL;
+	}
+	return (*(interp->cb_fgets))( s, size, cookie );
+}
+
+	
+
+
+
+
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/jim.h
===================================================================
--- src/jim.h	(revision 753)
+++ src/jim.h	(working copy)
@@ -497,9 +497,14 @@
     struct Jim_HashTable assocData; /* per-interp storage for use by packages */
     Jim_PrngState *prngState; /* per interpreter Random Number Gen. state. */
     struct Jim_HashTable packages; /* Provided packages hash table */
-    FILE *stdin_; /* input file pointer, 'stdin' by default */
-    FILE *stdout_; /* output file pointer, 'stdout' by default */
-    FILE *stderr_; /* errors file pointer, 'stderr' by default */
+    void *cookie_stdin; /* input file pointer, 'stdin' by default */
+    void *cookie_stdout; /* output file pointer, 'stdout' by default */
+    void *cookie_stderr; /* errors file pointer, 'stderr' by default */
+    size_t (*cb_fwrite  )( const void *ptr, size_t size, size_t n, void *cookie );
+	size_t (*cb_fread   )( void *ptr, size_t size, size_t n, void *cookie );
+	int    (*cb_vfprintf)( void *cookie, const char *fmt, va_list ap );
+	int    (*cb_fflush  )( void *cookie );
+	char  *(*cb_fgets   )( char *s, int size, void *cookie );
 } Jim_Interp;
 
 /* Currently provided as macro that performs the increment.
@@ -662,9 +667,9 @@
 JIM_STATIC Jim_Interp * JIM_API(Jim_CreateInterp) (void);
 JIM_STATIC void JIM_API(Jim_FreeInterp) (Jim_Interp *i);
 JIM_STATIC int JIM_API(Jim_GetExitCode) (Jim_Interp *interp);
-JIM_STATIC FILE * JIM_API(Jim_SetStdin) (Jim_Interp *interp, FILE *fp);
-JIM_STATIC FILE * JIM_API(Jim_SetStdout) (Jim_Interp *interp, FILE *fp);
-JIM_STATIC FILE * JIM_API(Jim_SetStderr) (Jim_Interp *interp, FILE *fp);
+JIM_STATIC void * JIM_API(Jim_SetStdin) (Jim_Interp *interp, void *fp);
+JIM_STATIC void * JIM_API(Jim_SetStdout) (Jim_Interp *interp, void *fp);
+JIM_STATIC void * JIM_API(Jim_SetStderr) (Jim_Interp *interp, void *fp);
 
 /* commands */
 JIM_STATIC void JIM_API(Jim_RegisterCoreCommands) (Jim_Interp *interp);
@@ -815,6 +820,15 @@
 /* Misc */
 JIM_STATIC void JIM_API(Jim_Panic) (Jim_Interp *interp, const char *fmt, ...);
 
+/* Jim's STDIO */
+JIM_STATIC int     JIM_API( Jim_fprintf  )( Jim_Interp *interp, void *cookie, const char *fmt, ... );
+JIM_STATIC int     JIM_API( Jim_vfprintf )( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap );
+JIM_STATIC size_t  JIM_API( Jim_fwrite   )( Jim_Interp *interp, const void *ptr, size_t size, size_t nmeb, void *cookie );
+JIM_STATIC size_t  JIM_API( Jim_fread    )( Jim_Interp *interp, void *ptr, size_t size, size_t nmeb, void *cookie );
+JIM_STATIC int     JIM_API( Jim_fflush   )( Jim_Interp *interp, void *cookie );
+JIM_STATIC char *  JIM_API( Jim_fgets    )( Jim_Interp *interp, char *s, int size, void *cookie );
+
+
 #undef JIM_STATIC
 #undef JIM_API
 
@@ -942,6 +956,13 @@
   JIM_GET_API(StackPop);
   JIM_GET_API(StackPeek);
   JIM_GET_API(FreeStackElements);
+  JIM_GET_API(fprintf  );
+  JIM_GET_API(vfprintf );
+  JIM_GET_API(fwrite   );
+  JIM_GET_API(fread    );
+  JIM_GET_API(fflush   );
+  JIM_GET_API(fgets    );
+  
 }
 #endif /* defined JIM_EXTENSION || defined JIM_EMBEDDED */
 
@@ -962,3 +983,11 @@
 #endif
 
 #endif /* __JIM__H */
+
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/server/telnet_server.c
===================================================================
--- src/server/telnet_server.c	(revision 753)
+++ src/server/telnet_server.c	(working copy)
@@ -92,7 +92,7 @@
 		telnet_write(connection, line, len);
 		if (line_end)
 		{
-			telnet_write(connection, "\r\n\0", 3);
+			telnet_write(connection, "\r\n", 2);
 			line += len+1;
 		}
 		else
@@ -104,7 +104,7 @@
 	return ERROR_OK;
 }
 
-int telnet_output(struct command_context_s *cmd_ctx, char* line)
+int telnet_output(struct command_context_s *cmd_ctx, const char* line)
 {
 	connection_t *connection = cmd_ctx->output_handler_priv;
 
@@ -181,7 +181,7 @@
 	if (telnet_service->banner)
 	{
 		telnet_write(connection, telnet_service->banner, strlen(telnet_service->banner));
-		telnet_write(connection, "\r\n\0", 3);
+		telnet_write(connection, "\r\n", 2);
 	}
 
 	telnet_prompt(connection);
@@ -658,3 +658,11 @@
 {
 	return ERROR_COMMAND_CLOSE_CONNECTION;
 }
+
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/server/gdb_server.c
===================================================================
--- src/server/gdb_server.c	(revision 753)
+++ src/server/gdb_server.c	(working copy)
@@ -568,7 +568,7 @@
 	return ERROR_OK;
 }
 
-int gdb_output(struct command_context_s *context, char* line)
+int gdb_output(struct command_context_s *context, const char* line)
 {
 	/* this will be dumped to the log and also sent as an O packet if possible */
 	LOG_USER_N("%s", line);
@@ -577,25 +577,11 @@
 
 int gdb_program_handler(struct target_s *target, enum target_event event, void *priv)
 {
-	FILE *script;
 	struct command_context_s *cmd_ctx = priv;
 
-	if (target->gdb_program_script)
-	{
-		script = open_file_from_path(target->gdb_program_script, "r");
-		if (!script)
-		{
-			LOG_ERROR("couldn't open script file %s", target->gdb_program_script);
-				return ERROR_OK;
-		}
+	target_invoke_script(cmd_ctx, target, "gdb_program");
+	jtag_execute_queue();
 
-		LOG_INFO("executing gdb_program script '%s'", target->gdb_program_script);
-		command_run_file(cmd_ctx, script, COMMAND_EXEC);
-		fclose(script);
-
-		jtag_execute_queue();
-	}
-
 	return ERROR_OK;
 }
 
Index: src/target/target.c
===================================================================
--- src/target/target.c	(revision 754)
+++ src/target/target.c	(working copy)
@@ -215,23 +215,6 @@
 	return target;
 }
 
-static void execute_script(struct command_context_s *cmd_ctx, char *reset_script)
-{
-	if (reset_script==NULL)
-		return;
-	FILE *script;
-	script = open_file_from_path(reset_script, "r");
-	if (!script)
-	{
-		LOG_ERROR("couldn't open script file %s", reset_script);
-		return;
-	}
-	
-	LOG_INFO("executing script '%s'", reset_script);
-	command_run_file(cmd_ctx, script, COMMAND_EXEC);
-	fclose(script);
-}
-
 /* Process target initialization, when target entered debug out of reset
  * the handler is unregistered at the end of this function, so it's only called once
  */
@@ -243,7 +226,7 @@
 	{
 		target_unregister_event_callback(target_init_handler, priv);
 
-		execute_script(cmd_ctx, target->reset_script);
+		target_invoke_script(cmd_ctx, target, "reset");
 
 		jtag_execute_queue();
 	}
@@ -305,7 +288,7 @@
 	target = targets;
 	while (target)
 	{
-		execute_script(cmd_ctx, target->pre_reset_script);
+		target_invoke_script(cmd_ctx, target, "pre_reset");
 		target = target->next;
 	}
 	
@@ -950,7 +933,8 @@
 {
 	register_command(cmd_ctx, NULL, "target", handle_target_command, COMMAND_CONFIG, "target <cpu> [reset_init default - DEPRECATED] <chainpos> <endianness> <variant> [cpu type specifc args]");
 	register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, NULL);
-	register_command(cmd_ctx, NULL, "target_script", handle_target_script_command, COMMAND_CONFIG, NULL);
+	register_command(cmd_ctx, NULL, "target_script", handle_target_script_command, COMMAND_CONFIG, 
+	"target_script <target#> <event=reset/pre_reset/post_halt/pre_resume/gdb_program_config> <script_file>");
 	register_command(cmd_ctx, NULL, "run_and_halt_time", handle_run_and_halt_time_command, COMMAND_CONFIG, "<target> <run time ms>");
 	register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "working_area <target#> <address> <size> <'backup'|'nobackup'> [virtual address]");
 	register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "virt2phys <virtual address>");
@@ -1437,12 +1421,6 @@
 				}
 				(*last_target_p)->run_and_halt_time = 1000; /* default 1s */
 				
-				(*last_target_p)->reset_script = NULL;
-				(*last_target_p)->pre_reset_script = NULL;
-				(*last_target_p)->post_halt_script = NULL;
-				(*last_target_p)->pre_resume_script = NULL;
-				(*last_target_p)->gdb_program_script = NULL;
-				
 				(*last_target_p)->working_area = 0x0;
 				(*last_target_p)->working_area_size = 0x0;
 				(*last_target_p)->working_areas = NULL;
@@ -1487,7 +1465,14 @@
 	return ERROR_OK;
 }
 
-/* usage: target_script <target#> <event> <script_file> */
+int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, char *name)
+{
+	return command_run_linef(cmd_ctx, " if {[catch {info body target_%s_%d} t]==0} {target_%s_%d}", 
+	name, get_num_by_target(target),
+	name, get_num_by_target(target));
+}
+
+
 int handle_target_script_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
 	target_t *target = NULL;
@@ -1505,41 +1490,14 @@
 		return ERROR_COMMAND_SYNTAX_ERROR;
 	}
 	
-	if ((strcmp(args[1], "reset") == 0)||(strcmp(args[1], "post_reset") == 0))
-	{
-		if (target->reset_script)
-			free(target->reset_script);
-		target->reset_script = strdup(args[2]);
-	}
-	else if (strcmp(args[1], "pre_reset") == 0)
-	{
-		if (target->pre_reset_script)
-			free(target->pre_reset_script);
-		target->pre_reset_script = strdup(args[2]);
-	}
-	else if (strcmp(args[1], "post_halt") == 0)
-	{
-		if (target->post_halt_script)
-			free(target->post_halt_script);
-		target->post_halt_script = strdup(args[2]);
-	}
-	else if (strcmp(args[1], "pre_resume") == 0)
-	{
-		if (target->pre_resume_script)
-			free(target->pre_resume_script);
-		target->pre_resume_script = strdup(args[2]);
-	}
-	else if (strcmp(args[1], "gdb_program_config") == 0)
-	{
-		if (target->gdb_program_script)
-			free(target->gdb_program_script);
-		target->gdb_program_script = strdup(args[2]);
-	}
-	else
-	{
-		LOG_ERROR("unknown event type: '%s", args[1]);
-		return ERROR_COMMAND_SYNTAX_ERROR;
-	}
+	/* Define a tcl procedure which we'll invoke upon some event */
+	command_run_linef(cmd_ctx, 
+	"proc target_%s_%d {} {"
+	"openocd {script %s}" 
+	"}",
+	args[1],
+	get_num_by_target(target),
+	args[2]);
 	
 	return ERROR_OK;
 }
@@ -2021,14 +1979,11 @@
 				output_len = 0;
 			}
 		}
-	} else
-	{
-		LOG_ERROR("Failure examining memory");
 	}
 
 	free(buffer);
 	
-	return ERROR_OK;
+	return retval;
 }
 
 int handle_mw_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
Index: src/target/target.h
===================================================================
--- src/target/target.h	(revision 754)
+++ src/target/target.h	(working copy)
@@ -200,11 +200,6 @@
 	target_type_t *type;				/* target type definition (name, access functions) */
 	enum target_reset_mode reset_mode;	/* what to do after a reset */
 	int run_and_halt_time;				/* how long the target should run after a run_and_halt reset */
-	char *pre_reset_script;					/* script file to initialize the target before a reset */
-	char *reset_script;					/* script file to initialize the target after a reset */
-	char *post_halt_script;				/* script file to execute after the target halted */
-	char *pre_resume_script;			/* script file to execute before the target resumed */
-	char *gdb_program_script;			/* script file to execute before programming vis gdb */
 	u32 working_area;					/* working area (initialized RAM). Evaluated 
 										   upon first allocation from virtual/physical address.
 										  */
@@ -325,6 +320,9 @@
 /* Issues USER() statements with target state information */
 int target_arch_state(struct target_s *target);
 
+int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, char *name);
+
+
 #define ERROR_TARGET_INVALID	(-300)
 #define ERROR_TARGET_INIT_FAILED (-301)
 #define ERROR_TARGET_TIMEOUT	(-302)
Index: src/openocd.c
===================================================================
--- src/openocd.c	(revision 753)
+++ src/openocd.c	(working copy)
@@ -165,6 +165,191 @@
 Jim_Interp *interp;
 command_context_t *active_cmd_ctx;
 
+static int
+new_int_array_element( Jim_Interp * interp, 
+					   const char *varname, 
+					   int idx, 
+					   u32 val )
+{
+	char *namebuf;
+	Jim_Obj *nameObjPtr, *valObjPtr;
+	int result;
+
+	namebuf = alloca( strlen(varname) + 30 );
+	sprintf( namebuf, "%s(%d)", varname, idx );
+
+
+    nameObjPtr = Jim_NewStringObj(interp, namebuf, -1);
+    valObjPtr = Jim_NewIntObj(interp, val );
+    Jim_IncrRefCount(nameObjPtr);
+    Jim_IncrRefCount(valObjPtr);
+    result = Jim_SetVariable(interp, nameObjPtr, valObjPtr);
+    Jim_DecrRefCount(interp, nameObjPtr);
+    Jim_DecrRefCount(interp, valObjPtr);
+	// printf( "%s = 0%08x\n", namebuf, val );
+    return result;
+}
+
+static int
+Jim_Command_mem2array( Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+	target_t *target;
+	long l;
+	u32 width;
+	u32 endian;
+	u32 len;
+	u32 addr;
+	u32 count;
+	u32 v;
+	const char *varname;
+	u8 buffer[4096];
+	int  i,n,e,retval;
+
+
+	/* argv[1] = name of array to receive the data
+	 * argv[2] = desired width
+	 * argv[3] = memory address 
+	 * argv[4] = length in bytes to read
+	 */
+	if( argc != 5 ){
+		Jim_WrongNumArgs( interp, 1, argv, "varname width addr nelems" );
+		return JIM_ERR;
+	}
+	varname = Jim_GetString( argv[1], &len );
+	/* given "foo" get space for worse case "foo(%d)" .. add 20 */
+
+
+	e = Jim_GetLong( interp, argv[2], &l );
+	width = l;
+	if( e != JIM_OK ){
+		return e;
+	}
+	
+	e = Jim_GetLong( interp, argv[3], &l );
+	addr = l;
+	if( e != JIM_OK ){
+		return e;
+	}
+	e = Jim_GetLong( interp, argv[4], &l );
+	len = l;
+	if( e != JIM_OK ){
+		return e;
+	}
+	switch(width){
+	case 8:
+		width = 1;
+		break;
+	case 16:
+		width = 2;
+		break;
+	case 32:
+		width = 4;
+		break;
+	default:
+		Jim_SetResult(interp, 
+					  Jim_NewEmptyStringObj(interp));
+		Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   "Invalid width param, must be 8/16/32", NULL );
+		return JIM_ERR;
+	}
+	if( len == 0 ){
+		Jim_SetResult(interp, 
+					  Jim_NewEmptyStringObj(interp));
+		Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   "mem2array: zero width read?", NULL );
+		return JIM_ERR;
+	}
+	if( (addr + (len * width)) < addr ){
+		Jim_SetResult(interp, 
+					  Jim_NewEmptyStringObj(interp));
+		Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   "mem2array: addr + len - wraps to zero?", NULL );
+		return JIM_ERR;
+	}
+	/* absurd transfer size? */
+	if( len > 65536 ){
+		Jim_SetResult(interp, 
+					  Jim_NewEmptyStringObj(interp));
+		Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   "mem2array: absurd > 64K item request", NULL );
+		return JIM_ERR;
+	}		
+		
+	if( (width == 1) ||
+		((width == 2) && ((addr & 1) == 0)) ||
+		((width == 4) && ((addr & 3) == 0)) ){
+		/* all is well */
+	} else {
+		char buf[100];
+		Jim_SetResult(interp, 
+					  Jim_NewEmptyStringObj(interp));
+		sprintf( buf, 
+				 "mem2array address: 0x%08x is not aligned for %d byte reads",
+				 addr, width );
+				 
+		Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   buf , NULL );
+		return JIM_ERR;
+	}
+
+	target = get_current_target( active_cmd_ctx );
+	
+	/* Transfer loop */
+
+	/* index counter */
+	n = 0;
+	/* assume ok */
+	e = JIM_OK;
+	while( len ){
+
+		/* Slurp... in buffer size chunks */
+		
+		count = len; /* in objects.. */
+		if( count > (sizeof(buffer)/width)){
+			count = (sizeof(buffer)/width);
+		}
+		
+		retval = target->type->read_memory( target, 
+											addr, 
+											width, 
+											count,
+											buffer );
+
+		if( retval != ERROR_OK ){
+			/* BOO !*/
+			LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed",
+					  addr, width, count );
+			Jim_SetResult(interp, 
+						  Jim_NewEmptyStringObj(interp));
+			Jim_AppendStrings( interp, Jim_GetResult(interp),
+						   "mem2array: cannot read memory", NULL );
+			e = JIM_ERR;
+			len = 0;
+		} else {
+			v = 0; /* shut up gcc */
+			for( i = 0 ; i < count ; i++, n++ ){
+				switch(width){
+				case 4:
+					v = target_buffer_get_u32( target, &buffer[i*width] );
+					break;
+				case 2:
+					v = target_buffer_get_u16( target, &buffer[i*width] );
+					break;
+				case 1:
+					v = buffer[i] & 0x0ff;
+					break;
+				}
+				new_int_array_element( interp, varname, n, v );
+			}
+			len -= count;
+		}
+	}
+	Jim_SetResult(interp, 
+				  Jim_NewEmptyStringObj(interp));
+
+	return JIM_OK;
+}
+
 static void tcl_output(void *privData, const char *file, int line, 
 		const char *function, const char *string)
 {		
@@ -323,6 +508,97 @@
 	return JIM_OK;
 }
 
+static size_t
+openocd_jim_fwrite( const void *_ptr, size_t size, size_t n, void *cookie )
+{
+	size_t nbytes;
+	const char *ptr;
+
+	/* make it a char easier to read code */
+	ptr = _ptr;
+
+	nbytes = size * n;
+	if( nbytes == 0 ){
+		return 0;
+	}
+
+	if( !active_cmd_ctx ){
+		/* FIXME: Where should this go? */		
+		return n;
+	}
+
+	
+	/* do we have to chunk it? */
+	if( ptr[ nbytes ] == 0 ){
+		/* no it is a C style string */
+		command_output_text( active_cmd_ctx, ptr );
+		return;
+	}
+	/* GRR we must chunk - not null terminated */
+	while( nbytes ){
+		char chunk[128+1];
+		int x;
+
+		x = nbytes;
+		if( x > 128 ){
+			x = 128;
+		}
+		/* copy it */
+		memcpy( chunk, ptr, x );
+		/* terminate it */
+		chunk[n] = 0;
+		/* output it */
+		command_output_text( active_cmd_ctx, chunk );
+		ptr += x;
+		nbytes -= x;
+	}
+	
+	return n;
+}
+
+static size_t
+openocd_jim_fread(void *ptr, size_t size, size_t n, void *cookie )
+{
+	/* TCL wants to read... tell him no */
+	return 0;
+}
+
+
+static int
+openocd_jim_vfprintf( void *cookie, const char *fmt, va_list ap )
+{
+	char *cp;
+	int n;
+	
+	n = -1;
+	if( active_cmd_ctx ){
+		cp = alloc_vprintf( fmt, ap );
+		if( cp ){
+			command_output_text( active_cmd_ctx, cp );
+			n = strlen(cp);
+			free(cp);
+		}
+	}
+	return n;
+}
+
+static int
+openocd_jim_fflush( void *cookie )
+{
+	/* nothing to flush */
+	return 0;
+}
+
+static char  *
+openocd_jim_fgets( char *s, int size, void *cookie )
+{
+	/* not supported */
+	errno = ENOTSUP;
+	return NULL;
+}
+
+
+
 void initJim(void)
 {
     Jim_InitEmbedded();
@@ -335,6 +611,17 @@
     Jim_CreateCommand(interp, "openocd_throw", Jim_Command_openocd_throw, NULL, NULL);
     Jim_CreateCommand(interp, "find", Jim_Command_find, NULL, NULL);
     Jim_CreateCommand(interp, "echo", Jim_Command_echo, NULL, NULL);
+    Jim_CreateCommand(interp, "mem2array", Jim_Command_mem2array, NULL, NULL );
+
+	/* Set Jim's STDIO */
+	interp->cookie_stdin  = NULL;
+	interp->cookie_stdout = NULL;
+	interp->cookie_stderr = NULL;
+	interp->cb_fwrite     = openocd_jim_fwrite;
+	interp->cb_fread      = openocd_jim_fread ;
+	interp->cb_vfprintf   = openocd_jim_vfprintf;
+	interp->cb_fflush     = openocd_jim_fflush;
+	interp->cb_fgets      = openocd_jim_fgets;
 }
 
 int main(int argc, char *argv[])
@@ -422,3 +709,11 @@
 	return EXIT_SUCCESS;
 }
 
+
+/*
+ * Local Variables: **
+ * tab-width: 4 **
+ * c-basic-offset: 4 **
+ * End: **
+ */
+
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 753)
+++ src/Makefile.am	(working copy)
@@ -81,4 +81,20 @@
 
 	
 	
-nobase_dist_pkglib_DATA = tcl/commands.tcl
+nobase_dist_pkglib_DATA = \
+	tcl/commands.tcl  \
+	tcl/bitsbytes.tcl  \
+	tcl/chip/atmel/at91/aic.tcl  \
+	tcl/chip/atmel/at91/at91sam7x128.tcl  \
+	tcl/chip/atmel/at91/at91sam7x256.tcl  \
+	tcl/chip/atmel/at91/pmc.tcl  \
+	tcl/chip/atmel/at91/rtt.tcl  \
+	tcl/chip/atmel/at91/usarts.tcl  \
+	tcl/cpu/arm/arm7tdmi.tcl  \
+	tcl/cpu/arm/arm920.tcl  \
+	tcl/cpu/arm/arm946.tcl  \
+	tcl/cpu/arm/arm966.tcl  \
+	tcl/memory.tcl  \
+	tcl/mmr_helpers.tcl  \
+	tcl/readable.tcl  
+
