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

📄 tcl_config.c

📁 网络数据管理协议的开发
💻 C
📖 第 1 页 / 共 2 页
字号:
/*                               -*- Mode: C -*-  * tcl_config.c *  * Description     : ndmpc Tcl config commands. *  * Copyright (c) 1996,1997 PDC, Network Appliance. All Rights Reserved. * * $Id: tcl_config.c,v 1.9 1998/05/26 03:51:54 tim Exp $ */#if !defined(lint) && !defined(SABER)static char rcsId[] __attribute__ ((unused)) = "@(#) $Id: tcl_config.c,v 1.9 1998/05/26 03:51:54 tim Exp $";#endif#include <tcl.h>#include <sys/types.h>#include "ndmp_common.h"#include "ndmpc.h"char	md5Challenge[64];/* * configGetHostInfoCmd *   Sends a ndmp_config_get_host_info request to the NDMP server. *   usage: config_get_host_info  * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */intconfigGetHostInfoCmd(void*			clientData,					 Tcl_Interp*	interp,					 int			argc,					 char*			argv[] __attribute__ ((unused))){	NdmpConnection						connection = (NdmpConnection)clientData;	ndmp_config_get_host_info_reply*	reply = 0;	int 								r;		if (argc != 1)	{		Tcl_SetResult(interp, "usage: config_get_host_info",					  TCL_STATIC);		return(TCL_ERROR);	}	r = ndmpSendRequest(connection, NDMP_CONFIG_GET_HOST_INFO, NDMP_NO_ERR,						0, (void*)&reply);	if (ndmpcCheckNdmpSend(interp, r,						   reply ? reply->error : 0))	{		ndmpFreeMessage(connection);		return(r < 0 ? TCL_ERROR : TCL_OK);	}	ndmpcTclAddToResult(interp, "hostname", reply->hostname);	ndmpcTclAddToResult(interp, "os_type", reply->os_type);	ndmpcTclAddToResult(interp, "os_vers", reply->os_vers);	ndmpcTclAddToResult(interp, "hostid", reply->hostid);	ndmpFreeMessage(connection);	return(TCL_OK);}/* * configGetConnectionTypeCmd *   Sends a ndmp_config_get_connection_type_request to the NDMP server. *   usage: config_get_connection_type  * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */intconfigGetConnectionTypeCmd(void*		clientData,						   Tcl_Interp*	interp,						   int			argc,						   char*		argv[] __attribute__ ((unused))){	NdmpConnection						connection = (NdmpConnection)clientData;	ndmp_config_get_connection_type_reply*	reply = 0;	int 									r;	u_long									i;	Tcl_DString								list;		if (argc != 1)	{		Tcl_SetResult(interp, "usage: config_get_connection_type",					  TCL_STATIC);		return(TCL_ERROR);	}	r = ndmpSendRequest(connection, NDMP_CONFIG_GET_CONNECTION_TYPE, NDMP_NO_ERR,						0, (void*)&reply);	if (ndmpcCheckNdmpSend(interp, r,						   reply ? reply->error : 0))	{		ndmpFreeMessage(connection);		return(r < 0 ? TCL_ERROR : TCL_OK);	}	Tcl_DStringInit(&list);	for (i = 0; i < reply->addr_types.addr_types_len; i++)	{		char		*type;		switch (reply->addr_types.addr_types_val[i])		{			case NDMP_ADDR_LOCAL:				type = "LOCAL ";				break;			case NDMP_ADDR_TCP:				type = "TCP ";				break;			case NDMP_ADDR_FC:				type = "FC ";				break;			case NDMP_ADDR_IPC:				type = "IPC ";				break;			default:				type = "Unknown ";				break;		}				Tcl_DStringStartSublist(&list);		Tcl_DStringAppend(&list, type, -1);		Tcl_DStringEndSublist(&list);	}		ndmpcTclAddToResult(interp, "addr_types", Tcl_DStringValue(&list));	Tcl_DStringFree(&list);		ndmpFreeMessage(connection);	return(TCL_OK);}/* * configGetAuthAttrCmd *   Sends a ndmp_config_get_auth_attr_request to the NDMP server. *   usage: config_get_auth_attr none|text|md5  * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */intconfigGetAuthAttrCmd(void*			clientData,					 Tcl_Interp*	interp,					 int			argc,					 char*			argv[] __attribute__ ((unused))){	NdmpConnection						connection = (NdmpConnection)clientData;	ndmp_config_get_auth_attr_request	request;	ndmp_config_get_auth_attr_reply*	reply = 0;	int 								r;		if (argc != 2)	{		Tcl_SetResult(interp, "usage: config_get_auth_attr none|text|md5",					  TCL_STATIC);		return(TCL_ERROR);	}	if (strcmp(argv[1], "none") == 0)		request.auth_type = NDMP_AUTH_NONE;	else if (strcmp(argv[1], "text") == 0)		request.auth_type = NDMP_AUTH_TEXT;	else if (strcmp(argv[1], "md5") == 0)		request.auth_type = NDMP_AUTH_MD5;	else	{		Tcl_SetResult(interp, "usage: config_get_auth_attr none|text|md5",					  TCL_STATIC);		return(TCL_ERROR);	}		r = ndmpSendRequest(connection, NDMP_CONFIG_GET_AUTH_ATTR, NDMP_NO_ERR,						(void*)&request, (void*)&reply);	if (ndmpcCheckNdmpSend(interp, r,						   reply ? reply->error : 0))	{		ndmpFreeMessage(connection);		return(r < 0 ? TCL_ERROR : TCL_OK);	}	switch (reply->server_attr.auth_type)	{		case NDMP_AUTH_NONE:			ndmpcTclAddToResult(interp, "auth_type", "NONE");			break;		case NDMP_AUTH_TEXT:			ndmpcTclAddToResult(interp, "auth_type", "TEXT");			break;					case NDMP_AUTH_MD5:			ndmpcTclAddToResult(interp, "auth_type", "MD5");			ndmpcTclAddHexToResult(interp, "challenge",								   reply->server_attr.ndmp_auth_attr_u.challenge,								   64);			memcpy(md5Challenge, reply->server_attr.ndmp_auth_attr_u.challenge,				   64);			break;	}		ndmpFreeMessage(connection);	return(TCL_OK);}/* * configGetButypeInfoCmd *   Sends a ndmp_config_get_butype_info_request to the NDMP server. *   usage: config_get_butype_info * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */intconfigGetButypeInfoCmd(void*		clientData,					   Tcl_Interp*	interp,					   int			argc,					   char*		argv[] __attribute__ ((unused))){	NdmpConnection						connection = (NdmpConnection)clientData;	ndmp_config_get_butype_info_reply*	reply = 0;	int 								r;	char								buf[16];	ndmp_butype_info*					info;	ndmp_pval*							pval;	u_long								i;	u_long								j;	Tcl_DString							list;		if (argc != 1)	{		Tcl_SetResult(interp, "usage: config_get_butype_info",					  TCL_STATIC);		return(TCL_ERROR);	}	r = ndmpSendRequest(connection, NDMP_CONFIG_GET_BUTYPE_INFO, NDMP_NO_ERR,						0, (void*)&reply);	if (ndmpcCheckNdmpSend(interp, r,						   reply ? reply->error : 0))	{		ndmpFreeMessage(connection);		return(r < 0 ? TCL_ERROR : TCL_OK);	}	for (i = 0; i < reply->butype_info.butype_info_len; i++)	{		info = &reply->butype_info.butype_info_val[i];				ndmpcTclAddToResult(interp, "butype_name", info->butype_name);		sprintf(buf, "0x%lx", info->attrs);		ndmpcTclAddToResult(interp, "attrs", buf);		Tcl_DStringInit(&list);		for (j = 0; j < info->default_env.default_env_len; j++)		{			pval = &info->default_env.default_env_val[j];			Tcl_DStringStartSublist(&list);			Tcl_DStringAppend(&list, pval->name, -1);			Tcl_DStringAppendElement(&list, pval->value);			Tcl_DStringEndSublist(&list);		}				ndmpcTclAddToResult(interp, "default_env", Tcl_DStringValue(&list));		Tcl_DStringFree(&list);	}		ndmpFreeMessage(connection);	return(TCL_OK);}/* * configGetFsInfoCmd *   Sends a ndmp_config_get_fs_info_request to the NDMP server. *   usage: config_get_fs_info  * * Parameters: *   clientData (input) - connection handle. *   interp     (input) - Tcl interpreter. *   argc       (input) - argument count. *   argv       (input) - argument array. * * Returns: *   Tcl error code. */int

⌨️ 快捷键说明

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