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

📄 megaco_pretty_text_encoder_v2.erl

📁 OTP是开放电信平台的简称
💻 ERL
📖 第 1 页 / 共 2 页
字号:
%% ``The contents of this file are subject to the Erlang Public License,%% Version 1.1, (the "License"); you may not use this file except in%% compliance with the License. You should have received a copy of the%% Erlang Public License along with this software. If not, it can be%% retrieved via the world wide web at http://www.erlang.org/.%% %% Software distributed under the License is distributed on an "AS IS"%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See%% the License for the specific language governing rights and limitations%% under the License.%% %% The Initial Developer of the Original Code is Ericsson Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %%     $Id$%%%%----------------------------------------------------------------------%%% Purpose: Encode PRETTY Megaco/H.248 text messages from internal form%%-----------------------------------------------------------------------module(megaco_pretty_text_encoder_v2).-export([encode_message/2,	 encode_transaction/2,	 encode_action_requests/2,	 encode_action_request/2,	 encode_command_request/2,	 encode_action_reply/2]).-export([token_tag2string/1]).-include_lib("megaco/include/megaco.hrl").-include_lib("megaco/include/megaco_message_v2.hrl").-define(encoder_version_pre_prev3c,true).-include("megaco_text_tokens.hrl").%%----------------------------------------------------------------------%% Convert a 'MegacoMessage' record into a binary%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_message(EC, MegaMsg)   when is_list(EC) and is_record(MegaMsg, 'MegacoMessage') ->    case (catch enc_MegacoMessage(MegaMsg)) of	{'EXIT', Reason} ->	    {error, Reason};	Bin when binary(Bin) ->	    {ok, Bin};	DeepIoList ->	    Bin = erlang:list_to_binary(DeepIoList),	    {ok, Bin}    end;encode_message(EncodingConfig, MegaMsg)   when is_record(MegaMsg, 'MegacoMessage')  ->    {error, {bad_encoding_config, EncodingConfig}};encode_message(_EncodingConfig, _MegaMsg) ->    {error, bad_megaco_message}.	    %%----------------------------------------------------------------------%% Convert a binary into a 'MegacoMessage' record%% Return {ok, MegacoMessageRecord} | {error, Reason}%% %% See megaco_pretty_text_encoder:decode_message/2%% %%----------------------------------------------------------------------%%----------------------------------------------------------------------%% Convert a transaction record into a deep io list%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_transaction(_EC, Trans) ->    case (catch enc_Transaction(Trans)) of        {'EXIT', Reason} ->            {error, Reason};        Bin when binary(Bin) ->            {ok, Bin};        DeepIoList ->            Bin = erlang:list_to_binary(DeepIoList),            {ok, Bin}    end.%%----------------------------------------------------------------------%% Convert a list of ActionRequest record's into a binary%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_action_requests(_EC, ActReqs) when list(ActReqs) ->     case (catch enc_ActionRequests(ActReqs)) of	{'EXIT', Reason} ->	    {error, Reason};	Bin when binary(Bin) ->	    {ok, Bin};	DeepIoList ->	    Bin = erlang:list_to_binary(DeepIoList),	    {ok, Bin}    end.%%----------------------------------------------------------------------%% Convert a ActionRequest record into a binary%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_action_request(_EC, ActReq)   when record(ActReq, 'ActionRequest') ->    case (catch enc_ActionRequest(ActReq)) of	{'EXIT', Reason} ->	    {error, Reason};	Bin when binary(Bin) ->	    {ok, Bin};	DeepIoList ->	    Bin = erlang:list_to_binary(DeepIoList),	    {ok, Bin}    end.%%----------------------------------------------------------------------%% Convert a CommandRequest record into a deep io list%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_command_request(_EC, CmdReq)   when record(CmdReq, 'CommandRequest') ->    case (catch enc_CommandRequest(CmdReq)) of        {'EXIT', Reason} ->            {error, Reason};        Bin when binary(Bin) ->            {ok, Bin};        DeepIoList ->            Bin = erlang:list_to_binary(DeepIoList),            {ok, Bin}    end.%%----------------------------------------------------------------------%% Convert a action reply into a deep io list%% Return {ok, DeepIoList} | {error, Reason}%%----------------------------------------------------------------------encode_action_reply(_EC, ActRep)   when record(ActRep, 'ActionReply') ->    case (catch enc_ActionReply(ActRep)) of        {'EXIT', Reason} ->            {error, Reason};        DeepIoList ->            {ok, DeepIoList}    end.%%----------------------------------------------------------------------%% A utility function to pretty print the tags found in a megaco message%%----------------------------------------------------------------------token_tag2string(addReq)                 -> ?PrettyAddToken;token_tag2string(addReply)               -> ?PrettyAddToken;token_tag2string(auditDescriptor)        -> ?PrettyAuditToken;token_tag2string(auditCapRequest)        -> ?PrettyAuditCapToken;token_tag2string(auditCapReply)          -> ?PrettyAuditCapToken;token_tag2string(auditValueRequest)      -> ?PrettyAuditValueToken;token_tag2string(auditValueReply)        -> ?PrettyAuditValueToken;%% token_tag2string(X) -> ?PrettyAuthToken;token_tag2string(bothway)                -> ?PrettyBothwayToken;token_tag2string(brief)                  -> ?PrettyBriefToken;%% token_tag2string(X) -> ?PrettyBufferToken;%% token_tag2string(X) -> ?PrettyCtxToken;%% token_tag2string(X) -> ?PrettyContextAuditToken;token_tag2string(digitMapDescriptor)     -> ?PrettyDigitMapToken;token_tag2string(digitMapToken)          -> ?PrettyDigitMapToken;%% token_tag2string(X) -> ?PrettyDiscardToken;%% token_tag2string(X) -> ?PrettyDisconnectedToken;%% token_tag2string(X) -> ?PrettyDelayToken;token_tag2string(duration)               -> ?PrettyDurationToken;%% token_tag2string(X) -> ?PrettyEmbedToken;token_tag2string(emergencyAudit)         -> ?PrettyEmergencyToken;%% token_tag2string(X)         -> ?PrettyEmergencyOffToken;token_tag2string(errorDescriptor)        -> ?PrettyErrorToken;token_tag2string(eventBufferDescriptor)  -> ?PrettyEventBufferToken;token_tag2string(eventBufferToken)       -> ?PrettyEventBufferToken;token_tag2string(eventsDescriptor)       -> ?PrettyEventsToken;token_tag2string(eventsToken)            -> ?PrettyEventsToken;%% token_tag2string(X) -> ?PrettyFailoverToken;%% token_tag2string(X) -> ?PrettyForcedToken;%% token_tag2string(X) -> ?PrettyGracefulToken;%% token_tag2string(X) -> ?PrettyH221Token;%% token_tag2string(X) -> ?PrettyH223Token;%% token_tag2string(X) -> ?PrettyH226Token;%% token_tag2string(X) -> ?PrettyHandOffToken;%% token_tag2string(X) -> ?PrettyImmAckRequiredToken;token_tag2string(inactive)                    -> ?PrettyInactiveToken;token_tag2string(onInterruptByEvent)          -> ?PrettyInterruptByEventToken;token_tag2string(onInterruptByNewSignalDescr) -> ?PrettyInterruptByNewSignalsDescrToken;token_tag2string(isolate)        	 -> ?PrettyIsolateToken;token_tag2string(inSvc)          	 -> ?PrettyInSvcToken;token_tag2string(keepActive)     	 -> ?PrettyKeepActiveToken;token_tag2string(localDescriptor)        -> ?PrettyLocalToken;token_tag2string(localControlDescriptor) -> ?PrettyLocalControlToken;token_tag2string(lockStep)          	 -> ?PrettyLockStepToken;token_tag2string(loopBack)          	 -> ?PrettyLoopbackToken;token_tag2string(mediaDescriptor)   	 -> ?PrettyMediaToken;token_tag2string(mediaToken)        	 -> ?PrettyMediaToken;%% token_tag2string(X) -> ?PrettyMegacopToken;%% token_tag2string(X) -> ?PrettyMethodToken;%% token_tag2string(X) -> ?PrettyMgcIdToken;%% token_tag2string(X) -> ?PrettyModeToken;token_tag2string(modReq)               -> ?PrettyModifyToken;token_tag2string(modReply)             -> ?PrettyModifyToken;token_tag2string(modemDescriptor)      -> ?PrettyModemToken;token_tag2string(modemToken)           -> ?PrettyModemToken;token_tag2string(moveReq)              -> ?PrettyMoveToken;

⌨️ 快捷键说明

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