Ejemplo n.º 1
0
int fill_resource_list(

  job        **pj, 
  xmlNodePtr   resource_list_node, 
  char        *log_buf,
  size_t       buflen,
  const char  *aname)

  {
  xmlNodePtr resNode = NULL;
  int        rc = PBSE_NONE;
  bool       element_found = false;
  bool       freeExisting = true;

  for (resNode = resource_list_node->children; resNode != NULL; resNode = resNode->next)
    {
    /* skip text children, only process elements */
    if (!strcmp((const char *)resNode->name, text_name))
      continue;

    element_found = true;
      
    xmlChar  *value = xmlNodeGetContent(resNode);
    svrattrl *pal = NULL;

    if ((pal = fill_svrattr_info(aname, (const char*)value, (const char *)resNode->name, log_buf, buflen)))
      {
      char *attr_flags;
      unsigned int flags;
      if ((attr_flags = (char *)xmlGetProp(resNode, (xmlChar *)AL_FLAGS_ATTR)))
        {
        flags = (unsigned int)atoi((char *)attr_flags);
        xmlFree(attr_flags);
        pal->al_flags = flags;
        }
      decode_attribute(pal,pj,freeExisting);
      freeExisting = false;
      free(pal);
      }
    else
      rc = -1;

    if (value) 
      xmlFree(value);
    }

  if (element_found == false)
    {
    snprintf(log_buf, buflen, "%s", "no Resource_List nodes were found in the xml");
    rc = -1;
    }

  return(rc);
  }
Ejemplo n.º 2
0
int parse_attributes(

  job     **pj,       /* M */ /* job information to fill into */
  xmlNode *attr_node, /* I */ /* attribute node to parse */
  char    *log_buf,   /* O */ /* error message buffer */
  size_t   buf_len)   /* I */ /* size of error message buffer */

  {
  int           rc = PBSE_NONE;
  xmlNode      *cur_node = NULL;
  xmlNode      *resource_list_node = NULL;
  xmlNode      *resources_used_node = NULL;
  bool          element_found = false;

  for (cur_node = attr_node->children; cur_node != NULL && rc == PBSE_NONE; cur_node = cur_node->next)
    {
    /* skip text children, only process elements */
    if (!strcmp((const char *)cur_node->name, text_name))
      continue;

    element_found = true;
      
    if (!(strcmp((const char*)cur_node->name,  ATTR_l)))
      resource_list_node = cur_node;
    else if (!(strcmp((const char*)cur_node->name,  ATTR_used)))
      resources_used_node = cur_node;
    else
      {
      svrattrl *pal = NULL;
      xmlChar *value = xmlNodeGetContent(cur_node);
      if ((pal = fill_svrattr_info((const char*)cur_node->name, (const char*)value, NULL, log_buf, buf_len)))
        {
        xmlChar      *attr_flags;
        unsigned int  flags;
        if ((attr_flags = xmlGetProp(cur_node, (xmlChar *)AL_FLAGS_ATTR)))
          {
          flags = (unsigned int)atoi((char *)attr_flags);
          xmlFree(attr_flags);
          pal->al_flags = flags;
          }
          
        decode_attribute(pal, pj);

        free(pal);
        }
      else
        rc = -1;

      if (value)
        xmlFree(value);
      }
    
    }
    
  if (rc == PBSE_NONE && resource_list_node) 
    rc = fill_resource_list(pj, resource_list_node, log_buf, buf_len, ATTR_l);
  if (rc == PBSE_NONE && resources_used_node)
    rc = fill_resource_list(pj, resources_used_node, log_buf, buf_len, ATTR_used);
  else if (element_found == false)
    {
    snprintf(log_buf, buf_len, "%s", "Error: there were no job attributes found"); 
    rc = -1;
    }

  return(rc);
  } /* END parse_attributes */