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   const uint16_t suXRDRedirect     = 101;
00045 
00046   //----------------------------------------------------------------------------
00047   // Generic errors
00048   //----------------------------------------------------------------------------
00049   const uint16_t errNone           = 0; 
00050   const uint16_t errRetry          = 1; 
00051   const uint16_t errUnknown        = 2; 
00052   const uint16_t errInvalidOp      = 3; 
00053 
00054   const uint16_t errFcntl          = 4; 
00055   const uint16_t errPoll           = 5; 
00056   const uint16_t errConfig         = 6; 
00057   const uint16_t errInternal       = 7; 
00058   const uint16_t errUnknownCommand = 8;
00059   const uint16_t errInvalidArgs    = 9;
00060   const uint16_t errInProgress     = 10;
00061   const uint16_t errUninitialized  = 11;
00062   const uint16_t errOSError        = 12;
00063   const uint16_t errNotSupported   = 13;
00064   const uint16_t errDataError      = 14; 
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 
00101   //----------------------------------------------------------------------------
00103   //----------------------------------------------------------------------------
00104   struct Status
00105   {
00106     //--------------------------------------------------------------------------
00108     //--------------------------------------------------------------------------
00109     Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ):
00110       status(st), code(cod), errNo( errN ) {}
00111 
00112     bool IsError() const { return status & stError; }           
00113     bool IsFatal() const { return (status&0x0002) & stFatal; }  
00114     bool IsOK()    const { return status == stOK; }             
00115 
00116     //--------------------------------------------------------------------------
00118     //--------------------------------------------------------------------------
00119     int GetShellCode() const
00120     {
00121       if( IsOK() )
00122         return 0;
00123       return (code/100)+50;
00124     }
00125 
00126     //--------------------------------------------------------------------------
00128     //--------------------------------------------------------------------------
00129     std::string ToString() const;
00130 
00131     uint16_t status;     
00132     uint16_t code;       
00133     uint32_t errNo;      
00134   };
00135 }
00136 
00137 #endif // __XRD_CL_STATUS_HH__

Generated on 16 Jan 2014 for xrootd by  doxygen 1.4.7