Changeset 3394 for trunk/packages/vizservers/nanovis/Command.cpp
- Timestamp:
- Feb 28, 2013, 11:37:18 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r3378 r3394 758 758 { 759 759 Tcl_DString ds; 760 Tcl_Obj *objPtr, *listObjPtr, **items; 760 761 int result; 761 int i, numElems; 762 Tcl_Obj **elems; 762 int i, numItems, length; 763 763 char buf[BUFSIZ]; 764 const char *string; 764 765 static int first = 1; 765 766 … … 781 782 } 782 783 #endif 784 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); 785 Tcl_IncrRefCount(listObjPtr); 786 if (first) { 787 first = false; 788 objPtr = Tcl_NewStringObj("render_start", 12); 789 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 790 /* server */ 791 objPtr = Tcl_NewStringObj("server", 6); 792 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 793 objPtr = Tcl_NewStringObj("nanovis", 7); 794 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 795 /* pid */ 796 objPtr = Tcl_NewStringObj("pid", 3); 797 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 798 Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(getpid())); 799 /* machine */ 800 objPtr = Tcl_NewStringObj("machine", 7); 801 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 802 gethostname(buf, BUFSIZ-1); 803 buf[BUFSIZ-1] = '\0'; 804 objPtr = Tcl_NewStringObj(buf, -1); 805 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 806 } else { 807 objPtr = Tcl_NewStringObj("render_info", 11); 808 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 809 } 783 810 Tcl_DStringInit(&ds); 784 if (first) {785 Tcl_DStringAppendElement(&ds, "render_start");786 first = 0;787 } else {788 Tcl_DStringAppendElement(&ds, "render_info");789 }790 /* renderer */791 Tcl_DStringAppendElement(&ds, "renderer");792 Tcl_DStringAppendElement(&ds, "nanovis");793 /* pid */794 Tcl_DStringAppendElement(&ds, "pid");795 sprintf(buf, "%d", getpid());796 Tcl_DStringAppendElement(&ds, buf);797 /* host */798 Tcl_DStringAppendElement(&ds, "host");799 gethostname(buf, BUFSIZ-1);800 buf[BUFSIZ-1] = '\0';801 Tcl_DStringAppendElement(&ds, buf);802 811 /* date */ 803 Tcl_ DStringAppendElement(&ds, "date");812 Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("date", 4)); 804 813 strcpy(buf, ctime(&NanoVis::startTime.tv_sec)); 805 814 buf[strlen(buf) - 1] = '\0'; 806 Tcl_ DStringAppendElement(&ds, buf);815 Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(buf, -1)); 807 816 /* date_secs */ 808 Tcl_DStringAppendElement(&ds, "date_secs"); 809 sprintf(buf, "%ld", NanoVis::startTime.tv_sec); 810 Tcl_DStringAppendElement(&ds, buf); 817 Tcl_ListObjAppendElement(interp, listObjPtr, 818 Tcl_NewStringObj("date_secs", 9)); 819 Tcl_ListObjAppendElement(interp, listObjPtr, 820 Tcl_NewLongObj(NanoVis::startTime.tv_sec)); 811 821 /* Client arguments. */ 812 if (Tcl_ListObjGetElements(interp, objv[1], &num Elems, &elems) != TCL_OK) {822 if (Tcl_ListObjGetElements(interp, objv[1], &numItems, &items) != TCL_OK) { 813 823 return TCL_ERROR; 814 824 } 815 for (i = 0; i < numElems; i++) { 816 Tcl_DStringAppendElement(&ds, Tcl_GetString(elems[i])); 817 } 825 for (i = 0; i < numItems; i++) { 826 Tcl_ListObjAppendElement(interp, listObjPtr, items[i]); 827 } 828 Tcl_DStringInit(&ds); 829 string = Tcl_GetStringFromObj(listObjPtr, &length); 830 Tcl_DStringAppend(&ds, string, length); 818 831 Tcl_DStringAppend(&ds, "\n", 1); 819 820 832 #ifdef KEEPSTATS 821 833 result = NanoVis::writeToStatsFile(f, Tcl_DStringValue(&ds), … … 825 837 #endif 826 838 Tcl_DStringFree(&ds); 839 Tcl_DecrRefCount(listObjPtr); 827 840 return result; 828 841 }
Note: See TracChangeset
for help on using the changeset viewer.