summaryrefslogtreecommitdiffstats
path: root/unix/dltest/pkgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/dltest/pkgc.c')
-rw-r--r--unix/dltest/pkgc.c119
1 files changed, 65 insertions, 54 deletions
diff --git a/unix/dltest/pkgc.c b/unix/dltest/pkgc.c
index 9aac361..557f21b 100644
--- a/unix/dltest/pkgc.c
+++ b/unix/dltest/pkgc.c
@@ -1,35 +1,43 @@
-/*
+/*
* pkgc.c --
*
- * This file contains a simple Tcl package "pkgc" that is intended
- * for testing the Tcl dynamic loading facilities. It can be used
- * in both safe and unsafe interpreters.
+ * This file contains a simple Tcl package "pkgc" that is intended for
+ * testing the Tcl dynamic loading facilities. It can be used in both
+ * safe and unsafe interpreters.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: pkgc.c,v 1.3 1999/03/11 21:47:40 stanton Exp $
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
+
+#undef STATIC_BUILD
#include "tcl.h"
/*
+ * TCL_STORAGE_CLASS is set unconditionally to DLLEXPORT because the
+ * Pkgc_Init declaration is in the source file itself, which is only
+ * accessed when we are building a library.
+ */
+#undef TCL_STORAGE_CLASS
+#define TCL_STORAGE_CLASS DLLEXPORT
+
+/*
* Prototypes for procedures defined later in this file:
*/
-static int Pkgc_SubCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static int Pkgc_UnsafeCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+static int Pkgc_SubObjCmd(ClientData clientData,
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+static int Pkgc_UnsafeObjCmd(ClientData clientData,
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
/*
*----------------------------------------------------------------------
*
- * Pkgc_SubCmd --
+ * Pkgc_SubObjCmd --
*
- * This procedure is invoked to process the "pkgc_sub" Tcl command.
- * It expects two arguments and returns their difference.
+ * This procedure is invoked to process the "pkgc_sub" Tcl command. It
+ * expects two arguments and returns their difference.
*
* Results:
* A standard Tcl result.
@@ -41,24 +49,23 @@ static int Pkgc_UnsafeCmd _ANSI_ARGS_((ClientData clientData,
*/
static int
-Pkgc_SubCmd(dummy, interp, argc, argv)
- ClientData dummy; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Pkgc_SubObjCmd(
+ ClientData dummy, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
int first, second;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " num num\"", (char *) NULL);
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "num num");
return TCL_ERROR;
}
- if ((Tcl_GetInt(interp, argv[1], &first) != TCL_OK)
- || (Tcl_GetInt(interp, argv[2], &second) != TCL_OK)) {
+ if ((Tcl_GetIntFromObj(interp, objv[1], &first) != TCL_OK)
+ || (Tcl_GetIntFromObj(interp, objv[2], &second) != TCL_OK)) {
return TCL_ERROR;
}
- sprintf(interp->result, "%d", first - second);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(first - second));
return TCL_OK;
}
@@ -67,8 +74,8 @@ Pkgc_SubCmd(dummy, interp, argc, argv)
*
* Pkgc_UnsafeCmd --
*
- * This procedure is invoked to process the "pkgc_unsafe" Tcl command.
- * It just returns a constant string.
+ * This procedure is invoked to process the "pkgc_unsafe" Tcl command. It
+ * just returns a constant string.
*
* Results:
* A standard Tcl result.
@@ -80,13 +87,13 @@ Pkgc_SubCmd(dummy, interp, argc, argv)
*/
static int
-Pkgc_UnsafeCmd(dummy, interp, argc, argv)
- ClientData dummy; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+Pkgc_UnsafeObjCmd(
+ ClientData dummy, /* Not used. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- interp->result = "unsafe command invoked";
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("unsafe command invoked", -1));
return TCL_OK;
}
@@ -95,8 +102,8 @@ Pkgc_UnsafeCmd(dummy, interp, argc, argv)
*
* Pkgc_Init --
*
- * This is a package initialization procedure, which is called
- * by Tcl when this package is to be added to an interpreter.
+ * This is a package initialization procedure, which is called by Tcl
+ * when this package is to be added to an interpreter.
*
* Results:
* None.
@@ -107,24 +114,23 @@ Pkgc_UnsafeCmd(dummy, interp, argc, argv)
*----------------------------------------------------------------------
*/
-int
-Pkgc_Init(interp)
- Tcl_Interp *interp; /* Interpreter in which the package is
- * to be made available. */
+EXTERN int
+Pkgc_Init(
+ Tcl_Interp *interp) /* Interpreter in which the package is to be
+ * made available. */
{
int code;
- if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
+ if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "Pkgc", "1.7.2");
if (code != TCL_OK) {
return code;
}
- Tcl_CreateCommand(interp, "pkgc_sub", Pkgc_SubCmd, (ClientData) 0,
- (Tcl_CmdDeleteProc *) NULL);
- Tcl_CreateCommand(interp, "pkgc_unsafe", Pkgc_UnsafeCmd, (ClientData) 0,
- (Tcl_CmdDeleteProc *) NULL);
+ Tcl_CreateObjCommand(interp, "pkgc_sub", Pkgc_SubObjCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "pkgc_unsafe", Pkgc_UnsafeObjCmd, NULL,
+ NULL);
return TCL_OK;
}
@@ -133,8 +139,8 @@ Pkgc_Init(interp)
*
* Pkgc_SafeInit --
*
- * This is a package initialization procedure, which is called
- * by Tcl when this package is to be added to an unsafe interpreter.
+ * This is a package initialization procedure, which is called by Tcl
+ * when this package is to be added to a safe interpreter.
*
* Results:
* None.
@@ -145,15 +151,20 @@ Pkgc_Init(interp)
*----------------------------------------------------------------------
*/
-int
-Pkgc_SafeInit(interp)
- Tcl_Interp *interp; /* Interpreter in which the package is
- * to be made available. */
+EXTERN int
+Pkgc_SafeInit(
+ Tcl_Interp *interp) /* Interpreter in which the package is to be
+ * made available. */
{
- if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
+ int code;
+
+ if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
return TCL_ERROR;
}
- Tcl_CreateCommand(interp, "pkgc_sub", Pkgc_SubCmd, (ClientData) 0,
- (Tcl_CmdDeleteProc *) NULL);
+ code = Tcl_PkgProvide(interp, "Pkgc", "1.7.2");
+ if (code != TCL_OK) {
+ return code;
+ }
+ Tcl_CreateObjCommand(interp, "pkgc_sub", Pkgc_SubObjCmd, NULL, NULL);
return TCL_OK;
}