⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amoimess_mms_encode.c

📁 关于彩信的编解码
💻 C
📖 第 1 页 / 共 3 页
字号:
	}
	if(messmms->body[iType].Contentype.acceptrangestext)
	{
		strcatC(stream,Accept_Ranges);
		strcatUC(stream,messmms->body[iType].Contentype.acceptrangestext);
	}

	if(messmms->body[iType].Contentype.cachecontrol)
	{
		strcatC(stream,Cache_Control);
		strcatC(stream,messmms->body[iType].Contentype.cachecontrol);
	}
	if(messmms->body[iType].Contentype.cachecontroltext)
	{
		strcatC(stream,Cache_Control);
		strcatUC(stream,messmms->body[iType].Contentype.cachecontroltext);
	}

	if(messmms->body[iType].Contentype.connectiontext)
	{
		strcatC(stream,Connection);
		strcatUC(stream,messmms->body[iType].Contentype.connectiontext);
	}

	if(messmms->body[iType].Contentype.connection)
	{
		strcatC(stream,Connection);
		strcatC(stream,messmms->body[iType].Contentype.connection);
	}
	if(messmms->body[iType].Contentype.contentbase)
	{
		strcatC(stream,Content_Base);
		strcatUC(stream,messmms->body[iType].Contentype.contentbase);
	}

	if(messmms->body[iType].Contentype.contentencoding)
	{
		strcatC(stream,Content_Encoding);
		strcatC(stream,messmms->body[iType].Contentype.contentencoding);
	}
	if(messmms->body[iType].Contentype.contentencodingtext)
	{
		strcatC(stream,Content_Encoding);
		strcatUC(stream,messmms->body[iType].Contentype.contentencodingtext);
	}

	if(messmms->body[iType].Contentype.contentlanguage)
	{
		strcatC(stream,Content_Language);
		strcatC(stream,messmms->body[iType].Contentype.contentlanguage);
	}
	if(messmms->body[iType].Contentype.contentlanguagetext)
	{
		strcatC(stream,Content_Language);
		strcatUC(stream,messmms->body[iType].Contentype.contentlanguagetext);
	}

	if(messmms->body[iType].Contentype.contentlocation)
	{
		strcatC(stream,Content_Location);
		strcatUC(stream,messmms->body[iType].Contentype.contentlocation);
	}
	if(messmms->body[iType].Contentype.date.datecontent.year)
	{
		allseconds = DateToSecond(messmms->body[iType].Contentype.date.datecontent.year,
				messmms->body[iType].Contentype.date.datecontent.month,messmms->body[iType].Contentype.date.datecontent.day,
				messmms->body[iType].Contentype.date.datecontent.hour,messmms->body[iType].Contentype.date.datecontent.minute,
				messmms->body[iType].Contentype.date.datecontent.second);
	
		datetmp = SecondsEncode(allseconds,messmms->body[iType].Contentype.date.datelength); //执行移位操作
		strcatUCL(stream,datetmp,strlen((C*)datetmp));
	}

	if(messmms->body[iType].Contentype.etag)
	{
		strcatC(stream,Etag);
		strcatUC(stream,messmms->body[iType].Contentype.etag);
	}

	if(messmms->body[iType].Contentype.expires.datecontent.year)
	{
		allseconds = DateToSecond(messmms->body[iType].Contentype.expires.datecontent.year,
				messmms->body[iType].Contentype.expires.datecontent.month,messmms->body[iType].Contentype.expires.datecontent.day,
				messmms->body[iType].Contentype.expires.datecontent.hour,messmms->body[iType].Contentype.expires.datecontent.minute,
				messmms->body[iType].Contentype.expires.datecontent.second);
	
		datetmp = SecondsEncode(allseconds,messmms->body[iType].Contentype.expires.datelength); //执行移位操作
		strcatUCL(stream,datetmp,strlen((C*)datetmp));
	}

	if(messmms->body[iType].Contentype.from)
	{
		strcatC(stream,From_Single);
		strcatUC(stream,messmms->body[iType].Contentype.from);
	}
	if(messmms->body[iType].Contentype.host)
	{
		strcatC(stream,Host);
		strcatUC(stream,messmms->body[iType].Contentype.host);
	}
	if(messmms->body[iType].Contentype.ifmatch)
	{
		strcatC(stream,If_Match);
		strcatUC(stream,messmms->body[iType].Contentype.ifmatch);
	}
	if(messmms->body[iType].Contentype.ifnonematch)
	{
		strcatC(stream,If_None_Match);
		strcatUC(stream,messmms->body[iType].Contentype.ifnonematch);
	}
	if(messmms->body[iType].Contentype.location)
	{
		strcatC(stream,Location);
		strcatUC(stream,messmms->body[iType].Contentype.location);
	}
	if(messmms->body[iType].Contentype.maxforwards)
	{
		strcatC(stream,Max_Forwards);
		strcatUC(stream,messmms->body[iType].Contentype.maxforwards);
	}
	if(messmms->body[iType].Contentype.range)
	{
		strcatC(stream,Range);
		strcatC(stream,messmms->body[iType].Contentype.range);
	}
	if(messmms->body[iType].Contentype.referer)
	{
		strcatC(stream,Referer);
		strcatUC(stream,messmms->body[iType].Contentype.referer);
	}
	if(messmms->body[iType].Contentype.server)
	{
		strcatC(stream,Server);
		strcatUC(stream,messmms->body[iType].Contentype.server);
	}
	if(messmms->body[iType].Contentype.upgrade)
	{
		strcatC(stream,Upgrade);
		strcatUC(stream,messmms->body[iType].Contentype.upgrade);
	}
	if(messmms->body[iType].Contentype.useragent)
	{
		strcatC(stream,User_Agent);
		strcatUC(stream,messmms->body[iType].Contentype.useragent);
	}
	if(messmms->body[iType].Contentype.via)
	{
		strcatC(stream,Via);
		strcatUC(stream,messmms->body[iType].Contentype.via);
	}
	if(messmms->body[iType].Contentype.warning)
	{
		strcatC(stream,Warning);
		strcatUC(stream,messmms->body[iType].Contentype.warning);
	}
	if(messmms->body[iType].Contentype.wapapplicationid)
	{
		strcatC(stream,X_Wap_Application_Id);
		strcatUC(stream,messmms->body[iType].Contentype.wapapplicationid);
	}
	if(messmms->body[iType].Contentype.wapcontenturl)
	{
		strcatC(stream,X_Wap_Content_URI);
		strcatUC(stream,messmms->body[iType].Contentype.wapcontenturl);
	}
	if(messmms->body[iType].Contentype.wapinitiatorurl)
	{
		strcatC(stream,X_Wap_Initiator_URI);
		strcatUC(stream,messmms->body[iType].Contentype.wapinitiatorurl);
	}
	if(messmms->body[iType].Contentype.bearerindication)
	{
		strcatC(stream,Bearer_Indication);
		strcatUC(stream,messmms->body[iType].Contentype.bearerindication);
	}
	if(messmms->body[iType].Contentype.pushflag)
	{
		strcatC(stream,Push_Flag);
		strcatUC(stream,messmms->body[iType].Contentype.pushflag);
	}
	if(messmms->body[iType].Contentype.profile)
	{
		strcatC(stream,Profile);
		strcatUC(stream,messmms->body[iType].Contentype.profile);
	}

	if(messmms->body[iType].Contentype.transferencoding)
	{
		strcatC(stream,Transfer_Encoding);
		strcatC(stream,messmms->body[iType].Contentype.transferencoding);
	}
	if(messmms->body[iType].Contentype.transferencodingtext)
	{
		strcatC(stream,Transfer_Encoding);
		strcatUC(stream,messmms->body[iType].Contentype.transferencodingtext);
	}

	if(messmms->body[iType].Contentype.contentid)
	{
		if(messmms->body[iType].Contentype.contentidname)
		{
			strcatUC(stream,messmms->body[iType].Contentype.contentidname); 
			strcatUC(stream,messmms->body[iType].Contentype.contentid);
		}
		else
		{
			strcatC(stream,Content_ID);
			strcatUC(stream,messmms->body[iType].Contentype.contentid);
		}
	}
	return stream;
}

/************************************************
编码content_type值域(contentype<0x80)函数
*************************************************/
UC* EncodeContentypeHeaderValue(UC *stream)
{
	UL32 allseconds;
	UC *datetmp;
	if(messmms->Contentype.accept)
	{
		strcatC(stream,Accept);
		strcatUC(stream,messmms->Contentype.accept);
	}

	if(messmms->Contentype.characterset)
	{
		strcatC(stream,Accept_Charset);
		strcatC(stream,(UC)(messmms->Contentype.characterset));
	}
	if(messmms->Contentype.charactersetext)
	{
		strcatC(stream,Accept_Charset);
		strcatUC(stream,messmms->Contentype.charactersetext);
	}

	if(messmms->Contentype.acceptencoding)
	{
		strcatC(stream,Accept_Encoding);
		strcatUC(stream,messmms->Contentype.acceptencoding);
	}

	if(messmms->Contentype.acceptlanguage)
	{
		strcatC(stream,Accept_Language);
		strcatC(stream,(UC)(messmms->Contentype.acceptlanguage));
	}
	if(messmms->Contentype.acceptlanguagetext)
	{
		strcatC(stream,Accept_Language);
		strcatUC(stream,messmms->Contentype.acceptlanguagetext);
	}

	if(messmms->Contentype.acceptranges)
	{
		strcatC(stream,Accept_Ranges);
		strcatC(stream,messmms->Contentype.acceptranges);
	}
	if(messmms->Contentype.acceptrangestext)
	{
		strcatC(stream,Accept_Ranges);
		strcatUC(stream,messmms->Contentype.acceptrangestext);
	}

	if(messmms->Contentype.cachecontrol)
	{
		strcatC(stream,Cache_Control);
		strcatC(stream,messmms->Contentype.cachecontrol);
	}
	if(messmms->Contentype.cachecontroltext)
	{
		strcatC(stream,Cache_Control);
		strcatUC(stream,messmms->Contentype.cachecontroltext);
	}

	if(messmms->Contentype.connectiontext)
	{
		strcatC(stream,Connection);
		strcatUC(stream,messmms->Contentype.connectiontext);
	}
	if(messmms->Contentype.connection)
	{
		strcatC(stream,Connection);
		strcatC(stream,messmms->Contentype.connection);
	}
	if(messmms->Contentype.contentbase)
	{
		strcatC(stream,Content_Base);
		strcatUC(stream,messmms->Contentype.contentbase);
	}

	if(messmms->Contentype.contentencoding)
	{
		strcatC(stream,Content_Encoding);
		strcatC(stream,messmms->Contentype.contentencoding);
	}
	if(messmms->Contentype.contentencodingtext)
	{
		strcatC(stream,Content_Encoding);
		strcatUC(stream,messmms->Contentype.contentencodingtext);
	}

	if(messmms->Contentype.contentlanguage)
	{
		strcatC(stream,Content_Language);
		strcatC(stream,messmms->Contentype.contentlanguage);
	}
	if(messmms->Contentype.contentlanguagetext)
	{
		strcatC(stream,Content_Language);
		strcatUC(stream,messmms->Contentype.contentlanguagetext);
	}

	if(messmms->Contentype.contentlocation)
	{
		strcatC(stream,Content_Location);
		strcatUC(stream,messmms->Contentype.contentlocation);
	}
	if(messmms->Contentype.date.datecontent.year)
	{
		allseconds = DateToSecond(messmms->Contentype.date.datecontent.year,
				messmms->Contentype.date.datecontent.month,messmms->Contentype.date.datecontent.day,
				messmms->Contentype.date.datecontent.hour,messmms->Contentype.date.datecontent.minute,
				messmms->Contentype.date.datecontent.second);
	
		datetmp = SecondsEncode(allseconds,messmms->Contentype.date.datelength); //执行移位操作
		strcatUCL(stream,datetmp,strlen((C*)datetmp));
	}

	if(messmms->Contentype.etag)
	{
		strcatC(stream,Etag);
		strcatUC(stream,messmms->Contentype.etag);
	}

	if(messmms->Contentype.expires.datecontent.year)
	{
		allseconds = DateToSecond(messmms->Contentype.expires.datecontent.year,
				messmms->Contentype.expires.datecontent.month,messmms->Contentype.expires.datecontent.day,
				messmms->Contentype.expires.datecontent.hour,messmms->Contentype.expires.datecontent.minute,
				messmms->Contentype.expires.datecontent.second);
	
		datetmp = SecondsEncode(allseconds,messmms->Contentype.expires.datelength); //执行移位操作
		strcatUCL(stream,datetmp,strlen((C*)datetmp));
	}

	if(messmms->Contentype.from)
	{
		strcatC(stream,From_Single);
		strcatUC(stream,messmms->Contentype.from);
	}
	if(messmms->Contentype.host)
	{
		strcatC(stream,Host);
		strcatUC(stream,messmms->Contentype.host);
	}
	if(messmms->Contentype.ifmatch)
	{
		strcatC(stream,If_Match);
		strcatUC(stream,messmms->Contentype.ifmatch);
	}
	if(messmms->Contentype.ifnonematch)
	{
		strcatC(stream,If_None_Match);
		strcatUC(stream,messmms->Contentype.ifnonematch);
	}
	if(messmms->Contentype.location)
	{
		strcatC(stream,Location);
		strcatUC(stream,messmms->Contentype.location);
	}
	if(messmms->Contentype.maxforwards)
	{
		strcatC(stream,Max_Forwards);
		strcatUC(stream,messmms->Contentype.maxforwards);
	}
	if(messmms->Contentype.range)
	{
		strcatC(stream,Range);
		strcatC(stream,messmms->Contentype.range);
	}
	if(messmms->Contentype.referer)
	{
		strcatC(stream,Referer);
		strcatUC(stream,messmms->Contentype.referer);
	}
	if(messmms->Contentype.server)
	{
		strcatC(stream,Server);
		strcatUC(stream,messmms->Contentype.server);
	}
	if(messmms->Contentype.upgrade)
	{
		strcatC(stream,Upgrade);
		strcatUC(stream,messmms->Contentype.upgrade);
	}
	if(messmms->Contentype.useragent)
	{
		strcatC(stream,User_Agent);
		strcatUC(stream,messmms->Contentype.useragent);
	}
	if(messmms->Contentype.via)
	{
		strcatC(stream,Via);
		strcatUC(stream,messmms->Contentype.via);
	}
	if(messmms->Contentype.warning)
	{
		strcatC(stream,Warning);
		strcatUC(stream,messmms->Contentype.warning);
	}
	if(messmms->Contentype.wapapplicationid)
	{
		strcatC(stream,X_Wap_Application_Id);
		strcatUC(stream,messmms->Contentype.wapapplicationid);
	}
	if(messmms->Contentype.wapcontenturl)
	{
		strcatC(stream,X_Wap_Content_URI);
		strcatUC(stream,messmms->Contentype.wapcontenturl);
	}
	if(messmms->Contentype.wapinitiatorurl)
	{
		strcatC(stream,X_Wap_Initiator_URI);
		strcatUC(stream,messmms->Contentype.wapinitiatorurl);
	}
	if(messmms->Contentype.bearerindication)
	{
		strcatC(stream,Bearer_Indication);
		strcatUC(stream,messmms->Contentype.bearerindication);
	}
	if(messmms->Contentype.pushflag)
	{
		strcatC(stream,Push_Flag);
		strcatUC(stream,messmms->Contentype.pushflag);
	}
	if(messmms->Contentype.profile)
	{
		strcatC(stream,Profile);
		strcatUC(stream,messmms->Contentype.profile);
	}

	if(messmms->Contentype.transferencoding)
	{
		strcatC(stream,Transfer_Encoding);
		strcatC(stream,messmms->Contentype.transferencoding);
	}
	if(messmms->Contentype.transferencodingtext)
	{
		strcatC(stream,Transfer_Encoding);
		strcatUC(stream,messmms->Contentype.transferencodingtext);
	}

	if(messmms->Contentype.contentid)
	{
		if(messmms->Contentype.contentidname)
		{
			strcatUC(stream,messmms->Contentype.contentidname); 
			strcatUC(stream,messmms->Contentype.contentid);
		}
		else
		{
			strcatC(stream,Content_ID);
			strcatUC(stream,messmms->Contentype.contentid);
		}
	}
	return stream;
}

/************************************************
*彩信编码主体函数
*************************************************/
UC *Amoi_MmsEncode(MMS_STRUCTION *messmms)
{	
	UC *stream = (UC*)SpaceMalloc(sizeof(UC)*MAXLENGTHOFMMS);  
	UC *pos = stream;  // pos 指向stream的结尾,每次加字符串都从尾部加入

	/****************	Heads  ****************/

	pos = strcatC(pos,MessageType);
	pos = strcatC(pos,messmms->messagetype);

	pos = strcatC(pos,Transaction_ID);
	pos = strcatUC(pos,messmms->transcationid);

	pos = strcatC(pos,Version);
	pos = strcatC(pos,(UC)messmms->version); 

	/* date */
	if(messmms->date.datecontent.year)
	{
		pos=strcatC(pos,Date);
		pos=strcatC(pos,(UC)messmms->date.datelength);
		UL32 allseconds = DateToSecond(messmms->date.datecontent.year,
						messmms->date.datecontent.month,messmms->date.datecontent.day,
						messmms->date.datecontent.hour,messmms->date.datecontent.minute,
						messmms->date.datecontent.second);

		UC *datetmp = SecondsEncode(allseconds,messmms->date.datelength); 
		pos=strcatUCL(pos,datetmp,DEStrlen((C*)datetmp));
	}

	/* from */
	if(messmms->from.content)
	{
		pos=strcatC(pos,From);
		if(messmms->from.length)
		{
			pos=strcatC(pos,(UC)messmms->from.length);
		}
		if(messmms->from.type)
		{
			pos=strcatC(pos,messmms->from.type);
		}

		pos=strcatUC(pos,messmms->from.content);
	}

	/* cc */
	if(messmms->cc)
	{
		UL32 ccnumbers;
		for(ccnumbers=0;ccnumbers < (messmms->cc->number);ccnumbers++)
		{
			pos=strcatC(pos,Cc);
			pos=strcatUC(pos,messmms->cc[ccnumbers].content);
		}
	}

	/* bcc */
	if(messmms->bcc)
	{
		UL32 bccnumber;
		for(bccnumber=0;bccnumber < (messmms->bcc->number);bccnumber++)
		{
			pos=strcatC(pos,Bcc);
			pos=strcatUC(pos,messmms->bcc[bccnumber].content);
		}
	}
	
	/* to */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -