当前位置: 首页>>代码示例>>C++>>正文


C++ xmlParseChunk函数代码示例

本文整理汇总了C++中xmlParseChunk函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlParseChunk函数的具体用法?C++ xmlParseChunk怎么用?C++ xmlParseChunk使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlParseChunk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ocr_callback

static void ocr_callback(ocr_t *ocr, char *buf, int size)
{
  if ( buf != NULL ) {
    dprintf("READ '%s'\n", buf);

    /* Create XML parser context if a new page is coming */
    if ( ocr->xml == NULL )
      ocr->xml = xmlCreatePushParserCtxt(&handlers, &(ocr->ctx), buf, size, "ocr-output");
    else
      xmlParseChunk(ocr->xml, buf, size, 0);

    if ( (ocr->xml != NULL) && (ocr->ctx.state == OCR_STATE_END) ) {
      /* End document parsing */
      xmlParseChunk(ocr->xml, buf, 0, 1);

      /* Free XML SAX parser */
      xmlFreeParserCtxt(ocr->xml);
      ocr->xml = NULL;

      ocr->ctx.state = OCR_STATE_IDLE;
    }
  }
  else {
    ocr_terminate(ocr);
  }
}
开发者ID:testfarm,项目名称:testfarm,代码行数:26,代码来源:ocr.c

示例2: main

int main(void)
{
	FILE *f;
	int ret;
	char chars[10];
	xmlParserCtxtPtr ctxt;
	xdebug_str message = {0, 0, NULL};

	xdebug_xml_reader_priv data;
	data.level   = 0;
	data.xml     = NULL;
	data.current = NULL;

	f = fopen("test.xml", "r");
	
	ctxt = xmlCreatePushParserCtxt(sax_handler_ptr, NULL, NULL, 0, "test");
	ctxt->_private = &data;
	while ((ret = fread(chars, 1, 3, f)) > 0) {
		xmlParseChunk(ctxt, chars, ret, 0);
	}
	xmlParseChunk(ctxt, chars, 0, 1);

	xdebug_xml_return_node(data.xml, &message);
	xdebug_xml_node_dtor(data.xml);
	printf("%s\n", message.d);
	xdebug_str_dtor(message);
	
	xmlFreeParserCtxt(ctxt);
	fclose(f);
	xmlCleanupParser();
	xmlMemoryDump();

	return 0;
}
开发者ID:azhargiri,项目名称:gtkdbgp,代码行数:34,代码来源:xdebug_xml_reader.c

示例3: lj_entry_load_from_xml

static gboolean
lj_entry_load_from_xml(LJEntry *entry, const char *data, int len, GError **err) {
	xmlNodePtr cur;
	xmlDocPtr  doc = NULL;
	xmlParserCtxtPtr ctxt;

	ctxt = xmlCreatePushParserCtxt(NULL, NULL,
				data, 4,
				NULL /* XXX why does this want a filename? */);
	/* suppress error messages */
	ctxt->sax->warning = NULL;
	ctxt->sax->error   = NULL;

	xmlParseChunk(ctxt, data+4, len-4, 0);
	xmlParseChunk(ctxt, data, 0, 1);
	if (!ctxt->errNo)
		doc = ctxt->myDoc;

	xmlFreeParserCtxt(ctxt);

	if (!doc) {
		/* XXX better error message. */
		g_set_error(err, 0, 0, "Error parsing XML");
		return FALSE;
	}

	cur = xmlDocGetRootElement(doc);
	lj_entry_load_from_xml_node(entry, doc, cur);
	xmlFreeDoc(doc);
	return TRUE;
}
开发者ID:spotrh,项目名称:LogJam,代码行数:31,代码来源:entry.c

示例4: xmlCreatePushParserCtxt

/** 
 * Parses a descriptor that contains part of a document. 
 */
void CXMLEngineSAXPlugin::ParseChunkL(const TDesC8& aDescriptor)
	{	
	
	TInt result = KErrNone;
	
	if (!iParserContext)
		{		
		//creating sax parser object
	    iParserContext = xmlCreatePushParserCtxt( 
   						(xmlSAXHandler*) &iParserEvents, 
   						this, 
  						(const char *) aDescriptor.Ptr(), 
						aDescriptor.Length(),
   						NULL
   						);
		if(!iParserContext)
			{
			CleanupAndLeaveL(KErrNoMemory);			
			}
		
		//creating empty document object
		iParserContext->myDoc = xmlNewDoc(BAD_CAST "SAX compatibility mode document");
		if(!iParserContext->myDoc)
			{
			CleanupAndLeaveL(KErrNoMemory);			
			}
		iParserContext->myDoc->intSubset = xmlNewDtd(iParserContext->myDoc, BAD_CAST "fake", NULL, NULL);
		if(!iParserContext->myDoc->intSubset)
			{
			CleanupAndLeaveL(KErrNoMemory);			
			}
		
		//parsing process
	    result = xmlParseChunk(iParserContext, NULL, 0, 0);					
		}
	else
		{
		//parsing process
		result = xmlParseChunk(
				iParserContext, 
				(const char *) aDescriptor.Ptr(), 
				aDescriptor.Length(),
				0);		
		}
					
	//handling error situation
	//if fatal error, function throws exception 
	//in any other case next chunk is taken (recoverable)
	if ((result == XML_ERR_NO_MEMORY) || (iParserContext->lastError.level == XML_ERR_FATAL)
	        || (result < 0))
		{
		CleanupAndLeaveL(GetErrorNum(result));	
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:57,代码来源:xmlengsaxplugin.cpp

示例5: _waitForAnswer

xmlDocPtr _waitForAnswer(int sockfd) {
	xmlParserCtxtPtr requestParserCtxt;
	xmlDocPtr parsedDoc = NULL;
    int resRead = 0;
    int bytesRead = 0;
    int readTries = 0;
    int chunkParseResult = 0;
	
    char buffer[XMLBUS_CHUNK_READLENGTH + 1];
    resRead = recv(sockfd, buffer, XMLBUS_CHUNK_INITIAL_READLENGTH, 0);
    if (resRead > 0) {
        buffer[resRead] = '\0';
        requestParserCtxt = xmlCreatePushParserCtxt(NULL, NULL, buffer, resRead, NULL);
        bytesRead += resRead;
    } else {
        printf("Read failed socket readerror:%d -> closing clientsocket", resRead);
        return NULL;
    }
    xmlCtxtUseOptions(requestParserCtxt,XML_PARSE_NOWARNING); 
	
    while(1) {
        resRead = recv(sockfd, buffer, XMLBUS_CHUNK_READLENGTH, 0);
        buffer[resRead] = '\0';
        if (resRead > 0) {
            chunkParseResult = xmlParseChunk(requestParserCtxt,buffer,resRead,0);
            if (chunkParseResult != 0) {
                xmlErrorPtr xmlErr = xmlGetLastError();
                printf("request parsing found error %d: %s", chunkParseResult, xmlErr->message);
                //@TODO recover or bail out
            }
            if (requestParserCtxt->instate == XML_PARSER_EPILOG) {
                break;
            }
            bytesRead += resRead;
            continue;                             // don't need to parse it another time... it is done already
        }                                         // end of reading (no data received)
        else {
            // Closed connection or error (in this case there is no buffer content, is it ?)
            if (readTries < 5) {
                readTries++;
                continue;
            }
            else {
                // end of parsing (check if the xml is valid)
                if (bytesRead > 0) {
                    // end of reading, try to parse the message so far
                    break;
                }
                //log4c_category_error(loggerCategory, "thread %d read: data read failed, bailing out", threadId);
                //close(request->clientSocket);
                return NULL;
            }
        }                                         // end resRead > 0 .. else
    }                                             // end while(1)
    chunkParseResult = xmlParseChunk(requestParserCtxt, NULL, 0, 1);
	parsedDoc = requestParserCtxt->myDoc;
    xmlFreeParserCtxt(requestParserCtxt);
	return parsedDoc;	
}
开发者ID:olger,项目名称:xmlbus,代码行数:59,代码来源:tcphelpers.c

示例6: xmms_xspf_browse

static gboolean
xmms_xspf_browse (xmms_xform_t *xform, const gchar *url, xmms_error_t *error)
{
	int ret;
	char buf[4096];
	xmlParserCtxtPtr ctx;
	xmlDocPtr doc;

	g_return_val_if_fail (xform, FALSE);

	xmms_error_reset (error);

	ctx = xmlCreatePushParserCtxt (NULL, NULL, buf, 0, NULL);

	if (!ctx) {
		xmms_error_set (error, XMMS_ERROR_OOM, "Could not allocate xml parser");
		return FALSE;
	}

	while ((ret = xmms_xform_read (xform, buf, sizeof (buf), error)) > 0) {
		if ((xmlParseChunk (ctx, buf, ret, 0)) != 0) {
			break;
		}
	}

	if (ret < 0) {
		xmms_error_set (error, XMMS_ERROR_GENERIC,
		                "failed to read data from previous xform");
		xmlFreeParserCtxt (ctx);
		return FALSE;
	}

	xmlParseChunk (ctx, buf, 0, 1);

	if (ctx->lastError.message) {
		xmms_error_set (error, XMMS_ERROR_INVAL, ctx->lastError.message);
		xmlFreeParserCtxt (ctx);
		return FALSE;
	}

	doc = ctx->myDoc;

	if (!xmms_xspf_browse_add_entries (xform, doc, error)) {
		xmlFreeParserCtxt (ctx);
		return FALSE;
	}

	xmms_error_reset (error);
	xmlFreeParserCtxt (ctx);

	return TRUE;
}
开发者ID:eggpi,项目名称:xmms2-guilherme,代码行数:52,代码来源:xspf.c

示例7: xmms_rss_browse

static gboolean
xmms_rss_browse (xmms_xform_t *xform, const gchar *url, xmms_error_t *error)
{
	int ret;
	char buffer[1024];
	xmlSAXHandler handler;
	xmlParserCtxtPtr ctx;
	xmms_rss_data_t data;

	g_return_val_if_fail (xform, FALSE);

	memset (&handler, 0, sizeof (handler));
	memset (&data, 0, sizeof (data));

	handler.startElement = (startElementSAXFunc) xmms_rss_start_element;
	handler.error = (errorSAXFunc) xmms_rss_error;
	handler.fatalError = (fatalErrorSAXFunc) xmms_rss_error;

	data.xform = xform;
	data.error = error;
	data.parse_failure = FALSE;

	xmms_error_reset (error);

	ctx = xmlCreatePushParserCtxt (&handler, &data, buffer, 0, NULL);
	if (!ctx) {
		xmms_error_set (error, XMMS_ERROR_OOM,
		                "Could not allocate xml parser");
		return FALSE;
	}

	while ((ret = xmms_xform_read (xform, buffer, sizeof (buffer), error)) > 0) {
		xmlParseChunk (ctx, buffer, ret, 0);
	}

	if (ret < 0) {
		xmms_error_set (error, XMMS_ERROR_GENERIC, "xmms_xform_read failed");
		return FALSE;
	}

	if (data.parse_failure)
		return FALSE;

	xmlParseChunk (ctx, buffer, 0, 1);

	xmms_error_reset (error);
	xmlFreeParserCtxt (ctx);

	return TRUE;
}
开发者ID:mantaraya36,项目名称:xmms2-mantaraya36,代码行数:50,代码来源:rss.c

示例8: xml_complete

/**
 * Finalise XML parsing.
 */
int xml_complete(modsec_rec *msr, char **error_msg) {
    if (error_msg == NULL) return -1;
    *error_msg = NULL;

    /* Only if we have a context, meaning we've done some work. */
    if (msr->xml->parsing_ctx != NULL) {
        /* This is how we signalise the end of parsing to libxml. */
        xmlParseChunk(msr->xml->parsing_ctx, NULL, 0, 1);

        /* Preserve the results for our reference. */
        msr->xml->well_formed = msr->xml->parsing_ctx->wellFormed;
        msr->xml->doc = msr->xml->parsing_ctx->myDoc;

        /* Clean up everything else. */
        xmlFreeParserCtxt(msr->xml->parsing_ctx);
        msr->xml->parsing_ctx = NULL;
        msr_log(msr, 4, "XML: Parsing complete (well_formed %u).", msr->xml->well_formed);

        if (msr->xml->well_formed != 1) {
            *error_msg = ngx_pstrndup(msr->mp, "XML: Failed parsing document.");
            return -1;
        }
    }

    return 1;
}
开发者ID:shajf,项目名称:WSEngine,代码行数:29,代码来源:msc_xml.c

示例9: result

/** 
 * Parses a descriptor that contains the last  part of a document. 
 */
void CXMLEngineSAXPlugin::ParseLastChunkL(const TDesC8& /*aDescriptor*/)
	{
	if (!iParserContext)
		{
		User::Leave(EXmlParserError);
		}

	//parsing process
	TInt result(KErrNone);
	result = xmlParseChunk(iParserContext, NULL, 0, 1);
	if ((result == XML_ERR_NO_MEMORY) || (iParserContext->lastError.level == XML_ERR_FATAL)
	        || (result < 0))
		{
		CleanupAndLeaveL(GetErrorNum(result));			
		}			
		
	//releasing context to the parser
    xmlParserCtxtPtr ctxt = reinterpret_cast<xmlParserCtxtPtr>(iParserContext);
    if(ctxt->myDoc)                     
       {
       xmlFreeDoc(ctxt->myDoc); 
       }
    xmlFreeParserCtxt(ctxt);
	iParserContext = NULL;	
	
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:29,代码来源:xmlengsaxplugin.cpp

示例10: parser_feed

/* feed a chunk of data to the parser */
int parser_feed(parser_t *parser, char *chunk, int len)
{
    if (XML_ERR_OK == xmlParseChunk(parser->xmlctx, chunk, len, 0))
       return 1;
    else 
       return 0;
}
开发者ID:talisein,项目名称:libstrophe,代码行数:8,代码来源:parser_libxml2.c

示例11: soap_got_chunk

static void
soap_got_chunk (SoupMessage *msg,
                SoupBuffer *chunk,
                gpointer data)
{
	ESoapMessagePrivate *priv = E_SOAP_MESSAGE_GET_PRIVATE (msg);

	if (msg->status_code != 200)
		return;

	priv->response_received += chunk->length;

	if (priv->response_size && priv->progress_fn) {
		gint pc = priv->response_received * 100 / priv->response_size;
		priv->progress_fn (priv->progress_data, pc);
	}

	if (!priv->ctxt) {
		priv->ctxt = xmlCreatePushParserCtxt (NULL, msg, chunk->data,
						      chunk->length, NULL);
		priv->ctxt->_private = priv;
		priv->ctxt->sax->startElementNs = soap_sax_startElementNs;
		priv->ctxt->sax->endElementNs = soap_sax_endElementNs;
		priv->ctxt->sax->characters = soap_sax_characters;
	}
	else
		xmlParseChunk (priv->ctxt, chunk->data, chunk->length, 0);
}
开发者ID:tivv,项目名称:evolution-ews,代码行数:28,代码来源:e-soap-message.c

示例12: cherokee_handler_tmi_step

ret_t
cherokee_handler_tmi_step (cherokee_handler_tmi_t *hdl, cherokee_buffer_t *buffer)
{
    char time_buf[21];
    size_t len;

    len = strftime(time_buf, 21, "%Y-%m-%dT%H:%S:%MZ", &cherokee_bogonow_tmgmt);
    cherokee_buffer_add_buffer (buffer, &HANDLER_TMI_PROPS(hdl)->reply);
    cherokee_buffer_add (buffer, time_buf, len);

#ifdef LIBXML_PUSH_ENABLED
    if (hdl->validate_xml) {
        cherokee_buffer_add_str (buffer, "</tmi8:Timestamp><tmi8:ResponseCode>");

        if (hdl->inflated && hdl->z_ret != Z_OK) {
            cherokee_buffer_add_str(buffer, "PE");
        } else {
            xmlParseChunk(hdl->ctxt, NULL, 0, 1);
            if (hdl->ctxt->wellFormed) {
                cherokee_buffer_add_str(buffer, "OK");
            } else {
                cherokee_buffer_add_str(buffer, "SE");
            }
        }

        cherokee_buffer_add_str (buffer, "</tmi8:ResponseCode></tmi8:VV_TM_RES>");

        return ret_eof_have_data;
    }
#endif
    cherokee_buffer_add_str (buffer, "</tmi8:Timestamp><tmi8:ResponseCode>OK</tmi8:ResponseCode></tmi8:VV_TM_RES>");

    return ret_eof_have_data;
}
开发者ID:StichtingOpenGeo,项目名称:webserver,代码行数:34,代码来源:handler_tmi.c

示例13: e_soap_message_parse_response

/**
 * e_soap_message_parse_response:
 * @msg: the #ESoapMessage.
 *
 * Parses the response returned by the server.
 *
 * Returns: a #ESoapResponse representing the response from
 * the server, or %NULL if there was an error.
 *
 * Since: 2.92
 */
ESoapResponse *
e_soap_message_parse_response (ESoapMessage *msg)
{
	ESoapMessagePrivate *priv;
	xmlDocPtr xmldoc;

	g_return_val_if_fail (E_IS_SOAP_MESSAGE (msg), NULL);

	priv = E_SOAP_MESSAGE_GET_PRIVATE (msg);

	if (!priv->ctxt)
		return NULL;

	xmlParseChunk (priv->ctxt, 0, 0, 1);

	xmldoc = priv->ctxt->myDoc;

	xmlFreeParserCtxt (priv->ctxt);
	priv->ctxt = NULL;

	if (!xmldoc)
		return NULL;

	return e_soap_response_new_from_xmldoc (xmldoc);
}
开发者ID:tivv,项目名称:evolution-ews,代码行数:36,代码来源:e-soap-message.c

示例14: ParseXML

xmlDocPtr ParseXML(SDL_RWops *io)
{
    const size_t bufsize = 1024;
    size_t res;
    char buf [bufsize];

    xmlParserCtxtPtr ctxt;
    xmlDocPtr doc;

    // read first 4 bytes
    if ((res = io->read (io, buf, 1, 4)) < 4)
    {
        SetError ("Failed to read first xml bytes: %s", SDL_GetError ());
        return NULL;
    }

    // Create a progressive parsing context
    ctxt = xmlCreatePushParserCtxt (NULL, NULL, buf, res, NULL);
    if (! ctxt) {
        SetError ("Failed to create parser context!");
        return NULL;
    }

    // loop on the input getting the document data
    while ((res = io->read (io, buf, 1, bufsize)) > 0) {

        xmlParseChunk (ctxt, buf, res, 0);
    }

    // there is no more input, indicate the parsing is finished.
    xmlParseChunk (ctxt, buf, 0, 1);

    // check if it was well formed
    doc = ctxt->myDoc;
    res = ctxt->wellFormed;
    xmlFreeParserCtxt (ctxt);

    if (!res) {

        SetError ("xml document is not well formed");

        xmlFreeDoc (doc);
        doc = NULL;
    }

    return doc;
}
开发者ID:cbaakman,项目名称:game-templates,代码行数:47,代码来源:xml.cpp

示例15: mxml_update

/*****************************************************************************
 * Update the parser with more file content.
 ****************************************************************************/
void mxml_update(void *data, const char *chunk, size_t size, short end) {
  MXML_T *parser;
  int result;
  parser = (MXML_T*)data;
  if ((result = xmlParseChunk(parser->ctxt, chunk, size, end)) != 0) {
    local_error(parser->data, "MEME XML parser returned error code %d.\n", result);
  }
}
开发者ID:NeonTheBlackstar,项目名称:RiboDatabase,代码行数:11,代码来源:motif-in-meme-xml.c


注:本文中的xmlParseChunk函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。