From cd6e40a206f36ecdc26468f8064d9d25a6fe3de7 Mon Sep 17 00:00:00 2001 From: Cedric RICARD Date: Tue, 20 Jan 2009 22:39:43 +0000 Subject: [PATCH] More message constants into NetServices --- calexium_lib/net_services/CXM_generic_protocol.anubis | 58 +++++++++++++++++++++++++++++++++------------------------- calexium_lib/net_services_protocols/ftp_client.anubis | 1 + 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/calexium_lib/net_services/CXM_generic_protocol.anubis b/calexium_lib/net_services/CXM_generic_protocol.anubis index 426d071..433f9d8 100644 --- a/calexium_lib/net_services/CXM_generic_protocol.anubis +++ b/calexium_lib/net_services/CXM_generic_protocol.anubis @@ -14,18 +14,21 @@ read tools/basis.anubis read system/message_queue.anubis read calexium_lib/CXM_message_constants.anubis -public define Word32 _CXM_OK = 0. -public define Word32 _CXM_ERROR = 1. -public define Word32 _CXM_UNKNOW_CMD = 2. -public define Word32 _CXM_UNKNOW_SERVICE = 3. +public define Word32 _CXM_OK = 0. +public define Word32 _CXM_ERROR = 1. +public define Word32 _CXM_UNKNOW_CMD = 2. +public define Word32 _CXM_UNKNOW_SERVICE = 3. public define Word32 _CXM_MISSING_REQUIRED_FIELD = 4. -public define Word32 _CXM_FORBIDDEN = 5. +public define Word32 _CXM_FORBIDDEN = 5. +public define Word32 _CXM_BAD_AUTHENTICATION = 6. +public define Word32 _CXM_TEMPORARY_ERROR = 7. // When received, the client should try later public type ProtocolResult: failure, timeout, unknow_cmd, error, + error(Word32, String), ok, ok_msg(Message). @@ -33,8 +36,8 @@ public define One send_ACK_error ( MessageQueue queue, - Word32 cmd_id, - Word32 error_code, + Word32 cmd_id, + Word32 error_code, String error_string, )= with err_msg = message(_CXM_ACK), @@ -137,24 +140,29 @@ public define ProtocolResult failure then failure, //println("wait_for_reply CMD"); success(cmd) then // println("wait_for_reply CMD="+to_hexa(cmd)); - if find_int32(_msg, "STATUS") is - { - failure then failure, //println("wait_for_reply STATUS"); - success(status) then - if cmd = wait_cmd & status = _CXM_OK then - if find_message(_msg, "RESULT") is - { - failure then ok, - success(ok_message) then ok_msg(ok_message) - } - else if cmd = wait_cmd & status = _CXM_ERROR then - error - else if cmd = wait_cmd & status = _CXM_UNKNOW_CMD then - unknow_cmd - else - failure //println("wait_for_reply "); - } - } + if find_int32(_msg, "STATUS") is + { + failure then failure, //println("wait_for_reply STATUS"); + success(status) then + if cmd = wait_cmd then + ( + if status = _CXM_OK then + if find_message(_msg, "RESULT") is + { + failure then ok, + success(ok_message) then ok_msg(ok_message) + } + else if status = _CXM_ERROR then + error + else if status = _CXM_UNKNOW_CMD then + unknow_cmd + else + error(status, if find_string(_msg, "STATUS_MSG") is success(txt) then txt else "") + ) + else + failure //println("wait_for_reply "); + } + } else failure //println("wait_for_reply not ACK"); }. diff --git a/calexium_lib/net_services_protocols/ftp_client.anubis b/calexium_lib/net_services_protocols/ftp_client.anubis index 7fec923..e448420 100644 --- a/calexium_lib/net_services_protocols/ftp_client.anubis +++ b/calexium_lib/net_services_protocols/ftp_client.anubis @@ -91,6 +91,7 @@ define Maybe(One) timeout then println("get_file timeout");failure, unknow_cmd then println("get_file unknow_cmd");failure, error then println("get_file remote error msg");failure, + error(c,m) then println("get_file remote error [" + c + "] msg '" + m + "'");failure, ok then println("get_file ok");failure, ok_msg(msg)then if find_int32(msg, "FileSize") is -- libgit2 0.21.4