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

📄 dsa_control.c

📁 ftam等标准协议服务器和客户端的源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* dsa_control.c - write-only attribute for dsa console. SPT */#ifndef	lintstatic char *rcsid = "$Header: /xtel/isode/isode/dsap/common/RCS/dsa_control.c,v 9.0 1992/06/16 12:12:39 isode Rel $";#endif/*  * $Header: /xtel/isode/isode/dsap/common/RCS/dsa_control.c,v 9.0 1992/06/16 12:12:39 isode Rel $ * * * $Log: dsa_control.c,v $ * Revision 9.0  1992/06/16  12:12:39  isode * Release 8.0 * *//* *				  NOTICE * *    Acquisition, use, and distribution of this module and related *    materials are subject to the restrictions of a license agreement. *    Consult the Preface in the User's Manual for the full terms of *    this agreement. * */#include <signal.h>#include "quipu/util.h"/* #include "quipu/dsa_control.h"*/#include "quipu/attr.h"#include "quipu/attrvalue.h"#include "psap.h"#include <errno.h>#ifdef  BSD42#include <sys/wait.h>#endif#include "quipu/syntaxes.h"extern struct qbuf        *str2qb() ;extern struct qbuf        *qb_cpy() ;static        PE          dsa_control_enc() ; static struct dsa_control * dsa_control_decode() ;	      int	  dsa_control_print() ;       struct dsa_control * dsa_control_cpy() ;	      int	  dsa_control_cmp() ;              void	  dsa_control_free();       struct dsa_control * str2dsa_control() ;static struct dsa_control * str2dsa_control_aux() ;static        PE          quipu_call_enc() ; static struct quipu_call *quipu_call_decode() ;	      int	  quipu_call_print() ;       struct quipu_call *quipu_call_cpy() ;	      int	  quipu_call_cmp() ;              void	  quipu_call_free();              void        auth_level_free() ;       struct quipu_call *str2quipu_call() ;static struct quipu_call *str2quipu_call_aux() ;static        int         op_list_print() ;static        int         ops_print() ;       struct op_list    *op_list_cpy() ;       struct ops        *ops_cpy() ;       struct chain_list *chain_list_cpy() ;       struct sub_ch_list *sub_ch_list_cpy() ;static        int         chain_list_print() ;static        int         sub_ch_list_print() ;dsa_control_syntax(){	(void) add_attribute_syntax 	  ("DSAControl",	   (IFP)dsa_control_enc,    (IFP)dsa_control_decode,/* Encoder and decoder */	   (IFP)str2dsa_control,	dsa_control_print,          /* parser, print */	   (IFP)dsa_control_cpy,    dsa_control_cmp,/* copy and compare */	   (IFP)dsa_control_free,	NULLCP,             /* structure_free, print - READOUT */	   NULLIFP,	TRUE );                     /* Approx matching, multiline output */}static PE dsa_control_enc (control_option)struct dsa_control * control_option;{PE ret_pe;        (void) encode_Quipu_DSAControl(&ret_pe,0,0,NULLCP,control_option);        return (ret_pe);}static struct dsa_control * dsa_control_decode (pe)PE pe;{struct dsa_control * dsa_controlptr;        if (decode_Quipu_DSAControl(pe,1,NULLIP,NULLVP,&dsa_controlptr) == NOTOK) {                return ((struct dsa_control *) NULL);        }        return (dsa_controlptr);}dsa_control_print (ps, dsa_controlptr, format)register PS ps;register struct dsa_control * dsa_controlptr;register int format;{        if (format == READOUT)	{		ps_printf(ps, "Write attribute only - No READ printing. SPT\n") ;		switch (dsa_controlptr->dsa_control_option)		{		  case(CONTROL_LOCKDSA):		  {		    if (dsa_controlptr->un.lockdsa->offset == DN_PRESENT)		    {		      ps_printf(ps, "Locked the EDB: ") ;		      dn_print(ps, dsa_controlptr->un.lockdsa->un.selectedDN, READOUT) ;		    }		    break ;		  }		  case(CONTROL_SETLOGLEVEL):		  {		    ps_printf(ps, "Set logging level to %s\n", qb2str(dsa_controlptr->un.setLogLevel)) ;		    break ;		  }		  case(CONTROL_REFRESH):		  {		    ps_printf(ps, "Refreshed the EDB ") ;		    dn_print(ps, dsa_controlptr->un.refresh->un.selectedDN,EDBOUT) ;		    ps_printf(ps, ".\n") ;		    break ;		  }		  case(CONTROL_STOPDSA):		  {		    ps_printf(ps, "Stopped the DSA.\n") ;		    break ;		  }		  case(CONTROL_UNLOCK):		  {		    if (dsa_controlptr->un.unlock->offset == DN_PRESENT)		    {		      ps_printf(ps, "Unlocked the EDB: ") ;		      dn_print(ps, dsa_controlptr->un.unlock->un.selectedDN, READOUT) ;		    }		    break ;		  }		  case(CONTROL_RESYNCH):		  {		    ps_printf(ps, "Resync-ed the EDB ") ;		    dn_print(ps, dsa_controlptr->un.resynch->un.selectedDN,EDBOUT) ;		    ps_printf(ps, ".\n") ;		    break ;		  }		  case(CONTROL_CHANGETAILOR):		  {		    ps_printf(ps, "Changed the tailorong to %s.\n", 			      qb2str(dsa_controlptr->un.changeTailor)) ;		    break ;		  }		  case(CONTROL_UPDATESLAVEEDBS):		  {		    ps_printf(ps, "Updated the EDBs with arg '%s'...\n",		    	      qb2str(dsa_controlptr->un.updateSlaveEDBs)) ;		    break ;		  }		}	}	else 	{		ps_printf(ps, "Write attribute only - No EDB printing. SPT\n") ;	}}static struct dsa_control * dsa_control_cpy (dsa_c_ptr)struct dsa_control * dsa_c_ptr ;{	struct dsa_control * new_item = (struct dsa_control *) malloc (sizeof (struct dsa_control)) ;	new_item->dsa_control_option = dsa_c_ptr->dsa_control_option ;	switch (dsa_c_ptr->dsa_control_option)	{	case (CONTROL_LOCKDSA):	{	        struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                                  malloc (sizeof (struct optional_dn)) ;		if (dsa_c_ptr->un.lockdsa->offset == EMPTYDN)		{		        tmp_opt_dn->offset = EMPTYDN ;			tmp_opt_dn->un.no_dn = NULL ;			new_item->un.lockdsa = tmp_opt_dn ;		}		else		  {		        tmp_opt_dn->offset = DN_PRESENT ;			tmp_opt_dn->un.selectedDN = dn_cpy(dsa_c_ptr->un.lockdsa->un.selectedDN) ;			new_item->un.lockdsa = tmp_opt_dn ;		}		break ;	}	case (CONTROL_SETLOGLEVEL):	{		new_item->un.setLogLevel = qb_cpy(dsa_c_ptr->un.setLogLevel) ;		break ;	}	case (CONTROL_REFRESH):	{	        struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                                  malloc (sizeof (struct optional_dn)) ;		if (dsa_c_ptr->un.refresh->offset == EMPTYDN)		{		        tmp_opt_dn->offset = EMPTYDN ;			tmp_opt_dn->un.no_dn = NULL ;			new_item->un.refresh = tmp_opt_dn ;		}		else		  {		        tmp_opt_dn->offset = DN_PRESENT ;			tmp_opt_dn->un.selectedDN = dn_cpy(dsa_c_ptr->un.refresh->un.selectedDN) ;			new_item->un.refresh = tmp_opt_dn ;		}		break ;	}	case (CONTROL_STOPDSA):	{		new_item->un.stopDSA = dsa_c_ptr->un.stopDSA ;		break ;	}	case (CONTROL_UNLOCK):	{	        struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                                  malloc (sizeof (struct optional_dn)) ;		if (dsa_c_ptr->un.unlock->offset == EMPTYDN)		{		        tmp_opt_dn->offset = EMPTYDN ;			tmp_opt_dn->un.no_dn = NULL ;			new_item->un.unlock = tmp_opt_dn ;		}		else		  {		        tmp_opt_dn->offset = DN_PRESENT ;			tmp_opt_dn->un.selectedDN = dn_cpy(dsa_c_ptr->un.unlock->un.selectedDN) ;			new_item->un.unlock = tmp_opt_dn ;		}		break ;	}	case (CONTROL_RESYNCH):	{	      new_item->un.resynch = (struct optional_dn *) 		                              malloc (sizeof (struct optional_dn)) ;		if (dsa_c_ptr->un.resynch->offset == EMPTYDN)		{			new_item->un.resynch->offset = EMPTYDN ;			new_item->un.resynch->un.no_dn = 0 ;		}		else		{			new_item->un.resynch->offset = DN_PRESENT ;			new_item->un.resynch->un.selectedDN = 			  dn_cpy( dsa_c_ptr->un.resynch->un.selectedDN ) ;		}		break ;	}	case (CONTROL_CHANGETAILOR):	{		new_item->un.changeTailor = qb_cpy(dsa_c_ptr->un.changeTailor) ;		break ;	}	case (CONTROL_UPDATESLAVEEDBS):	{		new_item->un.updateSlaveEDBs= qb_cpy(dsa_c_ptr->un.updateSlaveEDBs) ;		break ;	}	}	return(new_item) ;}/* ARGSUSED */intdsa_control_cmp(a, b)struct dsa_control *a, *b ;{	return (2) ;}void dsa_control_free(item_to_free)struct dsa_control * item_to_free ;{	switch (item_to_free->dsa_control_option)	{	case(CONTROL_SETLOGLEVEL):	{		qb_free(item_to_free->un.setLogLevel) ;		break ;	}	case(CONTROL_CHANGETAILOR):	{		qb_free(item_to_free->un.changeTailor) ;		break ;	}	case(CONTROL_UPDATESLAVEEDBS):	{		qb_free(item_to_free->un.updateSlaveEDBs) ;		break ;	}	case(CONTROL_LOCKDSA):	{		optional_dn_free(item_to_free->un.lockdsa) ;		break ;	}	case(CONTROL_UNLOCK):	{		optional_dn_free(item_to_free->un.unlock) ;		break ;	}	case(CONTROL_REFRESH):	{		optional_dn_free(item_to_free->un.refresh) ;		break ;	}	case(CONTROL_RESYNCH):	{		optional_dn_free(item_to_free->un.resynch) ;		break ;	}	}	free ((char *)item_to_free) ;}struct dsa_control * str2dsa_control (str)char * str;{struct dsa_control * the_item;        the_item = (struct dsa_control *) malloc (sizeof (struct dsa_control)) ;        if (str2dsa_control_aux(str, the_item) != (struct dsa_control *) 0 )                return (the_item);        free ((char *)the_item);        return ((struct dsa_control *) 0);}static struct dsa_control * str2dsa_control_aux (str, item)char * str ;struct dsa_control * item ;{/*	format: number $ string */        char * ptr_to_num, *ptr_to_string ;	ptr_to_num = str ;	while (!isdigit(*ptr_to_num))		ptr_to_num++ ;	ptr_to_string = ptr_to_num ;	switch ((*ptr_to_num) - '0' )	{	  case(CONTROL_LOCKDSA):	    {	      struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                              calloc (1, sizeof (struct optional_dn)) ;	      item->dsa_control_option = CONTROL_LOCKDSA ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		{		  tmp_opt_dn->offset = DN_PRESENT ;		  tmp_opt_dn->un.selectedDN = NULLDN ;		}	      else		{		  tmp_opt_dn->offset = DN_PRESENT ;		  if ((tmp_opt_dn->un.selectedDN = str2dn(ptr_to_string)) == NULLDN)		    return ((struct dsa_control *) 0) ;		}	      item->un.lockdsa = tmp_opt_dn ;	      break ;	    }	  case(CONTROL_SETLOGLEVEL):	    {	      item->dsa_control_option = CONTROL_SETLOGLEVEL ;	      ptr_to_string = ptr_to_num ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      item->un.setLogLevel = str2qb(ptr_to_string, strlen(ptr_to_string), 1) ;	      break ;	    }	  case(CONTROL_REFRESH):	    {	      struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                              calloc (1, sizeof (struct optional_dn)) ;	      item->dsa_control_option = CONTROL_REFRESH ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		{		  tmp_opt_dn->offset = DN_PRESENT ;		  tmp_opt_dn->un.selectedDN = NULLDN ;		}	      else		{		  tmp_opt_dn->offset = DN_PRESENT ;		  if ((tmp_opt_dn->un.selectedDN = str2dn(ptr_to_string)) == NULLDN)		    return ((struct dsa_control *) 0) ;		}	      item->un.refresh = tmp_opt_dn ;	      break ;	    }	  case(CONTROL_STOPDSA):	    {	      item->dsa_control_option = CONTROL_STOPDSA ;	      break ;	    }	  case(CONTROL_UNLOCK):	    {	      struct optional_dn * tmp_opt_dn = (struct optional_dn *) 		                              calloc (1, sizeof (struct optional_dn)) ;	      item->dsa_control_option = CONTROL_UNLOCK ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		{		  tmp_opt_dn->offset = DN_PRESENT ;		  tmp_opt_dn->un.selectedDN = NULLDN ;		}	      else		{		  tmp_opt_dn->offset = DN_PRESENT ;		  if ((tmp_opt_dn->un.selectedDN = str2dn(ptr_to_string)) == NULLDN)		    return ((struct dsa_control *) 0) ;		}	      item->un.unlock = tmp_opt_dn ;	      break ;	    }	  case(CONTROL_RESYNCH):	    {	      struct optional_dn * tmp_opt_dn = (struct optional_dn *) malloc (sizeof (struct optional_dn)) ;	      item->dsa_control_option = CONTROL_RESYNCH ;	      while (! ((*ptr_to_string == NULL) || (*ptr_to_string == '$')))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		{		  tmp_opt_dn->offset = DN_PRESENT ;		  tmp_opt_dn->un.selectedDN = NULLDN ;		}	      else		{		  tmp_opt_dn->offset = DN_PRESENT ;		  tmp_opt_dn->un.selectedDN = str2dn(ptr_to_string) ;		}	      item->un.resynch = tmp_opt_dn ;	      break ;	    }	  case(CONTROL_CHANGETAILOR):	    {	      item->dsa_control_option = CONTROL_CHANGETAILOR ;	      ptr_to_string = ptr_to_num ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      item->un.changeTailor = str2qb(ptr_to_string, strlen(ptr_to_string), 1) ;	      break ;	    }	  case(CONTROL_UPDATESLAVEEDBS):	    {	      item->dsa_control_option = CONTROL_UPDATESLAVEEDBS ;	      ptr_to_string = ptr_to_num ;	      while ((*ptr_to_string != NULL) && (*ptr_to_string != '$'))		ptr_to_string++ ;	      if (*ptr_to_string == NULL)		return ((struct dsa_control *) 0) ;	      ptr_to_string++ ;	      if (*ptr_to_string == NULL)

⌨️ 快捷键说明

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