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 00066 //---------------------------------------------------------------------------- 00067 // Socket related errors 00068 //---------------------------------------------------------------------------- 00069 const uint16_t errInvalidAddr = 101; 00070 const uint16_t errSocketError = 102; 00071 const uint16_t errSocketTimeout = 103; 00072 const uint16_t errSocketDisconnected = 104; 00073 const uint16_t errPollerError = 105; 00074 const uint16_t errSocketOptError = 106; 00075 const uint16_t errStreamDisconnect = 107; 00076 const uint16_t errConnectionError = 108; 00077 const uint16_t errInvalidSession = 109; 00078 00079 //---------------------------------------------------------------------------- 00080 // Post Master related errors 00081 //---------------------------------------------------------------------------- 00082 const uint16_t errInvalidMessage = 201; 00083 const uint16_t errHandShakeFailed = 202; 00084 const uint16_t errLoginFailed = 203; 00085 const uint16_t errAuthFailed = 204; 00086 const uint16_t errQueryNotSupported = 205; 00087 const uint16_t errOperationExpired = 206; 00088 00089 //---------------------------------------------------------------------------- 00090 // XRootD related errors 00091 //---------------------------------------------------------------------------- 00092 const uint16_t errNoMoreFreeSIDs = 301; 00093 const uint16_t errInvalidRedirectURL = 302; 00094 const uint16_t errInvalidResponse = 303; 00095 const uint16_t errNotFound = 304; 00096 const uint16_t errCheckSumError = 305; 00097 const uint16_t errRedirectLimit = 306; 00098 00099 const uint16_t errErrorResponse = 400; 00100 const uint16_t errRedirect = 401; 00101 00102 const uint16_t errResponseNegative = 500; 00103 00104 //---------------------------------------------------------------------------- 00106 //---------------------------------------------------------------------------- 00107 struct Status 00108 { 00109 //-------------------------------------------------------------------------- 00111 //-------------------------------------------------------------------------- 00112 Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ): 00113 status(st), code(cod), errNo( errN ) {} 00114 00115 bool IsError() const { return status & stError; } 00116 bool IsFatal() const { return (status&0x0002) & stFatal; } 00117 bool IsOK() const { return status == stOK; } 00118 00119 //-------------------------------------------------------------------------- 00121 //-------------------------------------------------------------------------- 00122 int GetShellCode() const 00123 { 00124 if( IsOK() ) 00125 return 0; 00126 return (code/100)+50; 00127 } 00128 00129 //-------------------------------------------------------------------------- 00131 //-------------------------------------------------------------------------- 00132 std::string ToString() const; 00133 00134 uint16_t status; 00135 uint16_t code; 00136 uint32_t errNo; 00137 }; 00138 } 00139 00140 #endif // __XRD_CL_STATUS_HH__