Re: [tkined] Question about object-type DEFVAL

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Thu, 18 Mar 1999 16:21:51 +0100

>>>>> Peder Chr Norgaard writes:

>> I actually think that your proposal is the better solution, but it
>> will take more time to implement, document and test your solution.

Peder> I agree with you on both assertions in this last paragraph :-)

Peder> so the decision is really just for you to make. I can live
Peder> very well with both solutions.

I will look into the source code and the test suite over the weekend.
For now, you may want to try the following little patch which changes
the implementation for the Tnm::mib defval command.

Juergen

diff -u -r1.22 tnmMibTcl.c
--- tnmMibTcl.c 1998/10/28 15:36:21 1.22
+++ tnmMibTcl.c 1999/03/18 15:02:46
@@ -929,8 +899,8 @@
}

case cmdDefval:
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "node");
+ if (objc < 3 || objc > 4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "node ?varName?");
return TCL_ERROR;
}
nodePtr = GetMibNode(interp, objv[2], NULL, NULL);
@@ -940,7 +910,21 @@
if (nodePtr->macro == TNM_MIB_OBJECTTYPE && nodePtr->index
&& nodePtr->syntax != ASN1_SEQUENCE_OF
&& nodePtr->syntax != ASN1_SEQUENCE) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp), nodePtr->index, -1);
+ result = nodePtr->index;
+ }
+ if (objc == 4) {
+ if (result) {
+ if (Tcl_ObjSetVar2(interp, objv[3], NULL,
+ Tcl_NewStringObj(result, -1),
+ TCL_LEAVE_ERR_MSG | TCL_PARSE_PART1) == NULL) {
+ return TCL_ERROR;
+ }
+ }
+ Tcl_SetIntObj(Tcl_GetObjResult(interp), result != NULL);
+ } else {
+ if (result) {
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), result, -1);
+ }
}
break;

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.