home *** CD-ROM | disk | FTP | other *** search
/ Practical Programming in Tcl & Tk (4th Edition) / TCLBOOK4.BIN / pc / exsource.old / 45_10.c < prev    next >
C/C++ Source or Header  |  2003-04-15  |  663b  |  32 lines

  1. /*
  2.  * Example 45-10
  3.  * The BlobNames procedure.
  4.  */
  5.  
  6. int
  7. BlobNames(Tcl_Interp *interp, BlobState *statePtr)
  8. {
  9.     Tcl_HashEntry *entryPtr;
  10.     Tcl_HashSearch search;
  11.     Tcl_Obj *listPtr;
  12.     Tcl_Obj *objPtr;
  13.     char *name;
  14.     /*
  15.      * Walk the hash table and build a list of names.
  16.      */
  17.     listPtr = Tcl_NewListObj(0, NULL);
  18.     entryPtr = Tcl_FirstHashEntry(&statePtr->hash, &search);
  19.     while (entryPtr != NULL) {
  20.         name = Tcl_GetHashKey(&statePtr->hash, entryPtr);
  21.         if (Tcl_ListObjAppendElement(interp, listPtr, 
  22.                 Tcl_NewStringObj(name, -1)) != TCL_OK) {
  23.             return TCL_ERROR;
  24.         }
  25.         entryPtr = Tcl_NextHashEntry(&search);
  26.     }
  27.     Tcl_SetObjResult(interp, listPtr);
  28.     return TCL_OK;
  29. }
  30.  
  31.  
  32.