XrdClStatus.hh

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

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7