示例#1
0
文件: util.c 项目: DJEX93/dsploit
static int
wrapper_reader_cb(void *baton, const char *data, size_t len)
{
  parser_wrapper_baton_t *pwb = baton;
  svn_ra_neon__session_t *sess = pwb->req->sess;
  int parser_status;

  if (pwb->req->err)
    return 1;

  if (sess->callbacks->cancel_func)
    SVN_RA_NEON__REQ_ERR
      (pwb->req,
       (sess->callbacks->cancel_func)(sess->callback_baton));

  if (pwb->req->err)
    return 1;

  parser_status = ne_xml_parse(pwb->parser, data, len);
  if (parser_status)
    {
      /* Pass XML parser error. */
      SVN_RA_NEON__REQ_ERR(pwb->req,
                           svn_ra_neon__check_parse_error(pwb->req->method,
                                                          pwb->parser,
                                                          pwb->req->url));
    }

  return parser_status;
}
示例#2
0
文件: util.c 项目: DJEX93/dsploit
static svn_error_t *
parse_spool_file(svn_ra_neon__session_t *ras,
                 const char *spool_file_name,
                 ne_xml_parser *success_parser,
                 apr_pool_t *pool)
{
  svn_stream_t *spool_stream;
  char *buf = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
  apr_size_t len;

  SVN_ERR(svn_stream_open_readonly(&spool_stream, spool_file_name, pool, pool));
  while (1)
    {
      if (ras->callbacks &&
          ras->callbacks->cancel_func)
        SVN_ERR((ras->callbacks->cancel_func)(ras->callback_baton));

      len = SVN__STREAM_CHUNK_SIZE;
      SVN_ERR(svn_stream_read(spool_stream, buf, &len));
      if (len > 0)
        if (ne_xml_parse(success_parser, buf, len) != 0)
          /* The parse encountered an error or
             was aborted by a user defined callback */
          break;

      if (len != SVN__STREAM_CHUNK_SIZE)
        break;
    }
  return svn_stream_close(spool_stream);
}
示例#3
0
文件: libs3.c 项目: soundsrc/s3nbd
static void s3_parse_xml_response(S3 *s3,ne_request *req,
							ne_xml_startelm_cb *startelm,
							ne_xml_cdata_cb *cdata,
							ne_xml_endelm_cb *endelm,
							void *userdata)
{
	char buffer[4096];
	size_t bytes_read;
	ne_xml_parser *xml;

	xml = ne_xml_create();
	ne_xml_push_handler(xml,startelm,cdata,endelm,userdata);

	while((bytes_read = ne_read_response_block(req,buffer,4096)) > 0) {
		if(ne_xml_parse(xml,buffer,bytes_read) != 0)
			strncpy(s3->error,ne_xml_get_error(xml),511);
	}
	ne_xml_parse(xml,buffer,0);
	ne_xml_destroy(xml);
}
示例#4
0
int ne_xml_parse_response(ne_request *req, ne_xml_parser *parser)
{
    char buf[8000];
    ssize_t bytes;
    int ret = 0;

    while ((bytes = ne_read_response_block(req, buf, sizeof buf)) > 0) {
        ret = ne_xml_parse(parser, buf, bytes);
        if (ret)
            return parse_error(ne_get_session(req), parser);
    }

    if (bytes == 0) {
        /* Tell the parser that end of document was reached: */
        if (ne_xml_parse(parser, NULL, 0) == 0)
            return NE_OK;
        else
            return parse_error(ne_get_session(req), parser);
    } else {
        return NE_ERROR;
    }    
}
示例#5
0
int DavXMLParser::parseChuck(const char *partial_string, size_t length){
    int ret = ne_xml_parse(_ne_parser,partial_string,length);
    if(ret != 0){
        if(ret > 0){
            ret =-1;
            const char* ne_parser_err = ne_xml_get_error(_ne_parser);
            DavixError::setupError(&err, davix_scope_xml_parser(), StatusCode::WebDavPropertiesParsingError, "XML Parsing Error: " + std::string((ne_parser_err)?ne_parser_err:"Unknow ne error"));
        }
        if(!err){
             DavixError::setupError(&err, davix_scope_xml_parser(), StatusCode::WebDavPropertiesParsingError, "Unknow XML parsing error ");
        }
    }
    return ret;
}
示例#6
0
文件: netxml-ups.c 项目: balooloo/nut
static object_query_t *set_object_deserialise_raw(ne_buffer *buff) {
	int ne_status;

	assert(NULL != buff);

	/* Create SET_OBJECT query response */
	object_query_t *handle = object_query_create(SET_OBJECT_RESPONSE, RAW_POST);

	if (NULL == handle)
		return NULL;

	/* Create XML parser */
	ne_xml_parser *parser = ne_xml_create();

	/* neon API ref. states that the function always succeeds */
	assert(NULL != parser);

	/* Set element & data handlers */
	ne_xml_push_handler(
		parser,
		set_object_raw_resp_start_element,
		set_object_raw_resp_cdata,
		set_object_raw_resp_end_element,
		handle);

	/* Parse the response */
	ne_status = ne_xml_parse(parser, buff->data, buff->used);

	if (NE_OK != ne_status)
		handle->status = OBJECT_PARSE_ERROR;

	/* Destroy parser */
	ne_xml_destroy(parser);

	return handle;
}
示例#7
0
文件: netxml-ups.c 项目: balooloo/nut
void upsdrv_updateinfo(void)
{
	int	ret, errors = 0;

	/* We really should be dealing with alarms through a separate callback, so that we can keep the
	 * processing of alarms and polling for data separated. Currently, this isn't supported by the
	 * driver main body, so we'll have to revert to polling each time we're called, unless the
	 * socket indicates we're no longer connected.
	 */
	if (testvar("subscribe")) {
		char	buf[LARGEBUF];

		ret = ne_sock_read(sock, buf, sizeof(buf));

		if (ret > 0) {
			/* alarm message received */

			ne_xml_parser	*parser = ne_xml_create();
			upsdebugx(2, "%s: ne_sock_read(%d bytes) => %s", __func__, ret, buf);
			ne_xml_push_handler(parser, subdriver->startelm_cb, subdriver->cdata_cb, subdriver->endelm_cb, NULL);
			ne_xml_parse(parser, buf, strlen(buf));
			ne_xml_destroy(parser);
			time(&lastheard);

		} else if ((ret == NE_SOCK_TIMEOUT) && (difftime(time(NULL), lastheard) < 180)) {
			/* timed out */

			upsdebugx(2, "%s: ne_sock_read(timeout)", __func__);

		} else {
			/* connection closed or unknown error */

			upslogx(LOG_ERR, "NSM connection with '%s' lost", uri.host);

			upsdebugx(2, "%s: ne_sock_read(%d) => %s", __func__, ret, ne_sock_error(sock));
			ne_sock_close(sock);

			if (netxml_alarm_subscribe(subdriver->subscribe) == NE_OK) {
				extrafd = ne_sock_fd(sock);
				time(&lastheard);
				return;
			}

			dstate_datastale();
			extrafd = -1;
			return;
		}
	}

	/* get additional data */
	ret = netxml_get_page(subdriver->getobject);
	if (ret != NE_OK) {
		errors++;
	}

	ret = netxml_get_page(subdriver->summary);
	if (ret != NE_OK) {
		errors++;
	}

	if (errors > 1) {
		dstate_datastale();
		return;
	}

	status_init();

	alarm_init();
	netxml_alarm_set();
	alarm_commit();

	netxml_status_set();
	status_commit();

	dstate_dataok();
}