2016-11-12 127 views
0

我正在使用gmime库的c版本,并且在解析和提取似乎已经处于多部分形式的内容时出现问题。我以为解析内容是gmime将弄清楚如何正确地构建多,这样就简单GMime多部分内容

g_mime_multipart_get_part(mimeMessage, 0) 

将返回SOAP-XML部分。很明显,我错了,我对mime和gmime库的理解有限,正在杀死我。请协助。提前感谢你。下面

GMimeStream * mimeStream = g_mime_stream_mem_new_with_buffer(incoming, n); 
GMimeParser * mimeParser = g_mime_parser_new_with_stream(mimeStream); 
g_object_unref(mimeStream); 
GMimeMessage * mimeMessage = g_mime_parser_construct_message(mimeParser); 
g_object_unref(mimeParser); 

**原始内容*

------=_Part_5896175_1217116888.1478087584633 
Content-Type: text/xml 

<soap-env:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
... 
</soap-env:Envelope> 
------=_Part_5896175_1217116888.1478087584633 
Content-Type: multipart/related;Start="<smil>";Type="application/smil"; 
    boundary="----=_Part_5896174_292278572.1478087584547" 
Content-ID: /mms/mm7/mm7client 

------=_Part_5896174_292278572.1478087584547 
Content-Type: application/smil;Name=smil.xml 
Content-Transfer-Encoding: 7bit 
Content-ID:<smil> 
Content-Location:smil.xml 

<smil><head><layout><root-layout width="320px" height="480px"/><region id="Text" left="0" top="320" width="320px" height="160px" fit="meet"/></layout></head><body><par dur="0ms"><text src="text_0.txt" region="Text"/></par></body></smil> 
------=_Part_5896174_292278572.1478087584547 
Content-Type: text/plain;Name=text_0.txt;Charset=utf-8 
Content-Transfer-Encoding: 7bit 
Content-ID:<text_0> 
Content-Location:text_0.txt 

Your MMS was read 02 Nov 2016 13:53 
------=_Part_5896174_292278572.1478087584547-- 

------=_Part_5896175_1217116888.1478087584633-- 

回答

0

GMime无法分析,因为它是不完整的。如果内容不是以定义边界的Content-Type头开始,解析器如何知道多方边界是什么?