sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Abstraction representing a UNIX file descriptor
sl@0: // CFileDescBase maintains the simple semantics of
sl@0: // Dup() and Close(), so the final Close() will
sl@0: // delete the object and hence call the destructor.
sl@0: // 
sl@0: //
sl@0: 
sl@0: #ifndef _FDESC_H
sl@0: #define _FDESC_H
sl@0: 
sl@0: #include <e32std.h>
sl@0: #include <e32atomics.h>
sl@0: #include <e32cons.h>
sl@0: #include <f32file.h>
sl@0: #include <es_sock.h>
sl@0: #include <c32comm.h>
sl@0: #include <stddef.h>
sl@0: #include <cdblen.h>
sl@0: #include <commdb.h>
sl@0: #include <commdbconnpref.h>
sl@0: #include <sys/stat.h>
sl@0: #include <fcntl.h>
sl@0: #include <rpipe.h>
sl@0: #include <in_sock.h>
sl@0: 
sl@0: #include "base.h"
sl@0: #include "StdioClient.h"
sl@0: 
sl@0: //FD attributes used internally by the backend
sl@0: const TUint KInvalidFd 		= 0x00000001;
sl@0: const TUint KMMapedFd 		= 0x00000002;
sl@0: const TUint KCloseonExec    = 0x00000004;
sl@0: const TUint KPipeFd         = 0x00000008;
sl@0: const TUint KIoctlOutstanding = 0x00000010;
sl@0: const TUint KConsoleFd         = 0x00000020;
sl@0: const TUint KFifoFd			= 0x00000030;
sl@0: const TUint KSpawnCloseInChild = 0x00000040;
sl@0: 
sl@0: #define SET_CLOSE_ON_EXEC_FLG   (1 << 2) 
sl@0: 
sl@0: #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
sl@0: 
sl@0: //Large File Support - Use RFile64 and 64 bit file sizes
sl@0: #define RFILE 	RFile64
sl@0: #define FSIZE	TInt64
sl@0: 
sl@0: #else
sl@0: 
sl@0: //No large file support - Use RFile and 32 bit file sizes
sl@0: #define RFILE 	RFile
sl@0: #define FSIZE	TInt
sl@0: 
sl@0: #endif //SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS
sl@0: 
sl@0: // Atomic socket operations support
sl@0: 
sl@0: #define ATOMICSOCKETOP(realcall,on_error) \
sl@0:     { \
sl@0:     if (__e32_atomic_tau_ord32((void *)&iCount, 0x8000, 0, 1) >= 0x8000) \
sl@0:         { \
sl@0:         on_error; \
sl@0:         } \
sl@0:     else \
sl@0:         { \
sl@0:         realcall; \
sl@0:         __e32_atomic_tas_ord32((void *)&iCount, 0, -1, 0); \
sl@0:         } \
sl@0:     }
sl@0: 
sl@0: #define NOP 
sl@0: 
sl@0: //Enumarations for Polling
sl@0: enum TPollMode
sl@0:     {
sl@0:     EReadyForReading = 1,
sl@0:     EReadyForWriting = 2,
sl@0:     EAnyException = 4
sl@0:     };
sl@0:   
sl@0: //Enumarations for Redirection Server
sl@0: enum TRedirConnState
sl@0: 	{
sl@0: 	ENotConnected,
sl@0: 	EConnected,
sl@0: 	ENoServer
sl@0: 	};
sl@0: 
sl@0: //Enumerations for the console echo
sl@0: enum TConsoleEcho
sl@0: 	{
sl@0: 	EOff = 0, //Turn Off the echo
sl@0: 	EOn = 1,  //Turn On the echo
sl@0: 	EPrintValid = 33, //Printable ascii character set <33-126>
sl@0: 	EPrintInvalid=127 
sl@0: 	};
sl@0: 	
sl@0: //  The base class for all flavours of FileDescriptor
sl@0: //
sl@0: class CSocketDesc;
sl@0: 
sl@0: NONSHARABLE_CLASS(CFileDescBase) : public CBase
sl@0: /*
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 
sl@0: 	static CFileDescBase* Open(const wchar_t* name, int mode, int perms, TInt& err);
sl@0: 	static CFileDescBase* Socket(RSocketServ& aSs, int family, int style, int protocol, TInt& err);
sl@0: 
sl@0: 	virtual void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	virtual TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
sl@0: 	virtual void ReadCancel();
sl@0: 
sl@0: 	virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	virtual TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
sl@0: 	virtual void WriteCancel();
sl@0: 	virtual TInt SetAtt(TUint aSetAttMask, TUint aClearAttMask);
sl@0: 
sl@0: 	virtual void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	virtual TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
sl@0: 	virtual void IoctlCancel();
sl@0: 
sl@0: 	virtual void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
sl@0: 	virtual void RecvFromCancel();
sl@0: 
sl@0: 	virtual void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen,int flags, TRequestStatus& aStatus);
sl@0: 
sl@0: 	virtual void SendToCancel();
sl@0: 
sl@0: 	virtual TInt CompletionStatus(TInt& aLength, TInt aStatus);
sl@0: 
sl@0: 	virtual void Sync(TRequestStatus& aStatus);
sl@0: 	virtual void SyncCancel();
sl@0: 
sl@0: 	virtual void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs,TSockAddr *aAddr);
sl@0: 	virtual void AcceptCancel();
sl@0: 
sl@0: 	virtual void Connect(const struct sockaddr* aAddr,unsigned long size,TRequestStatus& aStatus);
sl@0: 	virtual void ConnectCancel();
sl@0: 	virtual TBool GetConnectionProgress();
sl@0: 	virtual void SetConnectionProgress( TBool aInProgress );
sl@0: 
sl@0: 	virtual void Shutdown(TUint aHow,TRequestStatus& aStatus);
sl@0: 	virtual void ShutdownCancel();
sl@0: 	
sl@0: 	virtual TBool TimedRead() {return EFalse;}	//default implementation
sl@0: 	TInt TimeoutValue() const {return iReadTimeout;}
sl@0: 
sl@0: 	virtual TInt LSeek(off_t& offset, int whence);
sl@0: 	virtual TInt FStat(struct stat* st);
sl@0: 	virtual TInt Bind(const struct sockaddr* addr, unsigned long size);
sl@0: 	virtual TInt Listen(TUint qSize);
sl@0: 	virtual TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
sl@0: 	virtual TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
sl@0: 	virtual TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
sl@0: 	virtual TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	
sl@0: 	virtual TInt Poll(TPollMode aMode,TBool& aReadyStatus,TInt& aErrno);
sl@0: 	virtual TInt Poll(TUint aEvents);
sl@0: 	virtual TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
sl@0: 	virtual void TweakWatchedEvents(TUint& events);
sl@0: 	virtual TInt TweakReadyEvents(TInt errval);
sl@0: 	virtual void CancelNotify();
sl@0: 
sl@0: 	//Truncate the File
sl@0: 	virtual TInt Truncate(off_t /*anOffset*/)
sl@0: 		{
sl@0: 		return KErrNotSupported;
sl@0: 		}
sl@0: 	//Type of the Descriptor
sl@0: 	virtual TInt Type()  
sl@0: 		{
sl@0: 		return EBaseDesc;
sl@0: 		}
sl@0: 		
sl@0: 	//Set/reset the Attributes of the FD
sl@0: 	 inline void SetAttributes( TUint32 aBit, TBool aFlag )
sl@0: 		{
sl@0: 		if( aFlag )
sl@0: 			{
sl@0: 			//Set the bit to 1
sl@0: 			iFdAttrib |= aBit;
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			//Reset the bit to 0
sl@0: 			iFdAttrib &= ~aBit;
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	//Get the Attributes of the FD
sl@0: 	inline const TUint32 Attributes() const
sl@0: 		{
sl@0: 		return iFdAttrib;
sl@0: 		}
sl@0: 
sl@0: 	inline const TUint32 FcntlFlag() const
sl@0: 		{
sl@0: 		return iFcntlFlag;
sl@0: 		}
sl@0: 
sl@0: 	static inline void Cleanup(TAny *aPtr)
sl@0: 		{
sl@0: 		((CFileDescBase*)aPtr)->Close();
sl@0: 		}
sl@0: 		
sl@0: 	inline void PushLC() 
sl@0: 		{
sl@0: 		CleanupStack::PushL(TCleanupItem(Cleanup,this));
sl@0: 		}
sl@0: 
sl@0: 	IMPORT_C TInt Close();
sl@0: 	virtual void UserClose() {return;}
sl@0: 	inline CFileDescBase* Dup();
sl@0: 	inline void SetFid(TInt aFid) { iFid = aFid; }
sl@0: 	virtual void SetFids(void *aFids);
sl@0: 	
sl@0: 	inline void operator delete(TAny *aPtr) __NO_THROW
sl@0: 		{
sl@0: 		Backend()->Free(aPtr);
sl@0: 		}
sl@0: 		
sl@0: 	inline void operator delete(TAny *aPtr, TLeave) __NO_THROW
sl@0: 		{
sl@0: 		Backend()->Free(aPtr);
sl@0: 		}
sl@0: 		
sl@0: 	inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
sl@0: 		{
sl@0: 		Backend()->Free(aPtr);
sl@0: 		}
sl@0: 		
sl@0: 	TBool ReadIsTimed;
sl@0: 	TBool ReadWasCancelled;
sl@0: 
sl@0: protected:
sl@0: 	CFileDescBase( TUint aFcntl = 0, TUint32 aFdAttrib = 0 );
sl@0: 	virtual TInt FinalClose();
sl@0: 	static void Complete(TRequestStatus& aStatus, TInt aResult);
sl@0: 	TInt iReadTimeout;
sl@0: 	//Used in case of CRedirDesc
sl@0: 	TInt iFid;
sl@0: 	//For FD's fcntl
sl@0: 	TUint iFcntlFlag;
sl@0: 	//For FD's other attributes
sl@0: 	TUint32 iFdAttrib;
sl@0: 	
sl@0: private:
sl@0: 	//Check if the path corresponds to a directory
sl@0: 	static TBool CheckIfDirectory(const TDesC& aPath, RFs& aFs);
sl@0: 	
sl@0: public:
sl@0:     enum TDescType
sl@0:         {
sl@0:         EBaseDesc,
sl@0:         EFileDesc,
sl@0:         EFileTempDesc,
sl@0:         ESocketDesc,
sl@0:         ESerialDesc,
sl@0:         EDirDesc,
sl@0:         ETtyDesc,
sl@0:         EPopenPipeDesc,
sl@0:         EPipeDesc,
sl@0:         ERedirDesc,
sl@0:         EStdErrDesc,
sl@0:         EFileSocketDesc
sl@0:         };
sl@0: private:
sl@0:     TInt iDupCount;
sl@0: public:
sl@0: 	// Poll is required to return any of the requested events. 
sl@0: 	// In case of any error, "iPollErr" should be checked by the socket-descriptor
sl@0: 	// to take any corrective action.
sl@0: 	TInt iPollErr;
sl@0: 	};
sl@0: 
sl@0: 
sl@0: inline CFileDescBase* CFileDescBase::Dup () 
sl@0: 	{ iDupCount += 1; return this; }
sl@0: 
sl@0: 
sl@0: NONSHARABLE_CLASS(CTtyDesc) : public CFileDescBase
sl@0: /*
sl@0: Abstraction of a teletype device, which will be used for
sl@0: the console.
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	inline CTtyDesc(CConsoleBase *c);
sl@0: 	inline CTtyDesc();
sl@0: 	~CTtyDesc();
sl@0:      virtual TInt Type()
sl@0: 	    {
sl@0: 	    return ETtyDesc;
sl@0: 	    }
sl@0: 	void Read(TDes8& aDesc, TRequestStatus &aStatus);
sl@0: 	void ReadCancel();
sl@0: 	TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
sl@0: 	TInt SetEcho(TUint8 aEcho);
sl@0: protected:
sl@0: 	virtual TInt FinalClose();
sl@0: private:
sl@0: 	void MapCodeAndEcho(TDes8& aDesc, TKeyCode aCode);
sl@0: 	void CheckConsoleCreated();
sl@0: 	void Write(TDes8& aDesc);
sl@0: 	CConsoleBase *iConsole;
sl@0: 	//To store last non-modifiable data position and flag for reading data
sl@0: 	TInt  iCurPosX;
sl@0: 	TInt  iCurPosY;
sl@0: 	TBool iReadingData;
sl@0: 	TUint8 iEchoVal;
sl@0: 	};
sl@0: 
sl@0: inline CTtyDesc::CTtyDesc(CConsoleBase *c) : CFileDescBase(), iConsole(c), iEchoVal(EOn){}
sl@0: inline CTtyDesc::CTtyDesc() : CFileDescBase(), iEchoVal(EOn) {}
sl@0: 
sl@0: 
sl@0: NONSHARABLE_CLASS(CRedirDesc) : public CFileDescBase
sl@0: /*
sl@0: client-side CRedirDesc desc class which will be used to connecting to the Redirection Server
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CRedirDesc();
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return ERedirDesc;
sl@0: 	    }
sl@0: 	virtual void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt WriteCompletion(TDes8& aDesc, TInt /*aStatus*/);
sl@0: 	TInt ReadCompletion(TDes8& aDesc, TInt /*aStatus*/);
sl@0: 	virtual TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	TInt FinalClose();
sl@0: 	TInt Configure();
sl@0: 	TInt Poll(TUint aEvents);
sl@0: 	TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
sl@0: 	TInt TweakReadyEvents(TInt errval);
sl@0: 	void CancelNotify();
sl@0: 	TInt SetEcho(TUint8 aEcho);
sl@0: 	TBool iReadNone;
sl@0: 	TBool iWriteNone;
sl@0: private:
sl@0: 	//Handle to StdioSession
sl@0: 	RStdioSession iSession;
sl@0: 	TRedirConnState iStatus;
sl@0: 	RFastLock iLock;
sl@0: 	};
sl@0: 
sl@0: 
sl@0: NONSHARABLE_CLASS(CStdErrDesc) : public CFileDescBase
sl@0: 
sl@0: /*
sl@0: client-side Standard Error desc class which will be used to put all stderr to RDebug::Printf
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CStdErrDesc();
sl@0: 	virtual void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt WriteCompletion(TDes8& aDesc, TInt /*aStatus*/);
sl@0: 	virtual TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EStdErrDesc;
sl@0: 	    }
sl@0: 	};
sl@0: 
sl@0: NONSHARABLE_CLASS(CFileDesc) : public CFileDescBase
sl@0: /*
sl@0: Abstractions for a plain file and a temporary file
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CFileDesc();
sl@0: 	~CFileDesc();
sl@0: 
sl@0: 	void SetState(const TDes& params);
sl@0: 
sl@0: 	TInt Open(RFs& aSession, const TDesC& aName, int mode, int perms);
sl@0: 	TInt LSeek(off_t& offset, int whence);
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt FStat(struct stat *st);
sl@0: 	void Sync(TRequestStatus &aStatus);
sl@0: 	TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
sl@0: 	TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	static void MapStat(struct stat& st, const TTime& aModTime, TUint& aAttr, const mode_t aMode = S_IFREG);
sl@0: 	TInt Truncate(off_t anOffset);
sl@0: 	TInt SetAtt(TUint aSetAttMask, TUint aClearAttMask);
sl@0: 	TInt ProcessLockParams(FSIZE& pos, FSIZE &lock_len, TInt& lock_type, struct flock* anArg);
sl@0: 	inline int CreateLock() 
sl@0: 		{
sl@0: 		return iLock.CreateLocal();
sl@0: 		}
sl@0: 
sl@0: 	inline RFILE& FileHandle()
sl@0: 		{
sl@0: 		return iFile;
sl@0: 		}
sl@0: 	
sl@0: 	inline const FSIZE Offset() const
sl@0: 		{
sl@0: 		return iPos;
sl@0: 		}
sl@0: 	
sl@0:     inline const FSIZE Size() const
sl@0: 		{
sl@0: 			return iSize;
sl@0: 		}
sl@0: 	inline void setSize(TUint32 param)
sl@0: 		{
sl@0: 		iSize = param;
sl@0: 		}
sl@0: 	inline const FSIZE Extent() const
sl@0: 		{
sl@0: 		return iExt;
sl@0: 		}
sl@0:      virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EFileDesc;
sl@0: 	    }
sl@0: protected:
sl@0: 	virtual TInt FinalClose();
sl@0: 	TInt Alloc();
sl@0: private:
sl@0: 	TInt FileRead(TUint8* aPtr,TInt aLength);
sl@0: 	TInt FileWrite(TUint8* aPtr,TInt aLength);
sl@0: 	TInt Flush();
sl@0: 	TInt DoSync();
sl@0: 	TInt DoRead(TDes8& aDesc);
sl@0: 	TInt DoWrite(TDes8& aDesc);
sl@0: 	FSIZE Pos();
sl@0: 	FSIZE Ext();
sl@0: 	
sl@0: private:
sl@0: 	enum {EAlloc,EReading,EWriting};
sl@0: 	enum {EBufferSize = 0x600,EReadAhead = 0x200};
sl@0: protected:
sl@0: 	RFILE	iFile;
sl@0: 	TInt16	iDrive;	// for use with stat()
sl@0: private:
sl@0: 	TUint8 iState;
sl@0: 	TUint8* iBuffer;
sl@0: 	TUint8* iPtr;
sl@0: 	TUint8* iEnd;
sl@0: 	
sl@0: 	FSIZE iSize;
sl@0: 	FSIZE iPos;
sl@0: 	FSIZE iExt;
sl@0: 	
sl@0: 	//For locking the descriptor before any operation.
sl@0: 	//To make it thread safe.
sl@0: 	RFastLock iLock;
sl@0: 	friend class RFileDesTransferSession;
sl@0: 	friend class CFileDesTransferSession;
sl@0: 	};
sl@0: 
sl@0: NONSHARABLE_CLASS(CTempFileDesc) : public CFileDesc
sl@0: /*
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	TInt Open(const wchar_t* aName, TInt mode);
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EFileTempDesc;
sl@0: 	    }
sl@0: protected:
sl@0: 	virtual TInt FinalClose();
sl@0: private:
sl@0: 	RFs iSession;
sl@0: 	TFileName iName;
sl@0: 	};
sl@0: 
sl@0: /*
sl@0: Implements common functionality between CSocketDesc and CFileSocketDesc.
sl@0: Not meant to be instantaible.
sl@0: */	
sl@0: NONSHARABLE_CLASS(CSockDescBase) : public CFileDescBase
sl@0: 	{
sl@0: public:
sl@0: 	 virtual TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
sl@0: 	 TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	 TInt FStat(struct stat *st);
sl@0: 	 TInt FinalClose();
sl@0: 	 void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	 void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	 void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
sl@0: 	 void SendTo(TDes8& aDesc, TSockAddr& to, int flags, TRequestStatus& aStatus);
sl@0: 	 TInt Poll(TUint aEvents);
sl@0: 	 TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 aTimeout);
sl@0: 	 void TweakWatchedEvents(TUint& events);
sl@0: 	 TInt TweakReadyEvents(TInt errval);
sl@0: 	 void CancelNotify();
sl@0: 	 TInt Listen(TUint qSize);
sl@0: 	 void ReadCancel();
sl@0: 	 TInt ReadCompletion(TDes8& aBuf, TInt aStatus);
sl@0: 	 void RecvFromCancel();
sl@0: 	 void SendToCancel();
sl@0: 	 void WriteCancel();
sl@0: 	 TInt SockName(int anEnd, TSockAddr& anAddr);
sl@0: 	 void Shutdown(TUint aHow,TRequestStatus& aStatus);
sl@0: 	 TInt CompletionStatus(TInt& aLength, TInt aStatus);
sl@0: 	 const TUint& GetSelectEvents()
sl@0: 		 {
sl@0: 		 iIoctlLock.Signal();
sl@0: 		 return iSelectEvents();
sl@0: 		 }
sl@0: 	 
sl@0: 	 inline TInt CreateLock() 
sl@0: 		 {
sl@0: 	     TInt err = iIoctlLock.CreateLocal(1) || iReadLock.CreateLocal() || iWriteLock.CreateLocal();
sl@0: 	     if (err != KErrNone)
sl@0: 	         {
sl@0:              // closes on unopened handles are safe
sl@0:              iIoctlLock.Close();
sl@0:              iReadLock.Close();
sl@0:              iWriteLock.Close();
sl@0: 	         }
sl@0: 	     return err;
sl@0: 		 }
sl@0: 		 
sl@0: 	 inline RSemaphore& GetIoctlLock()
sl@0: 		 {
sl@0: 		 return iIoctlLock;
sl@0: 		 }
sl@0: 	 inline TBool GetConnectionProgress()
sl@0: 		 {
sl@0: 		 return iConnectInProgress;
sl@0: 		 }
sl@0: 
sl@0: 	 inline void SetConnectionProgress( TBool aInProgress )
sl@0: 		 {
sl@0: 		 iConnectInProgress = aInProgress;
sl@0: 		 }
sl@0: 	 
sl@0: protected:
sl@0: 		//rearrange these 
sl@0: 	CSockDescBase():iAddrFamily(-1),iProtocol(KUndefinedProtocol),iIoctlFlag(EFalse),iCount(0)
sl@0: 	{
sl@0: 	
sl@0: 	}	
sl@0: 	RSocket iSocket;
sl@0: 	TSockXfrLength iLength;
sl@0: 	TFileName iPath;
sl@0: 	TPckgBuf<TUint> iSelectEvents;
sl@0: 	TInt iAddrFamily;
sl@0: 	TInt iProtocol;
sl@0: 	TInt iStyle;
sl@0: 	// For preventing simultaneous ioctl calls.
sl@0: 	// No native support.
sl@0: 	RSemaphore iIoctlLock;
sl@0: 	// Is this required?
sl@0: 	TBool iIoctlFlag;
sl@0: 	// Safeguard against issue of a second Read/Write request while the first is pending.
sl@0: 	// The iReadLock also guards OpenUsingPreference
sl@0: 	//For locking the descriptor before any operation.
sl@0: 	//To make it thread safe.
sl@0: 	RFastLock iReadLock;
sl@0: 	RFastLock iWriteLock;
sl@0: 
sl@0: 	//Flag to mark the connect status of a non-blocking socket as "in progress"
sl@0: 	//to prevent duplicate connection request
sl@0: 	TBool iConnectInProgress;
sl@0: 	volatile TInt iCount;
sl@0: protected:
sl@0: 
sl@0: 	inline TInt isStream() const	// inline, but private
sl@0: 		{ 
sl@0: 		return iStyle==SOCK_STREAM; 
sl@0: 		}
sl@0: 	};
sl@0: 
sl@0: NONSHARABLE_CLASS(CSocketDesc) : public CSockDescBase
sl@0: /*
sl@0: Abstraction for a socket
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CSocketDesc();
sl@0: 	TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt ReadCompletion (TDes8& /*aBuf*/, TInt aStatus);	
sl@0: 	void ReadCancel();
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void WriteCancel();
sl@0: 	void Sync(TRequestStatus& aStatus);
sl@0: 	void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
sl@0: 	void IoctlCancel();
sl@0: 
sl@0: 	void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
sl@0: 	void RecvFromCancel();
sl@0: 	void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen, int flags, TRequestStatus& aStatus);
sl@0: 
sl@0: 	void SendToCancel();
sl@0: 
sl@0: 	void Shutdown(TUint aHow,TRequestStatus& aStatus);
sl@0: 	void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs,TSockAddr *aAddr);
sl@0: 	void AcceptCancel();
sl@0: 	void Connect(const struct sockaddr* aAddr,unsigned long size,TRequestStatus& aStatus);
sl@0: 	void ConnectCancel();
sl@0: 
sl@0: 	TInt Bind(const struct sockaddr* addr, unsigned long size);
sl@0: 	TInt Listen(TUint qSize);
sl@0: 	TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
sl@0: 	TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
sl@0: 	TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
sl@0: 	TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	
sl@0: 	TInt Poll(TPollMode aMode,TBool& aReadyStatus,TInt& aErrno);
sl@0: 	TInt Poll(TUint aEvents);
sl@0: 	void CancelNotify();
sl@0: 	void TempClose();
sl@0: 	
sl@0: 	void SetFids(void *aFids);
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return ESocketDesc;
sl@0: 	    }
sl@0: 	
sl@0: protected:
sl@0: 	TInt FinalClose();
sl@0: private:
sl@0: 	
sl@0:     TInt GetInterfaceIndex(TUint32 aAddr);
sl@0: 	TInt GetInterfaceList(void *aParam);
sl@0: 	TInt GetActiveInterface( void *aParam);
sl@0: 	TInt GetInterfaceIndexByName(void *aParam);
sl@0: 	TInt GetActiveInterfaceList(void *aParam);
sl@0: 	TInt SetInterfaceByName(void *aParam);
sl@0: 	TInt StartInterface(void *aParam);
sl@0: 	TInt StartActiveInterface(void *aParam);
sl@0: 	TInt StopInterface(void *aParam);
sl@0: 	TInt OpenUsingPreference();
sl@0: 	void AccessPointListL(CArrayFixFlat<TAccessPointRecord> *&aRecordPtr, TInt &aLength);
sl@0: 	void AccessPointCountL(TInt &aCount);
sl@0: 	void ReadRecordFromIapTableL(CCommsDbTableView* aView, TAccessPointRecord &aRecord);
sl@0: 	void OpenIapTableLC(CCommsDatabase **aIapDatabase, CCommsDbTableView **aView);
sl@0: 	TInt ActiveConnectionCount(TInt &aCount);
sl@0: 	TInt ActiveConnectionListL(CArrayFixFlat<TAccessPointRecord> *aRecordPtr, TInt &aLength);
sl@0: 	TInt GetRConnectionDetails(RConnection *aRc, TAccessPointRecord &aApr);
sl@0: 	TInt StartConnection(void *aParam);
sl@0: 	TInt GetConnectionPreference(TCommDbConnPref &aApr);
sl@0: 	void GetIapDetailsByNameL(TBuf<KCommsDbSvrMaxColumnNameLength> aIapName, TAccessPointRecord &aRecord);
sl@0: 	void StopSubConnection();
sl@0: 	void StopConnection();
sl@0: 	TInt StartSubConnection(void *aParam);
sl@0: 	TInt GetInterface(void *Param, TInt aType);
sl@0: 	TInt GetInterafceNumber(void *aParam);
sl@0: 	TInt GetIpAddress( void *aParam );
sl@0: 	
sl@0: 	TInt RouteRequest(TInt aReq, void *aParam);
sl@0: 	TInt GetInterfaceHWAddress(void *aParam);
sl@0: 	
sl@0: 	TInt ConvertRtEntry(TSoInetRouteInfo& aRouteInfo, struct rtentry *aRouteEntry);
sl@0: 	TInt ConvertSockAddr(TInetAddr& aInetAddr, struct sockaddr_in *aSockAddr);	
sl@0: 		
sl@0: 	TInt GetInterfaceByName(const TDesC& aIfName, TPckgBuf<TSoInetInterfaceInfo>& aIface);
sl@0: 	TInt Copy(TInetAddr& aDest, TInetAddr& aSrc);
sl@0: 	
sl@0: 	TInt GetRemoteIpAddress( void *aParam );
sl@0: 	TInt GetInterafceParamInfo( void *aParam,TInt aType);
sl@0: 	void FindConnectionDetailsL(CArrayFixFlat<TAccessPointRecord>*& aRecordPtr, TInt& aCount);    
sl@0: 	void FindConnectionInfoL(TAccessPointRecord &aRecord,char *ptr);
sl@0: 	TInt GetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType );
sl@0: 	TInt SetInterafceParamInfo( void *aParam,TInt aType);
sl@0: 	TInt SetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType );
sl@0: 	
sl@0: 	TInt maybe_reopen_socket()
sl@0: 	    {
sl@0: 	    TInt err = KErrNone;
sl@0: 	    if (!__e32_atomic_load_acq32(&iSocketPtr))
sl@0: 	        {
sl@0:             iReadLock.Wait();
sl@0:             if (!iSocketPtr)
sl@0:                 {
sl@0:                 err = OpenUsingPreference();
sl@0:                 }
sl@0:             iReadLock.Signal();
sl@0: 	        }
sl@0: 	    return err;
sl@0: 	    }
sl@0: 	
sl@0: 	enum InterfaceType
sl@0: 		{
sl@0: 		EACCESS_POINT,
sl@0: 		EACTIVE_CONNECTION,
sl@0: 		EACTIVE_GETIP,
sl@0: 		EACCESS_GETMETRIC,
sl@0: 		EACCESS_GETMTU,
sl@0: 		EACCESS_GETNETMASK,
sl@0: 		EACCESS_GETBROADCAST,
sl@0: 		EACCESS_GETPHYSADDR,
sl@0: 		EACCESS_GETFLAGS,
sl@0: 		EACCESS_SETMETRIC,
sl@0: 		EACCESS_SETMTU,
sl@0: 		EACCESS_SETFLAGS,
sl@0: 		EACCESS_SETPHYSADDR,
sl@0: 		EACTIVE_SETIP,
sl@0: 		EACCESS_SETNETMASK,
sl@0: 		EACCESS_SETBROADCAST
sl@0: 		};
sl@0: 
sl@0: 	TPtr8 iIoctlBuf;
sl@0: 	RSocket *iSocketPtr;
sl@0: 	TAccessPointRecord iConnPref;
sl@0: 	RConnection iConnection;
sl@0: 	RConnection *iConnectionPtr;
sl@0: 	RSubConnection iSubConnection;
sl@0: 	RSubConnection *iSubConnectionPtr;
sl@0: 	TInt iRConnectionIndex;
sl@0: 	RSocketServ *iSockServPtr;
sl@0: 	void *iFids;
sl@0: 
sl@0: 	};
sl@0: 
sl@0: 
sl@0: class CNotifier;
sl@0: 
sl@0: NONSHARABLE_CLASS(CSerialDesc) : public CFileDescBase
sl@0: /*
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: 
sl@0: 	friend class CNotifier;
sl@0: 
sl@0: 	public:
sl@0: 	CSerialDesc() : CFileDescBase(), iReadThreshold(-1), iRequestedSignals(0),
sl@0: 					iNotifyStatus(NULL), iNotifyParamPtr(NULL) {}
sl@0: 
sl@0: 	TInt Open(const wchar_t* name, int mode, int perms);
sl@0: 	TInt FinalClose();
sl@0: 
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void ReadCancel();
sl@0: 	
sl@0: 	TInt& TimeoutValue() const;
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
sl@0: 
sl@0: 	
sl@0: 	void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
sl@0: 	void IoctlCancel();
sl@0: 
sl@0: 	TBool TimedRead();
sl@0: 	void UserClose();
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return  ESerialDesc;
sl@0: 	    }
sl@0: 
sl@0: protected:
sl@0: 
sl@0: private:
sl@0: 
sl@0: 	void NotifyDataAvailable(TRequestStatus& aStatus);
sl@0: 	void NotifyOutputEmpty(TRequestStatus& aStatus);
sl@0: 	void NotifyBreak(TRequestStatus& aStatus);
sl@0: 	void NotifyWriteErrors(TRequestStatus& aStatus, TUint* aRequestParams, TUint aSignalsMask);
sl@0: 	void NotifySignalChange(TRequestStatus& iStatus, TUint& aRequestParam, TUint aSignalsMask);
sl@0: 	void NotifyDataAvailableCancel();
sl@0: 	void NotifyOutputEmptyCancel();
sl@0: 	void NotifyBreakCancel();
sl@0: 	void NotifyWriteErrorsCancel();
sl@0: 	void NotifySignalChangeCancel();
sl@0: 	void Notify(TInt aVal);		//complete the notify request
sl@0: 	TInt NotifiesSupported();	//return the notifies supported at the moment
sl@0: 	TBool RequestedNotifiesSupported(TInt aRequested);	//see if the notifies requested are supported
sl@0: 	void CancelNotifiers(const CNotifier* aCompletedNotifier);	//cancel them all apart from the passed one
sl@0: 	TUint Signals();
sl@0: 
sl@0: 	TInt ReadCompletion (TDes8& aBuf, TInt aStatus);	
sl@0: 
sl@0: 	TInt iReadThreshold;
sl@0: 	RComm iCommPort;
sl@0: 
sl@0: 	TInt iRequestedSignals;
sl@0: 	TRequestStatus* iNotifyStatus;
sl@0: 	TUint* iNotifyParamPtr;
sl@0: 	TUint* iRequestDataPtr;
sl@0: 
sl@0: 	CNotifier* iDataAvailableNotifier;
sl@0: 	CNotifier* iOutputEmptyNotifier;
sl@0: 	CNotifier* iBreakNotifier;
sl@0: 	CNotifier* iErrorsNotifier;
sl@0: 	CNotifier* iSignalsNotifier;
sl@0: 
sl@0: 	};
sl@0: 
sl@0: 	
sl@0: NONSHARABLE_CLASS(CPipeDescBase) : public CFileDescBase
sl@0: /*
sl@0: Base class with the RPipe handle and common methods
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CPipeDescBase(const TUint16 aMode = 0) : CFileDescBase()
sl@0: 		{
sl@0: 		iFdAttrib |= KPipeFd;
sl@0: 		if (aMode & O_NONBLOCK)
sl@0: 			{
sl@0: 			iFcntlFlag |= O_NONBLOCK;
sl@0: 		}
sl@0: 		}
sl@0: 		
sl@0: 	TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	TInt FStat(struct stat *st);
sl@0: 	void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	TInt FinalClose();
sl@0: 	
sl@0: 	RPipe& Handle()
sl@0: 		{
sl@0: 		return iHandle;
sl@0: 		}
sl@0: 		
sl@0: 	TUint& FcntlFlag()
sl@0: 		{
sl@0: 		return iFcntlFlag;
sl@0: 		}
sl@0: 		
sl@0: 	TUint32& FDAttrib()
sl@0: 		{
sl@0: 		return iFdAttrib;
sl@0: 		}
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EPipeDesc;
sl@0: 	    }
sl@0: 
sl@0: protected:
sl@0: 	RPipe iHandle;
sl@0: 	};
sl@0: 	
sl@0: NONSHARABLE_CLASS(CPipeReadDesc) : public CPipeDescBase
sl@0: /*
sl@0: Handle to the read-end of an RPipe object.
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CPipeReadDesc(const TUint16 aMode = 0) : CPipeDescBase(aMode)
sl@0: 		{
sl@0: 		iFcntlFlag |= O_RDONLY;
sl@0: 		}
sl@0: 		
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt Poll(TUint aEvents);
sl@0: 	TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 /*timeout*/);
sl@0: 	TInt TweakReadyEvents(TInt errval);
sl@0: 	void CancelNotify();
sl@0: 	
sl@0: protected:
sl@0: 	TInt DoRead(TDes8& aDesc);
sl@0: 	};
sl@0: 	
sl@0: NONSHARABLE_CLASS(CPipeWriteDesc) : public CPipeDescBase
sl@0: /*
sl@0: Handle to the write-end of an RPipe object.
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CPipeWriteDesc(const TUint16 aMode = 0) : CPipeDescBase(aMode)
sl@0: 		{
sl@0: 		iFcntlFlag |= O_WRONLY;
sl@0: 		}
sl@0: 		
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt Poll(TUint aEvents);
sl@0: 	TInt NotifyActivity(TUint aEvents, TRequestStatus& aRequest, TTimeIntervalMicroSeconds32 timeout);
sl@0: 	TInt TweakReadyEvents(TInt errval);
sl@0: 	void CancelNotify();
sl@0: 	
sl@0: protected:
sl@0: 	TInt DoWrite(TDes8& aDesc);
sl@0: 	};
sl@0: NONSHARABLE_CLASS(CFileSocketDesc) : public CSockDescBase
sl@0: /*
sl@0: Class representing AF_UNIX socket descriptors
sl@0: Implemented using 2 FIFOs
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CFileSocketDesc(const TUint16 aMode = 0) 
sl@0: 		{
sl@0: 		if (aMode & O_NONBLOCK)
sl@0: 			{
sl@0: 			iFcntlFlag |= O_NONBLOCK;
sl@0: 			}
sl@0: 		iFcntlFlag |= O_RDWR;
sl@0: 		iPath.Zero();
sl@0: 		}
sl@0: 		
sl@0: 	void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
sl@0: 	TInt FinalClose();
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void RecvFrom(TDes8& aDesc, TSockAddr& from, int flags, TRequestStatus& aStatus);
sl@0: 	void SendTo(TDes8& aDesc, const struct sockaddr* anAddr, unsigned long aAddrLen, int flags, TRequestStatus& aStatus);
sl@0: 	TInt Listen(TUint qSize);
sl@0: 	TInt GetSockOpt(TInt anOptionName,TInt anOptionLevel,TDes8& anOption);
sl@0: 	TInt SetSockOpt(TInt anOptionName,TInt anOptionLevel,TDesC8& anOption);
sl@0: 	TInt Bind(const struct sockaddr* addr, unsigned long size);
sl@0: 	void Connect(const struct sockaddr* aAddr,unsigned long size, TRequestStatus& aStatus);
sl@0: 	void Accept(CFileDescBase*& aNewSocket, TRequestStatus& aStatus, RSocketServ& aSs, TSockAddr *);
sl@0: 	TInt Socket(RSocketServ& aSs, int family, int style, int protocol);
sl@0: 	TInt SockName(int anEnd, struct sockaddr* anAddr,unsigned long* aSize);
sl@0: 	void AcceptCancel();
sl@0: 	void ConnectCancel();
sl@0: 
sl@0: 	TUint& FcntlFlag()
sl@0: 		{
sl@0: 		return iFcntlFlag;
sl@0: 		}
sl@0: 		
sl@0: 	TUint32& FDAttrib()
sl@0: 		{
sl@0: 		return iFdAttrib;
sl@0: 		}
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EFileSocketDesc;
sl@0: 	    }
sl@0: 
sl@0: 	TInt GetLocalSockAddrByPort(struct sockaddr_un* aAddr,unsigned long* aAddrLen,TUint aPortNum);
sl@0: 	TInt GetLocalSockPortByPath(const struct sockaddr_un* aAddr,unsigned long aAddrLen,TUint& aPortNum);
sl@0: 
sl@0: private:
sl@0: 	TInt ValidateAddress(const struct sockaddr_un* aAddr,unsigned long* aAddrLen);
sl@0: 	TInt RemoveLocalSockAddr();
sl@0: private:
sl@0: 	TBuf8<KMaxFileName> iPath;
sl@0: 	RFastLock iReadLock;
sl@0: 	RFastLock iWriteLock;
sl@0: 	class TAutoFastLock
sl@0: 		{
sl@0: 	public:
sl@0: 		TAutoFastLock(RFastLock &aLock):iAutoLock(aLock)
sl@0: 			{
sl@0: 			iAutoLock.Wait() ;
sl@0: 			}
sl@0: 		~TAutoFastLock()
sl@0: 			{
sl@0: 			iAutoLock.Signal() ;
sl@0: 			}
sl@0: 	private:
sl@0: 		RFastLock &iAutoLock;
sl@0: 		};
sl@0: 	};
sl@0: 	
sl@0: NONSHARABLE_CLASS(CDirectoryDesc) : public CFileDescBase
sl@0: /*
sl@0: Abstractions for a directory 
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CDirectoryDesc();
sl@0: 	~CDirectoryDesc();
sl@0: 
sl@0: 	TInt Open(RFs& aSession, const TDesC& aName, int mode, int perms);
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	TInt LSeek(off_t& offset, int whence);
sl@0: 	TInt FStat(struct stat *st);
sl@0: 	//Get the Name of the directory
sl@0: 	inline const wchar_t* GetDirName()
sl@0: 		{
sl@0: 		return (const wchar_t*)iDirName.Ptr();
sl@0: 		}
sl@0: 	virtual TInt Type()
sl@0: 	    {
sl@0: 	    return EDirDesc;
sl@0: 	    }
sl@0: 
sl@0: private:
sl@0: 	RDir	iDir;
sl@0: 	//Name of the directory
sl@0: 	TFileName iDirName;
sl@0: 	};
sl@0: 
sl@0: #ifdef SYMBIAN_OE_LIBRT
sl@0: NONSHARABLE_CLASS(CSharedMemDesc) : public CFileDescBase
sl@0: /*
sl@0: Abstractions for shared memory 
sl@0: @internalComponent
sl@0: */
sl@0: 	{
sl@0: public:
sl@0: 	CSharedMemDesc();
sl@0: 	~CSharedMemDesc();
sl@0: 
sl@0: 	TInt Open(const wchar_t* aName, int mode, int perms);
sl@0: 	void Read(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	void Write(TDes8& aDesc, TRequestStatus& aStatus);
sl@0: 	TInt Fcntl(TUint anArg, TUint aCmd);
sl@0: 	TInt FStat(struct stat *st);
sl@0: 	TInt LSeek(off_t& offset, int whence);
sl@0: private:
sl@0: 	TInt ShmRead(TUint8* aPtr,TInt aLength);
sl@0: 	TInt ShmWrite(TUint8* aPtr,TInt aLength);
sl@0: 	TInt DoShmRead(TDes8& aDesc);
sl@0: 	TInt DoShmWrite(TDes8& aDesc);
sl@0: 	TInt Pos();
sl@0: 	TInt Ext();	
sl@0: protected:
sl@0: 	TInt FinalClose();	
sl@0: private:
sl@0: 	RFastLock iLock;	
sl@0: 	void* iPtr;
sl@0: 	TInt iSize;
sl@0: 	TInt iPos;
sl@0: 	TInt iExt;
sl@0: 	TInt iPerms;
sl@0: 	TInt iKey;
sl@0: 	};
sl@0: #endif //SYMBIAN_OE_LIBRT
sl@0: #endif // !_FDESC_H