mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ad...@apache.org
Subject [06/51] [partial] incubator-mynewt-site git commit: remove untarred files for openocd
Date Thu, 16 Jun 2016 21:57:10 GMT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-pack.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-pack.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-pack.c
deleted file mode 100644
index 61741fc..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-pack.c
+++ /dev/null
@@ -1,489 +0,0 @@
-#include <string.h>
-#include <jim.h>
-
-/* Provides the [pack] and [unpack] commands to pack and unpack
- * a binary string to/from arbitrary width integers and strings.
- *
- * This may be used to implement the [binary] command.
- */
-
-/**
- * Big endian bit test.
- *
- * Considers 'bitvect' as a big endian bit stream and returns
- * bit 'b' as zero or non-zero.
- */
-static int JimTestBitBigEndian(const unsigned char *bitvec, int b)
-{
-    div_t pos = div(b, 8);
-    return bitvec[pos.quot] & (1 << (7 - pos.rem));
-}
-
-/**
- * Little endian bit test.
- *
- * Considers 'bitvect' as a little endian bit stream and returns
- * bit 'b' as zero or non-zero.
- */
-static int JimTestBitLittleEndian(const unsigned char *bitvec, int b)
-{
-    div_t pos = div(b, 8);
-    return bitvec[pos.quot] & (1 << pos.rem);
-}
-
-/**
- * Sign extends the given value, 'n' of width 'width' bits.
- *
- * For example, sign extending 0x80 with a width of 8, produces -128
- */
-static jim_wide JimSignExtend(jim_wide n, int width)
-{
-    if (width == sizeof(jim_wide) * 8) {
-        /* Can't sign extend the maximum size integer */
-        return n;
-    }
-    if (n & ((jim_wide)1 << (width - 1))) {
-        /* Need to extend */
-        n -= ((jim_wide)1 << width);
-    }
-
-    return n;
-}
-
-/**
- * Big endian integer extraction.
- *
- * Considers 'bitvect' as a big endian bit stream.
- * Returns an integer of the given width (in bits)
- * starting at the given position (in bits).
- *
- * The pos/width must represent bits inside bitvec,
- * and the width be no more than the width of jim_wide.
- */
-static jim_wide JimBitIntBigEndian(const unsigned char *bitvec, int pos, int width)
-{
-    jim_wide result = 0;
-    int i;
-
-    /* Aligned, byte extraction */
-    if (pos % 8 == 0 && width % 8 == 0) {
-        for (i = 0; i < width; i += 8) {
-            result = (result << 8) + bitvec[(pos + i) / 8];
-        }
-        return result;
-    }
-
-    /* Unaligned */
-    for (i = 0; i < width; i++) {
-        if (JimTestBitBigEndian(bitvec, pos + width - i - 1)) {
-            result |= ((jim_wide)1 << i);
-        }
-    }
-
-    return result;
-}
-
-/**
- * Little endian integer extraction.
- *
- * Like JimBitIntBigEndian() but considers 'bitvect' as a little endian bit stream.
- */
-static jim_wide JimBitIntLittleEndian(const unsigned char *bitvec, int pos, int width)
-{
-    jim_wide result = 0;
-    int i;
-
-    /* Aligned, byte extraction */
-    if (pos % 8 == 0 && width % 8 == 0) {
-        for (i = 0; i < width; i += 8) {
-            result += (jim_wide)bitvec[(pos + i) / 8] << i;
-        }
-        return result;
-    }
-
-    /* Unaligned */
-    for (i = 0; i < width; i++) {
-        if (JimTestBitLittleEndian(bitvec, pos + i)) {
-            result |= ((jim_wide)1 << i);
-        }
-    }
-
-    return result;
-}
-
-/**
- * Big endian bit set.
- *
- * Considers 'bitvect' as a big endian bit stream and sets
- * bit 'b' to 'bit'
- */
-static void JimSetBitBigEndian(unsigned char *bitvec, int b, int bit)
-{
-    div_t pos = div(b, 8);
-    if (bit) {
-        bitvec[pos.quot] |= (1 << (7 - pos.rem));
-    }
-    else {
-        bitvec[pos.quot] &= ~(1 << (7 - pos.rem));
-    }
-}
-
-/**
- * Little endian bit set.
- *
- * Considers 'bitvect' as a little endian bit stream and sets
- * bit 'b' to 'bit'
- */
-static void JimSetBitLittleEndian(unsigned char *bitvec, int b, int bit)
-{
-    div_t pos = div(b, 8);
-    if (bit) {
-        bitvec[pos.quot] |= (1 << pos.rem);
-    }
-    else {
-        bitvec[pos.quot] &= ~(1 << pos.rem);
-    }
-}
-
-/**
- * Big endian integer packing.
- *
- * Considers 'bitvect' as a big endian bit stream.
- * Packs integer 'value' of the given width (in bits)
- * starting at the given position (in bits).
- *
- * The pos/width must represent bits inside bitvec,
- * and the width be no more than the width of jim_wide.
- */
-static void JimSetBitsIntBigEndian(unsigned char *bitvec, jim_wide value, int pos, int width)
-{
-    int i;
-
-    /* Common fast option */
-    if (pos % 8 == 0 && width == 8) {
-        bitvec[pos / 8] = value;
-        return;
-    }
-
-    for (i = 0; i < width; i++) {
-        int bit = !!(value & ((jim_wide)1 << i));
-        JimSetBitBigEndian(bitvec, pos + width - i - 1, bit);
-    }
-}
-
-/**
- * Little endian version of JimSetBitsIntBigEndian()
- */
-static void JimSetBitsIntLittleEndian(unsigned char *bitvec, jim_wide value, int pos, int width)
-{
-    int i;
-
-    /* Common fast option */
-    if (pos % 8 == 0 && width == 8) {
-        bitvec[pos / 8] = value;
-        return;
-    }
-
-    for (i = 0; i < width; i++) {
-        int bit = !!(value & ((jim_wide)1 << i));
-        JimSetBitLittleEndian(bitvec, pos + i, bit);
-    }
-}
-
-/**
- * Binary conversion of jim_wide integer to float
- *
- * Considers the least significant bits of
- * jim_wide 'value' as a IEEE float.
- *
- * Should work for both little- and big-endian platforms.
- */
-static float JimIntToFloat(jim_wide value)
-{
-    int offs;
-    float val;
-
-    /* Skip offs to get to least significant bytes */
-    offs = Jim_IsBigEndian() ? (sizeof(jim_wide) - sizeof(float)) : 0;
-
-    memcpy(&val, (unsigned char *) &value + offs, sizeof(float));
-    return val;
-}
-
-/**
- * Binary conversion of jim_wide integer to double
- *
- * Double precision version of JimIntToFloat
- */
-static double JimIntToDouble(jim_wide value)
-{
-    int offs;
-    double val;
-
-    /* Skip offs to get to least significant bytes */
-    offs = Jim_IsBigEndian() ? (sizeof(jim_wide) - sizeof(double)) : 0;
-
-    memcpy(&val, (unsigned char *) &value + offs, sizeof(double));
-    return val;
-}
-
-/**
- * Binary conversion of float to jim_wide integer
- *
- * Considers the bits of IEEE float 'value' as integer.
- * The integer is zero-extended to jim_wide.
- *
- * Should work for both little- and big-endian platforms.
- */
-static jim_wide JimFloatToInt(float value)
-{
-    int offs;
-    jim_wide val = 0;
-
-    /* Skip offs to get to least significant bytes */
-    offs = Jim_IsBigEndian() ? (sizeof(jim_wide) - sizeof(float)) : 0;
-
-    memcpy((unsigned char *) &val + offs, &value, sizeof(float));
-    return val;
-}
-
-/**
- * Binary conversion of double to jim_wide integer
- *
- * Double precision version of JimFloatToInt
- */
-static jim_wide JimDoubleToInt(double value)
-{
-    int offs;
-    jim_wide val = 0;
-
-    /* Skip offs to get to least significant bytes */
-    offs = Jim_IsBigEndian() ? (sizeof(jim_wide) - sizeof(double)) : 0;
-
-    memcpy((unsigned char *) &val + offs, &value, sizeof(double));
-    return val;
-}
-
-/**
- * [unpack]
- *
- * Usage: unpack binvalue -intbe|-intle|-uintbe|-uintle|-floatbe|-floatle|-str bitpos bitwidth
- *
- * Unpacks bits from $binvalue at bit position $bitpos and with $bitwidth.
- * Interprets the value according to the type and returns it.
- */
-static int Jim_UnpackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int option;
-    static const char * const options[] = { "-intbe", "-intle", "-uintbe", "-uintle",
-        "-floatbe", "-floatle", "-str", NULL };
-    enum { OPT_INTBE, OPT_INTLE, OPT_UINTBE, OPT_UINTLE, OPT_FLOATBE, OPT_FLOATLE, OPT_STR, };
-    jim_wide pos;
-    jim_wide width;
-
-    if (argc != 5) {
-        Jim_WrongNumArgs(interp, 1, argv,
-                "binvalue -intbe|-intle|-uintbe|-uintle|-floatbe|-floatle|-str bitpos bitwidth");
-        return JIM_ERR;
-    }
-    if (Jim_GetEnum(interp, argv[2], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
-        return JIM_ERR;
-    }
-
-    if (Jim_GetWide(interp, argv[3], &pos) != JIM_OK) {
-        return JIM_ERR;
-    }
-    if (Jim_GetWide(interp, argv[4], &width) != JIM_OK) {
-        return JIM_ERR;
-    }
-
-    if (option == OPT_STR) {
-        int len;
-        const char *str = Jim_GetString(argv[1], &len);
-
-        if (width % 8 || pos % 8) {
-            Jim_SetResultString(interp, "string field is not on a byte boundary", -1);
-            return JIM_ERR;
-        }
-
-        if (pos >= 0 && width > 0 && pos < len * 8) {
-            if (pos + width > len * 8) {
-                width = len * 8 - pos;
-            }
-            Jim_SetResultString(interp, str + pos / 8, width / 8);
-        }
-        return JIM_OK;
-    }
-    else {
-        int len;
-        const unsigned char *str = (const unsigned char *)Jim_GetString(argv[1], &len);
-        jim_wide result = 0;
-
-        if (width > sizeof(jim_wide) * 8) {
-            Jim_SetResultFormatted(interp, "int field is too wide: %#s", argv[4]);
-            return JIM_ERR;
-        }
-
-        if (pos >= 0 && width > 0 && pos < len * 8) {
-            if (pos + width > len * 8) {
-                width = len * 8 - pos;
-            }
-            if (option == OPT_INTBE || option == OPT_UINTBE || option == OPT_FLOATBE) {
-                result = JimBitIntBigEndian(str, pos, width);
-            }
-            else {
-                result = JimBitIntLittleEndian(str, pos, width);
-            }
-            if (option == OPT_INTBE || option == OPT_INTLE) {
-                result = JimSignExtend(result, width);
-            }
-
-        }
-
-        if (option == OPT_FLOATBE || option == OPT_FLOATLE) {
-            double fresult;
-            if (width == 32) {
-                fresult = (double) JimIntToFloat(result);
-            } else if (width == 64) {
-                fresult = JimIntToDouble(result);
-            } else {
-                Jim_SetResultFormatted(interp, "float field has bad bitwidth: %#s", argv[4]);
-                return JIM_ERR;
-            }
-            Jim_SetResult(interp, Jim_NewDoubleObj(interp, fresult));
-        } else {
-            Jim_SetResultInt(interp, result);
-        }
-        return JIM_OK;
-    }
-}
-
-/**
- * [pack]
- *
- * Usage: pack varname value -intbe|-intle|-floatle|-floatbe|-str width ?bitoffset?
- *
- * Packs the binary representation of 'value' into the variable of the given name.
- * The value is packed according to the given type, width and bitoffset.
- * The variable is created if necessary (like [append])
- * The variable is expanded if necessary
- */
-static int Jim_PackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int option;
-    static const char * const options[] = { "-intle", "-intbe", "-floatle", "-floatbe",
-        "-str", NULL };
-    enum { OPT_LE, OPT_BE, OPT_FLOATLE, OPT_FLOATBE, OPT_STR };
-    jim_wide pos = 0;
-    jim_wide width;
-    jim_wide value;
-    double fvalue;
-    Jim_Obj *stringObjPtr;
-    int len;
-    int freeobj = 0;
-
-    if (argc != 5 && argc != 6) {
-        Jim_WrongNumArgs(interp, 1, argv,
-                "varName value -intle|-intbe|-floatle|-floatbe|-str bitwidth ?bitoffset?");
-        return JIM_ERR;
-    }
-    if (Jim_GetEnum(interp, argv[3], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
-        return JIM_ERR;
-    }
-    if ((option == OPT_LE || option == OPT_BE) &&
-            Jim_GetWide(interp, argv[2], &value) != JIM_OK) {
-        return JIM_ERR;
-    }
-    if ((option == OPT_FLOATLE || option == OPT_FLOATBE) &&
-            Jim_GetDouble(interp, argv[2], &fvalue) != JIM_OK) {
-        return JIM_ERR;
-    }
-    if (Jim_GetWide(interp, argv[4], &width) != JIM_OK) {
-        return JIM_ERR;
-    }
-    if (width <= 0 || (option == OPT_STR && width % 8) || (option != OPT_STR && width > sizeof(jim_wide) * 8) ||
-       ((option == OPT_FLOATLE || option == OPT_FLOATBE) && width != 32 && width != 64)) {
-        Jim_SetResultFormatted(interp, "bad bitwidth: %#s", argv[4]);
-        return JIM_ERR;
-    }
-    if (argc == 6) {
-        if (Jim_GetWide(interp, argv[5], &pos) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (pos < 0 || (option == OPT_STR && pos % 8)) {
-            Jim_SetResultFormatted(interp, "bad bitoffset: %#s", argv[5]);
-            return JIM_ERR;
-        }
-    }
-
-    stringObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
-    if (!stringObjPtr) {
-        /* Create the string if it doesn't exist */
-        stringObjPtr = Jim_NewEmptyStringObj(interp);
-        freeobj = 1;
-    }
-    else if (Jim_IsShared(stringObjPtr)) {
-        freeobj = 1;
-        stringObjPtr = Jim_DuplicateObj(interp, stringObjPtr);
-    }
-
-    len = Jim_Length(stringObjPtr) * 8;
-
-    /* Extend the string as necessary first */
-    while (len < pos + width) {
-        Jim_AppendString(interp, stringObjPtr, "", 1);
-        len += 8;
-    }
-
-    Jim_SetResultInt(interp, pos + width);
-
-    /* Now set the bits. Note that the the string *must* have no non-string rep
-     * since we are writing the bytes directly.
-     */
-    Jim_AppendString(interp, stringObjPtr, "", 0);
-
-    /* Convert floating point to integer if necessary */
-    if (option == OPT_FLOATLE || option == OPT_FLOATBE) {
-        /* Note that the following is slightly incompatible with Tcl behaviour.
-         * In Tcl floating overflow gives FLT_MAX (cf. test binary-13.13).
-         * In Jim Tcl it gives Infinity. This behavior may change.
-         */
-        value = (width == 32) ? JimFloatToInt((float)fvalue) : JimDoubleToInt(fvalue);
-    }
-
-    if (option == OPT_BE || option == OPT_FLOATBE) {
-        JimSetBitsIntBigEndian((unsigned char *)stringObjPtr->bytes, value, pos, width);
-    }
-    else if (option == OPT_LE || option == OPT_FLOATLE) {
-        JimSetBitsIntLittleEndian((unsigned char *)stringObjPtr->bytes, value, pos, width);
-    }
-    else {
-        pos /= 8;
-        width /= 8;
-
-        if (width > Jim_Length(argv[2])) {
-            width = Jim_Length(argv[2]);
-        }
-        memcpy(stringObjPtr->bytes + pos, Jim_String(argv[2]), width);
-        /* No padding is needed since the string is already extended */
-    }
-
-    if (Jim_SetVariable(interp, argv[1], stringObjPtr) != JIM_OK) {
-        if (freeobj) {
-            Jim_FreeNewObj(interp, stringObjPtr);
-            return JIM_ERR;
-        }
-    }
-    return JIM_OK;
-}
-
-int Jim_packInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "pack", "1.0", JIM_ERRMSG)) {
-        return JIM_ERR;
-    }
-
-    Jim_CreateCommand(interp, "unpack", Jim_UnpackCmd, NULL, NULL);
-    Jim_CreateCommand(interp, "pack", Jim_PackCmd, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-package.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-package.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-package.c
deleted file mode 100644
index 8b37c0a..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-package.c
+++ /dev/null
@@ -1,253 +0,0 @@
-#include <string.h>
-
-#include "jimautoconf.h"
-#include <jim-subcmd.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#else
-#define R_OK 4
-#endif
-
-/* All packages have a fixed, dummy version */
-static const char *package_version_1 = "1.0";
-
-/* -----------------------------------------------------------------------------
- * Packages handling
- * ---------------------------------------------------------------------------*/
-
-int Jim_PackageProvide(Jim_Interp *interp, const char *name, const char *ver, int flags)
-{
-    /* If the package was already provided returns an error. */
-    Jim_HashEntry *he = Jim_FindHashEntry(&interp->packages, name);
-
-    /* An empty result means the automatic entry. This can be replaced */
-    if (he && *(const char *)he->u.val) {
-        if (flags & JIM_ERRMSG) {
-            Jim_SetResultFormatted(interp, "package \"%s\" was already provided", name);
-        }
-        return JIM_ERR;
-    }
-    Jim_ReplaceHashEntry(&interp->packages, name, (char *)ver);
-    return JIM_OK;
-}
-
-/**
- * Searches along a of paths for the given package.
- *
- * Returns the allocated path to the package file if found,
- * or NULL if not found.
- */
-static char *JimFindPackage(Jim_Interp *interp, Jim_Obj *prefixListObj, const char *pkgName)
-{
-    int i;
-    char *buf = Jim_Alloc(JIM_PATH_LEN);
-    int prefixc = Jim_ListLength(interp, prefixListObj);
-
-    for (i = 0; i < prefixc; i++) {
-        Jim_Obj *prefixObjPtr = Jim_ListGetIndex(interp, prefixListObj, i);
-        const char *prefix = Jim_String(prefixObjPtr);
-
-        /* Loadable modules are tried first */
-#ifdef jim_ext_load
-        snprintf(buf, JIM_PATH_LEN, "%s/%s.so", prefix, pkgName);
-        if (access(buf, R_OK) == 0) {
-            return buf;
-        }
-#endif
-        if (strcmp(prefix, ".") == 0) {
-            snprintf(buf, JIM_PATH_LEN, "%s.tcl", pkgName);
-        }
-        else {
-            snprintf(buf, JIM_PATH_LEN, "%s/%s.tcl", prefix, pkgName);
-        }
-
-        if (access(buf, R_OK) == 0) {
-            return buf;
-        }
-    }
-    Jim_Free(buf);
-    return NULL;
-}
-
-/* Search for a suitable package under every dir specified by JIM_LIBPATH,
- * and load it if possible. If a suitable package was loaded with success
- * JIM_OK is returned, otherwise JIM_ERR is returned. */
-static int JimLoadPackage(Jim_Interp *interp, const char *name, int flags)
-{
-    int retCode = JIM_ERR;
-    Jim_Obj *libPathObjPtr = Jim_GetGlobalVariableStr(interp, JIM_LIBPATH, JIM_NONE);
-    if (libPathObjPtr) {
-        char *path;
-
-        /* Scan every directory for the the first match */
-        path = JimFindPackage(interp, libPathObjPtr, name);
-        if (path) {
-            const char *p;
-
-            /* Note: Even if the file fails to load, we consider the package loaded.
-             *       This prevents issues with recursion.
-             *       Use a dummy version of "" to signify this case.
-             */
-            Jim_PackageProvide(interp, name, "", 0);
-
-            /* Try to load/source it */
-            p = strrchr(path, '.');
-
-            if (p && strcmp(p, ".tcl") == 0) {
-                Jim_IncrRefCount(libPathObjPtr);
-                retCode = Jim_EvalFileGlobal(interp, path);
-                Jim_DecrRefCount(interp, libPathObjPtr);
-            }
-#ifdef jim_ext_load
-            else {
-                retCode = Jim_LoadLibrary(interp, path);
-            }
-#endif
-            if (retCode != JIM_OK) {
-                /* Upon failure, remove the dummy entry */
-                Jim_DeleteHashEntry(&interp->packages, name);
-            }
-            Jim_Free(path);
-        }
-
-        return retCode;
-    }
-    return JIM_ERR;
-}
-
-int Jim_PackageRequire(Jim_Interp *interp, const char *name, int flags)
-{
-    Jim_HashEntry *he;
-
-    /* Start with an empty error string */
-    Jim_SetEmptyResult(interp);
-
-    he = Jim_FindHashEntry(&interp->packages, name);
-    if (he == NULL) {
-        /* Try to load the package. */
-        int retcode = JimLoadPackage(interp, name, flags);
-        if (retcode != JIM_OK) {
-            if (flags & JIM_ERRMSG) {
-                int len = Jim_Length(Jim_GetResult(interp));
-                Jim_SetResultFormatted(interp, "%#s%sCan't load package %s",
-                    Jim_GetResult(interp), len ? "\n" : "", name);
-            }
-            return retcode;
-        }
-
-        /* In case the package did not 'package provide' */
-        Jim_PackageProvide(interp, name, package_version_1, 0);
-
-        /* Now it must exist */
-        he = Jim_FindHashEntry(&interp->packages, name);
-    }
-
-    Jim_SetResultString(interp, he->u.val, -1);
-    return JIM_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * package provide name ?version?
- *
- *      This procedure is invoked to declare that
- *      a particular package is now present in an interpreter.
- *      The package must not already be provided in the interpreter.
- *
- * Results:
- *      Returns JIM_OK and sets results as "1.0" (the given version is ignored)
- *
- *----------------------------------------------------------------------
- */
-static int package_cmd_provide(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    return Jim_PackageProvide(interp, Jim_String(argv[0]), package_version_1, JIM_ERRMSG);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * package require name ?version?
- *
- *      This procedure is load a given package.
- *      Note that the version is ignored.
- *
- * Results:
- *      Returns JIM_OK and sets the package version.
- *
- *----------------------------------------------------------------------
- */
-static int package_cmd_require(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    /* package require failing is important enough to add to the stack */
-    interp->addStackTrace++;
-
-    return Jim_PackageRequire(interp, Jim_String(argv[0]), JIM_ERRMSG);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * package list
- *
- *      Returns a list of known packages
- *
- * Results:
- *      Returns JIM_OK and sets a list of known packages.
- *
- *----------------------------------------------------------------------
- */
-static int package_cmd_list(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    Jim_HashTableIterator *htiter;
-    Jim_HashEntry *he;
-    Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
-
-    htiter = Jim_GetHashTableIterator(&interp->packages);
-    while ((he = Jim_NextHashEntry(htiter)) != NULL) {
-        Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, he->key, -1));
-    }
-    Jim_FreeHashTableIterator(htiter);
-
-    Jim_SetResult(interp, listObjPtr);
-
-    return JIM_OK;
-}
-
-static const jim_subcmd_type package_command_table[] = {
-    {
-        "provide",
-        "name ?version?",
-        package_cmd_provide,
-        1,
-        2,
-        /* Description: Indicates that the current script provides the given package */
-    },
-    {
-        "require",
-        "name ?version?",
-        package_cmd_require,
-        1,
-        2,
-        /* Description: Loads the given package by looking in standard places */
-    },
-    {
-        "list",
-        NULL,
-        package_cmd_list,
-        0,
-        0,
-        /* Description: Lists all known packages */
-    },
-    {
-        NULL
-    }
-};
-
-int Jim_packageInit(Jim_Interp *interp)
-{
-    Jim_CreateCommand(interp, "package", Jim_SubCmdProc, (void *)package_command_table, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-posix.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-posix.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-posix.c
deleted file mode 100644
index af8c0f1..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-posix.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Jim - POSIX extension
- *
- * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * official policies, either expressed or implied, of the Jim Tcl Project.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-
-#include "jimautoconf.h"
-#include <jim.h>
-
-#ifdef HAVE_SYS_SYSINFO_H
-#include <sys/sysinfo.h>
-#endif
-
-static void Jim_PosixSetError(Jim_Interp *interp)
-{
-    Jim_SetResultString(interp, strerror(errno), -1);
-}
-
-#if defined(HAVE_FORK)
-static int Jim_PosixForkCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    pid_t pid;
-
-    JIM_NOTUSED(argv);
-
-    if (argc != 1) {
-        Jim_WrongNumArgs(interp, 1, argv, "");
-        return JIM_ERR;
-    }
-    if ((pid = fork()) == -1) {
-        Jim_PosixSetError(interp);
-        return JIM_ERR;
-    }
-    Jim_SetResultInt(interp, (jim_wide) pid);
-    return JIM_OK;
-}
-#endif
-
-/*
- * os.wait ?-nohang? pid
- *
- * An interface to waitpid(2)
- *
- * Returns a 3 element list.
- *
- * If -nohang is specified, and the process is still alive, returns
- *
- *   {0 none 0}
- *
- * If the process does not exist or has already been waited for, returns:
- *
- *   {-1 error <error-description>}
- *
- * If the process exited normally, returns:
- *
- *   {<pid> exit <exit-status>}
- *
- * If the process terminated on a signal, returns:
- *
- *   {<pid> signal <signal-number>}
- *
- * Otherwise (core dump, stopped, continued, ...), returns:
- *
- *   {<pid> other 0}
- */
-static int Jim_PosixWaitCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int nohang = 0;
-    long pid;
-    int status;
-    Jim_Obj *listObj;
-    const char *type;
-    int value;
-
-    if (argc > 1 && Jim_CompareStringImmediate(interp, argv[1], "-nohang")) {
-        nohang = 1;
-    }
-    if (argc != nohang + 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "?-nohang? pid");
-        return JIM_ERR;
-    }
-    if (Jim_GetLong(interp, argv[nohang + 1], &pid) != JIM_OK) {
-        return JIM_ERR;
-    }
-
-    pid = waitpid(pid, &status, nohang ? WNOHANG : 0);
-    listObj = Jim_NewListObj(interp, NULL, 0);
-    Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, pid));
-    if (pid < 0) {
-        type = "error";
-        value = errno;
-    }
-    else if (pid == 0) {
-        type = "none";
-        value = 0;
-    }
-    else if (WIFEXITED(status)) {
-        type = "exit";
-        value = WEXITSTATUS(status);
-    }
-    else if (WIFSIGNALED(status)) {
-        type = "signal";
-        value = WTERMSIG(status);
-    }
-    else {
-        type = "other";
-        value = 0;
-    }
-
-    Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, type, -1));
-    if (pid < 0) {
-        Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, strerror(value), -1));
-    }
-    else {
-        Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
-    }
-    Jim_SetResult(interp, listObj);
-    return JIM_OK;
-}
-
-static int Jim_PosixGetidsCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    Jim_Obj *objv[8];
-
-    if (argc != 1) {
-        Jim_WrongNumArgs(interp, 1, argv, "");
-        return JIM_ERR;
-    }
-    objv[0] = Jim_NewStringObj(interp, "uid", -1);
-    objv[1] = Jim_NewIntObj(interp, getuid());
-    objv[2] = Jim_NewStringObj(interp, "euid", -1);
-    objv[3] = Jim_NewIntObj(interp, geteuid());
-    objv[4] = Jim_NewStringObj(interp, "gid", -1);
-    objv[5] = Jim_NewIntObj(interp, getgid());
-    objv[6] = Jim_NewStringObj(interp, "egid", -1);
-    objv[7] = Jim_NewIntObj(interp, getegid());
-    Jim_SetResult(interp, Jim_NewListObj(interp, objv, 8));
-    return JIM_OK;
-}
-
-#define JIM_HOST_NAME_MAX 1024
-static int Jim_PosixGethostnameCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    char *buf;
-    int rc = JIM_OK;
-
-    if (argc != 1) {
-        Jim_WrongNumArgs(interp, 1, argv, "");
-        return JIM_ERR;
-    }
-    buf = Jim_Alloc(JIM_HOST_NAME_MAX);
-    if (gethostname(buf, JIM_HOST_NAME_MAX) == -1) {
-        Jim_PosixSetError(interp);
-        Jim_Free(buf);
-        rc = JIM_ERR;
-    }
-    else {
-        Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, buf, -1));
-    }
-    return rc;
-}
-
-static int Jim_PosixUptimeCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-#ifdef HAVE_STRUCT_SYSINFO_UPTIME
-    struct sysinfo info;
-
-    if (argc != 1) {
-        Jim_WrongNumArgs(interp, 1, argv, "");
-        return JIM_ERR;
-    }
-
-    if (sysinfo(&info) == -1) {
-        Jim_PosixSetError(interp);
-        return JIM_ERR;
-    }
-
-    Jim_SetResultInt(interp, info.uptime);
-#else
-    Jim_SetResultInt(interp, (long)time(NULL));
-#endif
-    return JIM_OK;
-}
-
-static int Jim_PosixPidCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    if (argc != 1) {
-        Jim_WrongNumArgs(interp, 1, argv, "");
-        return JIM_ERR;
-    }
-
-    Jim_SetResultInt(interp, getpid());
-    return JIM_OK;
-}
-
-int Jim_posixInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "posix", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-#ifdef HAVE_FORK
-    Jim_CreateCommand(interp, "os.fork", Jim_PosixForkCommand, NULL, NULL);
-#endif
-    Jim_CreateCommand(interp, "os.wait", Jim_PosixWaitCommand, NULL, NULL);
-    Jim_CreateCommand(interp, "os.getids", Jim_PosixGetidsCommand, NULL, NULL);
-    Jim_CreateCommand(interp, "os.gethostname", Jim_PosixGethostnameCommand, NULL, NULL);
-    Jim_CreateCommand(interp, "os.uptime", Jim_PosixUptimeCommand, NULL, NULL);
-    Jim_CreateCommand(interp, "pid", Jim_PosixPidCommand, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readdir.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readdir.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readdir.c
deleted file mode 100644
index d7c0e40..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readdir.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Tcl readdir command.
- *
- * (c) 2008 Steve Bennett <steveb@worware.net.au>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * official policies, either expressed or implied, of the Jim Tcl Project.
- *
- * Based on original work by:
- *-----------------------------------------------------------------------------
- * Copyright 1991-1994 Karl Lehenbauer and Mark Diekhans.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies.  Karl Lehenbauer and
- * Mark Diekhans make no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express or
- * implied warranty.
- *-----------------------------------------------------------------------------
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <jim.h>
-#include <jimautoconf.h>
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-/*
- *-----------------------------------------------------------------------------
- *
- * Jim_ReaddirCmd --
- *     Implements the rename TCL command:
- *         readdir ?-nocomplain? dirPath
- *
- * Results:
- *      Standard TCL result.
- *-----------------------------------------------------------------------------
- */
-int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    const char *dirPath;
-    DIR *dirPtr;
-    struct dirent *entryPtr;
-    int nocomplain = 0;
-
-    if (argc == 3 && Jim_CompareStringImmediate(interp, argv[1], "-nocomplain")) {
-        nocomplain = 1;
-    }
-    if (argc != 2 && !nocomplain) {
-        Jim_WrongNumArgs(interp, 1, argv, "?-nocomplain? dirPath");
-        return JIM_ERR;
-    }
-
-    dirPath = Jim_String(argv[1 + nocomplain]);
-
-    dirPtr = opendir(dirPath);
-    if (dirPtr == NULL) {
-        if (nocomplain) {
-            return JIM_OK;
-        }
-        Jim_SetResultString(interp, strerror(errno), -1);
-        return JIM_ERR;
-    }
-    else {
-        Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
-
-        while ((entryPtr = readdir(dirPtr)) != NULL) {
-            if (entryPtr->d_name[0] == '.') {
-                if (entryPtr->d_name[1] == '\0') {
-                    continue;
-                }
-                if ((entryPtr->d_name[1] == '.') && (entryPtr->d_name[2] == '\0'))
-                    continue;
-            }
-            Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, entryPtr->d_name, -1));
-        }
-        closedir(dirPtr);
-
-        Jim_SetResult(interp, listObj);
-
-        return JIM_OK;
-    }
-}
-
-int Jim_readdirInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "readdir", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-    Jim_CreateCommand(interp, "readdir", Jim_ReaddirCmd, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readline.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readline.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readline.c
deleted file mode 100644
index 39051b0..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-readline.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Jim - Readline bindings for Jim
- *
- * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * official policies, either expressed or implied, of the Jim Tcl Project.
- */
-
-#include <jim.h>
-
-#include <readline/readline.h>
-#include <readline/history.h>
-
-static int JimRlReadlineCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    char *line;
-
-    if (argc != 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "prompt");
-        return JIM_ERR;
-    }
-    line = readline(Jim_String(argv[1]));
-    if (!line) {
-        return JIM_EXIT;
-    }
-    Jim_SetResult(interp, Jim_NewStringObj(interp, line, -1));
-    return JIM_OK;
-}
-
-static int JimRlAddHistoryCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    if (argc != 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "string");
-        return JIM_ERR;
-    }
-    add_history(Jim_String(argv[1]));
-    return JIM_OK;
-}
-
-int Jim_readlineInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "readline", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-    Jim_CreateCommand(interp, "readline.readline", JimRlReadlineCommand, NULL, NULL);
-    Jim_CreateCommand(interp, "readline.addhistory", JimRlAddHistoryCommand, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-regexp.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-regexp.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-regexp.c
deleted file mode 100644
index 8eb457d..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-regexp.c
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * Implements the regexp and regsub commands for Jim
- *
- * (c) 2008 Steve Bennett <steveb@workware.net.au>
- *
- * Uses C library regcomp()/regexec() for the matching.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * official policies, either expressed or implied, of the Jim Tcl Project.
- *
- * Based on code originally from Tcl 6.7:
- *
- * Copyright 1987-1991 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies.  The University of California
- * makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without
- * express or implied warranty.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "jimautoconf.h"
-#if defined(JIM_REGEXP)
-    #include "jimregexp.h"
-#else
-    #include <regex.h>
-#endif
-#include "jim.h"
-
-static void FreeRegexpInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
-{
-    regfree(objPtr->internalRep.regexpValue.compre);
-    Jim_Free(objPtr->internalRep.regexpValue.compre);
-}
-
-static const Jim_ObjType regexpObjType = {
-    "regexp",
-    FreeRegexpInternalRep,
-    NULL,
-    NULL,
-    JIM_TYPE_NONE
-};
-
-static regex_t *SetRegexpFromAny(Jim_Interp *interp, Jim_Obj *objPtr, unsigned flags)
-{
-    regex_t *compre;
-    const char *pattern;
-    int ret;
-
-    /* Check if the object is already an uptodate variable */
-    if (objPtr->typePtr == &regexpObjType &&
-        objPtr->internalRep.regexpValue.compre && objPtr->internalRep.regexpValue.flags == flags) {
-        /* nothing to do */
-        return objPtr->internalRep.regexpValue.compre;
-    }
-
-    /* Not a regexp or the flags do not match */
-
-    /* Get the string representation */
-    pattern = Jim_String(objPtr);
-    compre = Jim_Alloc(sizeof(regex_t));
-
-    if ((ret = regcomp(compre, pattern, REG_EXTENDED | flags)) != 0) {
-        char buf[100];
-
-        regerror(ret, compre, buf, sizeof(buf));
-        Jim_SetResultFormatted(interp, "couldn't compile regular expression pattern: %s", buf);
-        regfree(compre);
-        Jim_Free(compre);
-        return NULL;
-    }
-
-    Jim_FreeIntRep(interp, objPtr);
-
-    objPtr->typePtr = &regexpObjType;
-    objPtr->internalRep.regexpValue.flags = flags;
-    objPtr->internalRep.regexpValue.compre = compre;
-
-    return compre;
-}
-
-int Jim_RegexpCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int opt_indices = 0;
-    int opt_all = 0;
-    int opt_inline = 0;
-    regex_t *regex;
-    int match, i, j;
-    int offset = 0;
-    regmatch_t *pmatch = NULL;
-    int source_len;
-    int result = JIM_OK;
-    const char *pattern;
-    const char *source_str;
-    int num_matches = 0;
-    int num_vars;
-    Jim_Obj *resultListObj = NULL;
-    int regcomp_flags = 0;
-    int eflags = 0;
-    int option;
-    enum {
-        OPT_INDICES,  OPT_NOCASE, OPT_LINE, OPT_ALL, OPT_INLINE, OPT_START, OPT_END
-    };
-    static const char * const options[] = {
-        "-indices", "-nocase", "-line", "-all", "-inline", "-start", "--", NULL
-    };
-
-    if (argc < 3) {
-      wrongNumArgs:
-        Jim_WrongNumArgs(interp, 1, argv,
-            "?-switch ...? exp string ?matchVar? ?subMatchVar ...?");
-        return JIM_ERR;
-    }
-
-    for (i = 1; i < argc; i++) {
-        const char *opt = Jim_String(argv[i]);
-
-        if (*opt != '-') {
-            break;
-        }
-        if (Jim_GetEnum(interp, argv[i], options, &option, "switch", JIM_ERRMSG | JIM_ENUM_ABBREV) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (option == OPT_END) {
-            i++;
-            break;
-        }
-        switch (option) {
-            case OPT_INDICES:
-                opt_indices = 1;
-                break;
-
-            case OPT_NOCASE:
-                regcomp_flags |= REG_ICASE;
-                break;
-
-            case OPT_LINE:
-                regcomp_flags |= REG_NEWLINE;
-                break;
-
-            case OPT_ALL:
-                opt_all = 1;
-                break;
-
-            case OPT_INLINE:
-                opt_inline = 1;
-                break;
-
-            case OPT_START:
-                if (++i == argc) {
-                    goto wrongNumArgs;
-                }
-                if (Jim_GetIndex(interp, argv[i], &offset) != JIM_OK) {
-                    return JIM_ERR;
-                }
-                break;
-        }
-    }
-    if (argc - i < 2) {
-        goto wrongNumArgs;
-    }
-
-    regex = SetRegexpFromAny(interp, argv[i], regcomp_flags);
-    if (!regex) {
-        return JIM_ERR;
-    }
-
-    pattern = Jim_String(argv[i]);
-    source_str = Jim_GetString(argv[i + 1], &source_len);
-
-    num_vars = argc - i - 2;
-
-    if (opt_inline) {
-        if (num_vars) {
-            Jim_SetResultString(interp, "regexp match variables not allowed when using -inline",
-                -1);
-            result = JIM_ERR;
-            goto done;
-        }
-        num_vars = regex->re_nsub + 1;
-    }
-
-    pmatch = Jim_Alloc((num_vars + 1) * sizeof(*pmatch));
-
-    /* If an offset has been specified, adjust for that now.
-     * If it points past the end of the string, point to the terminating null
-     */
-    if (offset) {
-        if (offset < 0) {
-            offset += source_len + 1;
-        }
-        if (offset > source_len) {
-            source_str += source_len;
-        }
-        else if (offset > 0) {
-            source_str += offset;
-        }
-        eflags |= REG_NOTBOL;
-    }
-
-    if (opt_inline) {
-        resultListObj = Jim_NewListObj(interp, NULL, 0);
-    }
-
-  next_match:
-    match = regexec(regex, source_str, num_vars + 1, pmatch, eflags);
-    if (match >= REG_BADPAT) {
-        char buf[100];
-
-        regerror(match, regex, buf, sizeof(buf));
-        Jim_SetResultFormatted(interp, "error while matching pattern: %s", buf);
-        result = JIM_ERR;
-        goto done;
-    }
-
-    if (match == REG_NOMATCH) {
-        goto done;
-    }
-
-    num_matches++;
-
-    if (opt_all && !opt_inline) {
-        /* Just count the number of matches, so skip the substitution h */
-        goto try_next_match;
-    }
-
-    /*
-     * If additional variable names have been specified, return
-     * index information in those variables.
-     */
-
-    j = 0;
-    for (i += 2; opt_inline ? j < num_vars : i < argc; i++, j++) {
-        Jim_Obj *resultObj;
-
-        if (opt_indices) {
-            resultObj = Jim_NewListObj(interp, NULL, 0);
-        }
-        else {
-            resultObj = Jim_NewStringObj(interp, "", 0);
-        }
-
-        if (pmatch[j].rm_so == -1) {
-            if (opt_indices) {
-                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, -1));
-                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, -1));
-            }
-        }
-        else {
-            int len = pmatch[j].rm_eo - pmatch[j].rm_so;
-
-            if (opt_indices) {
-                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp,
-                        offset + pmatch[j].rm_so));
-                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp,
-                        offset + pmatch[j].rm_so + len - 1));
-            }
-            else {
-                Jim_AppendString(interp, resultObj, source_str + pmatch[j].rm_so, len);
-            }
-        }
-
-        if (opt_inline) {
-            Jim_ListAppendElement(interp, resultListObj, resultObj);
-        }
-        else {
-            /* And now set the result variable */
-            result = Jim_SetVariable(interp, argv[i], resultObj);
-
-            if (result != JIM_OK) {
-                Jim_FreeObj(interp, resultObj);
-                break;
-            }
-        }
-    }
-
-  try_next_match:
-    if (opt_all && (pattern[0] != '^' || (regcomp_flags & REG_NEWLINE)) && *source_str) {
-        if (pmatch[0].rm_eo) {
-            offset += pmatch[0].rm_eo;
-            source_str += pmatch[0].rm_eo;
-        }
-        else {
-            source_str++;
-            offset++;
-        }
-        if (*source_str) {
-            eflags = REG_NOTBOL;
-            goto next_match;
-        }
-    }
-
-  done:
-    if (result == JIM_OK) {
-        if (opt_inline) {
-            Jim_SetResult(interp, resultListObj);
-        }
-        else {
-            Jim_SetResultInt(interp, num_matches);
-        }
-    }
-
-    Jim_Free(pmatch);
-    return result;
-}
-
-#define MAX_SUB_MATCHES 50
-
-int Jim_RegsubCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int regcomp_flags = 0;
-    int regexec_flags = 0;
-    int opt_all = 0;
-    int offset = 0;
-    regex_t *regex;
-    const char *p;
-    int result;
-    regmatch_t pmatch[MAX_SUB_MATCHES + 1];
-    int num_matches = 0;
-
-    int i, j, n;
-    Jim_Obj *varname;
-    Jim_Obj *resultObj;
-    const char *source_str;
-    int source_len;
-    const char *replace_str;
-    int replace_len;
-    const char *pattern;
-    int option;
-    enum {
-        OPT_NOCASE, OPT_LINE, OPT_ALL, OPT_START, OPT_END
-    };
-    static const char * const options[] = {
-        "-nocase", "-line", "-all", "-start", "--", NULL
-    };
-
-    if (argc < 4) {
-      wrongNumArgs:
-        Jim_WrongNumArgs(interp, 1, argv,
-            "?-switch ...? exp string subSpec ?varName?");
-        return JIM_ERR;
-    }
-
-    for (i = 1; i < argc; i++) {
-        const char *opt = Jim_String(argv[i]);
-
-        if (*opt != '-') {
-            break;
-        }
-        if (Jim_GetEnum(interp, argv[i], options, &option, "switch", JIM_ERRMSG | JIM_ENUM_ABBREV) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (option == OPT_END) {
-            i++;
-            break;
-        }
-        switch (option) {
-            case OPT_NOCASE:
-                regcomp_flags |= REG_ICASE;
-                break;
-
-            case OPT_LINE:
-                regcomp_flags |= REG_NEWLINE;
-                break;
-
-            case OPT_ALL:
-                opt_all = 1;
-                break;
-
-            case OPT_START:
-                if (++i == argc) {
-                    goto wrongNumArgs;
-                }
-                if (Jim_GetIndex(interp, argv[i], &offset) != JIM_OK) {
-                    return JIM_ERR;
-                }
-                break;
-        }
-    }
-    if (argc - i != 3 && argc - i != 4) {
-        goto wrongNumArgs;
-    }
-
-    regex = SetRegexpFromAny(interp, argv[i], regcomp_flags);
-    if (!regex) {
-        return JIM_ERR;
-    }
-    pattern = Jim_String(argv[i]);
-
-    source_str = Jim_GetString(argv[i + 1], &source_len);
-    replace_str = Jim_GetString(argv[i + 2], &replace_len);
-    varname = argv[i + 3];
-
-    /* Create the result string */
-    resultObj = Jim_NewStringObj(interp, "", 0);
-
-    /* If an offset has been specified, adjust for that now.
-     * If it points past the end of the string, point to the terminating null
-     */
-    if (offset) {
-        if (offset < 0) {
-            offset += source_len + 1;
-        }
-        if (offset > source_len) {
-            offset = source_len;
-        }
-        else if (offset < 0) {
-            offset = 0;
-        }
-    }
-
-    /* Copy the part before -start */
-    Jim_AppendString(interp, resultObj, source_str, offset);
-
-    /*
-     * The following loop is to handle multiple matches within the
-     * same source string;  each iteration handles one match and its
-     * corresponding substitution.  If "-all" hasn't been specified
-     * then the loop body only gets executed once.
-     */
-
-    n = source_len - offset;
-    p = source_str + offset;
-    do {
-        int match = regexec(regex, p, MAX_SUB_MATCHES, pmatch, regexec_flags);
-
-        if (match >= REG_BADPAT) {
-            char buf[100];
-
-            regerror(match, regex, buf, sizeof(buf));
-            Jim_SetResultFormatted(interp, "error while matching pattern: %s", buf);
-            return JIM_ERR;
-        }
-        if (match == REG_NOMATCH) {
-            break;
-        }
-
-        num_matches++;
-
-        /*
-         * Copy the portion of the source string before the match to the
-         * result variable.
-         */
-        Jim_AppendString(interp, resultObj, p, pmatch[0].rm_so);
-
-        /*
-         * Append the subSpec (replace_str) argument to the variable, making appropriate
-         * substitutions.  This code is a bit hairy because of the backslash
-         * conventions and because the code saves up ranges of characters in
-         * subSpec to reduce the number of calls to Jim_SetVar.
-         */
-
-        for (j = 0; j < replace_len; j++) {
-            int idx;
-            int c = replace_str[j];
-
-            if (c == '&') {
-                idx = 0;
-            }
-            else if (c == '\\' && j < replace_len) {
-                c = replace_str[++j];
-                if ((c >= '0') && (c <= '9')) {
-                    idx = c - '0';
-                }
-                else if ((c == '\\') || (c == '&')) {
-                    Jim_AppendString(interp, resultObj, replace_str + j, 1);
-                    continue;
-                }
-                else {
-                    /* If the replacement is a trailing backslash, just replace with a backslash, otherwise
-                     * with the literal backslash and the following character
-                     */
-                    Jim_AppendString(interp, resultObj, replace_str + j - 1, (j == replace_len) ? 1 : 2);
-                    continue;
-                }
-            }
-            else {
-                Jim_AppendString(interp, resultObj, replace_str + j, 1);
-                continue;
-            }
-            if ((idx < MAX_SUB_MATCHES) && pmatch[idx].rm_so != -1 && pmatch[idx].rm_eo != -1) {
-                Jim_AppendString(interp, resultObj, p + pmatch[idx].rm_so,
-                    pmatch[idx].rm_eo - pmatch[idx].rm_so);
-            }
-        }
-
-        p += pmatch[0].rm_eo;
-        n -= pmatch[0].rm_eo;
-
-        /* If -all is not specified, or there is no source left, we are done */
-        if (!opt_all || n == 0) {
-            break;
-        }
-
-        /* An anchored pattern without -line must be done */
-        if ((regcomp_flags & REG_NEWLINE) == 0 && pattern[0] == '^') {
-            break;
-        }
-
-        /* If the pattern is empty, need to step forwards */
-        if (pattern[0] == '\0' && n) {
-            /* Need to copy the char we are moving over */
-            Jim_AppendString(interp, resultObj, p, 1);
-            p++;
-            n--;
-        }
-
-        regexec_flags |= REG_NOTBOL;
-    } while (n);
-
-    /*
-     * Copy the portion of the string after the last match to the
-     * result variable.
-     */
-    Jim_AppendString(interp, resultObj, p, -1);
-
-    /* And now set or return the result variable */
-    if (argc - i == 4) {
-        result = Jim_SetVariable(interp, varname, resultObj);
-
-        if (result == JIM_OK) {
-            Jim_SetResultInt(interp, num_matches);
-        }
-        else {
-            Jim_FreeObj(interp, resultObj);
-        }
-    }
-    else {
-        Jim_SetResult(interp, resultObj);
-        result = JIM_OK;
-    }
-
-    return result;
-}
-
-int Jim_regexpInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "regexp", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-    Jim_CreateCommand(interp, "regexp", Jim_RegexpCmd, NULL, NULL);
-    Jim_CreateCommand(interp, "regsub", Jim_RegsubCmd, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-sdl.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-sdl.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-sdl.c
deleted file mode 100644
index 27e49c4..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-sdl.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Jim - SDL extension
- *
- * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials
- *    provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * official policies, either expressed or implied, of the Jim Tcl Project.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <SDL/SDL.h>
-#include <SDL/SDL_gfxPrimitives.h>
-
-#include <jim.h>
-
-#define AIO_CMD_LEN 128
-
-typedef struct JimSdlSurface
-{
-    SDL_Surface *screen;
-} JimSdlSurface;
-
-static void JimSdlSetError(Jim_Interp *interp)
-{
-    Jim_SetResultString(interp, SDL_GetError(), -1);
-}
-
-static void JimSdlDelProc(Jim_Interp *interp, void *privData)
-{
-    JimSdlSurface *jss = privData;
-
-    JIM_NOTUSED(interp);
-
-    SDL_FreeSurface(jss->screen);
-    Jim_Free(jss);
-}
-
-/* Calls to commands created via [sdl.surface] are implemented by this
- * C command. */
-static int JimSdlHandlerCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    JimSdlSurface *jss = Jim_CmdPrivData(interp);
-    int option;
-    static const char * const options[] = {
-        "free", "flip", "pixel", "rectangle", "box", "line", "aaline",
-        "circle", "aacircle", "fcircle", NULL
-    };
-    enum
-    { OPT_FREE, OPT_FLIP, OPT_PIXEL, OPT_RECTANGLE, OPT_BOX, OPT_LINE,
-        OPT_AALINE, OPT_CIRCLE, OPT_AACIRCLE, OPT_FCIRCLE
-    };
-
-    if (argc < 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "method ?args ...?");
-        return JIM_ERR;
-    }
-    if (Jim_GetEnum(interp, argv[1], options, &option, "SDL surface method", JIM_ERRMSG) != JIM_OK)
-        return JIM_ERR;
-    if (option == OPT_PIXEL) {
-        /* PIXEL */
-        long x, y, red, green, blue, alpha = 255;
-
-        if (argc != 7 && argc != 8) {
-            Jim_WrongNumArgs(interp, 2, argv, "x y red green blue ?alpha?");
-            return JIM_ERR;
-        }
-        if (Jim_GetLong(interp, argv[2], &x) != JIM_OK ||
-            Jim_GetLong(interp, argv[3], &y) != JIM_OK ||
-            Jim_GetLong(interp, argv[4], &red) != JIM_OK ||
-            Jim_GetLong(interp, argv[5], &green) != JIM_OK ||
-            Jim_GetLong(interp, argv[6], &blue) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (argc == 8 && Jim_GetLong(interp, argv[7], &alpha) != JIM_OK)
-            return JIM_ERR;
-        pixelRGBA(jss->screen, x, y, red, green, blue, alpha);
-        return JIM_OK;
-    }
-    else if (option == OPT_RECTANGLE || option == OPT_BOX ||
-        option == OPT_LINE || option == OPT_AALINE) {
-        /* RECTANGLE, BOX, LINE, AALINE */
-        long x1, y1, x2, y2, red, green, blue, alpha = 255;
-
-        if (argc != 9 && argc != 10) {
-            Jim_WrongNumArgs(interp, 2, argv, "x y red green blue ?alpha?");
-            return JIM_ERR;
-        }
-        if (Jim_GetLong(interp, argv[2], &x1) != JIM_OK ||
-            Jim_GetLong(interp, argv[3], &y1) != JIM_OK ||
-            Jim_GetLong(interp, argv[4], &x2) != JIM_OK ||
-            Jim_GetLong(interp, argv[5], &y2) != JIM_OK ||
-            Jim_GetLong(interp, argv[6], &red) != JIM_OK ||
-            Jim_GetLong(interp, argv[7], &green) != JIM_OK ||
-            Jim_GetLong(interp, argv[8], &blue) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (argc == 10 && Jim_GetLong(interp, argv[9], &alpha) != JIM_OK)
-            return JIM_ERR;
-        switch (option) {
-            case OPT_RECTANGLE:
-                rectangleRGBA(jss->screen, x1, y1, x2, y2, red, green, blue, alpha);
-                break;
-            case OPT_BOX:
-                boxRGBA(jss->screen, x1, y1, x2, y2, red, green, blue, alpha);
-                break;
-            case OPT_LINE:
-                lineRGBA(jss->screen, x1, y1, x2, y2, red, green, blue, alpha);
-                break;
-            case OPT_AALINE:
-                aalineRGBA(jss->screen, x1, y1, x2, y2, red, green, blue, alpha);
-                break;
-        }
-        return JIM_OK;
-    }
-    else if (option == OPT_CIRCLE || option == OPT_AACIRCLE || option == OPT_FCIRCLE) {
-        /* CIRCLE, AACIRCLE, FCIRCLE */
-        long x, y, radius, red, green, blue, alpha = 255;
-
-        if (argc != 8 && argc != 9) {
-            Jim_WrongNumArgs(interp, 2, argv, "x y radius red green blue ?alpha?");
-            return JIM_ERR;
-        }
-        if (Jim_GetLong(interp, argv[2], &x) != JIM_OK ||
-            Jim_GetLong(interp, argv[3], &y) != JIM_OK ||
-            Jim_GetLong(interp, argv[4], &radius) != JIM_OK ||
-            Jim_GetLong(interp, argv[5], &red) != JIM_OK ||
-            Jim_GetLong(interp, argv[6], &green) != JIM_OK ||
-            Jim_GetLong(interp, argv[7], &blue) != JIM_OK) {
-            return JIM_ERR;
-        }
-        if (argc == 9 && Jim_GetLong(interp, argv[8], &alpha) != JIM_OK)
-            return JIM_ERR;
-        switch (option) {
-            case OPT_CIRCLE:
-                circleRGBA(jss->screen, x, y, radius, red, green, blue, alpha);
-                break;
-            case OPT_AACIRCLE:
-                aacircleRGBA(jss->screen, x, y, radius, red, green, blue, alpha);
-                break;
-            case OPT_FCIRCLE:
-                filledCircleRGBA(jss->screen, x, y, radius, red, green, blue, alpha);
-                break;
-        }
-        return JIM_OK;
-    }
-    else if (option == OPT_FREE) {
-        /* FREE */
-        if (argc != 2) {
-            Jim_WrongNumArgs(interp, 2, argv, "");
-            return JIM_ERR;
-        }
-        Jim_DeleteCommand(interp, Jim_String(argv[0]));
-        return JIM_OK;
-    }
-    else if (option == OPT_FLIP) {
-        /* FLIP */
-        if (argc != 2) {
-            Jim_WrongNumArgs(interp, 2, argv, "");
-            return JIM_ERR;
-        }
-        SDL_Flip(jss->screen);
-        return JIM_OK;
-    }
-    return JIM_OK;
-}
-
-static int JimSdlSurfaceCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    JimSdlSurface *jss;
-    char buf[AIO_CMD_LEN];
-    Jim_Obj *objPtr;
-    long screenId, xres, yres;
-    SDL_Surface *screen;
-
-    if (argc != 3) {
-        Jim_WrongNumArgs(interp, 1, argv, "xres yres");
-        return JIM_ERR;
-    }
-    if (Jim_GetLong(interp, argv[1], &xres) != JIM_OK ||
-        Jim_GetLong(interp, argv[2], &yres) != JIM_OK)
-        return JIM_ERR;
-
-    /* Try to create the surface */
-    screen = SDL_SetVideoMode(xres, yres, 32, SDL_SWSURFACE | SDL_ANYFORMAT);
-    if (screen == NULL) {
-        JimSdlSetError(interp);
-        return JIM_ERR;
-    }
-    /* Get the next file id */
-    if (Jim_EvalGlobal(interp, "if {[catch {incr sdl.surfaceId}]} {set sdl.surfaceId 0}") != JIM_OK)
-        return JIM_ERR;
-    objPtr = Jim_GetVariableStr(interp, "sdl.surfaceId", JIM_ERRMSG);
-    if (objPtr == NULL)
-        return JIM_ERR;
-    if (Jim_GetLong(interp, objPtr, &screenId) != JIM_OK)
-        return JIM_ERR;
-
-    /* Create the SDL screen command */
-    jss = Jim_Alloc(sizeof(*jss));
-    jss->screen = screen;
-    sprintf(buf, "sdl.surface%ld", screenId);
-    Jim_CreateCommand(interp, buf, JimSdlHandlerCommand, jss, JimSdlDelProc);
-    Jim_SetResult(interp, Jim_MakeGlobalNamespaceName(interp, Jim_NewStringObj(interp, buf, -1)));
-    return JIM_OK;
-}
-
-int Jim_sdlInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "sdl", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        JimSdlSetError(interp);
-        return JIM_ERR;
-    }
-    atexit(SDL_Quit);
-    Jim_CreateCommand(interp, "sdl.screen", JimSdlSurfaceCommand, NULL, NULL);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.c
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.c b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.c
deleted file mode 100644
index b760ede..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * jim-signal.c
- *
- */
-
-#include <signal.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "jimautoconf.h"
-#ifdef HAVE_UNISTD_H
-    #include <unistd.h>
-#endif
-#include <jim-subcmd.h>
-#include <jim-signal.h>
-
-#define MAX_SIGNALS_WIDE (sizeof(jim_wide) * 8)
-#if defined(NSIG)
-    #define MAX_SIGNALS ((NSIG < MAX_SIGNALS_WIDE) ? NSIG : MAX_SIGNALS_WIDE)
-#else
-    #define MAX_SIGNALS MAX_SIGNALS_WIDE
-#endif
-
-static jim_wide *sigloc;
-static jim_wide sigsblocked;
-static struct sigaction *sa_old;
-static struct {
-    int status;
-    const char *name;
-} siginfo[MAX_SIGNALS];
-
-/* Make sure to do this as a wide, not int */
-#define sig_to_bit(SIG) ((jim_wide)1 << (SIG))
-
-static void signal_handler(int sig)
-{
-    /* We just remember which signals occurred. Jim_Eval() will
-     * notice this as soon as it can and throw an error
-     */
-    *sigloc |= sig_to_bit(sig);
-}
-
-static void signal_ignorer(int sig)
-{
-    /* We just remember which signals occurred */
-    sigsblocked |= sig_to_bit(sig);
-}
-
-static void signal_init_names(void)
-{
-#define SET_SIG_NAME(SIG) siginfo[SIG].name = #SIG
-
-    SET_SIG_NAME(SIGABRT);
-    SET_SIG_NAME(SIGALRM);
-    SET_SIG_NAME(SIGBUS);
-    SET_SIG_NAME(SIGCHLD);
-    SET_SIG_NAME(SIGCONT);
-    SET_SIG_NAME(SIGFPE);
-    SET_SIG_NAME(SIGHUP);
-    SET_SIG_NAME(SIGILL);
-    SET_SIG_NAME(SIGINT);
-#ifdef SIGIO
-    SET_SIG_NAME(SIGIO);
-#endif
-    SET_SIG_NAME(SIGKILL);
-    SET_SIG_NAME(SIGPIPE);
-    SET_SIG_NAME(SIGPROF);
-    SET_SIG_NAME(SIGQUIT);
-    SET_SIG_NAME(SIGSEGV);
-    SET_SIG_NAME(SIGSTOP);
-    SET_SIG_NAME(SIGSYS);
-    SET_SIG_NAME(SIGTERM);
-    SET_SIG_NAME(SIGTRAP);
-    SET_SIG_NAME(SIGTSTP);
-    SET_SIG_NAME(SIGTTIN);
-    SET_SIG_NAME(SIGTTOU);
-    SET_SIG_NAME(SIGURG);
-    SET_SIG_NAME(SIGUSR1);
-    SET_SIG_NAME(SIGUSR2);
-    SET_SIG_NAME(SIGVTALRM);
-    SET_SIG_NAME(SIGWINCH);
-    SET_SIG_NAME(SIGXCPU);
-    SET_SIG_NAME(SIGXFSZ);
-#ifdef SIGPWR
-    SET_SIG_NAME(SIGPWR);
-#endif
-#ifdef SIGCLD
-    SET_SIG_NAME(SIGCLD);
-#endif
-#ifdef SIGEMT
-    SET_SIG_NAME(SIGEMT);
-#endif
-#ifdef SIGLOST
-    SET_SIG_NAME(SIGLOST);
-#endif
-#ifdef SIGPOLL
-    SET_SIG_NAME(SIGPOLL);
-#endif
-#ifdef SIGINFO
-    SET_SIG_NAME(SIGINFO);
-#endif
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_SignalId --
- *
- *      Return a textual identifier for a signal number.
- *
- * Results:
- *      This procedure returns a machine-readable textual identifier
- *      that corresponds to sig.  The identifier is the same as the
- *      #define name in signal.h.
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-const char *Jim_SignalId(int sig)
-{
-    if (sig >=0 && sig < MAX_SIGNALS) {
-        if (siginfo[sig].name) {
-            return siginfo[sig].name;
-        }
-    }
-    return "unknown signal";
-}
-
-const char *Jim_SignalName(int sig)
-{
-#ifdef HAVE_SYS_SIGLIST
-    if (sig >= 0 && sig < NSIG) {
-        return sys_siglist[sig];
-    }
-#endif
-    return Jim_SignalId(sig);
-}
-
-/**
- * Given the name of a signal, returns the signal value if found,
- * or returns -1 (and sets an error) if not found.
- * We accept -SIGINT, SIGINT, INT or any lowercase version or a number,
- * either positive or negative.
- */
-static int find_signal_by_name(Jim_Interp *interp, const char *name)
-{
-    int i;
-    const char *pt = name;
-
-    /* Remove optional - and SIG from the front of the name */
-    if (*pt == '-') {
-        pt++;
-    }
-    if (strncasecmp(name, "sig", 3) == 0) {
-        pt += 3;
-    }
-    if (isdigit(UCHAR(pt[0]))) {
-        i = atoi(pt);
-        if (i > 0 && i < MAX_SIGNALS) {
-            return i;
-        }
-    }
-    else {
-        for (i = 1; i < MAX_SIGNALS; i++) {
-            /* Jim_SignalId() returns names such as SIGINT, and
-             * returns "unknown signal" if unknown, so this will work
-             */
-            if (strcasecmp(Jim_SignalId(i) + 3, pt) == 0) {
-                return i;
-            }
-        }
-    }
-    Jim_SetResultFormatted(interp, "unknown signal %s", name);
-
-    return -1;
-}
-
-#define SIGNAL_ACTION_HANDLE 1
-#define SIGNAL_ACTION_IGNORE -1
-#define SIGNAL_ACTION_DEFAULT 0
-
-static int do_signal_cmd(Jim_Interp *interp, int action, int argc, Jim_Obj *const *argv)
-{
-    struct sigaction sa;
-    int i;
-
-    if (argc == 0) {
-        Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0));
-        for (i = 1; i < MAX_SIGNALS; i++) {
-            if (siginfo[i].status == action) {
-                /* Add signal name to the list  */
-                Jim_ListAppendElement(interp, Jim_GetResult(interp),
-                    Jim_NewStringObj(interp, Jim_SignalId(i), -1));
-            }
-        }
-        return JIM_OK;
-    }
-
-    /* Catch all the signals we care about */
-    if (action != SIGNAL_ACTION_DEFAULT) {
-        memset(&sa, 0, sizeof(sa));
-        if (action == SIGNAL_ACTION_HANDLE) {
-            sa.sa_handler = signal_handler;
-        }
-        else {
-            sa.sa_handler = signal_ignorer;
-        }
-    }
-
-    /* Iterate through the provided signals */
-    for (i = 0; i < argc; i++) {
-        int sig = find_signal_by_name(interp, Jim_String(argv[i]));
-
-        if (sig < 0) {
-            return JIM_ERR;
-        }
-        if (action != siginfo[sig].status) {
-            /* Need to change the action for this signal */
-            switch (action) {
-                case SIGNAL_ACTION_HANDLE:
-                case SIGNAL_ACTION_IGNORE:
-                    if (siginfo[sig].status == SIGNAL_ACTION_DEFAULT) {
-                        if (!sa_old) {
-                            /* Allocate the structure the first time through */
-                            sa_old = Jim_Alloc(sizeof(*sa_old) * MAX_SIGNALS);
-                        }
-                        sigaction(sig, &sa, &sa_old[sig]);
-                    }
-                    else {
-                        sigaction(sig, &sa, 0);
-                    }
-                    break;
-
-                case SIGNAL_ACTION_DEFAULT:
-                    /* Restore old handler */
-                    if (sa_old) {
-                        sigaction(sig, &sa_old[sig], 0);
-                    }
-            }
-            siginfo[sig].status = action;
-        }
-    }
-
-    return JIM_OK;
-}
-
-static int signal_cmd_handle(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    return do_signal_cmd(interp, SIGNAL_ACTION_HANDLE, argc, argv);
-}
-
-static int signal_cmd_ignore(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    return do_signal_cmd(interp, SIGNAL_ACTION_IGNORE, argc, argv);
-}
-
-static int signal_cmd_default(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    return do_signal_cmd(interp, SIGNAL_ACTION_DEFAULT, argc, argv);
-}
-
-static int signal_set_sigmask_result(Jim_Interp *interp, jim_wide sigmask)
-{
-    int i;
-    Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
-
-    for (i = 0; i < MAX_SIGNALS; i++) {
-        if (sigmask & sig_to_bit(i)) {
-            Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, Jim_SignalId(i), -1));
-        }
-    }
-    Jim_SetResult(interp, listObj);
-    return JIM_OK;
-}
-
-static int signal_cmd_check(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int clear = 0;
-    jim_wide mask = 0;
-    jim_wide blocked;
-
-    if (argc > 0 && Jim_CompareStringImmediate(interp, argv[0], "-clear")) {
-        clear++;
-    }
-    if (argc > clear) {
-        int i;
-
-        /* Signals specified */
-        for (i = clear; i < argc; i++) {
-            int sig = find_signal_by_name(interp, Jim_String(argv[i]));
-
-            if (sig < 0 || sig >= MAX_SIGNALS) {
-                return -1;
-            }
-            mask |= sig_to_bit(sig);
-        }
-    }
-    else {
-        /* No signals specified, so check/clear all */
-        mask = ~mask;
-    }
-
-    if ((sigsblocked & mask) == 0) {
-        /* No matching signals, so empty result and nothing to do */
-        return JIM_OK;
-    }
-    /* Be careful we don't have a race condition where signals are cleared but not returned */
-    blocked = sigsblocked & mask;
-    if (clear) {
-        sigsblocked &= ~blocked;
-    }
-    /* Set the result */
-    signal_set_sigmask_result(interp, blocked);
-    return JIM_OK;
-}
-
-static int signal_cmd_throw(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int sig = SIGINT;
-
-    if (argc == 1) {
-        if ((sig = find_signal_by_name(interp, Jim_String(argv[0]))) < 0) {
-            return JIM_ERR;
-        }
-    }
-
-    /* If the signal is ignored (blocked) ... */
-    if (siginfo[sig].status == SIGNAL_ACTION_IGNORE) {
-        sigsblocked |= sig_to_bit(sig);
-        return JIM_OK;
-    }
-
-    /* Just set the signal */
-    interp->sigmask |= sig_to_bit(sig);
-
-    /* Set the canonical name of the signal as the result */
-    Jim_SetResultString(interp, Jim_SignalId(sig), -1);
-
-    /* And simply say we caught the signal */
-    return JIM_SIGNAL;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * Jim_SignalCmd --
- *     Implements the TCL signal command:
- *         signal handle|ignore|default|throw ?signals ...?
- *         signal throw signal
- *
- *     Specifies which signals are handled by Tcl code.
- *     If the one of the given signals is caught, it causes a JIM_SIGNAL
- *     exception to be thrown which can be caught by catch.
- *
- *     Use 'signal ignore' to ignore the signal(s)
- *     Use 'signal default' to go back to the default behaviour
- *     Use 'signal throw signal' to raise the given signal
- *
- *     If no arguments are given, returns the list of signals which are being handled
- *
- * Results:
- *      Standard TCL results.
- *
- *-----------------------------------------------------------------------------
- */
-static const jim_subcmd_type signal_command_table[] = {
-    {   "handle",
-        "?signals ...?",
-        signal_cmd_handle,
-        0,
-        -1,
-        /* Description: Lists handled signals, or adds to handled signals */
-    },
-    {   "ignore",
-        "?signals ...?",
-        signal_cmd_ignore,
-        0,
-        -1,
-        /* Description: Lists ignored signals, or adds to ignored signals */
-    },
-    {   "default",
-        "?signals ...?",
-        signal_cmd_default,
-        0,
-        -1,
-        /* Description: Lists defaulted signals, or adds to defaulted signals */
-    },
-    {   "check",
-        "?-clear? ?signals ...?",
-        signal_cmd_check,
-        0,
-        -1,
-        /* Description: Returns ignored signals which have occurred, and optionally clearing them */
-    },
-    {   "throw",
-        "?signal?",
-        signal_cmd_throw,
-        0,
-        1,
-        /* Description: Raises the given signal (default SIGINT) */
-    },
-    { NULL }
-};
-
-static int Jim_AlarmCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int ret;
-
-    if (argc != 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "seconds");
-        return JIM_ERR;
-    }
-    else {
-#ifdef HAVE_UALARM
-        double t;
-
-        ret = Jim_GetDouble(interp, argv[1], &t);
-        if (ret == JIM_OK) {
-            if (t < 1) {
-                ualarm(t * 1e6, 0);
-            }
-            else {
-                alarm(t);
-            }
-        }
-#else
-        long t;
-
-        ret = Jim_GetLong(interp, argv[1], &t);
-        if (ret == JIM_OK) {
-            alarm(t);
-        }
-#endif
-    }
-
-    return ret;
-}
-
-static int Jim_SleepCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int ret;
-
-    if (argc != 2) {
-        Jim_WrongNumArgs(interp, 1, argv, "seconds");
-        return JIM_ERR;
-    }
-    else {
-        double t;
-
-        ret = Jim_GetDouble(interp, argv[1], &t);
-        if (ret == JIM_OK) {
-#ifdef HAVE_USLEEP
-            usleep((int)((t - (int)t) * 1e6));
-#endif
-            sleep(t);
-        }
-    }
-
-    return ret;
-}
-
-static int Jim_KillCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
-    int sig;
-    long pid;
-    Jim_Obj *pidObj;
-    const char *signame;
-
-    if (argc != 2 && argc != 3) {
-        Jim_WrongNumArgs(interp, 1, argv, "?SIG|-0? pid");
-        return JIM_ERR;
-    }
-
-    if (argc == 2) {
-        sig = SIGTERM;
-        pidObj = argv[1];
-    }
-    else {
-        signame = Jim_String(argv[1]);
-        pidObj = argv[2];
-
-        /* Special 'kill -0 pid' to determine if a pid exists */
-        if (strcmp(signame, "-0") == 0 || strcmp(signame, "0") == 0) {
-            sig = 0;
-        }
-        else {
-            sig = find_signal_by_name(interp, signame);
-            if (sig < 0) {
-                return JIM_ERR;
-            }
-        }
-    }
-
-    if (Jim_GetLong(interp, pidObj, &pid) != JIM_OK) {
-        return JIM_ERR;
-    }
-
-    if (kill(pid, sig) == 0) {
-        return JIM_OK;
-    }
-
-    Jim_SetResultString(interp, "kill: Failed to deliver signal", -1);
-    return JIM_ERR;
-}
-
-int Jim_signalInit(Jim_Interp *interp)
-{
-    if (Jim_PackageProvide(interp, "signal", "1.0", JIM_ERRMSG))
-        return JIM_ERR;
-
-    signal_init_names();
-
-    /* Teach the jim core how to set a result from a sigmask */
-    interp->signal_set_result = signal_set_sigmask_result;
-
-    /* Make sure we know where to store the signals which occur */
-    sigloc = &interp->sigmask;
-
-    Jim_CreateCommand(interp, "signal", Jim_SubCmdProc, (void *)signal_command_table, NULL);
-    Jim_CreateCommand(interp, "alarm", Jim_AlarmCmd, 0, 0);
-    Jim_CreateCommand(interp, "kill", Jim_KillCmd, 0, 0);
-
-    /* Sleep is slightly dubious here */
-    Jim_CreateCommand(interp, "sleep", Jim_SleepCmd, 0, 0);
-    return JIM_OK;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/0a2f3c5b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.h
----------------------------------------------------------------------
diff --git a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.h b/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.h
deleted file mode 100644
index 84dcd8b..0000000
--- a/os/tutorials/downloads/openocd-code-89bf96ffe6ac66c80407af8383b9d5adc0dc35f4/jimtcl/jim-signal.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef JIM_SIGNAL_H
-#define JIM_SIGNAL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Returns the canonical name for the given signal,
- * e.g. "SIGTERM", "SIGINT"
- */
-const char *Jim_SignalId(int sig);
-
-/**
- * If available, returns a short description of the given signal.
- * e.g. "Terminated", "Interrupted"
- * 
- * Otherwise returns the same as Jim_SignalId()
- */
-const char *Jim_SignalName(int sig);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif


Mime
View raw message