Invokes 'prefix' as a command with the objv array as arguments.
Note. Does not support embedded nulls in either the pattern or the object.
Apply the printf-like format in fmtObjPtr with the given arguments. Returns a new object with zero reference count if OK, or NULL on error.
Returns the length of the object string in chars, not bytes. These may be different for a utf-8 string.
Very simple printf-like formatting, designed for error messages. The format may contain up to 5 '%s' or '%#s', corresponding to variable arguments. The resulting string is created and set as the result. Each '%s' should correspond to a regular string parameter. Each '%#s' should correspond to a (Jim_Obj *) parameter. Any other printf specifier is not allowed (but %% is allowed for the % character). e.g. Jim_SetResultFormatted(interp, "Bad option \"%#s\" in proc \"%#s\"", optionObjPtr, procNamePtr); Note: We take advantage of the fact that printf has the same behaviour for both %s and %#s Note that any Jim_Obj parameters with zero ref count will be freed as a result of this call.
Set the variable nameObjPtr to value valObjptr.
If nameObjPtr starts with "::", returns it. Otherwise returns a new object with nameObjPtr prefixed with "::". In this case, decrements the ref count of nameObjPtr.
match_type must be one of JIM_DICTMATCH_KEYS or JIM_DICTMATCH_VALUES return_types should be either or both
Must be called with at least one object. Returns the new dictionary, or NULL on error.
Returns an allocated line, or NULL if EOF.
Sets a completion command to be used with Jim_HistoryGetline() If commandObj is NULL, deletes any existing completion command.
Note that Jim_LoadLibrary() requires a path to an existing file. If it is necessary to search JIM_LIBPATH, use Jim_PackageRequire() instead.
prints a nice 'unknown' parameter error message to the 'result'
Debug: convert argc/argv into a printable string for printf() debug Note, next call to this function will free the old (last) string. For example might want do this: \code fp = fopen("some.file.log", "a"); fprintf(fp, "PARAMS are: %s\n", Jim_DebugArgvString(interp, argc, argv)); fclose(fp); \endcode
GetOpt - how to. Example (short and incomplete): \code struct jim_getopt_info goi; jim_getopt_setup(&goi, interp, argc, argv); while (goi.argc) { e = jim_getopt_nvp(&goi, nvp_options, &n); if (e != JIM_OK) { jim_getopt_nvp_unknown(&goi, nvp_options, 0); return e; } switch (n->value) { case ALIVE: printf("Option ALIVE specified\n"); break; case FIRST: if (goi.argc < 1) { .. not enough args error .. } jim_getopt_string(&goi, &cp, NULL); printf("FIRSTNAME: %s\n", cp); case AGE: jim_getopt_wide(&goi, &w); printf("AGE: %d\n", (int)(w)); break; case POLITICS: e = jim_getopt_nvp(&goi, nvp_politics, &n); if (e != JIM_OK) { jim_getopt_nvp_unknown(&goi, nvp_politics, 1); return e; } } } \endcode Setup GETOPT \code struct jim_getopt_info goi; Jim_GetOptSetup(&goi, interp, argc, argv); \endcode
Creates a new command context using the startup TCL provided and the existing Jim interpreter, if any. If interp == NULL, then command_init creates a command interpreter.
Find a openocd command from fullname.
Register a file event handler on the given file descriptor with the given mask (may be 1 or more of JIM_EVENT_xxx) When the event occurs, proc is called with clientData and the mask of events that occurred. When the filehandler is removed, finalizerProc is called. Note that no check is made that only one handler is registered for the given event(s).
A convenience version of Jim_CreateFileHandler() which evaluates scriptObj with Jim_EvalObjBackground() when the event occurs.
Removes all event handlers for 'handle' that match 'mask'.
If there is a file handler registered with the given mask, return the clientData for the (first) handler. Otherwise return NULL.
Looks up the appropriate subcommand in the given command table and return the command function which implements the subcommand. NULL will be returned and an appropriate error will be set if the subcommand or arguments are invalid. Typical usage is: { const jim_subcmd_type *ct = Jim_ParseSubCmd(interp, command_table, argc, argv); return Jim_CallSubCmd(interp, ct, argc, argv); }
Parses the args against the given command table and executes the subcommand if found or sets an appropriate error if the subcommand or arguments is invalid. Can be used directly with Jim_CreateCommand() where the ClientData is the command table. e.g. Jim_CreateCommand(interp, "mycmd", Jim_SubCmdProc, command_table, NULL);
Implements the common 'commands' subcommand
Invokes the given subcmd with the given args as returned by Jim_ParseSubCmd() If ct is NULL, returns JIM_ERR, leaving any message. Otherwise invokes ct->function If ct->function returns -1, sets an error message and returns JIM_ERR. Otherwise returns the result of ct->function.
For each key of the hash table 'ht' with object keys that matches the glob pattern (all if NULL), invoke the callback to add entries to a list. Returns the list.
Adds matching command names (procs, channels) to the list.
Adds matching variable names to the list.
Implements the [dict with] command
If the command is a proc, sets/updates the cached namespace (nsObj) based on the command name.
Expands the array variable (dict sugar) and returns the result, or NULL on error. If JIM_UNSHARED is set and the dictionary is shared, it will be duplicated and stored back to the variable before expansion.
If the name in objPtr is not fully qualified, and a non-global namespace is in effect, qualifies the name with the current namespace and returns the new name. Otherwise returns objPtr. In either case the ref count is incremented and should be decremented by the caller. with Jim_DecrRefCount()
Add the command to the commands hash table
Free the entire dict structure, including the key, value table, the hash table and the dict structure.
Allocate and return a new Jim_Dict structure with space for 'table_size' (key, object) entries and hash table size 'ht_size' These can be 0.
Create a script/subst object from the given token.
Takes a tokenlist and creates the allocated list of script tokens in script->token, of length script->len. Unnecessary tokens are discarded, and LINE and WORD tokens are inserted as required. Also sets script->line to the line number of the first token
Sets an appropriate error message for a missing script/expression terminator. Returns JIM_ERR if 'ch' represents an unmatched/missing character. Note that a trailing backslash is not considered to be an error.
Similar to ScriptObjAddTokens(), but for subst objects.
Returns the parsed script. Note that if there is any possibility that the script is not valid, call JimScriptValid() to check
Returns 1 if the script is valid (parsed ok), otherwise returns 0 and leaves an error message in the interp result.
Run any $jim::defer scripts for the current call frame. retcode is the return code from the current proc. Returns the new return code.
Parse the subexpression at builder->token and return with the node on the stack. builder->token is advanced to the next unconsumed token. Returns JIM_OK if OK or JIM_ERR on error and leaves a message in the interpreter result. 'precedence' is the precedence of the current operator. Tokens are consumed until an operator with an equal or lower precedence is reached (or strictly lower if right associative). If EXPR_UNTIL_CLOSE is set, the subexpression extends up to and including the next close parenthesis. If EXPR_FUNC_ARGS is set, multiple subexpressions (terms) are expected separated by comma If EXPR_TERNARY is set, two subexpressions (terms) are expected separated by colon 'exp_numterms' indicates how many terms are expected. Normally this is 1, but may be more for EXPR_FUNC_ARGS and EXPR_TERNARY.
Returns the next object from the list, or NULL on end-of-list.
Returns 1 if end-of-list has been reached.
Note: does not support embedded nulls.
Note: does not support embedded nulls.
Note: does not support embedded nulls.
Creates a channel for fh/fd/filename. If fh is not NULL, uses that as the channel (and sets AIO_KEEPOPEN). Otherwise fd must be >= 0, in which case it uses that as the channel. hdlfmt is a sprintf format for the filehandle. Anything with %ld at the end will do. mode is used for open or fdopen. Creates the command and sets the name as the current result. Returns the AioFile pointer on sucess or NULL on failure (only if fdopen fails).
Create a pair of channels. e.g. from pipe() or socketpair()
Set an error result based on errno and the given message.
Read from 'fd', append the data to strObj and close 'fd'. Returns 1 if data was added, 0 if not, or -1 on error.
Builds the environment array from $::env If $::env is not set, simply returns environ. Otherwise allocates the environ array from the contents of $::env If the exec fails, memory can be freed via JimFreeEnv()
Note that inputId, etc. are osf_handles.
Give a path in objPtr, returns a new path with any trailing slash removed. Use Jim_DecrRefCount() on the returned object (which may be identical to objPtr).
Set file atime/mtime to the given time in microseconds since the epoch.
nsObj is a canonical namespace name (.e.g. "" for root, "abc" for ::abc) The given name is appended to the namespace name to produce a complete canonical name. e.g. "" "abc" => abc "" "::abc" => abc "" "abc::def" => abc::def "abc" "def" => abc::def "abc" "::def" => def
Returns the parent of the given namespace. ::bob::tom => ::bob bob::tom => bob ::bob => :: bob => "" :: => "" "" => ""
[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
[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.
Searches along a of paths for the given package. Returns the allocated path to the package file if found, or NULL if not found.