Exemple #1
0
int
decode_arst(struct attribute *patr, char *name, char *rescn, char *val)
{
    int	  rc;
    attribute temp;

    if ((val == (char *)0) || (strlen(val) == 0)) {
        free_arst(patr);
        /* _SET cleared in free_arst */
        patr->at_flags |= ATR_VFLAG_MODIFY | ATR_VFLAG_MODCACHE;

        return (0);
    }

    if ((patr->at_flags & ATR_VFLAG_SET) && (patr->at_val.at_arst)) {
        /* already have values, decode new into temp	*/
        /* then use set(incr) to add new to existing	*/

        temp.at_flags   = 0;
        temp.at_type    = ATR_TYPE_ARST;
        temp.at_user_encoded = NULL;
        temp.at_priv_encoded = NULL;
        temp.at_val.at_arst = 0;
        if ((rc = decode_arst_direct(&temp, val)) != 0)
            return (rc);
        rc = set_arst(patr, &temp, SET);
        free_arst(&temp);
        return (rc);

    } else {
        /* decode directly into real attribute */
        return (decode_arst_direct(patr, val));
    }
}
int decode_arst_merge(

  pbs_attribute *patr,    /* O (modified) */
  char          *name,    /* I pbs_attribute name (notused) */
  char          *rescn,   /* I resource name (notused) */
  char          *val)     /* I pbs_attribute value */

  {
  int           rc;
  pbs_attribute new_attr;
  pbs_attribute tmp;

  if ((val == NULL) || (strlen(val) == 0))
    {
    free_arst(patr);

    patr->at_flags &= ~ATR_VFLAG_MODIFY; /* _SET cleared in free_arst */

    return(0);
    }

  if (!(patr->at_flags & ATR_VFLAG_SET) || (patr->at_val.at_arst == NULL))
    {
    /* decode directly into real pbs_attribute */

    return(decode_arst_direct(patr,val));
    }

  memset(&new_attr,0x0,sizeof(pbs_attribute));
  memset(&tmp,0x0,sizeof(pbs_attribute));

  /* already have values, decode new into temp */
  /* then use set(incr) to add new to existing */

  /* convert value string into pbs_attribute array */

  if ((rc = decode_arst_direct(&new_attr,val)) != 0)
    {
    /* FAILURE */

    return(rc);
    }

  /* copy patr to temp, and new to patr */

  tmp.at_val.at_arst = patr->at_val.at_arst;
  patr->at_val.at_arst = new_attr.at_val.at_arst;

  /* incr original patr value onto new patr */

  tmp.at_flags |= ATR_VFLAG_SET;
  rc = set_arst(patr,&tmp,MERGE);

  free_arst(&tmp);

  return(rc);
  }  /* END decode_arst_merge() */
int decode_arst(

  pbs_attribute *patr,    /* O (modified) */
  char          *name,    /* I pbs_attribute name (notused) */
  char          *rescn,   /* I resource name (notused) */
  char          *val,     /* I pbs_attribute value */
  int            perm) /* only used for resources */

  {
  int           rc;
  pbs_attribute temp;

  if ((val == NULL) || (strlen(val) == 0))
    {
    free_arst(patr);

    patr->at_flags &= ~ATR_VFLAG_MODIFY; /* _SET cleared in free_arst */

    return(0);
    }

  memset(&temp, 0, sizeof(pbs_attribute));

  if ((patr->at_flags & ATR_VFLAG_SET) && (patr->at_val.at_arst))
    {
    /* already have values, decode new into temp */
    /* then use set(incr) to add new to existing */


    /* convert value string into pbs_attribute array */

    if ((rc = decode_arst_direct(&temp,val)) != 0)
      {
      /* FAILURE */

      return(rc);
      }

    rc = set_arst(patr,&temp,INCR);

    free_arst(&temp);

    return(rc);
    }

  /* decode directly into real pbs_attribute */

  return(decode_arst_direct(patr,val));
  }  /* END decode_arst() */