author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// |
sl@0 | 15 |
|
sl@0 | 16 |
|
sl@0 | 17 |
#include "POSIXIF.H" |
sl@0 | 18 |
#include <estw32.h> |
sl@0 | 19 |
#include <redircli.h> |
sl@0 | 20 |
|
sl@0 | 21 |
#ifdef __WINS__ |
sl@0 | 22 |
|
sl@0 | 23 |
// Largely default STDLIB file descriptor for accessing Win32 streams |
sl@0 | 24 |
// We could in principle widen the RWin32Stream interface to allow for |
sl@0 | 25 |
// things like stat, but that can wait until it seems to be necessary! |
sl@0 | 26 |
|
sl@0 | 27 |
class CW32StreamDesc : public CFileDescBase |
sl@0 | 28 |
{ |
sl@0 | 29 |
public: |
sl@0 | 30 |
TInt Attach(TInt aStream); |
sl@0 | 31 |
virtual void Read(TDes8& aDesc, TRequestStatus& aStatus); |
sl@0 | 32 |
virtual void Write(TDes8& aDesc, TRequestStatus& aStatus); |
sl@0 | 33 |
virtual void Flush(TRequestStatus& aStatus); |
sl@0 | 34 |
protected: |
sl@0 | 35 |
virtual TInt FinalClose(); |
sl@0 | 36 |
private: |
sl@0 | 37 |
RWin32Stream iStream; |
sl@0 | 38 |
}; |
sl@0 | 39 |
|
sl@0 | 40 |
TInt CW32StreamDesc::Attach(TInt aStream) |
sl@0 | 41 |
{ |
sl@0 | 42 |
return iStream.Open(aStream); |
sl@0 | 43 |
} |
sl@0 | 44 |
|
sl@0 | 45 |
void CW32StreamDesc::Read(TDes8& aDesc, TRequestStatus& aStatus) |
sl@0 | 46 |
{ |
sl@0 | 47 |
iStream.Read(aStatus, aDesc); |
sl@0 | 48 |
} |
sl@0 | 49 |
|
sl@0 | 50 |
void CW32StreamDesc::Write(TDes8& aDesc, TRequestStatus& aStatus) |
sl@0 | 51 |
{ |
sl@0 | 52 |
iStream.Write(aStatus, aDesc); |
sl@0 | 53 |
} |
sl@0 | 54 |
|
sl@0 | 55 |
void CW32StreamDesc::Flush(TRequestStatus& aStatus) |
sl@0 | 56 |
{ |
sl@0 | 57 |
iStream.Flush(aStatus); |
sl@0 | 58 |
} |
sl@0 | 59 |
|
sl@0 | 60 |
TInt CW32StreamDesc::FinalClose() |
sl@0 | 61 |
{ |
sl@0 | 62 |
iStream.Close(); |
sl@0 | 63 |
return KErrNone; |
sl@0 | 64 |
} |
sl@0 | 65 |
|
sl@0 | 66 |
#endif |
sl@0 | 67 |
|
sl@0 | 68 |
void CPosixServer::DefaultConsoleL() |
sl@0 | 69 |
{ |
sl@0 | 70 |
#ifdef __WINS__ |
sl@0 | 71 |
// Try to attach Win32 stdin/stdout/stderr |
sl@0 | 72 |
TInt i; |
sl@0 | 73 |
for (i=0; i<3; i++) |
sl@0 | 74 |
{ |
sl@0 | 75 |
CW32StreamDesc* stream=new(ELeave) CW32StreamDesc; |
sl@0 | 76 |
if (stream->Attach(i)==KErrNone) |
sl@0 | 77 |
iFids.Attach(i, stream); |
sl@0 | 78 |
else |
sl@0 | 79 |
delete stream; |
sl@0 | 80 |
} |
sl@0 | 81 |
#endif |
sl@0 | 82 |
// set up default fids |
sl@0 | 83 |
CRedirDesc* redirector = new(ELeave) CRedirDesc; |
sl@0 | 84 |
// redirector->Connect(); |
sl@0 | 85 |
iFids.Default(redirector); |
sl@0 | 86 |
redirector->Close(); |
sl@0 | 87 |
} |
sl@0 | 88 |
|
sl@0 | 89 |