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

📄 dsa_control.c

📁 ftam等标准协议服务器和客户端的源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
		item->un.updateSlaveEDBs = str2qb("all", strlen("all"), 1) ;	      else		item->un.updateSlaveEDBs = str2qb(ptr_to_string, strlen(ptr_to_string), 1) ;	      break ;	    }	}	    	return (item) ;	}optional_dn_free(item_to_free)struct optional_dn * item_to_free ;{  if (item_to_free->offset == DN_PRESENT)    {      dn_free(item_to_free->un.selectedDN) ;    }  free ((char *)item_to_free) ;}quipu_call_syntax(){	(void) add_attribute_syntax 	  ("Call",	   (IFP)quipu_call_enc,    (IFP)quipu_call_decode,     /* Encoder and decoder */	   (IFP)str2quipu_call,	  quipu_call_print,      /* parser, print */	   (IFP)quipu_call_cpy,    quipu_call_cmp,        /* copy and compare */	   (IFP)quipu_call_free,	  NULLCP,               /* structure_free, print - READOUT */	   NULLIFP,	          TRUE );               /* Approx matching, multiline output */}static PE quipu_call_enc (control_option)struct quipu_call * control_option;{PE ret_pe;        (void) encode_Quipu_Call(&ret_pe,0,0,NULLCP,control_option);        return (ret_pe);}static struct quipu_call * quipu_call_decode (pe)PE pe;{struct quipu_call * quipu_callptr;        if (decode_Quipu_Call(pe,1,NULLIP,NULLVP,&quipu_callptr) == NOTOK) {                return ((struct quipu_call *) 0);        }        return (quipu_callptr);}struct quipu_call * str2quipu_call(str)char * str ;{  struct quipu_call * the_item ;  the_item = (struct quipu_call *) malloc (sizeof (struct quipu_call)) ;  if ((struct quipu_call *) str2quipu_call_aux(str, the_item) != (struct quipu_call *) 0 )    return (the_item);  free ((char *)the_item);  return ((struct quipu_call *) 0);}/* ARGSUSED */static struct quipu_call * str2quipu_call_aux(str, item)char * str ;struct quipu_call * item ;{  /* SPT: Forget it! The structure is horrible    and should be filled in by hand!             Read only structure. */  return((struct quipu_call *) 0) ;}intquipu_call_print(ps, item, format)PS ps ;struct quipu_call * item ;int format ;{    /* When the DSA exits, we do not want to print this out */    /* as it really is irrelevant info, not to be reloaded */    /* upon start up. */    if (format == EDBOUT)    	return ;    if (item->protocol == PROTOCOL_DAP)    {      ps_printf(ps, "\tProtocol = DAP\n") ;    }    else    if (item->protocol == PROTOCOL_DSP)    {      ps_printf(ps, "\tProtocol = DSP\n") ;    }    else    if (item->protocol == PROTOCOL_QUIPUDSP)    {      ps_printf(ps, "\tProtocol = Quipu DSP\n") ;    }    else    {      ps_printf(ps, "\tProtocol = Internet DSP\n") ;    }    ps_printf(ps, "\tAssociation ID = %d\n", item->assoc_id) ;    switch (item->authorizationLevel->parm)    {      case(AUTHLEVEL_NONE):      {	ps_print(ps, "\tAuth Level = NONE\n") ;	break ;      }      case(AUTHLEVEL_IDENTIFIED):      {	ps_print(ps, "\tAuth Level = Identified\n") ;	break ;      }      case(AUTHLEVEL_SIMPLE):      {	ps_print(ps, "\tAuth Level = Simple\n") ;	break ;      }      case(AUTHLEVEL_PROTECTED_SIMPLE):      {	ps_print(ps, "\tAuth Level = Protected Simple\n") ;	break ;      }      case(AUTHLEVEL_STRONG):      {	ps_print(ps, "\tAuth Level = Strong\n") ;	break ;      }    }    if (item->initiated_by_dsa == TRUE)    {      ps_print(ps, "\tInitialised by DSA.\n") ;    }    else    {      ps_print(ps, "\tNot initialised by DSA.\n") ;    }    ps_print(ps, "\tUsers DN = ") ;    dn_print(ps, item->usersDN, format) ;    ps_print(ps, "\n") ;    ps_printf(ps, "\tNet Address: %s\n", item->net_address) ;    ps_print(ps, "\tStart: ") ;    utcprint(ps, item->start_time, format) ;    ps_print(ps, "   Finish: ") ;    if (item->finish_time)    {      utcprint(ps, item->finish_time, format) ;    }    else    {      ps_print(ps, " <unknown>") ;    }    ps_print(ps, "\n\tPending Operations:\n") ;    op_list_print(ps, item->pending_ops, format) ;    ps_print(ps, "\tInvoked Operations:\n") ;    op_list_print(ps, item->invoked_ops, format) ;}static intop_list_print(ps, item, format)PS ps ;struct op_list * item ;int format ;{  while (item != (struct op_list *) 0)  {    ps_print(ps, "\t\tOperation List:\n") ;    ops_print(ps, item->operation_list, format) ;    item = item->next ;  }}static intops_print(ps, item, format)PS ps ;struct ops * item ;int format ;{  ps_printf(ps, "\t\t   Invoke_id %d, ", item->invoke_id) ;  ps_printf(ps, "Op Id. %d, ", item->operation_id) ;  dn_print(ps, item->base_object, format) ;  ps_print(ps, " Start: ") ;  utcprint(ps, item->start_time, format) ;  ps_print(ps, " Finish: ") ;  if (item->finish_time)  {    utcprint(ps, item->finish_time, format) ;  }  else  {    ps_print(ps, " <unknown> ") ;  }  ps_print(ps, " Chained Ops: ") ;  chain_list_print(ps, item->chained_ops, format) ;  ps_print(ps, "\n") ;}static intchain_list_print(ps, item, format)PS ps ;struct chain_list * item ;int format ;{  while (item != (struct chain_list *) 0)  {    sub_ch_list_print(ps, item->sub_chained_ops, format) ;    item = item->next ;    if (item != (struct chain_list *) 0)    {      ps_print(ps, " $ ") ;    }  }}/* ARGSUSED */static intsub_ch_list_print(ps, item, format)PS ps ;struct sub_ch_list * item ;int format ;{  ps_printf(ps, "%d, %d", item->assoc_id, item->invok_id) ;}struct quipu_call * quipu_call_cpy(item)struct quipu_call * item ;{  struct quipu_call * tmp_item = (struct quipu_call *) 0 ;  tmp_item = (struct quipu_call *) calloc (1, sizeof (struct quipu_call)) ;  tmp_item->protocol = item->protocol ;  tmp_item->assoc_id = item->assoc_id ;  if (item->authorizationLevel != (struct auth_level *) 0)  {    tmp_item->authorizationLevel = (struct auth_level *) malloc (sizeof (struct auth_level)) ;    tmp_item->authorizationLevel->parm = item->authorizationLevel->parm ;  }  tmp_item->initiated_by_dsa = item->initiated_by_dsa ;  tmp_item->usersDN = dn_cpy(item->usersDN) ;  tmp_item->net_address = strdup(item->net_address) ;  tmp_item->start_time = strdup(item->start_time) ;  if (item->finish_time)    tmp_item->finish_time = strdup(item->finish_time) ;  else    item->finish_time = (char *) 0 ;/*  tmp_item->net_address = strdup(item->net_address) ; */  tmp_item->pending_ops = op_list_cpy(item->pending_ops) ;  tmp_item->invoked_ops = op_list_cpy(item->invoked_ops) ;  return (tmp_item) ;}struct op_list * op_list_cpy(item)struct op_list * item ;{  struct op_list * new_item = (struct op_list *) 0 ;  struct op_list * tmp_item = (struct op_list *) 0 ;  while (item != (struct op_list *) 0)  {    tmp_item = (struct op_list *) malloc (sizeof (struct op_list)) ;    tmp_item->operation_list = ops_cpy(item->operation_list) ;    tmp_item->next = (struct op_list *) 0 ;    if (new_item == (struct op_list *) 0)    {      new_item = tmp_item ;    }    else    {      struct op_list * tmp = new_item ;      while (tmp->next != (struct op_list * ) 0)      {	tmp = tmp->next ;      }      tmp->next = tmp_item ;    }    item = item->next ;  }  return (new_item) ;}struct ops * ops_cpy(item)struct ops * item ;{  struct ops * tmp_item = (struct ops *) malloc (sizeof (struct ops)) ;  tmp_item->invoke_id = item->invoke_id ;  tmp_item->operation_id = item->operation_id ;  tmp_item->base_object = dn_cpy(item->base_object) ;  if (item->start_time)  {    tmp_item->start_time = strdup(item->start_time) ;  }  else  {    tmp_item->start_time = (char *) 0 ;  }  if (item->finish_time)  {    tmp_item->finish_time = strdup(item->finish_time) ;  }  else  {    tmp_item->finish_time = (char *) 0 ;  }/*  if (item->start_time)  {    tmp_item->start_time = malloc (strlen(item->start_time)+1) ;    (void) strcpy(tmp_item->start_time, item->start_time) ;  }  else  {    tmp_item->start_time = (char *) 0 ;  }  if (item->finish_time)  {    tmp_item->finish_time = malloc (strlen(item->finish_time)+1) ;    (void) strcpy(tmp_item->finish_time, item->finish_time) ;  }  else  {    tmp_item->finish_time = (char *) 0 ;  } */  tmp_item->chained_ops = chain_list_cpy(item->chained_ops) ;  return (tmp_item) ;}struct chain_list *chain_list_cpy(item)struct chain_list * item ; {   struct chain_list * new_item = (struct chain_list *) 0 ;   struct chain_list * tmp_item = (struct chain_list *) 0 ;  while (item != (struct chain_list *) 0)  {    tmp_item = (struct chain_list *) malloc (sizeof (struct chain_list)) ;    tmp_item->sub_chained_ops = sub_ch_list_cpy(item->sub_chained_ops) ;    tmp_item->next = (struct chain_list *) 0 ;    if (new_item == (struct chain_list *) 0)    {      new_item = tmp_item ;    }    else    {      struct chain_list * tmp = new_item ;      while (tmp->next != (struct chain_list * ) 0)      {	tmp = tmp->next ;      }      tmp->next = tmp_item ;    }    item = item->next ;  }  return (new_item) ;}struct sub_ch_list *sub_ch_list_cpy(item)struct sub_ch_list *item ;{  struct sub_ch_list *new_item = (struct sub_ch_list *) malloc (sizeof (struct sub_ch_list)) ;  new_item->assoc_id = item->assoc_id ;  new_item->invok_id = item->invok_id ;  return (new_item) ;}/* ARGSUSED */intquipu_call_cmp(a, b)struct quipu_call *a, *b ;{	return (2) ;}voidquipu_call_free(item_to_free)struct quipu_call * item_to_free ;{    if (item_to_free->authorizationLevel)      auth_level_free(item_to_free->authorizationLevel) ;    if (item_to_free->usersDN)      dn_free(item_to_free->usersDN) ;    if (item_to_free->net_address)      free((char *)item_to_free->net_address) ;    if (item_to_free->start_time)      free((char *)item_to_free->start_time) ;    if (item_to_free->finish_time)      free((char *)item_to_free->finish_time) ;/*    if (item_to_free->net_address)      free((char *)item_to_free->net_address) ;    if (item_to_free->start_time)      free((char *)item_to_free->start_time) ;    if (item_to_free->finish_time)      free((char *)item_to_free->finish_time) ; */    if (item_to_free->pending_ops)      op_list_free(item_to_free->pending_ops) ;    if (item_to_free->invoked_ops)      op_list_free(item_to_free->invoked_ops) ;    free((char *)item_to_free) ;}intop_list_free(elem)struct op_list * elem ;{  struct op_list * tmp_elem ;  while (elem != (struct op_list *) 0)  {    tmp_elem = elem ;    ops_free (tmp_elem->operation_list) ;    elem = tmp_elem->next ;    free ((char *)tmp_elem) ;  }}intops_free(elem)struct ops * elem ;{  dn_free(elem->base_object) ;  if (elem->start_time)    free((char *)elem->start_time) ;  if (elem->finish_time)    free((char *)elem->finish_time) ;/*  if (elem->start_time)    free((char *)elem->start_time) ;  if (elem->finish_time)    free((char *)elem->finish_time) ;*/  if (elem->chained_ops)    chain_list_free(elem->chained_ops) ;  free((char *)elem) ;}intchain_list_free(elem)struct chain_list * elem ;{  struct chain_list * tmp_elem ;    while (elem != (struct chain_list *) 0)  {    free((char *)elem->sub_chained_ops) ;    tmp_elem = elem ;    elem = elem->next ;    free((char *)tmp_elem) ;  }}voidauth_level_free(item)struct auth_level * item ;{	free((char *)item) ;}

⌨️ 快捷键说明

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