4 * This file contains a simple Tcl package "pkgb" 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.
13 * SCCS: @(#) pkgb.c 1.4 96/02/15 12:30:34
18 * Prototypes for procedures defined later in this file:
21 static int Pkgb_SubCmd _ANSI_ARGS_((ClientData clientData,
22 Tcl_Interp *interp, int argc, char **argv));
23 static int Pkgb_UnsafeCmd _ANSI_ARGS_((ClientData clientData,
24 Tcl_Interp *interp, int argc, char **argv));
27 *----------------------------------------------------------------------
31 * This procedure is invoked to process the "pkgb_sub" Tcl command.
32 * It expects two arguments and returns their difference.
35 * A standard Tcl result.
38 * See the user documentation.
40 *----------------------------------------------------------------------
44 Pkgb_SubCmd(dummy, interp, argc, argv)
45 ClientData dummy; /* Not used. */
46 Tcl_Interp *interp; /* Current interpreter. */
47 int argc; /* Number of arguments. */
48 char **argv; /* Argument strings. */
53 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
54 " num num\"", (char *) NULL);
57 if ((Tcl_GetInt(interp, argv[1], &first) != TCL_OK)
58 || (Tcl_GetInt(interp, argv[2], &second) != TCL_OK)) {
61 sprintf(interp->result, "%d", first - second);
66 *----------------------------------------------------------------------
70 * This procedure is invoked to process the "pkgb_unsafe" Tcl command.
71 * It just returns a constant string.
74 * A standard Tcl result.
77 * See the user documentation.
79 *----------------------------------------------------------------------
83 Pkgb_UnsafeCmd(dummy, interp, argc, argv)
84 ClientData dummy; /* Not used. */
85 Tcl_Interp *interp; /* Current interpreter. */
86 int argc; /* Number of arguments. */
87 char **argv; /* Argument strings. */
89 interp->result = "unsafe command invoked";
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 code = Tcl_PkgProvide(interp, "Pkgb", "2.3");
118 if (code != TCL_OK) {
121 Tcl_CreateCommand(interp, "pkgb_sub", Pkgb_SubCmd, (ClientData) 0,
122 (Tcl_CmdDeleteProc *) NULL);
123 Tcl_CreateCommand(interp, "pkgb_unsafe", Pkgb_UnsafeCmd, (ClientData) 0,
124 (Tcl_CmdDeleteProc *) NULL);
129 *----------------------------------------------------------------------
133 * This is a package initialization procedure, which is called
134 * by Tcl when this package is to be added to an unsafe interpreter.
142 *----------------------------------------------------------------------
146 Pkgb_SafeInit(interp)
147 Tcl_Interp *interp; /* Interpreter in which the package is
148 * to be made available. */
150 Tcl_CreateCommand(interp, "pkgb_sub", Pkgb_SubCmd, (ClientData) 0,
151 (Tcl_CmdDeleteProc *) NULL);