home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / tcl / tclsrc / c / WimpInfo < prev    next >
Encoding:
Text File  |  1996-03-14  |  1.5 KB  |  74 lines

  1. /* Wimp info commands for tcl */
  2. /* (c) C.T.Stretch */
  3. /* Sun 3rd March 1996 */
  4.  
  5. #include "h.WInt"
  6. #include "h.taskmanager"
  7.  
  8. /*
  9.  *  hashlist --
  10.  *      Returns a list of names from a hash table.
  11.  *
  12.  * Results:
  13.  *      returns TCL_OK.
  14.  *
  15.  * Side effects:
  16.  *      None.
  17.  *
  18. */
  19.  
  20. static int hashlist(Tcl_HashTable *t)
  21. { Tcl_HashEntry *e;
  22.   Tcl_HashSearch s;
  23.   for(e=Tcl_FirstHashEntry(t,&s);e;e=Tcl_NextHashEntry(&s))
  24.       Tcl_AppendElement(w_Interp,Tcl_GetHashKey(t,e));
  25.   return TCL_OK;
  26. }
  27.  
  28. /*
  29.  *  wimptasklist --
  30.  *      Returns a list of wimp tasks.
  31.  *
  32.  * Results:
  33.  *      A standard tcl result.
  34.  *
  35.  * Side effects:
  36.  *      None.
  37.  *
  38. */
  39.  
  40. static int wimptasklist(void)
  41. { os_error *e;
  42.   int c=0;
  43.   taskmanager_task t;
  44.   while(1)
  45.   { e=xtaskmanager_enumerate_tasks(c,&t,sizeof(taskmanager_task),&c,0);
  46.     if(c<0) return TCL_OK;
  47.     Tcl_AppendElement(w_Interp,t.name);
  48.   }
  49. }
  50.  
  51. /*
  52.  *  w_InfoCmd --
  53.  *      Implements the w_info command.
  54.  *
  55.  * Results:
  56.  *      A standard tcl result.
  57.  *
  58.  * Side effects:
  59.  *      None.
  60.  *
  61. */
  62.  
  63. int w_InfoCmd(ClientData dummy,Tcl_Interp *interp,int argc,char **argv)
  64. {
  65.   if(argc<2) return wrong(WNA,"w_info <option>");
  66.   if(!strcmp(argv[1],"templates")) return hashlist(&boxTable);
  67.   if(!strcmp(argv[1],"diagrams")) return hashlist(&diagramTable);
  68.   if(!strcmp(argv[1],"documents")) return hashlist(&documentTable);
  69.   if(!strcmp(argv[1],"tasks")) return hashlist(&taskTable);
  70.   if(!strcmp(argv[1],"wimptasks")) return wimptasklist();
  71.   return wrong("unknown w_info option: ",argv[1]);
  72. }
  73.  
  74.