Example #1
0
int parse_reservation_output(

  char  *output,
  char **rsv_id)

  {
  xmlDocPtr  doc;
  xmlNode   *node;
  char      *attr_val;
  int        rc = apbasil_fail_transient;

  if ((doc = xmlReadMemory(output, strlen(output), "apbasil", NULL, 0)) == NULL)
    {
    char buf[MAXLINE * 4];
    xmlErrorPtr pErr = xmlGetLastError();
    snprintf(buf, sizeof(buf), "Failed to parse the output of alps - %s", pErr->message);
    log_err(-1, __func__, buf);
    return(ALPS_PARSING_ERROR);
    }

  node = xmlDocGetRootElement(doc);

  while (node != NULL)
    {
    if (!strcmp((const char *)node->name, text_name))
      {
      node = node->next;
      continue;
      }
    
    if (!strcmp((const char *)node->name, response_data))
      {
      attr_val = (char *)xmlGetProp(node, (const xmlChar *)status);
      if (strcmp(attr_val, success))
        {
        /* FAILURE - permanent or transient? */
        free(attr_val);
        return(find_error_type(node));
        }
      else
        rc = PBSE_NONE;
        
      free(attr_val);
      }
    else if (!strcmp((const char *)node->name, reserved))
      {
      *rsv_id = (char *)xmlGetProp(node, (const xmlChar *)reservation_id);
      }

    node = node->children;
    }

  return(rc);
  } /* END parse_reservation_output() */
Example #2
0
int parse_confirmation_output(

  char *output)

  {
  int        rc = -1;
  xmlDocPtr  doc;
  xmlNode   *node;
  char      *attr_val;

  if ((doc = xmlReadMemory(output, strlen(output), "apbasil", NULL, 0)) == NULL)
    {
    char buf[MAXLINE * 4];
    xmlErrorPtr pErr = xmlGetLastError();
    snprintf(buf, sizeof(buf), "Failed to parse the output of alps - %s", pErr->message);
    log_err(-1, __func__, buf);
    return(ALPS_PARSING_ERROR);
    }

  node = xmlDocGetRootElement(doc);

  while (node != NULL)
    {
    if (!strcmp((const char *)node->name, response_data))
      {
      attr_val = (char *)xmlGetProp(node, (const xmlChar *)status);

      if (strcmp(attr_val, success))
        {
        rc = find_error_type(node);
        }
      else
        rc = PBSE_NONE;

      free(attr_val);

      break;
      }
    else if (!strcmp((const char *)node->name, text_name))
      node = node->next;
    else
      node = node->children;
    }

  return(rc);
  } /* END parse_confirmation_output() */
Example #3
0
NErrorType*
nt_error_type(NErrorRegistry* registry, const char* name, NError* error) {
    return find_error_type(registry, name, error);
}
Example #4
0
NErrorType*
n_error_type(const char* name, NError* error) {
    return find_error_type(&DEFAULT_REGISTRY, name, error);
}