modify.c

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

C
855
字号
	  AS_SYNTAX(as) >= AV_WRITE_FILE ||	  !strcmp(AS_STROID(as), "0.9.2342.19200300.100.1.23") ||	  !strcmp(AS_STROID(as), "0.9.2342.19200300.100.1.24"))) {      nas = as_comp_new(AttrT_cpy(as->attr_type), 			avs_cpy(as->attr_value),			NULLACL_INFO);      if (tas) tas = as_merge(tas, nas);      else tas = nas;    }  as = templ_as;  nas = templ_as = 0;  for (; as != NULLATTR; as = as->attr_link)    if (!(AS_SYNTAX(as) == str2syntax("schema") ||          AS_SYNTAX(as) == str2syntax("objectclass") ||          AS_SYNTAX(as) == str2syntax("acl") ||          AS_SYNTAX(as) == str2syntax("edbinfo") ||          AS_SYNTAX(as) == str2syntax("octetstring") ||	  AS_SYNTAX(as) >= AV_WRITE_FILE ||	  !strcmp(AS_STROID(as), "0.9.2342.19200300.100.1.23") ||	  !strcmp(AS_STROID(as), "0.9.2342.19200300.100.1.24"))) {      nas = as_comp_new(AttrT_cpy(as->attr_type), NULLAV, NULLACL_INFO);      if (templ_as) templ_as = as_merge(templ_as, nas);      else templ_as = nas;    }  as = as_merge(tas, templ_as);  as = as_sort(as);    my_as_print(ps, as, READOUT);  buffer = ps->ps_base;  ps->ps_ptr = NULL;  ps->ps_cnt = 0;  ps->ps_bufsiz = 0;  ps->ps_base = NULL;  photo_on = TRUE;  ps_free(ps);  as_free(as);    make_attr_sequence(buffer, attrs);  if (buffer != NULLCP) free(buffer);}make_attr_sequence(entry_string, attrs)     char *entry_string;     dirAttrs *attrs;{  register char *str, *sptr;  char save, buffer[RESBUF];  modVals curr_val = 0;  dirAttrs curr_attr = 0;  AttributeType curr_attr_type = NULLAttrT;  int count = 0;  str = sptr = entry_string;  while (1) {    str = index(sptr, '-');    /* Look for things like "dl-policy" -- don't know what the test SHOULD be*/    while (str && isalpha(str[-1]) && isalpha(str[1])) 	    str = index(str+1, '-');    if (!str || str == sptr) return;    while (!isalpha(*str)) {      if (str < sptr) return;      else --str;    }    str++;    save = *str;    *str = '\0';        if (curr_attr) {      if (strcmp(curr_attr->attr_name, sptr)) {	curr_val = 0;	curr_attr->next = (dirAttrs) malloc(sizeof(dir_attrs));	curr_attr = curr_attr->next;	curr_attr->next = 0;	curr_attr->val_seq = 0;	curr_attr->mod_flag = FALSE;	curr_attr->in_flag = TRUE;	curr_attr->attr_name = strdup(sptr);	if (curr_attr_type != NULLAttrT) {	  AttrT_free(curr_attr_type);	  curr_attr_type = str2AttrT(curr_attr->attr_name);	}	if (curr_attr_type && curr_attr_type->oa_ot.ot_stroid &&	    strcmp(curr_attr_type->oa_ot.ot_stroid, "2.5.4.35"))	  curr_attr->hidden_flag = TRUE;	else	  curr_attr->hidden_flag = FALSE;		if (!lexequ(curr_attr->attr_name, "rfc822Mailbox") 	    && mailformat == greybook) {	  (void) strcpy(curr_attr->attr_name, "mailbox");	}      }    } else {      curr_attr = (dirAttrs) malloc(sizeof(dir_attrs));      *attrs = curr_attr;      curr_attr->next = 0;      curr_attr->val_seq = (modVals) 0;      curr_attr->mod_flag = FALSE;      curr_attr->in_flag = TRUE;      curr_attr->attr_name = strdup(sptr);      if (curr_attr_type != NULLAttrT) AttrT_free(curr_attr_type);      curr_attr_type = str2AttrT(curr_attr->attr_name);      if (!strcmp(curr_attr_type->oa_ot.ot_stroid, "2.5.4.35"))	curr_attr->hidden_flag = TRUE;      else	curr_attr->hidden_flag = FALSE;      if (!lexequ(curr_attr->attr_name, "rfc822Mailbox") 	  && mailformat == greybook) {	(void) strcpy(curr_attr->attr_name, "mailbox");      }    }        *str = save;    while ((isspace(*str) || (*str == '-')) && *str != '\n' && *str != '\0')       str++;    sptr = str;    count = 0;    while (1) {      while (*str != '\n' && *str != '\0') {	buffer[count++] = *str;	str++;      }      if (*str != '\0' && *(str + 1) == '\t') {	buffer[count++] = '\n';	while (isspace(*str)) str++;      } else break;    }    buffer[count] = '\0';    save = *str;    *str = '\0';    if (curr_val) {      curr_val->next = (modVals) malloc(sizeof(struct mod_vals));      curr_val = curr_val->next;    } else {      curr_val = (modVals) malloc(sizeof(struct mod_vals));      curr_attr->val_seq = curr_val;      if (!count) curr_attr->in_flag = FALSE;    }    curr_val->attr = curr_attr;    curr_val->next = 0;    curr_val->mod_flag = FALSE;    curr_val->new_value = 0;    curr_val->text_widg = 0;    curr_val->value = strdup(buffer);    char_map(buffer, curr_val->value, curr_attr_type);    free(curr_val->value);    curr_val->value = strdup(buffer);    if (mailformat == greybook	&& !lexequ(curr_attr->attr_name, "mailbox")) {      rfc2greybook(curr_val->value);    }    *str = save;    if (*str == '\0' || *++str == '\0') {      if (curr_attr_type != NULLAttrT) AttrT_free(curr_attr_type);      return;    }    sptr = str;  }}static void char_map(buffer, value, at)     char *buffer, *value;     AttributeType at;{  char ia5_char_desc[3];  long ia5_char;  extern long strtol();  ia5_char_desc[2] = '\0';  if (!at || !is_map_required(at)) {    (void) strcpy(buffer, value);    return;  }  if (value != NULLCP && *value != '\0') {    while (*value != '\0') {      switch (*value) {      case '$':	*buffer = '\n';	break;      case '\\':	ia5_char_desc[0] = *(char *) (value + 1);	ia5_char_desc[1] = *(char *) (value + 2);	ia5_char = strtol(ia5_char_desc, (char **) NULL, 16);	*buffer = (char) ia5_char;	value += 2;		break;      default:	*buffer = *value;      }      value++;      buffer++;    }  }    *buffer = '\0';}static bool is_map_required(at)     AttributeType at;{  int at_syntax = at->oa_syntax;  if ((str2syntax("PostalAddress") == at_syntax) ||      (str2syntax("CaseIgnoreIA5String") == at_syntax) ||      (str2syntax("IA5String") == at_syntax))    return TRUE;    return FALSE;}static void char_unmap(buffer, value, at)     char *buffer, *value;     AttributeType at;{  if (value == NULLCP || *value == '\0') {    *buffer = '\0';    return;  }    if (str2syntax("dn") == at->oa_syntax) {    if (*value == '@') (void) strcpy(buffer, (char *) (value + 1));    return;  }    if (!is_map_required(at)) {    (void) strcpy(buffer, value);    return;  }  if (value != NULLCP && *value != '\0') {    while (*value != '\0') {      switch (*value) {      case '\n':	*buffer = '$';	break;      default:	*buffer = *value;      }      value++;      buffer++;    }  }  *buffer = '\0';}    Attr_Sequence make_template_as(oc)     AV_Sequence oc;{  AV_Sequence avs;  Attr_Sequence newas;  Attr_Sequence as = NULLATTR;  table_seq optr;  AttributeType at;  objectclass * ocp;    for (avs = oc; avs != NULLAV; avs = avs->avseq_next) {    ocp = (objectclass *) avs->avseq_av.av_struct;    for (optr = ocp->oc_must; optr != NULLTABLE_SEQ; optr = optr->ts_next) {      at = optr->ts_oa;      newas = as_comp_new(at, NULLAV, NULLACL_INFO);      as = as_merge(as, newas);    }  }    for (avs = oc; avs != NULLAV; avs = avs->avseq_next) {    ocp = (objectclass *) avs->avseq_av.av_struct;    for (optr = ocp->oc_may; optr != NULLTABLE_SEQ; optr = optr->ts_next) {      at = optr->ts_oa;      newas = as_comp_new(at, NULLAV, NULLACL_INFO);      as = as_merge(as, newas);    }  }  return(as);}/*Big Bodge!*/char *modify_error(error)     struct DSError *error;{  PS ps;  char buffer[RESBUF];  char *str, *message;    if ((ps = ps_alloc(str_open)) == NULLPS) {    return NULLCP;  }  if (str_setup(ps, buffer, RESBUF, 1) == NOTOK) {    return NULLCP;  }  ds_error(ps, error);  *ps->ps_ptr = 0;  ps_free(ps);  str = buffer;  if (*str != '\0') {    message = strdup(str);  } else message = NULLCP;  return message;}  static void my_as_comp_print (ps,as,format)     PS   ps;     Attr_Sequence  as;     int  format;{  AV_Sequence avs;  char buffer[64];  extern int oidformat;    if (as != NULLATTR) {    if (format == READOUT)      (void) sprintf(buffer,"%s", attr2name(as->attr_type, 1));    else      (void) sprintf(buffer,"%s", attr2name_aux(as->attr_type));        if (split_attr (as)) {      if (as->attr_value == NULLAV && format != READOUT) 	ps_printf(ps, "%s=\n", buffer);      else {	if (as->attr_value == NULLAV)	  ps_printf(ps, "%-21s - \n", buffer);	else {	  for (avs = as->attr_value; avs != NULLAV; avs = avs->avseq_next) {	    if (format == READOUT)	      ps_printf (ps, "%-21s - ", buffer);	    else	      ps_printf (ps, "%s= ", buffer);	    avs_comp_print (ps, avs, EDBOUT);	    ps_print (ps, "\n");	  }	}      }    } else {      if (format == READOUT)	ps_printf (ps, "%-21s - ", buffer);      else	ps_printf (ps, "%s= ", buffer);      avs_print (ps, as->attr_value, format);    }  }}static void my_as_print (ps,as,format)     Attr_Sequence  as;     PS   ps;     int  format;{  Attr_Sequence curr_as;  if (as != NULLATTR)    for (curr_as = as; curr_as != NULLATTR; curr_as = curr_as->attr_link)      my_as_comp_print(ps, curr_as, format);}static Attr_Sequence as_sort(as)     Attr_Sequence as;{  Attr_Sequence with_vals = NULLATTR, without_vals = NULLATTR, next_as;  if (as == NULLATTR) return as;  while (as != NULLATTR) {    next_as = as->attr_link;    as->attr_link = NULLATTR;    if (as->attr_value) with_vals = as_merge(with_vals, as);    else without_vals = as_merge(without_vals, as);        as = next_as;  }  as = with_vals;  if (as != NULLATTR)     for (; as->attr_link != NULLATTR; as = as->attr_link)      ;  else return without_vals;  as->attr_link = without_vals;  return with_vals;}    

⌨️ 快捷键说明

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