-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_clientuser.h
166 lines (137 loc) · 6.08 KB
/
php_clientuser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2001-2008, Perforce Software, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* php_clientuser.h - Implementation of ClientUser. Handles I/O.
*
* Classes:
*
* PHPClientUser - Implementation of ClientUser.
*
* The PHPClientUser class subclasses ClientUser to handle all I/O for Perforce
* commands.
*
* Methods:
*
* PHPClientUser::HandleError() - Virtual method. Process error data on failure
* PHPClientUser::OutputText() - Virtual method. Output textual data
* PHPClientUser::OutputInfo() - Virtual method. Output tabular data
* PHPClientUser::OutputStat() - Virtual method. Process tagged output
* PHPClientUser::OutputBinary() - Virtual method. Output binary data
* PHPClientUser::InputData() - Virtual method. Provide input data to commands
* PHPClientUser::Diff() - Virtual method. Diff two methods and display results
* PHPClientUser::Prompt() - Virtual method. Prompt the user and get a response
* PHPClientUser::Resolve() - Virtual method. Perform a resolve
* PHPClientUser::Finished() - Virtual method. To be called after a command
* PHPClientUser::GetInput() - Get the user input to be used for next command
* PHPClientUser::SetInput() - Set the user input to be used for next command
* PHPClientUser::GetResolver() - Get the resolver used when resolving
* PHPClientUser::SetResolver() - Set the resolver used when resolving
* PHPClientUser::SetCommand() - Set the name of the command being run
* PHPClientUser::GetResults() - Get the results collected from a command
* PHPClientUser::ErrorCount() - Get the error count
* PHPClientUser::Reset() - Reset all data, doesn't touch user input
* PHPClientUser::SetDebug() - Toggle the debug flag
*/
#ifndef PHP_CLIENT_USER_H
#define PHP_CLIENT_USER_H
class PHPClientSSO : public ClientSSO
{
public:
PHPClientSSO( SpecMgr *s );
virtual ~PHPClientSSO();
// Client SSO methods overridden here
virtual ClientSSOStatus Authorize( StrDict &vars, int maxLength,
StrBuf &result );
// Local methods
bool EnableSSO( zval *e );
void SSOEnabled( zval *retval );
bool SetPassResult( zval *i );
void GetPassResult( zval *retval );
bool SetFailResult( zval *i );
void GetFailResult( zval *retval );
void GetSSOVars( zval *retval );
private:
bool SetResult( zval *i );
int ssoEnabled;
int resultSet;
StrBufDict ssoVars;
SpecMgr * specMgr;
zval result;
};
class PHPClientUser : public ClientUser, public KeepAlive
{
public:
PHPClientUser( SpecMgr *s );
virtual ~PHPClientUser();
// Client User methods overridden here
virtual void HandleError( Error *e );
virtual void OutputText( const char *data, int length );
virtual void OutputInfo( char level, const char *data );
virtual void OutputStat( StrDict *values );
virtual void OutputBinary( const char *data, int length );
virtual void InputData( StrBuf *strBuf, Error *e );
virtual void Diff( FileSys *f1, FileSys *f2, int doPage, char *diffFlags,
Error *e );
virtual void Prompt( const StrPtr &msg, StrBuf &rsp, int noEcho, Error *e );
virtual int Resolve( ClientMerge *m, Error *e );
virtual int Resolve( ClientResolveA *m, int preview, Error *e );
virtual void Finished();
int IsAlive() { return alive; }
// Local methods
bool SetInput( zval *i );
void GetInput( zval *retval );
bool SetResolver( zval *i );
void GetResolver( zval *retval);
bool SetHandler( zval *h );
void GetHandler( zval *retval );
void SetCommand( const char *c ) { cmd = c; }
P4Result &GetResults() { return results; }
zval MkMergeInfo( ClientMerge *m, StrPtr &hint );
bool EnableSSO( zval *e ) { return ssoHandler->EnableSSO( e ); }
void SSOEnabled(zval *retval ) { ssoHandler->SSOEnabled( retval ); }
bool SetSSOPassResult( zval *i ) { return ssoHandler->SetPassResult( i ); }
void GetSSOPassResult( zval *retval ){ssoHandler->GetPassResult( retval );}
bool SetSSOFailResult( zval *i ) { return ssoHandler->SetFailResult( i ); }
void GetSSOFailResult( zval *retval ){ssoHandler->GetFailResult( retval );}
void GetSSOVars( zval *retval ) { ssoHandler->GetSSOVars( retval ); }
int ErrorCount();
void Reset();
// Debugging Support
void SetDebug( int d ) { debug = d; }
static void ArraySlice( zval *input, long offset, long length );
private:
P4Result results;
StrBuf cmd;
SpecMgr * specMgr;
int debug;
int alive;
zval input;
zval resolver;
zval handler;
PHPClientSSO * ssoHandler;
bool CallOutputMethod( const char * method, zval *data);
void ProcessOutput( const char * method, zval *data);
};
#endif /* PHP_CLIENT_USER_H */