本文整理汇总了C++中Jim_GetString函数的典型用法代码示例。如果您正苦于以下问题:C++ Jim_GetString函数的具体用法?C++ Jim_GetString怎么用?C++ Jim_GetString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Jim_GetString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: aio_cmd_puts
static int aio_cmd_puts(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
int wlen;
const char *wdata;
Jim_Obj *strObj;
if (argc == 2) {
if (!Jim_CompareStringImmediate(interp, argv[0], "-nonewline")) {
return -1;
}
strObj = argv[1];
}
else {
strObj = argv[0];
}
wdata = Jim_GetString(strObj, &wlen);
if (fwrite(wdata, 1, wlen, af->fp) == (unsigned)wlen) {
if (argc == 2 || putc('\n', af->fp) != EOF) {
return JIM_OK;
}
}
JimAioSetError(interp, af->filename);
return JIM_ERR;
}
开发者ID:alex-shpilkin,项目名称:jimtcl,代码行数:26,代码来源:jim-aio.c
示例2: ioutil_Jim_Command_ls
static int ioutil_Jim_Command_ls(Jim_Interp *interp,
int argc,
Jim_Obj * const *argv)
{
if (argc != 2) {
Jim_WrongNumArgs(interp, 1, argv, "ls ?dir?");
return JIM_ERR;
}
const char *name = Jim_GetString(argv[1], NULL);
DIR *dirp = NULL;
dirp = opendir(name);
if (dirp == NULL)
return JIM_ERR;
Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0);
for (;; ) {
struct dirent *entry = NULL;
entry = readdir(dirp);
if (entry == NULL)
break;
if ((strcmp(".", entry->d_name) == 0) || (strcmp("..", entry->d_name) == 0))
continue;
Jim_ListAppendElement(interp, objPtr,
Jim_NewStringObj(interp, entry->d_name, strlen(entry->d_name)));
}
closedir(dirp);
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
开发者ID:01org,项目名称:CODK-A-Flashpack,代码行数:35,代码来源:ioutil.c
示例3: aio_eventinfo
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
int argc, Jim_Obj * const *argv)
{
int scriptlen = 0;
if (argc == 0) {
/* Return current script */
if (*scriptHandlerObj) {
Jim_SetResult(interp, *scriptHandlerObj);
}
return JIM_OK;
}
if (*scriptHandlerObj) {
/* Delete old handler */
Jim_DeleteFileHandler(interp, af->fp);
*scriptHandlerObj = NULL;
}
/* Now possibly add the new script(s) */
Jim_GetString(argv[0], &scriptlen);
if (scriptlen == 0) {
/* Empty script, so done */
return JIM_OK;
}
/* A new script to add */
Jim_IncrRefCount(argv[0]);
*scriptHandlerObj = argv[0];
Jim_CreateFileHandler(interp, af->fp, mask,
JimAioFileEventHandler, *scriptHandlerObj, JimAioFileEventFinalizer);
return JIM_OK;
}
开发者ID:alex-shpilkin,项目名称:jimtcl,代码行数:35,代码来源:jim-aio.c
示例4: GetAnimateWindowFlagsFromObj
static int
GetAnimateWindowFlagsFromObj(Jim_Interp *interp, Jim_Obj *listObj, DWORD *flags)
{
int r = JIM_OK, n, nLength;
*flags = 0;
Jim_ListLength(interp, listObj, &nLength);
if (r == JIM_OK) {
for (n = 0; n < nLength; n++) {
ANIMATEWINDOWFLAGSMAP *p;
Jim_Obj *obj;
r = Jim_ListIndex(interp, listObj, n, &obj, 1);
for (p = AnimateWindowFlagsMap; r == JIM_OK && p->s != NULL; p++) {
size_t len;
const char *name = Jim_GetString(obj, &len);
if (strncmp(p->s, name, len) == 0) {
*flags |= p->f;
break;
}
}
if (p->s == NULL) {
Jim_SetResultString(interp, "invalid option", -1);
return JIM_ERR;
}
}
}
return r;
}
开发者ID:alepharchives,项目名称:Jim,代码行数:28,代码来源:jim-win32.c
示例5: Win32_FindWindow
/* win32.FindWindow title ?class? */
static int
Win32_FindWindow(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
{
const char *title = NULL, *class = NULL;
HWND hwnd = NULL;
int r = JIM_OK;
if (objc < 2 || objc > 3) {
Jim_WrongNumArgs(interp, 1, objv, "title ?class?");
return JIM_ERR;
}
title = Jim_GetString(objv[1], NULL);
if (objc == 3)
class = Jim_GetString(objv[2], NULL);
hwnd = FindWindowA(class, title);
if (hwnd == NULL) {
Jim_SetResult(interp,
Win32ErrorObj(interp, "FindWindow", GetLastError()));
r = JIM_ERR;
} else {
Jim_SetResult(interp, Jim_NewIntObj(interp, (long)hwnd));
}
return r;
}
开发者ID:alepharchives,项目名称:Jim,代码行数:26,代码来源:jim-win32.c
示例6: main
/*
* Now we try to write big enough code to duplication our array in Jim's
* list implementation. Later, we try to load a sample script in Tcl that
* could print our list.
*/
int
main(int argc, char **argv)
{
Jim_Interp *interp;
int error;
/* Create an interpreter. */
interp = Jim_CreateInterp();
assert(interp != NULL && "couldn't create interpreter");
/* We register base commands, so that we actually implement Tcl. */
Jim_RegisterCoreCommands(interp);
/* And initialise any static extensions */
Jim_InitStaticExtensions(interp);
/* Register our Jim commands. */
Jim_CreateCommand(interp, "MySampleCommand", MySampleCommandFunc,
NULL, NULL);
/* Run a script. */
error = Jim_Eval(interp, JIM_PROGRAM);
if (error == JIM_ERR) {
Jim_MakeErrorMessage(interp);
fprintf(stderr, "%s\n", Jim_GetString(Jim_GetResult(interp), NULL));
Jim_FreeInterp(interp);
exit(EXIT_FAILURE);
}
Jim_FreeInterp(interp);
return (EXIT_SUCCESS);
}
开发者ID:BitThunder,项目名称:bitthunder,代码行数:37,代码来源:jim_command.c
示例7: aio_cmd_sendto
static int aio_cmd_sendto(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
int wlen;
int len;
const char *wdata;
union sockaddr_any sa;
const char *addr = Jim_String(argv[1]);
int salen;
if (IPV6 && af->addr_family == PF_INET6) {
if (JimParseIPv6Address(interp, addr, &sa, &salen) != JIM_OK) {
return JIM_ERR;
}
}
else if (JimParseIpAddress(interp, addr, &sa, &salen) != JIM_OK) {
return JIM_ERR;
}
wdata = Jim_GetString(argv[0], &wlen);
/* Note that we don't validate the socket type. Rely on sendto() failing if appropriate */
len = sendto(fileno(af->fp), wdata, wlen, 0, &sa.sa, salen);
if (len < 0) {
JimAioSetError(interp, NULL);
return JIM_ERR;
}
Jim_SetResultInt(interp, len);
return JIM_OK;
}
开发者ID:alex-shpilkin,项目名称:jimtcl,代码行数:29,代码来源:jim-aio.c
示例8: jim_capture
/* Capture progress output and return as tcl return value. If the
* progress output was empty, return tcl return value.
*/
static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 2)
return JIM_ERR;
struct log_capture_state *state = command_log_capture_start(interp);
/* disable polling during capture. This avoids capturing output
* from polling.
*
* This is necessary in order to avoid accidentally getting a non-empty
* string for tcl fn's.
*/
bool save_poll = jtag_poll_get_enabled();
jtag_poll_set_enabled(false);
const char *str = Jim_GetString(argv[1], NULL);
int retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
jtag_poll_set_enabled(save_poll);
command_log_capture_finish(state);
return retcode;
}
开发者ID:jfischer-phytec-iot,项目名称:openocd,代码行数:29,代码来源:command.c
示例9: Jim_GetString
/* Everything passing between interpreters must be converted to a string */
static Jim_Obj *JimInterpCopyObj(Jim_Interp *target, Jim_Obj *obj)
{
const char *rep;
int len;
rep = Jim_GetString(obj, &len);
return Jim_NewStringObj(target, rep, len);
}
开发者ID:evanhunter,项目名称:jimtcl,代码行数:9,代码来源:jim-interp.c
示例10: jim_echo
static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 2)
return JIM_ERR;
const char *str = Jim_GetString(argv[1], NULL);
LOG_USER("%s", str);
return JIM_OK;
}
开发者ID:unnamet,项目名称:estick-jtag,代码行数:8,代码来源:command.c
示例11: es_eval_tcl
es_Status es_eval_tcl(es_Interp *interp, const char *script) {
int error = Jim_Eval(interp, script);
if (error == JIM_ERR) {
Jim_MakeErrorMessage(interp);
LOG_ERROR(Tcl,"%s\n", Jim_GetString(Jim_GetResult(interp), NULL));
}
return error;
}
开发者ID:openETCS,项目名称:modeling,代码行数:8,代码来源:interp.c
示例12: InterfaceFunc
/*
* Parse "interface" keyword.
*/
static int
InterfaceFunc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct mystate *softc;
struct iface *iface;
Jim_Obj *ipobj;
const char *ip;
const char *name;
int error;
iface = NULL;
ipobj = NULL;
ip = name = NULL;
error = 0;
if (argc != 3)
return (JIM_ERR);
softc = Jim_CmdPrivData(interp);
/* Name of the interface. */
name = Jim_GetString(argv[1], NULL);
softc->block_parsing = 1;
/* Body of the block */
error = Jim_EvalObj(interp, argv[2]);
if (error) {
printf("couldn't evaluate\n");
return (JIM_ERR);
}
softc->block_parsing = 0;
/* Take our hidden variable */
ipobj = Jim_GetVariableStr(interp, JCONF_VAR_IP, JIM_NONE);
assert(ipobj != NULL);
ip = Jim_GetString(ipobj, NULL);
if (ip == NULL) {
Jim_fprintf(interp, interp->cookie_stdout, "NULL!\n");
return (JIM_ERR);
}
iface = iface_alloc(ip, name);
assert(iface != NULL);
INSERT(softc->head, iface);
return (JIM_OK);
}
开发者ID:wkoszek,项目名称:jimctl,代码行数:49,代码来源:jim_conf.c
示例13: JimTrimTrailingNewline
/*
* If the last character of the result is a newline, then remove
* the newline character (the newline would just confuse things).
*
* Note: Ideally we could do this by just reducing the length of stringrep
* by 1, but there is no API for this :-(
*/
static void JimTrimTrailingNewline(Jim_Interp *interp)
{
int len;
const char *p = Jim_GetString(Jim_GetResult(interp), &len);
if (len > 0 && p[len - 1] == '\n') {
Jim_SetResultString(interp, p, len - 1);
}
}
开发者ID:dokterp,项目名称:jimtcl,代码行数:16,代码来源:jim-exec.c
示例14: Jim_PosixSignalCommand
static int Jim_PosixSignalCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
int sig;
int signum;
sighandler_t lastaction;
sighandler_t nextaction = SIG_DFL;
const char *op;
int strlen = 0;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "signame ?action ...?");
return JIM_ERR;
}
if (Jim_GetEnum(interp, argv[1], signames, &sig, "Signal Names",
JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
signum = signums[sig];
switch (argc) {
case 3:
if (op = Jim_GetString(argv[2], &strlen),strlen == 0) {
return JIM_ERR;
}
if (strcmp("default",op) == 0) {
nextaction = SIG_DFL;
} else if (strcmp("ignore",op) == 0) {
nextaction = SIG_IGN;
} else if (strcmp("debug",op) == 0) {
nextaction = Jim_Posix_SigHandler;
} else {
// this is the place to insert a script! UK
}
// fall through to query case:
case 2:
lastaction = signal(signum, nextaction);
if (argc==2)
signal(signum, lastaction);
if (lastaction == SIG_ERR) {
return JIM_ERR;
}
if (lastaction == SIG_DFL) {
Jim_SetResultString(interp, "default", -1);
return JIM_OK;
}
if (lastaction == SIG_IGN) {
Jim_SetResultString(interp, "ignore", -1);
return JIM_OK;
}
Jim_SetResultString(interp, "function", -1);
return JIM_OK;
}
return JIM_OK;
}
开发者ID:alepharchives,项目名称:Jim,代码行数:56,代码来源:jim-posix.c
示例15: Jim_RemoveTrailingNewline
static void Jim_RemoveTrailingNewline(Jim_Obj *objPtr)
{
int len;
const char *s = Jim_GetString(objPtr, &len);
if (len > 0 && s[len - 1] == '\n') {
objPtr->length--;
objPtr->bytes[objPtr->length] = '\0';
}
}
开发者ID:dokterp,项目名称:jimtcl,代码行数:10,代码来源:jim-exec.c
示例16: Jim_GetString
struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
{
const char *cp = Jim_GetString(o, NULL);
struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
if (NULL == cp)
cp = "(unknown)";
if (NULL == t)
Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
return t;
}
开发者ID:cz172638,项目名称:openocd,代码行数:10,代码来源:tcl.c
示例17: zylinjtag_Jim_Command_rm
static int
zylinjtag_Jim_Command_rm(Jim_Interp *interp,
int argc,
Jim_Obj * const *argv)
{
int del;
if (argc != 2)
{
Jim_WrongNumArgs(interp, 1, argv, "rm ?dirorfile?");
return JIM_ERR;
}
del = 0;
if (unlink(Jim_GetString(argv[1], NULL)) == 0)
del = 1;
if (rmdir(Jim_GetString(argv[1], NULL)) == 0)
del = 1;
return del ? JIM_OK : JIM_ERR;
}
开发者ID:unnamet,项目名称:estick-jtag,代码行数:20,代码来源:ioutil.c
示例18: es_jim_log_cmd
int es_jim_log_cmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) {
if(argc!=4) {
WRONG_ARGS(interp,1,argv,"info|warn|error tag message");
}
char *lvl = (char*)Jim_GetString(argv[1],NULL);
char *src = (char*)Jim_GetString(argv[2],NULL);
char *msg = (char*)Jim_GetString(argv[3],NULL);
if(!strcmp("info",lvl)) {
LOG_INFO(src,msg);
return JIM_OK;
}
if(!strcmp("warn",lvl)) {
LOG_WARN(src,msg);
return JIM_OK;
}
if(!strcmp("error",lvl)) {
LOG_ERROR(src,msg);
return JIM_OK;
}
RCERROR(interp,"Invalid log level: %s",lvl);
}
开发者ID:openETCS,项目名称:modeling,代码行数:21,代码来源:interp.c
示例19: JimParseAfterId
static jim_wide JimParseAfterId(Jim_Obj *idObj)
{
int len;
const char *tok = Jim_GetString(idObj, &len);
jim_wide id;
if (strncmp(tok, "after#", 6) == 0 && Jim_StringToWide(tok + 6, &id, 10) == JIM_OK) {
/* Got an event by id */
return id;
}
return -1;
}
开发者ID:JimmyDurandWesolowski,项目名称:openocd,代码行数:12,代码来源:jim-eventloop.c
示例20: JimELAfterCommand
static int JimELAfterCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
jim_wide ms, id;
Jim_Obj *objPtr, *idObjPtr;
const char *options[] = {
"info", "cancel", "restart", "expire", NULL
};
enum {INFO, CANCEL, RESTART, EXPIRE, CREATE };
int option = CREATE ;
if (argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "<after milliseconds> script");
return JIM_ERR;
}
if (Jim_GetWide(interp, argv[1], &ms) != JIM_OK)
if (Jim_GetEnum(interp, argv[1], options, &option, "after options",
JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
switch (option) {
case CREATE:
Jim_IncrRefCount(argv[2]);
id = Jim_CreateTimeHandler(interp, ms, JimAfterTimeHandler, argv[2],
JimAfterTimeEventFinalizer);
objPtr = Jim_NewStringObj(interp, NULL, 0);
Jim_AppendString(interp, objPtr, "after#", -1);
idObjPtr = Jim_NewIntObj(interp, id);
Jim_IncrRefCount(idObjPtr);
Jim_AppendObj(interp, objPtr, idObjPtr);
Jim_DecrRefCount(interp, idObjPtr);
Jim_SetResult(interp, objPtr);
return JIM_OK;
case CANCEL:
{
int tlen ;
jim_wide remain = 0;
const char *tok = Jim_GetString(argv[2], &tlen);
if ( sscanf(tok,"after#%lld",&id) == 1) {
remain = Jim_DeleteTimeHandler(interp, id);
if (remain > -2) {
Jim_SetResult(interp, Jim_NewIntObj(interp, remain));
return JIM_OK;
}
}
Jim_SetResultString(interp, "invalid event" , -1);
return JIM_ERR;
}
default:
fprintf(stderr,"unserviced option to after %d\n",option);
}
return JIM_OK;
}
开发者ID:unnamet,项目名称:estick-jtag,代码行数:52,代码来源:jim-eventloop.c
注:本文中的Jim_GetString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论