os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/tclXtTest.c
Update contrib.
4 * Contains commands for Xt notifier specific tests on Unix.
6 * Copyright (c) 1997 by Sun Microsystems, Inc.
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * RCS: @(#) $Id: tclXtTest.c,v 1.5 2002/08/05 03:24:41 dgp Exp $
14 #include <X11/Intrinsic.h>
17 static int TesteventloopCmd _ANSI_ARGS_((ClientData clientData,
18 Tcl_Interp *interp, int argc, CONST char **argv));
19 extern void InitNotifier _ANSI_ARGS_((void));
23 *----------------------------------------------------------------------
27 * This procedure performs application-specific initialization.
28 * Most applications, especially those that incorporate additional
29 * packages, will have their own version of this procedure.
32 * Returns a standard Tcl completion code, and leaves an error
33 * message in the interp's result if an error occurs.
36 * Depends on the startup script.
38 *----------------------------------------------------------------------
42 Tclxttest_Init(interp)
43 Tcl_Interp *interp; /* Interpreter for application. */
45 if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
48 XtToolkitInitialize();
50 Tcl_CreateCommand(interp, "testeventloop", TesteventloopCmd,
51 (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
56 *----------------------------------------------------------------------
60 * This procedure implements the "testeventloop" command. It is
61 * used to test the Tcl notifier from an "external" event loop
62 * (i.e. not Tcl_DoOneEvent()).
65 * A standard Tcl result.
70 *----------------------------------------------------------------------
74 TesteventloopCmd(clientData, interp, argc, argv)
75 ClientData clientData; /* Not used. */
76 Tcl_Interp *interp; /* Current interpreter. */
77 int argc; /* Number of arguments. */
78 CONST char **argv; /* Argument strings. */
80 static int *framePtr = NULL; /* Pointer to integer on stack frame of
81 * innermost invocation of the "wait"
85 Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
86 " option ... \"", (char *) NULL);
89 if (strcmp(argv[1], "done") == 0) {
91 } else if (strcmp(argv[1], "wait") == 0) {
94 int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
97 * Save the old stack frame pointer and set up the current frame.
100 oldFramePtr = framePtr;
104 * Enter an Xt event loop until the flag changes.
105 * Note that we do not explicitly call Tcl_ServiceEvent().
110 XtAppProcessEvent(TclSetAppContext(NULL), XtIMAll);
112 (void) Tcl_SetServiceMode(oldMode);
113 framePtr = oldFramePtr;
115 Tcl_AppendResult(interp, "bad option \"", argv[1],
116 "\": must be done or wait", (char *) NULL);