Overview
| Artifact ID: | 89886687e9dfa0c09a72020680bab8af2e450b76 |
|---|---|
| Ticket: | 502197ffffffffffffffffffffffffffffffffff |
| Date: | 2004-01-15 15:57:59 |
| User: | davygrvy |
| Artifact Attached: | 2d84ad589f97e2bc8f0245bdf37d0d5d910f8f54 |
| Filename: | test.c |
| Description: | test extension that shows the problems. |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95#define USE_TCL_STUBS #include <tclInt.h> #include <windows.h> Tcl_ObjCmdProc GetEnvObjCmd; Tcl_ObjCmdProc SetEnvObjCmd; Tcl_ObjCmdProc WGetEnvObjCmd; Tcl_ObjCmdProc WSetEnvObjCmd; Tcl_ObjCmdProc TGetEnvObjCmd; Tcl_ObjCmdProc TSetEnvObjCmd; #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT EXTERN int Test_Init (Tcl_Interp *interp) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { return TCL_ERROR; } Tcl_CreateObjCommand(interp, "getenv", GetEnvObjCmd, 0L, 0L); Tcl_CreateObjCommand(interp, "setenv", SetEnvObjCmd, 0L, 0L); Tcl_CreateObjCommand(interp, "wgetenv", WGetEnvObjCmd, 0L, 0L); Tcl_CreateObjCommand(interp, "wsetenv", WSetEnvObjCmd, 0L, 0L); Tcl_CreateObjCommand(interp, "tgetenv", TGetEnvObjCmd, 0L, 0L); Tcl_CreateObjCommand(interp, "tsetenv", TSetEnvObjCmd, 0L, 0L); return TCL_OK; } int GetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { Tcl_SetObjResult(interp, Tcl_NewStringObj( getenv(Tcl_GetString(objv[1])), -1)); return TCL_OK; } int SetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { Tcl_DString ds; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, Tcl_GetString(objv[1]), -1); Tcl_DStringAppend(&ds, "=", -1); Tcl_DStringAppend(&ds, Tcl_GetString(objv[2]), -1); putenv(Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); return TCL_OK; } int WGetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { TCHAR buf[255]; GetEnvironmentVariable(Tcl_GetString(objv[1]), buf, 255); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } int WSetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { SetEnvironmentVariable(Tcl_GetString(objv[1]), Tcl_GetString(objv[2])); return TCL_OK; } int TGetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { Tcl_DString ds; TclGetEnv(Tcl_GetString(objv[1]), &ds); Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_DStringValue(&ds), -1)); Tcl_DStringFree(&ds); return TCL_OK; } int TSetEnvObjCmd(ClientData cData, Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]) { Tcl_DString ds; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, Tcl_GetString(objv[1]), -1); Tcl_DStringAppend(&ds, "=", -1); Tcl_DStringAppend(&ds, Tcl_GetString(objv[2]), -1); Tcl_PutEnv(Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); return TCL_OK; }
