-static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
- if (argc != 2)
- return JIM_ERR;
- const char *str = Jim_GetString(argv[1], NULL);
- LOG_USER("%s", str);
- 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;
- Jim_Interp *interp;
-
- /* make it a char easier to read code */
- ptr = _ptr;
- interp = cookie;
- nbytes = size * n;
- if (ptr == NULL || interp == NULL || nbytes == 0) {
- return 0;
- }
-
- /* do we have to chunk it? */
- if (ptr[nbytes] == 0)
- {
- /* no it is a C style string */
- LOG_USER_N("%s", ptr);
- return strlen(ptr);
- }
- /* 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 */
- LOG_USER_N("%s", 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)