⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tclevent.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *---------------------------------------------------------------------- * * BgErrorDeleteProc -- * *	This procedure is associated with the "tclBgError" assoc data *	for an interpreter;  it is invoked when the interpreter is *	deleted in order to free the information assoicated with any *	pending error reports. * * Results: *	None. * * Side effects: *	Background error information is freed: if there were any *	pending error reports, they are cancelled. * *---------------------------------------------------------------------- */static voidBgErrorDeleteProc(clientData, interp)    ClientData clientData;	/* Pointer to ErrAssocData structure. */    Tcl_Interp *interp;		/* Interpreter being deleted. */{    ErrAssocData *assocPtr = (ErrAssocData *) clientData;    BgError *errPtr;    while (assocPtr->firstBgPtr != NULL) {	errPtr = assocPtr->firstBgPtr;	assocPtr->firstBgPtr = errPtr->nextPtr;	ckfree(errPtr->errorMsg);	ckfree(errPtr->errorInfo);	ckfree(errPtr->errorCode);	ckfree((char *) errPtr);    }    Tcl_CancelIdleCall(HandleBgErrors, (ClientData) assocPtr);    Tcl_EventuallyFree((ClientData) assocPtr, TCL_DYNAMIC);}/* *---------------------------------------------------------------------- * * Tcl_CreateExitHandler -- * *	Arrange for a given procedure to be invoked just before the *	application exits. * * Results: *	None. * * Side effects: *	Proc will be invoked with clientData as argument when the *	application exits. * *---------------------------------------------------------------------- */voidTcl_CreateExitHandler(proc, clientData)    Tcl_ExitProc *proc;		/* Procedure to invoke. */    ClientData clientData;	/* Arbitrary value to pass to proc. */{    ExitHandler *exitPtr;    exitPtr = (ExitHandler *) ckalloc(sizeof(ExitHandler));    exitPtr->proc = proc;    exitPtr->clientData = clientData;    exitPtr->nextPtr = firstExitPtr;    firstExitPtr = exitPtr;}/* *---------------------------------------------------------------------- * * Tcl_DeleteExitHandler -- * *	This procedure cancels an existing exit handler matching proc *	and clientData, if such a handler exits. * * Results: *	None. * * Side effects: *	If there is an exit handler corresponding to proc and clientData *	then it is cancelled;  if no such handler exists then nothing *	happens. * *---------------------------------------------------------------------- */voidTcl_DeleteExitHandler(proc, clientData)    Tcl_ExitProc *proc;		/* Procedure that was previously registered. */    ClientData clientData;	/* Arbitrary value to pass to proc. */{    ExitHandler *exitPtr, *prevPtr;    for (prevPtr = NULL, exitPtr = firstExitPtr; exitPtr != NULL;	    prevPtr = exitPtr, exitPtr = exitPtr->nextPtr) {	if ((exitPtr->proc == proc)		&& (exitPtr->clientData == clientData)) {	    if (prevPtr == NULL) {		firstExitPtr = exitPtr->nextPtr;	    } else {		prevPtr->nextPtr = exitPtr->nextPtr;	    }	    ckfree((char *) exitPtr);	    return;	}    }}/* *---------------------------------------------------------------------- * * Tcl_Exit -- * *	This procedure is called to terminate the application. * * Results: *	None. * * Side effects: *	All existing exit handlers are invoked, then the application *	ends. * *---------------------------------------------------------------------- */voidTcl_Exit(status)    int status;			/* Exit status for application;  typically				 * 0 for normal return, 1 for error return. */{    Tcl_Finalize();#ifdef TCL_MEM_DEBUG    if (tclMemDumpFileName != NULL) {	Tcl_DumpActiveMemory(tclMemDumpFileName);    }#endif    TclPlatformExit(status);}/* *---------------------------------------------------------------------- * * Tcl_Finalize -- * *	Runs the exit handlers to allow Tcl to clean up its state prior *	to being unloaded. Called by Tcl_Exit and when Tcl was dynamically *	loaded and is now being unloaded. * * Results: *	None. * * Side effects: *	Whatever the exit handlers do. Also frees up storage associated *	with the Tcl object type table. * *---------------------------------------------------------------------- */voidTcl_Finalize(){    ExitHandler *exitPtr;        /*     * Invoke exit handler first.     */    tclInExit = 1;    for (exitPtr = firstExitPtr; exitPtr != NULL; exitPtr = firstExitPtr) {	/*	 * Be careful to remove the handler from the list before invoking	 * its callback.  This protects us against double-freeing if the	 * callback should call Tcl_DeleteExitHandler on itself.	 */	firstExitPtr = exitPtr->nextPtr;	(*exitPtr->proc)(exitPtr->clientData);	ckfree((char *) exitPtr);    }    /*     * Now finalize the Tcl execution environment.  Note that this must be done     * after the exit handlers, because there are order dependencies.     */        TclFinalizeCompExecEnv();    TclFinalizeEnvironment();    TclpFinalize();    firstExitPtr = NULL;    tclInExit = 0;}/* *---------------------------------------------------------------------- * * TclInExit -- * *	Determines if we are in the middle of exit-time cleanup. * * Results: *	If we are in the middle of exiting, 1, otherwise 0. * * Side effects: *	None. * *---------------------------------------------------------------------- */intTclInExit(){    return tclInExit;}/* *---------------------------------------------------------------------- * * Tcl_VwaitCmd -- * *	This procedure is invoked to process the "vwait" Tcl command. *	See the user documentation for details on what it does. * * Results: *	A standard Tcl result. * * Side effects: *	See the user documentation. * *---------------------------------------------------------------------- */	/* ARGSUSED */intTcl_VwaitCmd(clientData, interp, argc, argv)    ClientData clientData;	/* Not used. */    Tcl_Interp *interp;		/* Current interpreter. */    int argc;			/* Number of arguments. */    char **argv;		/* Argument strings. */{    int done, foundEvent;    if (argc != 2) {	Tcl_AppendResult(interp, "wrong # args: should be \"",		argv[0], " name\"", (char *) NULL);	return TCL_ERROR;    }    if (Tcl_TraceVar(interp, argv[1],	    TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,	    VwaitVarProc, (ClientData) &done) != TCL_OK) {	return TCL_ERROR;    };    done = 0;    foundEvent = 1;    while (!done && foundEvent) {	foundEvent = Tcl_DoOneEvent(TCL_ALL_EVENTS);    }    Tcl_UntraceVar(interp, argv[1],	    TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,	    VwaitVarProc, (ClientData) &done);    /*     * Clear out the interpreter's result, since it may have been set     * by event handlers.     */    Tcl_ResetResult(interp);    if (!foundEvent) {	Tcl_AppendResult(interp, "can't wait for variable \"", argv[1],		"\":  would wait forever", (char *) NULL);	return TCL_ERROR;    }    return TCL_OK;}	/* ARGSUSED */static char *VwaitVarProc(clientData, interp, name1, name2, flags)    ClientData clientData;	/* Pointer to integer to set to 1. */    Tcl_Interp *interp;		/* Interpreter containing variable. */    char *name1;		/* Name of variable. */    char *name2;		/* Second part of variable name. */    int flags;			/* Information about what happened. */{    int *donePtr = (int *) clientData;    *donePtr = 1;    return (char *) NULL;}/* *---------------------------------------------------------------------- * * Tcl_UpdateCmd -- * *	This procedure is invoked to process the "update" Tcl command. *	See the user documentation for details on what it does. * * Results: *	A standard Tcl result. * * Side effects: *	See the user documentation. * *---------------------------------------------------------------------- */	/* ARGSUSED */intTcl_UpdateCmd(clientData, interp, argc, argv)    ClientData clientData;	/* Not used. */    Tcl_Interp *interp;		/* Current interpreter. */    int argc;			/* Number of arguments. */    char **argv;		/* Argument strings. */{    int flags;    if (argc == 1) {	flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;    } else if (argc == 2) {	if (strncmp(argv[1], "idletasks", strlen(argv[1])) != 0) {	    Tcl_AppendResult(interp, "bad option \"", argv[1],		    "\": must be idletasks", (char *) NULL);	    return TCL_ERROR;	}	flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;    } else {	Tcl_AppendResult(interp, "wrong # args: should be \"",		argv[0], " ?idletasks?\"", (char *) NULL);	return TCL_ERROR;    }    while (Tcl_DoOneEvent(flags) != 0) {	/* Empty loop body */    }    /*     * Must clear the interpreter's result because event handlers could     * have executed commands.     */    Tcl_ResetResult(interp);    return TCL_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -