Beispiel #1
0
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;
}
Beispiel #2
0
/*
** 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;
}
Beispiel #3
0
/*
** 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;
}
Beispiel #4
0
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;
}
Beispiel #5
0
/* 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);
}
Beispiel #6
0
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;
}
Beispiel #7
0
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));
	    }
	}
    }
}
Beispiel #8
0
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;
}
Beispiel #9
0
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;
}
Beispiel #10
0
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;
}
Beispiel #11
0
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;
}
Beispiel #12
0
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;
    }
}
Beispiel #13
0
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;
}
Beispiel #14
0
void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g)
{
    Agsym_t *a = NULL;
    while ((a = agnxtattr(g, AGEDGE, a))) {
	Tcl_AppendElement(interp, a->name);
    }
}
Beispiel #15
0
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;
}
Beispiel #16
0
static int halCmd(ClientData cd, Tcl_Interp *interp, int argc, const char **argv) {
    int result;
    Tcl_ResetResult(interp);

    if(argc < 2) {
        Tcl_AppendResult(interp,
                "wrong # args: should be \"", argv[0], " command ...\"", NULL);
        return TCL_ERROR;
    }

    if(strcmp(argv[1], "--commands") == 0)
    {
        int i;
        Tcl_ResetResult(interp);
        for(i=0; i<halcmd_ncommands; i++)
            Tcl_AppendElement(interp, halcmd_commands[i].name);
        return TCL_OK;
    }

    target_interp = interp;
    pending_cr = 0;
    result = halcmd_parse_cmd((char **)argv+1);
    target_interp = NULL;

    if(result == 0) return TCL_OK;
    halError(interp, result);
    return TCL_ERROR;
}
Beispiel #17
0
/*
** Usage:   btree_get_meta ID
**
** Return meta data
*/
static int btree_get_meta(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  const char **argv      /* Text of each argument */
){
  Btree *pBt;
  int rc;
  int i;
  if( argc!=2 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
       " ID\"", 0);
    return TCL_ERROR;
  }
  pBt = sqlite3TestTextToPtr(argv[1]);
  for(i=0; i<SQLITE_N_BTREE_META; i++){
    char zBuf[30];
    u32 v;
    sqlite3BtreeEnter(pBt);
    rc = sqlite3BtreeGetMeta(pBt, i, &v);
    sqlite3BtreeLeave(pBt);
    if( rc!=SQLITE_OK ){
      Tcl_AppendResult(interp, errorName(rc), 0);
      return TCL_ERROR;
    }
    sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",v);
    Tcl_AppendElement(interp, zBuf);
  }
  return TCL_OK;
}
Beispiel #18
0
static int
get_ports(ClientData clientData,
              Tcl_Interp *interp,
              int argc,
              char *argv[])
{
    char msg[255];
    channel_t *chan;
    int i, n;

    memset(msg, 0, 255);
    n = queue_length(priv_c);
    Tcl_SetResult(interp,NULL,TCL_STATIC);
    for(i = 0; i < n; i++) {
        chan = (channel_t*)queue_get(priv_c, i, Q_KEEP);
        sprintf(msg, "%d", chan->port);
        Tcl_AppendElement(interp,msg);
    }

    UNUSED(clientData);
    UNUSED(argc);
    UNUSED(argv);

    return TCL_OK;
}
/*
** Usage:   btree_pager_stats ID
**
** Returns pager statistics
*/
static int btree_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 */
){
  Btree *pBt;
  int i;
  int *a;

  if( argc!=2 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
       " ID\"", 0);
    return TCL_ERROR;
  }
  pBt = sqlite3TestTextToPtr(argv[1]);
 
  /* Normally in this file, with a b-tree handle opened using the 
  ** [btree_open] command it is safe to call sqlite3BtreeEnter() directly.
  ** But this function is sometimes called with a btree handle obtained
  ** from an open SQLite connection (using [btree_from_db]). In this case
  ** we need to obtain the mutex for the controlling SQLite handle before
  ** it is safe to call sqlite3BtreeEnter().
  */
  sqlite3_mutex_enter(pBt->db->mutex);

  sqlite3BtreeEnter(pBt);
  a = sqlite3PagerStats(sqlite3BtreePager(pBt));
  for(i=0; i<11; i++){
    static char *zName[] = {
      "ref", "page", "max", "size", "state", "err",
      "hit", "miss", "ovfl", "read", "write"
    };
    char zBuf[100];
    Tcl_AppendElement(interp, zName[i]);
    sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",a[i]);
    Tcl_AppendElement(interp, zBuf);
  }
  sqlite3BtreeLeave(pBt);

  /* Release the mutex on the SQLite handle that controls this b-tree */
  sqlite3_mutex_leave(pBt->db->mutex);
  return TCL_OK;
}
Beispiel #20
0
int TclAppendResult(Tcl_Interp* interp,const char* format, ...)
{
   char buffer [512];
   va_list argptr;
   va_start(argptr, format);
   vsprintf(buffer, format, argptr);
   va_end(argptr);
   Tcl_AppendElement(interp,buffer);
   return TCL_OK;
}
Beispiel #21
0
const tclmod_command_type *
tclmod_parse_cmd(Tcl_Interp *interp, const tclmod_command_type *command_table, int argc, char **argv)
{
	const tclmod_command_type *ct;
	const char *sep;
	int ret;

	if (argc < 2) {
		Tcl_AppendResult (interp, "wrong # args: should be \"", argv[0], " command ...\"\n", (char *) NULL);
		Tcl_AppendResult (interp, "Use \"", argv[0], " ?\" or \"", argv[0], " command ?\" for help", (char *) NULL);
		return 0;
	}

	for (ct = command_table; ct->cmd; ct++) {
		ret = check_match_command(interp, ct, argc, argv);
		if (ret == 1) {
			/* Matched and args OK */
			return ct;
		}
		if (ret == -1) {
			/* Matched, but bad args */
			return 0;
		}
	}

	/* No match, so see if it is a builtin command */
	if (strcmp(argv[1], "commands") == 0) {
		const tclmod_command_type *ct;

		for (ct = command_table; ct->cmd; ct++) {
			if (!(ct->flags & TCL_MODFLAG_HIDDEN)) {
				Tcl_AppendElement(interp, (char *)ct->cmd, 0);
			}
		}
		return &tclmod_command_entry;
	}

	/* No, so show usage */
	if (strcmp(argv[1], "?") == 0) {
		Tcl_AppendResult(interp, "Usage: \"", argv[0], " command ...\", where command is one of: ", (char *) NULL);
	}
	else {
		Tcl_AppendResult(interp, "Error: ", argv[0], ", unknown command \"", argv[1], "\": should be ", (char *) NULL);
	}

	sep = "";
	for (ct = command_table; ct->cmd; ct++) {
		if (!(ct->flags & TCL_MODFLAG_HIDDEN)) {
			Tcl_AppendResult(interp, sep, ct->cmd, (char *) NULL);
			sep = ", ";
		}
	}
	return 0;
}
Beispiel #22
0
static int tcl_bots(ClientData cd, Tcl_Interp *irp,
                    int argc, char *argv[])
{
  tand_t *bot;

  BADARGS(1, 1, "");

  for (bot = tandbot; bot; bot = bot->next)
    Tcl_AppendElement(irp, bot->bot);
  return TCL_OK;
}
Beispiel #23
0
static int tcl_getflags(ClientData cd, Tcl_Interp *irp,
                        int argc, char *argv[])
{
  filedb_entry *fdbe;
  char *s = NULL, *p, *d;

  BADARGS(2, 2, " dir");

  malloc_strcpy(s, argv[1]);
  if (s[strlen(s) - 1] == '/')
    s[strlen(s) - 1] = 0;
  p = strrchr(s, '/');
  if (p == NULL) {
    p = s;
    d = "";
  } else {
    *p = 0;
    p++;
    d = s;
  }

  fdbe = filedb_getentry(d, p);
  /* Directory doesn't exist? */
  if (!fdbe || !(fdbe->stat & FILE_DIR)) {
    Tcl_AppendResult(irp, "", NULL);
    my_free(s);
    free_fdbe(&fdbe);
    return TCL_OK;
  }
  if (fdbe->flags_req) {
    malloc_strcpy(s, fdbe->flags_req);
    if (s[0] == '-')
      s[0] = 0;
  } else
    s[0] = 0;
  Tcl_AppendElement(irp, s);
  Tcl_AppendElement(irp, fdbe->chan);
  my_free(s);
  free_fdbe(&fdbe);
  return TCL_OK;
}
Beispiel #24
0
/*
** Usage:  sqlite_get_table_printf  DB  FORMAT  STRING
**
** Invoke the sqlite_get_table_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_get_table_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;
  int nRow, nCol;
  char **aResult;
  int i;
  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_get_table_printf(db, argv[2], &aResult, &nRow, &nCol, 
               &zErr, argv[3]);
  sprintf(zBuf, "%d", rc);
  Tcl_AppendElement(interp, zBuf);
  if( rc==SQLITE_OK ){
    sprintf(zBuf, "%d", nRow);
    Tcl_AppendElement(interp, zBuf);
    sprintf(zBuf, "%d", nCol);
    Tcl_AppendElement(interp, zBuf);
    for(i=0; i<(nRow+1)*nCol; i++){
      Tcl_AppendElement(interp, aResult[i] ? aResult[i] : "NULL");
    }
  }else{
    Tcl_AppendElement(interp, zErr);
  }
  sqlite_free_table(aResult);
  if( zErr ) free(zErr);
  return TCL_OK;
}
Beispiel #25
0
static int
PlaceInfoCommand(
    Tcl_Interp *interp,		/* Interp into which to place result. */
    Tk_Window tkwin)		/* Token for the window to get info on. */
{
    char buffer[32 + TCL_INTEGER_SPACE];
    Slave *slavePtr;

    slavePtr = FindSlave(tkwin);
    if (slavePtr == NULL) {
        return TCL_OK;
    }
    if (slavePtr->masterPtr != NULL) {
        Tcl_AppendElement(interp, "-in");
        Tcl_AppendElement(interp, Tk_PathName(slavePtr->masterPtr->tkwin));
    }
    sprintf(buffer, " -x %d", slavePtr->x);
    Tcl_AppendResult(interp, buffer, NULL);
    sprintf(buffer, " -relx %.4g", slavePtr->relX);
    Tcl_AppendResult(interp, buffer, NULL);
    sprintf(buffer, " -y %d", slavePtr->y);
    Tcl_AppendResult(interp, buffer, NULL);
    sprintf(buffer, " -rely %.4g", slavePtr->relY);
    Tcl_AppendResult(interp, buffer, NULL);
    if (slavePtr->flags & CHILD_WIDTH) {
        sprintf(buffer, " -width %d", slavePtr->width);
        Tcl_AppendResult(interp, buffer, NULL);
    } else {
        Tcl_AppendResult(interp, " -width {}", NULL);
    }
    if (slavePtr->flags & CHILD_REL_WIDTH) {
        sprintf(buffer, " -relwidth %.4g", slavePtr->relWidth);
        Tcl_AppendResult(interp, buffer, NULL);
    } else {
        Tcl_AppendResult(interp, " -relwidth {}", NULL);
    }
    if (slavePtr->flags & CHILD_HEIGHT) {
        sprintf(buffer, " -height %d", slavePtr->height);
        Tcl_AppendResult(interp, buffer, NULL);
    } else {
        Tcl_AppendResult(interp, " -height {}", NULL);
    }
    if (slavePtr->flags & CHILD_REL_HEIGHT) {
        sprintf(buffer, " -relheight %.4g", slavePtr->relHeight);
        Tcl_AppendResult(interp, buffer, NULL);
    } else {
        Tcl_AppendResult(interp, " -relheight {}", NULL);
    }

    Tcl_AppendElement(interp, "-anchor");
    Tcl_AppendElement(interp, Tk_NameOfAnchor(slavePtr->anchor));
    Tcl_AppendElement(interp, "-bordermode");
    Tcl_AppendElement(interp, borderModeStrings[slavePtr->borderMode]);
    return TCL_OK;
}
Beispiel #26
0
// OutputListElement:
//	Adds an item to the result list.
void animTcl::OutputListElement(char * format, ...)
{
	va_list vl;

	//  format is the last argument specified; all
	//  others must be accessed using the variable-argument macros.
	va_start( vl, format);   
	static char message[1024];
	vsprintf(message,format,vl);
	va_end( vl );

	int len = (int) strlen(message);
	assert( len < 1024); // Exceeded internal print buffer.

	Tcl_AppendElement(m_interpreter,message);
}
Beispiel #27
0
/* Return list of timers. */
void list_timers(Tcl_Interp *irp, tcl_timer_t *stack)
{
  char mins[10], id[16], *x;
  EGG_CONST char *argv[3];
  tcl_timer_t *mark;

  for (mark = stack; mark; mark = mark->next) {
    egg_snprintf(mins, sizeof mins, "%u", mark->mins);
    egg_snprintf(id, sizeof id, "timer%lu", mark->id);
    argv[0] = mins;
    argv[1] = mark->cmd;
    argv[2] = id;
    x = Tcl_Merge(3, argv);
    Tcl_AppendElement(irp, x);
    Tcl_Free((char *) x);
  }
}
Beispiel #28
0
static void filedb_getdirs(Tcl_Interp * irp, char *dir)
{
  FILE *f;
  filedb fdb;

  f = filedb_open(dir, 0);
  if (!f)
    return;
  rewind(f);
  while (!feof(f)) {
    fread(&fdb, sizeof(filedb), 1, f);
    if (!feof(f)) {
      if ((!(fdb.stat & FILE_UNUSED)) && (fdb.stat & FILE_DIR))
	Tcl_AppendElement(irp, fdb.filename);
    }
  }
  filedb_close(f);
}
Beispiel #29
0
static int tcl_strip(ClientData cd, Tcl_Interp *irp,
                     int argc, char *argv[])
{
  int i, j, pls, arg;
  module_entry *me;

  BADARGS(2, 4, " idx ?strip-flags?");

  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] != '+') && (argv[arg][0] != '-'))
      dcc[i].u.chat->strip_flags = 0;
    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->strip_flags |= stripmodes(s);
        else
          dcc[i].u.chat->strip_flags &= ~stripmodes(s);
      }
    }
  }
  Tcl_AppendElement(irp, stripmasktype(dcc[i].u.chat->strip_flags));
  /* Console autosave. */
  if (argc > 2 && (me = module_find("console", 1, 1))) {
    Function *func = me->funcs;

    (func[CONSOLE_DOSTORE]) (i);
  }
  return TCL_OK;
}
Beispiel #30
0
static void filedb_getdirs(Tcl_Interp *irp, char *dir)
{
    FILE *fdb;
    filedb_entry *fdbe;

    fdb = filedb_open(dir, 0);
    if (!fdb)
        return;
    filedb_readtop(fdb, NULL);
    while (!feof(fdb)) {
        fdbe = filedb_getfile(fdb, ftell(fdb), GET_FILENAME);
        if (fdbe) {
            if ((!(fdbe->stat & FILE_UNUSED)) && (fdbe->stat & FILE_DIR))
                Tcl_AppendElement(irp, fdbe->filename);
            free_fdbe(&fdbe);
        }
    }
    filedb_close(fdb);
}