modify.c

来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 1,375 行 · 第 1/3 页

C
1,375
字号
		curr_mod->em_what = as_comp_new(curr_attr->attr_type,						attrVal_seq,						NULLACL_INFO);	    }	    	  /* This attributes arguments set */	  attrVal_seq = NULLAV;	  	  if (curr_mod->em_type != 127)	    {	      entrymods = ems_append(entrymods, curr_mod);	      curr_mod = NULLMOD;	    }	  else	    ems_free(curr_mod);	}    }  if (entrymods == NULLMOD)    {      error = error_alloc();      error->next = NULLError;            error->baseobject = NULLCP;      error->error_type = QERR_no_mods_supplied;      error->ds_message = NULLCP;            return error;    }  (void) get_default_service(&mod_arg.mea_common);  mod_arg.mea_common.ca_servicecontrol.svc_options =    mod_arg.mea_common.ca_servicecontrol.svc_options | SVC_OPT_PREFERCHAIN;  mod_arg.mea_object = str2dn(baseobject);  mod_arg.mea_changes = entrymods;  if (_task_invoked(MODIFY_TASK, baseobject, request_id, &task_id) != QERR_ok)    {      error = error_alloc();      error->next = NULLError;            error->baseobject = NULLCP;      error->error_type = QERR_internal_limit_reached;      error->ds_message = NULLCP;            return error;    }  *task_id_ptr = task_id;  if (DapModifyEntry(dsap_ad, task_id, &mod_arg, &di, ROS_ASYNC) == NOTOK)    {      error = error_alloc();      error->next = NULLError;            error->baseobject = NULLCP;      error->error_type = QERR_internal;      error->ds_message = NULLCP;            return error;    }#ifndef NO_STATS  LLOG (log_stat, LLOG_NOTICE,        ("MODIFY +%s, task %d",         baseobject,         task_id));#endif  return NULLError;} /* start_modify *//* * - process_modify_ds_result() - * * *//* ARGSUSED */request_state process_modify_ds_result(request, task_id, ds_result)     requestRec request;     int task_id;     struct DSResult *ds_result;{  modifyRec modrec = request->MODIFY_REC;  /* This shouldn't happen */  if (_get_task_of_id(task_id) == NULLDsTask)    return RQ_processing;  modrec->result = modify_result_alloc();  modrec->result->was_successful = TRUE;  modrec->result->errors = NULLError;  return RQ_results_returned;} /* process_modify_ds_result *//* * - process_modify_ds_error() - * * */request_state process_modify_ds_error(request, task_id, ds_error)     requestRec request;     int task_id;     struct DSError *ds_error;{  DsTask task_rec;  modifyRec modrec = request->MODIFY_REC;  QE_error_code error_type;  /* This shouldn't happen */  if ((task_rec = _get_task_of_id(task_id)) == NULLDsTask)    return RQ_processing;  /* Save error and log it */  error_type = get_log_error_type(ds_error, task_id);  add_error_to_request_rec(request,			   task_rec->baseobject,			   error_type,			   ds_error);    modrec->result = modify_result_alloc();  modrec->result->was_successful = FALSE;  modrec->result->errors = request->errors;    request->errors = NULLError;  /* Remove invocation record for this task */  _task_complete(task_id);  return RQ_results_returned;  } /* process_modify_ds_error *//* *	Start of procedures for making entry templates. * * *//* * - get_modify_result() - * * */makeTemplateResult get_make_template_result(request_id)     QCardinal request_id;{  requestRec request = _get_request_of_id(request_id);  makeTemplateRec temprec;  makeTemplateResult result;  if (request == NULLReqRec) return NULLTemplateResult;  temprec = request->TEMPLATE_REC;  result = temprec->result;  temprec->result = NULLTemplateResult;  _request_complete(request_id);  return result;} /* get_make_template_result *//* * - do_make_template() - * * */QE_error_code do_make_template(baseobject, id_ptr, attr_list)     char *baseobject;     QCardinal *id_ptr;     modifyAttr *attr_list;{  makeTemplateRec template_rec;  requestRec this_request;  stringCell str_attr_list = NULLStrCell;  modifyAttr curr_attr;  QE_error_code error_code;  (void) _request_invoked(ENTRY_TEMPLATE, id_ptr);  this_request = _get_request_of_id(*id_ptr);  template_rec = this_request->TEMPLATE_REC;  template_rec->base_object = copy_string(baseobject);  template_rec->request_id = *id_ptr;/* * 	Make sure to read objectClass */  curr_attr = modify_attr_alloc();  curr_attr->next = *attr_list;  curr_attr->attr_name = copy_string("2.5.4.0");  curr_attr->attr_type = AttrT_new("2.5.4.0");  curr_attr->values = NULLModifyValue;  curr_attr->to_modify = FALSE;  template_rec->include_attrs = curr_attr;/* *	Perform the read (reading all attributes) */      error_code = start_read(*id_ptr,			  baseobject,			  NULLStrCell,			  &template_rec->task_id);  free_string_seq(&str_attr_list);  return error_code;} /* do_make_template *//* * - process_template_ds_result() - * * */request_state process_template_ds_result(request, task_id, ds_result)     requestRec request;     int task_id;     struct DSResult *ds_result;{  DsTask task_rec;  makeTemplateRec templaterec = request->TEMPLATE_REC;  struct ds_read_result *read_result;  modifyAttr entry_template = templaterec->include_attrs,  	     oclass_attr = NULLModifyAttr,	     curr_attr,	     last_attr,  	     must_in = NULLModifyAttr,             may_in = NULLModifyAttr,             must_out = NULLModifyAttr,             may_out = NULLModifyAttr,             tmp;  modifyValue curr_oclass;  objectclass *ocp;  register table_seq optr;  /* This shouldn't happen */  if ((task_rec = _get_task_of_id(task_id)) == NULLDsTask)    return RQ_processing;  read_result = &ds_result->res_rd;/* *	Log receipt of results */#ifndef NO_STATS  LLOG (log_stat,        LLOG_NOTICE,        ("READ RESULT +%s, task %d", task_rec->baseobject, task_id));#endif/* *	Put the results into the entry_template linked list. */  get_template_attrs(read_result->rdr_entry.ent_attr, entry_template);/* *	Get the object class field, and check that all other attributes *	conform to object class specifications. */  oclass_attr = entry_template;  entry_template = entry_template->next;  oclass_attr->next = NULLModifyAttr;  last_attr = NULLModifyAttr;/* *	Pick out the must attributes */  for (curr_oclass = oclass_attr->values;       curr_oclass != NULLModifyValue;       curr_oclass = curr_oclass->next)    {      ocp = name2oc(curr_oclass->value);      for (optr = ocp->oc_must; optr != NULLTABLE_SEQ; optr = optr->ts_next)	{	  for (curr_attr = entry_template, last_attr = NULLModifyAttr;	       curr_attr != NULLModifyAttr;	       last_attr = curr_attr, curr_attr = curr_attr->next)	    if (curr_attr->attr_type == optr->ts_oa)	      break;	  if (curr_attr == NULLModifyAttr)	    /*	     * 	The attr type in `oc_must' wasn't requested so stick it	     *  in the `must_out' list.	     */	    {	      if (must_out == NULLModifyAttr)		{		  must_out = modify_attr_alloc();		  must_out->next = NULLModifyAttr;		}	      else		{		  tmp = must_out;		  must_out = modify_attr_alloc();		  must_out->next = tmp;		}	      	      must_out->attr_name =copy_string(attr2name(optr->ts_oa,OIDPART));	      must_out->attr_type = optr->ts_oa;	      must_out->values = modify_value_alloc();	      	      must_out->values->value = must_out->values->new_value = NULLCP;	      must_out->values->status = unchanged;	      must_out->values->next = NULLModifyValue;	      must_out->to_modify = FALSE;	    }	  else	    /*	     *	The attr type in `oc_must' was requested so put it in the	     *	`must_in' list.	     */	    {	      if (last_attr == NULLModifyAttr)		entry_template = curr_attr->next;	      else		last_attr->next = curr_attr->next;	      	      curr_attr->next = must_in;	      must_in = curr_attr;	    }	}      /*       *	Get the `oc_may' attributes       */      for (optr = ocp->oc_may; optr != NULLTABLE_SEQ; optr = optr->ts_next)	{	  for (curr_attr = entry_template, last_attr = NULLModifyAttr;	       curr_attr != NULLModifyAttr;	       last_attr = curr_attr, curr_attr = curr_attr->next)	    if (curr_attr->attr_type == optr->ts_oa)	      break;	  if (curr_attr == NULLModifyAttr)	    /*	     * 	The attr type in `oc_may' wasn't requested so stick it	     *  in the `may_out' list.	     *	     */	    {	      	      if (may_out == NULLModifyAttr)		{		  may_out = modify_attr_alloc();		  may_out->next = NULLModifyAttr;		}	      else		{		  tmp = may_out;		  may_out = modify_attr_alloc();		  may_out->next = tmp;		}	      	      may_out->attr_name = copy_string(attr2name(optr->ts_oa,OIDPART));	      may_out->attr_type = optr->ts_oa;	      may_out->values = modify_value_alloc();	      	      may_out->values->value = may_out->values->new_value = NULLCP;	      may_out->values->status = unchanged;	      may_out->values->next = NULLModifyValue;	      may_out->to_modify = FALSE;	    }	  else	    /*	     *	The attr type in `oc_may' was requested so put it in the	     *	`may_in' list.	     */	    {	      if (last_attr == NULLModifyAttr)		entry_template = curr_attr->next;	      else		last_attr->next = curr_attr->next;	      	      curr_attr->next = may_in;	      may_in = curr_attr;	    }	}    }  /*   *	Check for attribute overlaps and copies in the attribute lists   */  must_in = remove_double_attrs(must_in);  may_out = remove_double_attrs(may_out);  may_in = remove_double_attrs(may_in);  must_out = remove_double_attrs(must_out);  must_out = remove_common_attrs(must_in, must_out);  may_in = remove_common_attrs(must_in, may_in);  may_out = remove_common_attrs(must_in, may_out);  must_out = remove_common_attrs(may_in, must_out);  may_out = remove_common_attrs(may_in, may_out);  may_out = remove_common_attrs(must_out, may_out);  /*   *	Put the results structure into the request record   *	for later retrieval.   *   */  templaterec->result = template_result_alloc();  templaterec->result->object_class = oclass_attr;  templaterec->result->must_request = must_in;  get_template_attrs(read_result->rdr_entry.ent_attr, must_out);  templaterec->result->must_exc = must_out;  templaterec->result->may_request = may_in;  get_template_attrs(read_result->rdr_entry.ent_attr, may_out);

⌨️ 快捷键说明

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