Posted to tcl by de at Fri Feb 10 15:57:26 GMT 2023view raw

  1. #include <tcl.h>
  2.  
  3. #if TCL_MAJOR_VERSION == 8
  4. # define STUB_VERSION "8.6"
  5. #else
  6. # define STUB_VERSION "9"
  7. #endif
  8.  
  9. static int rdeCmd(
  10. void *clientData,
  11. Tcl_Interp *interp,
  12. int objc,
  13. Tcl_Obj *const objv[]
  14. )
  15. {
  16. size_t len;
  17.  
  18. if (objc != 2) {
  19. Tcl_WrongNumArgs (interp, 1, objv, "string");
  20. return TCL_ERROR;
  21. }
  22. Tcl_GetStringFromObj (objv[1], &len);
  23. Tcl_SetObjResult (interp, Tcl_NewWideIntObj(len));
  24. return TCL_OK;
  25. }
  26.  
  27. int Rde_Init(Tcl_Interp *interp) {
  28. if (Tcl_InitStubs(interp, STUB_VERSION, 0) == NULL) {
  29. return TCL_ERROR;
  30. }
  31. Tcl_CreateObjCommand(interp, "rde", rdeCmd, NULL, NULL);
  32. return TCL_OK;
  33. }
  34.  
  35.