sl@0
|
1 |
// Copyright (c) 1997-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 |
// Support for pipes between processes
|
sl@0
|
15 |
// CPipeDesc is in the parent process, CPipeChildDesc is in the child
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "FDESC.H"
|
sl@0
|
20 |
#include <sys/ioctl.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
NONSHARABLE_CLASS(CPipeDesc) : public CFileDescBase
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
@internalComponent
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
{
|
sl@0
|
27 |
public:
|
sl@0
|
28 |
CPipeDesc(TInt anIndex);
|
sl@0
|
29 |
|
sl@0
|
30 |
void SetClientSide(CPipeDesc*& aClientPointer);
|
sl@0
|
31 |
TInt LSeek(int& offset, int whence);
|
sl@0
|
32 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
33 |
TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
34 |
void ReadCancel();
|
sl@0
|
35 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
36 |
TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
37 |
void WriteCancel();
|
sl@0
|
38 |
TInt FStat(struct stat *st);
|
sl@0
|
39 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
40 |
TInt IoctlCompletion(int aCmd, void* aParam, TInt aStatus);
|
sl@0
|
41 |
void IoctlCancel();
|
sl@0
|
42 |
|
sl@0
|
43 |
void ClientRead(const RMessage2& aMessage);
|
sl@0
|
44 |
void ClientWrite(const RMessage2& aMessage);
|
sl@0
|
45 |
void ClientIoctl(const RMessage2& aMessage);
|
sl@0
|
46 |
void ClientCancel(const RMessage2& aMessage);
|
sl@0
|
47 |
void ClientClose();
|
sl@0
|
48 |
protected:
|
sl@0
|
49 |
TInt FinalClose();
|
sl@0
|
50 |
private:
|
sl@0
|
51 |
void Cancel();
|
sl@0
|
52 |
TInt IsWriteable() { return !iIndex; } // 0 => child STDIN
|
sl@0
|
53 |
TInt IsReadable() { return iIndex; }
|
sl@0
|
54 |
TInt SelectMask() { return (iIndex)? E32SELECT_READ :E32SELECT_WRITE; }
|
sl@0
|
55 |
TInt ClientSelectMask() { return (iIndex)? E32SELECT_WRITE:E32SELECT_READ; }
|
sl@0
|
56 |
TInt ClientIoctlPending() { return iClientIoctlPending; }
|
sl@0
|
57 |
|
sl@0
|
58 |
void TransferFromClient();
|
sl@0
|
59 |
void TransferToClient();
|
sl@0
|
60 |
void CompleteClientIoctl(TInt ret);
|
sl@0
|
61 |
void CompleteClientIoctl();
|
sl@0
|
62 |
void Panic(TInt aReason);
|
sl@0
|
63 |
void Panic(RMessage2& aMessage, TInt aReason);
|
sl@0
|
64 |
private:
|
sl@0
|
65 |
TInt iIndex; // index into per-process table of pipes, also implies direction.
|
sl@0
|
66 |
CPipeDesc** iClientSide;
|
sl@0
|
67 |
TInt iClientClosed;
|
sl@0
|
68 |
// Pending info for parent operation
|
sl@0
|
69 |
TRequestStatus* iStatus; // null implies "no pending operation"
|
sl@0
|
70 |
TRequestStatus* iIoctlStatus;
|
sl@0
|
71 |
TPtrC8 iWriteBuf;
|
sl@0
|
72 |
TDes8* iReadBuf;
|
sl@0
|
73 |
// Pending info for child operation
|
sl@0
|
74 |
TInt iClientLength; // 0 implies "no pending operation"
|
sl@0
|
75 |
TInt iClientOffset;
|
sl@0
|
76 |
RMessage2 iMessage;
|
sl@0
|
77 |
TInt iClientIoctlPending;
|
sl@0
|
78 |
RMessage2 iIoctlMessage;
|
sl@0
|
79 |
};
|
sl@0
|
80 |
|
sl@0
|
81 |
class RPosixSession;
|
sl@0
|
82 |
NONSHARABLE_CLASS(CPipeChildDesc) : public CFileDescBase
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
CPipeChildDesc
|
sl@0
|
85 |
Basically just forwards requests to the parent CPosixServer, where the related CPipeDesc
|
sl@0
|
86 |
does the actual work.
|
sl@0
|
87 |
@internalComponent
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
{
|
sl@0
|
90 |
public:
|
sl@0
|
91 |
CPipeChildDesc(TInt anIndex, RPosixSession& aSession);
|
sl@0
|
92 |
|
sl@0
|
93 |
TInt LSeek(int& offset, int whence);
|
sl@0
|
94 |
void Read(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
95 |
TInt ReadCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
96 |
void ReadCancel();
|
sl@0
|
97 |
void Write(TDes8& aDesc, TRequestStatus& aStatus);
|
sl@0
|
98 |
TInt WriteCompletion(TDes8& aDesc, TInt aStatus);
|
sl@0
|
99 |
void WriteCancel();
|
sl@0
|
100 |
TInt FStat(struct stat *st);
|
sl@0
|
101 |
void Ioctl(int aCmd, void* aParam, TRequestStatus& aStatus);
|
sl@0
|
102 |
void IoctlCancel();
|
sl@0
|
103 |
|
sl@0
|
104 |
void ClientClose() { iClientClosed=1; }
|
sl@0
|
105 |
|
sl@0
|
106 |
protected:
|
sl@0
|
107 |
TInt FinalClose();
|
sl@0
|
108 |
private:
|
sl@0
|
109 |
void Cancel(TInt aType);
|
sl@0
|
110 |
TInt IsWriteable() { return iIndex; } // 0 => child STDIN
|
sl@0
|
111 |
TInt IsReadable() { return !iIndex; }
|
sl@0
|
112 |
TInt SelectMask() { return (!iIndex)? E32SELECT_READ:E32SELECT_WRITE; }
|
sl@0
|
113 |
|
sl@0
|
114 |
TInt iIndex; // index into per-process table of pipes, also implies direction.
|
sl@0
|
115 |
RPosixSession& iSession;
|
sl@0
|
116 |
TInt iClientClosed;
|
sl@0
|
117 |
TPtr8 iParamDes;
|
sl@0
|
118 |
};
|