Posted to tcl by mjanssen at Thu Sep 21 11:48:24 GMT 2006view pretty
#include <tcl.h> typedef struct ShapeFile { Tcl_Obj * filename; /* the name of the shape filem */ Tcl_Channel chan; /* the channel to the openend shape file */ } ShapeFile; static int ShpObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { ShapeFile *shp = (ShapeFile*)clientData; Tcl_SetObjResult(interp, shp->filename); return TCL_OK; } static int ShpShpCmd ( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { char *cmdName; ShapeFile *shp; shp = (ShapeFile*)Tcl_Alloc(sizeof(*shp)); shp->chan = NULL; shp->filename = NULL; cmdName = Tcl_GetStringFromObj(objv[1], 0); shp->filename = Tcl_DuplicateObj(objv[2]); Tcl_CreateObjCommand(interp, cmdName, ShpObjCmd, shp, NULL); return TCL_OK; } __declspec(dllexport) int Hello_Init(Tcl_Interp *interp) { /* we want to use stubs */ if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } Tcl_CreateObjCommand(interp, "shp", ShpShpCmd, NULL, NULL); Tcl_PkgProvide(interp, "Hello", "1.0"); return TCL_OK; }