applayerprotocols/ftpengine/ftpprot/PASVANS.H
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 /**
       
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * PASV command answer parser
       
    16 * Author:	Philippe Gabriel
       
    17 * RFC 959 defines the syntax for answer to the PASV command
       
    18 * We must parse an IP+Port number (decimal, big endian)
       
    19 * (ip1,ip2,ip3,ip4,ip5,port1,port2)
       
    20 * We parse these regular expressions using an FSM
       
    21 * Use:
       
    22 * TFtpPASVAnswerParser::Reset 
       
    23 * to Reset the parser before we begin to parse a new answer
       
    24 * TFtpPASVAnswerParser::Parse 
       
    25 * to parse an answer
       
    26 * returns:
       
    27 * TRUE: we parsed an answer (answer might be correct or inccorect)
       
    28 * FALSE: An answer has not been completely parsed yet
       
    29 * TFtpPASVAnswerParser::Fetch 
       
    30 * Fetch an answer
       
    31 * returns:
       
    32 * TRUE: We got a valid answer
       
    33 * FALSE: The answer we got had an invalid syntax
       
    34 * 
       
    35 *
       
    36 */
       
    37 
       
    38 
       
    39 
       
    40 /**
       
    41  @file PASVANS.H
       
    42  @internalComponent
       
    43 */
       
    44 
       
    45 #if !defined(__PASVANS_H__)
       
    46 #define __PASVANS_H__
       
    47 #include <e32base.h>
       
    48 #include <in_sock.h>
       
    49 
       
    50 //////////////////////////////////////////////////////////////
       
    51 // Definitions
       
    52 //////////////////////////////////////////////////////////////
       
    53 
       
    54 class TFtpPASVAnswerParser 
       
    55 /**
       
    56 @internalComponent
       
    57 */
       
    58 {
       
    59 
       
    60 public:
       
    61 	enum TState
       
    62 		{
       
    63 		/** Do some clever encoding here 
       
    64 		*/
       
    65 		EIdle=0,	
       
    66 		/** to simplify parsing code
       
    67 		*/
       
    68 		EBeginParse=1,	
       
    69 		EParsing=2,
       
    70 		ESuccess,EFailed
       
    71 		};
       
    72 
       
    73 			TFtpPASVAnswerParser(void){iState=EIdle;}
       
    74 	TBool	Parse(const TDesC8&, const TInetAddr& aAddr);
       
    75 	TBool	Fetch(TInetAddr& aFTPServerAddress);
       
    76 	void	Reset(void);
       
    77 private:
       
    78 	/** Helper to Parse() */
       
    79 	TBool ParsePASV(const TDesC8&); 
       
    80 	/** Helper to Parse() */
       
    81 	TBool ParseEPSV(const TDesC8&); 
       
    82 	/** The current state of the parser */
       
    83 	TUint		iState;	
       
    84 	/** The parsed answer digits */
       
    85 	TBuf<12>	iDigit; 
       
    86 	TInetAddr   iFTPServerAddress;
       
    87 	TInt		iNumberCounter;
       
    88 };
       
    89 
       
    90 #endif // __PASVANS_H__