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

📄 notify.c

📁 网络数据管理协议的开发
💻 C
字号:
/*                               -*- Mode: C -*-  * notify.c *  * Description     : Notify request handlers. *  * Copyright (c) 1996,1997 PDC, Network Appliance. All Rights Reserved. * * $Id: notify.c,v 1.7 1998/02/16 21:08:11 tim Exp $ */#if !defined(lint) && !defined(SABER)static char rcsId[] __attribute__ ((unused)) = "@(#) $Id: notify.c,v 1.7 1998/02/16 21:08:11 tim Exp $";#endif#include <tcl.h>#include "ndmp_common.h"static Tcl_DString		notifyProc;static Tcl_Interp*		theInterp = 0;static voidcallNotifyProc(char*	message,			   u_long	arg);/* * addNotifyProcCmd *   Specifies the name of a Tcl procedure to call when a notify *   message is received. The procedure will be called with two arguments. *   The first argument will indicate the type of notify message *   received: "connected", "paused", or "halted". The second argument *   will be the protocol version for a connected message and the reason *   value for a paused or halted message. * *   usage: add_notify_proc proc-name * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */intaddNotifyProcCmd(void*			clientData __attribute__ ((unused)),				 Tcl_Interp*	interp,				 int			argc,				 char*			argv[]){	if (argc != 2)	{		Tcl_SetResult(interp, "usage: add_notify_proc proc-name",					  TCL_STATIC);		return(TCL_ERROR);	}		theInterp = interp;		Tcl_DStringInit(&notifyProc);	Tcl_DStringAppend(&notifyProc, argv[1], -1);		return(TCL_OK);}/* * notifyDataHalted *   ndmp_notify_data_halted_request message handler. * * Parameters: *   connection (input) - NDMP connection. *   msginfo    (input) - message. * * Returns: *   void */voidnotifyDataHalted(NdmpConnection	connection __attribute__ ((unused)),				 void*			body){	ndmp_notify_data_halted_request*	request =		(ndmp_notify_data_halted_request *)body;		char	*reason_str;	switch (request->reason)	{		case NDMP_DATA_HALT_NA:			reason_str = "NA";			break;		case NDMP_DATA_HALT_SUCCESSFUL:			reason_str = "SUCCESSFUL";			break;		case NDMP_DATA_HALT_ABORTED:			reason_str = "ABORTED";			break;		case NDMP_DATA_HALT_INTERNAL_ERROR:			reason_str = "INTERNAL_ERROR";			break;		case NDMP_DATA_HALT_CONNECT_ERROR:			reason_str = "CONNECT_ERROR";			break;		default:			reason_str = "Unknown";			break;	}	Log("Received notify_data_halted: reason:%s %s\n",		reason_str, request->text_reason);	callNotifyProc("data_halted", (u_long)request->reason);    return;}/* * notifyConnected *   notify_connected request message handler. * * Parameters: *   connection (input) - NDMP connection. *   msginfo    (input) - message. * * Returns: *   void */voidnotifyConnected(NdmpConnection	connection __attribute__ ((unused)),				void*			body){	ndmp_notify_connected_request*	request =		(ndmp_notify_connected_request *)body;		char	*reason_str;	switch (request->reason)	{		case NDMP_CONNECTED:			reason_str = "CONNECTED";			break;		case NDMP_SHUTDOWN:			reason_str = "SHUTDOWN";			break;		case NDMP_REFUSED:			reason_str = "REFUSED";			break;		default:			reason_str = "Unknown";			break;	}			    Log("Received notify_connected request: version:%d reason:%s %s\n",		(long)request->protocol_version, reason_str, request->text_reason);		callNotifyProc("connected", request->protocol_version);	    return;}/* * notifyMoverHalted *   ndmp_notify_mover_halted_request message handler. * * Parameters: *   connection (input) - NDMP connection. *   msginfo    (input) - message. * * Returns: *   void */voidnotifyMoverHalted(NdmpConnection	connection __attribute__ ((unused)),				  void*				body){	ndmp_notify_mover_halted_request*	request =		(ndmp_notify_mover_halted_request *)body;		char	*reason_str;	switch (request->reason)	{		case NDMP_MOVER_HALT_NA:			reason_str = "NA";			break;		case NDMP_MOVER_HALT_CONNECT_CLOSED:			reason_str = "CONNECT_CLOSED";			break;		case NDMP_MOVER_HALT_ABORTED:			reason_str = "ABORTED";			break;		case NDMP_MOVER_HALT_INTERNAL_ERROR:			reason_str = "INTERNAL_ERROR";			break;		case NDMP_MOVER_HALT_CONNECT_ERROR:			reason_str = "CONNECT_ERROR";			break;		default:			reason_str = "Unknown";			break;	}			    Log("Received notify_mover_halted: reason:%s %s\n",		reason_str, request->text_reason);		callNotifyProc("mover_halted", request->reason);    return;}/* * notifyMoverPaused *   ndmp_notify_mover_paused_request message handler. * * Parameters: *   connection (input) - NDMP connection. *   msginfo    (input) - message. * * Returns: *   void */voidnotifyMoverPaused(NdmpConnection	connection __attribute__ ((unused)),				  void*				body){	ndmp_notify_mover_paused_request*	request =		(ndmp_notify_mover_paused_request *)body;		char	*reason_str;	switch (request->reason)	{		case NDMP_MOVER_PAUSE_NA:			reason_str = "NA";			break;		case NDMP_MOVER_PAUSE_EOM:			reason_str = "EOM";			break;		case NDMP_MOVER_PAUSE_EOF:			reason_str = "EOF";			break;		case NDMP_MOVER_PAUSE_SEEK:			reason_str = "SEEK";			break;		case NDMP_MOVER_PAUSE_MEDIA_ERROR:			reason_str = "MEDIA_ERROR";			break;		case NDMP_MOVER_PAUSE_EOW:			reason_str = "EOW";			break;		default:			reason_str = "Unknown";			break;	}			    Log("Received notify_mover_paused: reason:%s seek:%lld\n",		reason_str,		quadToLongLong(request->seek_position));		callNotifyProc("mover_paused", request->reason);    return;}/* * notifyDataRead *   notify_data_read request message handler. * * Parameters: *   connection (input) - NDMP connection. *   msginfo    (input) - message. * * Returns: *   void */voidnotifyDataRead(NdmpConnection	connection __attribute__ ((unused)),			   void*			body){	ndmp_notify_data_read_request*	request =		(ndmp_notify_data_read_request *)body;	    Log("Received notify_data_read: offset:%llu len:%llu\n",		quadToLongLong(request->offset),		quadToLongLong(request->length));		callNotifyProc("data_read", 0);    return;}static voidcallNotifyProc(char*	message,			   u_long	arg){	char			argStr[32];		if (theInterp == 0)		return;	sprintf(argStr, "%lu", arg);	Tcl_VarEval(theInterp, Tcl_DStringValue(&notifyProc),				" ", message, " ", argStr, 0);}

⌨️ 快捷键说明

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