本文整理汇总了C++中Tcl_AppendElement函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_AppendElement函数的具体用法?C++ Tcl_AppendElement怎么用?C++ Tcl_AppendElement使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tcl_AppendElement函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uutcl_GetProgressInfo
static int UUTCLFUNC
uutcl_GetProgressInfo (ClientData clientData, Tcl_Interp *interp,
int argc, char *argv[])
{
uuprogress progress;
char tmpstring[32];
if (UUGetOption (UUOPT_PROGRESS, NULL,
(char *) &progress, sizeof (uuprogress)) != 0) {
Tcl_SetResult (interp, "oops, could not get info?", TCL_STATIC);
return TCL_ERROR;
}
sprintf (tmpstring, "%d", progress.action);
Tcl_AppendElement (interp, tmpstring);
Tcl_AppendElement (interp, progress.curfile);
sprintf (tmpstring, "%d", progress.partno);
Tcl_AppendElement (interp, tmpstring);
sprintf (tmpstring, "%d", progress.numparts);
Tcl_AppendElement (interp, tmpstring);
sprintf (tmpstring, "%d", progress.percent);
Tcl_AppendElement (interp, tmpstring);
return TCL_OK;
}
示例2: test_exec_printf
/*
** Usage: sqlite_exec_printf DB FORMAT STRING
**
** Invoke the sqlite_exec_printf() interface using the open database
** DB. The SQL is the string FORMAT. The format string should contain
** one %s or %q. STRING is the value inserted into %s or %q.
*/
static int test_exec_printf(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
char **argv /* Text of each argument */
){
sqlite *db;
Tcl_DString str;
int rc;
char *zErr = 0;
char zBuf[30];
if( argc!=4 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB FORMAT STRING", 0);
return TCL_ERROR;
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
Tcl_DStringInit(&str);
rc = sqlite_exec_printf(db, argv[2], exec_printf_cb, &str, &zErr, argv[3]);
sprintf(zBuf, "%d", rc);
Tcl_AppendElement(interp, zBuf);
Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);
Tcl_DStringFree(&str);
if( zErr ) free(zErr);
return TCL_OK;
}
示例3: pager_stats
/*
** Usage: pager_stats ID
**
** Return pager statistics.
*/
static int pager_stats(
void *NotUsed,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int argc, /* Number of arguments */
const char **argv /* Text of each argument */
){
Pager *pPager;
int i, *a;
if( argc!=2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID\"", 0);
return TCL_ERROR;
}
pPager = sqlite3TestTextToPtr(argv[1]);
a = sqlite3PagerStats(pPager);
for(i=0; i<9; i++){
static char *zName[] = {
"ref", "page", "max", "size", "state", "err",
"hit", "miss", "ovfl",
};
char zBuf[100];
Tcl_AppendElement(interp, zName[i]);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",a[i]);
Tcl_AppendElement(interp, zBuf);
}
return TCL_OK;
}
示例4: tcl_console
static int tcl_console(ClientData cd, Tcl_Interp *irp,
int argc, char *argv[])
{
int i, j, pls, arg;
module_entry *me;
BADARGS(2, 4, " idx ?channel? ?console-modes?");
i = findidx(atoi(argv[1]));
if (i < 0 || dcc[i].type != &DCC_CHAT) {
Tcl_AppendResult(irp, "invalid idx", NULL);
return TCL_ERROR;
}
pls = 1;
for (arg = 2; arg < argc; arg++) {
if (argv[arg][0] && ((strchr(CHANMETA, argv[arg][0]) != NULL) ||
(argv[arg][0] == '*'))) {
if ((argv[arg][0] != '*') && (!findchan_by_dname(argv[arg]))) {
/* If we dont find the channel, and it starts with a +, assume it
* should be the console flags to set. */
if (argv[arg][0] == '+')
goto do_console_flags;
Tcl_AppendResult(irp, "invalid channel", NULL);
return TCL_ERROR;
}
strncpyz(dcc[i].u.chat->con_chan, argv[arg], 81);
} else {
if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
dcc[i].u.chat->con_flags = 0;
do_console_flags:
for (j = 0; j < strlen(argv[arg]); j++) {
if (argv[arg][j] == '+')
pls = 1;
else if (argv[arg][j] == '-')
pls = -1;
else {
char s[2];
s[0] = argv[arg][j];
s[1] = 0;
if (pls == 1)
dcc[i].u.chat->con_flags |= logmodes(s);
else
dcc[i].u.chat->con_flags &= ~logmodes(s);
}
}
}
}
Tcl_AppendElement(irp, dcc[i].u.chat->con_chan);
Tcl_AppendElement(irp, masktype(dcc[i].u.chat->con_flags));
/* Console autosave. */
if (argc > 2 && (me = module_find("console", 1, 1))) {
Function *func = me->funcs;
(func[CONSOLE_DOSTORE]) (i);
}
return TCL_OK;
}
示例5: appendpoint
/* append the x and y coordinates of a point to the Tcl result */
static void appendpoint(Tcl_Interp * interp, point p)
{
char buf[30];
sprintf(buf, "%g", p.x);
Tcl_AppendElement(interp, buf);
sprintf(buf, "%g", p.y);
Tcl_AppendElement(interp, buf);
}
示例6: TestfilewaitCmd
static int
TestfilewaitCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
CONST char **argv) /* Argument strings. */
{
int mask, result, timeout;
Tcl_Channel channel;
int fd;
ClientData data;
if (argc != 4) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
" file readable|writable|both timeout\"", NULL);
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, argv[1], NULL);
if (channel == NULL) {
return TCL_ERROR;
}
if (strcmp(argv[2], "readable") == 0) {
mask = TCL_READABLE;
} else if (strcmp(argv[2], "writable") == 0){
mask = TCL_WRITABLE;
} else if (strcmp(argv[2], "both") == 0){
mask = TCL_WRITABLE|TCL_READABLE;
} else {
Tcl_AppendResult(interp, "bad argument \"", argv[2],
"\": must be readable, writable, or both", NULL);
return TCL_ERROR;
}
if (Tcl_GetChannelHandle(channel,
(mask & TCL_READABLE) ? TCL_READABLE : TCL_WRITABLE,
(ClientData*) &data) != TCL_OK) {
Tcl_SetResult(interp, "couldn't get channel file", TCL_STATIC);
return TCL_ERROR;
}
fd = PTR2INT(data);
if (Tcl_GetInt(interp, argv[3], &timeout) != TCL_OK) {
return TCL_ERROR;
}
result = TclUnixWaitForFile(fd, mask, timeout);
if (result & TCL_READABLE) {
Tcl_AppendElement(interp, "readable");
}
if (result & TCL_WRITABLE) {
Tcl_AppendElement(interp, "writable");
}
return TCL_OK;
}
示例7: Dci_ListDump
void
Dci_ListDump(Tcl_Interp *interp, Dci_List *listPtr, char *pattern, int values)
{
char *key;
int i;
for (i = 0; i < listPtr->nelem; ++i) {
key = Dci_ListKey(listPtr, i);
if (pattern == NULL || Tcl_StringMatch(key, pattern)) {
Tcl_AppendElement(interp, key);
if (values) {
Tcl_AppendElement(interp, Dci_ListValue(listPtr, i));
}
}
}
}
示例8: BrowOperands
int BrowOperands(Tcl_Interp *interp, struct Instance *i)
{
struct gl_list_t *ol;
struct Instance *p;
unsigned long c,len;
char *name;
if (i == NULL) {
return TCL_OK;
}
ol = GetInstanceOperands(i);
if (ol == NULL) {
return TCL_OK;
}
len = gl_length(ol);
p = FirstModelUpward(i);
for (c=1;c <= len; c++) {
i = gl_fetch(ol,c);
if (i == NULL) {
continue;
}
name = WriteInstanceNameString(i,p);
if (name == NULL) {
continue;
}
Tcl_AppendElement(interp,name);
ascfree(name);
}
gl_destroy(ol);
return TCL_OK;
}
示例9: Asc_BrowSimListCmd
int Asc_BrowSimListCmd(ClientData cdata, Tcl_Interp *interp,
int argc, CONST84 char *argv[])
{
struct Instance *sptr;
struct gl_list_t *sl;
unsigned long len, c;
UNUSED_PARAMETER(cdata);
(void)argv; /* stop gcc whine about unused parameter */
if ( argc != 1 ) {
Tcl_SetResult(interp, "wrong # args to \"slist\"", TCL_STATIC);
return TCL_ERROR;
}
sl = g_simulation_list;
if (sl==NULL) {
Tcl_SetResult(interp, "Simulation list is NULL", TCL_STATIC);
} else {
len = gl_length(sl);
for(c=1;c<=len;c++) {
sptr = (struct Instance *)gl_fetch(sl,c);
Tcl_AppendElement(interp,(char *)SCP(GetSimulationName(sptr)));
}
}
return TCL_OK;
}
示例10: IvyApplicationMsgsCmd
static int
IvyApplicationMsgsCmd(ClientData clientData,
Tcl_Interp *interp,
int argc,
const char **argv)
{
Tcl_HashEntry *entry;
char **msgs, **scan;
if (argc != 2) {
Tcl_AppendResult(interp, "wrong # of args: \"",
argv[0], " appName\"", (char *) NULL);
return TCL_ERROR;
}
entry = Tcl_FindHashEntry(&app_table, argv[1]);
if (!entry) {
Tcl_AppendResult(interp, "Application \"",
argv[1], "\" not connected", (char *) NULL);
return TCL_ERROR;
}
msgs = IvyGetApplicationMessages((IvyClientPtr) Tcl_GetHashValue(entry));
for (scan = msgs; *scan; scan++) {
Tcl_AppendElement(interp, *scan);
}
return TCL_OK;
}
示例11: SWIG_Tcl_ConvertPacked
SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c;
if (!obj) goto type_error;
c = Tcl_GetStringFromObj(obj,NULL);
/* Pointer values must start with leading underscore */
if (*c != '_') goto type_error;
c++;
c = SWIG_UnpackData(c,ptr,sz);
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
}
return TCL_OK;
type_error:
if (flags) {
if (ty) {
Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
Tcl_AppendElement(interp, (char *) ty->name);
return TCL_ERROR;
} else {
Tcl_SetResult(interp, (char *) "Expected packed data.", TCL_STATIC);
return TCL_ERROR;
}
}
return TCL_ERROR;
}
示例12: TclGetAndDetachPids
void
TclGetAndDetachPids(
Tcl_Interp *interp, /* Interpreter to append the PIDs to. */
Tcl_Channel chan) /* Handle for the pipeline. */
{
PipeState *pipePtr;
const Tcl_ChannelType *chanTypePtr;
int i;
char buf[TCL_INTEGER_SPACE];
/*
* Punt if the channel is not a command channel.
*/
chanTypePtr = Tcl_GetChannelType(chan);
if (chanTypePtr != &pipeChannelType) {
return;
}
pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan);
for (i = 0; i < pipePtr->numPids; i++) {
TclFormatInt(buf, (long) TclpGetPid(pipePtr->pidPtr[i]));
Tcl_AppendElement(interp, buf);
Tcl_DetachPids(1, &(pipePtr->pidPtr[i]));
}
if (pipePtr->numPids > 0) {
ckfree((char *) pipePtr->pidPtr);
pipePtr->numPids = 0;
}
}
示例13: TclAppendRealMatrix
int TclAppendRealMatrix(Tcl_Interp* interp,mv_double * m)
{
int i,j,r,c;
char num[64];
char buf[BUFLEN];
int nbuf;
r = m->row;
c = m->col;
for (i=1;i<=r;i++) {
nbuf=0;
buf[0]=0;
for (j=1;j<=c;j++) {
sprintf(num,"%g",m->data[i+j*r]);
nbuf += strlen(num);
if (nbuf >= BUFLEN) {
Tcl_SetResult(interp,"getmatrix: internal buffer overflow\n",TCL_STATIC);
return TCL_ERROR;
}
if (j != 1) strcat(buf," ");
strcat(buf,num);
}
Tcl_AppendElement(interp,buf);
}
return TCL_OK;
}
示例14: listEdgeAttrs
void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g)
{
Agsym_t *a = NULL;
while ((a = agnxtattr(g, AGEDGE, a))) {
Tcl_AppendElement(interp, a->name);
}
}
示例15: TclAppendMatrix
int TclAppendMatrix(Tcl_Interp* interp,mv_complx * m)
{
int i,j,r,c;
char num[64];
char buf[BUFLEN];
int nbuf;
complx z;
r = m->row;
c = m->col;
for (i=0;i<r;i++) {
nbuf=0;
buf[0]=0;
for (j=0;j<c;j++) {
z = m->data[i+j*r];
sprintf(num,"{%g %g}",z.re,z.im);
nbuf += strlen(num);
if (nbuf >= BUFLEN) {
Tcl_SetResult(interp,"getmatrix: internal buffer overflow\n",TCL_STATIC);
return TCL_ERROR;
}
if (j != 0) strcat(buf," ");
strcat(buf,num);
}
Tcl_AppendElement(interp,buf);
}
return TCL_OK;
}