Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Net/TFTP/TFTP_Error.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__TFTP_Error_HPP__
00002 #define __J2K__TFTP_Error_HPP__
00003 
00004 #include <j2k/Fred/Standard.hpp>
00005 #include <j2k/Fred/Error/JErrorController.hpp>
00006 #include <j2k/Net/TFTP/TFTP_Option.hpp>
00007 #include <j2k/Net/TFTP/TFTP_Packet.hpp>
00008 
00009 static void TFTP_NotDefinedErrorHandler( MC_JErrorHandlerArg )
00010 {
00011   if ( option.isConnected() ) {
00012     TFTP_Packet pkt;
00013     pkt.sendError( TFTP_NotDefined, errmsg );
00014   }
00015   defaultErrorHandler( level, no, errmsg, line, file );
00016 }
00017 
00018 static void TFTP_FileNotFoundErrorHandler( MC_JErrorHandlerArg )
00019 {
00020   if ( option.isConnected() ) {
00021     TFTP_Packet pkt;
00022     pkt.sendError( TFTP_FileNotFound, errmsg );
00023   }
00024   defaultErrorHandler( level, no, errmsg, line, file );
00025 }
00026 
00027 static void TFTP_AccessViolationErrorHandler( MC_JErrorHandlerArg )
00028 {
00029   if ( option.isConnected() ) {
00030     TFTP_Packet pkt;
00031     pkt.sendError( TFTP_AccessViolation, errmsg );
00032   }
00033   defaultErrorHandler( level, no, errmsg, line, file );
00034 }
00035 
00036 static void TFTP_DiskFullErrorHandler( MC_JErrorHandlerArg )
00037 {
00038   if ( option.isConnected() ) {
00039     TFTP_Packet pkt;
00040     pkt.sendError( TFTP_DiskFull, errmsg );
00041   }
00042   defaultErrorHandler( level, no, errmsg, line, file );
00043 }
00044 
00045 static void TFTP_IllegalOpErrorHandler( MC_JErrorHandlerArg )
00046 {
00047   if ( option.isConnected() ) {
00048     TFTP_Packet pkt;
00049     pkt.sendError( TFTP_IllegalOp, errmsg );
00050   }
00051   defaultErrorHandler( level, no, errmsg, line, file );
00052 }
00053 
00054 static void TFTP_FileAlreadyExistErrorHandler( MC_JErrorHandlerArg )
00055 {
00056   if ( option.isConnected() ) {
00057     TFTP_Packet pkt;
00058     pkt.sendError( TFTP_FileAlreadyExist, errmsg );
00059   }
00060   defaultErrorHandler( level, no, errmsg, line, file );
00061 }
00062 
00063 // Shouldn't happen, since no Mail option in this TFTP.
00064 static void TFTP_NoSuchUserErrorHandler( MC_JErrorHandlerArg )
00065 {
00066   if ( option.isConnected() ) {
00067     TFTP_Packet pkt;
00068     pkt.sendError( TFTP_NoSuchUser, errmsg );
00069   }
00070   defaultErrorHandler( level, no, errmsg, line, file );
00071 }
00072 
00073 #define SendNotDefinedError( errmsg ) \
00074   TFTP_NotDefinedErrorHandler( Error, TFTPerror_NotDefined,   errmsg, __LINE__, __FILE__ ) 
00075 
00076 #define SendIllegalOpError( errmsg ) \
00077   TFTP_IllegalOpErrorHandler( Error, TFTPerror_IllegalOpCode, errmsg, __LINE__, __FILE__ ) 
00078 
00079 #define ADD_TFTP_ERROR0( i ) \
00080   pgmErrorController.add( (JErrorNo)(i), TFTP_NotDefinedErrorHandler, 2    );
00081 
00082 #define ADD_TFTP_ERROR1( i ) \
00083   pgmErrorController.add( (JErrorNo)(i), TFTP_FileNotFoundErrorHandler, 2  );
00084 
00085 #define ADD_TFTP_ERROR2( i ) \
00086   pgmErrorController.add( (JErrorNo)(i), TFTP_AccessViolationErrorHandler, 2 );
00087 
00088 #define ADD_TFTP_ERROR3( i ) \
00089   pgmErrorController.add( (JErrorNo)(i), TFTP_DiskFullErrorHandler, 2      );
00090 
00091 #define ADD_TFTP_ERROR4( i ) \
00092   pgmErrorController.add( (JErrorNo)(i), TFTP_IllegalOpErrorHandler, 2     );
00093 
00094 #define ADD_TFTP_ERROR5( i ) \
00095   pgmErrorController.add( (JErrorNo)(i), TFTP_FileAlreadyExistErrorHandler, 2 );
00096 
00097 #define ADD_TFTP_ERROR6( i ) \
00098   pgmErrorController.add( (JErrorNo)(i), TFTP_NoSuchUserErrorHandler, 2    );
00099 
00100 
00101 // Look associated numbers        in <Error/JError.hpp>
00102 // Look associated TFTP_errcode_t in <j2k/Net/TFTP/TFTP_header.hpp> 
00103 static void add_TFTP_ErrorHandlers() 
00104 {
00105   ADD_TFTP_ERROR1(  2 )
00106   ADD_TFTP_ERROR0(  5 )
00107   ADD_TFTP_ERROR0(  9 )
00108   ADD_TFTP_ERROR0( 11 )
00109   ADD_TFTP_ERROR2( 13 )
00110   ADD_TFTP_ERROR2( 14 )
00111   ADD_TFTP_ERROR0( 16 )
00112   ADD_TFTP_ERROR5( 17 )
00113   ADD_TFTP_ERROR1( 19 )
00114   ADD_TFTP_ERROR2( 21 )
00115   ADD_TFTP_ERROR0( 23 )
00116   ADD_TFTP_ERROR0( 24 )
00117   ADD_TFTP_ERROR0( 26 )
00118   ADD_TFTP_ERROR3( 27 )
00119   ADD_TFTP_ERROR3( 28 )
00120   ADD_TFTP_ERROR2( 30 )
00121   ADD_TFTP_ERROR3( 49 )
00122   ADD_TFTP_ERROR0( 56 )
00123   ADD_TFTP_ERROR0( 81 )
00124 
00125   // Add default TFTP handlers
00126   short k = 0;
00127   for( ; k < 255; k++ ) {
00128     if ( pgmErrorController.getID( (JErrorNo)(k) ) < 2 ) {
00129       ADD_TFTP_ERROR0( k )
00130     }
00131   }
00132 
00133 }
00134 
00135 #endif
00136 
00137 
00138 
00139 

Generated on Sun Oct 14 18:46:34 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001