4 * This file contains a simple Tcl package "pkgd" that is intended
5 * for testing the Tcl dynamic loading facilities. It can be used
6 * in both safe and unsafe interpreters.
8 * Copyright (c) 1995 Sun Microsystems, Inc.
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
19 * Prototypes for procedures defined later in this file:
22 static int Pkgd_SubObjCmd _ANSI_ARGS_((ClientData clientData,
23 Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]));
24 static int Pkgd_UnsafeObjCmd _ANSI_ARGS_((ClientData clientData,
25 Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]));
28 *----------------------------------------------------------------------
32 * This procedure is invoked to process the "pkgd_sub" Tcl command.
33 * It expects two arguments and returns their difference.
36 * A standard Tcl result.
39 * See the user documentation.
41 *----------------------------------------------------------------------
45 Pkgd_SubObjCmd(dummy, interp, objc, objv)
46 ClientData dummy; /* Not used. */
47 Tcl_Interp *interp; /* Current interpreter. */
48 int objc; /* Number of arguments. */
49 Tcl_Obj * CONST objv[]; /* Argument objects. */
54 Tcl_WrongNumArgs(interp, 1, objv, "num num");
57 if ((Tcl_GetIntFromObj(interp, objv[1], &first) != TCL_OK)
58 || (Tcl_GetIntFromObj(interp, objv[2], &second) != TCL_OK)) {
61 Tcl_SetObjResult(interp, Tcl_NewIntObj(first - second));
66 *----------------------------------------------------------------------
70 * This procedure is invoked to process the "pkgd_unsafe" Tcl command.
71 * It just returns a constant string.
74 * A standard Tcl result.
77 * See the user documentation.
79 *----------------------------------------------------------------------
83 Pkgd_UnsafeObjCmd(dummy, interp, objc, objv)
84 ClientData dummy; /* Not used. */
85 Tcl_Interp *interp; /* Current interpreter. */
86 int objc; /* Number of arguments. */
87 Tcl_Obj * CONST objv[]; /* Argument objects. */
89 Tcl_SetObjResult(interp, Tcl_NewStringObj("unsafe command invoked", -1));
94 *----------------------------------------------------------------------
98 * This is a package initialization procedure, which is called
99 * by Tcl when this package is to be added to an interpreter.
107 *----------------------------------------------------------------------
112 Tcl_Interp *interp; /* Interpreter in which the package is
113 * to be made available. */
117 if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
120 code = Tcl_PkgProvide(interp, "Pkgd", "7.3");
121 if (code != TCL_OK) {
124 Tcl_CreateObjCommand(interp, "pkgd_sub", Pkgd_SubObjCmd,
125 (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
126 Tcl_CreateObjCommand(interp, "pkgd_unsafe", Pkgd_UnsafeObjCmd,
127 (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
132 *----------------------------------------------------------------------
136 * This is a package initialization procedure, which is called
137 * by Tcl when this package is to be added to an unsafe interpreter.
145 *----------------------------------------------------------------------
149 Pkgd_SafeInit(interp)
150 Tcl_Interp *interp; /* Interpreter in which the package is
151 * to be made available. */
155 if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
158 code = Tcl_PkgProvide(interp, "Pkgd", "7.3");
159 if (code != TCL_OK) {
162 Tcl_CreateObjCommand(interp, "pkgd_sub", Pkgd_SubObjCmd, (ClientData) 0,
163 (Tcl_CmdDeleteProc *) NULL);