4 * This file contains a simple Tcl package "pkgd" that is intended for
5 * testing the Tcl dynamic loading facilities. It can be used in both
6 * safe and unsafe interpreters.
8 * Copyright (c) 1995 Sun Microsystems, Inc.
10 * See the file "license.terms" for information on usage and redistribution of
11 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
18 * Prototypes for procedures defined later in this file:
21 static int Pkgd_SubObjCmd(ClientData clientData,
22 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
23 static int Pkgd_UnsafeObjCmd(ClientData clientData,
24 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
27 *----------------------------------------------------------------------
31 * This procedure is invoked to process the "pkgd_sub" Tcl command. It
32 * expects two arguments and returns their difference.
35 * A standard Tcl result.
38 * See the user documentation.
40 *----------------------------------------------------------------------
45 ClientData dummy, /* Not used. */
46 Tcl_Interp *interp, /* Current interpreter. */
47 int objc, /* Number of arguments. */
48 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. It
71 * just returns a constant string.
74 * A standard Tcl result.
77 * See the user documentation.
79 *----------------------------------------------------------------------
84 ClientData dummy, /* Not used. */
85 Tcl_Interp *interp, /* Current interpreter. */
86 int objc, /* Number of arguments. */
87 Tcl_Obj *const objv[]) /* Argument objects. */
93 Tcl_SetObjResult(interp, Tcl_NewStringObj("unsafe command invoked", -1));
98 *----------------------------------------------------------------------
102 * This is a package initialization procedure, which is called by Tcl
103 * when this package is to be added to an interpreter.
111 *----------------------------------------------------------------------
116 Tcl_Interp *interp) /* Interpreter in which the package is to be
121 if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
124 code = Tcl_PkgProvide(interp, "pkgd", "7.3");
125 if (code != TCL_OK) {
128 Tcl_CreateObjCommand(interp, "pkgd_sub", Pkgd_SubObjCmd, NULL, NULL);
129 Tcl_CreateObjCommand(interp, "pkgd_unsafe", Pkgd_UnsafeObjCmd, NULL,
135 *----------------------------------------------------------------------
139 * This is a package initialization procedure, which is called by Tcl
140 * when this package is to be added to a safe interpreter.
148 *----------------------------------------------------------------------
153 Tcl_Interp *interp) /* Interpreter in which the package is to be
158 if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
161 code = Tcl_PkgProvide(interp, "pkgd", "7.3");
162 if (code != TCL_OK) {
165 Tcl_CreateObjCommand(interp, "pkgd_sub", Pkgd_SubObjCmd, NULL, NULL);