00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 00019 #ifndef __XRD_CL_STATUS_HH__ 00020 #define __XRD_CL_STATUS_HH__ 00021 00022 #include <stdint.h> 00023 #include <errno.h> 00024 #include <sstream> 00025 00026 namespace XrdCl 00027 { 00028 //---------------------------------------------------------------------------- 00029 // Constants 00030 //---------------------------------------------------------------------------- 00031 const uint16_t stOK = 0x0000; 00032 const uint16_t stError = 0x0001; 00033 const uint16_t stFatal = 0x0003; 00034 00035 //---------------------------------------------------------------------------- 00036 // Additional info for the stOK status 00037 //---------------------------------------------------------------------------- 00038 const uint16_t suDone = 0; 00039 const uint16_t suContinue = 1; 00040 const uint16_t suRetry = 2; 00041 const uint16_t suPartial = 3; 00042 const uint16_t suAlreadyDone = 4; 00043 00044 //---------------------------------------------------------------------------- 00045 // Generic errors 00046 //---------------------------------------------------------------------------- 00047 const uint16_t errNone = 0; 00048 const uint16_t errRetry = 1; 00049 const uint16_t errUnknown = 2; 00050 const uint16_t errInvalidOp = 3; 00051 00052 const uint16_t errFcntl = 4; 00053 const uint16_t errPoll = 5; 00054 const uint16_t errConfig = 6; 00055 const uint16_t errInternal = 7; 00056 const uint16_t errUnknownCommand = 8; 00057 const uint16_t errInvalidArgs = 9; 00058 const uint16_t errInProgress = 10; 00059 const uint16_t errUninitialized = 11; 00060 const uint16_t errOSError = 12; 00061 const uint16_t errNotSupported = 13; 00062 const uint16_t errDataError = 14; 00063 const uint16_t errNotImplemented = 15; 00064 const uint16_t errNoMoreReplicas = 16; 00065 const uint16_t errPipelineFailed = 17; 00066 00067 //---------------------------------------------------------------------------- 00068 // Socket related errors 00069 //---------------------------------------------------------------------------- 00070 const uint16_t errInvalidAddr = 101; 00071 const uint16_t errSocketError = 102; 00072 const uint16_t errSocketTimeout = 103; 00073 const uint16_t errSocketDisconnected = 104; 00074 const uint16_t errPollerError = 105; 00075 const uint16_t errSocketOptError = 106; 00076 const uint16_t errStreamDisconnect = 107; 00077 const uint16_t errConnectionError = 108; 00078 const uint16_t errInvalidSession = 109; 00079 const uint16_t errTlsError = 110; 00080 00081 //---------------------------------------------------------------------------- 00082 // Post Master related errors 00083 //---------------------------------------------------------------------------- 00084 const uint16_t errInvalidMessage = 201; 00085 const uint16_t errHandShakeFailed = 202; 00086 const uint16_t errLoginFailed = 203; 00087 const uint16_t errAuthFailed = 204; 00088 const uint16_t errQueryNotSupported = 205; 00089 const uint16_t errOperationExpired = 206; 00090 const uint16_t errOperationInterrupted = 207; 00091 00092 //---------------------------------------------------------------------------- 00093 // XRootD related errors 00094 //---------------------------------------------------------------------------- 00095 const uint16_t errNoMoreFreeSIDs = 301; 00096 const uint16_t errInvalidRedirectURL = 302; 00097 const uint16_t errInvalidResponse = 303; 00098 const uint16_t errNotFound = 304; 00099 const uint16_t errCheckSumError = 305; 00100 const uint16_t errRedirectLimit = 306; 00101 00102 const uint16_t errErrorResponse = 400; 00103 const uint16_t errRedirect = 401; 00104 00105 const uint16_t errResponseNegative = 500; 00106 00107 //---------------------------------------------------------------------------- 00109 //---------------------------------------------------------------------------- 00110 struct Status 00111 { 00112 //-------------------------------------------------------------------------- 00114 //-------------------------------------------------------------------------- 00115 Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ): 00116 status(st), code(cod), errNo( errN ) {} 00117 00118 bool IsError() const { return status & stError; } 00119 bool IsFatal() const { return (status&0x0002) & stFatal; } 00120 bool IsOK() const { return status == stOK; } 00121 00122 //-------------------------------------------------------------------------- 00124 //-------------------------------------------------------------------------- 00125 int GetShellCode() const 00126 { 00127 if( IsOK() ) 00128 return 0; 00129 return (code/100)+50; 00130 } 00131 00132 //-------------------------------------------------------------------------- 00134 //-------------------------------------------------------------------------- 00135 std::string ToString() const; 00136 00137 uint16_t status; 00138 uint16_t code; 00139 uint32_t errNo; 00140 }; 00141 } 00142 00143 #endif // __XRD_CL_STATUS_HH__