Kitxuuu commited on
Commit
cf6e430
·
verified ·
1 Parent(s): d2fab09

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Bookmark.h +48 -0
  2. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Encryptor.m +206 -0
  3. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPSession.h +109 -0
  4. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPSession.m +534 -0
  5. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/CredentialsInputView.xib +481 -0
  6. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/EditSelectionTableViewCell.xib +347 -0
  7. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/EditTextTableViewCell.xib +364 -0
  8. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/RDPConnectingView.xib +342 -0
  9. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/RDPSessionView.xib +553 -0
  10. local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/SessionTableViewCell.xib +574 -0
  11. local-test-sqlite3-delta-03/afc-sqlite3/ext/fts3/unicode/mkunicode.tcl +987 -0
  12. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest.h +303 -0
  13. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest1.c +656 -0
  14. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest3.c +238 -0
  15. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_datasource.c +96 -0
  16. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb.c +846 -0
  17. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb3.c +1429 -0
  18. local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb4.c +980 -0
  19. local-test-sqlite3-delta-03/afc-sqlite3/ext/repair/test/README.md +13 -0
  20. local-test-sqlite3-delta-03/afc-sqlite3/ext/repair/test/checkindex01.test +349 -0
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Bookmark.h ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Bookmark model abstraction
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import <UIKit/UIKit.h>
13
+ #import "ConnectionParams.h"
14
+
15
+ @interface ComputerBookmark : NSObject <NSCoding>
16
+ {
17
+ @protected
18
+ ComputerBookmark *_parent;
19
+ NSString *_uuid, *_label;
20
+ UIImage *_image;
21
+ ConnectionParams *_connection_params;
22
+ BOOL _connected_via_wlan;
23
+ }
24
+
25
+ @property(nonatomic, assign) ComputerBookmark *parent;
26
+ @property(nonatomic, readonly) NSString *uuid;
27
+ @property(nonatomic, copy) NSString *label;
28
+ @property(nonatomic, retain) UIImage *image;
29
+ @property(readonly, nonatomic) ConnectionParams *params;
30
+ @property(nonatomic, assign) BOOL conntectedViaWLAN;
31
+
32
+ // Creates a copy of this object, with a new UUID
33
+ - (id)copy;
34
+ - (id)copyWithUUID;
35
+
36
+ // Whether user can delete, move, or rename this entry
37
+ - (BOOL)isDeletable;
38
+ - (BOOL)isMovable;
39
+ - (BOOL)isRenamable;
40
+ - (BOOL)hasImmutableHost;
41
+
42
+ - (id)initWithConnectionParameters:(ConnectionParams *)params;
43
+ - (id)initWithBaseDefaultParameters;
44
+
45
+ // A copy of @params, with _bookmark_uuid set.
46
+ - (ConnectionParams *)copyMarkedParams;
47
+
48
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Encryptor.m ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Password Encryptor
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ /* We try to use CommonCrypto as much as possible. PBKDF2 was added to CommonCrypto in iOS 5, so use
12
+ * OpenSSL only as a fallback to do PBKDF2 on pre iOS 5 systems. */
13
+
14
+ #import "Encryptor.h"
15
+ #import <CommonCrypto/CommonKeyDerivation.h>
16
+ #import <CommonCrypto/CommonCryptor.h>
17
+ #import <CommonCrypto/CommonDigest.h>
18
+ #import <openssl/evp.h> // For PBKDF2 on < 5.0
19
+ #include <fcntl.h>
20
+
21
+ #pragma mark -
22
+
23
+ @interface Encryptor (Private)
24
+ - (NSData *)randomInitializationVector;
25
+ @end
26
+
27
+ @implementation Encryptor
28
+ @synthesize plaintextPassword = _plaintext_password;
29
+
30
+ - (id)initWithPassword:(NSString *)plaintext_password
31
+ {
32
+ if (plaintext_password == nil)
33
+ return nil;
34
+
35
+ if (!(self = [super init]))
36
+ return nil;
37
+
38
+ _plaintext_password = [plaintext_password retain];
39
+ const char *plaintext_password_data =
40
+ [plaintext_password length] ? [plaintext_password UTF8String] : " ";
41
+
42
+ if (!plaintext_password_data || !strlen(plaintext_password_data))
43
+ [NSException raise:NSInternalInconsistencyException
44
+ format:@"%s: plaintext password data is zero length!", __func__];
45
+
46
+ uint8_t *derived_key = calloc(1, TSXEncryptorPBKDF2KeySize);
47
+
48
+ if (CCKeyDerivationPBKDF != NULL)
49
+ {
50
+ int ret = CCKeyDerivationPBKDF(
51
+ kCCPBKDF2, plaintext_password_data, strlen(plaintext_password_data) - 1,
52
+ (const uint8_t *)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen, kCCPRFHmacAlgSHA1,
53
+ TSXEncryptorPBKDF2Rounds, derived_key, TSXEncryptorPBKDF2KeySize);
54
+ // NSLog(@"CCKeyDerivationPBKDF ret = %d; key: %@", ret, [NSData
55
+ // dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
56
+
57
+ if (ret)
58
+ {
59
+ NSLog(@"%s: CCKeyDerivationPBKDF ret == %d, indicating some sort of failure.", __func__,
60
+ ret);
61
+ free(derived_key);
62
+ [self autorelease];
63
+ return nil;
64
+ }
65
+ }
66
+ else
67
+ {
68
+ // iOS 4.x or earlier -- use OpenSSL
69
+ unsigned long ret = PKCS5_PBKDF2_HMAC_SHA1(
70
+ plaintext_password_data, (int)strlen(plaintext_password_data) - 1,
71
+ (const unsigned char *)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen,
72
+ TSXEncryptorPBKDF2Rounds, TSXEncryptorPBKDF2KeySize, derived_key);
73
+ // NSLog(@"PKCS5_PBKDF2_HMAC_SHA1 ret = %lu; key: %@", ret, [NSData
74
+ // dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
75
+
76
+ if (ret != 1)
77
+ {
78
+ NSLog(@"%s: PKCS5_PBKDF2_HMAC_SHA1 ret == %lu, indicating some sort of failure.",
79
+ __func__, ret);
80
+ free(derived_key);
81
+ [self release];
82
+ return nil;
83
+ }
84
+ }
85
+
86
+ _encryption_key = [[NSData alloc] initWithBytesNoCopy:derived_key
87
+ length:TSXEncryptorPBKDF2KeySize
88
+ freeWhenDone:YES];
89
+ return self;
90
+ }
91
+
92
+ #pragma mark -
93
+ #pragma mark Encrypting/Decrypting data
94
+
95
+ - (NSData *)encryptData:(NSData *)plaintext_data
96
+ {
97
+ if (![plaintext_data length])
98
+ return nil;
99
+
100
+ NSData *iv = [self randomInitializationVector];
101
+ NSMutableData *encrypted_data = [NSMutableData
102
+ dataWithLength:[iv length] + [plaintext_data length] + TSXEncryptorBlockCipherBlockSize];
103
+ [encrypted_data replaceBytesInRange:NSMakeRange(0, [iv length]) withBytes:[iv bytes]];
104
+
105
+ size_t data_out_moved = 0;
106
+ int ret = CCCrypt(kCCEncrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions,
107
+ [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [iv bytes],
108
+ [plaintext_data bytes], [plaintext_data length],
109
+ [encrypted_data mutableBytes] + [iv length],
110
+ [encrypted_data length] - [iv length], &data_out_moved);
111
+
112
+ switch (ret)
113
+ {
114
+ case kCCSuccess:
115
+ [encrypted_data setLength:[iv length] + data_out_moved];
116
+ return encrypted_data;
117
+
118
+ default:
119
+ NSLog(
120
+ @"%s: uncaught error, ret CCCryptorStatus = %d (plaintext len = %lu; buffer size = "
121
+ @"%lu)",
122
+ __func__, ret, (unsigned long)[plaintext_data length],
123
+ (unsigned long)([encrypted_data length] - [iv length]));
124
+ return nil;
125
+ }
126
+
127
+ return nil;
128
+ }
129
+
130
+ - (NSData *)decryptData:(NSData *)encrypted_data
131
+ {
132
+ if ([encrypted_data length] <= TSXEncryptorBlockCipherBlockSize)
133
+ return nil;
134
+
135
+ NSMutableData *plaintext_data =
136
+ [NSMutableData dataWithLength:[encrypted_data length] + TSXEncryptorBlockCipherBlockSize];
137
+ size_t data_out_moved = 0;
138
+
139
+ int ret =
140
+ CCCrypt(kCCDecrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions,
141
+ [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [encrypted_data bytes],
142
+ [encrypted_data bytes] + TSXEncryptorBlockCipherBlockSize,
143
+ [encrypted_data length] - TSXEncryptorBlockCipherBlockSize,
144
+ [plaintext_data mutableBytes], [plaintext_data length], &data_out_moved);
145
+
146
+ switch (ret)
147
+ {
148
+ case kCCSuccess:
149
+ [plaintext_data setLength:data_out_moved];
150
+ return plaintext_data;
151
+
152
+ case kCCBufferTooSmall: // Our output buffer is big enough to decrypt valid data. This
153
+ // return code indicates malformed data.
154
+ case kCCAlignmentError: // Shouldn't get this, since we're using padding.
155
+ case kCCDecodeError: // Wrong key.
156
+ return nil;
157
+
158
+ default:
159
+ NSLog(@"%s: uncaught error, ret CCCryptorStatus = %d (encrypted data len = %lu; buffer "
160
+ @"size = %lu; dom = %lu)",
161
+ __func__, ret, (unsigned long)[encrypted_data length],
162
+ (unsigned long)[plaintext_data length], data_out_moved);
163
+ return nil;
164
+ }
165
+
166
+ return nil;
167
+ }
168
+
169
+ - (NSData *)encryptString:(NSString *)plaintext_string
170
+ {
171
+ return [self encryptData:[plaintext_string dataUsingEncoding:NSUTF8StringEncoding]];
172
+ }
173
+
174
+ - (NSString *)decryptString:(NSData *)encrypted_string
175
+ {
176
+ return [[[NSString alloc] initWithData:[self decryptData:encrypted_string]
177
+ encoding:NSUTF8StringEncoding] autorelease];
178
+ }
179
+
180
+ - (NSData *)randomInitializationVector
181
+ {
182
+ NSMutableData *iv = [NSMutableData dataWithLength:TSXEncryptorBlockCipherBlockSize];
183
+ int fd;
184
+
185
+ if ((fd = open("/dev/urandom", O_RDONLY)) < 0)
186
+ return nil;
187
+
188
+ NSInteger bytes_needed = [iv length];
189
+ char *p = [iv mutableBytes];
190
+
191
+ while (bytes_needed)
192
+ {
193
+ long bytes_read = read(fd, p, bytes_needed);
194
+
195
+ if (bytes_read < 0)
196
+ continue;
197
+
198
+ p += bytes_read;
199
+ bytes_needed -= bytes_read;
200
+ }
201
+
202
+ close(fd);
203
+ return iv;
204
+ }
205
+
206
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPSession.h ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Session object
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import <UIKit/UIKit.h>
13
+
14
+ #include <freerdp/freerdp.h>
15
+
16
+ // forward declaration
17
+ @class RDPSession;
18
+ @class ComputerBookmark;
19
+ @class ConnectionParams;
20
+
21
+ // notification handler for session disconnect
22
+ extern NSString *TSXSessionDidDisconnectNotification;
23
+ extern NSString *TSXSessionDidFailToConnectNotification;
24
+
25
+ // protocol for session notifications
26
+ @protocol RDPSessionDelegate <NSObject>
27
+ @optional
28
+ - (void)session:(RDPSession *)session didFailToConnect:(int)reason;
29
+ - (void)sessionWillConnect:(RDPSession *)session;
30
+ - (void)sessionDidConnect:(RDPSession *)session;
31
+ - (void)sessionWillDisconnect:(RDPSession *)session;
32
+ - (void)sessionDidDisconnect:(RDPSession *)session;
33
+ - (void)sessionBitmapContextWillChange:(RDPSession *)session;
34
+ - (void)sessionBitmapContextDidChange:(RDPSession *)session;
35
+ - (void)session:(RDPSession *)session needsRedrawInRect:(CGRect)rect;
36
+ - (CGSize)sizeForFitScreenForSession:(RDPSession *)session;
37
+
38
+ - (void)session:(RDPSession *)session
39
+ requestsAuthenticationWithParams:(NSMutableDictionary *)params;
40
+ - (void)session:(RDPSession *)session verifyCertificateWithParams:(NSMutableDictionary *)params;
41
+
42
+ @end
43
+
44
+ // rdp session
45
+ @interface RDPSession : NSObject
46
+ {
47
+ @private
48
+ freerdp *_freerdp;
49
+
50
+ ComputerBookmark *_bookmark;
51
+
52
+ ConnectionParams *_params;
53
+
54
+ NSObject<RDPSessionDelegate> *_delegate;
55
+
56
+ NSCondition *_ui_request_completed;
57
+
58
+ NSString *_name;
59
+
60
+ // flag if the session is suspended
61
+ BOOL _suspended;
62
+
63
+ // flag that specifies whether the RDP toolbar is visible
64
+ BOOL _toolbar_visible;
65
+ }
66
+
67
+ @property(readonly) ConnectionParams *params;
68
+ @property(readonly) ComputerBookmark *bookmark;
69
+ @property(assign) id<RDPSessionDelegate> delegate;
70
+ @property(assign) BOOL toolbarVisible;
71
+ @property(readonly) CGContextRef bitmapContext;
72
+ @property(readonly) NSCondition *uiRequestCompleted;
73
+
74
+ // initialize a new session with the given bookmark
75
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark;
76
+
77
+ #pragma mark - session control functions
78
+
79
+ // connect the session
80
+ - (void)connect;
81
+
82
+ // disconnect session
83
+ - (void)disconnect;
84
+
85
+ // suspends the session
86
+ - (void)suspend;
87
+
88
+ // resumes a previously suspended session
89
+ - (void)resume;
90
+
91
+ // returns YES if the session is started
92
+ - (BOOL)isSuspended;
93
+
94
+ // send input event to the server
95
+ - (void)sendInputEvent:(NSDictionary *)event;
96
+
97
+ // session needs a refresh of its view
98
+ - (void)setNeedsDisplayInRectAsValue:(NSValue *)rect_value;
99
+
100
+ // get a small session screenshot
101
+ - (UIImage *)getScreenshotWithSize:(CGSize)size;
102
+
103
+ // returns the session's current parameters
104
+ - (rdpSettings *)getSessionParams;
105
+
106
+ // returns the session's name (usually the label of the bookmark the session was created with)
107
+ - (NSString *)sessionName;
108
+
109
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPSession.m ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Session object
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "ios_freerdp.h"
12
+ #import "ios_freerdp_ui.h"
13
+ #import "ios_freerdp_events.h"
14
+
15
+ #import "RDPSession.h"
16
+ #import "TSXTypes.h"
17
+ #import "Bookmark.h"
18
+ #import "ConnectionParams.h"
19
+
20
+ NSString *TSXSessionDidDisconnectNotification = @"TSXSessionDidDisconnect";
21
+ NSString *TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect";
22
+
23
+ @interface RDPSession (Private)
24
+ - (void)runSession;
25
+ - (void)runSessionFinished:(NSNumber *)result;
26
+ - (mfInfo *)mfi;
27
+
28
+ // The connection thread calls these on the main thread.
29
+ - (void)sessionWillConnect;
30
+ - (void)sessionDidConnect;
31
+ - (void)sessionDidDisconnect;
32
+ - (void)sessionDidFailToConnect:(int)reason;
33
+ - (void)sessionBitmapContextWillChange;
34
+ - (void)sessionBitmapContextDidChange;
35
+ @end
36
+
37
+ @implementation RDPSession
38
+
39
+ @synthesize delegate = _delegate, params = _params, toolbarVisible = _toolbar_visible,
40
+ uiRequestCompleted = _ui_request_completed, bookmark = _bookmark;
41
+
42
+ + (void)initialize
43
+ {
44
+ ios_init_freerdp();
45
+ }
46
+
47
+ static BOOL addArgument(int *argc, char ***argv, const char *fmt, ...)
48
+ {
49
+ va_list ap;
50
+ char *arg = NULL;
51
+ char **tmp = realloc(*argv, (*argc + 1) * sizeof(char *));
52
+
53
+ if (!tmp)
54
+ return FALSE;
55
+
56
+ *argv = tmp;
57
+ *argc = *argc + 1;
58
+ va_start(ap, fmt);
59
+ vasprintf(&arg, fmt, ap);
60
+ va_end(ap);
61
+ (*argv)[*argc - 1] = arg;
62
+ return TRUE;
63
+ }
64
+
65
+ static BOOL addFlag(int *argc, char ***argv, const char *str, BOOL flag)
66
+ {
67
+ return addArgument(argc, argv, "%s%s", flag ? "+" : "-", str);
68
+ }
69
+
70
+ static void freeArguments(int argc, char **argv)
71
+ {
72
+ for (int i = 0; i < argc; i++)
73
+ free(argv[i]);
74
+
75
+ free(argv);
76
+ }
77
+
78
+ // Designated initializer.
79
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark
80
+ {
81
+ int status;
82
+ char **argv = NULL;
83
+ int argc = 0;
84
+
85
+ if (!(self = [super init]))
86
+ return nil;
87
+
88
+ if (!bookmark)
89
+ [NSException raise:NSInvalidArgumentException
90
+ format:@"%s: params may not be nil.", __func__];
91
+
92
+ _bookmark = [bookmark retain];
93
+ _params = [[bookmark params] copy];
94
+ _name = [[bookmark label] retain];
95
+ _delegate = nil;
96
+ _toolbar_visible = YES;
97
+ _freerdp = ios_freerdp_new();
98
+ _ui_request_completed = [[NSCondition alloc] init];
99
+ BOOL connected_via_3g = ![bookmark conntectedViaWLAN];
100
+
101
+ if (!addArgument(&argc, &argv, "iFreeRDP"))
102
+ goto out_free;
103
+
104
+ if (!addArgument(&argc, &argv, "/gdi:sw"))
105
+ goto out_free;
106
+
107
+ // Screen Size is set on connect (we need a valid delegate in case the user choose an automatic
108
+ // screen size)
109
+
110
+ // Other simple numeric settings
111
+ if ([_params hasValueForKey:@"colors"])
112
+ if (!addArgument(&argc, &argv, "/bpp:%d",
113
+ [_params intForKey:@"colors" with3GEnabled:connected_via_3g]))
114
+ goto out_free;
115
+
116
+ if ([_params hasValueForKey:@"port"])
117
+ if (!addArgument(&argc, &argv, "/port:%d", [_params intForKey:@"port"]))
118
+ goto out_free;
119
+
120
+ if ([_params boolForKey:@"console"])
121
+ if (!addArgument(&argc, &argv, "/admin"))
122
+ goto out_free;
123
+
124
+ if (!addArgument(&argc, &argv, "/v:%s", [_params UTF8StringForKey:@"hostname"]))
125
+ goto out_free;
126
+
127
+ // String settings
128
+ if ([[_params StringForKey:@"username"] length])
129
+ {
130
+ if (!addArgument(&argc, &argv, "/u:%s", [_params UTF8StringForKey:@"username"]))
131
+ goto out_free;
132
+ }
133
+
134
+ if ([[_params StringForKey:@"password"] length])
135
+ {
136
+ if (!addArgument(&argc, &argv, "/p:%s", [_params UTF8StringForKey:@"password"]))
137
+ goto out_free;
138
+ }
139
+
140
+ if ([[_params StringForKey:@"domain"] length])
141
+ {
142
+ if (!addArgument(&argc, &argv, "/d:%s", [_params UTF8StringForKey:@"domain"]))
143
+ goto out_free;
144
+ }
145
+
146
+ if ([[_params StringForKey:@"working_directory"] length])
147
+ {
148
+ if (!addArgument(&argc, &argv, "/shell-dir:%s",
149
+ [_params UTF8StringForKey:@"working_directory"]))
150
+ goto out_free;
151
+ }
152
+
153
+ if ([[_params StringForKey:@"remote_program"] length])
154
+ {
155
+ if (!addArgument(&argc, &argv, "/shell:%s", [_params UTF8StringForKey:@"remote_program"]))
156
+ goto out_free;
157
+ }
158
+
159
+ // RemoteFX
160
+ if ([_params boolForKey:@"perf_remotefx" with3GEnabled:connected_via_3g])
161
+ if (!addArgument(&argc, &argv, "/rfx"))
162
+ goto out_free;
163
+
164
+ if ([_params boolForKey:@"perf_gfx" with3GEnabled:connected_via_3g])
165
+ if (!addArgument(&argc, &argv, "/gfx"))
166
+ goto out_free;
167
+
168
+ if ([_params boolForKey:@"perf_h264" with3GEnabled:connected_via_3g])
169
+ if (!addArgument(&argc, &argv, "/gfx-h264"))
170
+ goto out_free;
171
+
172
+ if (![_params boolForKey:@"perf_remotefx" with3GEnabled:connected_via_3g] &&
173
+ ![_params boolForKey:@"perf_gfx" with3GEnabled:connected_via_3g] &&
174
+ ![_params boolForKey:@"perf_h264" with3GEnabled:connected_via_3g])
175
+ if (!addArgument(&argc, &argv, "/nsc"))
176
+ goto out_free;
177
+
178
+ if (!addFlag(&argc, &argv, "bitmap-cache", TRUE))
179
+ goto out_free;
180
+
181
+ if (!addFlag(&argc, &argv, "wallpaper",
182
+ [_params boolForKey:@"perf_show_desktop" with3GEnabled:connected_via_3g]))
183
+ goto out_free;
184
+
185
+ if (!addFlag(&argc, &argv, "window-drag",
186
+ [_params boolForKey:@"perf_window_dragging" with3GEnabled:connected_via_3g]))
187
+ goto out_free;
188
+
189
+ if (!addFlag(&argc, &argv, "menu-anims",
190
+ [_params boolForKey:@"perf_menu_animation" with3GEnabled:connected_via_3g]))
191
+ goto out_free;
192
+
193
+ if (!addFlag(&argc, &argv, "themes",
194
+ [_params boolForKey:@"perf_windows_themes" with3GEnabled:connected_via_3g]))
195
+ goto out_free;
196
+
197
+ if (!addFlag(&argc, &argv, "fonts",
198
+ [_params boolForKey:@"perf_font_smoothing" with3GEnabled:connected_via_3g]))
199
+ goto out_free;
200
+
201
+ if (!addFlag(&argc, &argv, "aero",
202
+ [_params boolForKey:@"perf_desktop_composition" with3GEnabled:connected_via_3g]))
203
+ goto out_free;
204
+
205
+ if ([_params hasValueForKey:@"width"])
206
+ if (!addArgument(&argc, &argv, "/w:%d", [_params intForKey:@"width"]))
207
+ goto out_free;
208
+
209
+ if ([_params hasValueForKey:@"height"])
210
+ if (!addArgument(&argc, &argv, "/h:%d", [_params intForKey:@"height"]))
211
+ goto out_free;
212
+
213
+ // security
214
+ switch ([_params intForKey:@"security"])
215
+ {
216
+ case TSXProtocolSecurityNLA:
217
+ if (!addArgument(&argc, &argv, "/sec:NLA"))
218
+ goto out_free;
219
+
220
+ break;
221
+
222
+ case TSXProtocolSecurityTLS:
223
+ if (!addArgument(&argc, &argv, "/sec:TLS"))
224
+ goto out_free;
225
+
226
+ break;
227
+
228
+ case TSXProtocolSecurityRDP:
229
+ if (!addArgument(&argc, &argv, "/sec:RDP"))
230
+ goto out_free;
231
+
232
+ break;
233
+
234
+ default:
235
+ break;
236
+ }
237
+
238
+ // ts gateway settings
239
+ if ([_params boolForKey:@"enable_tsg_settings"])
240
+ {
241
+ if (!addArgument(&argc, &argv, "/g:%s", [_params UTF8StringForKey:@"tsg_hostname"]))
242
+ goto out_free;
243
+
244
+ if (!addArgument(&argc, &argv, "/gp:%d", [_params intForKey:@"tsg_port"]))
245
+ goto out_free;
246
+
247
+ if (!addArgument(&argc, &argv, "/gu:%s", [_params intForKey:@"tsg_username"]))
248
+ goto out_free;
249
+
250
+ if (!addArgument(&argc, &argv, "/gp:%s", [_params intForKey:@"tsg_password"]))
251
+ goto out_free;
252
+
253
+ if (!addArgument(&argc, &argv, "/gd:%s", [_params intForKey:@"tsg_domain"]))
254
+ goto out_free;
255
+ }
256
+
257
+ // Remote keyboard layout
258
+ if (!addArgument(&argc, &argv, "/kbd:%d", 0x409))
259
+ goto out_free;
260
+
261
+ status =
262
+ freerdp_client_settings_parse_command_line(_freerdp->context->settings, argc, argv, FALSE);
263
+
264
+ if (0 != status)
265
+ goto out_free;
266
+
267
+ freeArguments(argc, argv);
268
+ [self mfi]->session = self;
269
+ return self;
270
+ out_free:
271
+ freeArguments(argc, argv);
272
+ [self release];
273
+ return nil;
274
+ }
275
+
276
+ - (void)dealloc
277
+ {
278
+ [self setDelegate:nil];
279
+ [_bookmark release];
280
+ [_name release];
281
+ [_params release];
282
+ [_ui_request_completed release];
283
+ ios_freerdp_free(_freerdp);
284
+ [super dealloc];
285
+ }
286
+
287
+ - (CGContextRef)bitmapContext
288
+ {
289
+ return [self mfi]->bitmap_context;
290
+ }
291
+
292
+ #pragma mark -
293
+ #pragma mark Connecting and disconnecting
294
+
295
+ - (void)connect
296
+ {
297
+ // Set Screen Size to automatic if width or height are still 0
298
+ rdpSettings *settings = _freerdp->context->settings;
299
+
300
+ if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) == 0 ||
301
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) == 0)
302
+ {
303
+ CGSize size = CGSizeZero;
304
+
305
+ if ([[self delegate] respondsToSelector:@selector(sizeForFitScreenForSession:)])
306
+ size = [[self delegate] sizeForFitScreenForSession:self];
307
+
308
+ if (!CGSizeEqualToSize(CGSizeZero, size))
309
+ {
310
+ [_params setInt:size.width forKey:@"width"];
311
+ [_params setInt:size.height forKey:@"height"];
312
+ (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, size.width);
313
+ (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, size.height);
314
+ }
315
+ }
316
+
317
+ // TODO: This is a hack to ensure connections to RDVH with 16bpp don't have an odd screen
318
+ // resolution width
319
+ // Otherwise this could result in screen corruption ..
320
+ if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) <= 16)
321
+ {
322
+ const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) & (~1);
323
+ (void)freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, w);
324
+ }
325
+
326
+ [self performSelectorInBackground:@selector(runSession) withObject:nil];
327
+ }
328
+
329
+ - (void)disconnect
330
+ {
331
+ mfInfo *mfi = [self mfi];
332
+ ios_events_send(mfi, [NSDictionary dictionaryWithObject:@"disconnect" forKey:@"type"]);
333
+
334
+ if (mfi->connection_state == TSXConnectionConnecting)
335
+ {
336
+ mfi->unwanted = YES;
337
+ [self sessionDidDisconnect];
338
+ return;
339
+ }
340
+ }
341
+
342
+ - (TSXConnectionState)connectionState
343
+ {
344
+ return [self mfi]->connection_state;
345
+ }
346
+
347
+ // suspends the session
348
+ - (void)suspend
349
+ {
350
+ if (!_suspended)
351
+ {
352
+ _suspended = YES;
353
+ // instance->update->SuppressOutput(instance->context, 0, NULL);
354
+ }
355
+ }
356
+
357
+ // resumes a previously suspended session
358
+ - (void)resume
359
+ {
360
+ if (_suspended)
361
+ {
362
+ /* RECTANGLE_16 rec;
363
+ rec.left = 0;
364
+ rec.top = 0;
365
+ rec.right = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopWidth);
366
+ rec.bottom = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopHeight);
367
+ */
368
+ _suspended = NO;
369
+ // instance->update->SuppressOutput(instance->context, 1, &rec);
370
+ // [delegate sessionScreenSettingsChanged:self];
371
+ }
372
+ }
373
+
374
+ // returns YES if the session is started
375
+ - (BOOL)isSuspended
376
+ {
377
+ return _suspended;
378
+ }
379
+
380
+ #pragma mark -
381
+ #pragma mark Input events
382
+
383
+ - (void)sendInputEvent:(NSDictionary *)eventDescriptor
384
+ {
385
+ if ([self mfi]->connection_state == TSXConnectionConnected)
386
+ ios_events_send([self mfi], eventDescriptor);
387
+ }
388
+
389
+ #pragma mark -
390
+ #pragma mark Server events (main thread)
391
+
392
+ - (void)setNeedsDisplayInRectAsValue:(NSValue *)rect_value
393
+ {
394
+ if ([[self delegate] respondsToSelector:@selector(session:needsRedrawInRect:)])
395
+ [[self delegate] session:self needsRedrawInRect:[rect_value CGRectValue]];
396
+ }
397
+
398
+ #pragma mark -
399
+ #pragma mark interface functions
400
+
401
+ - (UIImage *)getScreenshotWithSize:(CGSize)size
402
+ {
403
+ NSAssert([self mfi]->bitmap_context != nil,
404
+ @"Screenshot requested while having no valid RDP drawing context");
405
+ CGImageRef cgImage = CGBitmapContextCreateImage([self mfi]->bitmap_context);
406
+ UIGraphicsBeginImageContext(size);
407
+ CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, size.height);
408
+ CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
409
+ CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height),
410
+ cgImage);
411
+ UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
412
+ UIGraphicsEndImageContext();
413
+ CGImageRelease(cgImage);
414
+ return viewImage;
415
+ }
416
+
417
+ - (rdpSettings *)getSessionParams
418
+ {
419
+ return _freerdp->context->settings;
420
+ }
421
+
422
+ - (NSString *)sessionName
423
+ {
424
+ return _name;
425
+ }
426
+
427
+ @end
428
+
429
+ #pragma mark -
430
+ @implementation RDPSession (Private)
431
+
432
+ - (mfInfo *)mfi
433
+ {
434
+ return MFI_FROM_INSTANCE(_freerdp);
435
+ }
436
+
437
+ // Blocks until rdp session finishes.
438
+ - (void)runSession
439
+ {
440
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
441
+ // Run the session
442
+ [self performSelectorOnMainThread:@selector(sessionWillConnect)
443
+ withObject:nil
444
+ waitUntilDone:YES];
445
+ int result_code = ios_run_freerdp(_freerdp);
446
+ [self mfi]->connection_state = TSXConnectionDisconnected;
447
+ [self performSelectorOnMainThread:@selector(runSessionFinished:)
448
+ withObject:[NSNumber numberWithInt:result_code]
449
+ waitUntilDone:YES];
450
+ [pool release];
451
+ }
452
+
453
+ // Main thread.
454
+ - (void)runSessionFinished:(NSNumber *)result
455
+ {
456
+ int result_code = [result intValue];
457
+
458
+ switch (result_code)
459
+ {
460
+ case MF_EXIT_CONN_CANCELED:
461
+ [self sessionDidDisconnect];
462
+ break;
463
+
464
+ case MF_EXIT_LOGON_TIMEOUT:
465
+ case MF_EXIT_CONN_FAILED:
466
+ [self sessionDidFailToConnect:result_code];
467
+ break;
468
+
469
+ case MF_EXIT_SUCCESS:
470
+ default:
471
+ [self sessionDidDisconnect];
472
+ break;
473
+ }
474
+ }
475
+
476
+ #pragma mark -
477
+ #pragma mark Session management (main thread)
478
+
479
+ - (void)sessionWillConnect
480
+ {
481
+ if ([[self delegate] respondsToSelector:@selector(sessionWillConnect:)])
482
+ [[self delegate] sessionWillConnect:self];
483
+ }
484
+
485
+ - (void)sessionDidConnect
486
+ {
487
+ if ([[self delegate] respondsToSelector:@selector(sessionDidConnect:)])
488
+ [[self delegate] sessionDidConnect:self];
489
+ }
490
+
491
+ - (void)sessionDidFailToConnect:(int)reason
492
+ {
493
+ [[NSNotificationCenter defaultCenter]
494
+ postNotificationName:TSXSessionDidFailToConnectNotification
495
+ object:self];
496
+
497
+ if ([[self delegate] respondsToSelector:@selector(session:didFailToConnect:)])
498
+ [[self delegate] session:self didFailToConnect:reason];
499
+ }
500
+
501
+ - (void)sessionDidDisconnect
502
+ {
503
+ [[NSNotificationCenter defaultCenter] postNotificationName:TSXSessionDidDisconnectNotification
504
+ object:self];
505
+
506
+ if ([[self delegate] respondsToSelector:@selector(sessionDidDisconnect:)])
507
+ [[self delegate] sessionDidDisconnect:self];
508
+ }
509
+
510
+ - (void)sessionBitmapContextWillChange
511
+ {
512
+ if ([[self delegate] respondsToSelector:@selector(sessionBitmapContextWillChange:)])
513
+ [[self delegate] sessionBitmapContextWillChange:self];
514
+ }
515
+
516
+ - (void)sessionBitmapContextDidChange
517
+ {
518
+ if ([[self delegate] respondsToSelector:@selector(sessionBitmapContextDidChange:)])
519
+ [[self delegate] sessionBitmapContextDidChange:self];
520
+ }
521
+
522
+ - (void)sessionRequestsAuthenticationWithParams:(NSMutableDictionary *)params
523
+ {
524
+ if ([[self delegate] respondsToSelector:@selector(session:requestsAuthenticationWithParams:)])
525
+ [[self delegate] session:self requestsAuthenticationWithParams:params];
526
+ }
527
+
528
+ - (void)sessionVerifyCertificateWithParams:(NSMutableDictionary *)params
529
+ {
530
+ if ([[self delegate] respondsToSelector:@selector(session:verifyCertificateWithParams:)])
531
+ [[self delegate] session:self verifyCertificateWithParams:params];
532
+ }
533
+
534
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/CredentialsInputView.xib ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
14
+ <bool key="EncodedWithXMLCoder">YES</bool>
15
+ <string>IBUITextField</string>
16
+ <string>IBUILabel</string>
17
+ <string>IBUIButton</string>
18
+ <string>IBUIView</string>
19
+ <string>IBUIScrollView</string>
20
+ <string>IBProxyObject</string>
21
+ </object>
22
+ <object class="NSArray" key="IBDocument.PluginDependencies">
23
+ <bool key="EncodedWithXMLCoder">YES</bool>
24
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
25
+ </object>
26
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
27
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
28
+ <integer value="1" key="NS.object.0"/>
29
+ </object>
30
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
31
+ <bool key="EncodedWithXMLCoder">YES</bool>
32
+ <object class="IBProxyObject" id="372490531">
33
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
34
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
35
+ </object>
36
+ <object class="IBProxyObject" id="975951072">
37
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
38
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
39
+ </object>
40
+ <object class="IBUIView" id="234977634">
41
+ <reference key="NSNextResponder"/>
42
+ <int key="NSvFlags">274</int>
43
+ <object class="NSMutableArray" key="NSSubviews">
44
+ <bool key="EncodedWithXMLCoder">YES</bool>
45
+ <object class="IBUIScrollView" id="76355032">
46
+ <reference key="NSNextResponder" ref="234977634"/>
47
+ <int key="NSvFlags">279</int>
48
+ <object class="NSMutableArray" key="NSSubviews">
49
+ <bool key="EncodedWithXMLCoder">YES</bool>
50
+ <object class="IBUITextField" id="502350293">
51
+ <reference key="NSNextResponder" ref="76355032"/>
52
+ <int key="NSvFlags">290</int>
53
+ <string key="NSFrame">{{15, 112}, {210, 31}}</string>
54
+ <reference key="NSSuperview" ref="76355032"/>
55
+ <reference key="NSNextKeyView" ref="407758879"/>
56
+ <bool key="IBUIOpaque">NO</bool>
57
+ <bool key="IBUIClipsSubviews">YES</bool>
58
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
59
+ <int key="IBUIContentVerticalAlignment">0</int>
60
+ <string key="IBUIText"/>
61
+ <int key="IBUIBorderStyle">3</int>
62
+ <string key="IBUIPlaceholder">Username</string>
63
+ <object class="NSColor" key="IBUITextColor">
64
+ <int key="NSColorSpace">3</int>
65
+ <bytes key="NSWhite">MAA</bytes>
66
+ <object class="NSColorSpace" key="NSCustomColorSpace" id="1055564775">
67
+ <int key="NSID">2</int>
68
+ </object>
69
+ </object>
70
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
71
+ <float key="IBUIMinimumFontSize">17</float>
72
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
73
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
74
+ </object>
75
+ <int key="IBUIClearButtonMode">3</int>
76
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="72634085">
77
+ <int key="type">1</int>
78
+ <double key="pointSize">12</double>
79
+ </object>
80
+ <object class="NSFont" key="IBUIFont" id="168483421">
81
+ <string key="NSName">Helvetica</string>
82
+ <double key="NSSize">12</double>
83
+ <int key="NSfFlags">16</int>
84
+ </object>
85
+ </object>
86
+ <object class="IBUITextField" id="407758879">
87
+ <reference key="NSNextResponder" ref="76355032"/>
88
+ <int key="NSvFlags">290</int>
89
+ <string key="NSFrame">{{15, 161}, {210, 31}}</string>
90
+ <reference key="NSSuperview" ref="76355032"/>
91
+ <reference key="NSNextKeyView" ref="316210701"/>
92
+ <bool key="IBUIOpaque">NO</bool>
93
+ <bool key="IBUIClipsSubviews">YES</bool>
94
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
95
+ <int key="IBUIContentVerticalAlignment">0</int>
96
+ <string key="IBUIText"/>
97
+ <int key="IBUIBorderStyle">3</int>
98
+ <string key="IBUIPlaceholder">Password</string>
99
+ <object class="NSColor" key="IBUITextColor">
100
+ <int key="NSColorSpace">3</int>
101
+ <bytes key="NSWhite">MAA</bytes>
102
+ <reference key="NSCustomColorSpace" ref="1055564775"/>
103
+ </object>
104
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
105
+ <float key="IBUIMinimumFontSize">17</float>
106
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
107
+ <bool key="IBUISecureTextEntry">YES</bool>
108
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
109
+ </object>
110
+ <int key="IBUIClearButtonMode">3</int>
111
+ <reference key="IBUIFontDescription" ref="72634085"/>
112
+ <reference key="IBUIFont" ref="168483421"/>
113
+ </object>
114
+ <object class="IBUITextField" id="316210701">
115
+ <reference key="NSNextResponder" ref="76355032"/>
116
+ <int key="NSvFlags">290</int>
117
+ <string key="NSFrame">{{15, 210}, {210, 31}}</string>
118
+ <reference key="NSSuperview" ref="76355032"/>
119
+ <reference key="NSNextKeyView" ref="266626143"/>
120
+ <bool key="IBUIOpaque">NO</bool>
121
+ <bool key="IBUIClipsSubviews">YES</bool>
122
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
123
+ <int key="IBUIContentVerticalAlignment">0</int>
124
+ <string key="IBUIText"/>
125
+ <int key="IBUIBorderStyle">3</int>
126
+ <string key="IBUIPlaceholder">Domain</string>
127
+ <object class="NSColor" key="IBUITextColor">
128
+ <int key="NSColorSpace">3</int>
129
+ <bytes key="NSWhite">MAA</bytes>
130
+ <reference key="NSCustomColorSpace" ref="1055564775"/>
131
+ </object>
132
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
133
+ <float key="IBUIMinimumFontSize">17</float>
134
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
135
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
136
+ </object>
137
+ <int key="IBUIClearButtonMode">3</int>
138
+ <reference key="IBUIFontDescription" ref="72634085"/>
139
+ <reference key="IBUIFont" ref="168483421"/>
140
+ </object>
141
+ <object class="IBUIButton" id="67582393">
142
+ <reference key="NSNextResponder" ref="76355032"/>
143
+ <int key="NSvFlags">291</int>
144
+ <string key="NSFrame">{{130, 263}, {95, 37}}</string>
145
+ <reference key="NSSuperview" ref="76355032"/>
146
+ <bool key="IBUIOpaque">NO</bool>
147
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
148
+ <int key="IBUIContentHorizontalAlignment">0</int>
149
+ <int key="IBUIContentVerticalAlignment">0</int>
150
+ <int key="IBUIButtonType">1</int>
151
+ <string key="IBUINormalTitle">Cancel</string>
152
+ <object class="NSColor" key="IBUIHighlightedTitleColor" id="484131582">
153
+ <int key="NSColorSpace">3</int>
154
+ <bytes key="NSWhite">MQA</bytes>
155
+ </object>
156
+ <object class="NSColor" key="IBUINormalTitleColor">
157
+ <int key="NSColorSpace">1</int>
158
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
159
+ </object>
160
+ <object class="NSColor" key="IBUINormalTitleShadowColor" id="210891822">
161
+ <int key="NSColorSpace">3</int>
162
+ <bytes key="NSWhite">MC41AA</bytes>
163
+ </object>
164
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="223796057">
165
+ <string key="name">Helvetica-Bold</string>
166
+ <string key="family">Helvetica</string>
167
+ <int key="traits">2</int>
168
+ <double key="pointSize">15</double>
169
+ </object>
170
+ <object class="NSFont" key="IBUIFont" id="1043513320">
171
+ <string key="NSName">Helvetica-Bold</string>
172
+ <double key="NSSize">15</double>
173
+ <int key="NSfFlags">16</int>
174
+ </object>
175
+ </object>
176
+ <object class="IBUIButton" id="266626143">
177
+ <reference key="NSNextResponder" ref="76355032"/>
178
+ <int key="NSvFlags">294</int>
179
+ <string key="NSFrame">{{15, 263}, {95, 37}}</string>
180
+ <reference key="NSSuperview" ref="76355032"/>
181
+ <reference key="NSNextKeyView" ref="67582393"/>
182
+ <bool key="IBUIOpaque">NO</bool>
183
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
184
+ <int key="IBUIContentHorizontalAlignment">0</int>
185
+ <int key="IBUIContentVerticalAlignment">0</int>
186
+ <int key="IBUIButtonType">1</int>
187
+ <string key="IBUINormalTitle">Login</string>
188
+ <reference key="IBUIHighlightedTitleColor" ref="484131582"/>
189
+ <object class="NSColor" key="IBUINormalTitleColor">
190
+ <int key="NSColorSpace">1</int>
191
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
192
+ </object>
193
+ <reference key="IBUINormalTitleShadowColor" ref="210891822"/>
194
+ <reference key="IBUIFontDescription" ref="223796057"/>
195
+ <reference key="IBUIFont" ref="1043513320"/>
196
+ </object>
197
+ <object class="IBUILabel" id="876100682">
198
+ <reference key="NSNextResponder" ref="76355032"/>
199
+ <int key="NSvFlags">290</int>
200
+ <string key="NSFrame">{{15, 20}, {210, 71}}</string>
201
+ <reference key="NSSuperview" ref="76355032"/>
202
+ <reference key="NSNextKeyView" ref="502350293"/>
203
+ <bool key="IBUIOpaque">NO</bool>
204
+ <bool key="IBUIClipsSubviews">YES</bool>
205
+ <int key="IBUIContentMode">7</int>
206
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
207
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
208
+ <string key="IBUIText">Please provide the missing user information in order to proceed and login.</string>
209
+ <object class="NSColor" key="IBUITextColor">
210
+ <int key="NSColorSpace">1</int>
211
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
212
+ </object>
213
+ <nil key="IBUIHighlightedColor"/>
214
+ <int key="IBUIBaselineAdjustment">1</int>
215
+ <float key="IBUIMinimumFontSize">10</float>
216
+ <int key="IBUINumberOfLines">3</int>
217
+ <int key="IBUILineBreakMode">0</int>
218
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
219
+ <int key="type">1</int>
220
+ <double key="pointSize">17</double>
221
+ </object>
222
+ <object class="NSFont" key="IBUIFont">
223
+ <string key="NSName">Helvetica</string>
224
+ <double key="NSSize">17</double>
225
+ <int key="NSfFlags">16</int>
226
+ </object>
227
+ </object>
228
+ </object>
229
+ <string key="NSFrameSize">{240, 320}</string>
230
+ <reference key="NSSuperview" ref="234977634"/>
231
+ <reference key="NSNextKeyView" ref="876100682"/>
232
+ <string key="NSReuseIdentifierKey">_NS:9</string>
233
+ <bool key="IBUIClipsSubviews">YES</bool>
234
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
235
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
236
+ </object>
237
+ </object>
238
+ <string key="NSFrameSize">{240, 320}</string>
239
+ <reference key="NSSuperview"/>
240
+ <reference key="NSNextKeyView" ref="76355032"/>
241
+ <string key="NSReuseIdentifierKey">_NS:9</string>
242
+ <object class="NSColor" key="IBUIBackgroundColor">
243
+ <int key="NSColorSpace">3</int>
244
+ <bytes key="NSWhite">MQA</bytes>
245
+ <reference key="NSCustomColorSpace" ref="1055564775"/>
246
+ </object>
247
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
248
+ </object>
249
+ </object>
250
+ <object class="IBObjectContainer" key="IBDocument.Objects">
251
+ <object class="NSMutableArray" key="connectionRecords">
252
+ <bool key="EncodedWithXMLCoder">YES</bool>
253
+ <object class="IBConnectionRecord">
254
+ <object class="IBCocoaTouchOutletConnection" key="connection">
255
+ <string key="label">view</string>
256
+ <reference key="source" ref="372490531"/>
257
+ <reference key="destination" ref="234977634"/>
258
+ </object>
259
+ <int key="connectionID">41</int>
260
+ </object>
261
+ <object class="IBConnectionRecord">
262
+ <object class="IBCocoaTouchOutletConnection" key="connection">
263
+ <string key="label">_scroll_view</string>
264
+ <reference key="source" ref="372490531"/>
265
+ <reference key="destination" ref="76355032"/>
266
+ </object>
267
+ <int key="connectionID">42</int>
268
+ </object>
269
+ <object class="IBConnectionRecord">
270
+ <object class="IBCocoaTouchOutletConnection" key="connection">
271
+ <string key="label">_textfield_username</string>
272
+ <reference key="source" ref="372490531"/>
273
+ <reference key="destination" ref="502350293"/>
274
+ </object>
275
+ <int key="connectionID">34</int>
276
+ </object>
277
+ <object class="IBConnectionRecord">
278
+ <object class="IBCocoaTouchOutletConnection" key="connection">
279
+ <string key="label">_textfield_password</string>
280
+ <reference key="source" ref="372490531"/>
281
+ <reference key="destination" ref="407758879"/>
282
+ </object>
283
+ <int key="connectionID">33</int>
284
+ </object>
285
+ <object class="IBConnectionRecord">
286
+ <object class="IBCocoaTouchOutletConnection" key="connection">
287
+ <string key="label">_textfield_domain</string>
288
+ <reference key="source" ref="372490531"/>
289
+ <reference key="destination" ref="316210701"/>
290
+ </object>
291
+ <int key="connectionID">32</int>
292
+ </object>
293
+ <object class="IBConnectionRecord">
294
+ <object class="IBCocoaTouchOutletConnection" key="connection">
295
+ <string key="label">_btn_cancel</string>
296
+ <reference key="source" ref="372490531"/>
297
+ <reference key="destination" ref="67582393"/>
298
+ </object>
299
+ <int key="connectionID">30</int>
300
+ </object>
301
+ <object class="IBConnectionRecord">
302
+ <object class="IBCocoaTouchOutletConnection" key="connection">
303
+ <string key="label">_btn_login</string>
304
+ <reference key="source" ref="372490531"/>
305
+ <reference key="destination" ref="266626143"/>
306
+ </object>
307
+ <int key="connectionID">31</int>
308
+ </object>
309
+ <object class="IBConnectionRecord">
310
+ <object class="IBCocoaTouchOutletConnection" key="connection">
311
+ <string key="label">_lbl_message</string>
312
+ <reference key="source" ref="372490531"/>
313
+ <reference key="destination" ref="876100682"/>
314
+ </object>
315
+ <int key="connectionID">43</int>
316
+ </object>
317
+ <object class="IBConnectionRecord">
318
+ <object class="IBCocoaTouchEventConnection" key="connection">
319
+ <string key="label">cancelPressed:</string>
320
+ <reference key="source" ref="67582393"/>
321
+ <reference key="destination" ref="372490531"/>
322
+ <int key="IBEventType">7</int>
323
+ </object>
324
+ <int key="connectionID">36</int>
325
+ </object>
326
+ <object class="IBConnectionRecord">
327
+ <object class="IBCocoaTouchEventConnection" key="connection">
328
+ <string key="label">loginPressed:</string>
329
+ <reference key="source" ref="266626143"/>
330
+ <reference key="destination" ref="372490531"/>
331
+ <int key="IBEventType">7</int>
332
+ </object>
333
+ <int key="connectionID">37</int>
334
+ </object>
335
+ </object>
336
+ <object class="IBMutableOrderedSet" key="objectRecords">
337
+ <object class="NSArray" key="orderedObjects">
338
+ <bool key="EncodedWithXMLCoder">YES</bool>
339
+ <object class="IBObjectRecord">
340
+ <int key="objectID">0</int>
341
+ <object class="NSArray" key="object" id="0">
342
+ <bool key="EncodedWithXMLCoder">YES</bool>
343
+ </object>
344
+ <reference key="children" ref="1000"/>
345
+ <nil key="parent"/>
346
+ </object>
347
+ <object class="IBObjectRecord">
348
+ <int key="objectID">-1</int>
349
+ <reference key="object" ref="372490531"/>
350
+ <reference key="parent" ref="0"/>
351
+ <string key="objectName">File's Owner</string>
352
+ </object>
353
+ <object class="IBObjectRecord">
354
+ <int key="objectID">-2</int>
355
+ <reference key="object" ref="975951072"/>
356
+ <reference key="parent" ref="0"/>
357
+ </object>
358
+ <object class="IBObjectRecord">
359
+ <int key="objectID">40</int>
360
+ <reference key="object" ref="234977634"/>
361
+ <object class="NSMutableArray" key="children">
362
+ <bool key="EncodedWithXMLCoder">YES</bool>
363
+ <reference ref="76355032"/>
364
+ </object>
365
+ <reference key="parent" ref="0"/>
366
+ </object>
367
+ <object class="IBObjectRecord">
368
+ <int key="objectID">38</int>
369
+ <reference key="object" ref="76355032"/>
370
+ <object class="NSMutableArray" key="children">
371
+ <bool key="EncodedWithXMLCoder">YES</bool>
372
+ <reference ref="876100682"/>
373
+ <reference ref="266626143"/>
374
+ <reference ref="67582393"/>
375
+ <reference ref="502350293"/>
376
+ <reference ref="316210701"/>
377
+ <reference ref="407758879"/>
378
+ </object>
379
+ <reference key="parent" ref="234977634"/>
380
+ </object>
381
+ <object class="IBObjectRecord">
382
+ <int key="objectID">3</int>
383
+ <reference key="object" ref="502350293"/>
384
+ <reference key="parent" ref="76355032"/>
385
+ </object>
386
+ <object class="IBObjectRecord">
387
+ <int key="objectID">5</int>
388
+ <reference key="object" ref="407758879"/>
389
+ <reference key="parent" ref="76355032"/>
390
+ </object>
391
+ <object class="IBObjectRecord">
392
+ <int key="objectID">7</int>
393
+ <reference key="object" ref="316210701"/>
394
+ <reference key="parent" ref="76355032"/>
395
+ </object>
396
+ <object class="IBObjectRecord">
397
+ <int key="objectID">10</int>
398
+ <reference key="object" ref="67582393"/>
399
+ <reference key="parent" ref="76355032"/>
400
+ </object>
401
+ <object class="IBObjectRecord">
402
+ <int key="objectID">20</int>
403
+ <reference key="object" ref="266626143"/>
404
+ <reference key="parent" ref="76355032"/>
405
+ </object>
406
+ <object class="IBObjectRecord">
407
+ <int key="objectID">11</int>
408
+ <reference key="object" ref="876100682"/>
409
+ <reference key="parent" ref="76355032"/>
410
+ </object>
411
+ </object>
412
+ </object>
413
+ <object class="NSMutableDictionary" key="flattenedProperties">
414
+ <bool key="EncodedWithXMLCoder">YES</bool>
415
+ <object class="NSArray" key="dict.sortedKeys">
416
+ <bool key="EncodedWithXMLCoder">YES</bool>
417
+ <string>-1.CustomClassName</string>
418
+ <string>-1.IBPluginDependency</string>
419
+ <string>-2.CustomClassName</string>
420
+ <string>-2.IBAttributePlaceholdersKey</string>
421
+ <string>-2.IBPluginDependency</string>
422
+ <string>10.IBPluginDependency</string>
423
+ <string>11.IBPluginDependency</string>
424
+ <string>20.IBPluginDependency</string>
425
+ <string>3.IBPluginDependency</string>
426
+ <string>38.IBPluginDependency</string>
427
+ <string>40.IBPluginDependency</string>
428
+ <string>5.IBPluginDependency</string>
429
+ <string>7.IBPluginDependency</string>
430
+ </object>
431
+ <object class="NSArray" key="dict.values">
432
+ <bool key="EncodedWithXMLCoder">YES</bool>
433
+ <string>CredentialsInputController</string>
434
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
435
+ <string>UIResponder</string>
436
+ <object class="NSMutableDictionary">
437
+ <bool key="EncodedWithXMLCoder">YES</bool>
438
+ <reference key="dict.sortedKeys" ref="0"/>
439
+ <reference key="dict.values" ref="0"/>
440
+ </object>
441
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
442
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
443
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
444
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
445
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
446
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
447
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
448
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
449
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
450
+ </object>
451
+ </object>
452
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
453
+ <bool key="EncodedWithXMLCoder">YES</bool>
454
+ <reference key="dict.sortedKeys" ref="0"/>
455
+ <reference key="dict.values" ref="0"/>
456
+ </object>
457
+ <nil key="activeLocalization"/>
458
+ <object class="NSMutableDictionary" key="localizations">
459
+ <bool key="EncodedWithXMLCoder">YES</bool>
460
+ <reference key="dict.sortedKeys" ref="0"/>
461
+ <reference key="dict.values" ref="0"/>
462
+ </object>
463
+ <nil key="sourceID"/>
464
+ <int key="maxID">43</int>
465
+ </object>
466
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
467
+ <int key="IBDocument.localizationMode">0</int>
468
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
469
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
470
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
471
+ <real value="1296" key="NS.object.0"/>
472
+ </object>
473
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
474
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
475
+ <integer value="3100" key="NS.object.0"/>
476
+ </object>
477
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
478
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
479
+ <string key="IBCocoaTouchPluginVersion">1179</string>
480
+ </data>
481
+ </archive>
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/EditSelectionTableViewCell.xib ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <array key="IBDocument.IntegratedClassDependencies">
14
+ <string>IBProxyObject</string>
15
+ <string>IBUILabel</string>
16
+ <string>IBUITableViewCell</string>
17
+ </array>
18
+ <array key="IBDocument.PluginDependencies">
19
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
20
+ </array>
21
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
22
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
23
+ <integer value="1" key="NS.object.0"/>
24
+ </object>
25
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
26
+ <object class="IBProxyObject" id="841351856">
27
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
28
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
29
+ </object>
30
+ <object class="IBProxyObject" id="371349661">
31
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
32
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
33
+ </object>
34
+ <object class="IBUITableViewCell" id="1049047257">
35
+ <reference key="NSNextResponder"/>
36
+ <int key="NSvFlags">292</int>
37
+ <array class="NSMutableArray" key="NSSubviews">
38
+ <object class="IBUIView" id="37971195">
39
+ <reference key="NSNextResponder" ref="1049047257"/>
40
+ <int key="NSvFlags">256</int>
41
+ <array class="NSMutableArray" key="NSSubviews">
42
+ <object class="IBUILabel" id="225091127">
43
+ <reference key="NSNextResponder" ref="37971195"/>
44
+ <int key="NSvFlags">302</int>
45
+ <string key="NSFrame">{{10, 10}, {140, 25}}</string>
46
+ <reference key="NSSuperview" ref="37971195"/>
47
+ <reference key="NSWindow"/>
48
+ <reference key="NSNextKeyView" ref="53086288"/>
49
+ <string key="NSReuseIdentifierKey">_NS:9</string>
50
+ <bool key="IBUIOpaque">NO</bool>
51
+ <bool key="IBUIClipsSubviews">YES</bool>
52
+ <int key="IBUIContentMode">7</int>
53
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
54
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
55
+ <string key="IBUIText">Label</string>
56
+ <object class="NSColor" key="IBUITextColor" id="487482859">
57
+ <int key="NSColorSpace">1</int>
58
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
59
+ </object>
60
+ <object class="NSColor" key="IBUIHighlightedColor" id="538435083">
61
+ <int key="NSColorSpace">3</int>
62
+ <bytes key="NSWhite">MQA</bytes>
63
+ </object>
64
+ <int key="IBUIBaselineAdjustment">0</int>
65
+ <float key="IBUIMinimumFontSize">10</float>
66
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
67
+ <int key="type">2</int>
68
+ <double key="pointSize">17</double>
69
+ </object>
70
+ <object class="NSFont" key="IBUIFont">
71
+ <string key="NSName">Helvetica-Bold</string>
72
+ <double key="NSSize">17</double>
73
+ <int key="NSfFlags">16</int>
74
+ </object>
75
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
76
+ </object>
77
+ <object class="IBUILabel" id="53086288">
78
+ <reference key="NSNextResponder" ref="37971195"/>
79
+ <int key="NSvFlags">299</int>
80
+ <string key="NSFrame">{{160, 10}, {120, 25}}</string>
81
+ <reference key="NSSuperview" ref="37971195"/>
82
+ <reference key="NSWindow"/>
83
+ <string key="NSReuseIdentifierKey">_NS:9</string>
84
+ <bool key="IBUIOpaque">NO</bool>
85
+ <bool key="IBUIClipsSubviews">YES</bool>
86
+ <int key="IBUIContentMode">7</int>
87
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
88
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
89
+ <string key="IBUIText">Selection</string>
90
+ <reference key="IBUITextColor" ref="487482859"/>
91
+ <reference key="IBUIHighlightedColor" ref="538435083"/>
92
+ <int key="IBUIBaselineAdjustment">0</int>
93
+ <float key="IBUIMinimumFontSize">10</float>
94
+ <int key="IBUITextAlignment">2</int>
95
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
96
+ <int key="type">1</int>
97
+ <double key="pointSize">17</double>
98
+ </object>
99
+ <object class="NSFont" key="IBUIFont">
100
+ <string key="NSName">Helvetica</string>
101
+ <double key="NSSize">17</double>
102
+ <int key="NSfFlags">16</int>
103
+ </object>
104
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
105
+ </object>
106
+ </array>
107
+ <string key="NSFrameSize">{300, 43}</string>
108
+ <reference key="NSSuperview" ref="1049047257"/>
109
+ <reference key="NSWindow"/>
110
+ <reference key="NSNextKeyView" ref="225091127"/>
111
+ <string key="NSReuseIdentifierKey">_NS:11</string>
112
+ <object class="NSColor" key="IBUIBackgroundColor">
113
+ <int key="NSColorSpace">3</int>
114
+ <bytes key="NSWhite">MCAwAA</bytes>
115
+ </object>
116
+ <bool key="IBUIOpaque">NO</bool>
117
+ <bool key="IBUIClipsSubviews">YES</bool>
118
+ <int key="IBUIContentMode">4</int>
119
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
120
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
121
+ </object>
122
+ </array>
123
+ <string key="NSFrameSize">{320, 44}</string>
124
+ <reference key="NSSuperview"/>
125
+ <reference key="NSWindow"/>
126
+ <reference key="NSNextKeyView" ref="37971195"/>
127
+ <string key="NSReuseIdentifierKey">_NS:9</string>
128
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
129
+ <int key="IBUIAccessoryType">1</int>
130
+ <reference key="IBUIContentView" ref="37971195"/>
131
+ </object>
132
+ </array>
133
+ <object class="IBObjectContainer" key="IBDocument.Objects">
134
+ <array class="NSMutableArray" key="connectionRecords">
135
+ <object class="IBConnectionRecord">
136
+ <object class="IBCocoaTouchOutletConnection" key="connection">
137
+ <string key="label">_selectionTableViewCell</string>
138
+ <reference key="source" ref="841351856"/>
139
+ <reference key="destination" ref="1049047257"/>
140
+ </object>
141
+ <int key="connectionID">9</int>
142
+ </object>
143
+ <object class="IBConnectionRecord">
144
+ <object class="IBCocoaTouchOutletConnection" key="connection">
145
+ <string key="label">_label</string>
146
+ <reference key="source" ref="1049047257"/>
147
+ <reference key="destination" ref="225091127"/>
148
+ </object>
149
+ <int key="connectionID">7</int>
150
+ </object>
151
+ <object class="IBConnectionRecord">
152
+ <object class="IBCocoaTouchOutletConnection" key="connection">
153
+ <string key="label">_selection</string>
154
+ <reference key="source" ref="1049047257"/>
155
+ <reference key="destination" ref="53086288"/>
156
+ </object>
157
+ <int key="connectionID">8</int>
158
+ </object>
159
+ </array>
160
+ <object class="IBMutableOrderedSet" key="objectRecords">
161
+ <array key="orderedObjects">
162
+ <object class="IBObjectRecord">
163
+ <int key="objectID">0</int>
164
+ <array key="object" id="0"/>
165
+ <reference key="children" ref="1000"/>
166
+ <nil key="parent"/>
167
+ </object>
168
+ <object class="IBObjectRecord">
169
+ <int key="objectID">-1</int>
170
+ <reference key="object" ref="841351856"/>
171
+ <reference key="parent" ref="0"/>
172
+ <string key="objectName">File's Owner</string>
173
+ </object>
174
+ <object class="IBObjectRecord">
175
+ <int key="objectID">-2</int>
176
+ <reference key="object" ref="371349661"/>
177
+ <reference key="parent" ref="0"/>
178
+ </object>
179
+ <object class="IBObjectRecord">
180
+ <int key="objectID">2</int>
181
+ <reference key="object" ref="1049047257"/>
182
+ <array class="NSMutableArray" key="children">
183
+ <reference ref="225091127"/>
184
+ <reference ref="53086288"/>
185
+ </array>
186
+ <reference key="parent" ref="0"/>
187
+ </object>
188
+ <object class="IBObjectRecord">
189
+ <int key="objectID">5</int>
190
+ <reference key="object" ref="225091127"/>
191
+ <reference key="parent" ref="1049047257"/>
192
+ </object>
193
+ <object class="IBObjectRecord">
194
+ <int key="objectID">6</int>
195
+ <reference key="object" ref="53086288"/>
196
+ <reference key="parent" ref="1049047257"/>
197
+ </object>
198
+ </array>
199
+ </object>
200
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
201
+ <string key="-1.CustomClassName">EditorBaseController</string>
202
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
203
+ <string key="-2.CustomClassName">UIResponder</string>
204
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
205
+ <string key="2.CustomClassName">EditSelectionTableViewCell</string>
206
+ <string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
207
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
208
+ <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
209
+ </dictionary>
210
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
211
+ <nil key="activeLocalization"/>
212
+ <dictionary class="NSMutableDictionary" key="localizations"/>
213
+ <nil key="sourceID"/>
214
+ <int key="maxID">9</int>
215
+ </object>
216
+ <object class="IBClassDescriber" key="IBDocument.Classes">
217
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
218
+ <object class="IBPartialClassDescription">
219
+ <string key="className">EditFlagTableViewCell</string>
220
+ <string key="superclassName">UITableViewCell</string>
221
+ <dictionary class="NSMutableDictionary" key="outlets">
222
+ <string key="_label">UILabel</string>
223
+ <string key="_toggle">UISwitch</string>
224
+ </dictionary>
225
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
226
+ <object class="IBToOneOutletInfo" key="_label">
227
+ <string key="name">_label</string>
228
+ <string key="candidateClassName">UILabel</string>
229
+ </object>
230
+ <object class="IBToOneOutletInfo" key="_toggle">
231
+ <string key="name">_toggle</string>
232
+ <string key="candidateClassName">UISwitch</string>
233
+ </object>
234
+ </dictionary>
235
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
236
+ <string key="majorKey">IBProjectSource</string>
237
+ <string key="minorKey">./Classes/EditFlagTableViewCell.h</string>
238
+ </object>
239
+ </object>
240
+ <object class="IBPartialClassDescription">
241
+ <string key="className">EditSelectionTableViewCell</string>
242
+ <string key="superclassName">UITableViewCell</string>
243
+ <dictionary class="NSMutableDictionary" key="outlets">
244
+ <string key="_label">UILabel</string>
245
+ <string key="_selection">UILabel</string>
246
+ </dictionary>
247
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
248
+ <object class="IBToOneOutletInfo" key="_label">
249
+ <string key="name">_label</string>
250
+ <string key="candidateClassName">UILabel</string>
251
+ </object>
252
+ <object class="IBToOneOutletInfo" key="_selection">
253
+ <string key="name">_selection</string>
254
+ <string key="candidateClassName">UILabel</string>
255
+ </object>
256
+ </dictionary>
257
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
258
+ <string key="majorKey">IBProjectSource</string>
259
+ <string key="minorKey">./Classes/EditSelectionTableViewCell.h</string>
260
+ </object>
261
+ </object>
262
+ <object class="IBPartialClassDescription">
263
+ <string key="className">EditSubEditTableViewCell</string>
264
+ <string key="superclassName">UITableViewCell</string>
265
+ <object class="NSMutableDictionary" key="outlets">
266
+ <string key="NS.key.0">_label</string>
267
+ <string key="NS.object.0">UILabel</string>
268
+ </object>
269
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
270
+ <string key="NS.key.0">_label</string>
271
+ <object class="IBToOneOutletInfo" key="NS.object.0">
272
+ <string key="name">_label</string>
273
+ <string key="candidateClassName">UILabel</string>
274
+ </object>
275
+ </object>
276
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
277
+ <string key="majorKey">IBProjectSource</string>
278
+ <string key="minorKey">./Classes/EditSubEditTableViewCell.h</string>
279
+ </object>
280
+ </object>
281
+ <object class="IBPartialClassDescription">
282
+ <string key="className">EditTextTableViewCell</string>
283
+ <string key="superclassName">UITableViewCell</string>
284
+ <dictionary class="NSMutableDictionary" key="outlets">
285
+ <string key="_label">UILabel</string>
286
+ <string key="_textfield">UITextField</string>
287
+ </dictionary>
288
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
289
+ <object class="IBToOneOutletInfo" key="_label">
290
+ <string key="name">_label</string>
291
+ <string key="candidateClassName">UILabel</string>
292
+ </object>
293
+ <object class="IBToOneOutletInfo" key="_textfield">
294
+ <string key="name">_textfield</string>
295
+ <string key="candidateClassName">UITextField</string>
296
+ </object>
297
+ </dictionary>
298
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
299
+ <string key="majorKey">IBProjectSource</string>
300
+ <string key="minorKey">./Classes/EditTextTableViewCell.h</string>
301
+ </object>
302
+ </object>
303
+ <object class="IBPartialClassDescription">
304
+ <string key="className">EditorBaseController</string>
305
+ <string key="superclassName">UITableViewController</string>
306
+ <dictionary class="NSMutableDictionary" key="outlets">
307
+ <string key="_flagTableViewCell">EditFlagTableViewCell</string>
308
+ <string key="_selectionTableViewCell">EditSelectionTableViewCell</string>
309
+ <string key="_subEditTableViewCell">EditSubEditTableViewCell</string>
310
+ <string key="_textTableViewCell">EditTextTableViewCell</string>
311
+ </dictionary>
312
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
313
+ <object class="IBToOneOutletInfo" key="_flagTableViewCell">
314
+ <string key="name">_flagTableViewCell</string>
315
+ <string key="candidateClassName">EditFlagTableViewCell</string>
316
+ </object>
317
+ <object class="IBToOneOutletInfo" key="_selectionTableViewCell">
318
+ <string key="name">_selectionTableViewCell</string>
319
+ <string key="candidateClassName">EditSelectionTableViewCell</string>
320
+ </object>
321
+ <object class="IBToOneOutletInfo" key="_subEditTableViewCell">
322
+ <string key="name">_subEditTableViewCell</string>
323
+ <string key="candidateClassName">EditSubEditTableViewCell</string>
324
+ </object>
325
+ <object class="IBToOneOutletInfo" key="_textTableViewCell">
326
+ <string key="name">_textTableViewCell</string>
327
+ <string key="candidateClassName">EditTextTableViewCell</string>
328
+ </object>
329
+ </dictionary>
330
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
331
+ <string key="majorKey">IBProjectSource</string>
332
+ <string key="minorKey">./Classes/EditorBaseController.h</string>
333
+ </object>
334
+ </object>
335
+ </array>
336
+ </object>
337
+ <int key="IBDocument.localizationMode">0</int>
338
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
339
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
340
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
341
+ <real value="1296" key="NS.object.0"/>
342
+ </object>
343
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
344
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
345
+ <string key="IBCocoaTouchPluginVersion">1179</string>
346
+ </data>
347
+ </archive>
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/EditTextTableViewCell.xib ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <array key="IBDocument.IntegratedClassDependencies">
14
+ <string>IBUITableViewCell</string>
15
+ <string>IBUILabel</string>
16
+ <string>IBUITextField</string>
17
+ <string>IBProxyObject</string>
18
+ </array>
19
+ <array key="IBDocument.PluginDependencies">
20
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
21
+ </array>
22
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
23
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
24
+ <integer value="1" key="NS.object.0"/>
25
+ </object>
26
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
27
+ <object class="IBProxyObject" id="841351856">
28
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
29
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
30
+ </object>
31
+ <object class="IBProxyObject" id="371349661">
32
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
33
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
34
+ </object>
35
+ <object class="IBUITableViewCell" id="873867585">
36
+ <reference key="NSNextResponder"/>
37
+ <int key="NSvFlags">292</int>
38
+ <array class="NSMutableArray" key="NSSubviews">
39
+ <object class="IBUIView" id="571279607">
40
+ <reference key="NSNextResponder" ref="873867585"/>
41
+ <int key="NSvFlags">256</int>
42
+ <array class="NSMutableArray" key="NSSubviews">
43
+ <object class="IBUILabel" id="837238439">
44
+ <reference key="NSNextResponder" ref="571279607"/>
45
+ <int key="NSvFlags">300</int>
46
+ <string key="NSFrame">{{10, 10}, {100, 25}}</string>
47
+ <reference key="NSSuperview" ref="571279607"/>
48
+ <reference key="NSWindow"/>
49
+ <reference key="NSNextKeyView" ref="915318991"/>
50
+ <string key="NSReuseIdentifierKey">_NS:9</string>
51
+ <bool key="IBUIOpaque">NO</bool>
52
+ <bool key="IBUIClipsSubviews">YES</bool>
53
+ <int key="IBUIContentMode">7</int>
54
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
55
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
56
+ <string key="IBUIText">Label</string>
57
+ <object class="NSColor" key="IBUITextColor">
58
+ <int key="NSColorSpace">1</int>
59
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
60
+ </object>
61
+ <object class="NSColor" key="IBUIHighlightedColor">
62
+ <int key="NSColorSpace">3</int>
63
+ <bytes key="NSWhite">MQA</bytes>
64
+ </object>
65
+ <int key="IBUIBaselineAdjustment">0</int>
66
+ <float key="IBUIMinimumFontSize">10</float>
67
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
68
+ <int key="type">2</int>
69
+ <double key="pointSize">17</double>
70
+ </object>
71
+ <object class="NSFont" key="IBUIFont">
72
+ <string key="NSName">Helvetica-Bold</string>
73
+ <double key="NSSize">17</double>
74
+ <int key="NSfFlags">16</int>
75
+ </object>
76
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
77
+ </object>
78
+ <object class="IBUITextField" id="915318991">
79
+ <reference key="NSNextResponder" ref="571279607"/>
80
+ <int key="NSvFlags">298</int>
81
+ <string key="NSFrame">{{120, 10}, {200, 25}}</string>
82
+ <reference key="NSSuperview" ref="571279607"/>
83
+ <reference key="NSWindow"/>
84
+ <reference key="NSNextKeyView"/>
85
+ <string key="NSReuseIdentifierKey">_NS:9</string>
86
+ <bool key="IBUIOpaque">NO</bool>
87
+ <bool key="IBUIClipsSubviews">YES</bool>
88
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
89
+ <int key="IBUIContentVerticalAlignment">0</int>
90
+ <string key="IBUIText">Test</string>
91
+ <object class="NSColor" key="IBUITextColor">
92
+ <int key="NSColorSpace">3</int>
93
+ <bytes key="NSWhite">MAA</bytes>
94
+ <object class="NSColorSpace" key="NSCustomColorSpace">
95
+ <int key="NSID">2</int>
96
+ </object>
97
+ </object>
98
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
99
+ <float key="IBUIMinimumFontSize">17</float>
100
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
101
+ <int key="IBUIAutocorrectionType">1</int>
102
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
103
+ </object>
104
+ <int key="IBUIClearButtonMode">3</int>
105
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
106
+ <int key="type">1</int>
107
+ <double key="pointSize">17</double>
108
+ </object>
109
+ <object class="NSFont" key="IBUIFont">
110
+ <string key="NSName">Helvetica</string>
111
+ <double key="NSSize">17</double>
112
+ <int key="NSfFlags">16</int>
113
+ </object>
114
+ </object>
115
+ </array>
116
+ <string key="NSFrameSize">{320, 43}</string>
117
+ <reference key="NSSuperview" ref="873867585"/>
118
+ <reference key="NSWindow"/>
119
+ <reference key="NSNextKeyView" ref="837238439"/>
120
+ <string key="NSReuseIdentifierKey">_NS:11</string>
121
+ <object class="NSColor" key="IBUIBackgroundColor">
122
+ <int key="NSColorSpace">3</int>
123
+ <bytes key="NSWhite">MCAwAA</bytes>
124
+ </object>
125
+ <bool key="IBUIOpaque">NO</bool>
126
+ <bool key="IBUIClipsSubviews">YES</bool>
127
+ <int key="IBUIContentMode">4</int>
128
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
129
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
130
+ </object>
131
+ </array>
132
+ <string key="NSFrameSize">{320, 44}</string>
133
+ <reference key="NSSuperview"/>
134
+ <reference key="NSWindow"/>
135
+ <reference key="NSNextKeyView" ref="571279607"/>
136
+ <string key="NSReuseIdentifierKey">_NS:9</string>
137
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
138
+ <int key="IBUISelectionStyle">0</int>
139
+ <reference key="IBUIContentView" ref="571279607"/>
140
+ </object>
141
+ </array>
142
+ <object class="IBObjectContainer" key="IBDocument.Objects">
143
+ <array class="NSMutableArray" key="connectionRecords">
144
+ <object class="IBConnectionRecord">
145
+ <object class="IBCocoaTouchOutletConnection" key="connection">
146
+ <string key="label">_textTableViewCell</string>
147
+ <reference key="source" ref="841351856"/>
148
+ <reference key="destination" ref="873867585"/>
149
+ </object>
150
+ <int key="connectionID">7</int>
151
+ </object>
152
+ <object class="IBConnectionRecord">
153
+ <object class="IBCocoaTouchOutletConnection" key="connection">
154
+ <string key="label">_label</string>
155
+ <reference key="source" ref="873867585"/>
156
+ <reference key="destination" ref="837238439"/>
157
+ </object>
158
+ <int key="connectionID">5</int>
159
+ </object>
160
+ <object class="IBConnectionRecord">
161
+ <object class="IBCocoaTouchOutletConnection" key="connection">
162
+ <string key="label">_textfield</string>
163
+ <reference key="source" ref="873867585"/>
164
+ <reference key="destination" ref="915318991"/>
165
+ </object>
166
+ <int key="connectionID">6</int>
167
+ </object>
168
+ <object class="IBConnectionRecord">
169
+ <object class="IBCocoaTouchOutletConnection" key="connection">
170
+ <string key="label">delegate</string>
171
+ <reference key="source" ref="915318991"/>
172
+ <reference key="destination" ref="841351856"/>
173
+ </object>
174
+ <int key="connectionID">8</int>
175
+ </object>
176
+ </array>
177
+ <object class="IBMutableOrderedSet" key="objectRecords">
178
+ <array key="orderedObjects">
179
+ <object class="IBObjectRecord">
180
+ <int key="objectID">0</int>
181
+ <array key="object" id="0"/>
182
+ <reference key="children" ref="1000"/>
183
+ <nil key="parent"/>
184
+ </object>
185
+ <object class="IBObjectRecord">
186
+ <int key="objectID">-1</int>
187
+ <reference key="object" ref="841351856"/>
188
+ <reference key="parent" ref="0"/>
189
+ <string key="objectName">File's Owner</string>
190
+ </object>
191
+ <object class="IBObjectRecord">
192
+ <int key="objectID">-2</int>
193
+ <reference key="object" ref="371349661"/>
194
+ <reference key="parent" ref="0"/>
195
+ </object>
196
+ <object class="IBObjectRecord">
197
+ <int key="objectID">2</int>
198
+ <reference key="object" ref="873867585"/>
199
+ <array class="NSMutableArray" key="children">
200
+ <reference ref="837238439"/>
201
+ <reference ref="915318991"/>
202
+ </array>
203
+ <reference key="parent" ref="0"/>
204
+ </object>
205
+ <object class="IBObjectRecord">
206
+ <int key="objectID">3</int>
207
+ <reference key="object" ref="837238439"/>
208
+ <reference key="parent" ref="873867585"/>
209
+ </object>
210
+ <object class="IBObjectRecord">
211
+ <int key="objectID">4</int>
212
+ <reference key="object" ref="915318991"/>
213
+ <reference key="parent" ref="873867585"/>
214
+ </object>
215
+ </array>
216
+ </object>
217
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
218
+ <string key="-1.CustomClassName">EditorBaseController</string>
219
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
220
+ <string key="-2.CustomClassName">UIResponder</string>
221
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
222
+ <string key="2.CustomClassName">EditTextTableViewCell</string>
223
+ <string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
224
+ <string key="3.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
225
+ <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
226
+ </dictionary>
227
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
228
+ <nil key="activeLocalization"/>
229
+ <dictionary class="NSMutableDictionary" key="localizations"/>
230
+ <nil key="sourceID"/>
231
+ <int key="maxID">8</int>
232
+ </object>
233
+ <object class="IBClassDescriber" key="IBDocument.Classes">
234
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
235
+ <object class="IBPartialClassDescription">
236
+ <string key="className">EditFlagTableViewCell</string>
237
+ <string key="superclassName">UITableViewCell</string>
238
+ <dictionary class="NSMutableDictionary" key="outlets">
239
+ <string key="_label">UILabel</string>
240
+ <string key="_toggle">UISwitch</string>
241
+ </dictionary>
242
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
243
+ <object class="IBToOneOutletInfo" key="_label">
244
+ <string key="name">_label</string>
245
+ <string key="candidateClassName">UILabel</string>
246
+ </object>
247
+ <object class="IBToOneOutletInfo" key="_toggle">
248
+ <string key="name">_toggle</string>
249
+ <string key="candidateClassName">UISwitch</string>
250
+ </object>
251
+ </dictionary>
252
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
253
+ <string key="majorKey">IBProjectSource</string>
254
+ <string key="minorKey">./Classes/EditFlagTableViewCell.h</string>
255
+ </object>
256
+ </object>
257
+ <object class="IBPartialClassDescription">
258
+ <string key="className">EditSelectionTableViewCell</string>
259
+ <string key="superclassName">UITableViewCell</string>
260
+ <dictionary class="NSMutableDictionary" key="outlets">
261
+ <string key="_label">UILabel</string>
262
+ <string key="_selection">UILabel</string>
263
+ </dictionary>
264
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
265
+ <object class="IBToOneOutletInfo" key="_label">
266
+ <string key="name">_label</string>
267
+ <string key="candidateClassName">UILabel</string>
268
+ </object>
269
+ <object class="IBToOneOutletInfo" key="_selection">
270
+ <string key="name">_selection</string>
271
+ <string key="candidateClassName">UILabel</string>
272
+ </object>
273
+ </dictionary>
274
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
275
+ <string key="majorKey">IBProjectSource</string>
276
+ <string key="minorKey">./Classes/EditSelectionTableViewCell.h</string>
277
+ </object>
278
+ </object>
279
+ <object class="IBPartialClassDescription">
280
+ <string key="className">EditSubEditTableViewCell</string>
281
+ <string key="superclassName">UITableViewCell</string>
282
+ <object class="NSMutableDictionary" key="outlets">
283
+ <string key="NS.key.0">_label</string>
284
+ <string key="NS.object.0">UILabel</string>
285
+ </object>
286
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
287
+ <string key="NS.key.0">_label</string>
288
+ <object class="IBToOneOutletInfo" key="NS.object.0">
289
+ <string key="name">_label</string>
290
+ <string key="candidateClassName">UILabel</string>
291
+ </object>
292
+ </object>
293
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
294
+ <string key="majorKey">IBProjectSource</string>
295
+ <string key="minorKey">./Classes/EditSubEditTableViewCell.h</string>
296
+ </object>
297
+ </object>
298
+ <object class="IBPartialClassDescription">
299
+ <string key="className">EditTextTableViewCell</string>
300
+ <string key="superclassName">UITableViewCell</string>
301
+ <dictionary class="NSMutableDictionary" key="outlets">
302
+ <string key="_label">UILabel</string>
303
+ <string key="_textfield">UITextField</string>
304
+ </dictionary>
305
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
306
+ <object class="IBToOneOutletInfo" key="_label">
307
+ <string key="name">_label</string>
308
+ <string key="candidateClassName">UILabel</string>
309
+ </object>
310
+ <object class="IBToOneOutletInfo" key="_textfield">
311
+ <string key="name">_textfield</string>
312
+ <string key="candidateClassName">UITextField</string>
313
+ </object>
314
+ </dictionary>
315
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
316
+ <string key="majorKey">IBProjectSource</string>
317
+ <string key="minorKey">./Classes/EditTextTableViewCell.h</string>
318
+ </object>
319
+ </object>
320
+ <object class="IBPartialClassDescription">
321
+ <string key="className">EditorBaseController</string>
322
+ <string key="superclassName">UITableViewController</string>
323
+ <dictionary class="NSMutableDictionary" key="outlets">
324
+ <string key="_flagTableViewCell">EditFlagTableViewCell</string>
325
+ <string key="_selectionTableViewCell">EditSelectionTableViewCell</string>
326
+ <string key="_subEditTableViewCell">EditSubEditTableViewCell</string>
327
+ <string key="_textTableViewCell">EditTextTableViewCell</string>
328
+ </dictionary>
329
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
330
+ <object class="IBToOneOutletInfo" key="_flagTableViewCell">
331
+ <string key="name">_flagTableViewCell</string>
332
+ <string key="candidateClassName">EditFlagTableViewCell</string>
333
+ </object>
334
+ <object class="IBToOneOutletInfo" key="_selectionTableViewCell">
335
+ <string key="name">_selectionTableViewCell</string>
336
+ <string key="candidateClassName">EditSelectionTableViewCell</string>
337
+ </object>
338
+ <object class="IBToOneOutletInfo" key="_subEditTableViewCell">
339
+ <string key="name">_subEditTableViewCell</string>
340
+ <string key="candidateClassName">EditSubEditTableViewCell</string>
341
+ </object>
342
+ <object class="IBToOneOutletInfo" key="_textTableViewCell">
343
+ <string key="name">_textTableViewCell</string>
344
+ <string key="candidateClassName">EditTextTableViewCell</string>
345
+ </object>
346
+ </dictionary>
347
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
348
+ <string key="majorKey">IBProjectSource</string>
349
+ <string key="minorKey">./Classes/EditorBaseController.h</string>
350
+ </object>
351
+ </object>
352
+ </array>
353
+ </object>
354
+ <int key="IBDocument.localizationMode">0</int>
355
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
356
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
357
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
358
+ <real value="1296" key="NS.object.0"/>
359
+ </object>
360
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
361
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
362
+ <string key="IBCocoaTouchPluginVersion">1179</string>
363
+ </data>
364
+ </archive>
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/RDPConnectingView.xib ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <array key="IBDocument.IntegratedClassDependencies">
14
+ <string>IBUIButton</string>
15
+ <string>IBUIActivityIndicatorView</string>
16
+ <string>IBUIView</string>
17
+ <string>IBUILabel</string>
18
+ <string>IBProxyObject</string>
19
+ </array>
20
+ <array key="IBDocument.PluginDependencies">
21
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
22
+ </array>
23
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
24
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
25
+ <integer value="1" key="NS.object.0"/>
26
+ </object>
27
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
28
+ <object class="IBProxyObject" id="372490531">
29
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
30
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
31
+ </object>
32
+ <object class="IBProxyObject" id="975951072">
33
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
34
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
35
+ </object>
36
+ <object class="IBUIView" id="191373211">
37
+ <reference key="NSNextResponder"/>
38
+ <int key="NSvFlags">301</int>
39
+ <array class="NSMutableArray" key="NSSubviews">
40
+ <object class="IBUIButton" id="971255490">
41
+ <reference key="NSNextResponder" ref="191373211"/>
42
+ <int key="NSvFlags">292</int>
43
+ <string key="NSFrame">{{45, 143}, {109, 37}}</string>
44
+ <reference key="NSSuperview" ref="191373211"/>
45
+ <reference key="NSWindow"/>
46
+ <string key="NSReuseIdentifierKey">_NS:9</string>
47
+ <bool key="IBUIOpaque">NO</bool>
48
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
49
+ <int key="IBUIContentHorizontalAlignment">0</int>
50
+ <int key="IBUIContentVerticalAlignment">0</int>
51
+ <int key="IBUIButtonType">1</int>
52
+ <string key="IBUINormalTitle">Cancel</string>
53
+ <object class="NSColor" key="IBUIHighlightedTitleColor" id="107901828">
54
+ <int key="NSColorSpace">3</int>
55
+ <bytes key="NSWhite">MQA</bytes>
56
+ </object>
57
+ <reference key="IBUINormalTitleColor" ref="107901828"/>
58
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
59
+ <int key="NSColorSpace">3</int>
60
+ <bytes key="NSWhite">MC41AA</bytes>
61
+ </object>
62
+ <object class="NSCustomResource" key="IBUINormalBackgroundImage">
63
+ <string key="NSClassName">NSImage</string>
64
+ <string key="NSResourceName">cancel_button_background.png</string>
65
+ </object>
66
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
67
+ <int key="type">2</int>
68
+ <double key="pointSize">15</double>
69
+ </object>
70
+ <object class="NSFont" key="IBUIFont">
71
+ <string key="NSName">Helvetica-Bold</string>
72
+ <double key="NSSize">15</double>
73
+ <int key="NSfFlags">16</int>
74
+ </object>
75
+ </object>
76
+ <object class="IBUIActivityIndicatorView" id="236881211">
77
+ <reference key="NSNextResponder" ref="191373211"/>
78
+ <int key="NSvFlags">301</int>
79
+ <string key="NSFrame">{{82, 81}, {37, 37}}</string>
80
+ <reference key="NSSuperview" ref="191373211"/>
81
+ <reference key="NSWindow"/>
82
+ <reference key="NSNextKeyView" ref="971255490"/>
83
+ <string key="NSReuseIdentifierKey">_NS:9</string>
84
+ <bool key="IBUIOpaque">NO</bool>
85
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
86
+ <bool key="IBUIHidesWhenStopped">NO</bool>
87
+ <int key="IBUIStyle">0</int>
88
+ </object>
89
+ <object class="IBUILabel" id="933286658">
90
+ <reference key="NSNextResponder" ref="191373211"/>
91
+ <int key="NSvFlags">292</int>
92
+ <string key="NSFrame">{{18, 20}, {165, 25}}</string>
93
+ <reference key="NSSuperview" ref="191373211"/>
94
+ <reference key="NSWindow"/>
95
+ <reference key="NSNextKeyView" ref="236881211"/>
96
+ <string key="NSReuseIdentifierKey">_NS:9</string>
97
+ <bool key="IBUIOpaque">NO</bool>
98
+ <bool key="IBUIClipsSubviews">YES</bool>
99
+ <int key="IBUIContentMode">7</int>
100
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
101
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
102
+ <string key="IBUIText">Connecting</string>
103
+ <reference key="IBUITextColor" ref="107901828"/>
104
+ <nil key="IBUIHighlightedColor"/>
105
+ <int key="IBUIBaselineAdjustment">0</int>
106
+ <float key="IBUIMinimumFontSize">10</float>
107
+ <int key="IBUITextAlignment">1</int>
108
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
109
+ <int key="type">2</int>
110
+ <double key="pointSize">17</double>
111
+ </object>
112
+ <object class="NSFont" key="IBUIFont">
113
+ <string key="NSName">Helvetica-Bold</string>
114
+ <double key="NSSize">17</double>
115
+ <int key="NSfFlags">16</int>
116
+ </object>
117
+ </object>
118
+ </array>
119
+ <string key="NSFrameSize">{200, 200}</string>
120
+ <reference key="NSSuperview"/>
121
+ <reference key="NSWindow"/>
122
+ <reference key="NSNextKeyView" ref="933286658"/>
123
+ <object class="NSColor" key="IBUIBackgroundColor">
124
+ <int key="NSColorSpace">3</int>
125
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
126
+ </object>
127
+ <object class="IBUISimulatedSizeMetrics" key="IBUISimulatedDestinationMetrics">
128
+ <string key="IBUISimulatedSizeMetricsClass">IBUISimulatedFreeformSizeMetricsSentinel</string>
129
+ <string key="IBUIDisplayName">Freeform</string>
130
+ </object>
131
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
132
+ </object>
133
+ </array>
134
+ <object class="IBObjectContainer" key="IBDocument.Objects">
135
+ <array class="NSMutableArray" key="connectionRecords">
136
+ <object class="IBConnectionRecord">
137
+ <object class="IBCocoaTouchOutletConnection" key="connection">
138
+ <string key="label">_connecting_view</string>
139
+ <reference key="source" ref="372490531"/>
140
+ <reference key="destination" ref="191373211"/>
141
+ </object>
142
+ <int key="connectionID">6</int>
143
+ </object>
144
+ <object class="IBConnectionRecord">
145
+ <object class="IBCocoaTouchOutletConnection" key="connection">
146
+ <string key="label">_cancel_connect_button</string>
147
+ <reference key="source" ref="372490531"/>
148
+ <reference key="destination" ref="971255490"/>
149
+ </object>
150
+ <int key="connectionID">7</int>
151
+ </object>
152
+ <object class="IBConnectionRecord">
153
+ <object class="IBCocoaTouchOutletConnection" key="connection">
154
+ <string key="label">_connecting_indicator_view</string>
155
+ <reference key="source" ref="372490531"/>
156
+ <reference key="destination" ref="236881211"/>
157
+ </object>
158
+ <int key="connectionID">8</int>
159
+ </object>
160
+ <object class="IBConnectionRecord">
161
+ <object class="IBCocoaTouchOutletConnection" key="connection">
162
+ <string key="label">_lbl_connecting</string>
163
+ <reference key="source" ref="372490531"/>
164
+ <reference key="destination" ref="933286658"/>
165
+ </object>
166
+ <int key="connectionID">10</int>
167
+ </object>
168
+ <object class="IBConnectionRecord">
169
+ <object class="IBCocoaTouchEventConnection" key="connection">
170
+ <string key="label">cancelButtonPressed:</string>
171
+ <reference key="source" ref="971255490"/>
172
+ <reference key="destination" ref="372490531"/>
173
+ <int key="IBEventType">7</int>
174
+ </object>
175
+ <int key="connectionID">9</int>
176
+ </object>
177
+ </array>
178
+ <object class="IBMutableOrderedSet" key="objectRecords">
179
+ <array key="orderedObjects">
180
+ <object class="IBObjectRecord">
181
+ <int key="objectID">0</int>
182
+ <array key="object" id="0"/>
183
+ <reference key="children" ref="1000"/>
184
+ <nil key="parent"/>
185
+ </object>
186
+ <object class="IBObjectRecord">
187
+ <int key="objectID">1</int>
188
+ <reference key="object" ref="191373211"/>
189
+ <array class="NSMutableArray" key="children">
190
+ <reference ref="971255490"/>
191
+ <reference ref="236881211"/>
192
+ <reference ref="933286658"/>
193
+ </array>
194
+ <reference key="parent" ref="0"/>
195
+ </object>
196
+ <object class="IBObjectRecord">
197
+ <int key="objectID">-1</int>
198
+ <reference key="object" ref="372490531"/>
199
+ <reference key="parent" ref="0"/>
200
+ <string key="objectName">File's Owner</string>
201
+ </object>
202
+ <object class="IBObjectRecord">
203
+ <int key="objectID">-2</int>
204
+ <reference key="object" ref="975951072"/>
205
+ <reference key="parent" ref="0"/>
206
+ </object>
207
+ <object class="IBObjectRecord">
208
+ <int key="objectID">3</int>
209
+ <reference key="object" ref="971255490"/>
210
+ <reference key="parent" ref="191373211"/>
211
+ </object>
212
+ <object class="IBObjectRecord">
213
+ <int key="objectID">4</int>
214
+ <reference key="object" ref="236881211"/>
215
+ <reference key="parent" ref="191373211"/>
216
+ </object>
217
+ <object class="IBObjectRecord">
218
+ <int key="objectID">5</int>
219
+ <reference key="object" ref="933286658"/>
220
+ <reference key="parent" ref="191373211"/>
221
+ </object>
222
+ </array>
223
+ </object>
224
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
225
+ <string key="-1.CustomClassName">RDPSessionViewController</string>
226
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
227
+ <string key="-2.CustomClassName">UIResponder</string>
228
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
229
+ <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
230
+ <string key="3.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
231
+ <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
232
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
233
+ </dictionary>
234
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
235
+ <nil key="activeLocalization"/>
236
+ <dictionary class="NSMutableDictionary" key="localizations"/>
237
+ <nil key="sourceID"/>
238
+ <int key="maxID">10</int>
239
+ </object>
240
+ <object class="IBClassDescriber" key="IBDocument.Classes">
241
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
242
+ <object class="IBPartialClassDescription">
243
+ <string key="className">RDPSessionView</string>
244
+ <string key="superclassName">UIView</string>
245
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
246
+ <string key="majorKey">IBProjectSource</string>
247
+ <string key="minorKey">./Classes/RDPSessionView.h</string>
248
+ </object>
249
+ </object>
250
+ <object class="IBPartialClassDescription">
251
+ <string key="className">RDPSessionViewController</string>
252
+ <string key="superclassName">UIViewController</string>
253
+ <dictionary class="NSMutableDictionary" key="outlets">
254
+ <string key="_cancel_connect_button">UIButton</string>
255
+ <string key="_connecting_indicator_view">UIActivityIndicatorView</string>
256
+ <string key="_connecting_view">UIView</string>
257
+ <string key="_dummy_textfield">UITextField</string>
258
+ <string key="_lbl_connecting">UILabel</string>
259
+ <string key="_session_scrollview">UIScrollView</string>
260
+ <string key="_session_toolbar">UIToolbar</string>
261
+ <string key="_session_view">RDPSessionView</string>
262
+ <string key="_touchpointer_view">TouchPointerView</string>
263
+ </dictionary>
264
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
265
+ <object class="IBToOneOutletInfo" key="_cancel_connect_button">
266
+ <string key="name">_cancel_connect_button</string>
267
+ <string key="candidateClassName">UIButton</string>
268
+ </object>
269
+ <object class="IBToOneOutletInfo" key="_connecting_indicator_view">
270
+ <string key="name">_connecting_indicator_view</string>
271
+ <string key="candidateClassName">UIActivityIndicatorView</string>
272
+ </object>
273
+ <object class="IBToOneOutletInfo" key="_connecting_view">
274
+ <string key="name">_connecting_view</string>
275
+ <string key="candidateClassName">UIView</string>
276
+ </object>
277
+ <object class="IBToOneOutletInfo" key="_dummy_textfield">
278
+ <string key="name">_dummy_textfield</string>
279
+ <string key="candidateClassName">UITextField</string>
280
+ </object>
281
+ <object class="IBToOneOutletInfo" key="_lbl_connecting">
282
+ <string key="name">_lbl_connecting</string>
283
+ <string key="candidateClassName">UILabel</string>
284
+ </object>
285
+ <object class="IBToOneOutletInfo" key="_session_scrollview">
286
+ <string key="name">_session_scrollview</string>
287
+ <string key="candidateClassName">UIScrollView</string>
288
+ </object>
289
+ <object class="IBToOneOutletInfo" key="_session_toolbar">
290
+ <string key="name">_session_toolbar</string>
291
+ <string key="candidateClassName">UIToolbar</string>
292
+ </object>
293
+ <object class="IBToOneOutletInfo" key="_session_view">
294
+ <string key="name">_session_view</string>
295
+ <string key="candidateClassName">RDPSessionView</string>
296
+ </object>
297
+ <object class="IBToOneOutletInfo" key="_touchpointer_view">
298
+ <string key="name">_touchpointer_view</string>
299
+ <string key="candidateClassName">TouchPointerView</string>
300
+ </object>
301
+ </dictionary>
302
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
303
+ <string key="majorKey">IBProjectSource</string>
304
+ <string key="minorKey">./Classes/RDPSessionViewController.h</string>
305
+ </object>
306
+ </object>
307
+ <object class="IBPartialClassDescription">
308
+ <string key="className">TouchPointerView</string>
309
+ <string key="superclassName">UIView</string>
310
+ <object class="NSMutableDictionary" key="outlets">
311
+ <string key="NS.key.0">delegate</string>
312
+ <string key="NS.object.0">NSObject</string>
313
+ </object>
314
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
315
+ <string key="NS.key.0">delegate</string>
316
+ <object class="IBToOneOutletInfo" key="NS.object.0">
317
+ <string key="name">delegate</string>
318
+ <string key="candidateClassName">NSObject</string>
319
+ </object>
320
+ </object>
321
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
322
+ <string key="majorKey">IBProjectSource</string>
323
+ <string key="minorKey">./Classes/TouchPointerView.h</string>
324
+ </object>
325
+ </object>
326
+ </array>
327
+ </object>
328
+ <int key="IBDocument.localizationMode">0</int>
329
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
330
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
331
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
332
+ <real value="1296" key="NS.object.0"/>
333
+ </object>
334
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
335
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
336
+ <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
337
+ <string key="NS.key.0">cancel_button_background.png</string>
338
+ <string key="NS.object.0">{63, 33}</string>
339
+ </object>
340
+ <string key="IBCocoaTouchPluginVersion">1179</string>
341
+ </data>
342
+ </archive>
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/RDPSessionView.xib ADDED
@@ -0,0 +1,553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <array key="IBDocument.IntegratedClassDependencies">
14
+ <string>IBUITextField</string>
15
+ <string>IBUIBarButtonItem</string>
16
+ <string>IBUIToolbar</string>
17
+ <string>IBUIView</string>
18
+ <string>IBUIScrollView</string>
19
+ <string>IBProxyObject</string>
20
+ </array>
21
+ <array key="IBDocument.PluginDependencies">
22
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
23
+ </array>
24
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
25
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
26
+ <integer value="1" key="NS.object.0"/>
27
+ </object>
28
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
29
+ <object class="IBProxyObject" id="372490531">
30
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
31
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
32
+ </object>
33
+ <object class="IBProxyObject" id="975951072">
34
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
35
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
36
+ </object>
37
+ <object class="IBUIView" id="191373211">
38
+ <reference key="NSNextResponder"/>
39
+ <int key="NSvFlags">274</int>
40
+ <array class="NSMutableArray" key="NSSubviews">
41
+ <object class="IBUITextField" id="774128306">
42
+ <reference key="NSNextResponder" ref="191373211"/>
43
+ <int key="NSvFlags">292</int>
44
+ <string key="NSFrameSize">{0, 31}</string>
45
+ <reference key="NSSuperview" ref="191373211"/>
46
+ <reference key="NSWindow"/>
47
+ <reference key="NSNextKeyView" ref="791392364"/>
48
+ <string key="NSReuseIdentifierKey">_NS:9</string>
49
+ <bool key="IBUIOpaque">NO</bool>
50
+ <bool key="IBUIClipsSubviews">YES</bool>
51
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
52
+ <int key="IBUIContentVerticalAlignment">0</int>
53
+ <string key="IBUIText">UserInput</string>
54
+ <int key="IBUIBorderStyle">3</int>
55
+ <object class="NSColor" key="IBUITextColor">
56
+ <int key="NSColorSpace">3</int>
57
+ <bytes key="NSWhite">MAA</bytes>
58
+ <object class="NSColorSpace" key="NSCustomColorSpace" id="239224178">
59
+ <int key="NSID">2</int>
60
+ </object>
61
+ </object>
62
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
63
+ <float key="IBUIMinimumFontSize">17</float>
64
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
65
+ <int key="IBUIAutocorrectionType">1</int>
66
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
67
+ </object>
68
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
69
+ <int key="type">1</int>
70
+ <double key="pointSize">14</double>
71
+ </object>
72
+ <object class="NSFont" key="IBUIFont">
73
+ <string key="NSName">Helvetica</string>
74
+ <double key="NSSize">14</double>
75
+ <int key="NSfFlags">16</int>
76
+ </object>
77
+ </object>
78
+ <object class="IBUIScrollView" id="791392364">
79
+ <reference key="NSNextResponder" ref="191373211"/>
80
+ <int key="NSvFlags">274</int>
81
+ <array class="NSMutableArray" key="NSSubviews">
82
+ <object class="IBUIView" id="111719994">
83
+ <reference key="NSNextResponder" ref="791392364"/>
84
+ <int key="NSvFlags">292</int>
85
+ <string key="NSFrameSize">{320, 460}</string>
86
+ <reference key="NSSuperview" ref="791392364"/>
87
+ <reference key="NSWindow"/>
88
+ <reference key="NSNextKeyView" ref="462653931"/>
89
+ <string key="NSReuseIdentifierKey">_NS:9</string>
90
+ <object class="NSColor" key="IBUIBackgroundColor">
91
+ <int key="NSColorSpace">3</int>
92
+ <bytes key="NSWhite">MQA</bytes>
93
+ <reference key="NSCustomColorSpace" ref="239224178"/>
94
+ </object>
95
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
96
+ </object>
97
+ </array>
98
+ <string key="NSFrameSize">{320, 460}</string>
99
+ <reference key="NSSuperview" ref="191373211"/>
100
+ <reference key="NSWindow"/>
101
+ <reference key="NSNextKeyView" ref="111719994"/>
102
+ <string key="NSReuseIdentifierKey">_NS:9</string>
103
+ <object class="NSColor" key="IBUIBackgroundColor" id="916436089">
104
+ <int key="NSColorSpace">3</int>
105
+ <bytes key="NSWhite">MAA</bytes>
106
+ </object>
107
+ <bool key="IBUIClipsSubviews">YES</bool>
108
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
109
+ <array key="IBUIGestureRecognizers" id="0"/>
110
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
111
+ <bool key="IBUICanCancelContentTouches">NO</bool>
112
+ <float key="IBUIMaximumZoomScale">2</float>
113
+ </object>
114
+ <object class="IBUIView" id="462653931">
115
+ <reference key="NSNextResponder" ref="191373211"/>
116
+ <int key="NSvFlags">-2147483374</int>
117
+ <string key="NSFrameSize">{320, 460}</string>
118
+ <reference key="NSSuperview" ref="191373211"/>
119
+ <reference key="NSWindow"/>
120
+ <string key="NSReuseIdentifierKey">_NS:9</string>
121
+ <object class="NSColor" key="IBUIBackgroundColor">
122
+ <int key="NSColorSpace">3</int>
123
+ <bytes key="NSWhite">MSAwAA</bytes>
124
+ <reference key="NSCustomColorSpace" ref="239224178"/>
125
+ </object>
126
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
127
+ </object>
128
+ <object class="IBUIToolbar" id="902223647">
129
+ <reference key="NSNextResponder" ref="191373211"/>
130
+ <int key="NSvFlags">290</int>
131
+ <string key="NSFrame">{{0, -66}, {320, 44}}</string>
132
+ <reference key="NSSuperview" ref="191373211"/>
133
+ <reference key="NSWindow"/>
134
+ <reference key="NSNextKeyView" ref="774128306"/>
135
+ <string key="NSReuseIdentifierKey">_NS:9</string>
136
+ <bool key="IBUIOpaque">NO</bool>
137
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
138
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
139
+ <int key="IBUIBarStyle">2</int>
140
+ <array class="NSMutableArray" key="IBUIItems">
141
+ <object class="IBUIBarButtonItem" id="1053104">
142
+ <object class="NSCustomResource" key="IBUIImage">
143
+ <string key="NSClassName">NSImage</string>
144
+ <string key="NSResourceName">toolbar_icon_keyboard.png</string>
145
+ </object>
146
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
147
+ <reference key="IBUIToolbar" ref="902223647"/>
148
+ </object>
149
+ <object class="IBUIBarButtonItem" id="610739936">
150
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
151
+ <float key="IBUIWidth">20</float>
152
+ <reference key="IBUIToolbar" ref="902223647"/>
153
+ <int key="IBUISystemItemIdentifier">6</int>
154
+ </object>
155
+ <object class="IBUIBarButtonItem" id="619296838">
156
+ <object class="NSCustomResource" key="IBUIImage">
157
+ <string key="NSClassName">NSImage</string>
158
+ <string key="NSResourceName">toolbar_icon_extkeyboad.png</string>
159
+ </object>
160
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
161
+ <reference key="IBUIToolbar" ref="902223647"/>
162
+ </object>
163
+ <object class="IBUIBarButtonItem" id="638922886">
164
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
165
+ <float key="IBUIWidth">20</float>
166
+ <reference key="IBUIToolbar" ref="902223647"/>
167
+ <int key="IBUISystemItemIdentifier">6</int>
168
+ </object>
169
+ <object class="IBUIBarButtonItem" id="771290196">
170
+ <object class="NSCustomResource" key="IBUIImage">
171
+ <string key="NSClassName">NSImage</string>
172
+ <string key="NSResourceName">toolbar_icon_touchpointer.png</string>
173
+ </object>
174
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
175
+ <reference key="IBUIToolbar" ref="902223647"/>
176
+ </object>
177
+ <object class="IBUIBarButtonItem" id="1053225403">
178
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
179
+ <reference key="IBUIToolbar" ref="902223647"/>
180
+ <int key="IBUISystemItemIdentifier">5</int>
181
+ </object>
182
+ <object class="IBUIBarButtonItem" id="977115063">
183
+ <object class="NSCustomResource" key="IBUIImage">
184
+ <string key="NSClassName">NSImage</string>
185
+ <string key="NSResourceName">toolbar_icon_disconnect.png</string>
186
+ </object>
187
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
188
+ <reference key="IBUIToolbar" ref="902223647"/>
189
+ </object>
190
+ </array>
191
+ </object>
192
+ </array>
193
+ <string key="NSFrame">{{0, 20}, {320, 460}}</string>
194
+ <reference key="NSSuperview"/>
195
+ <reference key="NSWindow"/>
196
+ <reference key="NSNextKeyView" ref="902223647"/>
197
+ <reference key="IBUIBackgroundColor" ref="916436089"/>
198
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
199
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
200
+ </object>
201
+ </array>
202
+ <object class="IBObjectContainer" key="IBDocument.Objects">
203
+ <array class="NSMutableArray" key="connectionRecords">
204
+ <object class="IBConnectionRecord">
205
+ <object class="IBCocoaTouchOutletConnection" key="connection">
206
+ <string key="label">view</string>
207
+ <reference key="source" ref="372490531"/>
208
+ <reference key="destination" ref="191373211"/>
209
+ </object>
210
+ <int key="connectionID">21</int>
211
+ </object>
212
+ <object class="IBConnectionRecord">
213
+ <object class="IBCocoaTouchOutletConnection" key="connection">
214
+ <string key="label">_dummy_textfield</string>
215
+ <reference key="source" ref="372490531"/>
216
+ <reference key="destination" ref="774128306"/>
217
+ </object>
218
+ <int key="connectionID">22</int>
219
+ </object>
220
+ <object class="IBConnectionRecord">
221
+ <object class="IBCocoaTouchOutletConnection" key="connection">
222
+ <string key="label">_session_scrollview</string>
223
+ <reference key="source" ref="372490531"/>
224
+ <reference key="destination" ref="791392364"/>
225
+ </object>
226
+ <int key="connectionID">23</int>
227
+ </object>
228
+ <object class="IBConnectionRecord">
229
+ <object class="IBCocoaTouchOutletConnection" key="connection">
230
+ <string key="label">_touchpointer_view</string>
231
+ <reference key="source" ref="372490531"/>
232
+ <reference key="destination" ref="462653931"/>
233
+ </object>
234
+ <int key="connectionID">25</int>
235
+ </object>
236
+ <object class="IBConnectionRecord">
237
+ <object class="IBCocoaTouchOutletConnection" key="connection">
238
+ <string key="label">_session_view</string>
239
+ <reference key="source" ref="372490531"/>
240
+ <reference key="destination" ref="111719994"/>
241
+ </object>
242
+ <int key="connectionID">26</int>
243
+ </object>
244
+ <object class="IBConnectionRecord">
245
+ <object class="IBCocoaTouchOutletConnection" key="connection">
246
+ <string key="label">_session_toolbar</string>
247
+ <reference key="source" ref="372490531"/>
248
+ <reference key="destination" ref="902223647"/>
249
+ </object>
250
+ <int key="connectionID">27</int>
251
+ </object>
252
+ <object class="IBConnectionRecord">
253
+ <object class="IBCocoaTouchEventConnection" key="connection">
254
+ <string key="label">toggleKeyboard:</string>
255
+ <reference key="source" ref="1053104"/>
256
+ <reference key="destination" ref="372490531"/>
257
+ </object>
258
+ <int key="connectionID">33</int>
259
+ </object>
260
+ <object class="IBConnectionRecord">
261
+ <object class="IBCocoaTouchEventConnection" key="connection">
262
+ <string key="label">toggleTouchPointer:</string>
263
+ <reference key="source" ref="771290196"/>
264
+ <reference key="destination" ref="372490531"/>
265
+ </object>
266
+ <int key="connectionID">34</int>
267
+ </object>
268
+ <object class="IBConnectionRecord">
269
+ <object class="IBCocoaTouchEventConnection" key="connection">
270
+ <string key="label">disconnectSession:</string>
271
+ <reference key="source" ref="977115063"/>
272
+ <reference key="destination" ref="372490531"/>
273
+ </object>
274
+ <int key="connectionID">31</int>
275
+ </object>
276
+ <object class="IBConnectionRecord">
277
+ <object class="IBCocoaTouchOutletConnection" key="connection">
278
+ <string key="label">delegate</string>
279
+ <reference key="source" ref="791392364"/>
280
+ <reference key="destination" ref="372490531"/>
281
+ </object>
282
+ <int key="connectionID">28</int>
283
+ </object>
284
+ <object class="IBConnectionRecord">
285
+ <object class="IBCocoaTouchOutletConnection" key="connection">
286
+ <string key="label">delegate</string>
287
+ <reference key="source" ref="774128306"/>
288
+ <reference key="destination" ref="372490531"/>
289
+ </object>
290
+ <int key="connectionID">29</int>
291
+ </object>
292
+ <object class="IBConnectionRecord">
293
+ <object class="IBCocoaTouchOutletConnection" key="connection">
294
+ <string key="label">delegate</string>
295
+ <reference key="source" ref="462653931"/>
296
+ <reference key="destination" ref="372490531"/>
297
+ </object>
298
+ <int key="connectionID">30</int>
299
+ </object>
300
+ <object class="IBConnectionRecord">
301
+ <object class="IBCocoaTouchEventConnection" key="connection">
302
+ <string key="label">toggleShiftKey:</string>
303
+ <reference key="source" ref="638922886"/>
304
+ <reference key="destination" ref="372490531"/>
305
+ </object>
306
+ <int key="connectionID">38</int>
307
+ </object>
308
+ <object class="IBConnectionRecord">
309
+ <object class="IBCocoaTouchEventConnection" key="connection">
310
+ <string key="label">toggleExtKeyboard:</string>
311
+ <reference key="source" ref="619296838"/>
312
+ <reference key="destination" ref="372490531"/>
313
+ </object>
314
+ <int key="connectionID">39</int>
315
+ </object>
316
+ </array>
317
+ <object class="IBMutableOrderedSet" key="objectRecords">
318
+ <array key="orderedObjects">
319
+ <object class="IBObjectRecord">
320
+ <int key="objectID">0</int>
321
+ <reference key="object" ref="0"/>
322
+ <reference key="children" ref="1000"/>
323
+ <nil key="parent"/>
324
+ </object>
325
+ <object class="IBObjectRecord">
326
+ <int key="objectID">1</int>
327
+ <reference key="object" ref="191373211"/>
328
+ <array class="NSMutableArray" key="children">
329
+ <reference ref="902223647"/>
330
+ <reference ref="791392364"/>
331
+ <reference ref="774128306"/>
332
+ <reference ref="462653931"/>
333
+ </array>
334
+ <reference key="parent" ref="0"/>
335
+ </object>
336
+ <object class="IBObjectRecord">
337
+ <int key="objectID">-1</int>
338
+ <reference key="object" ref="372490531"/>
339
+ <reference key="parent" ref="0"/>
340
+ <string key="objectName">File's Owner</string>
341
+ </object>
342
+ <object class="IBObjectRecord">
343
+ <int key="objectID">-2</int>
344
+ <reference key="object" ref="975951072"/>
345
+ <reference key="parent" ref="0"/>
346
+ </object>
347
+ <object class="IBObjectRecord">
348
+ <int key="objectID">3</int>
349
+ <reference key="object" ref="902223647"/>
350
+ <array class="NSMutableArray" key="children">
351
+ <reference ref="1053104"/>
352
+ <reference ref="610739936"/>
353
+ <reference ref="771290196"/>
354
+ <reference ref="1053225403"/>
355
+ <reference ref="977115063"/>
356
+ <reference ref="638922886"/>
357
+ <reference ref="619296838"/>
358
+ </array>
359
+ <reference key="parent" ref="191373211"/>
360
+ </object>
361
+ <object class="IBObjectRecord">
362
+ <int key="objectID">4</int>
363
+ <reference key="object" ref="1053104"/>
364
+ <reference key="parent" ref="902223647"/>
365
+ </object>
366
+ <object class="IBObjectRecord">
367
+ <int key="objectID">5</int>
368
+ <reference key="object" ref="610739936"/>
369
+ <reference key="parent" ref="902223647"/>
370
+ </object>
371
+ <object class="IBObjectRecord">
372
+ <int key="objectID">6</int>
373
+ <reference key="object" ref="771290196"/>
374
+ <reference key="parent" ref="902223647"/>
375
+ </object>
376
+ <object class="IBObjectRecord">
377
+ <int key="objectID">9</int>
378
+ <reference key="object" ref="1053225403"/>
379
+ <reference key="parent" ref="902223647"/>
380
+ </object>
381
+ <object class="IBObjectRecord">
382
+ <int key="objectID">10</int>
383
+ <reference key="object" ref="977115063"/>
384
+ <reference key="parent" ref="902223647"/>
385
+ </object>
386
+ <object class="IBObjectRecord">
387
+ <int key="objectID">11</int>
388
+ <reference key="object" ref="791392364"/>
389
+ <array class="NSMutableArray" key="children">
390
+ <reference ref="111719994"/>
391
+ </array>
392
+ <reference key="parent" ref="191373211"/>
393
+ </object>
394
+ <object class="IBObjectRecord">
395
+ <int key="objectID">12</int>
396
+ <reference key="object" ref="774128306"/>
397
+ <reference key="parent" ref="191373211"/>
398
+ </object>
399
+ <object class="IBObjectRecord">
400
+ <int key="objectID">13</int>
401
+ <reference key="object" ref="111719994"/>
402
+ <array class="NSMutableArray" key="children"/>
403
+ <reference key="parent" ref="791392364"/>
404
+ </object>
405
+ <object class="IBObjectRecord">
406
+ <int key="objectID">14</int>
407
+ <reference key="object" ref="462653931"/>
408
+ <reference key="parent" ref="191373211"/>
409
+ </object>
410
+ <object class="IBObjectRecord">
411
+ <int key="objectID">35</int>
412
+ <reference key="object" ref="638922886"/>
413
+ <reference key="parent" ref="902223647"/>
414
+ </object>
415
+ <object class="IBObjectRecord">
416
+ <int key="objectID">36</int>
417
+ <reference key="object" ref="619296838"/>
418
+ <reference key="parent" ref="902223647"/>
419
+ </object>
420
+ </array>
421
+ </object>
422
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
423
+ <string key="-1.CustomClassName">RDPSessionViewController</string>
424
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
425
+ <string key="-2.CustomClassName">UIResponder</string>
426
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
427
+ <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
428
+ <string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
429
+ <string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
430
+ <string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
431
+ <string key="13.CustomClassName">RDPSessionView</string>
432
+ <string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
433
+ <string key="14.CustomClassName">TouchPointerView</string>
434
+ <string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
435
+ <string key="3.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
436
+ <string key="35.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
437
+ <string key="36.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
438
+ <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
439
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
440
+ <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
441
+ <string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
442
+ </dictionary>
443
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
444
+ <nil key="activeLocalization"/>
445
+ <dictionary class="NSMutableDictionary" key="localizations"/>
446
+ <nil key="sourceID"/>
447
+ <int key="maxID">39</int>
448
+ </object>
449
+ <object class="IBClassDescriber" key="IBDocument.Classes">
450
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
451
+ <object class="IBPartialClassDescription">
452
+ <string key="className">RDPSessionView</string>
453
+ <string key="superclassName">UIView</string>
454
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
455
+ <string key="majorKey">IBProjectSource</string>
456
+ <string key="minorKey">./Classes/RDPSessionView.h</string>
457
+ </object>
458
+ </object>
459
+ <object class="IBPartialClassDescription">
460
+ <string key="className">RDPSessionViewController</string>
461
+ <string key="superclassName">UIViewController</string>
462
+ <dictionary class="NSMutableDictionary" key="outlets">
463
+ <string key="_cancel_connect_button">UIButton</string>
464
+ <string key="_connecting_indicator_view">UIActivityIndicatorView</string>
465
+ <string key="_connecting_view">UIView</string>
466
+ <string key="_dummy_textfield">UITextField</string>
467
+ <string key="_lbl_connecting">UILabel</string>
468
+ <string key="_session_scrollview">UIScrollView</string>
469
+ <string key="_session_toolbar">UIToolbar</string>
470
+ <string key="_session_view">RDPSessionView</string>
471
+ <string key="_touchpointer_view">TouchPointerView</string>
472
+ </dictionary>
473
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
474
+ <object class="IBToOneOutletInfo" key="_cancel_connect_button">
475
+ <string key="name">_cancel_connect_button</string>
476
+ <string key="candidateClassName">UIButton</string>
477
+ </object>
478
+ <object class="IBToOneOutletInfo" key="_connecting_indicator_view">
479
+ <string key="name">_connecting_indicator_view</string>
480
+ <string key="candidateClassName">UIActivityIndicatorView</string>
481
+ </object>
482
+ <object class="IBToOneOutletInfo" key="_connecting_view">
483
+ <string key="name">_connecting_view</string>
484
+ <string key="candidateClassName">UIView</string>
485
+ </object>
486
+ <object class="IBToOneOutletInfo" key="_dummy_textfield">
487
+ <string key="name">_dummy_textfield</string>
488
+ <string key="candidateClassName">UITextField</string>
489
+ </object>
490
+ <object class="IBToOneOutletInfo" key="_lbl_connecting">
491
+ <string key="name">_lbl_connecting</string>
492
+ <string key="candidateClassName">UILabel</string>
493
+ </object>
494
+ <object class="IBToOneOutletInfo" key="_session_scrollview">
495
+ <string key="name">_session_scrollview</string>
496
+ <string key="candidateClassName">UIScrollView</string>
497
+ </object>
498
+ <object class="IBToOneOutletInfo" key="_session_toolbar">
499
+ <string key="name">_session_toolbar</string>
500
+ <string key="candidateClassName">UIToolbar</string>
501
+ </object>
502
+ <object class="IBToOneOutletInfo" key="_session_view">
503
+ <string key="name">_session_view</string>
504
+ <string key="candidateClassName">RDPSessionView</string>
505
+ </object>
506
+ <object class="IBToOneOutletInfo" key="_touchpointer_view">
507
+ <string key="name">_touchpointer_view</string>
508
+ <string key="candidateClassName">TouchPointerView</string>
509
+ </object>
510
+ </dictionary>
511
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
512
+ <string key="majorKey">IBProjectSource</string>
513
+ <string key="minorKey">./Classes/RDPSessionViewController.h</string>
514
+ </object>
515
+ </object>
516
+ <object class="IBPartialClassDescription">
517
+ <string key="className">TouchPointerView</string>
518
+ <string key="superclassName">UIView</string>
519
+ <object class="NSMutableDictionary" key="outlets">
520
+ <string key="NS.key.0">delegate</string>
521
+ <string key="NS.object.0">NSObject</string>
522
+ </object>
523
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
524
+ <string key="NS.key.0">delegate</string>
525
+ <object class="IBToOneOutletInfo" key="NS.object.0">
526
+ <string key="name">delegate</string>
527
+ <string key="candidateClassName">NSObject</string>
528
+ </object>
529
+ </object>
530
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
531
+ <string key="majorKey">IBProjectSource</string>
532
+ <string key="minorKey">./Classes/TouchPointerView.h</string>
533
+ </object>
534
+ </object>
535
+ </array>
536
+ </object>
537
+ <int key="IBDocument.localizationMode">0</int>
538
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
539
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
540
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
541
+ <real value="1296" key="NS.object.0"/>
542
+ </object>
543
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
544
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
545
+ <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
546
+ <string key="toolbar_icon_disconnect.png">{24, 24}</string>
547
+ <string key="toolbar_icon_extkeyboad.png">{24, 24}</string>
548
+ <string key="toolbar_icon_keyboard.png">{35, 24}</string>
549
+ <string key="toolbar_icon_touchpointer.png">{24, 24}</string>
550
+ </dictionary>
551
+ <string key="IBCocoaTouchPluginVersion">1179</string>
552
+ </data>
553
+ </archive>
local-test-freerdp-full-01/afc-freerdp/client/iOS/Resources/SessionTableViewCell.xib ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="7.10">
3
+ <data>
4
+ <int key="IBDocument.SystemTarget">1296</int>
5
+ <string key="IBDocument.SystemVersion">11D50b</string>
6
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
7
+ <string key="IBDocument.AppKitVersion">1138.32</string>
8
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
9
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11
+ <string key="NS.object.0">1179</string>
12
+ </object>
13
+ <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
14
+ <bool key="EncodedWithXMLCoder">YES</bool>
15
+ <string>IBUITableViewCell</string>
16
+ <string>IBUIImageView</string>
17
+ <string>IBUILabel</string>
18
+ <string>IBUIButton</string>
19
+ <string>IBProxyObject</string>
20
+ </object>
21
+ <object class="NSArray" key="IBDocument.PluginDependencies">
22
+ <bool key="EncodedWithXMLCoder">YES</bool>
23
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
24
+ </object>
25
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
26
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
27
+ <integer value="1" key="NS.object.0"/>
28
+ </object>
29
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
30
+ <bool key="EncodedWithXMLCoder">YES</bool>
31
+ <object class="IBProxyObject" id="372490531">
32
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
33
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
34
+ </object>
35
+ <object class="IBProxyObject" id="975951072">
36
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
37
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
38
+ </object>
39
+ <object class="IBUITableViewCell" id="660975430">
40
+ <reference key="NSNextResponder"/>
41
+ <int key="NSvFlags">292</int>
42
+ <object class="NSMutableArray" key="NSSubviews">
43
+ <bool key="EncodedWithXMLCoder">YES</bool>
44
+ <object class="IBUIView" id="64247618">
45
+ <reference key="NSNextResponder" ref="660975430"/>
46
+ <int key="NSvFlags">256</int>
47
+ <object class="NSMutableArray" key="NSSubviews">
48
+ <bool key="EncodedWithXMLCoder">YES</bool>
49
+ <object class="IBUIImageView" id="60336238">
50
+ <reference key="NSNextResponder" ref="64247618"/>
51
+ <int key="NSvFlags">300</int>
52
+ <string key="NSFrame">{{20, 12}, {63, 47}}</string>
53
+ <reference key="NSSuperview" ref="64247618"/>
54
+ <reference key="NSWindow"/>
55
+ <reference key="NSNextKeyView" ref="695281447"/>
56
+ <string key="NSReuseIdentifierKey">_NS:9</string>
57
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
58
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
59
+ </object>
60
+ <object class="IBUILabel" id="695281447">
61
+ <reference key="NSNextResponder" ref="64247618"/>
62
+ <int key="NSvFlags">290</int>
63
+ <string key="NSFrame">{{91, 12}, {168, 21}}</string>
64
+ <reference key="NSSuperview" ref="64247618"/>
65
+ <reference key="NSWindow"/>
66
+ <reference key="NSNextKeyView" ref="583414824"/>
67
+ <string key="NSReuseIdentifierKey">_NS:9</string>
68
+ <bool key="IBUIOpaque">NO</bool>
69
+ <bool key="IBUIClipsSubviews">YES</bool>
70
+ <int key="IBUIContentMode">7</int>
71
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
72
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
73
+ <string key="IBUIText">Label</string>
74
+ <object class="NSColor" key="IBUITextColor" id="852118610">
75
+ <int key="NSColorSpace">1</int>
76
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
77
+ </object>
78
+ <object class="NSColor" key="IBUIHighlightedColor" id="645846245">
79
+ <int key="NSColorSpace">3</int>
80
+ <bytes key="NSWhite">MQA</bytes>
81
+ </object>
82
+ <int key="IBUIBaselineAdjustment">0</int>
83
+ <float key="IBUIMinimumFontSize">10</float>
84
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
85
+ <int key="type">2</int>
86
+ <double key="pointSize">18</double>
87
+ </object>
88
+ <object class="NSFont" key="IBUIFont">
89
+ <string key="NSName">Helvetica-Bold</string>
90
+ <double key="NSSize">18</double>
91
+ <int key="NSfFlags">16</int>
92
+ </object>
93
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
94
+ </object>
95
+ <object class="IBUILabel" id="583414824">
96
+ <reference key="NSNextResponder" ref="64247618"/>
97
+ <int key="NSvFlags">290</int>
98
+ <string key="NSFrame">{{91, 25}, {168, 21}}</string>
99
+ <reference key="NSSuperview" ref="64247618"/>
100
+ <reference key="NSWindow"/>
101
+ <reference key="NSNextKeyView" ref="597512619"/>
102
+ <string key="NSReuseIdentifierKey">_NS:9</string>
103
+ <bool key="IBUIOpaque">NO</bool>
104
+ <bool key="IBUIClipsSubviews">YES</bool>
105
+ <int key="IBUIContentMode">7</int>
106
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
107
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
108
+ <string key="IBUIText">Label</string>
109
+ <reference key="IBUITextColor" ref="852118610"/>
110
+ <reference key="IBUIHighlightedColor" ref="645846245"/>
111
+ <int key="IBUIBaselineAdjustment">0</int>
112
+ <float key="IBUIMinimumFontSize">10</float>
113
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="263878792">
114
+ <int key="type">1</int>
115
+ <double key="pointSize">14</double>
116
+ </object>
117
+ <object class="NSFont" key="IBUIFont" id="649156643">
118
+ <string key="NSName">Helvetica</string>
119
+ <double key="NSSize">14</double>
120
+ <int key="NSfFlags">16</int>
121
+ </object>
122
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
123
+ </object>
124
+ <object class="IBUILabel" id="597512619">
125
+ <reference key="NSNextResponder" ref="64247618"/>
126
+ <int key="NSvFlags">290</int>
127
+ <string key="NSFrame">{{91, 41}, {168, 21}}</string>
128
+ <reference key="NSSuperview" ref="64247618"/>
129
+ <reference key="NSWindow"/>
130
+ <reference key="NSNextKeyView" ref="30378675"/>
131
+ <string key="NSReuseIdentifierKey">_NS:9</string>
132
+ <bool key="IBUIOpaque">NO</bool>
133
+ <bool key="IBUIClipsSubviews">YES</bool>
134
+ <int key="IBUIContentMode">7</int>
135
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
136
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
137
+ <string key="IBUIText">Label</string>
138
+ <reference key="IBUITextColor" ref="852118610"/>
139
+ <reference key="IBUIHighlightedColor" ref="645846245"/>
140
+ <int key="IBUIBaselineAdjustment">0</int>
141
+ <float key="IBUIMinimumFontSize">10</float>
142
+ <reference key="IBUIFontDescription" ref="263878792"/>
143
+ <reference key="IBUIFont" ref="649156643"/>
144
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
145
+ </object>
146
+ <object class="IBUIButton" id="30378675">
147
+ <reference key="NSNextResponder" ref="64247618"/>
148
+ <int key="NSvFlags">297</int>
149
+ <string key="NSFrame">{{267, 19}, {33, 33}}</string>
150
+ <reference key="NSSuperview" ref="64247618"/>
151
+ <reference key="NSWindow"/>
152
+ <string key="NSReuseIdentifierKey">_NS:9</string>
153
+ <bool key="IBUIOpaque">NO</bool>
154
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
155
+ <int key="IBUIContentHorizontalAlignment">0</int>
156
+ <int key="IBUIContentVerticalAlignment">0</int>
157
+ <int key="IBUIButtonType">1</int>
158
+ <reference key="IBUIHighlightedTitleColor" ref="645846245"/>
159
+ <object class="NSColor" key="IBUINormalTitleColor">
160
+ <int key="NSColorSpace">1</int>
161
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
162
+ </object>
163
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
164
+ <int key="NSColorSpace">3</int>
165
+ <bytes key="NSWhite">MC41AA</bytes>
166
+ </object>
167
+ <object class="NSCustomResource" key="IBUINormalImage">
168
+ <string key="NSClassName">NSImage</string>
169
+ <string key="NSResourceName">toolbar_icon_disconnect.png</string>
170
+ </object>
171
+ <object class="NSCustomResource" key="IBUINormalBackgroundImage">
172
+ <string key="NSClassName">NSImage</string>
173
+ <string key="NSResourceName">cancel_button_background.png</string>
174
+ </object>
175
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
176
+ <int key="type">2</int>
177
+ <double key="pointSize">15</double>
178
+ </object>
179
+ <object class="NSFont" key="IBUIFont">
180
+ <string key="NSName">Helvetica-Bold</string>
181
+ <double key="NSSize">15</double>
182
+ <int key="NSfFlags">16</int>
183
+ </object>
184
+ </object>
185
+ </object>
186
+ <string key="NSFrameSize">{320, 71}</string>
187
+ <reference key="NSSuperview" ref="660975430"/>
188
+ <reference key="NSWindow"/>
189
+ <reference key="NSNextKeyView" ref="60336238"/>
190
+ <string key="NSReuseIdentifierKey">_NS:11</string>
191
+ <object class="NSColor" key="IBUIBackgroundColor">
192
+ <int key="NSColorSpace">3</int>
193
+ <bytes key="NSWhite">MCAwAA</bytes>
194
+ </object>
195
+ <bool key="IBUIOpaque">NO</bool>
196
+ <bool key="IBUIClipsSubviews">YES</bool>
197
+ <int key="IBUIContentMode">4</int>
198
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
199
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
200
+ </object>
201
+ </object>
202
+ <string key="NSFrameSize">{320, 72}</string>
203
+ <reference key="NSSuperview"/>
204
+ <reference key="NSWindow"/>
205
+ <reference key="NSNextKeyView" ref="64247618"/>
206
+ <string key="NSReuseIdentifierKey">_NS:9</string>
207
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
208
+ <reference key="IBUIContentView" ref="64247618"/>
209
+ <real value="72" key="IBUIRowHeight"/>
210
+ </object>
211
+ </object>
212
+ <object class="IBObjectContainer" key="IBDocument.Objects">
213
+ <object class="NSMutableArray" key="connectionRecords">
214
+ <bool key="EncodedWithXMLCoder">YES</bool>
215
+ <object class="IBConnectionRecord">
216
+ <object class="IBCocoaTouchOutletConnection" key="connection">
217
+ <string key="label">sessTableCell</string>
218
+ <reference key="source" ref="372490531"/>
219
+ <reference key="destination" ref="660975430"/>
220
+ </object>
221
+ <int key="connectionID">34</int>
222
+ </object>
223
+ <object class="IBConnectionRecord">
224
+ <object class="IBCocoaTouchOutletConnection" key="connection">
225
+ <string key="label">_disconnect_button</string>
226
+ <reference key="source" ref="660975430"/>
227
+ <reference key="destination" ref="30378675"/>
228
+ </object>
229
+ <int key="connectionID">29</int>
230
+ </object>
231
+ <object class="IBConnectionRecord">
232
+ <object class="IBCocoaTouchOutletConnection" key="connection">
233
+ <string key="label">_screenshot</string>
234
+ <reference key="source" ref="660975430"/>
235
+ <reference key="destination" ref="60336238"/>
236
+ </object>
237
+ <int key="connectionID">30</int>
238
+ </object>
239
+ <object class="IBConnectionRecord">
240
+ <object class="IBCocoaTouchOutletConnection" key="connection">
241
+ <string key="label">_server</string>
242
+ <reference key="source" ref="660975430"/>
243
+ <reference key="destination" ref="583414824"/>
244
+ </object>
245
+ <int key="connectionID">31</int>
246
+ </object>
247
+ <object class="IBConnectionRecord">
248
+ <object class="IBCocoaTouchOutletConnection" key="connection">
249
+ <string key="label">_title</string>
250
+ <reference key="source" ref="660975430"/>
251
+ <reference key="destination" ref="695281447"/>
252
+ </object>
253
+ <int key="connectionID">32</int>
254
+ </object>
255
+ <object class="IBConnectionRecord">
256
+ <object class="IBCocoaTouchOutletConnection" key="connection">
257
+ <string key="label">_username</string>
258
+ <reference key="source" ref="660975430"/>
259
+ <reference key="destination" ref="597512619"/>
260
+ </object>
261
+ <int key="connectionID">33</int>
262
+ </object>
263
+ <object class="IBConnectionRecord">
264
+ <object class="IBCocoaTouchEventConnection" key="connection">
265
+ <string key="label">disconnectButtonPressed:</string>
266
+ <reference key="source" ref="30378675"/>
267
+ <reference key="destination" ref="372490531"/>
268
+ <int key="IBEventType">7</int>
269
+ </object>
270
+ <int key="connectionID">35</int>
271
+ </object>
272
+ </object>
273
+ <object class="IBMutableOrderedSet" key="objectRecords">
274
+ <object class="NSArray" key="orderedObjects">
275
+ <bool key="EncodedWithXMLCoder">YES</bool>
276
+ <object class="IBObjectRecord">
277
+ <int key="objectID">0</int>
278
+ <object class="NSArray" key="object" id="0">
279
+ <bool key="EncodedWithXMLCoder">YES</bool>
280
+ </object>
281
+ <reference key="children" ref="1000"/>
282
+ <nil key="parent"/>
283
+ </object>
284
+ <object class="IBObjectRecord">
285
+ <int key="objectID">-1</int>
286
+ <reference key="object" ref="372490531"/>
287
+ <reference key="parent" ref="0"/>
288
+ <string key="objectName">File's Owner</string>
289
+ </object>
290
+ <object class="IBObjectRecord">
291
+ <int key="objectID">-2</int>
292
+ <reference key="object" ref="975951072"/>
293
+ <reference key="parent" ref="0"/>
294
+ </object>
295
+ <object class="IBObjectRecord">
296
+ <int key="objectID">23</int>
297
+ <reference key="object" ref="660975430"/>
298
+ <object class="NSMutableArray" key="children">
299
+ <bool key="EncodedWithXMLCoder">YES</bool>
300
+ <reference ref="695281447"/>
301
+ <reference ref="597512619"/>
302
+ <reference ref="583414824"/>
303
+ <reference ref="60336238"/>
304
+ <reference ref="30378675"/>
305
+ </object>
306
+ <reference key="parent" ref="0"/>
307
+ </object>
308
+ <object class="IBObjectRecord">
309
+ <int key="objectID">24</int>
310
+ <reference key="object" ref="695281447"/>
311
+ <reference key="parent" ref="660975430"/>
312
+ </object>
313
+ <object class="IBObjectRecord">
314
+ <int key="objectID">25</int>
315
+ <reference key="object" ref="60336238"/>
316
+ <reference key="parent" ref="660975430"/>
317
+ </object>
318
+ <object class="IBObjectRecord">
319
+ <int key="objectID">26</int>
320
+ <reference key="object" ref="583414824"/>
321
+ <reference key="parent" ref="660975430"/>
322
+ </object>
323
+ <object class="IBObjectRecord">
324
+ <int key="objectID">27</int>
325
+ <reference key="object" ref="597512619"/>
326
+ <reference key="parent" ref="660975430"/>
327
+ </object>
328
+ <object class="IBObjectRecord">
329
+ <int key="objectID">28</int>
330
+ <reference key="object" ref="30378675"/>
331
+ <reference key="parent" ref="660975430"/>
332
+ </object>
333
+ </object>
334
+ </object>
335
+ <object class="NSMutableDictionary" key="flattenedProperties">
336
+ <bool key="EncodedWithXMLCoder">YES</bool>
337
+ <object class="NSArray" key="dict.sortedKeys">
338
+ <bool key="EncodedWithXMLCoder">YES</bool>
339
+ <string>-1.CustomClassName</string>
340
+ <string>-1.IBPluginDependency</string>
341
+ <string>-2.CustomClassName</string>
342
+ <string>-2.IBPluginDependency</string>
343
+ <string>23.CustomClassName</string>
344
+ <string>23.IBPluginDependency</string>
345
+ <string>24.IBPluginDependency</string>
346
+ <string>25.IBPluginDependency</string>
347
+ <string>26.IBPluginDependency</string>
348
+ <string>27.IBPluginDependency</string>
349
+ <string>28.IBPluginDependency</string>
350
+ </object>
351
+ <object class="NSArray" key="dict.values">
352
+ <bool key="EncodedWithXMLCoder">YES</bool>
353
+ <string>BookmarkListController</string>
354
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
355
+ <string>UIResponder</string>
356
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
357
+ <string>SessionTableCell</string>
358
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
359
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
360
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
361
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
362
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
363
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
364
+ </object>
365
+ </object>
366
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
367
+ <bool key="EncodedWithXMLCoder">YES</bool>
368
+ <reference key="dict.sortedKeys" ref="0"/>
369
+ <reference key="dict.values" ref="0"/>
370
+ </object>
371
+ <nil key="activeLocalization"/>
372
+ <object class="NSMutableDictionary" key="localizations">
373
+ <bool key="EncodedWithXMLCoder">YES</bool>
374
+ <reference key="dict.sortedKeys" ref="0"/>
375
+ <reference key="dict.values" ref="0"/>
376
+ </object>
377
+ <nil key="sourceID"/>
378
+ <int key="maxID">35</int>
379
+ </object>
380
+ <object class="IBClassDescriber" key="IBDocument.Classes">
381
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
382
+ <bool key="EncodedWithXMLCoder">YES</bool>
383
+ <object class="IBPartialClassDescription">
384
+ <string key="className">BookmarkListController</string>
385
+ <string key="superclassName">UIViewController</string>
386
+ <object class="NSMutableDictionary" key="outlets">
387
+ <bool key="EncodedWithXMLCoder">YES</bool>
388
+ <object class="NSArray" key="dict.sortedKeys">
389
+ <bool key="EncodedWithXMLCoder">YES</bool>
390
+ <string>bmTableCell</string>
391
+ <string>searchBar</string>
392
+ <string>sessTableCell</string>
393
+ <string>tableView</string>
394
+ </object>
395
+ <object class="NSArray" key="dict.values">
396
+ <bool key="EncodedWithXMLCoder">YES</bool>
397
+ <string>BookmarkTableCell</string>
398
+ <string>UISearchBar</string>
399
+ <string>SessionTableCell</string>
400
+ <string>UITableView</string>
401
+ </object>
402
+ </object>
403
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
404
+ <bool key="EncodedWithXMLCoder">YES</bool>
405
+ <object class="NSArray" key="dict.sortedKeys">
406
+ <bool key="EncodedWithXMLCoder">YES</bool>
407
+ <string>bmTableCell</string>
408
+ <string>searchBar</string>
409
+ <string>sessTableCell</string>
410
+ <string>tableView</string>
411
+ </object>
412
+ <object class="NSArray" key="dict.values">
413
+ <bool key="EncodedWithXMLCoder">YES</bool>
414
+ <object class="IBToOneOutletInfo">
415
+ <string key="name">bmTableCell</string>
416
+ <string key="candidateClassName">BookmarkTableCell</string>
417
+ </object>
418
+ <object class="IBToOneOutletInfo">
419
+ <string key="name">searchBar</string>
420
+ <string key="candidateClassName">UISearchBar</string>
421
+ </object>
422
+ <object class="IBToOneOutletInfo">
423
+ <string key="name">sessTableCell</string>
424
+ <string key="candidateClassName">SessionTableCell</string>
425
+ </object>
426
+ <object class="IBToOneOutletInfo">
427
+ <string key="name">tableView</string>
428
+ <string key="candidateClassName">UITableView</string>
429
+ </object>
430
+ </object>
431
+ </object>
432
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
433
+ <string key="majorKey">IBProjectSource</string>
434
+ <string key="minorKey">./Classes/BookmarkListController.h</string>
435
+ </object>
436
+ </object>
437
+ <object class="IBPartialClassDescription">
438
+ <string key="className">BookmarkTableCell</string>
439
+ <string key="superclassName">UITableViewCell</string>
440
+ <object class="NSMutableDictionary" key="outlets">
441
+ <bool key="EncodedWithXMLCoder">YES</bool>
442
+ <object class="NSArray" key="dict.sortedKeys">
443
+ <bool key="EncodedWithXMLCoder">YES</bool>
444
+ <string>_connection_state_icon</string>
445
+ <string>_sub_title</string>
446
+ <string>_title</string>
447
+ </object>
448
+ <object class="NSArray" key="dict.values">
449
+ <bool key="EncodedWithXMLCoder">YES</bool>
450
+ <string>UIImageView</string>
451
+ <string>UILabel</string>
452
+ <string>UILabel</string>
453
+ </object>
454
+ </object>
455
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
456
+ <bool key="EncodedWithXMLCoder">YES</bool>
457
+ <object class="NSArray" key="dict.sortedKeys">
458
+ <bool key="EncodedWithXMLCoder">YES</bool>
459
+ <string>_connection_state_icon</string>
460
+ <string>_sub_title</string>
461
+ <string>_title</string>
462
+ </object>
463
+ <object class="NSArray" key="dict.values">
464
+ <bool key="EncodedWithXMLCoder">YES</bool>
465
+ <object class="IBToOneOutletInfo">
466
+ <string key="name">_connection_state_icon</string>
467
+ <string key="candidateClassName">UIImageView</string>
468
+ </object>
469
+ <object class="IBToOneOutletInfo">
470
+ <string key="name">_sub_title</string>
471
+ <string key="candidateClassName">UILabel</string>
472
+ </object>
473
+ <object class="IBToOneOutletInfo">
474
+ <string key="name">_title</string>
475
+ <string key="candidateClassName">UILabel</string>
476
+ </object>
477
+ </object>
478
+ </object>
479
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
480
+ <string key="majorKey">IBProjectSource</string>
481
+ <string key="minorKey">./Classes/BookmarkTableCell.h</string>
482
+ </object>
483
+ </object>
484
+ <object class="IBPartialClassDescription">
485
+ <string key="className">SessionTableCell</string>
486
+ <string key="superclassName">UITableViewCell</string>
487
+ <object class="NSMutableDictionary" key="outlets">
488
+ <bool key="EncodedWithXMLCoder">YES</bool>
489
+ <object class="NSArray" key="dict.sortedKeys">
490
+ <bool key="EncodedWithXMLCoder">YES</bool>
491
+ <string>_disconnect_button</string>
492
+ <string>_screenshot</string>
493
+ <string>_server</string>
494
+ <string>_title</string>
495
+ <string>_username</string>
496
+ </object>
497
+ <object class="NSArray" key="dict.values">
498
+ <bool key="EncodedWithXMLCoder">YES</bool>
499
+ <string>UIButton</string>
500
+ <string>UIImageView</string>
501
+ <string>UILabel</string>
502
+ <string>UILabel</string>
503
+ <string>UILabel</string>
504
+ </object>
505
+ </object>
506
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
507
+ <bool key="EncodedWithXMLCoder">YES</bool>
508
+ <object class="NSArray" key="dict.sortedKeys">
509
+ <bool key="EncodedWithXMLCoder">YES</bool>
510
+ <string>_disconnect_button</string>
511
+ <string>_screenshot</string>
512
+ <string>_server</string>
513
+ <string>_title</string>
514
+ <string>_username</string>
515
+ </object>
516
+ <object class="NSArray" key="dict.values">
517
+ <bool key="EncodedWithXMLCoder">YES</bool>
518
+ <object class="IBToOneOutletInfo">
519
+ <string key="name">_disconnect_button</string>
520
+ <string key="candidateClassName">UIButton</string>
521
+ </object>
522
+ <object class="IBToOneOutletInfo">
523
+ <string key="name">_screenshot</string>
524
+ <string key="candidateClassName">UIImageView</string>
525
+ </object>
526
+ <object class="IBToOneOutletInfo">
527
+ <string key="name">_server</string>
528
+ <string key="candidateClassName">UILabel</string>
529
+ </object>
530
+ <object class="IBToOneOutletInfo">
531
+ <string key="name">_title</string>
532
+ <string key="candidateClassName">UILabel</string>
533
+ </object>
534
+ <object class="IBToOneOutletInfo">
535
+ <string key="name">_username</string>
536
+ <string key="candidateClassName">UILabel</string>
537
+ </object>
538
+ </object>
539
+ </object>
540
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
541
+ <string key="majorKey">IBProjectSource</string>
542
+ <string key="minorKey">./Classes/SessionTableCell.h</string>
543
+ </object>
544
+ </object>
545
+ </object>
546
+ </object>
547
+ <int key="IBDocument.localizationMode">0</int>
548
+ <string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
549
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
550
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
551
+ <real value="1296" key="NS.object.0"/>
552
+ </object>
553
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
554
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
555
+ <integer value="3100" key="NS.object.0"/>
556
+ </object>
557
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
558
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
559
+ <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
560
+ <bool key="EncodedWithXMLCoder">YES</bool>
561
+ <object class="NSArray" key="dict.sortedKeys">
562
+ <bool key="EncodedWithXMLCoder">YES</bool>
563
+ <string>cancel_button_background.png</string>
564
+ <string>toolbar_icon_disconnect.png</string>
565
+ </object>
566
+ <object class="NSArray" key="dict.values">
567
+ <bool key="EncodedWithXMLCoder">YES</bool>
568
+ <string>{63, 33}</string>
569
+ <string>{24, 24}</string>
570
+ </object>
571
+ </object>
572
+ <string key="IBCocoaTouchPluginVersion">1179</string>
573
+ </data>
574
+ </archive>
local-test-sqlite3-delta-03/afc-sqlite3/ext/fts3/unicode/mkunicode.tcl ADDED
@@ -0,0 +1,987 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ source [file join [file dirname [info script]] parseunicode.tcl]
3
+
4
+ proc print_rd {map} {
5
+ global tl_lookup_table
6
+ set aChar [list]
7
+ set lRange [list]
8
+
9
+ set nRange 1
10
+ set iFirst [lindex $map 0 0]
11
+ set cPrev [lindex $map 0 1]
12
+ set fPrev [lindex $map 0 2]
13
+
14
+ foreach m [lrange $map 1 end] {
15
+ foreach {i c f} $m {}
16
+
17
+ if {$cPrev == $c && $fPrev==$f} {
18
+ for {set j [expr $iFirst+$nRange]} {$j<$i} {incr j} {
19
+ if {[info exists tl_lookup_table($j)]==0} break
20
+ }
21
+
22
+ if {$j==$i} {
23
+ set nNew [expr {(1 + $i - $iFirst)}]
24
+ if {$nNew<=8} {
25
+ set nRange $nNew
26
+ continue
27
+ }
28
+ }
29
+ }
30
+
31
+ lappend lRange [list $iFirst $nRange]
32
+ lappend aChar $cPrev
33
+ lappend aFlag $fPrev
34
+
35
+ set iFirst $i
36
+ set cPrev $c
37
+ set fPrev $f
38
+ set nRange 1
39
+ }
40
+ lappend lRange [list $iFirst $nRange]
41
+ lappend aChar $cPrev
42
+ lappend aFlag $fPrev
43
+
44
+ puts "/*"
45
+ puts "** If the argument is a codepoint corresponding to a lowercase letter"
46
+ puts "** in the ASCII range with a diacritic added, return the codepoint"
47
+ puts "** of the ASCII letter only. For example, if passed 235 - \"LATIN"
48
+ puts "** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER"
49
+ puts "** E\"). The resuls of passing a codepoint that corresponds to an"
50
+ puts "** uppercase letter are undefined."
51
+ puts "*/"
52
+ puts "static int ${::remove_diacritic}(int c, int bComplex)\{"
53
+ puts " unsigned short aDia\[\] = \{"
54
+ puts -nonewline " 0, "
55
+ set i 1
56
+ foreach r $lRange {
57
+ foreach {iCode nRange} $r {}
58
+ if {($i % 8)==0} {puts "" ; puts -nonewline " " }
59
+ incr i
60
+
61
+ puts -nonewline [format "%5d" [expr ($iCode<<3) + $nRange-1]]
62
+ puts -nonewline ", "
63
+ }
64
+ puts ""
65
+ puts " \};"
66
+ puts "#define HIBIT ((unsigned char)0x80)"
67
+ puts " unsigned char aChar\[\] = \{"
68
+ puts -nonewline " '\\0', "
69
+ set i 1
70
+ foreach c $aChar f $aFlag {
71
+ if { $f } {
72
+ set str "'$c'|HIBIT, "
73
+ } else {
74
+ set str "'$c', "
75
+ }
76
+ if {$c == ""} { set str "'\\0', " }
77
+
78
+ if {($i % 6)==0} {puts "" ; puts -nonewline " " }
79
+ incr i
80
+ puts -nonewline "$str"
81
+ }
82
+ puts ""
83
+ puts " \};"
84
+ puts {
85
+ unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
86
+ int iRes = 0;
87
+ int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
88
+ int iLo = 0;
89
+ while( iHi>=iLo ){
90
+ int iTest = (iHi + iLo) / 2;
91
+ if( key >= aDia[iTest] ){
92
+ iRes = iTest;
93
+ iLo = iTest+1;
94
+ }else{
95
+ iHi = iTest-1;
96
+ }
97
+ }
98
+ assert( key>=aDia[iRes] );
99
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
100
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);}
101
+ puts "\}"
102
+ }
103
+
104
+ proc print_isdiacritic {zFunc map} {
105
+
106
+ set lCode [list]
107
+ foreach m $map {
108
+ foreach {code char flag} $m {}
109
+ if {$flag} continue
110
+ if {$code && $char == ""} { lappend lCode $code }
111
+ }
112
+ set lCode [lsort -integer $lCode]
113
+ set iFirst [lindex $lCode 0]
114
+ set iLast [lindex $lCode end]
115
+
116
+ set i1 0
117
+ set i2 0
118
+
119
+ foreach c $lCode {
120
+ set i [expr $c - $iFirst]
121
+ if {$i < 32} {
122
+ set i1 [expr {$i1 | (1<<$i)}]
123
+ } else {
124
+ set i2 [expr {$i2 | (1<<($i-32))}]
125
+ }
126
+ }
127
+
128
+ puts "/*"
129
+ puts "** Return true if the argument interpreted as a unicode codepoint"
130
+ puts "** is a diacritical modifier character."
131
+ puts "*/"
132
+ puts "int ${zFunc}\(int c)\{"
133
+ puts " unsigned int mask0 = [format "0x%08X" $i1];"
134
+ puts " unsigned int mask1 = [format "0x%08X" $i2];"
135
+
136
+ puts " if( c<$iFirst || c>$iLast ) return 0;"
137
+ puts " return (c < $iFirst+32) ?"
138
+ puts " (mask0 & ((unsigned int)1 << (c-$iFirst))) :"
139
+ puts " (mask1 & ((unsigned int)1 << (c-$iFirst-32)));"
140
+ puts "\}"
141
+ }
142
+
143
+
144
+ #-------------------------------------------------------------------------
145
+
146
+ proc an_load_separator_ranges {} {
147
+ global unicodedata.txt
148
+ set lSep [an_load_unicodedata_text ${unicodedata.txt}]
149
+ unset -nocomplain iFirst
150
+ unset -nocomplain nRange
151
+ set lRange [list]
152
+ foreach sep $lSep {
153
+ if {0==[info exists iFirst]} {
154
+ set iFirst $sep
155
+ set nRange 1
156
+ } elseif { $sep == ($iFirst+$nRange) } {
157
+ incr nRange
158
+ } else {
159
+ lappend lRange [list $iFirst $nRange]
160
+ set iFirst $sep
161
+ set nRange 1
162
+ }
163
+ }
164
+ lappend lRange [list $iFirst $nRange]
165
+ set lRange
166
+ }
167
+
168
+ proc an_print_range_array {lRange} {
169
+ set iFirstMax 0
170
+ set nRangeMax 0
171
+ foreach range $lRange {
172
+ foreach {iFirst nRange} $range {}
173
+ if {$iFirst > $iFirstMax} {set iFirstMax $iFirst}
174
+ if {$nRange > $nRangeMax} {set nRangeMax $nRange}
175
+ }
176
+ if {$iFirstMax >= (1<<22)} {error "first-max is too large for format"}
177
+ if {$nRangeMax >= (1<<10)} {error "range-max is too large for format"}
178
+
179
+ puts -nonewline " "
180
+ puts [string trim {
181
+ /* Each unsigned integer in the following array corresponds to a contiguous
182
+ ** range of unicode codepoints that are not either letters or numbers (i.e.
183
+ ** codepoints for which this function should return 0).
184
+ **
185
+ ** The most significant 22 bits in each 32-bit value contain the first
186
+ ** codepoint in the range. The least significant 10 bits are used to store
187
+ ** the size of the range (always at least 1). In other words, the value
188
+ ** ((C<<22) + N) represents a range of N codepoints starting with codepoint
189
+ ** C. It is not possible to represent a range larger than 1023 codepoints
190
+ ** using this format.
191
+ */
192
+ }]
193
+ puts -nonewline " static const unsigned int aEntry\[\] = \{"
194
+ set i 0
195
+ foreach range $lRange {
196
+ foreach {iFirst nRange} $range {}
197
+ set u32 [format "0x%08X" [expr ($iFirst<<10) + $nRange]]
198
+
199
+ if {($i % 5)==0} {puts "" ; puts -nonewline " "}
200
+ puts -nonewline " $u32,"
201
+ incr i
202
+ }
203
+ puts ""
204
+ puts " \};"
205
+ }
206
+
207
+ proc an_print_ascii_bitmap {lRange} {
208
+ foreach range $lRange {
209
+ foreach {iFirst nRange} $range {}
210
+ for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} {
211
+ if {$i<=127} { set a($i) 1 }
212
+ }
213
+ }
214
+
215
+ set aAscii [list 0 0 0 0]
216
+ foreach key [array names a] {
217
+ set idx [expr $key >> 5]
218
+ lset aAscii $idx [expr [lindex $aAscii $idx] | (1 << ($key&0x001F))]
219
+ }
220
+
221
+ puts " static const unsigned int aAscii\[4\] = \{"
222
+ puts -nonewline " "
223
+ foreach v $aAscii { puts -nonewline [format " 0x%08X," $v] }
224
+ puts ""
225
+ puts " \};"
226
+ }
227
+
228
+ proc print_isalnum {zFunc lRange} {
229
+ puts "/*"
230
+ puts "** Return true if the argument corresponds to a unicode codepoint"
231
+ puts "** classified as either a letter or a number. Otherwise false."
232
+ puts "**"
233
+ puts "** The results are undefined if the value passed to this function"
234
+ puts "** is less than zero."
235
+ puts "*/"
236
+ puts "int ${zFunc}\(int c)\{"
237
+ an_print_range_array $lRange
238
+ an_print_ascii_bitmap $lRange
239
+ puts {
240
+ if( (unsigned int)c<128 ){
241
+ return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );
242
+ }else if( (unsigned int)c<(1<<22) ){
243
+ unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;
244
+ int iRes = 0;
245
+ int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
246
+ int iLo = 0;
247
+ while( iHi>=iLo ){
248
+ int iTest = (iHi + iLo) / 2;
249
+ if( key >= aEntry[iTest] ){
250
+ iRes = iTest;
251
+ iLo = iTest+1;
252
+ }else{
253
+ iHi = iTest-1;
254
+ }
255
+ }
256
+ assert( aEntry[0]<key );
257
+ assert( key>=aEntry[iRes] );
258
+ return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
259
+ }
260
+ return 1;}
261
+ puts "\}"
262
+ }
263
+
264
+ proc print_test_isalnum {zFunc lRange} {
265
+ foreach range $lRange {
266
+ foreach {iFirst nRange} $range {}
267
+ for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} { set a($i) 1 }
268
+ }
269
+
270
+ puts "static int isalnum_test(int *piCode)\{"
271
+ puts -nonewline " unsigned char aAlnum\[\] = \{"
272
+ for {set i 0} {$i < 70000} {incr i} {
273
+ if {($i % 32)==0} { puts "" ; puts -nonewline " " }
274
+ set bFlag [expr ![info exists a($i)]]
275
+ puts -nonewline "${bFlag},"
276
+ }
277
+ puts ""
278
+ puts " \};"
279
+
280
+ puts -nonewline " int aLargeSep\[\] = \{"
281
+ set i 0
282
+ foreach iSep [lsort -integer [array names a]] {
283
+ if {$iSep<70000} continue
284
+ if {($i % 8)==0} { puts "" ; puts -nonewline " " }
285
+ puts -nonewline " $iSep,"
286
+ incr i
287
+ }
288
+ puts ""
289
+ puts " \};"
290
+ puts -nonewline " int aLargeOther\[\] = \{"
291
+ set i 0
292
+ foreach iSep [lsort -integer [array names a]] {
293
+ if {$iSep<70000} continue
294
+ if {[info exists a([expr $iSep-1])]==0} {
295
+ if {($i % 8)==0} { puts "" ; puts -nonewline " " }
296
+ puts -nonewline " [expr $iSep-1],"
297
+ incr i
298
+ }
299
+ if {[info exists a([expr $iSep+1])]==0} {
300
+ if {($i % 8)==0} { puts "" ; puts -nonewline " " }
301
+ puts -nonewline " [expr $iSep+1],"
302
+ incr i
303
+ }
304
+ }
305
+ puts ""
306
+ puts " \};"
307
+
308
+ puts [subst -nocommands {
309
+ int i;
310
+ for(i=0; i<sizeof(aAlnum)/sizeof(aAlnum[0]); i++){
311
+ if( ${zFunc}(i)!=aAlnum[i] ){
312
+ *piCode = i;
313
+ return 1;
314
+ }
315
+ }
316
+ for(i=0; i<sizeof(aLargeSep)/sizeof(aLargeSep[0]); i++){
317
+ if( ${zFunc}(aLargeSep[i])!=0 ){
318
+ *piCode = aLargeSep[i];
319
+ return 1;
320
+ }
321
+ }
322
+ for(i=0; i<sizeof(aLargeOther)/sizeof(aLargeOther[0]); i++){
323
+ if( ${zFunc}(aLargeOther[i])!=1 ){
324
+ *piCode = aLargeOther[i];
325
+ return 1;
326
+ }
327
+ }
328
+ }]
329
+ puts " return 0;"
330
+ puts "\}"
331
+ }
332
+
333
+ #-------------------------------------------------------------------------
334
+
335
+ proc tl_create_records {} {
336
+ global tl_lookup_table
337
+
338
+ set iFirst ""
339
+ set nOff 0
340
+ set nRange 0
341
+ set nIncr 0
342
+
343
+ set lRecord [list]
344
+ foreach code [lsort -integer [array names tl_lookup_table]] {
345
+ set mapping $tl_lookup_table($code)
346
+ if {$iFirst == ""} {
347
+ set iFirst $code
348
+ set nOff [expr $mapping - $code]
349
+ set nRange 1
350
+ set nIncr 1
351
+ } else {
352
+ set diff [expr $code - ($iFirst + ($nIncr * ($nRange - 1)))]
353
+ if { $nRange==1 && ($diff==1 || $diff==2) } {
354
+ set nIncr $diff
355
+ }
356
+
357
+ if {$diff != $nIncr || ($mapping - $code)!=$nOff} {
358
+ if { $nRange==1 } {set nIncr 1}
359
+ lappend lRecord [list $iFirst $nIncr $nRange $nOff]
360
+ set iFirst $code
361
+ set nOff [expr $mapping - $code]
362
+ set nRange 1
363
+ set nIncr 1
364
+ } else {
365
+ incr nRange
366
+ }
367
+ }
368
+ }
369
+
370
+ lappend lRecord [list $iFirst $nIncr $nRange $nOff]
371
+
372
+ set lRecord
373
+ }
374
+
375
+ proc tl_print_table_header {} {
376
+ puts -nonewline " "
377
+ puts [string trim {
378
+ /* Each entry in the following array defines a rule for folding a range
379
+ ** of codepoints to lower case. The rule applies to a range of nRange
380
+ ** codepoints starting at codepoint iCode.
381
+ **
382
+ ** If the least significant bit in flags is clear, then the rule applies
383
+ ** to all nRange codepoints (i.e. all nRange codepoints are upper case and
384
+ ** need to be folded). Or, if it is set, then the rule only applies to
385
+ ** every second codepoint in the range, starting with codepoint C.
386
+ **
387
+ ** The 7 most significant bits in flags are an index into the aiOff[]
388
+ ** array. If a specific codepoint C does require folding, then its lower
389
+ ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).
390
+ **
391
+ ** The contents of this array are generated by parsing the CaseFolding.txt
392
+ ** file distributed as part of the "Unicode Character Database". See
393
+ ** http://www.unicode.org for details.
394
+ */
395
+ }]
396
+ puts " static const struct TableEntry \{"
397
+ puts " unsigned short iCode;"
398
+ puts " unsigned char flags;"
399
+ puts " unsigned char nRange;"
400
+ puts " \} aEntry\[\] = \{"
401
+ }
402
+
403
+ proc tl_print_table_entry {togglevar entry liOff} {
404
+ upvar $togglevar t
405
+ foreach {iFirst nIncr nRange nOff} $entry {}
406
+
407
+ if {$iFirst > (1<<16)} { return 1 }
408
+
409
+ if {[info exists t]==0} {set t 0}
410
+ if {$t==0} { puts -nonewline " " }
411
+
412
+ set flags 0
413
+ if {$nIncr==2} { set flags 1 ; set nRange [expr $nRange * 2]}
414
+ if {$nOff<0} { incr nOff [expr (1<<16)] }
415
+
416
+ set idx [lsearch $liOff $nOff]
417
+ if {$idx<0} {error "malfunction generating aiOff"}
418
+ set flags [expr $flags + $idx*2]
419
+
420
+ set txt "{$iFirst, $flags, $nRange},"
421
+ if {$t==2} {
422
+ puts $txt
423
+ } else {
424
+ puts -nonewline [format "% -23s" $txt]
425
+ }
426
+ set t [expr ($t+1)%3]
427
+
428
+ return 0
429
+ }
430
+
431
+ proc tl_print_table_footer {togglevar} {
432
+ upvar $togglevar t
433
+ if {$t!=0} {puts ""}
434
+ puts " \};"
435
+ }
436
+
437
+ proc tl_print_if_entry {entry} {
438
+ foreach {iFirst nIncr nRange nOff} $entry {}
439
+ if {$nIncr==2} {error "tl_print_if_entry needs improvement!"}
440
+
441
+ puts " else if( c>=$iFirst && c<[expr $iFirst+$nRange] )\{"
442
+ puts " ret = c + $nOff;"
443
+ puts " \}"
444
+ }
445
+
446
+ proc tl_generate_ioff_table {lRecord} {
447
+ foreach entry $lRecord {
448
+ foreach {iFirst nIncr nRange iOff} $entry {}
449
+ if {$iOff<0} { incr iOff [expr (1<<16)] }
450
+ if {[info exists a($iOff)]} continue
451
+ set a($iOff) 1
452
+ }
453
+
454
+ set liOff [lsort -integer [array names a]]
455
+ if {[llength $liOff]>128} { error "Too many distinct ioffs" }
456
+ return $liOff
457
+ }
458
+
459
+ proc tl_print_ioff_table {liOff} {
460
+ puts -nonewline " static const unsigned short aiOff\[\] = \{"
461
+ set i 0
462
+ foreach off $liOff {
463
+ if {($i % 8)==0} {puts "" ; puts -nonewline " "}
464
+ puts -nonewline [format "% -7s" "$off,"]
465
+ incr i
466
+ }
467
+ puts ""
468
+ puts " \};"
469
+
470
+ }
471
+
472
+ proc print_fold {zFunc} {
473
+
474
+ set lRecord [tl_create_records]
475
+
476
+ set lHigh [list]
477
+ puts "/*"
478
+ puts "** Interpret the argument as a unicode codepoint. If the codepoint"
479
+ puts "** is an upper case character that has a lower case equivalent,"
480
+ puts "** return the codepoint corresponding to the lower case version."
481
+ puts "** Otherwise, return a copy of the argument."
482
+ puts "**"
483
+ puts "** The results are undefined if the value passed to this function"
484
+ puts "** is less than zero."
485
+ puts "*/"
486
+ puts "int ${zFunc}\(int c, int eRemoveDiacritic)\{"
487
+
488
+ set liOff [tl_generate_ioff_table $lRecord]
489
+ tl_print_table_header
490
+ foreach entry $lRecord {
491
+ if {[tl_print_table_entry toggle $entry $liOff]} {
492
+ lappend lHigh $entry
493
+ }
494
+ }
495
+ tl_print_table_footer toggle
496
+ tl_print_ioff_table $liOff
497
+
498
+ puts [subst -nocommands {
499
+ int ret = c;
500
+
501
+ assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );
502
+
503
+ if( c<128 ){
504
+ if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');
505
+ }else if( c<65536 ){
506
+ const struct TableEntry *p;
507
+ int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
508
+ int iLo = 0;
509
+ int iRes = -1;
510
+
511
+ assert( c>aEntry[0].iCode );
512
+ while( iHi>=iLo ){
513
+ int iTest = (iHi + iLo) / 2;
514
+ int cmp = (c - aEntry[iTest].iCode);
515
+ if( cmp>=0 ){
516
+ iRes = iTest;
517
+ iLo = iTest+1;
518
+ }else{
519
+ iHi = iTest-1;
520
+ }
521
+ }
522
+
523
+ assert( iRes>=0 && c>=aEntry[iRes].iCode );
524
+ p = &aEntry[iRes];
525
+ if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){
526
+ ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;
527
+ assert( ret>0 );
528
+ }
529
+
530
+ if( eRemoveDiacritic ){
531
+ ret = ${::remove_diacritic}(ret, eRemoveDiacritic==2);
532
+ }
533
+ }
534
+ }]
535
+
536
+ foreach entry $lHigh {
537
+ tl_print_if_entry $entry
538
+ }
539
+
540
+ puts ""
541
+ puts " return ret;"
542
+ puts "\}"
543
+ }
544
+
545
+ proc code {txt} {
546
+ set txt [string trimright $txt]
547
+ set txt [string trimleft $txt "\n"]
548
+ set n [expr {[string length $txt] - [string length [string trim $txt]]}]
549
+ set ret ""
550
+ foreach L [split $txt "\n"] {
551
+ append ret "[string range $L $n end]\n"
552
+ }
553
+ return [uplevel "subst -nocommands {$ret}"]
554
+ }
555
+
556
+ proc intarray {lInt} {
557
+ set ret ""
558
+ set n [llength $lInt]
559
+ for {set i 0} {$i < $n} {incr i 10} {
560
+ append ret "\n "
561
+ foreach int [lrange $lInt $i [expr $i+9]] {
562
+ append ret [format "%-7s" "$int, "]
563
+ }
564
+ }
565
+ append ret "\n "
566
+ set ret
567
+ }
568
+
569
+ proc categories_switch {Cvar first lSecond} {
570
+ upvar $Cvar C
571
+ set ret ""
572
+ append ret "case '$first':\n"
573
+ append ret " switch( zCat\[1\] ){\n"
574
+ foreach s $lSecond {
575
+ append ret " case '$s': aArray\[$C($first$s)\] = 1; break;\n"
576
+ }
577
+ append ret " case '*': \n"
578
+ foreach s $lSecond {
579
+ append ret " aArray\[$C($first$s)\] = 1;\n"
580
+ }
581
+ append ret " break;\n"
582
+ append ret " default: return 1;"
583
+ append ret " }\n"
584
+ append ret " break;\n"
585
+ }
586
+
587
+ # Argument is a list. Each element of which is itself a list of two elements:
588
+ #
589
+ # * the codepoint
590
+ # * the category
591
+ #
592
+ # List elements are sorted in order of codepoint.
593
+ #
594
+ proc print_categories {lMap} {
595
+ set categories {
596
+ Cc Cf Cn Cs
597
+ Ll Lm Lo Lt Lu
598
+ Mc Me Mn
599
+ Nd Nl No
600
+ Pc Pd Pe Pf Pi Po Ps
601
+ Sc Sk Sm So
602
+ Zl Zp Zs
603
+
604
+ LC Co
605
+ }
606
+
607
+ for {set i 0} {$i < [llength $categories]} {incr i} {
608
+ set C([lindex $categories $i]) [expr 1+$i]
609
+ }
610
+
611
+ set caseC [categories_switch C C {c f n s o}]
612
+ set caseL [categories_switch C L {l m o t u C}]
613
+ set caseM [categories_switch C M {c e n}]
614
+ set caseN [categories_switch C N {d l o}]
615
+ set caseP [categories_switch C P {c d e f i o s}]
616
+ set caseS [categories_switch C S {c k m o}]
617
+ set caseZ [categories_switch C Z {l p s}]
618
+
619
+ set nCat [expr [llength [array names C]] + 1]
620
+ puts [code {
621
+ int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
622
+ aArray[0] = 1;
623
+ switch( zCat[0] ){
624
+ $caseC
625
+ $caseL
626
+ $caseM
627
+ $caseN
628
+ $caseP
629
+ $caseS
630
+ $caseZ
631
+
632
+ default:
633
+ return 1;
634
+ }
635
+ return 0;
636
+ }
637
+ }]
638
+
639
+ set nRepeat 0
640
+ set first [lindex $lMap 0 0]
641
+ set class [lindex $lMap 0 1]
642
+ set prev -1
643
+
644
+ set CASE(0) "Lu"
645
+ set CASE(1) "Ll"
646
+
647
+ foreach m $lMap {
648
+ foreach {codepoint cl} $m {}
649
+ set codepoint [expr "0x$codepoint"]
650
+ if {$codepoint>=(1<<20)} continue
651
+
652
+ set bNew 0
653
+ if {$codepoint!=($prev+1)} {
654
+ set bNew 1
655
+ } elseif {
656
+ $cl==$class || ($class=="LC" && $cl==$CASE([expr $nRepeat & 0x01]))
657
+ } {
658
+ incr nRepeat
659
+ } elseif {$class=="Lu" && $nRepeat==1 && $cl=="Ll"} {
660
+ set class LC
661
+ incr nRepeat
662
+ } else {
663
+ set bNew 1
664
+ }
665
+ if {$bNew} {
666
+ lappend lEntries [list $first $class $nRepeat]
667
+ set nRepeat 1
668
+ set first $codepoint
669
+ set class $cl
670
+ }
671
+ set prev $codepoint
672
+ }
673
+ if {$nRepeat>0} {
674
+ lappend lEntries [list $first $class $nRepeat]
675
+ }
676
+
677
+ set aBlock [list 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
678
+ set aMap [list]
679
+ foreach e $lEntries {
680
+ foreach {cp class nRepeat} $e {}
681
+ set block [expr ($cp>>16)]
682
+ if {$block>0 && [lindex $aBlock $block]==0} {
683
+ for {set i 1} {$i<=$block} {incr i} {
684
+ if {[lindex $aBlock $i]==0} {
685
+ lset aBlock $i [llength $aMap]
686
+ }
687
+ }
688
+ }
689
+ lappend aMap [expr {$cp & 0xFFFF}]
690
+ lappend aData [expr {($nRepeat << 5) + $C($class)}]
691
+ }
692
+ for {set i 1} {$i<[llength $aBlock]} {incr i} {
693
+ if {[lindex $aBlock $i]==0} {
694
+ lset aBlock $i [llength $aMap]
695
+ }
696
+ }
697
+
698
+ set aBlockArray [intarray $aBlock]
699
+ set aMapArray [intarray $aMap]
700
+ set aDataArray [intarray $aData]
701
+ puts [code {
702
+ static u16 aFts5UnicodeBlock[] = {$aBlockArray};
703
+ static u16 aFts5UnicodeMap[] = {$aMapArray};
704
+ static u16 aFts5UnicodeData[] = {$aDataArray};
705
+
706
+ int sqlite3Fts5UnicodeCategory(u32 iCode) {
707
+ int iRes = -1;
708
+ int iHi;
709
+ int iLo;
710
+ int ret;
711
+ u16 iKey;
712
+
713
+ if( iCode>=(1<<20) ){
714
+ return 0;
715
+ }
716
+ iLo = aFts5UnicodeBlock[(iCode>>16)];
717
+ iHi = aFts5UnicodeBlock[1+(iCode>>16)];
718
+ iKey = (iCode & 0xFFFF);
719
+ while( iHi>iLo ){
720
+ int iTest = (iHi + iLo) / 2;
721
+ assert( iTest>=iLo && iTest<iHi );
722
+ if( iKey>=aFts5UnicodeMap[iTest] ){
723
+ iRes = iTest;
724
+ iLo = iTest+1;
725
+ }else{
726
+ iHi = iTest;
727
+ }
728
+ }
729
+
730
+ if( iRes<0 ) return 0;
731
+ if( iKey>=(aFts5UnicodeMap[iRes]+(aFts5UnicodeData[iRes]>>5)) ) return 0;
732
+ ret = aFts5UnicodeData[iRes] & 0x1F;
733
+ if( ret!=$C(LC) ) return ret;
734
+ return ((iKey - aFts5UnicodeMap[iRes]) & 0x01) ? $C(Ll) : $C(Lu);
735
+ }
736
+
737
+ void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){
738
+ int i = 0;
739
+ int iTbl = 0;
740
+ while( i<128 ){
741
+ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
742
+ int n = (aFts5UnicodeData[iTbl] >> 5) + i;
743
+ for(; i<128 && i<n; i++){
744
+ aAscii[i] = (u8)bToken;
745
+ }
746
+ iTbl++;
747
+ }
748
+ aAscii[0] = 0; /* 0x00 is never a token character */
749
+ }
750
+ }]
751
+ }
752
+
753
+ proc print_test_categories {lMap} {
754
+
755
+ set lCP [list]
756
+ foreach e $lMap {
757
+ foreach {cp cat} $e {}
758
+ if {[expr 0x$cp] < (1<<20)} {
759
+ lappend lCP "{0x$cp, \"$cat\"}, "
760
+ }
761
+ }
762
+
763
+ set aCP "\n"
764
+ for {set i 0} {$i < [llength $lCP]} {incr i 4} {
765
+ append aCP " [join [lrange $lCP $i $i+3]]\n"
766
+ }
767
+
768
+
769
+ puts [code {
770
+ static int categories_test (int *piCode){
771
+ struct Codepoint {
772
+ int iCode;
773
+ const char *zCat;
774
+ } aCP[] = {$aCP};
775
+ int i;
776
+ int iCP = 0;
777
+
778
+ for(i=0; i<1000000; i++){
779
+ u8 aArray[40];
780
+ int cat = 0;
781
+ int c = 0;
782
+ memset(aArray, 0, sizeof(aArray));
783
+ if( aCP[iCP].iCode==i ){
784
+ sqlite3Fts5UnicodeCatParse(aCP[iCP].zCat, aArray);
785
+ iCP++;
786
+ }else{
787
+ aArray[0] = 1;
788
+ }
789
+
790
+ c = sqlite3Fts5UnicodeCategory((u32)i);
791
+ if( aArray[c]==0 ){
792
+ *piCode = i;
793
+ return 1;
794
+ }
795
+ }
796
+
797
+ return 0;
798
+ }
799
+ }]
800
+ }
801
+
802
+ proc print_fold_test {zFunc mappings} {
803
+ global tl_lookup_table
804
+
805
+ foreach m $mappings {
806
+ set c [lindex $m 1]
807
+ if {$c == ""} {
808
+ set extra([lindex $m 0]) 0
809
+ } else {
810
+ scan $c %c i
811
+ set extra([lindex $m 0]) $i
812
+ }
813
+ }
814
+
815
+ puts "static int fold_test(int *piCode)\{"
816
+ puts -nonewline " static int aLookup\[\] = \{"
817
+ for {set i 0} {$i < 70000} {incr i} {
818
+
819
+ set expected $i
820
+ catch { set expected $tl_lookup_table($i) }
821
+ set expected2 $expected
822
+ catch { set expected2 $extra($expected2) }
823
+
824
+ if {($i % 4)==0} { puts "" ; puts -nonewline " " }
825
+ puts -nonewline "$expected, $expected2, "
826
+ }
827
+ puts " \};"
828
+ puts " int i;"
829
+ puts " for(i=0; i<sizeof(aLookup)/sizeof(aLookup\[0\]); i++)\{"
830
+ puts " int iCode = (i/2);"
831
+ puts " int bFlag = i & 0x0001;"
832
+ puts " if( ${zFunc}\(iCode, bFlag)!=aLookup\[i\] )\{"
833
+ puts " *piCode = iCode;"
834
+ puts " return 1;"
835
+ puts " \}"
836
+ puts " \}"
837
+ puts " return 0;"
838
+ puts "\}"
839
+ }
840
+
841
+
842
+ proc print_fileheader {} {
843
+ puts [string trim {
844
+ /*
845
+ ** 2012-05-25
846
+ **
847
+ ** The author disclaims copyright to this source code. In place of
848
+ ** a legal notice, here is a blessing:
849
+ **
850
+ ** May you do good and not evil.
851
+ ** May you find forgiveness for yourself and forgive others.
852
+ ** May you share freely, never taking more than you give.
853
+ **
854
+ ******************************************************************************
855
+ */
856
+
857
+ /*
858
+ ** DO NOT EDIT THIS MACHINE GENERATED FILE.
859
+ */
860
+ }]
861
+ puts ""
862
+ if {$::generate_fts5_code} {
863
+ # no-op
864
+ } else {
865
+ puts "#ifndef SQLITE_DISABLE_FTS3_UNICODE"
866
+ puts "#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)"
867
+ }
868
+ puts ""
869
+ puts "#include <assert.h>"
870
+ puts ""
871
+ }
872
+
873
+ proc print_test_main {} {
874
+ puts ""
875
+ puts "#include <stdio.h>"
876
+ puts ""
877
+ puts "int main(int argc, char **argv)\{"
878
+ puts " int r1, r2, r3;"
879
+ puts " int code;"
880
+ puts " r3 = 0;"
881
+ puts " r1 = isalnum_test(&code);"
882
+ puts " if( r1 ) printf(\"isalnum(): Problem with code %d\\n\",code);"
883
+ puts " else printf(\"isalnum(): test passed\\n\");"
884
+ puts " r2 = fold_test(&code);"
885
+ puts " if( r2 ) printf(\"fold(): Problem with code %d\\n\",code);"
886
+ puts " else printf(\"fold(): test passed\\n\");"
887
+ if {$::generate_fts5_code} {
888
+ puts " r3 = categories_test(&code);"
889
+ puts " if( r3 ) printf(\"categories(): Problem with code %d\\n\",code);"
890
+ puts " else printf(\"categories(): test passed\\n\");"
891
+ }
892
+ puts " return (r1 || r2 || r3);"
893
+ puts "\}"
894
+ }
895
+
896
+ # Proces the command line arguments. Exit early if they are not to
897
+ # our liking.
898
+ #
899
+ proc usage {} {
900
+ puts -nonewline stderr "Usage: $::argv0 ?-test? ?-fts5? "
901
+ puts stderr "<CaseFolding.txt file> <UnicodeData.txt file>"
902
+ exit 1
903
+ }
904
+ if {[llength $argv]<2} usage
905
+ set unicodedata.txt [lindex $argv end]
906
+ set casefolding.txt [lindex $argv end-1]
907
+
908
+ set remove_diacritic remove_diacritic
909
+ set generate_test_code 0
910
+ set generate_fts5_code 0
911
+ set function_prefix "sqlite3Fts"
912
+ for {set i 0} {$i < [llength $argv]-2} {incr i} {
913
+ switch -- [lindex $argv $i] {
914
+ -test {
915
+ set generate_test_code 1
916
+ }
917
+ -fts5 {
918
+ set function_prefix sqlite3Fts5
919
+ set generate_fts5_code 1
920
+ set remove_diacritic fts5_remove_diacritic
921
+ }
922
+ default {
923
+ usage
924
+ }
925
+ }
926
+ }
927
+
928
+ print_fileheader
929
+
930
+ if {$::generate_test_code} {
931
+ puts "typedef unsigned short int u16;"
932
+ puts "typedef unsigned char u8;"
933
+ puts "#include <string.h>"
934
+ }
935
+
936
+ # Print the isalnum() function to stdout.
937
+ #
938
+ set lRange [an_load_separator_ranges]
939
+ if {$generate_fts5_code==0} {
940
+ print_isalnum ${function_prefix}UnicodeIsalnum $lRange
941
+ }
942
+
943
+ # Leave a gap between the two generated C functions.
944
+ #
945
+ puts ""
946
+ puts ""
947
+
948
+ # Load the fold data. This is used by the [rd_XXX] commands
949
+ # as well as [print_fold].
950
+ tl_load_casefolding_txt ${casefolding.txt}
951
+
952
+ set mappings [rd_load_unicodedata_text ${unicodedata.txt}]
953
+ print_rd $mappings
954
+ puts ""
955
+ puts ""
956
+ print_isdiacritic ${function_prefix}UnicodeIsdiacritic $mappings
957
+ puts ""
958
+ puts ""
959
+
960
+ # Print the fold() function to stdout.
961
+ #
962
+ print_fold ${function_prefix}UnicodeFold
963
+
964
+ if {$generate_fts5_code} {
965
+ puts ""
966
+ puts ""
967
+ print_categories [cc_load_unicodedata_text ${unicodedata.txt}]
968
+ }
969
+
970
+ # Print the test routines and main() function to stdout, if -test
971
+ # was specified.
972
+ #
973
+ if {$::generate_test_code} {
974
+ if {$generate_fts5_code==0} {
975
+ print_test_isalnum ${function_prefix}UnicodeIsalnum $lRange
976
+ }
977
+ print_fold_test ${function_prefix}UnicodeFold $mappings
978
+ print_test_categories [cc_load_unicodedata_text ${unicodedata.txt}]
979
+ print_test_main
980
+ }
981
+
982
+ if {$generate_fts5_code} {
983
+ # no-op
984
+ } else {
985
+ puts "#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */"
986
+ puts "#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */"
987
+ }
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest.h ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #ifndef __WRAPPER_INT_H_
3
+ #define __WRAPPER_INT_H_
4
+
5
+ #include "lsmtest_tdb.h"
6
+ #include "sqlite3.h"
7
+ #include "lsm.h"
8
+
9
+ #include <assert.h>
10
+ #include <stdarg.h>
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include <stdio.h>
14
+ #ifndef _WIN32
15
+ # include <unistd.h>
16
+ #endif
17
+ #include <sys/types.h>
18
+ #include <sys/stat.h>
19
+ #include <fcntl.h>
20
+ #include <ctype.h>
21
+ #include <stdlib.h>
22
+ #include <errno.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ #ifdef _WIN32
29
+ # include "windows.h"
30
+ # define gettimeofday win32GetTimeOfDay
31
+ # define F_OK (0)
32
+ # define sleep(sec) Sleep(1000 * (sec))
33
+ # define usleep(usec) Sleep(((usec) + 999) / 1000)
34
+ # ifdef _MSC_VER
35
+ # include <io.h>
36
+ # define snprintf _snprintf
37
+ # define fsync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))
38
+ # define fdatasync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))
39
+ # define __va_copy(dst,src) ((dst) = (src))
40
+ # define ftruncate(fd,sz) ((_chsize_s((fd), (sz))==0) ? 0 : -1)
41
+ # else
42
+ # error Unsupported C compiler for Windows.
43
+ # endif
44
+ int win32GetTimeOfDay(struct timeval *, void *);
45
+ #endif
46
+
47
+ #ifndef _LSM_INT_H
48
+ typedef unsigned int u32;
49
+ typedef unsigned char u8;
50
+ typedef long long int i64;
51
+ typedef unsigned long long int u64;
52
+ #endif
53
+
54
+
55
+ #define ArraySize(x) ((int)(sizeof(x) / sizeof((x)[0])))
56
+
57
+ #define MIN(x,y) ((x)<(y) ? (x) : (y))
58
+ #define MAX(x,y) ((x)>(y) ? (x) : (y))
59
+
60
+ #define unused_parameter(x) (void)(x)
61
+
62
+ #define TESTDB_DEFAULT_PAGE_SIZE 4096
63
+ #define TESTDB_DEFAULT_CACHE_SIZE 2048
64
+
65
+ #ifndef _O_BINARY
66
+ # define _O_BINARY (0)
67
+ #endif
68
+
69
+ /*
70
+ ** Ideally, these should be in wrapper.c. But they are here instead so that
71
+ ** they can be used by the C++ database wrappers in wrapper2.cc.
72
+ */
73
+ typedef struct DatabaseMethods DatabaseMethods;
74
+ struct TestDb {
75
+ DatabaseMethods const *pMethods; /* Database methods */
76
+ const char *zLibrary; /* Library name for tdb_open() */
77
+ };
78
+ struct DatabaseMethods {
79
+ int (*xClose)(TestDb *);
80
+ int (*xWrite)(TestDb *, void *, int , void *, int);
81
+ int (*xDelete)(TestDb *, void *, int);
82
+ int (*xDeleteRange)(TestDb *, void *, int, void *, int);
83
+ int (*xFetch)(TestDb *, void *, int, void **, int *);
84
+ int (*xScan)(TestDb *, void *, int, void *, int, void *, int,
85
+ void (*)(void *, void *, int , void *, int)
86
+ );
87
+ int (*xBegin)(TestDb *, int);
88
+ int (*xCommit)(TestDb *, int);
89
+ int (*xRollback)(TestDb *, int);
90
+ };
91
+
92
+ /*
93
+ ** Functions in wrapper2.cc (a C++ source file). wrapper2.cc contains the
94
+ ** wrapper for Kyoto Cabinet. Kyoto cabinet has a C API, but
95
+ ** the primary interface is the C++ API.
96
+ */
97
+ int test_kc_open(const char*, const char *zFilename, int bClear, TestDb **ppDb);
98
+ int test_kc_close(TestDb *);
99
+ int test_kc_write(TestDb *, void *, int , void *, int);
100
+ int test_kc_delete(TestDb *, void *, int);
101
+ int test_kc_delete_range(TestDb *, void *, int, void *, int);
102
+ int test_kc_fetch(TestDb *, void *, int, void **, int *);
103
+ int test_kc_scan(TestDb *, void *, int, void *, int, void *, int,
104
+ void (*)(void *, void *, int , void *, int)
105
+ );
106
+
107
+ int test_mdb_open(const char*, const char *zFile, int bClear, TestDb **ppDb);
108
+ int test_mdb_close(TestDb *);
109
+ int test_mdb_write(TestDb *, void *, int , void *, int);
110
+ int test_mdb_delete(TestDb *, void *, int);
111
+ int test_mdb_fetch(TestDb *, void *, int, void **, int *);
112
+ int test_mdb_scan(TestDb *, void *, int, void *, int, void *, int,
113
+ void (*)(void *, void *, int , void *, int)
114
+ );
115
+
116
+ /*
117
+ ** Functions in wrapper3.c. This file contains the tdb wrapper for lsm.
118
+ ** The wrapper for lsm is a bit more involved than the others, as it
119
+ ** includes code for a couple of different lsm configurations, and for
120
+ ** various types of fault injection and robustness testing.
121
+ */
122
+ int test_lsm_open(const char*, const char *zFile, int bClear, TestDb **ppDb);
123
+ int test_lsm_lomem_open(const char*, const char*, int bClear, TestDb **ppDb);
124
+ int test_lsm_lomem2_open(const char*, const char*, int bClear, TestDb **ppDb);
125
+ int test_lsm_zip_open(const char*, const char*, int bClear, TestDb **ppDb);
126
+ int test_lsm_small_open(const char*, const char*, int bClear, TestDb **ppDb);
127
+ int test_lsm_mt2(const char*, const char *zFile, int bClear, TestDb **ppDb);
128
+ int test_lsm_mt3(const char*, const char *zFile, int bClear, TestDb **ppDb);
129
+
130
+ int tdb_lsm_configure(lsm_db *, const char *);
131
+
132
+ /* Functions in lsmtest_tdb4.c */
133
+ int test_bt_open(const char*, const char *zFile, int bClear, TestDb **ppDb);
134
+ int test_fbt_open(const char*, const char *zFile, int bClear, TestDb **ppDb);
135
+ int test_fbts_open(const char*, const char *zFile, int bClear, TestDb **ppDb);
136
+
137
+
138
+ /* Functions in testutil.c. */
139
+ int testPrngInit(void);
140
+ u32 testPrngValue(u32 iVal);
141
+ void testPrngArray(u32 iVal, u32 *aOut, int nOut);
142
+ void testPrngString(u32 iVal, char *aOut, int nOut);
143
+
144
+ void testErrorInit(int argc, char **);
145
+ void testPrintError(const char *zFormat, ...);
146
+ void testPrintUsage(const char *zArgs);
147
+ void testPrintFUsage(const char *zFormat, ...);
148
+ void testTimeInit(void);
149
+ int testTimeGet(void);
150
+
151
+ /* Functions in testmem.c. */
152
+ void testMallocInstall(lsm_env *pEnv);
153
+ void testMallocUninstall(lsm_env *pEnv);
154
+ void testMallocCheck(lsm_env *pEnv, int *, int *, FILE *);
155
+ void testMallocOom(lsm_env *pEnv, int, int, void(*)(void*), void *);
156
+ void testMallocOomEnable(lsm_env *pEnv, int);
157
+
158
+ /* lsmtest.c */
159
+ TestDb *testOpen(const char *zSystem, int, int *pRc);
160
+ void testReopen(TestDb **ppDb, int *pRc);
161
+ void testClose(TestDb **ppDb);
162
+
163
+ void testFetch(TestDb *, void *, int, void *, int, int *);
164
+ void testWrite(TestDb *, void *, int, void *, int, int *);
165
+ void testDelete(TestDb *, void *, int, int *);
166
+ void testDeleteRange(TestDb *, void *, int, void *, int, int *);
167
+ void testWriteStr(TestDb *, const char *, const char *zVal, int *pRc);
168
+ void testFetchStr(TestDb *, const char *, const char *, int *pRc);
169
+
170
+ void testBegin(TestDb *pDb, int iTrans, int *pRc);
171
+ void testCommit(TestDb *pDb, int iTrans, int *pRc);
172
+
173
+ void test_failed(void);
174
+
175
+ char *testMallocPrintf(const char *zFormat, ...);
176
+ char *testMallocVPrintf(const char *zFormat, va_list ap);
177
+ int testGlobMatch(const char *zPattern, const char *zStr);
178
+
179
+ void testScanCompare(TestDb *, TestDb *, int, void *, int, void *, int, int *);
180
+ void testFetchCompare(TestDb *, TestDb *, void *, int, int *);
181
+
182
+ void *testMalloc(int);
183
+ void *testMallocCopy(void *pCopy, int nByte);
184
+ void *testRealloc(void *, int);
185
+ void testFree(void *);
186
+
187
+ /* lsmtest_bt.c */
188
+ int do_bt(int nArg, char **azArg);
189
+
190
+ /* testio.c */
191
+ int testVfsConfigureDb(TestDb *pDb);
192
+
193
+ /* testfunc.c */
194
+ int do_show(int nArg, char **azArg);
195
+ int do_work(int nArg, char **azArg);
196
+
197
+ /* testio.c */
198
+ int do_io(int nArg, char **azArg);
199
+
200
+ /* lsmtest2.c */
201
+ void do_crash_test(const char *zPattern, int *pRc);
202
+ int do_rollback_test(int nArg, char **azArg);
203
+
204
+ /* test3.c */
205
+ void test_rollback(const char *zSystem, const char *zPattern, int *pRc);
206
+
207
+ /* test4.c */
208
+ void test_mc(const char *zSystem, const char *zPattern, int *pRc);
209
+
210
+ /* test5.c */
211
+ void test_mt(const char *zSystem, const char *zPattern, int *pRc);
212
+
213
+ /* lsmtest6.c */
214
+ void test_oom(const char *zPattern, int *pRc);
215
+ void testDeleteLsmdb(const char *zFile);
216
+
217
+ void testSaveDb(const char *zFile, const char *zAuxExt);
218
+ void testRestoreDb(const char *zFile, const char *zAuxExt);
219
+ void testCopyLsmdb(const char *zFrom, const char *zTo);
220
+
221
+ /* lsmtest7.c */
222
+ void test_api(const char *zPattern, int *pRc);
223
+
224
+ /* lsmtest8.c */
225
+ void do_writer_crash_test(const char *zPattern, int *pRc);
226
+
227
+ /*************************************************************************
228
+ ** Interface to functionality in test_datasource.c.
229
+ */
230
+ typedef struct Datasource Datasource;
231
+ typedef struct DatasourceDefn DatasourceDefn;
232
+
233
+ struct DatasourceDefn {
234
+ int eType; /* A TEST_DATASOURCE_* value */
235
+ int nMinKey; /* Minimum key size */
236
+ int nMaxKey; /* Maximum key size */
237
+ int nMinVal; /* Minimum value size */
238
+ int nMaxVal; /* Maximum value size */
239
+ };
240
+
241
+ #define TEST_DATASOURCE_RANDOM 1
242
+ #define TEST_DATASOURCE_SEQUENCE 2
243
+
244
+ char *testDatasourceName(const DatasourceDefn *);
245
+ Datasource *testDatasourceNew(const DatasourceDefn *);
246
+ void testDatasourceFree(Datasource *);
247
+ void testDatasourceEntry(Datasource *, int, void **, int *, void **, int *);
248
+ /* End of test_datasource.c interface.
249
+ *************************************************************************/
250
+ void testDatasourceFetch(
251
+ TestDb *pDb, /* Database handle */
252
+ Datasource *pData,
253
+ int iKey,
254
+ int *pRc /* IN/OUT: Error code */
255
+ );
256
+
257
+ void testWriteDatasource(TestDb *, Datasource *, int, int *);
258
+ void testWriteDatasourceRange(TestDb *, Datasource *, int, int, int *);
259
+ void testDeleteDatasource(TestDb *, Datasource *, int, int *);
260
+ void testDeleteDatasourceRange(TestDb *, Datasource *, int, int, int *);
261
+
262
+
263
+ /* test1.c */
264
+ void test_data_1(const char *, const char *, int *pRc);
265
+ void test_data_2(const char *, const char *, int *pRc);
266
+ void test_data_3(const char *, const char *, int *pRc);
267
+ void testDbContents(TestDb *, Datasource *, int, int, int, int, int, int *);
268
+ void testCaseProgress(int, int, int, int *);
269
+ int testCaseNDot(void);
270
+
271
+ void testCompareDb(Datasource *, int, int, TestDb *, TestDb *, int *);
272
+ int testControlDb(TestDb **ppDb);
273
+
274
+ typedef struct CksumDb CksumDb;
275
+ CksumDb *testCksumArrayNew(Datasource *, int, int, int);
276
+ char *testCksumArrayGet(CksumDb *, int);
277
+ void testCksumArrayFree(CksumDb *);
278
+ void testCaseStart(int *pRc, char *zFmt, ...);
279
+ void testCaseFinish(int rc);
280
+ void testCaseSkip(void);
281
+ int testCaseBegin(int *, const char *, const char *, ...);
282
+
283
+ #define TEST_CKSUM_BYTES 29
284
+ int testCksumDatabase(TestDb *pDb, char *zOut);
285
+ int testCountDatabase(TestDb *pDb);
286
+ void testCompareInt(int, int, int *);
287
+ void testCompareStr(const char *z1, const char *z2, int *pRc);
288
+
289
+ /* lsmtest9.c */
290
+ void test_data_4(const char *, const char *, int *pRc);
291
+
292
+
293
+ /*
294
+ ** Similar to the Tcl_GetIndexFromObjStruct() Tcl library function.
295
+ */
296
+ #define testArgSelect(w,x,y,z) testArgSelectX(w,x,sizeof(w[0]),y,z)
297
+ int testArgSelectX(void *, const char *, int, const char *, int *);
298
+
299
+ #ifdef __cplusplus
300
+ } /* End of the 'extern "C"' block */
301
+ #endif
302
+
303
+ #endif
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest1.c ADDED
@@ -0,0 +1,656 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #include "lsmtest.h"
3
+
4
+ #define DATA_SEQUENTIAL TEST_DATASOURCE_SEQUENCE
5
+ #define DATA_RANDOM TEST_DATASOURCE_RANDOM
6
+
7
+ typedef struct Datatest1 Datatest1;
8
+ typedef struct Datatest2 Datatest2;
9
+
10
+ /*
11
+ ** An instance of the following structure contains parameters used to
12
+ ** customize the test function in this file. Test procedure:
13
+ **
14
+ ** 1. Create a data-source based on the "datasource definition" vars.
15
+ **
16
+ ** 2. Insert nRow key value pairs into the database.
17
+ **
18
+ ** 3. Delete all keys from the database. Deletes are done in the same
19
+ ** order as the inserts.
20
+ **
21
+ ** During steps 2 and 3 above, after each Datatest1.nVerify inserts or
22
+ ** deletes, the following:
23
+ **
24
+ ** a. Run Datasource.nTest key lookups and check the results are as expected.
25
+ **
26
+ ** b. If Datasource.bTestScan is true, run a handful (8) of range
27
+ ** queries (scanning forwards and backwards). Check that the results
28
+ ** are as expected.
29
+ **
30
+ ** c. Close and reopen the database. Then run (a) and (b) again.
31
+ */
32
+ struct Datatest1 {
33
+ /* Datasource definition */
34
+ DatasourceDefn defn;
35
+
36
+ /* Test procedure parameters */
37
+ int nRow; /* Number of rows to insert then delete */
38
+ int nVerify; /* How often to verify the db contents */
39
+ int nTest; /* Number of keys to test (0==all) */
40
+ int bTestScan; /* True to do scan tests */
41
+ };
42
+
43
+ /*
44
+ ** An instance of the following data structure is used to describe the
45
+ ** second type of test case in this file. The chief difference between
46
+ ** these tests and those described by Datatest1 is that these tests also
47
+ ** experiment with range-delete operations. Tests proceed as follows:
48
+ **
49
+ ** 1. Open the datasource described by Datatest2.defn.
50
+ **
51
+ ** 2. Open a connection on an empty database.
52
+ **
53
+ ** 3. Do this Datatest2.nIter times:
54
+ **
55
+ ** a) Insert Datatest2.nWrite key-value pairs from the datasource.
56
+ **
57
+ ** b) Select two pseudo-random keys and use them as the start
58
+ ** and end points of a range-delete operation.
59
+ **
60
+ ** c) Verify that the contents of the database are as expected (see
61
+ ** below for details).
62
+ **
63
+ ** d) Close and then reopen the database handle.
64
+ **
65
+ ** e) Verify that the contents of the database are still as expected.
66
+ **
67
+ ** The inserts and range deletes are run twice - once on the database being
68
+ ** tested and once using a control system (sqlite3, kc etc. - something that
69
+ ** works). In order to verify that the contents of the db being tested are
70
+ ** correct, the test runs a bunch of scans and lookups on both the test and
71
+ ** control databases. If the results are the same, the test passes.
72
+ */
73
+ struct Datatest2 {
74
+ DatasourceDefn defn;
75
+ int nRange;
76
+ int nWrite; /* Number of writes per iteration */
77
+ int nIter; /* Total number of iterations to run */
78
+ };
79
+
80
+ /*
81
+ ** Generate a unique name for the test case pTest with database system
82
+ ** zSystem.
83
+ */
84
+ static char *getName(const char *zSystem, int bRecover, Datatest1 *pTest){
85
+ char *zRet;
86
+ char *zData;
87
+ zData = testDatasourceName(&pTest->defn);
88
+ zRet = testMallocPrintf("data.%s.%s.rec=%d.%d.%d",
89
+ zSystem, zData, bRecover, pTest->nRow, pTest->nVerify
90
+ );
91
+ testFree(zData);
92
+ return zRet;
93
+ }
94
+
95
+ int testControlDb(TestDb **ppDb){
96
+ #ifdef HAVE_KYOTOCABINET
97
+ return tdb_open("kyotocabinet", "tmp.db", 1, ppDb);
98
+ #else
99
+ return tdb_open("sqlite3", "", 1, ppDb);
100
+ #endif
101
+ }
102
+
103
+ void testDatasourceFetch(
104
+ TestDb *pDb, /* Database handle */
105
+ Datasource *pData,
106
+ int iKey,
107
+ int *pRc /* IN/OUT: Error code */
108
+ ){
109
+ void *pKey; int nKey; /* Database key to query for */
110
+ void *pVal; int nVal; /* Expected result of query */
111
+
112
+ testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);
113
+ testFetch(pDb, pKey, nKey, pVal, nVal, pRc);
114
+ }
115
+
116
+ /*
117
+ ** This function is called to test that the contents of database pDb
118
+ ** are as expected. In this case, expected is defined as containing
119
+ ** key-value pairs iFirst through iLast, inclusive, from data source
120
+ ** pData. In other words, a loop like the following could be used to
121
+ ** construct a database with identical contents from scratch.
122
+ **
123
+ ** for(i=iFirst; i<=iLast; i++){
124
+ ** testDatasourceEntry(pData, i, &pKey, &nKey, &pVal, &nVal);
125
+ ** // insert (pKey, nKey) -> (pVal, nVal) into database
126
+ ** }
127
+ **
128
+ ** The key domain consists of keys 0 to (nRow-1), inclusive, from
129
+ ** data source pData. For both scan and lookup tests, keys are selected
130
+ ** pseudo-randomly from within this set.
131
+ **
132
+ ** This function runs nLookupTest lookup tests and nScanTest scan tests.
133
+ **
134
+ ** A lookup test consists of selecting a key from the domain and querying
135
+ ** pDb for it. The test fails if the presence of the key and, if present,
136
+ ** the associated value do not match the expectations defined above.
137
+ **
138
+ ** A scan test involves selecting a key from the domain and running
139
+ ** the following queries:
140
+ **
141
+ ** 1. Scan all keys equal to or greater than the key, in ascending order.
142
+ ** 2. Scan all keys equal to or smaller than the key, in descending order.
143
+ **
144
+ ** Additionally, if nLookupTest is greater than zero, the following are
145
+ ** run once:
146
+ **
147
+ ** 1. Scan all keys in the db, in ascending order.
148
+ ** 2. Scan all keys in the db, in descending order.
149
+ **
150
+ ** As you would assume, the test fails if the returned values do not match
151
+ ** expectations.
152
+ */
153
+ void testDbContents(
154
+ TestDb *pDb, /* Database handle being tested */
155
+ Datasource *pData, /* pDb contains data from here */
156
+ int nRow, /* Size of key domain */
157
+ int iFirst, /* Index of first key from pData in pDb */
158
+ int iLast, /* Index of last key from pData in pDb */
159
+ int nLookupTest, /* Number of lookup tests to run */
160
+ int nScanTest, /* Number of scan tests to run */
161
+ int *pRc /* IN/OUT: Error code */
162
+ ){
163
+ int j;
164
+ int rc = *pRc;
165
+
166
+ if( rc==0 && nScanTest ){
167
+ TestDb *pDb2 = 0;
168
+
169
+ /* Open a control db (i.e. one that we assume works) */
170
+ rc = testControlDb(&pDb2);
171
+
172
+ for(j=iFirst; rc==0 && j<=iLast; j++){
173
+ void *pKey; int nKey; /* Database key to insert */
174
+ void *pVal; int nVal; /* Database value to insert */
175
+ testDatasourceEntry(pData, j, &pKey, &nKey, &pVal, &nVal);
176
+ rc = tdb_write(pDb2, pKey, nKey, pVal, nVal);
177
+ }
178
+
179
+ if( rc==0 ){
180
+ int iKey1;
181
+ int iKey2;
182
+ void *pKey1; int nKey1; /* Start key */
183
+ void *pKey2; int nKey2; /* Final key */
184
+
185
+ iKey1 = testPrngValue((iFirst<<8) + (iLast<<16)) % nRow;
186
+ iKey2 = testPrngValue((iLast<<8) + (iFirst<<16)) % nRow;
187
+ testDatasourceEntry(pData, iKey1, &pKey2, &nKey1, 0, 0);
188
+ pKey1 = testMalloc(nKey1+1);
189
+ memcpy(pKey1, pKey2, nKey1+1);
190
+ testDatasourceEntry(pData, iKey2, &pKey2, &nKey2, 0, 0);
191
+
192
+ testScanCompare(pDb2, pDb, 0, 0, 0, 0, 0, &rc);
193
+ testScanCompare(pDb2, pDb, 0, 0, 0, pKey2, nKey2, &rc);
194
+ testScanCompare(pDb2, pDb, 0, pKey1, nKey1, 0, 0, &rc);
195
+ testScanCompare(pDb2, pDb, 0, pKey1, nKey1, pKey2, nKey2, &rc);
196
+ testScanCompare(pDb2, pDb, 1, 0, 0, 0, 0, &rc);
197
+ testScanCompare(pDb2, pDb, 1, 0, 0, pKey2, nKey2, &rc);
198
+ testScanCompare(pDb2, pDb, 1, pKey1, nKey1, 0, 0, &rc);
199
+ testScanCompare(pDb2, pDb, 1, pKey1, nKey1, pKey2, nKey2, &rc);
200
+ testFree(pKey1);
201
+ }
202
+ tdb_close(pDb2);
203
+ }
204
+
205
+ /* Test some lookups. */
206
+ for(j=0; rc==0 && j<nLookupTest; j++){
207
+ int iKey; /* Datasource key to test */
208
+ void *pKey; int nKey; /* Database key to query for */
209
+ void *pVal; int nVal; /* Expected result of query */
210
+
211
+ if( nLookupTest>=nRow ){
212
+ iKey = j;
213
+ }else{
214
+ iKey = testPrngValue(j + (iFirst<<8) + (iLast<<16)) % nRow;
215
+ }
216
+
217
+ testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);
218
+ if( iFirst>iKey || iKey>iLast ){
219
+ pVal = 0;
220
+ nVal = -1;
221
+ }
222
+
223
+ testFetch(pDb, pKey, nKey, pVal, nVal, &rc);
224
+ }
225
+
226
+ *pRc = rc;
227
+ }
228
+
229
+ /*
230
+ ** This function should be called during long running test cases to output
231
+ ** the progress dots (...) to stdout.
232
+ */
233
+ void testCaseProgress(int i, int n, int nDot, int *piDot){
234
+ int iDot = *piDot;
235
+ while( iDot < ( ((nDot*2+1) * i) / (n*2) ) ){
236
+ printf(".");
237
+ fflush(stdout);
238
+ iDot++;
239
+ }
240
+ *piDot = iDot;
241
+ }
242
+
243
+ int testCaseNDot(void){ return 20; }
244
+
245
+ #if 0
246
+ static void printScanCb(
247
+ void *pCtx, void *pKey, int nKey, void *pVal, int nVal
248
+ ){
249
+ printf("%s\n", (char *)pKey);
250
+ fflush(stdout);
251
+ }
252
+ #endif
253
+
254
+ void testReopenRecover(TestDb **ppDb, int *pRc){
255
+ if( *pRc==0 ){
256
+ const char *zLib = tdb_library_name(*ppDb);
257
+ const char *zDflt = tdb_default_db(zLib);
258
+ testCopyLsmdb(zDflt, "bak.db");
259
+ testClose(ppDb);
260
+ testCopyLsmdb("bak.db", zDflt);
261
+ *pRc = tdb_open(zLib, 0, 0, ppDb);
262
+ }
263
+ }
264
+
265
+
266
+ static void doDataTest1(
267
+ const char *zSystem, /* Database system to test */
268
+ int bRecover,
269
+ Datatest1 *p, /* Structure containing test parameters */
270
+ int *pRc /* OUT: Error code */
271
+ ){
272
+ int i;
273
+ int iDot;
274
+ int rc = LSM_OK;
275
+ Datasource *pData;
276
+ TestDb *pDb;
277
+ int iToggle = 0;
278
+
279
+ /* Start the test case, open a database and allocate the datasource. */
280
+ pDb = testOpen(zSystem, 1, &rc);
281
+ pData = testDatasourceNew(&p->defn);
282
+
283
+ i = 0;
284
+ iDot = 0;
285
+ while( rc==LSM_OK && i<p->nRow ){
286
+
287
+ /* Insert some data */
288
+ testWriteDatasourceRange(pDb, pData, i, p->nVerify, &rc);
289
+ i += p->nVerify;
290
+
291
+ if( iToggle ) testBegin(pDb, 1, &rc);
292
+ /* Check that the db content is correct. */
293
+ testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);
294
+ if( iToggle ) testCommit(pDb, 0, &rc);
295
+ iToggle = (iToggle+1)%2;
296
+
297
+ if( bRecover ){
298
+ testReopenRecover(&pDb, &rc);
299
+ }else{
300
+ testReopen(&pDb, &rc);
301
+ }
302
+
303
+ /* Check that the db content is still correct. */
304
+ testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);
305
+
306
+ /* Update the progress dots... */
307
+ testCaseProgress(i, p->nRow, testCaseNDot()/2, &iDot);
308
+ }
309
+
310
+ i = 0;
311
+ iDot = 0;
312
+ while( rc==LSM_OK && i<p->nRow ){
313
+
314
+ /* Delete some entries */
315
+ testDeleteDatasourceRange(pDb, pData, i, p->nVerify, &rc);
316
+ i += p->nVerify;
317
+
318
+ /* Check that the db content is correct. */
319
+ testDbContents(pDb, pData, p->nRow, i, p->nRow-1,p->nTest,p->bTestScan,&rc);
320
+
321
+ /* Close and reopen the database. */
322
+ if( bRecover ){
323
+ testReopenRecover(&pDb, &rc);
324
+ }else{
325
+ testReopen(&pDb, &rc);
326
+ }
327
+
328
+ /* Check that the db content is still correct. */
329
+ testDbContents(pDb, pData, p->nRow, i, p->nRow-1,p->nTest,p->bTestScan,&rc);
330
+
331
+ /* Update the progress dots... */
332
+ testCaseProgress(i, p->nRow, testCaseNDot()/2, &iDot);
333
+ }
334
+
335
+ /* Free the datasource, close the database and finish the test case. */
336
+ testDatasourceFree(pData);
337
+ tdb_close(pDb);
338
+ testCaseFinish(rc);
339
+ *pRc = rc;
340
+ }
341
+
342
+
343
+ void test_data_1(
344
+ const char *zSystem, /* Database system name */
345
+ const char *zPattern, /* Run test cases that match this pattern */
346
+ int *pRc /* IN/OUT: Error code */
347
+ ){
348
+ Datatest1 aTest[] = {
349
+ { {DATA_RANDOM, 500,600, 1000,2000}, 1000, 100, 10, 0},
350
+ { {DATA_RANDOM, 20,25, 100,200}, 1000, 250, 1000, 1},
351
+ { {DATA_RANDOM, 8,10, 100,200}, 1000, 250, 1000, 1},
352
+ { {DATA_RANDOM, 8,10, 10,20}, 1000, 250, 1000, 1},
353
+ { {DATA_RANDOM, 8,10, 1000,2000}, 1000, 250, 1000, 1},
354
+ { {DATA_RANDOM, 8,100, 10000,20000}, 100, 25, 100, 1},
355
+ { {DATA_RANDOM, 80,100, 10,20}, 1000, 250, 1000, 1},
356
+ { {DATA_RANDOM, 5000,6000, 10,20}, 100, 25, 100, 1},
357
+ { {DATA_SEQUENTIAL, 5,10, 10,20}, 1000, 250, 1000, 1},
358
+ { {DATA_SEQUENTIAL, 5,10, 100,200}, 1000, 250, 1000, 1},
359
+ { {DATA_SEQUENTIAL, 5,10, 1000,2000}, 1000, 250, 1000, 1},
360
+ { {DATA_SEQUENTIAL, 5,100, 10000,20000}, 100, 25, 100, 1},
361
+ { {DATA_RANDOM, 10,10, 100,100}, 100000, 1000, 100, 0},
362
+ { {DATA_SEQUENTIAL, 10,10, 100,100}, 100000, 1000, 100, 0},
363
+ };
364
+
365
+ int i;
366
+ int bRecover;
367
+
368
+ for(bRecover=0; bRecover<2; bRecover++){
369
+ if( bRecover==1 && memcmp(zSystem, "lsm", 3) ) break;
370
+ for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){
371
+ char *zName = getName(zSystem, bRecover, &aTest[i]);
372
+ if( testCaseBegin(pRc, zPattern, "%s", zName) ){
373
+ doDataTest1(zSystem, bRecover, &aTest[i], pRc);
374
+ }
375
+ testFree(zName);
376
+ }
377
+ }
378
+ }
379
+
380
+ void testCompareDb(
381
+ Datasource *pData,
382
+ int nData,
383
+ int iSeed,
384
+ TestDb *pControl,
385
+ TestDb *pDb,
386
+ int *pRc
387
+ ){
388
+ int i;
389
+
390
+ static int nCall = 0;
391
+ nCall++;
392
+
393
+ testScanCompare(pControl, pDb, 0, 0, 0, 0, 0, pRc);
394
+ testScanCompare(pControl, pDb, 1, 0, 0, 0, 0, pRc);
395
+
396
+ if( *pRc==0 ){
397
+ int iKey1;
398
+ int iKey2;
399
+ void *pKey1; int nKey1; /* Start key */
400
+ void *pKey2; int nKey2; /* Final key */
401
+
402
+ iKey1 = testPrngValue(iSeed) % nData;
403
+ iKey2 = testPrngValue(iSeed+1) % nData;
404
+ testDatasourceEntry(pData, iKey1, &pKey2, &nKey1, 0, 0);
405
+ pKey1 = testMalloc(nKey1+1);
406
+ memcpy(pKey1, pKey2, nKey1+1);
407
+ testDatasourceEntry(pData, iKey2, &pKey2, &nKey2, 0, 0);
408
+
409
+ testScanCompare(pControl, pDb, 0, 0, 0, pKey2, nKey2, pRc);
410
+ testScanCompare(pControl, pDb, 0, pKey1, nKey1, 0, 0, pRc);
411
+ testScanCompare(pControl, pDb, 0, pKey1, nKey1, pKey2, nKey2, pRc);
412
+ testScanCompare(pControl, pDb, 1, 0, 0, pKey2, nKey2, pRc);
413
+ testScanCompare(pControl, pDb, 1, pKey1, nKey1, 0, 0, pRc);
414
+ testScanCompare(pControl, pDb, 1, pKey1, nKey1, pKey2, nKey2, pRc);
415
+ testFree(pKey1);
416
+ }
417
+
418
+ for(i=0; i<nData && *pRc==0; i++){
419
+ void *pKey; int nKey;
420
+ testDatasourceEntry(pData, i, &pKey, &nKey, 0, 0);
421
+ testFetchCompare(pControl, pDb, pKey, nKey, pRc);
422
+ }
423
+ }
424
+
425
+ static void doDataTest2(
426
+ const char *zSystem, /* Database system to test */
427
+ int bRecover,
428
+ Datatest2 *p, /* Structure containing test parameters */
429
+ int *pRc /* OUT: Error code */
430
+ ){
431
+ TestDb *pDb;
432
+ TestDb *pControl;
433
+ Datasource *pData;
434
+ int i;
435
+ int rc = LSM_OK;
436
+ int iDot = 0;
437
+
438
+ /* Start the test case, open a database and allocate the datasource. */
439
+ pDb = testOpen(zSystem, 1, &rc);
440
+ pData = testDatasourceNew(&p->defn);
441
+ rc = testControlDb(&pControl);
442
+
443
+ if( tdb_lsm(pDb) ){
444
+ int nBuf = 32 * 1024 * 1024;
445
+ lsm_config(tdb_lsm(pDb), LSM_CONFIG_AUTOFLUSH, &nBuf);
446
+ }
447
+
448
+ for(i=0; rc==0 && i<p->nIter; i++){
449
+ void *pKey1; int nKey1;
450
+ void *pKey2; int nKey2;
451
+ int ii;
452
+ int nRange = MIN(p->nIter*p->nWrite, p->nRange);
453
+
454
+ for(ii=0; rc==0 && ii<p->nWrite; ii++){
455
+ int iKey = (i*p->nWrite + ii) % p->nRange;
456
+ testWriteDatasource(pControl, pData, iKey, &rc);
457
+ testWriteDatasource(pDb, pData, iKey, &rc);
458
+ }
459
+
460
+ testDatasourceEntry(pData, i+1000000, &pKey1, &nKey1, 0, 0);
461
+ pKey1 = testMallocCopy(pKey1, nKey1);
462
+ testDatasourceEntry(pData, i+2000000, &pKey2, &nKey2, 0, 0);
463
+
464
+ testDeleteRange(pDb, pKey1, nKey1, pKey2, nKey2, &rc);
465
+ testDeleteRange(pControl, pKey1, nKey1, pKey2, nKey2, &rc);
466
+ testFree(pKey1);
467
+
468
+ testCompareDb(pData, nRange, i, pControl, pDb, &rc);
469
+ if( bRecover ){
470
+ testReopenRecover(&pDb, &rc);
471
+ }else{
472
+ testReopen(&pDb, &rc);
473
+ }
474
+ testCompareDb(pData, nRange, i, pControl, pDb, &rc);
475
+
476
+ /* Update the progress dots... */
477
+ testCaseProgress(i, p->nIter, testCaseNDot(), &iDot);
478
+ }
479
+
480
+ testClose(&pDb);
481
+ testClose(&pControl);
482
+ testDatasourceFree(pData);
483
+ testCaseFinish(rc);
484
+ *pRc = rc;
485
+ }
486
+
487
+ static char *getName2(const char *zSystem, int bRecover, Datatest2 *pTest){
488
+ char *zRet;
489
+ char *zData;
490
+ zData = testDatasourceName(&pTest->defn);
491
+ zRet = testMallocPrintf("data2.%s.%s.rec=%d.%d.%d.%d",
492
+ zSystem, zData, bRecover, pTest->nRange, pTest->nWrite, pTest->nIter
493
+ );
494
+ testFree(zData);
495
+ return zRet;
496
+ }
497
+
498
+ void test_data_2(
499
+ const char *zSystem, /* Database system name */
500
+ const char *zPattern, /* Run test cases that match this pattern */
501
+ int *pRc /* IN/OUT: Error code */
502
+ ){
503
+ Datatest2 aTest[] = {
504
+ /* defn, nRange, nWrite, nIter */
505
+ { {DATA_RANDOM, 20,25, 100,200}, 10000, 10, 50 },
506
+ { {DATA_RANDOM, 20,25, 100,200}, 10000, 200, 50 },
507
+ { {DATA_RANDOM, 20,25, 100,200}, 100, 10, 1000 },
508
+ { {DATA_RANDOM, 20,25, 100,200}, 100, 200, 50 },
509
+ };
510
+
511
+ int i;
512
+ int bRecover;
513
+
514
+ for(bRecover=0; bRecover<2; bRecover++){
515
+ if( bRecover==1 && memcmp(zSystem, "lsm", 3) ) break;
516
+ for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){
517
+ char *zName = getName2(zSystem, bRecover, &aTest[i]);
518
+ if( testCaseBegin(pRc, zPattern, "%s", zName) ){
519
+ doDataTest2(zSystem, bRecover, &aTest[i], pRc);
520
+ }
521
+ testFree(zName);
522
+ }
523
+ }
524
+ }
525
+
526
+ /*************************************************************************
527
+ ** Test case data3.*
528
+ */
529
+
530
+ typedef struct Datatest3 Datatest3;
531
+ struct Datatest3 {
532
+ int nRange; /* Keys are between 1 and this value, incl. */
533
+ int nIter; /* Number of iterations */
534
+ int nWrite; /* Number of writes per iteration */
535
+ int nDelete; /* Number of deletes per iteration */
536
+
537
+ int nValMin; /* Minimum value size for writes */
538
+ int nValMax; /* Maximum value size for writes */
539
+ };
540
+
541
+ void testPutU32(u8 *aBuf, u32 iVal){
542
+ aBuf[0] = (iVal >> 24) & 0xFF;
543
+ aBuf[1] = (iVal >> 16) & 0xFF;
544
+ aBuf[2] = (iVal >> 8) & 0xFF;
545
+ aBuf[3] = (iVal >> 0) & 0xFF;
546
+ }
547
+
548
+ void dt3PutKey(u8 *aBuf, int iKey){
549
+ assert( iKey<100000 && iKey>=0 );
550
+ sprintf((char *)aBuf, "%.5d", iKey);
551
+ }
552
+
553
+ static void doDataTest3(
554
+ const char *zSystem, /* Database system to test */
555
+ Datatest3 *p, /* Structure containing test parameters */
556
+ int *pRc /* OUT: Error code */
557
+ ){
558
+ int iDot = 0;
559
+ int rc = *pRc;
560
+ TestDb *pDb;
561
+ u8 *abPresent; /* Array of boolean */
562
+ char *aVal; /* Buffer to hold values */
563
+ int i;
564
+ u32 iSeq = 10; /* prng counter */
565
+
566
+ abPresent = (u8 *)testMalloc(p->nRange+1);
567
+ aVal = (char *)testMalloc(p->nValMax+1);
568
+ pDb = testOpen(zSystem, 1, &rc);
569
+
570
+ for(i=0; i<p->nIter && rc==0; i++){
571
+ int ii;
572
+
573
+ testCaseProgress(i, p->nIter, testCaseNDot(), &iDot);
574
+
575
+ /* Perform nWrite inserts */
576
+ for(ii=0; ii<p->nWrite; ii++){
577
+ u8 aKey[6];
578
+ u32 iKey;
579
+ int nVal;
580
+
581
+ iKey = (testPrngValue(iSeq++) % p->nRange) + 1;
582
+ nVal = (testPrngValue(iSeq++) % (p->nValMax - p->nValMin)) + p->nValMin;
583
+ testPrngString(testPrngValue(iSeq++), aVal, nVal);
584
+ dt3PutKey(aKey, iKey);
585
+
586
+ testWrite(pDb, aKey, sizeof(aKey)-1, aVal, nVal, &rc);
587
+ abPresent[iKey] = 1;
588
+ }
589
+
590
+ /* Perform nDelete deletes */
591
+ for(ii=0; ii<p->nDelete; ii++){
592
+ u8 aKey1[6];
593
+ u8 aKey2[6];
594
+ u32 iKey;
595
+
596
+ iKey = (testPrngValue(iSeq++) % p->nRange) + 1;
597
+ dt3PutKey(aKey1, iKey-1);
598
+ dt3PutKey(aKey2, iKey+1);
599
+
600
+ testDeleteRange(pDb, aKey1, sizeof(aKey1)-1, aKey2, sizeof(aKey2)-1, &rc);
601
+ abPresent[iKey] = 0;
602
+ }
603
+
604
+ testReopen(&pDb, &rc);
605
+
606
+ for(ii=1; rc==0 && ii<=p->nRange; ii++){
607
+ int nDbVal;
608
+ void *pDbVal;
609
+ u8 aKey[6];
610
+ int dbrc;
611
+
612
+ dt3PutKey(aKey, ii);
613
+ dbrc = tdb_fetch(pDb, aKey, sizeof(aKey)-1, &pDbVal, &nDbVal);
614
+ testCompareInt(0, dbrc, &rc);
615
+
616
+ if( abPresent[ii] ){
617
+ testCompareInt(1, (nDbVal>0), &rc);
618
+ }else{
619
+ testCompareInt(1, (nDbVal<0), &rc);
620
+ }
621
+ }
622
+ }
623
+
624
+ testClose(&pDb);
625
+ testCaseFinish(rc);
626
+ *pRc = rc;
627
+ }
628
+
629
+ static char *getName3(const char *zSystem, Datatest3 *p){
630
+ return testMallocPrintf("data3.%s.%d.%d.%d.%d.(%d..%d)",
631
+ zSystem, p->nRange, p->nIter, p->nWrite, p->nDelete,
632
+ p->nValMin, p->nValMax
633
+ );
634
+ }
635
+
636
+ void test_data_3(
637
+ const char *zSystem, /* Database system name */
638
+ const char *zPattern, /* Run test cases that match this pattern */
639
+ int *pRc /* IN/OUT: Error code */
640
+ ){
641
+ Datatest3 aTest[] = {
642
+ /* nRange, nIter, nWrite, nDelete, nValMin, nValMax */
643
+ { 100, 1000, 5, 5, 50, 100 },
644
+ { 100, 1000, 2, 2, 5, 10 },
645
+ };
646
+
647
+ int i;
648
+
649
+ for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){
650
+ char *zName = getName3(zSystem, &aTest[i]);
651
+ if( testCaseBegin(pRc, zPattern, "%s", zName) ){
652
+ doDataTest3(zSystem, &aTest[i], pRc);
653
+ }
654
+ testFree(zName);
655
+ }
656
+ }
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest3.c ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ /*
4
+ ** This file contains tests related to the explicit rollback of database
5
+ ** transactions and sub-transactions.
6
+ */
7
+
8
+
9
+ /*
10
+ ** Repeat 2000 times (until the db contains 100,000 entries):
11
+ **
12
+ ** 1. Open a transaction and insert 500 rows, opening a nested
13
+ ** sub-transaction each 100 rows.
14
+ **
15
+ ** 2. Roll back to each sub-transaction savepoint. Check the database
16
+ ** checksum looks Ok.
17
+ **
18
+ ** 3. Every second iteration, roll back the main transaction. Check the
19
+ ** db checksum is correct. Every other iteration, commit the main
20
+ ** transaction (increasing the size of the db by 100 rows).
21
+ */
22
+
23
+
24
+ #include "lsmtest.h"
25
+
26
+ struct CksumDb {
27
+ int nFirst;
28
+ int nLast;
29
+ int nStep;
30
+ char **azCksum;
31
+ };
32
+
33
+ CksumDb *testCksumArrayNew(
34
+ Datasource *pData,
35
+ int nFirst,
36
+ int nLast,
37
+ int nStep
38
+ ){
39
+ TestDb *pDb;
40
+ CksumDb *pRet;
41
+ int i;
42
+ int nEntry;
43
+ int rc = 0;
44
+
45
+ assert( nLast>=nFirst && ((nLast-nFirst)%nStep)==0 );
46
+
47
+ pRet = malloc(sizeof(CksumDb));
48
+ memset(pRet, 0, sizeof(CksumDb));
49
+ pRet->nFirst = nFirst;
50
+ pRet->nLast = nLast;
51
+ pRet->nStep = nStep;
52
+ nEntry = 1 + ((nLast - nFirst) / nStep);
53
+
54
+ /* Allocate space so that azCksum is an array of nEntry pointers to
55
+ ** buffers each TEST_CKSUM_BYTES in size. */
56
+ pRet->azCksum = (char **)malloc(nEntry * (sizeof(char *) + TEST_CKSUM_BYTES));
57
+ for(i=0; i<nEntry; i++){
58
+ char *pStart = (char *)(&pRet->azCksum[nEntry]);
59
+ pRet->azCksum[i] = &pStart[i * TEST_CKSUM_BYTES];
60
+ }
61
+
62
+ tdb_open("lsm", "tempdb.lsm", 1, &pDb);
63
+ testWriteDatasourceRange(pDb, pData, 0, nFirst, &rc);
64
+ for(i=0; i<nEntry; i++){
65
+ testCksumDatabase(pDb, pRet->azCksum[i]);
66
+ if( i==nEntry ) break;
67
+ testWriteDatasourceRange(pDb, pData, nFirst+i*nStep, nStep, &rc);
68
+ }
69
+
70
+ tdb_close(pDb);
71
+
72
+ return pRet;
73
+ }
74
+
75
+ char *testCksumArrayGet(CksumDb *p, int nRow){
76
+ int i;
77
+ assert( nRow>=p->nFirst );
78
+ assert( nRow<=p->nLast );
79
+ assert( ((nRow-p->nFirst) % p->nStep)==0 );
80
+
81
+ i = (nRow - p->nFirst) / p->nStep;
82
+ return p->azCksum[i];
83
+ }
84
+
85
+ void testCksumArrayFree(CksumDb *p){
86
+ free(p->azCksum);
87
+ memset(p, 0x55, sizeof(*p));
88
+ free(p);
89
+ }
90
+
91
+ /* End of CksumDb code.
92
+ **************************************************************************/
93
+
94
+ /*
95
+ ** Test utility function. Write key-value pair $i from datasource pData
96
+ ** into database pDb.
97
+ */
98
+ void testWriteDatasource(TestDb *pDb, Datasource *pData, int i, int *pRc){
99
+ void *pKey; int nKey;
100
+ void *pVal; int nVal;
101
+ testDatasourceEntry(pData, i, &pKey, &nKey, &pVal, &nVal);
102
+ testWrite(pDb, pKey, nKey, pVal, nVal, pRc);
103
+ }
104
+
105
+ /*
106
+ ** Test utility function. Delete datasource pData key $i from database pDb.
107
+ */
108
+ void testDeleteDatasource(TestDb *pDb, Datasource *pData, int i, int *pRc){
109
+ void *pKey; int nKey;
110
+ testDatasourceEntry(pData, i, &pKey, &nKey, 0, 0);
111
+ testDelete(pDb, pKey, nKey, pRc);
112
+ }
113
+
114
+ /*
115
+ ** This function inserts nWrite key/value pairs into database pDb - the
116
+ ** nWrite key value pairs starting at iFirst from data source pData.
117
+ */
118
+ void testWriteDatasourceRange(
119
+ TestDb *pDb, /* Database to write to */
120
+ Datasource *pData, /* Data source to read values from */
121
+ int iFirst, /* Index of first key/value pair */
122
+ int nWrite, /* Number of key/value pairs to write */
123
+ int *pRc /* IN/OUT: Error code */
124
+ ){
125
+ int i;
126
+ for(i=0; i<nWrite; i++){
127
+ testWriteDatasource(pDb, pData, iFirst+i, pRc);
128
+ }
129
+ }
130
+
131
+ void testDeleteDatasourceRange(
132
+ TestDb *pDb, /* Database to write to */
133
+ Datasource *pData, /* Data source to read keys from */
134
+ int iFirst, /* Index of first key */
135
+ int nWrite, /* Number of keys to delete */
136
+ int *pRc /* IN/OUT: Error code */
137
+ ){
138
+ int i;
139
+ for(i=0; i<nWrite; i++){
140
+ testDeleteDatasource(pDb, pData, iFirst+i, pRc);
141
+ }
142
+ }
143
+
144
+ static char *getName(const char *zSystem){
145
+ char *zRet;
146
+ zRet = testMallocPrintf("rollback.%s", zSystem);
147
+ return zRet;
148
+ }
149
+
150
+ static int rollback_test_1(
151
+ const char *zSystem,
152
+ Datasource *pData
153
+ ){
154
+ const int nRepeat = 100;
155
+
156
+ TestDb *pDb;
157
+ int rc;
158
+ int i;
159
+ CksumDb *pCksum;
160
+ char *zName;
161
+
162
+ zName = getName(zSystem);
163
+ testCaseStart(&rc, zName);
164
+ testFree(zName);
165
+
166
+ pCksum = testCksumArrayNew(pData, 0, nRepeat*100, 100);
167
+ pDb = 0;
168
+ rc = tdb_open(zSystem, 0, 1, &pDb);
169
+ if( pDb && tdb_transaction_support(pDb)==0 ){
170
+ testCaseSkip();
171
+ goto skip_rollback_test;
172
+ }
173
+
174
+ for(i=0; i<nRepeat && rc==0; i++){
175
+ char zCksum[TEST_CKSUM_BYTES];
176
+ int nCurrent = (((i+1)/2) * 100);
177
+ int nDbRow;
178
+ int iTrans;
179
+
180
+ /* Check that the database is the expected size. */
181
+ nDbRow = testCountDatabase(pDb);
182
+ testCompareInt(nCurrent, nDbRow, &rc);
183
+
184
+ for(iTrans=2; iTrans<=6 && rc==0; iTrans++){
185
+ tdb_begin(pDb, iTrans);
186
+ testWriteDatasourceRange(pDb, pData, nCurrent, 100, &rc);
187
+ nCurrent += 100;
188
+ }
189
+
190
+ testCksumDatabase(pDb, zCksum);
191
+ testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);
192
+
193
+ for(iTrans=6; iTrans>2 && rc==0; iTrans--){
194
+ tdb_rollback(pDb, iTrans);
195
+ nCurrent -= 100;
196
+ testCksumDatabase(pDb, zCksum);
197
+ testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);
198
+ }
199
+
200
+ if( i%2 ){
201
+ tdb_rollback(pDb, 0);
202
+ nCurrent -= 100;
203
+ testCksumDatabase(pDb, zCksum);
204
+ testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);
205
+ }else{
206
+ tdb_commit(pDb, 0);
207
+ }
208
+ }
209
+ testCaseFinish(rc);
210
+
211
+ skip_rollback_test:
212
+ tdb_close(pDb);
213
+ testCksumArrayFree(pCksum);
214
+ return rc;
215
+ }
216
+
217
+ void test_rollback(
218
+ const char *zSystem,
219
+ const char *zPattern,
220
+ int *pRc
221
+ ){
222
+ if( *pRc==0 ){
223
+ int bRun = 1;
224
+
225
+ if( zPattern ){
226
+ char *zName = getName(zSystem);
227
+ bRun = testGlobMatch(zPattern, zName);
228
+ testFree(zName);
229
+ }
230
+
231
+ if( bRun ){
232
+ DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 10, 15, 50, 100 };
233
+ Datasource *pData = testDatasourceNew(&defn);
234
+ *pRc = rollback_test_1(zSystem, pData);
235
+ testDatasourceFree(pData);
236
+ }
237
+ }
238
+ }
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_datasource.c ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ #include "lsmtest.h"
4
+
5
+ struct Datasource {
6
+ int eType;
7
+
8
+ int nMinKey;
9
+ int nMaxKey;
10
+ int nMinVal;
11
+ int nMaxVal;
12
+
13
+ char *aKey;
14
+ char *aVal;
15
+ };
16
+
17
+ void testDatasourceEntry(
18
+ Datasource *p,
19
+ int iData,
20
+ void **ppKey, int *pnKey,
21
+ void **ppVal, int *pnVal
22
+ ){
23
+ assert( (ppKey==0)==(pnKey==0) );
24
+ assert( (ppVal==0)==(pnVal==0) );
25
+
26
+ if( ppKey ){
27
+ int nKey = 0;
28
+ switch( p->eType ){
29
+ case TEST_DATASOURCE_RANDOM: {
30
+ int nRange = (1 + p->nMaxKey - p->nMinKey);
31
+ nKey = (int)( testPrngValue((u32)iData) % nRange ) + p->nMinKey;
32
+ testPrngString((u32)iData, p->aKey, nKey);
33
+ break;
34
+ }
35
+ case TEST_DATASOURCE_SEQUENCE:
36
+ nKey = sprintf(p->aKey, "%012d", iData);
37
+ break;
38
+ }
39
+ *ppKey = p->aKey;
40
+ *pnKey = nKey;
41
+ }
42
+ if( ppVal ){
43
+ u32 nVal = testPrngValue((u32)iData)%(1+p->nMaxVal-p->nMinVal)+p->nMinVal;
44
+ testPrngString((u32)~iData, p->aVal, (int)nVal);
45
+ *ppVal = p->aVal;
46
+ *pnVal = (int)nVal;
47
+ }
48
+ }
49
+
50
+ void testDatasourceFree(Datasource *p){
51
+ testFree(p);
52
+ }
53
+
54
+ /*
55
+ ** Return a pointer to a nul-terminated string that corresponds to the
56
+ ** contents of the datasource-definition passed as the first argument.
57
+ ** The caller should eventually free the returned pointer using testFree().
58
+ */
59
+ char *testDatasourceName(const DatasourceDefn *p){
60
+ char *zRet;
61
+ zRet = testMallocPrintf("%s.(%d-%d).(%d-%d)",
62
+ (p->eType==TEST_DATASOURCE_SEQUENCE ? "seq" : "rnd"),
63
+ p->nMinKey, p->nMaxKey,
64
+ p->nMinVal, p->nMaxVal
65
+ );
66
+ return zRet;
67
+ }
68
+
69
+ Datasource *testDatasourceNew(const DatasourceDefn *pDefn){
70
+ Datasource *p;
71
+ int nMinKey;
72
+ int nMaxKey;
73
+ int nMinVal;
74
+ int nMaxVal;
75
+
76
+ if( pDefn->eType==TEST_DATASOURCE_SEQUENCE ){
77
+ nMinKey = 128;
78
+ nMaxKey = 128;
79
+ }else{
80
+ nMinKey = MAX(0, pDefn->nMinKey);
81
+ nMaxKey = MAX(nMinKey, pDefn->nMaxKey);
82
+ }
83
+ nMinVal = MAX(0, pDefn->nMinVal);
84
+ nMaxVal = MAX(nMinVal, pDefn->nMaxVal);
85
+
86
+ p = (Datasource *)testMalloc(sizeof(Datasource) + nMaxKey + nMaxVal + 1);
87
+ p->eType = pDefn->eType;
88
+ p->nMinKey = nMinKey;
89
+ p->nMinVal = nMinVal;
90
+ p->nMaxKey = nMaxKey;
91
+ p->nMaxVal = nMaxVal;
92
+
93
+ p->aKey = (char *)&p[1];
94
+ p->aVal = &p->aKey[nMaxKey];
95
+ return p;
96
+ };
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb.c ADDED
@@ -0,0 +1,846 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*
3
+ ** This program attempts to test the correctness of some facets of the
4
+ ** LSM database library. Specifically, that the contents of the database
5
+ ** are maintained correctly during a series of inserts and deletes.
6
+ */
7
+
8
+
9
+ #include "lsmtest_tdb.h"
10
+ #include "lsm.h"
11
+
12
+ #include "lsmtest.h"
13
+
14
+ #include <stdlib.h>
15
+ #include <string.h>
16
+ #include <assert.h>
17
+ #ifndef _WIN32
18
+ # include <unistd.h>
19
+ #endif
20
+ #include <stdio.h>
21
+
22
+
23
+ typedef struct SqlDb SqlDb;
24
+
25
+ static int error_transaction_function(TestDb *p, int iLevel){
26
+ unused_parameter(p);
27
+ unused_parameter(iLevel);
28
+ return -1;
29
+ }
30
+
31
+
32
+ /*************************************************************************
33
+ ** Begin wrapper for LevelDB.
34
+ */
35
+ #ifdef HAVE_LEVELDB
36
+
37
+ #include <leveldb/c.h>
38
+
39
+ typedef struct LevelDb LevelDb;
40
+ struct LevelDb {
41
+ TestDb base;
42
+ leveldb_t *db;
43
+ leveldb_options_t *pOpt;
44
+ leveldb_writeoptions_t *pWriteOpt;
45
+ leveldb_readoptions_t *pReadOpt;
46
+
47
+ char *pVal;
48
+ };
49
+
50
+ static int test_leveldb_close(TestDb *pTestDb){
51
+ LevelDb *pDb = (LevelDb *)pTestDb;
52
+
53
+ leveldb_close(pDb->db);
54
+ leveldb_writeoptions_destroy(pDb->pWriteOpt);
55
+ leveldb_readoptions_destroy(pDb->pReadOpt);
56
+ leveldb_options_destroy(pDb->pOpt);
57
+ free(pDb->pVal);
58
+ free(pDb);
59
+
60
+ return 0;
61
+ }
62
+
63
+ static int test_leveldb_write(
64
+ TestDb *pTestDb,
65
+ void *pKey,
66
+ int nKey,
67
+ void *pVal,
68
+ int nVal
69
+ ){
70
+ LevelDb *pDb = (LevelDb *)pTestDb;
71
+ char *zErr = 0;
72
+ leveldb_put(pDb->db, pDb->pWriteOpt, pKey, nKey, pVal, nVal, &zErr);
73
+ return (zErr!=0);
74
+ }
75
+
76
+ static int test_leveldb_delete(TestDb *pTestDb, void *pKey, int nKey){
77
+ LevelDb *pDb = (LevelDb *)pTestDb;
78
+ char *zErr = 0;
79
+ leveldb_delete(pDb->db, pDb->pWriteOpt, pKey, nKey, &zErr);
80
+ return (zErr!=0);
81
+ }
82
+
83
+ static int test_leveldb_fetch(
84
+ TestDb *pTestDb,
85
+ void *pKey,
86
+ int nKey,
87
+ void **ppVal,
88
+ int *pnVal
89
+ ){
90
+ LevelDb *pDb = (LevelDb *)pTestDb;
91
+ char *zErr = 0;
92
+ size_t nVal = 0;
93
+
94
+ if( pKey==0 ) return 0;
95
+ free(pDb->pVal);
96
+ pDb->pVal = leveldb_get(pDb->db, pDb->pReadOpt, pKey, nKey, &nVal, &zErr);
97
+ *ppVal = (void *)(pDb->pVal);
98
+ if( pDb->pVal==0 ){
99
+ *pnVal = -1;
100
+ }else{
101
+ *pnVal = (int)nVal;
102
+ }
103
+
104
+ return (zErr!=0);
105
+ }
106
+
107
+ static int test_leveldb_scan(
108
+ TestDb *pTestDb,
109
+ void *pCtx,
110
+ int bReverse,
111
+ void *pKey1, int nKey1, /* Start of search */
112
+ void *pKey2, int nKey2, /* End of search */
113
+ void (*xCallback)(void *, void *, int , void *, int)
114
+ ){
115
+ LevelDb *pDb = (LevelDb *)pTestDb;
116
+ leveldb_iterator_t *iter;
117
+
118
+ iter = leveldb_create_iterator(pDb->db, pDb->pReadOpt);
119
+
120
+ if( bReverse==0 ){
121
+ if( pKey1 ){
122
+ leveldb_iter_seek(iter, pKey1, nKey1);
123
+ }else{
124
+ leveldb_iter_seek_to_first(iter);
125
+ }
126
+ }else{
127
+ if( pKey2 ){
128
+ leveldb_iter_seek(iter, pKey2, nKey2);
129
+
130
+ if( leveldb_iter_valid(iter)==0 ){
131
+ leveldb_iter_seek_to_last(iter);
132
+ }else{
133
+ const char *k; size_t n;
134
+ int res;
135
+ k = leveldb_iter_key(iter, &n);
136
+ res = memcmp(k, pKey2, MIN(n, nKey2));
137
+ if( res==0 ) res = n - nKey2;
138
+ assert( res>=0 );
139
+ if( res>0 ){
140
+ leveldb_iter_prev(iter);
141
+ }
142
+ }
143
+ }else{
144
+ leveldb_iter_seek_to_last(iter);
145
+ }
146
+ }
147
+
148
+
149
+ while( leveldb_iter_valid(iter) ){
150
+ const char *k; size_t n;
151
+ const char *v; size_t n2;
152
+ int res;
153
+
154
+ k = leveldb_iter_key(iter, &n);
155
+ if( bReverse==0 && pKey2 ){
156
+ res = memcmp(k, pKey2, MIN(n, nKey2));
157
+ if( res==0 ) res = n - nKey2;
158
+ if( res>0 ) break;
159
+ }
160
+ if( bReverse!=0 && pKey1 ){
161
+ res = memcmp(k, pKey1, MIN(n, nKey1));
162
+ if( res==0 ) res = n - nKey1;
163
+ if( res<0 ) break;
164
+ }
165
+
166
+ v = leveldb_iter_value(iter, &n2);
167
+
168
+ xCallback(pCtx, (void *)k, n, (void *)v, n2);
169
+
170
+ if( bReverse==0 ){
171
+ leveldb_iter_next(iter);
172
+ }else{
173
+ leveldb_iter_prev(iter);
174
+ }
175
+ }
176
+
177
+ leveldb_iter_destroy(iter);
178
+ return 0;
179
+ }
180
+
181
+ static int test_leveldb_open(
182
+ const char *zSpec,
183
+ const char *zFilename,
184
+ int bClear,
185
+ TestDb **ppDb
186
+ ){
187
+ static const DatabaseMethods LeveldbMethods = {
188
+ test_leveldb_close,
189
+ test_leveldb_write,
190
+ test_leveldb_delete,
191
+ 0,
192
+ test_leveldb_fetch,
193
+ test_leveldb_scan,
194
+ error_transaction_function,
195
+ error_transaction_function,
196
+ error_transaction_function
197
+ };
198
+
199
+ LevelDb *pLevelDb;
200
+ char *zErr = 0;
201
+
202
+ if( bClear ){
203
+ char *zCmd = sqlite3_mprintf("rm -rf %s\n", zFilename);
204
+ system(zCmd);
205
+ sqlite3_free(zCmd);
206
+ }
207
+
208
+ pLevelDb = (LevelDb *)malloc(sizeof(LevelDb));
209
+ memset(pLevelDb, 0, sizeof(LevelDb));
210
+
211
+ pLevelDb->pOpt = leveldb_options_create();
212
+ leveldb_options_set_create_if_missing(pLevelDb->pOpt, 1);
213
+ pLevelDb->pWriteOpt = leveldb_writeoptions_create();
214
+ pLevelDb->pReadOpt = leveldb_readoptions_create();
215
+
216
+ pLevelDb->db = leveldb_open(pLevelDb->pOpt, zFilename, &zErr);
217
+
218
+ if( zErr ){
219
+ test_leveldb_close((TestDb *)pLevelDb);
220
+ *ppDb = 0;
221
+ return 1;
222
+ }
223
+
224
+ *ppDb = (TestDb *)pLevelDb;
225
+ pLevelDb->base.pMethods = &LeveldbMethods;
226
+ return 0;
227
+ }
228
+ #endif /* HAVE_LEVELDB */
229
+ /*
230
+ ** End wrapper for LevelDB.
231
+ *************************************************************************/
232
+
233
+ #ifdef HAVE_KYOTOCABINET
234
+ static int kc_close(TestDb *pTestDb){
235
+ return test_kc_close(pTestDb);
236
+ }
237
+
238
+ static int kc_write(
239
+ TestDb *pTestDb,
240
+ void *pKey,
241
+ int nKey,
242
+ void *pVal,
243
+ int nVal
244
+ ){
245
+ return test_kc_write(pTestDb, pKey, nKey, pVal, nVal);
246
+ }
247
+
248
+ static int kc_delete(TestDb *pTestDb, void *pKey, int nKey){
249
+ return test_kc_delete(pTestDb, pKey, nKey);
250
+ }
251
+
252
+ static int kc_delete_range(
253
+ TestDb *pTestDb,
254
+ void *pKey1, int nKey1,
255
+ void *pKey2, int nKey2
256
+ ){
257
+ return test_kc_delete_range(pTestDb, pKey1, nKey1, pKey2, nKey2);
258
+ }
259
+
260
+ static int kc_fetch(
261
+ TestDb *pTestDb,
262
+ void *pKey,
263
+ int nKey,
264
+ void **ppVal,
265
+ int *pnVal
266
+ ){
267
+ if( pKey==0 ) return LSM_OK;
268
+ return test_kc_fetch(pTestDb, pKey, nKey, ppVal, pnVal);
269
+ }
270
+
271
+ static int kc_scan(
272
+ TestDb *pTestDb,
273
+ void *pCtx,
274
+ int bReverse,
275
+ void *pFirst, int nFirst,
276
+ void *pLast, int nLast,
277
+ void (*xCallback)(void *, void *, int , void *, int)
278
+ ){
279
+ return test_kc_scan(
280
+ pTestDb, pCtx, bReverse, pFirst, nFirst, pLast, nLast, xCallback
281
+ );
282
+ }
283
+
284
+ static int kc_open(
285
+ const char *zSpec,
286
+ const char *zFilename,
287
+ int bClear,
288
+ TestDb **ppDb
289
+ ){
290
+ static const DatabaseMethods KcdbMethods = {
291
+ kc_close,
292
+ kc_write,
293
+ kc_delete,
294
+ kc_delete_range,
295
+ kc_fetch,
296
+ kc_scan,
297
+ error_transaction_function,
298
+ error_transaction_function,
299
+ error_transaction_function
300
+ };
301
+
302
+ int rc;
303
+ TestDb *pTestDb = 0;
304
+
305
+ rc = test_kc_open(zFilename, bClear, &pTestDb);
306
+ if( rc!=0 ){
307
+ *ppDb = 0;
308
+ return rc;
309
+ }
310
+ pTestDb->pMethods = &KcdbMethods;
311
+ *ppDb = pTestDb;
312
+ return 0;
313
+ }
314
+ #endif /* HAVE_KYOTOCABINET */
315
+ /*
316
+ ** End wrapper for Kyoto cabinet.
317
+ *************************************************************************/
318
+
319
+ #ifdef HAVE_MDB
320
+ static int mdb_close(TestDb *pTestDb){
321
+ return test_mdb_close(pTestDb);
322
+ }
323
+
324
+ static int mdb_write(
325
+ TestDb *pTestDb,
326
+ void *pKey,
327
+ int nKey,
328
+ void *pVal,
329
+ int nVal
330
+ ){
331
+ return test_mdb_write(pTestDb, pKey, nKey, pVal, nVal);
332
+ }
333
+
334
+ static int mdb_delete(TestDb *pTestDb, void *pKey, int nKey){
335
+ return test_mdb_delete(pTestDb, pKey, nKey);
336
+ }
337
+
338
+ static int mdb_fetch(
339
+ TestDb *pTestDb,
340
+ void *pKey,
341
+ int nKey,
342
+ void **ppVal,
343
+ int *pnVal
344
+ ){
345
+ if( pKey==0 ) return LSM_OK;
346
+ return test_mdb_fetch(pTestDb, pKey, nKey, ppVal, pnVal);
347
+ }
348
+
349
+ static int mdb_scan(
350
+ TestDb *pTestDb,
351
+ void *pCtx,
352
+ int bReverse,
353
+ void *pFirst, int nFirst,
354
+ void *pLast, int nLast,
355
+ void (*xCallback)(void *, void *, int , void *, int)
356
+ ){
357
+ return test_mdb_scan(
358
+ pTestDb, pCtx, bReverse, pFirst, nFirst, pLast, nLast, xCallback
359
+ );
360
+ }
361
+
362
+ static int mdb_open(
363
+ const char *zSpec,
364
+ const char *zFilename,
365
+ int bClear,
366
+ TestDb **ppDb
367
+ ){
368
+ static const DatabaseMethods KcdbMethods = {
369
+ mdb_close,
370
+ mdb_write,
371
+ mdb_delete,
372
+ 0,
373
+ mdb_fetch,
374
+ mdb_scan,
375
+ error_transaction_function,
376
+ error_transaction_function,
377
+ error_transaction_function
378
+ };
379
+
380
+ int rc;
381
+ TestDb *pTestDb = 0;
382
+
383
+ rc = test_mdb_open(zSpec, zFilename, bClear, &pTestDb);
384
+ if( rc!=0 ){
385
+ *ppDb = 0;
386
+ return rc;
387
+ }
388
+ pTestDb->pMethods = &KcdbMethods;
389
+ *ppDb = pTestDb;
390
+ return 0;
391
+ }
392
+ #endif /* HAVE_MDB */
393
+
394
+ /*************************************************************************
395
+ ** Begin wrapper for SQLite.
396
+ */
397
+
398
+ /*
399
+ ** nOpenTrans:
400
+ ** The number of open nested transactions, in the same sense as used
401
+ ** by the tdb_begin/commit/rollback and SQLite 4 KV interfaces. If this
402
+ ** value is 0, there are no transactions open at all. If it is 1, then
403
+ ** there is a read transaction. If it is 2 or greater, then there are
404
+ ** (nOpenTrans-1) nested write transactions open.
405
+ */
406
+ struct SqlDb {
407
+ TestDb base;
408
+ sqlite3 *db;
409
+ sqlite3_stmt *pInsert;
410
+ sqlite3_stmt *pDelete;
411
+ sqlite3_stmt *pDeleteRange;
412
+ sqlite3_stmt *pFetch;
413
+ sqlite3_stmt *apScan[8];
414
+
415
+ int nOpenTrans;
416
+
417
+ /* Used by sql_fetch() to allocate space for results */
418
+ int nAlloc;
419
+ u8 *aAlloc;
420
+ };
421
+
422
+ static int sql_close(TestDb *pTestDb){
423
+ SqlDb *pDb = (SqlDb *)pTestDb;
424
+ sqlite3_finalize(pDb->pInsert);
425
+ sqlite3_finalize(pDb->pDelete);
426
+ sqlite3_finalize(pDb->pDeleteRange);
427
+ sqlite3_finalize(pDb->pFetch);
428
+ sqlite3_finalize(pDb->apScan[0]);
429
+ sqlite3_finalize(pDb->apScan[1]);
430
+ sqlite3_finalize(pDb->apScan[2]);
431
+ sqlite3_finalize(pDb->apScan[3]);
432
+ sqlite3_finalize(pDb->apScan[4]);
433
+ sqlite3_finalize(pDb->apScan[5]);
434
+ sqlite3_finalize(pDb->apScan[6]);
435
+ sqlite3_finalize(pDb->apScan[7]);
436
+ sqlite3_close(pDb->db);
437
+ free((char *)pDb->aAlloc);
438
+ free((char *)pDb);
439
+ return SQLITE_OK;
440
+ }
441
+
442
+ static int sql_write(
443
+ TestDb *pTestDb,
444
+ void *pKey,
445
+ int nKey,
446
+ void *pVal,
447
+ int nVal
448
+ ){
449
+ SqlDb *pDb = (SqlDb *)pTestDb;
450
+ sqlite3_bind_blob(pDb->pInsert, 1, pKey, nKey, SQLITE_STATIC);
451
+ sqlite3_bind_blob(pDb->pInsert, 2, pVal, nVal, SQLITE_STATIC);
452
+ sqlite3_step(pDb->pInsert);
453
+ return sqlite3_reset(pDb->pInsert);
454
+ }
455
+
456
+ static int sql_delete(TestDb *pTestDb, void *pKey, int nKey){
457
+ SqlDb *pDb = (SqlDb *)pTestDb;
458
+ sqlite3_bind_blob(pDb->pDelete, 1, pKey, nKey, SQLITE_STATIC);
459
+ sqlite3_step(pDb->pDelete);
460
+ return sqlite3_reset(pDb->pDelete);
461
+ }
462
+
463
+ static int sql_delete_range(
464
+ TestDb *pTestDb,
465
+ void *pKey1, int nKey1,
466
+ void *pKey2, int nKey2
467
+ ){
468
+ SqlDb *pDb = (SqlDb *)pTestDb;
469
+ sqlite3_bind_blob(pDb->pDeleteRange, 1, pKey1, nKey1, SQLITE_STATIC);
470
+ sqlite3_bind_blob(pDb->pDeleteRange, 2, pKey2, nKey2, SQLITE_STATIC);
471
+ sqlite3_step(pDb->pDeleteRange);
472
+ return sqlite3_reset(pDb->pDeleteRange);
473
+ }
474
+
475
+ static int sql_fetch(
476
+ TestDb *pTestDb,
477
+ void *pKey,
478
+ int nKey,
479
+ void **ppVal,
480
+ int *pnVal
481
+ ){
482
+ SqlDb *pDb = (SqlDb *)pTestDb;
483
+ int rc;
484
+
485
+ sqlite3_reset(pDb->pFetch);
486
+ if( pKey==0 ){
487
+ assert( ppVal==0 );
488
+ assert( pnVal==0 );
489
+ return LSM_OK;
490
+ }
491
+
492
+ sqlite3_bind_blob(pDb->pFetch, 1, pKey, nKey, SQLITE_STATIC);
493
+ rc = sqlite3_step(pDb->pFetch);
494
+ if( rc==SQLITE_ROW ){
495
+ int nVal = sqlite3_column_bytes(pDb->pFetch, 0);
496
+ u8 *aVal = (void *)sqlite3_column_blob(pDb->pFetch, 0);
497
+
498
+ if( nVal>pDb->nAlloc ){
499
+ free(pDb->aAlloc);
500
+ pDb->aAlloc = (u8 *)malloc(nVal*2);
501
+ pDb->nAlloc = nVal*2;
502
+ }
503
+ memcpy(pDb->aAlloc, aVal, nVal);
504
+ *pnVal = nVal;
505
+ *ppVal = (void *)pDb->aAlloc;
506
+ }else{
507
+ *pnVal = -1;
508
+ *ppVal = 0;
509
+ }
510
+
511
+ rc = sqlite3_reset(pDb->pFetch);
512
+ return rc;
513
+ }
514
+
515
+ static int sql_scan(
516
+ TestDb *pTestDb,
517
+ void *pCtx,
518
+ int bReverse,
519
+ void *pFirst, int nFirst,
520
+ void *pLast, int nLast,
521
+ void (*xCallback)(void *, void *, int , void *, int)
522
+ ){
523
+ SqlDb *pDb = (SqlDb *)pTestDb;
524
+ sqlite3_stmt *pScan;
525
+
526
+ assert( bReverse==1 || bReverse==0 );
527
+ pScan = pDb->apScan[(pFirst==0) + (pLast==0)*2 + bReverse*4];
528
+
529
+ if( pFirst ) sqlite3_bind_blob(pScan, 1, pFirst, nFirst, SQLITE_STATIC);
530
+ if( pLast ) sqlite3_bind_blob(pScan, 2, pLast, nLast, SQLITE_STATIC);
531
+
532
+ while( SQLITE_ROW==sqlite3_step(pScan) ){
533
+ void *pKey; int nKey;
534
+ void *pVal; int nVal;
535
+
536
+ nKey = sqlite3_column_bytes(pScan, 0);
537
+ pKey = (void *)sqlite3_column_blob(pScan, 0);
538
+ nVal = sqlite3_column_bytes(pScan, 1);
539
+ pVal = (void *)sqlite3_column_blob(pScan, 1);
540
+
541
+ xCallback(pCtx, pKey, nKey, pVal, nVal);
542
+ }
543
+ return sqlite3_reset(pScan);
544
+ }
545
+
546
+ static int sql_begin(TestDb *pTestDb, int iLevel){
547
+ int i;
548
+ SqlDb *pDb = (SqlDb *)pTestDb;
549
+
550
+ /* iLevel==0 is a no-op */
551
+ if( iLevel==0 ) return 0;
552
+
553
+ /* If there are no transactions at all open, open a read transaction. */
554
+ if( pDb->nOpenTrans==0 ){
555
+ int rc = sqlite3_exec(pDb->db,
556
+ "BEGIN; SELECT * FROM sqlite_schema LIMIT 1;" , 0, 0, 0
557
+ );
558
+ if( rc!=0 ) return rc;
559
+ pDb->nOpenTrans = 1;
560
+ }
561
+
562
+ /* Open any required write transactions */
563
+ for(i=pDb->nOpenTrans; i<iLevel; i++){
564
+ char *zSql = sqlite3_mprintf("SAVEPOINT x%d", i);
565
+ int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);
566
+ sqlite3_free(zSql);
567
+ if( rc!=SQLITE_OK ) return rc;
568
+ }
569
+
570
+ pDb->nOpenTrans = iLevel;
571
+ return 0;
572
+ }
573
+
574
+ static int sql_commit(TestDb *pTestDb, int iLevel){
575
+ SqlDb *pDb = (SqlDb *)pTestDb;
576
+ assert( iLevel>=0 );
577
+
578
+ /* Close the read transaction if requested. */
579
+ if( pDb->nOpenTrans>=1 && iLevel==0 ){
580
+ int rc = sqlite3_exec(pDb->db, "COMMIT", 0, 0, 0);
581
+ if( rc!=0 ) return rc;
582
+ pDb->nOpenTrans = 0;
583
+ }
584
+
585
+ /* Close write transactions as required */
586
+ if( pDb->nOpenTrans>iLevel ){
587
+ char *zSql = sqlite3_mprintf("RELEASE x%d", iLevel);
588
+ int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);
589
+ sqlite3_free(zSql);
590
+ if( rc!=0 ) return rc;
591
+ }
592
+
593
+ pDb->nOpenTrans = iLevel;
594
+ return 0;
595
+ }
596
+
597
+ static int sql_rollback(TestDb *pTestDb, int iLevel){
598
+ SqlDb *pDb = (SqlDb *)pTestDb;
599
+ assert( iLevel>=0 );
600
+
601
+ if( pDb->nOpenTrans>=1 && iLevel==0 ){
602
+ /* Close the read transaction if requested. */
603
+ int rc = sqlite3_exec(pDb->db, "ROLLBACK", 0, 0, 0);
604
+ if( rc!=0 ) return rc;
605
+ }else if( pDb->nOpenTrans>1 && iLevel==1 ){
606
+ /* Or, rollback and close the top-level write transaction */
607
+ int rc = sqlite3_exec(pDb->db, "ROLLBACK TO x1; RELEASE x1;", 0, 0, 0);
608
+ if( rc!=0 ) return rc;
609
+ }else{
610
+ /* Or, just roll back some nested transactions */
611
+ char *zSql = sqlite3_mprintf("ROLLBACK TO x%d", iLevel-1);
612
+ int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);
613
+ sqlite3_free(zSql);
614
+ if( rc!=0 ) return rc;
615
+ }
616
+
617
+ pDb->nOpenTrans = iLevel;
618
+ return 0;
619
+ }
620
+
621
+ static int sql_open(
622
+ const char *zSpec,
623
+ const char *zFilename,
624
+ int bClear,
625
+ TestDb **ppDb
626
+ ){
627
+ static const DatabaseMethods SqlMethods = {
628
+ sql_close,
629
+ sql_write,
630
+ sql_delete,
631
+ sql_delete_range,
632
+ sql_fetch,
633
+ sql_scan,
634
+ sql_begin,
635
+ sql_commit,
636
+ sql_rollback
637
+ };
638
+ const char *zCreate = "CREATE TABLE IF NOT EXISTS t1(k PRIMARY KEY, v)";
639
+ const char *zInsert = "REPLACE INTO t1 VALUES(?, ?)";
640
+ const char *zDelete = "DELETE FROM t1 WHERE k = ?";
641
+ const char *zRange = "DELETE FROM t1 WHERE k>? AND k<?";
642
+ const char *zFetch = "SELECT v FROM t1 WHERE k = ?";
643
+
644
+ const char *zScan0 = "SELECT * FROM t1 WHERE k BETWEEN ?1 AND ?2 ORDER BY k";
645
+ const char *zScan1 = "SELECT * FROM t1 WHERE k <= ?2 ORDER BY k";
646
+ const char *zScan2 = "SELECT * FROM t1 WHERE k >= ?1 ORDER BY k";
647
+ const char *zScan3 = "SELECT * FROM t1 ORDER BY k";
648
+
649
+ const char *zScan4 =
650
+ "SELECT * FROM t1 WHERE k BETWEEN ?1 AND ?2 ORDER BY k DESC";
651
+ const char *zScan5 = "SELECT * FROM t1 WHERE k <= ?2 ORDER BY k DESC";
652
+ const char *zScan6 = "SELECT * FROM t1 WHERE k >= ?1 ORDER BY k DESC";
653
+ const char *zScan7 = "SELECT * FROM t1 ORDER BY k DESC";
654
+
655
+ int rc;
656
+ SqlDb *pDb;
657
+ char *zPragma;
658
+
659
+ if( bClear && zFilename && zFilename[0] ){
660
+ unlink(zFilename);
661
+ }
662
+
663
+ pDb = (SqlDb *)malloc(sizeof(SqlDb));
664
+ memset(pDb, 0, sizeof(SqlDb));
665
+ pDb->base.pMethods = &SqlMethods;
666
+
667
+ if( 0!=(rc = sqlite3_open(zFilename, &pDb->db))
668
+ || 0!=(rc = sqlite3_exec(pDb->db, zCreate, 0, 0, 0))
669
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zInsert, -1, &pDb->pInsert, 0))
670
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zDelete, -1, &pDb->pDelete, 0))
671
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zRange, -1, &pDb->pDeleteRange, 0))
672
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zFetch, -1, &pDb->pFetch, 0))
673
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan0, -1, &pDb->apScan[0], 0))
674
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan1, -1, &pDb->apScan[1], 0))
675
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan2, -1, &pDb->apScan[2], 0))
676
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan3, -1, &pDb->apScan[3], 0))
677
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan4, -1, &pDb->apScan[4], 0))
678
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan5, -1, &pDb->apScan[5], 0))
679
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan6, -1, &pDb->apScan[6], 0))
680
+ || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan7, -1, &pDb->apScan[7], 0))
681
+ ){
682
+ *ppDb = 0;
683
+ sql_close((TestDb *)pDb);
684
+ return rc;
685
+ }
686
+
687
+ zPragma = sqlite3_mprintf("PRAGMA page_size=%d", TESTDB_DEFAULT_PAGE_SIZE);
688
+ sqlite3_exec(pDb->db, zPragma, 0, 0, 0);
689
+ sqlite3_free(zPragma);
690
+ zPragma = sqlite3_mprintf("PRAGMA cache_size=%d", TESTDB_DEFAULT_CACHE_SIZE);
691
+ sqlite3_exec(pDb->db, zPragma, 0, 0, 0);
692
+ sqlite3_free(zPragma);
693
+
694
+ /* sqlite3_exec(pDb->db, "PRAGMA locking_mode=EXCLUSIVE", 0, 0, 0); */
695
+ sqlite3_exec(pDb->db, "PRAGMA synchronous=OFF", 0, 0, 0);
696
+ sqlite3_exec(pDb->db, "PRAGMA journal_mode=WAL", 0, 0, 0);
697
+ sqlite3_exec(pDb->db, "PRAGMA wal_autocheckpoint=4096", 0, 0, 0);
698
+ if( zSpec ){
699
+ rc = sqlite3_exec(pDb->db, zSpec, 0, 0, 0);
700
+ if( rc!=SQLITE_OK ){
701
+ sql_close((TestDb *)pDb);
702
+ return rc;
703
+ }
704
+ }
705
+
706
+ *ppDb = (TestDb *)pDb;
707
+ return 0;
708
+ }
709
+ /*
710
+ ** End wrapper for SQLite.
711
+ *************************************************************************/
712
+
713
+ /*************************************************************************
714
+ ** Begin exported functions.
715
+ */
716
+ static struct Lib {
717
+ const char *zName;
718
+ const char *zDefaultDb;
719
+ int (*xOpen)(const char *, const char *zFilename, int bClear, TestDb **ppDb);
720
+ } aLib[] = {
721
+ { "sqlite3", "testdb.sqlite", sql_open },
722
+ { "lsm_small", "testdb.lsm_small", test_lsm_small_open },
723
+ { "lsm_lomem", "testdb.lsm_lomem", test_lsm_lomem_open },
724
+ { "lsm_lomem2", "testdb.lsm_lomem2", test_lsm_lomem2_open },
725
+ #ifdef HAVE_ZLIB
726
+ { "lsm_zip", "testdb.lsm_zip", test_lsm_zip_open },
727
+ #endif
728
+ { "lsm", "testdb.lsm", test_lsm_open },
729
+ #ifdef LSM_MUTEX_PTHREADS
730
+ { "lsm_mt2", "testdb.lsm_mt2", test_lsm_mt2 },
731
+ { "lsm_mt3", "testdb.lsm_mt3", test_lsm_mt3 },
732
+ #endif
733
+ #ifdef HAVE_LEVELDB
734
+ { "leveldb", "testdb.leveldb", test_leveldb_open },
735
+ #endif
736
+ #ifdef HAVE_KYOTOCABINET
737
+ { "kyotocabinet", "testdb.kc", kc_open },
738
+ #endif
739
+ #ifdef HAVE_MDB
740
+ { "mdb", "./testdb.mdb", mdb_open }
741
+ #endif
742
+ };
743
+
744
+ const char *tdb_system_name(int i){
745
+ if( i<0 || i>=ArraySize(aLib) ) return 0;
746
+ return aLib[i].zName;
747
+ }
748
+
749
+ const char *tdb_default_db(const char *zSys){
750
+ int i;
751
+ for(i=0; i<ArraySize(aLib); i++){
752
+ if( strcmp(aLib[i].zName, zSys)==0 ) return aLib[i].zDefaultDb;
753
+ }
754
+ return 0;
755
+ }
756
+
757
+ int tdb_open(const char *zLib, const char *zDb, int bClear, TestDb **ppDb){
758
+ int i;
759
+ int rc = 1;
760
+ const char *zSpec = 0;
761
+
762
+ int nLib = 0;
763
+ while( zLib[nLib] && zLib[nLib]!=' ' ){
764
+ nLib++;
765
+ }
766
+ zSpec = &zLib[nLib];
767
+ while( *zSpec==' ' ) zSpec++;
768
+ if( *zSpec=='\0' ) zSpec = 0;
769
+
770
+ for(i=0; i<ArraySize(aLib); i++){
771
+ if( (int)strlen(aLib[i].zName)==nLib
772
+ && 0==memcmp(zLib, aLib[i].zName, nLib) ){
773
+ rc = aLib[i].xOpen(zSpec, (zDb ? zDb : aLib[i].zDefaultDb), bClear, ppDb);
774
+ if( rc==0 ){
775
+ (*ppDb)->zLibrary = aLib[i].zName;
776
+ }
777
+ break;
778
+ }
779
+ }
780
+
781
+ if( rc ){
782
+ /* Failed to find the requested database library. Return an error. */
783
+ *ppDb = 0;
784
+ }
785
+ return rc;
786
+ }
787
+
788
+ int tdb_close(TestDb *pDb){
789
+ if( pDb ){
790
+ return pDb->pMethods->xClose(pDb);
791
+ }
792
+ return 0;
793
+ }
794
+
795
+ int tdb_write(TestDb *pDb, void *pKey, int nKey, void *pVal, int nVal){
796
+ return pDb->pMethods->xWrite(pDb, pKey, nKey, pVal, nVal);
797
+ }
798
+
799
+ int tdb_delete(TestDb *pDb, void *pKey, int nKey){
800
+ return pDb->pMethods->xDelete(pDb, pKey, nKey);
801
+ }
802
+
803
+ int tdb_delete_range(
804
+ TestDb *pDb, void *pKey1, int nKey1, void *pKey2, int nKey2
805
+ ){
806
+ return pDb->pMethods->xDeleteRange(pDb, pKey1, nKey1, pKey2, nKey2);
807
+ }
808
+
809
+ int tdb_fetch(TestDb *pDb, void *pKey, int nKey, void **ppVal, int *pnVal){
810
+ return pDb->pMethods->xFetch(pDb, pKey, nKey, ppVal, pnVal);
811
+ }
812
+
813
+ int tdb_scan(
814
+ TestDb *pDb, /* Database handle */
815
+ void *pCtx, /* Context pointer to pass to xCallback */
816
+ int bReverse, /* True to scan in reverse order */
817
+ void *pKey1, int nKey1, /* Start of search */
818
+ void *pKey2, int nKey2, /* End of search */
819
+ void (*xCallback)(void *pCtx, void *pKey, int nKey, void *pVal, int nVal)
820
+ ){
821
+ return pDb->pMethods->xScan(
822
+ pDb, pCtx, bReverse, pKey1, nKey1, pKey2, nKey2, xCallback
823
+ );
824
+ }
825
+
826
+ int tdb_begin(TestDb *pDb, int iLevel){
827
+ return pDb->pMethods->xBegin(pDb, iLevel);
828
+ }
829
+ int tdb_commit(TestDb *pDb, int iLevel){
830
+ return pDb->pMethods->xCommit(pDb, iLevel);
831
+ }
832
+ int tdb_rollback(TestDb *pDb, int iLevel){
833
+ return pDb->pMethods->xRollback(pDb, iLevel);
834
+ }
835
+
836
+ int tdb_transaction_support(TestDb *pDb){
837
+ return (pDb->pMethods->xBegin != error_transaction_function);
838
+ }
839
+
840
+ const char *tdb_library_name(TestDb *pDb){
841
+ return pDb->zLibrary;
842
+ }
843
+
844
+ /*
845
+ ** End exported functions.
846
+ *************************************************************************/
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb3.c ADDED
@@ -0,0 +1,1429 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #include "lsmtest_tdb.h"
3
+ #include "lsm.h"
4
+ #include "lsmtest.h"
5
+
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+ #include <assert.h>
9
+ #ifndef _WIN32
10
+ # include <unistd.h>
11
+ #endif
12
+ #include <stdio.h>
13
+
14
+ #ifndef _WIN32
15
+ # include <sys/time.h>
16
+ #endif
17
+
18
+ typedef struct LsmDb LsmDb;
19
+ typedef struct LsmWorker LsmWorker;
20
+ typedef struct LsmFile LsmFile;
21
+
22
+ #define LSMTEST_DFLT_MT_MAX_CKPT (8*1024)
23
+ #define LSMTEST_DFLT_MT_MIN_CKPT (2*1024)
24
+
25
+ #ifdef LSM_MUTEX_PTHREADS
26
+ #include <pthread.h>
27
+
28
+ #define LSMTEST_THREAD_CKPT 1
29
+ #define LSMTEST_THREAD_WORKER 2
30
+ #define LSMTEST_THREAD_WORKER_AC 3
31
+
32
+ /*
33
+ ** There are several different types of worker threads that run in different
34
+ ** test configurations, depending on the value of LsmWorker.eType.
35
+ **
36
+ ** 1. Checkpointer.
37
+ ** 2. Worker with auto-checkpoint.
38
+ ** 3. Worker without auto-checkpoint.
39
+ */
40
+ struct LsmWorker {
41
+ LsmDb *pDb; /* Main database structure */
42
+ lsm_db *pWorker; /* Worker database handle */
43
+ pthread_t worker_thread; /* Worker thread */
44
+ pthread_cond_t worker_cond; /* Condition var the worker waits on */
45
+ pthread_mutex_t worker_mutex; /* Mutex used with worker_cond */
46
+ int bDoWork; /* Set to true by client when there is work */
47
+ int worker_rc; /* Store error code here */
48
+ int eType; /* LSMTEST_THREAD_XXX constant */
49
+ int bBlock;
50
+ };
51
+ #else
52
+ struct LsmWorker { int worker_rc; int bBlock; };
53
+ #endif
54
+
55
+ static void mt_shutdown(LsmDb *);
56
+
57
+ lsm_env *tdb_lsm_env(void){
58
+ static int bInit = 0;
59
+ static lsm_env env;
60
+ if( bInit==0 ){
61
+ memcpy(&env, lsm_default_env(), sizeof(env));
62
+ bInit = 1;
63
+ }
64
+ return &env;
65
+ }
66
+
67
+ typedef struct FileSector FileSector;
68
+ typedef struct FileData FileData;
69
+
70
+ struct FileSector {
71
+ u8 *aOld; /* Old data for this sector */
72
+ };
73
+
74
+ struct FileData {
75
+ int nSector; /* Allocated size of apSector[] array */
76
+ FileSector *aSector; /* Array of file sectors */
77
+ };
78
+
79
+ /*
80
+ ** bPrepareCrash:
81
+ ** If non-zero, the file wrappers maintain enough in-memory data to
82
+ ** simulate the effect of a power-failure on the file-system (i.e. that
83
+ ** unsynced sectors may be written, not written, or overwritten with
84
+ ** arbitrary data when the crash occurs).
85
+ **
86
+ ** bCrashed:
87
+ ** Set to true after a crash is simulated. Once this variable is true, all
88
+ ** VFS methods other than xClose() return LSM_IOERR as soon as they are
89
+ ** called (without affecting the contents of the file-system).
90
+ **
91
+ ** env:
92
+ ** The environment object used by all lsm_db* handles opened by this
93
+ ** object (i.e. LsmDb.db plus any worker connections). Variable env.pVfsCtx
94
+ ** always points to the containing LsmDb structure.
95
+ */
96
+ struct LsmDb {
97
+ TestDb base; /* Base class - methods table */
98
+ lsm_env env; /* Environment used by connection db */
99
+ char *zName; /* Database file name */
100
+ lsm_db *db; /* LSM database handle */
101
+
102
+ lsm_cursor *pCsr; /* Cursor held open during read transaction */
103
+ void *pBuf; /* Buffer for tdb_fetch() output */
104
+ int nBuf; /* Allocated (not used) size of pBuf */
105
+
106
+ /* Crash testing related state */
107
+ int bCrashed; /* True once a crash has occurred */
108
+ int nAutoCrash; /* Number of syncs until a crash */
109
+ int bPrepareCrash; /* True to store writes in memory */
110
+
111
+ /* Unsynced data (while crash testing) */
112
+ int szSector; /* Assumed size of disk sectors (512B) */
113
+ FileData aFile[2]; /* Database and log file data */
114
+
115
+ /* Other test instrumentation */
116
+ int bNoRecovery; /* If true, assume DMS2 is locked */
117
+
118
+ /* Work hook redirection */
119
+ void (*xWork)(lsm_db *, void *);
120
+ void *pWorkCtx;
121
+
122
+ /* IO logging hook */
123
+ void (*xWriteHook)(void *, int, lsm_i64, int, int);
124
+ void *pWriteCtx;
125
+
126
+ /* Worker threads (for lsm_mt) */
127
+ int nMtMinCkpt;
128
+ int nMtMaxCkpt;
129
+ int eMode;
130
+ int nWorker;
131
+ LsmWorker *aWorker;
132
+ };
133
+
134
+ #define LSMTEST_MODE_SINGLETHREAD 1
135
+ #define LSMTEST_MODE_BACKGROUND_CKPT 2
136
+ #define LSMTEST_MODE_BACKGROUND_WORK 3
137
+ #define LSMTEST_MODE_BACKGROUND_BOTH 4
138
+
139
+ /*************************************************************************
140
+ **************************************************************************
141
+ ** Begin test VFS code.
142
+ */
143
+
144
+ struct LsmFile {
145
+ lsm_file *pReal; /* Real underlying file */
146
+ int bLog; /* True for log file. False for db file */
147
+ LsmDb *pDb; /* Database handle that uses this file */
148
+ };
149
+
150
+ static int testEnvFullpath(
151
+ lsm_env *pEnv, /* Environment for current LsmDb */
152
+ const char *zFile, /* Relative path name */
153
+ char *zOut, /* Output buffer */
154
+ int *pnOut /* IN/OUT: Size of output buffer */
155
+ ){
156
+ lsm_env *pRealEnv = tdb_lsm_env();
157
+ return pRealEnv->xFullpath(pRealEnv, zFile, zOut, pnOut);
158
+ }
159
+
160
+ static int testEnvOpen(
161
+ lsm_env *pEnv, /* Environment for current LsmDb */
162
+ const char *zFile, /* Name of file to open */
163
+ int flags,
164
+ lsm_file **ppFile /* OUT: New file handle object */
165
+ ){
166
+ lsm_env *pRealEnv = tdb_lsm_env();
167
+ LsmDb *pDb = (LsmDb *)pEnv->pVfsCtx;
168
+ int rc; /* Return Code */
169
+ LsmFile *pRet; /* The new file handle */
170
+ int nFile; /* Length of string zFile in bytes */
171
+
172
+ nFile = strlen(zFile);
173
+ pRet = (LsmFile *)testMalloc(sizeof(LsmFile));
174
+ pRet->pDb = pDb;
175
+ pRet->bLog = (nFile > 4 && 0==memcmp("-log", &zFile[nFile-4], 4));
176
+
177
+ rc = pRealEnv->xOpen(pRealEnv, zFile, flags, &pRet->pReal);
178
+ if( rc!=LSM_OK ){
179
+ testFree(pRet);
180
+ pRet = 0;
181
+ }
182
+
183
+ *ppFile = (lsm_file *)pRet;
184
+ return rc;
185
+ }
186
+
187
+ static int testEnvRead(lsm_file *pFile, lsm_i64 iOff, void *pData, int nData){
188
+ lsm_env *pRealEnv = tdb_lsm_env();
189
+ LsmFile *p = (LsmFile *)pFile;
190
+ if( p->pDb->bCrashed ) return LSM_IOERR;
191
+ return pRealEnv->xRead(p->pReal, iOff, pData, nData);
192
+ }
193
+
194
+ static int testEnvWrite(lsm_file *pFile, lsm_i64 iOff, void *pData, int nData){
195
+ lsm_env *pRealEnv = tdb_lsm_env();
196
+ LsmFile *p = (LsmFile *)pFile;
197
+ LsmDb *pDb = p->pDb;
198
+
199
+ if( pDb->bCrashed ) return LSM_IOERR;
200
+
201
+ if( pDb->bPrepareCrash ){
202
+ FileData *pData2 = &pDb->aFile[p->bLog];
203
+ int iFirst;
204
+ int iLast;
205
+ int iSector;
206
+
207
+ iFirst = (int)(iOff / pDb->szSector);
208
+ iLast = (int)((iOff + nData - 1) / pDb->szSector);
209
+
210
+ if( pData2->nSector<(iLast+1) ){
211
+ int nNew = ( ((iLast + 1) + 63) / 64 ) * 64;
212
+ assert( nNew>iLast );
213
+ pData2->aSector = (FileSector *)testRealloc(
214
+ pData2->aSector, nNew*sizeof(FileSector)
215
+ );
216
+ memset(&pData2->aSector[pData2->nSector],
217
+ 0, (nNew - pData2->nSector) * sizeof(FileSector)
218
+ );
219
+ pData2->nSector = nNew;
220
+ }
221
+
222
+ for(iSector=iFirst; iSector<=iLast; iSector++){
223
+ if( pData2->aSector[iSector].aOld==0 ){
224
+ u8 *aOld = (u8 *)testMalloc(pDb->szSector);
225
+ pRealEnv->xRead(
226
+ p->pReal, (lsm_i64)iSector*pDb->szSector, aOld, pDb->szSector
227
+ );
228
+ pData2->aSector[iSector].aOld = aOld;
229
+ }
230
+ }
231
+ }
232
+
233
+ if( pDb->xWriteHook ){
234
+ int rc;
235
+ int nUs;
236
+ struct timeval t1;
237
+ struct timeval t2;
238
+
239
+ gettimeofday(&t1, 0);
240
+ assert( nData>0 );
241
+ rc = pRealEnv->xWrite(p->pReal, iOff, pData, nData);
242
+ gettimeofday(&t2, 0);
243
+
244
+ nUs = (t2.tv_sec - t1.tv_sec) * 1000000 + (t2.tv_usec - t1.tv_usec);
245
+ pDb->xWriteHook(pDb->pWriteCtx, p->bLog, iOff, nData, nUs);
246
+ return rc;
247
+ }
248
+
249
+ return pRealEnv->xWrite(p->pReal, iOff, pData, nData);
250
+ }
251
+
252
+ static void doSystemCrash(LsmDb *pDb);
253
+
254
+ static int testEnvSync(lsm_file *pFile){
255
+ lsm_env *pRealEnv = tdb_lsm_env();
256
+ LsmFile *p = (LsmFile *)pFile;
257
+ LsmDb *pDb = p->pDb;
258
+ FileData *pData = &pDb->aFile[p->bLog];
259
+ int i;
260
+
261
+ if( pDb->bCrashed ) return LSM_IOERR;
262
+
263
+ if( pDb->nAutoCrash ){
264
+ pDb->nAutoCrash--;
265
+ if( pDb->nAutoCrash==0 ){
266
+ doSystemCrash(pDb);
267
+ pDb->bCrashed = 1;
268
+ return LSM_IOERR;
269
+ }
270
+ }
271
+
272
+ if( pDb->bPrepareCrash ){
273
+ for(i=0; i<pData->nSector; i++){
274
+ testFree(pData->aSector[i].aOld);
275
+ pData->aSector[i].aOld = 0;
276
+ }
277
+ }
278
+
279
+ if( pDb->xWriteHook ){
280
+ int rc;
281
+ int nUs;
282
+ struct timeval t1;
283
+ struct timeval t2;
284
+
285
+ gettimeofday(&t1, 0);
286
+ rc = pRealEnv->xSync(p->pReal);
287
+ gettimeofday(&t2, 0);
288
+
289
+ nUs = (t2.tv_sec - t1.tv_sec) * 1000000 + (t2.tv_usec - t1.tv_usec);
290
+ pDb->xWriteHook(pDb->pWriteCtx, p->bLog, 0, 0, nUs);
291
+ return rc;
292
+ }
293
+
294
+ return pRealEnv->xSync(p->pReal);
295
+ }
296
+
297
+ static int testEnvTruncate(lsm_file *pFile, lsm_i64 iOff){
298
+ lsm_env *pRealEnv = tdb_lsm_env();
299
+ LsmFile *p = (LsmFile *)pFile;
300
+ if( p->pDb->bCrashed ) return LSM_IOERR;
301
+ return pRealEnv->xTruncate(p->pReal, iOff);
302
+ }
303
+
304
+ static int testEnvSectorSize(lsm_file *pFile){
305
+ lsm_env *pRealEnv = tdb_lsm_env();
306
+ LsmFile *p = (LsmFile *)pFile;
307
+ return pRealEnv->xSectorSize(p->pReal);
308
+ }
309
+
310
+ static int testEnvRemap(
311
+ lsm_file *pFile,
312
+ lsm_i64 iMin,
313
+ void **ppOut,
314
+ lsm_i64 *pnOut
315
+ ){
316
+ lsm_env *pRealEnv = tdb_lsm_env();
317
+ LsmFile *p = (LsmFile *)pFile;
318
+ return pRealEnv->xRemap(p->pReal, iMin, ppOut, pnOut);
319
+ }
320
+
321
+ static int testEnvFileid(
322
+ lsm_file *pFile,
323
+ void *ppOut,
324
+ int *pnOut
325
+ ){
326
+ lsm_env *pRealEnv = tdb_lsm_env();
327
+ LsmFile *p = (LsmFile *)pFile;
328
+ return pRealEnv->xFileid(p->pReal, ppOut, pnOut);
329
+ }
330
+
331
+ static int testEnvClose(lsm_file *pFile){
332
+ lsm_env *pRealEnv = tdb_lsm_env();
333
+ LsmFile *p = (LsmFile *)pFile;
334
+
335
+ pRealEnv->xClose(p->pReal);
336
+ testFree(p);
337
+ return LSM_OK;
338
+ }
339
+
340
+ static int testEnvUnlink(lsm_env *pEnv, const char *zFile){
341
+ lsm_env *pRealEnv = tdb_lsm_env();
342
+ unused_parameter(pEnv);
343
+ return pRealEnv->xUnlink(pRealEnv, zFile);
344
+ }
345
+
346
+ static int testEnvLock(lsm_file *pFile, int iLock, int eType){
347
+ LsmFile *p = (LsmFile *)pFile;
348
+ lsm_env *pRealEnv = tdb_lsm_env();
349
+
350
+ if( iLock==2 && eType==LSM_LOCK_EXCL && p->pDb->bNoRecovery ){
351
+ return LSM_BUSY;
352
+ }
353
+ return pRealEnv->xLock(p->pReal, iLock, eType);
354
+ }
355
+
356
+ static int testEnvTestLock(lsm_file *pFile, int iLock, int nLock, int eType){
357
+ LsmFile *p = (LsmFile *)pFile;
358
+ lsm_env *pRealEnv = tdb_lsm_env();
359
+
360
+ if( iLock==2 && eType==LSM_LOCK_EXCL && p->pDb->bNoRecovery ){
361
+ return LSM_BUSY;
362
+ }
363
+ return pRealEnv->xTestLock(p->pReal, iLock, nLock, eType);
364
+ }
365
+
366
+ static int testEnvShmMap(lsm_file *pFile, int iRegion, int sz, void **pp){
367
+ LsmFile *p = (LsmFile *)pFile;
368
+ lsm_env *pRealEnv = tdb_lsm_env();
369
+ return pRealEnv->xShmMap(p->pReal, iRegion, sz, pp);
370
+ }
371
+
372
+ static void testEnvShmBarrier(void){
373
+ }
374
+
375
+ static int testEnvShmUnmap(lsm_file *pFile, int bDel){
376
+ LsmFile *p = (LsmFile *)pFile;
377
+ lsm_env *pRealEnv = tdb_lsm_env();
378
+ return pRealEnv->xShmUnmap(p->pReal, bDel);
379
+ }
380
+
381
+ static int testEnvSleep(lsm_env *pEnv, int us){
382
+ lsm_env *pRealEnv = tdb_lsm_env();
383
+ return pRealEnv->xSleep(pRealEnv, us);
384
+ }
385
+
386
+ static void doSystemCrash(LsmDb *pDb){
387
+ lsm_env *pEnv = tdb_lsm_env();
388
+ int iFile;
389
+ int iSeed = pDb->aFile[0].nSector + pDb->aFile[1].nSector;
390
+
391
+ char *zFile = pDb->zName;
392
+ char *zFree = 0;
393
+
394
+ for(iFile=0; iFile<2; iFile++){
395
+ lsm_file *pFile = 0;
396
+ int i;
397
+
398
+ pEnv->xOpen(pEnv, zFile, 0, &pFile);
399
+ for(i=0; i<pDb->aFile[iFile].nSector; i++){
400
+ u8 *aOld = pDb->aFile[iFile].aSector[i].aOld;
401
+ if( aOld ){
402
+ int iOpt = testPrngValue(iSeed++) % 3;
403
+ switch( iOpt ){
404
+ case 0:
405
+ break;
406
+
407
+ case 1:
408
+ testPrngArray(iSeed++, (u32 *)aOld, pDb->szSector/4);
409
+ /* Fall-through */
410
+
411
+ case 2:
412
+ pEnv->xWrite(
413
+ pFile, (lsm_i64)i * pDb->szSector, aOld, pDb->szSector
414
+ );
415
+ break;
416
+ }
417
+ testFree(aOld);
418
+ pDb->aFile[iFile].aSector[i].aOld = 0;
419
+ }
420
+ }
421
+ pEnv->xClose(pFile);
422
+ zFree = zFile = sqlite3_mprintf("%s-log", pDb->zName);
423
+ }
424
+
425
+ sqlite3_free(zFree);
426
+ }
427
+ /*
428
+ ** End test VFS code.
429
+ **************************************************************************
430
+ *************************************************************************/
431
+
432
+ /*************************************************************************
433
+ **************************************************************************
434
+ ** Begin test compression hooks.
435
+ */
436
+
437
+ #ifdef HAVE_ZLIB
438
+ #include <zlib.h>
439
+
440
+ static int testZipBound(void *pCtx, int nSrc){
441
+ return compressBound(nSrc);
442
+ }
443
+
444
+ static int testZipCompress(
445
+ void *pCtx, /* Context pointer */
446
+ char *aOut, int *pnOut, /* OUT: Buffer containing compressed data */
447
+ const char *aIn, int nIn /* Buffer containing input data */
448
+ ){
449
+ uLongf n = *pnOut; /* In/out buffer size for compress() */
450
+ int rc; /* compress() return code */
451
+
452
+ rc = compress((Bytef*)aOut, &n, (Bytef*)aIn, nIn);
453
+ *pnOut = n;
454
+ return (rc==Z_OK ? 0 : LSM_ERROR);
455
+ }
456
+
457
+ static int testZipUncompress(
458
+ void *pCtx, /* Context pointer */
459
+ char *aOut, int *pnOut, /* OUT: Buffer containing uncompressed data */
460
+ const char *aIn, int nIn /* Buffer containing input data */
461
+ ){
462
+ uLongf n = *pnOut; /* In/out buffer size for uncompress() */
463
+ int rc; /* uncompress() return code */
464
+
465
+ rc = uncompress((Bytef*)aOut, &n, (Bytef*)aIn, nIn);
466
+ *pnOut = n;
467
+ return (rc==Z_OK ? 0 : LSM_ERROR);
468
+ }
469
+
470
+ static int testConfigureCompression(lsm_db *pDb){
471
+ static lsm_compress zip = {
472
+ 0, /* Context pointer (unused) */
473
+ 1, /* Id value */
474
+ testZipBound, /* xBound method */
475
+ testZipCompress, /* xCompress method */
476
+ testZipUncompress /* xUncompress method */
477
+ };
478
+ return lsm_config(pDb, LSM_CONFIG_SET_COMPRESSION, &zip);
479
+ }
480
+ #endif /* ifdef HAVE_ZLIB */
481
+
482
+ /*
483
+ ** End test compression hooks.
484
+ **************************************************************************
485
+ *************************************************************************/
486
+
487
+ static int test_lsm_close(TestDb *pTestDb){
488
+ int i;
489
+ int rc = LSM_OK;
490
+ LsmDb *pDb = (LsmDb *)pTestDb;
491
+
492
+ lsm_csr_close(pDb->pCsr);
493
+ lsm_close(pDb->db);
494
+
495
+ /* If this is a multi-threaded database, wait on the worker threads. */
496
+ mt_shutdown(pDb);
497
+ for(i=0; i<pDb->nWorker && rc==LSM_OK; i++){
498
+ rc = pDb->aWorker[i].worker_rc;
499
+ }
500
+
501
+ for(i=0; i<pDb->aFile[0].nSector; i++){
502
+ testFree(pDb->aFile[0].aSector[i].aOld);
503
+ }
504
+ testFree(pDb->aFile[0].aSector);
505
+ for(i=0; i<pDb->aFile[1].nSector; i++){
506
+ testFree(pDb->aFile[1].aSector[i].aOld);
507
+ }
508
+ testFree(pDb->aFile[1].aSector);
509
+
510
+ memset(pDb, sizeof(LsmDb), 0x11);
511
+ testFree((char *)pDb->pBuf);
512
+ testFree((char *)pDb);
513
+ return rc;
514
+ }
515
+
516
+ static void mt_signal_worker(LsmDb*, int);
517
+
518
+ static int waitOnCheckpointer(LsmDb *pDb, lsm_db *db){
519
+ int nSleep = 0;
520
+ int nKB;
521
+ int rc;
522
+
523
+ do {
524
+ nKB = 0;
525
+ rc = lsm_info(db, LSM_INFO_CHECKPOINT_SIZE, &nKB);
526
+ if( rc!=LSM_OK || nKB<pDb->nMtMaxCkpt ) break;
527
+ #ifdef LSM_MUTEX_PTHREADS
528
+ mt_signal_worker(pDb,
529
+ (pDb->eMode==LSMTEST_MODE_BACKGROUND_CKPT ? 0 : 1)
530
+ );
531
+ #endif
532
+ usleep(5000);
533
+ nSleep += 5;
534
+ }while( 1 );
535
+
536
+ #if 0
537
+ if( nSleep ) printf("# waitOnCheckpointer(): nSleep=%d\n", nSleep);
538
+ #endif
539
+
540
+ return rc;
541
+ }
542
+
543
+ static int waitOnWorker(LsmDb *pDb){
544
+ int rc;
545
+ int nLimit = -1;
546
+ int nSleep = 0;
547
+
548
+ rc = lsm_config(pDb->db, LSM_CONFIG_AUTOFLUSH, &nLimit);
549
+ do {
550
+ int nOld, nNew, rc2;
551
+ rc2 = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);
552
+ if( rc2!=LSM_OK ) return rc2;
553
+ if( nOld==0 || nNew<(nLimit/2) ) break;
554
+ #ifdef LSM_MUTEX_PTHREADS
555
+ mt_signal_worker(pDb, 0);
556
+ #endif
557
+ usleep(5000);
558
+ nSleep += 5;
559
+ }while( 1 );
560
+
561
+ #if 0
562
+ if( nSleep ) printf("# waitOnWorker(): nSleep=%d\n", nSleep);
563
+ #endif
564
+
565
+ return rc;
566
+ }
567
+
568
+ static int test_lsm_write(
569
+ TestDb *pTestDb,
570
+ void *pKey,
571
+ int nKey,
572
+ void *pVal,
573
+ int nVal
574
+ ){
575
+ LsmDb *pDb = (LsmDb *)pTestDb;
576
+ int rc = LSM_OK;
577
+
578
+ if( pDb->eMode==LSMTEST_MODE_BACKGROUND_CKPT ){
579
+ rc = waitOnCheckpointer(pDb, pDb->db);
580
+ }else if(
581
+ pDb->eMode==LSMTEST_MODE_BACKGROUND_WORK
582
+ || pDb->eMode==LSMTEST_MODE_BACKGROUND_BOTH
583
+ ){
584
+ rc = waitOnWorker(pDb);
585
+ }
586
+
587
+ if( rc==LSM_OK ){
588
+ rc = lsm_insert(pDb->db, pKey, nKey, pVal, nVal);
589
+ }
590
+ return rc;
591
+ }
592
+
593
+ static int test_lsm_delete(TestDb *pTestDb, void *pKey, int nKey){
594
+ LsmDb *pDb = (LsmDb *)pTestDb;
595
+ return lsm_delete(pDb->db, pKey, nKey);
596
+ }
597
+
598
+ static int test_lsm_delete_range(
599
+ TestDb *pTestDb,
600
+ void *pKey1, int nKey1,
601
+ void *pKey2, int nKey2
602
+ ){
603
+ LsmDb *pDb = (LsmDb *)pTestDb;
604
+ return lsm_delete_range(pDb->db, pKey1, nKey1, pKey2, nKey2);
605
+ }
606
+
607
+ static int test_lsm_fetch(
608
+ TestDb *pTestDb,
609
+ void *pKey,
610
+ int nKey,
611
+ void **ppVal,
612
+ int *pnVal
613
+ ){
614
+ int rc;
615
+ LsmDb *pDb = (LsmDb *)pTestDb;
616
+ lsm_cursor *csr;
617
+
618
+ if( pKey==0 ) return LSM_OK;
619
+
620
+ if( pDb->pCsr==0 ){
621
+ rc = lsm_csr_open(pDb->db, &csr);
622
+ if( rc!=LSM_OK ) return rc;
623
+ }else{
624
+ csr = pDb->pCsr;
625
+ }
626
+
627
+ rc = lsm_csr_seek(csr, pKey, nKey, LSM_SEEK_EQ);
628
+ if( rc==LSM_OK ){
629
+ if( lsm_csr_valid(csr) ){
630
+ const void *pVal; int nVal;
631
+ rc = lsm_csr_value(csr, &pVal, &nVal);
632
+ if( nVal>pDb->nBuf ){
633
+ testFree(pDb->pBuf);
634
+ pDb->pBuf = testMalloc(nVal*2);
635
+ pDb->nBuf = nVal*2;
636
+ }
637
+ memcpy(pDb->pBuf, pVal, nVal);
638
+ *ppVal = pDb->pBuf;
639
+ *pnVal = nVal;
640
+ }else{
641
+ *ppVal = 0;
642
+ *pnVal = -1;
643
+ }
644
+ }
645
+ if( pDb->pCsr==0 ){
646
+ lsm_csr_close(csr);
647
+ }
648
+ return rc;
649
+ }
650
+
651
+ static int test_lsm_scan(
652
+ TestDb *pTestDb,
653
+ void *pCtx,
654
+ int bReverse,
655
+ void *pFirst, int nFirst,
656
+ void *pLast, int nLast,
657
+ void (*xCallback)(void *, void *, int , void *, int)
658
+ ){
659
+ LsmDb *pDb = (LsmDb *)pTestDb;
660
+ lsm_cursor *csr;
661
+ lsm_cursor *csr2 = 0;
662
+ int rc;
663
+
664
+ if( pDb->pCsr==0 ){
665
+ rc = lsm_csr_open(pDb->db, &csr);
666
+ if( rc!=LSM_OK ) return rc;
667
+ }else{
668
+ rc = LSM_OK;
669
+ csr = pDb->pCsr;
670
+ }
671
+
672
+ /* To enhance testing, if both pLast and pFirst are defined, seek the
673
+ ** cursor to the "end" boundary here. Then the next block seeks it to
674
+ ** the "start" ready for the scan. The point is to test that cursors
675
+ ** can be reused. */
676
+ if( pLast && pFirst ){
677
+ if( bReverse ){
678
+ rc = lsm_csr_seek(csr, pFirst, nFirst, LSM_SEEK_LE);
679
+ }else{
680
+ rc = lsm_csr_seek(csr, pLast, nLast, LSM_SEEK_GE);
681
+ }
682
+ }
683
+
684
+ if( bReverse ){
685
+ if( pLast ){
686
+ rc = lsm_csr_seek(csr, pLast, nLast, LSM_SEEK_LE);
687
+ }else{
688
+ rc = lsm_csr_last(csr);
689
+ }
690
+ }else{
691
+ if( pFirst ){
692
+ rc = lsm_csr_seek(csr, pFirst, nFirst, LSM_SEEK_GE);
693
+ }else{
694
+ rc = lsm_csr_first(csr);
695
+ }
696
+ }
697
+
698
+ while( rc==LSM_OK && lsm_csr_valid(csr) ){
699
+ const void *pKey; int nKey;
700
+ const void *pVal; int nVal;
701
+ int cmp;
702
+
703
+ lsm_csr_key(csr, &pKey, &nKey);
704
+ lsm_csr_value(csr, &pVal, &nVal);
705
+
706
+ if( bReverse && pFirst ){
707
+ cmp = memcmp(pFirst, pKey, MIN(nKey, nFirst));
708
+ if( cmp>0 || (cmp==0 && nFirst>nKey) ) break;
709
+ }else if( bReverse==0 && pLast ){
710
+ cmp = memcmp(pLast, pKey, MIN(nKey, nLast));
711
+ if( cmp<0 || (cmp==0 && nLast<nKey) ) break;
712
+ }
713
+
714
+ xCallback(pCtx, (void *)pKey, nKey, (void *)pVal, nVal);
715
+
716
+ if( bReverse ){
717
+ rc = lsm_csr_prev(csr);
718
+ }else{
719
+ rc = lsm_csr_next(csr);
720
+ }
721
+ }
722
+
723
+ if( pDb->pCsr==0 ){
724
+ lsm_csr_close(csr);
725
+ }
726
+ return rc;
727
+ }
728
+
729
+ static int test_lsm_begin(TestDb *pTestDb, int iLevel){
730
+ int rc = LSM_OK;
731
+ LsmDb *pDb = (LsmDb *)pTestDb;
732
+
733
+ /* iLevel==0 is a no-op. */
734
+ if( iLevel==0 ) return 0;
735
+
736
+ if( pDb->pCsr==0 ) rc = lsm_csr_open(pDb->db, &pDb->pCsr);
737
+ if( rc==LSM_OK && iLevel>1 ){
738
+ rc = lsm_begin(pDb->db, iLevel-1);
739
+ }
740
+
741
+ return rc;
742
+ }
743
+ static int test_lsm_commit(TestDb *pTestDb, int iLevel){
744
+ LsmDb *pDb = (LsmDb *)pTestDb;
745
+
746
+ /* If iLevel==0, close any open read transaction */
747
+ if( iLevel==0 && pDb->pCsr ){
748
+ lsm_csr_close(pDb->pCsr);
749
+ pDb->pCsr = 0;
750
+ }
751
+
752
+ /* If iLevel==0, close any open read transaction */
753
+ return lsm_commit(pDb->db, MAX(0, iLevel-1));
754
+ }
755
+ static int test_lsm_rollback(TestDb *pTestDb, int iLevel){
756
+ LsmDb *pDb = (LsmDb *)pTestDb;
757
+
758
+ /* If iLevel==0, close any open read transaction */
759
+ if( iLevel==0 && pDb->pCsr ){
760
+ lsm_csr_close(pDb->pCsr);
761
+ pDb->pCsr = 0;
762
+ }
763
+
764
+ return lsm_rollback(pDb->db, MAX(0, iLevel-1));
765
+ }
766
+
767
+ /*
768
+ ** A log message callback registered with lsm connections. Prints all
769
+ ** messages to stderr.
770
+ */
771
+ static void xLog(void *pCtx, int rc, const char *z){
772
+ unused_parameter(rc);
773
+ /* fprintf(stderr, "lsm: rc=%d \"%s\"\n", rc, z); */
774
+ if( pCtx ) fprintf(stderr, "%s: ", (char *)pCtx);
775
+ fprintf(stderr, "%s\n", z);
776
+ fflush(stderr);
777
+ }
778
+
779
+ static void xWorkHook(lsm_db *db, void *pArg){
780
+ LsmDb *p = (LsmDb *)pArg;
781
+ if( p->xWork ) p->xWork(db, p->pWorkCtx);
782
+ }
783
+
784
+ #define TEST_NO_RECOVERY -1
785
+ #define TEST_COMPRESSION -3
786
+
787
+ #define TEST_MT_MODE -2
788
+ #define TEST_MT_MIN_CKPT -4
789
+ #define TEST_MT_MAX_CKPT -5
790
+
791
+
792
+ int test_lsm_config_str(
793
+ LsmDb *pLsm,
794
+ lsm_db *db,
795
+ int bWorker,
796
+ const char *zStr,
797
+ int *pnThread
798
+ ){
799
+ struct CfgParam {
800
+ const char *zParam;
801
+ int bWorker;
802
+ int eParam;
803
+ } aParam[] = {
804
+ { "autoflush", 0, LSM_CONFIG_AUTOFLUSH },
805
+ { "page_size", 0, LSM_CONFIG_PAGE_SIZE },
806
+ { "block_size", 0, LSM_CONFIG_BLOCK_SIZE },
807
+ { "safety", 0, LSM_CONFIG_SAFETY },
808
+ { "autowork", 0, LSM_CONFIG_AUTOWORK },
809
+ { "autocheckpoint", 0, LSM_CONFIG_AUTOCHECKPOINT },
810
+ { "mmap", 0, LSM_CONFIG_MMAP },
811
+ { "use_log", 0, LSM_CONFIG_USE_LOG },
812
+ { "automerge", 0, LSM_CONFIG_AUTOMERGE },
813
+ { "max_freelist", 0, LSM_CONFIG_MAX_FREELIST },
814
+ { "multi_proc", 0, LSM_CONFIG_MULTIPLE_PROCESSES },
815
+ { "worker_automerge", 1, LSM_CONFIG_AUTOMERGE },
816
+ { "test_no_recovery", 0, TEST_NO_RECOVERY },
817
+ { "bg_min_ckpt", 0, TEST_NO_RECOVERY },
818
+
819
+ { "mt_mode", 0, TEST_MT_MODE },
820
+ { "mt_min_ckpt", 0, TEST_MT_MIN_CKPT },
821
+ { "mt_max_ckpt", 0, TEST_MT_MAX_CKPT },
822
+
823
+ #ifdef HAVE_ZLIB
824
+ { "compression", 0, TEST_COMPRESSION },
825
+ #endif
826
+ { 0, 0 }
827
+ };
828
+ const char *z = zStr;
829
+ int nThread = 1;
830
+
831
+ if( zStr==0 ) return 0;
832
+
833
+ assert( db );
834
+ while( z[0] ){
835
+ const char *zStart;
836
+
837
+ /* Skip whitespace */
838
+ while( *z==' ' ) z++;
839
+ zStart = z;
840
+
841
+ while( *z && *z!='=' ) z++;
842
+ if( *z ){
843
+ int eParam;
844
+ int i;
845
+ int iVal;
846
+ int iMul = 1;
847
+ int rc;
848
+ char zParam[32];
849
+ int nParam = z-zStart;
850
+ if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error;
851
+
852
+ memcpy(zParam, zStart, nParam);
853
+ zParam[nParam] = '\0';
854
+ rc = testArgSelect(aParam, "param", zParam, &i);
855
+ if( rc!=0 ) return rc;
856
+ eParam = aParam[i].eParam;
857
+
858
+ z++;
859
+ zStart = z;
860
+ while( *z>='0' && *z<='9' ) z++;
861
+ if( *z=='k' || *z=='K' ){
862
+ iMul = 1;
863
+ z++;
864
+ }else if( *z=='M' || *z=='M' ){
865
+ iMul = 1024;
866
+ z++;
867
+ }
868
+ nParam = z-zStart;
869
+ if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error;
870
+ memcpy(zParam, zStart, nParam);
871
+ zParam[nParam] = '\0';
872
+ iVal = atoi(zParam) * iMul;
873
+
874
+ if( eParam>0 ){
875
+ if( bWorker || aParam[i].bWorker==0 ){
876
+ lsm_config(db, eParam, &iVal);
877
+ }
878
+ }else{
879
+ switch( eParam ){
880
+ case TEST_NO_RECOVERY:
881
+ if( pLsm ) pLsm->bNoRecovery = iVal;
882
+ break;
883
+ case TEST_MT_MODE:
884
+ if( pLsm ) nThread = iVal;
885
+ break;
886
+ case TEST_MT_MIN_CKPT:
887
+ if( pLsm && iVal>0 ) pLsm->nMtMinCkpt = iVal*1024;
888
+ break;
889
+ case TEST_MT_MAX_CKPT:
890
+ if( pLsm && iVal>0 ) pLsm->nMtMaxCkpt = iVal*1024;
891
+ break;
892
+ #ifdef HAVE_ZLIB
893
+ case TEST_COMPRESSION:
894
+ testConfigureCompression(db);
895
+ break;
896
+ #endif
897
+ }
898
+ }
899
+ }else if( z!=zStart ){
900
+ goto syntax_error;
901
+ }
902
+ }
903
+
904
+ if( pnThread ) *pnThread = nThread;
905
+ if( pLsm && pLsm->nMtMaxCkpt < pLsm->nMtMinCkpt ){
906
+ pLsm->nMtMinCkpt = pLsm->nMtMaxCkpt;
907
+ }
908
+
909
+ return 0;
910
+ syntax_error:
911
+ testPrintError("syntax error at: \"%s\"\n", z);
912
+ return 1;
913
+ }
914
+
915
+ int tdb_lsm_config_str(TestDb *pDb, const char *zStr){
916
+ int rc = 0;
917
+ if( tdb_lsm(pDb) ){
918
+ #ifdef LSM_MUTEX_PTHREADS
919
+ int i;
920
+ #endif
921
+ LsmDb *pLsm = (LsmDb *)pDb;
922
+
923
+ rc = test_lsm_config_str(pLsm, pLsm->db, 0, zStr, 0);
924
+ #ifdef LSM_MUTEX_PTHREADS
925
+ for(i=0; rc==0 && i<pLsm->nWorker; i++){
926
+ rc = test_lsm_config_str(0, pLsm->aWorker[i].pWorker, 1, zStr, 0);
927
+ }
928
+ #endif
929
+ }
930
+ return rc;
931
+ }
932
+
933
+ int tdb_lsm_configure(lsm_db *db, const char *zConfig){
934
+ return test_lsm_config_str(0, db, 0, zConfig, 0);
935
+ }
936
+
937
+ static int testLsmStartWorkers(LsmDb *, int, const char *, const char *);
938
+
939
+ static int testLsmOpen(
940
+ const char *zCfg,
941
+ const char *zFilename,
942
+ int bClear,
943
+ TestDb **ppDb
944
+ ){
945
+ static const DatabaseMethods LsmMethods = {
946
+ test_lsm_close,
947
+ test_lsm_write,
948
+ test_lsm_delete,
949
+ test_lsm_delete_range,
950
+ test_lsm_fetch,
951
+ test_lsm_scan,
952
+ test_lsm_begin,
953
+ test_lsm_commit,
954
+ test_lsm_rollback
955
+ };
956
+
957
+ int rc;
958
+ int nFilename;
959
+ LsmDb *pDb;
960
+
961
+ /* If the bClear flag is set, delete any existing database. */
962
+ assert( zFilename);
963
+ if( bClear ) testDeleteLsmdb(zFilename);
964
+ nFilename = strlen(zFilename);
965
+
966
+ pDb = (LsmDb *)testMalloc(sizeof(LsmDb) + nFilename + 1);
967
+ memset(pDb, 0, sizeof(LsmDb));
968
+ pDb->base.pMethods = &LsmMethods;
969
+ pDb->zName = (char *)&pDb[1];
970
+ memcpy(pDb->zName, zFilename, nFilename + 1);
971
+
972
+ /* Default the sector size used for crash simulation to 512 bytes.
973
+ ** Todo: There should be an OS method to obtain this value - just as
974
+ ** there is in SQLite. For now, LSM assumes that it is smaller than
975
+ ** the page size (default 4KB).
976
+ */
977
+ pDb->szSector = 256;
978
+
979
+ /* Default values for the mt_min_ckpt and mt_max_ckpt parameters. */
980
+ pDb->nMtMinCkpt = LSMTEST_DFLT_MT_MIN_CKPT;
981
+ pDb->nMtMaxCkpt = LSMTEST_DFLT_MT_MAX_CKPT;
982
+
983
+ memcpy(&pDb->env, tdb_lsm_env(), sizeof(lsm_env));
984
+ pDb->env.pVfsCtx = (void *)pDb;
985
+ pDb->env.xFullpath = testEnvFullpath;
986
+ pDb->env.xOpen = testEnvOpen;
987
+ pDb->env.xRead = testEnvRead;
988
+ pDb->env.xWrite = testEnvWrite;
989
+ pDb->env.xTruncate = testEnvTruncate;
990
+ pDb->env.xSync = testEnvSync;
991
+ pDb->env.xSectorSize = testEnvSectorSize;
992
+ pDb->env.xRemap = testEnvRemap;
993
+ pDb->env.xFileid = testEnvFileid;
994
+ pDb->env.xClose = testEnvClose;
995
+ pDb->env.xUnlink = testEnvUnlink;
996
+ pDb->env.xLock = testEnvLock;
997
+ pDb->env.xTestLock = testEnvTestLock;
998
+ pDb->env.xShmBarrier = testEnvShmBarrier;
999
+ pDb->env.xShmMap = testEnvShmMap;
1000
+ pDb->env.xShmUnmap = testEnvShmUnmap;
1001
+ pDb->env.xSleep = testEnvSleep;
1002
+
1003
+ rc = lsm_new(&pDb->env, &pDb->db);
1004
+ if( rc==LSM_OK ){
1005
+ int nThread = 1;
1006
+ lsm_config_log(pDb->db, xLog, 0);
1007
+ lsm_config_work_hook(pDb->db, xWorkHook, (void *)pDb);
1008
+
1009
+ rc = test_lsm_config_str(pDb, pDb->db, 0, zCfg, &nThread);
1010
+ if( rc==LSM_OK ) rc = lsm_open(pDb->db, zFilename);
1011
+
1012
+ pDb->eMode = nThread;
1013
+ #ifdef LSM_MUTEX_PTHREADS
1014
+ if( rc==LSM_OK && nThread>1 ){
1015
+ testLsmStartWorkers(pDb, nThread, zFilename, zCfg);
1016
+ }
1017
+ #endif
1018
+
1019
+ if( rc!=LSM_OK ){
1020
+ test_lsm_close((TestDb *)pDb);
1021
+ pDb = 0;
1022
+ }
1023
+ }
1024
+
1025
+ *ppDb = (TestDb *)pDb;
1026
+ return rc;
1027
+ }
1028
+
1029
+ int test_lsm_open(
1030
+ const char *zSpec,
1031
+ const char *zFilename,
1032
+ int bClear,
1033
+ TestDb **ppDb
1034
+ ){
1035
+ return testLsmOpen(zSpec, zFilename, bClear, ppDb);
1036
+ }
1037
+
1038
+ int test_lsm_small_open(
1039
+ const char *zSpec,
1040
+ const char *zFile,
1041
+ int bClear,
1042
+ TestDb **ppDb
1043
+ ){
1044
+ const char *zCfg = "page_size=256 block_size=64 mmap=1024";
1045
+ return testLsmOpen(zCfg, zFile, bClear, ppDb);
1046
+ }
1047
+
1048
+ int test_lsm_lomem_open(
1049
+ const char *zSpec,
1050
+ const char *zFilename,
1051
+ int bClear,
1052
+ TestDb **ppDb
1053
+ ){
1054
+ /* "max_freelist=4 autocheckpoint=32" */
1055
+ const char *zCfg =
1056
+ "page_size=256 block_size=64 autoflush=16 "
1057
+ "autocheckpoint=32"
1058
+ "mmap=0 "
1059
+ ;
1060
+ return testLsmOpen(zCfg, zFilename, bClear, ppDb);
1061
+ }
1062
+
1063
+ int test_lsm_lomem2_open(
1064
+ const char *zSpec,
1065
+ const char *zFilename,
1066
+ int bClear,
1067
+ TestDb **ppDb
1068
+ ){
1069
+ /* "max_freelist=4 autocheckpoint=32" */
1070
+ const char *zCfg =
1071
+ "page_size=512 block_size=64 autoflush=0 mmap=0 "
1072
+ ;
1073
+ return testLsmOpen(zCfg, zFilename, bClear, ppDb);
1074
+ }
1075
+
1076
+ int test_lsm_zip_open(
1077
+ const char *zSpec,
1078
+ const char *zFilename,
1079
+ int bClear,
1080
+ TestDb **ppDb
1081
+ ){
1082
+ const char *zCfg =
1083
+ "page_size=256 block_size=64 autoflush=16 "
1084
+ "autocheckpoint=32 compression=1 mmap=0 "
1085
+ ;
1086
+ return testLsmOpen(zCfg, zFilename, bClear, ppDb);
1087
+ }
1088
+
1089
+ lsm_db *tdb_lsm(TestDb *pDb){
1090
+ if( pDb->pMethods->xClose==test_lsm_close ){
1091
+ return ((LsmDb *)pDb)->db;
1092
+ }
1093
+ return 0;
1094
+ }
1095
+
1096
+ int tdb_lsm_multithread(TestDb *pDb){
1097
+ int ret = 0;
1098
+ if( tdb_lsm(pDb) ){
1099
+ ret = ((LsmDb*)pDb)->eMode!=LSMTEST_MODE_SINGLETHREAD;
1100
+ }
1101
+ return ret;
1102
+ }
1103
+
1104
+ void tdb_lsm_enable_log(TestDb *pDb, int bEnable){
1105
+ lsm_db *db = tdb_lsm(pDb);
1106
+ if( db ){
1107
+ lsm_config_log(db, (bEnable ? xLog : 0), (void *)"client");
1108
+ }
1109
+ }
1110
+
1111
+ void tdb_lsm_application_crash(TestDb *pDb){
1112
+ if( tdb_lsm(pDb) ){
1113
+ LsmDb *p = (LsmDb *)pDb;
1114
+ p->bCrashed = 1;
1115
+ }
1116
+ }
1117
+
1118
+ void tdb_lsm_prepare_system_crash(TestDb *pDb){
1119
+ if( tdb_lsm(pDb) ){
1120
+ LsmDb *p = (LsmDb *)pDb;
1121
+ p->bPrepareCrash = 1;
1122
+ }
1123
+ }
1124
+
1125
+ void tdb_lsm_system_crash(TestDb *pDb){
1126
+ if( tdb_lsm(pDb) ){
1127
+ LsmDb *p = (LsmDb *)pDb;
1128
+ p->bCrashed = 1;
1129
+ doSystemCrash(p);
1130
+ }
1131
+ }
1132
+
1133
+ void tdb_lsm_safety(TestDb *pDb, int eMode){
1134
+ assert( eMode==LSM_SAFETY_OFF
1135
+ || eMode==LSM_SAFETY_NORMAL
1136
+ || eMode==LSM_SAFETY_FULL
1137
+ );
1138
+ if( tdb_lsm(pDb) ){
1139
+ int iParam = eMode;
1140
+ LsmDb *p = (LsmDb *)pDb;
1141
+ lsm_config(p->db, LSM_CONFIG_SAFETY, &iParam);
1142
+ }
1143
+ }
1144
+
1145
+ void tdb_lsm_prepare_sync_crash(TestDb *pDb, int iSync){
1146
+ assert( iSync>0 );
1147
+ if( tdb_lsm(pDb) ){
1148
+ LsmDb *p = (LsmDb *)pDb;
1149
+ p->nAutoCrash = iSync;
1150
+ p->bPrepareCrash = 1;
1151
+ }
1152
+ }
1153
+
1154
+ void tdb_lsm_config_work_hook(
1155
+ TestDb *pDb,
1156
+ void (*xWork)(lsm_db *, void *),
1157
+ void *pWorkCtx
1158
+ ){
1159
+ if( tdb_lsm(pDb) ){
1160
+ LsmDb *p = (LsmDb *)pDb;
1161
+ p->xWork = xWork;
1162
+ p->pWorkCtx = pWorkCtx;
1163
+ }
1164
+ }
1165
+
1166
+ void tdb_lsm_write_hook(
1167
+ TestDb *pDb,
1168
+ void (*xWrite)(void *, int, lsm_i64, int, int),
1169
+ void *pWriteCtx
1170
+ ){
1171
+ if( tdb_lsm(pDb) ){
1172
+ LsmDb *p = (LsmDb *)pDb;
1173
+ p->xWriteHook = xWrite;
1174
+ p->pWriteCtx = pWriteCtx;
1175
+ }
1176
+ }
1177
+
1178
+ int tdb_lsm_open(const char *zCfg, const char *zDb, int bClear, TestDb **ppDb){
1179
+ return testLsmOpen(zCfg, zDb, bClear, ppDb);
1180
+ }
1181
+
1182
+ #ifdef LSM_MUTEX_PTHREADS
1183
+
1184
+ /*
1185
+ ** Signal worker thread iWorker that there may be work to do.
1186
+ */
1187
+ static void mt_signal_worker(LsmDb *pDb, int iWorker){
1188
+ LsmWorker *p = &pDb->aWorker[iWorker];
1189
+ pthread_mutex_lock(&p->worker_mutex);
1190
+ p->bDoWork = 1;
1191
+ pthread_cond_signal(&p->worker_cond);
1192
+ pthread_mutex_unlock(&p->worker_mutex);
1193
+ }
1194
+
1195
+ /*
1196
+ ** This routine is used as the main() for all worker threads.
1197
+ */
1198
+ static void *worker_main(void *pArg){
1199
+ LsmWorker *p = (LsmWorker *)pArg;
1200
+ lsm_db *pWorker; /* Connection to access db through */
1201
+
1202
+ pthread_mutex_lock(&p->worker_mutex);
1203
+ while( (pWorker = p->pWorker) ){
1204
+ int rc = LSM_OK;
1205
+
1206
+ /* Do some work. If an error occurs, exit. */
1207
+
1208
+ pthread_mutex_unlock(&p->worker_mutex);
1209
+ if( p->eType==LSMTEST_THREAD_CKPT ){
1210
+ int nKB = 0;
1211
+ rc = lsm_info(pWorker, LSM_INFO_CHECKPOINT_SIZE, &nKB);
1212
+ if( rc==LSM_OK && nKB>=p->pDb->nMtMinCkpt ){
1213
+ rc = lsm_checkpoint(pWorker, 0);
1214
+ }
1215
+ }else{
1216
+ int nWrite;
1217
+ do {
1218
+
1219
+ if( p->eType==LSMTEST_THREAD_WORKER ){
1220
+ waitOnCheckpointer(p->pDb, pWorker);
1221
+ }
1222
+
1223
+ nWrite = 0;
1224
+ rc = lsm_work(pWorker, 0, 256, &nWrite);
1225
+
1226
+ if( p->eType==LSMTEST_THREAD_WORKER && nWrite ){
1227
+ mt_signal_worker(p->pDb, 1);
1228
+ }
1229
+ }while( nWrite && p->pWorker );
1230
+ }
1231
+ pthread_mutex_lock(&p->worker_mutex);
1232
+
1233
+ if( rc!=LSM_OK && rc!=LSM_BUSY ){
1234
+ p->worker_rc = rc;
1235
+ break;
1236
+ }
1237
+
1238
+ /* The thread will wake up when it is signaled either because another
1239
+ ** thread has created some work for this one or because the connection
1240
+ ** is being closed. */
1241
+ if( p->pWorker && p->bDoWork==0 ){
1242
+ pthread_cond_wait(&p->worker_cond, &p->worker_mutex);
1243
+ }
1244
+ p->bDoWork = 0;
1245
+ }
1246
+ pthread_mutex_unlock(&p->worker_mutex);
1247
+
1248
+ return 0;
1249
+ }
1250
+
1251
+
1252
+ static void mt_stop_worker(LsmDb *pDb, int iWorker){
1253
+ LsmWorker *p = &pDb->aWorker[iWorker];
1254
+ if( p->pWorker ){
1255
+ void *pDummy;
1256
+ lsm_db *pWorker;
1257
+
1258
+ /* Signal the worker to stop */
1259
+ pthread_mutex_lock(&p->worker_mutex);
1260
+ pWorker = p->pWorker;
1261
+ p->pWorker = 0;
1262
+ pthread_cond_signal(&p->worker_cond);
1263
+ pthread_mutex_unlock(&p->worker_mutex);
1264
+
1265
+ /* Join the worker thread. */
1266
+ pthread_join(p->worker_thread, &pDummy);
1267
+
1268
+ /* Free resources allocated in mt_start_worker() */
1269
+ pthread_cond_destroy(&p->worker_cond);
1270
+ pthread_mutex_destroy(&p->worker_mutex);
1271
+ lsm_close(pWorker);
1272
+ }
1273
+ }
1274
+
1275
+ static void mt_shutdown(LsmDb *pDb){
1276
+ int i;
1277
+ for(i=0; i<pDb->nWorker; i++){
1278
+ mt_stop_worker(pDb, i);
1279
+ }
1280
+ }
1281
+
1282
+ /*
1283
+ ** This callback is invoked by LSM when the client database writes to
1284
+ ** the database file (i.e. to flush the contents of the in-memory tree).
1285
+ ** This implies there may be work to do on the database, so signal
1286
+ ** the worker threads.
1287
+ */
1288
+ static void mt_client_work_hook(lsm_db *db, void *pArg){
1289
+ LsmDb *pDb = (LsmDb *)pArg; /* LsmDb database handle */
1290
+
1291
+ /* Invoke the user level work-hook, if any. */
1292
+ if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx);
1293
+
1294
+ /* Wake up worker thread 0. */
1295
+ mt_signal_worker(pDb, 0);
1296
+ }
1297
+
1298
+ static void mt_worker_work_hook(lsm_db *db, void *pArg){
1299
+ LsmDb *pDb = (LsmDb *)pArg; /* LsmDb database handle */
1300
+
1301
+ /* Invoke the user level work-hook, if any. */
1302
+ if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx);
1303
+ }
1304
+
1305
+ /*
1306
+ ** Launch worker thread iWorker for database connection pDb.
1307
+ */
1308
+ static int mt_start_worker(
1309
+ LsmDb *pDb, /* Main database structure */
1310
+ int iWorker, /* Worker number to start */
1311
+ const char *zFilename, /* File name of database to open */
1312
+ const char *zCfg, /* Connection configuration string */
1313
+ int eType /* Type of worker thread */
1314
+ ){
1315
+ int rc = 0; /* Return code */
1316
+ LsmWorker *p; /* Object to initialize */
1317
+
1318
+ assert( iWorker<pDb->nWorker );
1319
+ assert( eType==LSMTEST_THREAD_CKPT
1320
+ || eType==LSMTEST_THREAD_WORKER
1321
+ || eType==LSMTEST_THREAD_WORKER_AC
1322
+ );
1323
+
1324
+ p = &pDb->aWorker[iWorker];
1325
+ p->eType = eType;
1326
+ p->pDb = pDb;
1327
+
1328
+ /* Open the worker connection */
1329
+ if( rc==0 ) rc = lsm_new(&pDb->env, &p->pWorker);
1330
+ if( zCfg ){
1331
+ test_lsm_config_str(pDb, p->pWorker, 1, zCfg, 0);
1332
+ }
1333
+ if( rc==0 ) rc = lsm_open(p->pWorker, zFilename);
1334
+ lsm_config_log(p->pWorker, xLog, (void *)"worker");
1335
+
1336
+ /* Configure the work-hook */
1337
+ if( rc==0 ){
1338
+ lsm_config_work_hook(p->pWorker, mt_worker_work_hook, (void *)pDb);
1339
+ }
1340
+
1341
+ if( eType==LSMTEST_THREAD_WORKER ){
1342
+ test_lsm_config_str(0, p->pWorker, 1, "autocheckpoint=0", 0);
1343
+ }
1344
+
1345
+ /* Kick off the worker thread. */
1346
+ if( rc==0 ) rc = pthread_cond_init(&p->worker_cond, 0);
1347
+ if( rc==0 ) rc = pthread_mutex_init(&p->worker_mutex, 0);
1348
+ if( rc==0 ) rc = pthread_create(&p->worker_thread, 0, worker_main, (void *)p);
1349
+
1350
+ return rc;
1351
+ }
1352
+
1353
+
1354
+ static int testLsmStartWorkers(
1355
+ LsmDb *pDb, int eModel, const char *zFilename, const char *zCfg
1356
+ ){
1357
+ int rc;
1358
+
1359
+ if( eModel<1 || eModel>4 ) return 1;
1360
+ if( eModel==1 ) return 0;
1361
+
1362
+ /* Configure a work-hook for the client connection. Worker 0 is signalled
1363
+ ** every time the users connection writes to the database. */
1364
+ lsm_config_work_hook(pDb->db, mt_client_work_hook, (void *)pDb);
1365
+
1366
+ /* Allocate space for two worker connections. They may not both be
1367
+ ** used, but both are allocated. */
1368
+ pDb->aWorker = (LsmWorker *)testMalloc(sizeof(LsmWorker) * 2);
1369
+ memset(pDb->aWorker, 0, sizeof(LsmWorker) * 2);
1370
+
1371
+ switch( eModel ){
1372
+ case LSMTEST_MODE_BACKGROUND_CKPT:
1373
+ pDb->nWorker = 1;
1374
+ test_lsm_config_str(0, pDb->db, 0, "autocheckpoint=0", 0);
1375
+ rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_CKPT);
1376
+ break;
1377
+
1378
+ case LSMTEST_MODE_BACKGROUND_WORK:
1379
+ pDb->nWorker = 1;
1380
+ test_lsm_config_str(0, pDb->db, 0, "autowork=0", 0);
1381
+ rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_WORKER_AC);
1382
+ break;
1383
+
1384
+ case LSMTEST_MODE_BACKGROUND_BOTH:
1385
+ pDb->nWorker = 2;
1386
+ test_lsm_config_str(0, pDb->db, 0, "autowork=0", 0);
1387
+ rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_WORKER);
1388
+ if( rc==0 ){
1389
+ rc = mt_start_worker(pDb, 1, zFilename, zCfg, LSMTEST_THREAD_CKPT);
1390
+ }
1391
+ break;
1392
+ }
1393
+
1394
+ return rc;
1395
+ }
1396
+
1397
+
1398
+ int test_lsm_mt2(
1399
+ const char *zSpec,
1400
+ const char *zFilename,
1401
+ int bClear,
1402
+ TestDb **ppDb
1403
+ ){
1404
+ const char *zCfg = "mt_mode=2";
1405
+ return testLsmOpen(zCfg, zFilename, bClear, ppDb);
1406
+ }
1407
+
1408
+ int test_lsm_mt3(
1409
+ const char *zSpec,
1410
+ const char *zFilename,
1411
+ int bClear,
1412
+ TestDb **ppDb
1413
+ ){
1414
+ const char *zCfg = "mt_mode=4";
1415
+ return testLsmOpen(zCfg, zFilename, bClear, ppDb);
1416
+ }
1417
+
1418
+ #else
1419
+ static void mt_shutdown(LsmDb *pDb) {
1420
+ unused_parameter(pDb);
1421
+ }
1422
+ int test_lsm_mt(const char *zFilename, int bClear, TestDb **ppDb){
1423
+ unused_parameter(zFilename);
1424
+ unused_parameter(bClear);
1425
+ unused_parameter(ppDb);
1426
+ testPrintError("threads unavailable - recompile with LSM_MUTEX_PTHREADS\n");
1427
+ return 1;
1428
+ }
1429
+ #endif
local-test-sqlite3-delta-03/afc-sqlite3/ext/lsm1/lsm-test/lsmtest_tdb4.c ADDED
@@ -0,0 +1,980 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*
3
+ ** This file contains the TestDb bt wrapper.
4
+ */
5
+
6
+ #include "lsmtest_tdb.h"
7
+ #include "lsmtest.h"
8
+ #include <unistd.h>
9
+ #include "bt.h"
10
+
11
+ #include <pthread.h>
12
+
13
+ typedef struct BtDb BtDb;
14
+ typedef struct BtFile BtFile;
15
+
16
+ /* Background checkpointer interface (see implementations below). */
17
+ typedef struct bt_ckpter bt_ckpter;
18
+ static int bgc_attach(BtDb *pDb, const char*);
19
+ static int bgc_detach(BtDb *pDb);
20
+
21
+ /*
22
+ ** Each database or log file opened by a database handle is wrapped by
23
+ ** an object of the following type.
24
+ */
25
+ struct BtFile {
26
+ BtDb *pBt; /* Database handle that opened this file */
27
+ bt_env *pVfs; /* Underlying VFS */
28
+ bt_file *pFile; /* File handle belonging to underlying VFS */
29
+ int nSectorSize; /* Size of sectors in bytes */
30
+ int nSector; /* Allocated size of nSector array */
31
+ u8 **apSector; /* Original sector data */
32
+ };
33
+
34
+ /*
35
+ ** nCrashSync:
36
+ ** If this value is non-zero, then a "crash-test" is running. If
37
+ ** nCrashSync==1, then the crash is simulated during the very next
38
+ ** call to the xSync() VFS method (on either the db or log file).
39
+ ** If nCrashSync==2, the following call to xSync(), and so on.
40
+ **
41
+ ** bCrash:
42
+ ** After a crash is simulated, this variable is set. Any subsequent
43
+ ** attempts to write to a file or modify the file system in any way
44
+ ** fail once this is set. All the caller can do is close the connection.
45
+ **
46
+ ** bFastInsert:
47
+ ** If this variable is set to true, then a BT_CONTROL_FAST_INSERT_OP
48
+ ** control is issued before each callto BtReplace() or BtCsrOpen().
49
+ */
50
+ struct BtDb {
51
+ TestDb base; /* Base class */
52
+ bt_db *pBt; /* bt database handle */
53
+ sqlite4_env *pEnv; /* SQLite environment (for malloc/free) */
54
+ bt_env *pVfs; /* Underlying VFS */
55
+ int bFastInsert; /* True to use fast-insert */
56
+
57
+ /* Space for bt_fetch() results */
58
+ u8 *aBuffer; /* Space to store results */
59
+ int nBuffer; /* Allocated size of aBuffer[] in bytes */
60
+ int nRef;
61
+
62
+ /* Background checkpointer used by mt connections */
63
+ bt_ckpter *pCkpter;
64
+
65
+ /* Stuff used for crash test simulation */
66
+ BtFile *apFile[2]; /* Database and log files used by pBt */
67
+ bt_env env; /* Private VFS for this object */
68
+ int nCrashSync; /* Number of syncs until crash (see above) */
69
+ int bCrash; /* True once a crash has been simulated */
70
+ };
71
+
72
+ static int btVfsFullpath(
73
+ sqlite4_env *pEnv,
74
+ bt_env *pVfs,
75
+ const char *z,
76
+ char **pzOut
77
+ ){
78
+ BtDb *pBt = (BtDb*)pVfs->pVfsCtx;
79
+ if( pBt->bCrash ) return SQLITE4_IOERR;
80
+ return pBt->pVfs->xFullpath(pEnv, pBt->pVfs, z, pzOut);
81
+ }
82
+
83
+ static int btVfsOpen(
84
+ sqlite4_env *pEnv,
85
+ bt_env *pVfs,
86
+ const char *zFile,
87
+ int flags, bt_file **ppFile
88
+ ){
89
+ BtFile *p;
90
+ BtDb *pBt = (BtDb*)pVfs->pVfsCtx;
91
+ int rc;
92
+
93
+ if( pBt->bCrash ) return SQLITE4_IOERR;
94
+
95
+ p = (BtFile*)testMalloc(sizeof(BtFile));
96
+ if( !p ) return SQLITE4_NOMEM;
97
+ if( flags & BT_OPEN_DATABASE ){
98
+ pBt->apFile[0] = p;
99
+ }else if( flags & BT_OPEN_LOG ){
100
+ pBt->apFile[1] = p;
101
+ }
102
+ if( (flags & BT_OPEN_SHARED)==0 ){
103
+ p->pBt = pBt;
104
+ }
105
+ p->pVfs = pBt->pVfs;
106
+
107
+ rc = pBt->pVfs->xOpen(pEnv, pVfs, zFile, flags, &p->pFile);
108
+ if( rc!=SQLITE4_OK ){
109
+ testFree(p);
110
+ p = 0;
111
+ }else{
112
+ pBt->nRef++;
113
+ }
114
+
115
+ *ppFile = (bt_file*)p;
116
+ return rc;
117
+ }
118
+
119
+ static int btVfsSize(bt_file *pFile, sqlite4_int64 *piRes){
120
+ BtFile *p = (BtFile*)pFile;
121
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
122
+ return p->pVfs->xSize(p->pFile, piRes);
123
+ }
124
+
125
+ static int btVfsRead(bt_file *pFile, sqlite4_int64 iOff, void *pBuf, int nBuf){
126
+ BtFile *p = (BtFile*)pFile;
127
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
128
+ return p->pVfs->xRead(p->pFile, iOff, pBuf, nBuf);
129
+ }
130
+
131
+ static int btFlushSectors(BtFile *p, int iFile){
132
+ sqlite4_int64 iSz;
133
+ int rc;
134
+ int i;
135
+ u8 *aTmp = 0;
136
+
137
+ rc = p->pBt->pVfs->xSize(p->pFile, &iSz);
138
+ for(i=0; rc==SQLITE4_OK && i<p->nSector; i++){
139
+ if( p->pBt->bCrash && p->apSector[i] ){
140
+
141
+ /* The system is simulating a crash. There are three choices for
142
+ ** this sector:
143
+ **
144
+ ** 1) Leave it as it is (simulating a successful write),
145
+ ** 2) Restore the original data (simulating a lost write),
146
+ ** 3) Populate the disk sector with garbage data.
147
+ */
148
+ sqlite4_int64 iSOff = p->nSectorSize*i;
149
+ int nWrite = MIN(p->nSectorSize, iSz - iSOff);
150
+
151
+ if( nWrite ){
152
+ u8 *aWrite = 0;
153
+ int iOpt = (testPrngValue(i) % 3) + 1;
154
+ if( iOpt==1 ){
155
+ aWrite = p->apSector[i];
156
+ }else if( iOpt==3 ){
157
+ if( aTmp==0 ) aTmp = testMalloc(p->nSectorSize);
158
+ aWrite = aTmp;
159
+ testPrngArray(i*13, (u32*)aWrite, nWrite/sizeof(u32));
160
+ }
161
+
162
+ #if 0
163
+ fprintf(stderr, "handle sector %d of %s with %s\n", i,
164
+ iFile==0 ? "db" : "log",
165
+ iOpt==1 ? "rollback" : iOpt==2 ? "write" : "omit"
166
+ );
167
+ fflush(stderr);
168
+ #endif
169
+
170
+ if( aWrite ){
171
+ rc = p->pBt->pVfs->xWrite(p->pFile, iSOff, aWrite, nWrite);
172
+ }
173
+ }
174
+ }
175
+ testFree(p->apSector[i]);
176
+ p->apSector[i] = 0;
177
+ }
178
+
179
+ testFree(aTmp);
180
+ return rc;
181
+ }
182
+
183
+ static int btSaveSectors(BtFile *p, sqlite4_int64 iOff, int nBuf){
184
+ int rc;
185
+ sqlite4_int64 iSz; /* Size of file on disk */
186
+ int iFirst; /* First sector affected */
187
+ int iSector; /* Current sector */
188
+ int iLast; /* Last sector affected */
189
+
190
+ if( p->nSectorSize==0 ){
191
+ p->nSectorSize = p->pBt->pVfs->xSectorSize(p->pFile);
192
+ if( p->nSectorSize<512 ) p->nSectorSize = 512;
193
+ }
194
+ iLast = (iOff+nBuf-1) / p->nSectorSize;
195
+ iFirst = iOff / p->nSectorSize;
196
+
197
+ rc = p->pBt->pVfs->xSize(p->pFile, &iSz);
198
+ for(iSector=iFirst; rc==SQLITE4_OK && iSector<=iLast; iSector++){
199
+ int nRead;
200
+ sqlite4_int64 iSOff = iSector * p->nSectorSize;
201
+ u8 *aBuf = testMalloc(p->nSectorSize);
202
+ nRead = MIN(p->nSectorSize, (iSz - iSOff));
203
+ if( nRead>0 ){
204
+ rc = p->pBt->pVfs->xRead(p->pFile, iSOff, aBuf, nRead);
205
+ }
206
+
207
+ while( rc==SQLITE4_OK && iSector>=p->nSector ){
208
+ int nNew = p->nSector + 32;
209
+ u8 **apNew = (u8**)testMalloc(nNew * sizeof(u8*));
210
+ memcpy(apNew, p->apSector, p->nSector*sizeof(u8*));
211
+ testFree(p->apSector);
212
+ p->apSector = apNew;
213
+ p->nSector = nNew;
214
+ }
215
+
216
+ p->apSector[iSector] = aBuf;
217
+ }
218
+
219
+ return rc;
220
+ }
221
+
222
+ static int btVfsWrite(bt_file *pFile, sqlite4_int64 iOff, void *pBuf, int nBuf){
223
+ BtFile *p = (BtFile*)pFile;
224
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
225
+ if( p->pBt && p->pBt->nCrashSync ){
226
+ btSaveSectors(p, iOff, nBuf);
227
+ }
228
+ return p->pVfs->xWrite(p->pFile, iOff, pBuf, nBuf);
229
+ }
230
+
231
+ static int btVfsTruncate(bt_file *pFile, sqlite4_int64 iOff){
232
+ BtFile *p = (BtFile*)pFile;
233
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
234
+ return p->pVfs->xTruncate(p->pFile, iOff);
235
+ }
236
+
237
+ static int btVfsSync(bt_file *pFile){
238
+ int rc = SQLITE4_OK;
239
+ BtFile *p = (BtFile*)pFile;
240
+ BtDb *pBt = p->pBt;
241
+
242
+ if( pBt ){
243
+ if( pBt->bCrash ) return SQLITE4_IOERR;
244
+ if( pBt->nCrashSync ){
245
+ pBt->nCrashSync--;
246
+ pBt->bCrash = (pBt->nCrashSync==0);
247
+ if( pBt->bCrash ){
248
+ btFlushSectors(pBt->apFile[0], 0);
249
+ btFlushSectors(pBt->apFile[1], 1);
250
+ rc = SQLITE4_IOERR;
251
+ }else{
252
+ btFlushSectors(p, 0);
253
+ }
254
+ }
255
+ }
256
+
257
+ if( rc==SQLITE4_OK ){
258
+ rc = p->pVfs->xSync(p->pFile);
259
+ }
260
+ return rc;
261
+ }
262
+
263
+ static int btVfsSectorSize(bt_file *pFile){
264
+ BtFile *p = (BtFile*)pFile;
265
+ return p->pVfs->xSectorSize(p->pFile);
266
+ }
267
+
268
+ static void btDeref(BtDb *p){
269
+ p->nRef--;
270
+ assert( p->nRef>=0 );
271
+ if( p->nRef<=0 ) testFree(p);
272
+ }
273
+
274
+ static int btVfsClose(bt_file *pFile){
275
+ BtFile *p = (BtFile*)pFile;
276
+ BtDb *pBt = p->pBt;
277
+ int rc;
278
+ if( pBt ){
279
+ btFlushSectors(p, 0);
280
+ if( p==pBt->apFile[0] ) pBt->apFile[0] = 0;
281
+ if( p==pBt->apFile[1] ) pBt->apFile[1] = 0;
282
+ }
283
+ testFree(p->apSector);
284
+ rc = p->pVfs->xClose(p->pFile);
285
+ #if 0
286
+ btDeref(p->pBt);
287
+ #endif
288
+ testFree(p);
289
+ return rc;
290
+ }
291
+
292
+ static int btVfsUnlink(sqlite4_env *pEnv, bt_env *pVfs, const char *zFile){
293
+ BtDb *pBt = (BtDb*)pVfs->pVfsCtx;
294
+ if( pBt->bCrash ) return SQLITE4_IOERR;
295
+ return pBt->pVfs->xUnlink(pEnv, pBt->pVfs, zFile);
296
+ }
297
+
298
+ static int btVfsLock(bt_file *pFile, int iLock, int eType){
299
+ BtFile *p = (BtFile*)pFile;
300
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
301
+ return p->pVfs->xLock(p->pFile, iLock, eType);
302
+ }
303
+
304
+ static int btVfsTestLock(bt_file *pFile, int iLock, int nLock, int eType){
305
+ BtFile *p = (BtFile*)pFile;
306
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
307
+ return p->pVfs->xTestLock(p->pFile, iLock, nLock, eType);
308
+ }
309
+
310
+ static int btVfsShmMap(bt_file *pFile, int iChunk, int sz, void **ppOut){
311
+ BtFile *p = (BtFile*)pFile;
312
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
313
+ return p->pVfs->xShmMap(p->pFile, iChunk, sz, ppOut);
314
+ }
315
+
316
+ static void btVfsShmBarrier(bt_file *pFile){
317
+ BtFile *p = (BtFile*)pFile;
318
+ return p->pVfs->xShmBarrier(p->pFile);
319
+ }
320
+
321
+ static int btVfsShmUnmap(bt_file *pFile, int bDelete){
322
+ BtFile *p = (BtFile*)pFile;
323
+ if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;
324
+ return p->pVfs->xShmUnmap(p->pFile, bDelete);
325
+ }
326
+
327
+ static int bt_close(TestDb *pTestDb){
328
+ BtDb *p = (BtDb*)pTestDb;
329
+ int rc = sqlite4BtClose(p->pBt);
330
+ free(p->aBuffer);
331
+ if( p->apFile[0] ) p->apFile[0]->pBt = 0;
332
+ if( p->apFile[1] ) p->apFile[1]->pBt = 0;
333
+ bgc_detach(p);
334
+ testFree(p);
335
+ return rc;
336
+ }
337
+
338
+ static int btMinTransaction(BtDb *p, int iMin, int *piLevel){
339
+ int iLevel;
340
+ int rc = SQLITE4_OK;
341
+
342
+ iLevel = sqlite4BtTransactionLevel(p->pBt);
343
+ if( iLevel<iMin ){
344
+ rc = sqlite4BtBegin(p->pBt, iMin);
345
+ *piLevel = iLevel;
346
+ }else{
347
+ *piLevel = -1;
348
+ }
349
+
350
+ return rc;
351
+ }
352
+ static int btRestoreTransaction(BtDb *p, int iLevel, int rcin){
353
+ int rc = rcin;
354
+ if( iLevel>=0 ){
355
+ if( rc==SQLITE4_OK ){
356
+ rc = sqlite4BtCommit(p->pBt, iLevel);
357
+ }else{
358
+ sqlite4BtRollback(p->pBt, iLevel);
359
+ }
360
+ assert( iLevel==sqlite4BtTransactionLevel(p->pBt) );
361
+ }
362
+ return rc;
363
+ }
364
+
365
+ static int bt_write(TestDb *pTestDb, void *pK, int nK, void *pV, int nV){
366
+ BtDb *p = (BtDb*)pTestDb;
367
+ int iLevel;
368
+ int rc;
369
+
370
+ rc = btMinTransaction(p, 2, &iLevel);
371
+ if( rc==SQLITE4_OK ){
372
+ if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);
373
+ rc = sqlite4BtReplace(p->pBt, pK, nK, pV, nV);
374
+ rc = btRestoreTransaction(p, iLevel, rc);
375
+ }
376
+ return rc;
377
+ }
378
+
379
+ static int bt_delete(TestDb *pTestDb, void *pK, int nK){
380
+ return bt_write(pTestDb, pK, nK, 0, -1);
381
+ }
382
+
383
+ static int bt_delete_range(
384
+ TestDb *pTestDb,
385
+ void *pKey1, int nKey1,
386
+ void *pKey2, int nKey2
387
+ ){
388
+ BtDb *p = (BtDb*)pTestDb;
389
+ bt_cursor *pCsr = 0;
390
+ int rc = SQLITE4_OK;
391
+ int iLevel;
392
+
393
+ rc = btMinTransaction(p, 2, &iLevel);
394
+ if( rc==SQLITE4_OK ){
395
+ if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);
396
+ rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);
397
+ }
398
+ while( rc==SQLITE4_OK ){
399
+ const void *pK;
400
+ int n;
401
+ int nCmp;
402
+ int res;
403
+
404
+ rc = sqlite4BtCsrSeek(pCsr, pKey1, nKey1, BT_SEEK_GE);
405
+ if( rc==SQLITE4_INEXACT ) rc = SQLITE4_OK;
406
+ if( rc!=SQLITE4_OK ) break;
407
+
408
+ rc = sqlite4BtCsrKey(pCsr, &pK, &n);
409
+ if( rc!=SQLITE4_OK ) break;
410
+
411
+ nCmp = MIN(n, nKey1);
412
+ res = memcmp(pKey1, pK, nCmp);
413
+ assert( res<0 || (res==0 && nKey1<=n) );
414
+ if( res==0 && nKey1==n ){
415
+ rc = sqlite4BtCsrNext(pCsr);
416
+ if( rc!=SQLITE4_OK ) break;
417
+ rc = sqlite4BtCsrKey(pCsr, &pK, &n);
418
+ if( rc!=SQLITE4_OK ) break;
419
+ }
420
+
421
+ nCmp = MIN(n, nKey2);
422
+ res = memcmp(pKey2, pK, nCmp);
423
+ if( res<0 || (res==0 && nKey2<=n) ) break;
424
+
425
+ rc = sqlite4BtDelete(pCsr);
426
+ }
427
+ if( rc==SQLITE4_NOTFOUND ) rc = SQLITE4_OK;
428
+
429
+ sqlite4BtCsrClose(pCsr);
430
+
431
+ rc = btRestoreTransaction(p, iLevel, rc);
432
+ return rc;
433
+ }
434
+
435
+ static int bt_fetch(
436
+ TestDb *pTestDb,
437
+ void *pK, int nK,
438
+ void **ppVal, int *pnVal
439
+ ){
440
+ BtDb *p = (BtDb*)pTestDb;
441
+ bt_cursor *pCsr = 0;
442
+ int iLevel;
443
+ int rc = SQLITE4_OK;
444
+
445
+ iLevel = sqlite4BtTransactionLevel(p->pBt);
446
+ if( iLevel==0 ){
447
+ rc = sqlite4BtBegin(p->pBt, 1);
448
+ if( rc!=SQLITE4_OK ) return rc;
449
+ }
450
+
451
+ if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);
452
+ rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);
453
+ if( rc==SQLITE4_OK ){
454
+ rc = sqlite4BtCsrSeek(pCsr, pK, nK, BT_SEEK_EQ);
455
+ if( rc==SQLITE4_OK ){
456
+ const void *pV = 0;
457
+ int nV = 0;
458
+ rc = sqlite4BtCsrData(pCsr, 0, -1, &pV, &nV);
459
+ if( rc==SQLITE4_OK ){
460
+ if( nV>p->nBuffer ){
461
+ free(p->aBuffer);
462
+ p->aBuffer = (u8*)malloc(nV*2);
463
+ p->nBuffer = nV*2;
464
+ }
465
+ memcpy(p->aBuffer, pV, nV);
466
+ *pnVal = nV;
467
+ *ppVal = (void*)(p->aBuffer);
468
+ }
469
+
470
+ }else if( rc==SQLITE4_INEXACT || rc==SQLITE4_NOTFOUND ){
471
+ *ppVal = 0;
472
+ *pnVal = -1;
473
+ rc = SQLITE4_OK;
474
+ }
475
+ sqlite4BtCsrClose(pCsr);
476
+ }
477
+
478
+ if( iLevel==0 ) sqlite4BtCommit(p->pBt, 0);
479
+ return rc;
480
+ }
481
+
482
+ static int bt_scan(
483
+ TestDb *pTestDb,
484
+ void *pCtx,
485
+ int bReverse,
486
+ void *pFirst, int nFirst,
487
+ void *pLast, int nLast,
488
+ void (*xCallback)(void *, void *, int , void *, int)
489
+ ){
490
+ BtDb *p = (BtDb*)pTestDb;
491
+ bt_cursor *pCsr = 0;
492
+ int rc;
493
+ int iLevel;
494
+
495
+ rc = btMinTransaction(p, 1, &iLevel);
496
+
497
+ if( rc==SQLITE4_OK ){
498
+ if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);
499
+ rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);
500
+ }
501
+ if( rc==SQLITE4_OK ){
502
+ if( bReverse ){
503
+ if( pLast ){
504
+ rc = sqlite4BtCsrSeek(pCsr, pLast, nLast, BT_SEEK_LE);
505
+ }else{
506
+ rc = sqlite4BtCsrLast(pCsr);
507
+ }
508
+ }else{
509
+ rc = sqlite4BtCsrSeek(pCsr, pFirst, nFirst, BT_SEEK_GE);
510
+ }
511
+ if( rc==SQLITE4_INEXACT ) rc = SQLITE4_OK;
512
+
513
+ while( rc==SQLITE4_OK ){
514
+ const void *pK = 0; int nK = 0;
515
+ const void *pV = 0; int nV = 0;
516
+
517
+ rc = sqlite4BtCsrKey(pCsr, &pK, &nK);
518
+ if( rc==SQLITE4_OK ){
519
+ rc = sqlite4BtCsrData(pCsr, 0, -1, &pV, &nV);
520
+ }
521
+
522
+ if( rc!=SQLITE4_OK ) break;
523
+ if( bReverse ){
524
+ if( pFirst ){
525
+ int res;
526
+ int nCmp = MIN(nK, nFirst);
527
+ res = memcmp(pFirst, pK, nCmp);
528
+ if( res>0 || (res==0 && nK<nFirst) ) break;
529
+ }
530
+ }else{
531
+ if( pLast ){
532
+ int res;
533
+ int nCmp = MIN(nK, nLast);
534
+ res = memcmp(pLast, pK, nCmp);
535
+ if( res<0 || (res==0 && nK>nLast) ) break;
536
+ }
537
+ }
538
+
539
+ xCallback(pCtx, (void*)pK, nK, (void*)pV, nV);
540
+ if( bReverse ){
541
+ rc = sqlite4BtCsrPrev(pCsr);
542
+ }else{
543
+ rc = sqlite4BtCsrNext(pCsr);
544
+ }
545
+ }
546
+ if( rc==SQLITE4_NOTFOUND ) rc = SQLITE4_OK;
547
+
548
+ sqlite4BtCsrClose(pCsr);
549
+ }
550
+
551
+ rc = btRestoreTransaction(p, iLevel, rc);
552
+ return rc;
553
+ }
554
+
555
+ static int bt_begin(TestDb *pTestDb, int iLvl){
556
+ BtDb *p = (BtDb*)pTestDb;
557
+ int rc = sqlite4BtBegin(p->pBt, iLvl);
558
+ return rc;
559
+ }
560
+
561
+ static int bt_commit(TestDb *pTestDb, int iLvl){
562
+ BtDb *p = (BtDb*)pTestDb;
563
+ int rc = sqlite4BtCommit(p->pBt, iLvl);
564
+ return rc;
565
+ }
566
+
567
+ static int bt_rollback(TestDb *pTestDb, int iLvl){
568
+ BtDb *p = (BtDb*)pTestDb;
569
+ int rc = sqlite4BtRollback(p->pBt, iLvl);
570
+ return rc;
571
+ }
572
+
573
+ static int testParseOption(
574
+ const char **pzIn, /* IN/OUT: pointer to next option */
575
+ const char **pzOpt, /* OUT: nul-terminated option name */
576
+ const char **pzArg, /* OUT: nul-terminated option argument */
577
+ char *pSpace /* Temporary space for output params */
578
+ ){
579
+ const char *p = *pzIn;
580
+ const char *pStart;
581
+ int n;
582
+
583
+ char *pOut = pSpace;
584
+
585
+ while( *p==' ' ) p++;
586
+ pStart = p;
587
+ while( *p && *p!='=' ) p++;
588
+ if( *p==0 ) return 1;
589
+
590
+ n = (p - pStart);
591
+ memcpy(pOut, pStart, n);
592
+ *pzOpt = pOut;
593
+ pOut += n;
594
+ *pOut++ = '\0';
595
+
596
+ p++;
597
+ pStart = p;
598
+ while( *p && *p!=' ' ) p++;
599
+ n = (p - pStart);
600
+
601
+ memcpy(pOut, pStart, n);
602
+ *pzArg = pOut;
603
+ pOut += n;
604
+ *pOut++ = '\0';
605
+
606
+ *pzIn = p;
607
+ return 0;
608
+ }
609
+
610
+ static int testParseInt(const char *z, int *piVal){
611
+ int i = 0;
612
+ const char *p = z;
613
+
614
+ while( *p>='0' && *p<='9' ){
615
+ i = i*10 + (*p - '0');
616
+ p++;
617
+ }
618
+ if( *p=='K' || *p=='k' ){
619
+ i = i * 1024;
620
+ p++;
621
+ }else if( *p=='M' || *p=='m' ){
622
+ i = i * 1024 * 1024;
623
+ p++;
624
+ }
625
+
626
+ if( *p ) return SQLITE4_ERROR;
627
+ *piVal = i;
628
+ return SQLITE4_OK;
629
+ }
630
+
631
+ static int testBtConfigure(BtDb *pDb, const char *zCfg, int *pbMt){
632
+ int rc = SQLITE4_OK;
633
+
634
+ if( zCfg ){
635
+ struct CfgParam {
636
+ const char *zParam;
637
+ int eParam;
638
+ } aParam[] = {
639
+ { "safety", BT_CONTROL_SAFETY },
640
+ { "autockpt", BT_CONTROL_AUTOCKPT },
641
+ { "multiproc", BT_CONTROL_MULTIPROC },
642
+ { "blksz", BT_CONTROL_BLKSZ },
643
+ { "pagesz", BT_CONTROL_PAGESZ },
644
+ { "mt", -1 },
645
+ { "fastinsert", -2 },
646
+ { 0, 0 }
647
+ };
648
+ const char *z = zCfg;
649
+ int n = strlen(z);
650
+ char *aSpace;
651
+ const char *zOpt;
652
+ const char *zArg;
653
+
654
+ aSpace = (char*)testMalloc(n+2);
655
+ while( rc==SQLITE4_OK && 0==testParseOption(&z, &zOpt, &zArg, aSpace) ){
656
+ int i;
657
+ int iVal;
658
+ rc = testArgSelect(aParam, "param", zOpt, &i);
659
+ if( rc!=SQLITE4_OK ) break;
660
+
661
+ rc = testParseInt(zArg, &iVal);
662
+ if( rc!=SQLITE4_OK ) break;
663
+
664
+ switch( aParam[i].eParam ){
665
+ case -1:
666
+ *pbMt = iVal;
667
+ break;
668
+ case -2:
669
+ pDb->bFastInsert = 1;
670
+ break;
671
+ default:
672
+ rc = sqlite4BtControl(pDb->pBt, aParam[i].eParam, (void*)&iVal);
673
+ break;
674
+ }
675
+ }
676
+ testFree(aSpace);
677
+ }
678
+
679
+ return rc;
680
+ }
681
+
682
+
683
+ int test_bt_open(
684
+ const char *zSpec,
685
+ const char *zFilename,
686
+ int bClear,
687
+ TestDb **ppDb
688
+ ){
689
+
690
+ static const DatabaseMethods SqlMethods = {
691
+ bt_close,
692
+ bt_write,
693
+ bt_delete,
694
+ bt_delete_range,
695
+ bt_fetch,
696
+ bt_scan,
697
+ bt_begin,
698
+ bt_commit,
699
+ bt_rollback
700
+ };
701
+ BtDb *p = 0;
702
+ bt_db *pBt = 0;
703
+ int rc;
704
+ sqlite4_env *pEnv = sqlite4_env_default();
705
+
706
+ if( bClear && zFilename && zFilename[0] ){
707
+ char *zLog = sqlite3_mprintf("%s-wal", zFilename);
708
+ unlink(zFilename);
709
+ unlink(zLog);
710
+ sqlite3_free(zLog);
711
+ }
712
+
713
+ rc = sqlite4BtNew(pEnv, 0, &pBt);
714
+ if( rc==SQLITE4_OK ){
715
+ int mt = 0; /* True for multi-threaded connection */
716
+
717
+ p = (BtDb*)testMalloc(sizeof(BtDb));
718
+ p->base.pMethods = &SqlMethods;
719
+ p->pBt = pBt;
720
+ p->pEnv = pEnv;
721
+ p->nRef = 1;
722
+
723
+ p->env.pVfsCtx = (void*)p;
724
+ p->env.xFullpath = btVfsFullpath;
725
+ p->env.xOpen = btVfsOpen;
726
+ p->env.xSize = btVfsSize;
727
+ p->env.xRead = btVfsRead;
728
+ p->env.xWrite = btVfsWrite;
729
+ p->env.xTruncate = btVfsTruncate;
730
+ p->env.xSync = btVfsSync;
731
+ p->env.xSectorSize = btVfsSectorSize;
732
+ p->env.xClose = btVfsClose;
733
+ p->env.xUnlink = btVfsUnlink;
734
+ p->env.xLock = btVfsLock;
735
+ p->env.xTestLock = btVfsTestLock;
736
+ p->env.xShmMap = btVfsShmMap;
737
+ p->env.xShmBarrier = btVfsShmBarrier;
738
+ p->env.xShmUnmap = btVfsShmUnmap;
739
+
740
+ sqlite4BtControl(pBt, BT_CONTROL_GETVFS, (void*)&p->pVfs);
741
+ sqlite4BtControl(pBt, BT_CONTROL_SETVFS, (void*)&p->env);
742
+
743
+ rc = testBtConfigure(p, zSpec, &mt);
744
+ if( rc==SQLITE4_OK ){
745
+ rc = sqlite4BtOpen(pBt, zFilename);
746
+ }
747
+
748
+ if( rc==SQLITE4_OK && mt ){
749
+ int nAuto = 0;
750
+ rc = bgc_attach(p, zSpec);
751
+ sqlite4BtControl(pBt, BT_CONTROL_AUTOCKPT, (void*)&nAuto);
752
+ }
753
+ }
754
+
755
+ if( rc!=SQLITE4_OK && p ){
756
+ bt_close(&p->base);
757
+ }
758
+
759
+ *ppDb = &p->base;
760
+ return rc;
761
+ }
762
+
763
+ int test_fbt_open(
764
+ const char *zSpec,
765
+ const char *zFilename,
766
+ int bClear,
767
+ TestDb **ppDb
768
+ ){
769
+ return test_bt_open("fast=1", zFilename, bClear, ppDb);
770
+ }
771
+
772
+ int test_fbts_open(
773
+ const char *zSpec,
774
+ const char *zFilename,
775
+ int bClear,
776
+ TestDb **ppDb
777
+ ){
778
+ return test_bt_open("fast=1 blksz=32K pagesz=512", zFilename, bClear, ppDb);
779
+ }
780
+
781
+
782
+ void tdb_bt_prepare_sync_crash(TestDb *pTestDb, int iSync){
783
+ BtDb *p = (BtDb*)pTestDb;
784
+ assert( pTestDb->pMethods->xClose==bt_close );
785
+ assert( p->bCrash==0 );
786
+ p->nCrashSync = iSync;
787
+ }
788
+
789
+ bt_db *tdb_bt(TestDb *pDb){
790
+ if( pDb->pMethods->xClose==bt_close ){
791
+ return ((BtDb *)pDb)->pBt;
792
+ }
793
+ return 0;
794
+ }
795
+
796
+ /*************************************************************************
797
+ ** Beginning of code for background checkpointer.
798
+ */
799
+
800
+ struct bt_ckpter {
801
+ sqlite4_buffer file; /* File name */
802
+ sqlite4_buffer spec; /* Options */
803
+ int nLogsize; /* Minimum log size to checkpoint */
804
+ int nRef; /* Number of clients */
805
+
806
+ int bDoWork; /* Set by client threads */
807
+ pthread_t ckpter_thread; /* Checkpointer thread */
808
+ pthread_cond_t ckpter_cond; /* Condition var the ckpter waits on */
809
+ pthread_mutex_t ckpter_mutex; /* Mutex used with ckpter_cond */
810
+
811
+ bt_ckpter *pNext; /* Next object in list at gBgc.pCkpter */
812
+ };
813
+
814
+ static struct GlobalBackgroundCheckpointer {
815
+ bt_ckpter *pCkpter; /* Linked list of checkpointers */
816
+ } gBgc;
817
+
818
+ static void *bgc_main(void *pArg){
819
+ BtDb *pDb = 0;
820
+ int rc;
821
+ int mt;
822
+ bt_ckpter *pCkpter = (bt_ckpter*)pArg;
823
+
824
+ rc = test_bt_open("", (char*)pCkpter->file.p, 0, (TestDb**)&pDb);
825
+ assert( rc==SQLITE4_OK );
826
+ rc = testBtConfigure(pDb, (char*)pCkpter->spec.p, &mt);
827
+
828
+ while( pCkpter->nRef>0 ){
829
+ bt_db *db = pDb->pBt;
830
+ int nLog = 0;
831
+
832
+ sqlite4BtBegin(db, 1);
833
+ sqlite4BtCommit(db, 0);
834
+ sqlite4BtControl(db, BT_CONTROL_LOGSIZE, (void*)&nLog);
835
+
836
+ if( nLog>=pCkpter->nLogsize ){
837
+ int rc;
838
+ bt_checkpoint ckpt;
839
+ memset(&ckpt, 0, sizeof(bt_checkpoint));
840
+ ckpt.nFrameBuffer = nLog/2;
841
+ rc = sqlite4BtControl(db, BT_CONTROL_CHECKPOINT, (void*)&ckpt);
842
+ assert( rc==SQLITE4_OK );
843
+ sqlite4BtControl(db, BT_CONTROL_LOGSIZE, (void*)&nLog);
844
+ }
845
+
846
+ /* The thread will wake up when it is signaled either because another
847
+ ** thread has created some work for this one or because the connection
848
+ ** is being closed. */
849
+ pthread_mutex_lock(&pCkpter->ckpter_mutex);
850
+ if( pCkpter->bDoWork==0 ){
851
+ pthread_cond_wait(&pCkpter->ckpter_cond, &pCkpter->ckpter_mutex);
852
+ }
853
+ pCkpter->bDoWork = 0;
854
+ pthread_mutex_unlock(&pCkpter->ckpter_mutex);
855
+ }
856
+
857
+ if( pDb ) bt_close((TestDb*)pDb);
858
+ return 0;
859
+ }
860
+
861
+ static void bgc_logsize_cb(void *pCtx, int nLogsize){
862
+ bt_ckpter *p = (bt_ckpter*)pCtx;
863
+ if( nLogsize>=p->nLogsize ){
864
+ pthread_mutex_lock(&p->ckpter_mutex);
865
+ p->bDoWork = 1;
866
+ pthread_cond_signal(&p->ckpter_cond);
867
+ pthread_mutex_unlock(&p->ckpter_mutex);
868
+ }
869
+ }
870
+
871
+ static int bgc_attach(BtDb *pDb, const char *zSpec){
872
+ int rc;
873
+ int n;
874
+ bt_info info;
875
+ bt_ckpter *pCkpter;
876
+
877
+ /* Figure out the full path to the database opened by handle pDb. */
878
+ info.eType = BT_INFO_FILENAME;
879
+ info.pgno = 0;
880
+ sqlite4_buffer_init(&info.output, 0);
881
+ rc = sqlite4BtControl(pDb->pBt, BT_CONTROL_INFO, (void*)&info);
882
+ if( rc!=SQLITE4_OK ) return rc;
883
+
884
+ sqlite4_mutex_enter(sqlite4_mutex_alloc(pDb->pEnv, SQLITE4_MUTEX_STATIC_KV));
885
+
886
+ /* Search for an existing bt_ckpter object. */
887
+ n = info.output.n;
888
+ for(pCkpter=gBgc.pCkpter; pCkpter; pCkpter=pCkpter->pNext){
889
+ if( n==pCkpter->file.n && 0==memcmp(info.output.p, pCkpter->file.p, n) ){
890
+ break;
891
+ }
892
+ }
893
+
894
+ /* Failed to find a suitable checkpointer. Create a new one. */
895
+ if( pCkpter==0 ){
896
+ bt_logsizecb cb;
897
+
898
+ pCkpter = testMalloc(sizeof(bt_ckpter));
899
+ memcpy(&pCkpter->file, &info.output, sizeof(sqlite4_buffer));
900
+ info.output.p = 0;
901
+ pCkpter->pNext = gBgc.pCkpter;
902
+ pCkpter->nLogsize = 1000;
903
+ gBgc.pCkpter = pCkpter;
904
+ pCkpter->nRef = 1;
905
+
906
+ sqlite4_buffer_init(&pCkpter->spec, 0);
907
+ rc = sqlite4_buffer_set(&pCkpter->spec, zSpec, strlen(zSpec)+1);
908
+ assert( rc==SQLITE4_OK );
909
+
910
+ /* Kick off the checkpointer thread. */
911
+ if( rc==0 ) rc = pthread_cond_init(&pCkpter->ckpter_cond, 0);
912
+ if( rc==0 ) rc = pthread_mutex_init(&pCkpter->ckpter_mutex, 0);
913
+ if( rc==0 ){
914
+ rc = pthread_create(&pCkpter->ckpter_thread, 0, bgc_main, (void*)pCkpter);
915
+ }
916
+ assert( rc==0 ); /* todo: Fix this */
917
+
918
+ /* Set up the logsize callback for the client thread */
919
+ cb.pCtx = (void*)pCkpter;
920
+ cb.xLogsize = bgc_logsize_cb;
921
+ sqlite4BtControl(pDb->pBt, BT_CONTROL_LOGSIZECB, (void*)&cb);
922
+ }else{
923
+ pCkpter->nRef++;
924
+ }
925
+
926
+ /* Assuming a checkpointer was encountered or effected, attach the
927
+ ** connection to it. */
928
+ if( pCkpter ){
929
+ pDb->pCkpter = pCkpter;
930
+ }
931
+
932
+ sqlite4_mutex_leave(sqlite4_mutex_alloc(pDb->pEnv, SQLITE4_MUTEX_STATIC_KV));
933
+ sqlite4_buffer_clear(&info.output);
934
+ return rc;
935
+ }
936
+
937
+ static int bgc_detach(BtDb *pDb){
938
+ int rc = SQLITE4_OK;
939
+ bt_ckpter *pCkpter = pDb->pCkpter;
940
+ if( pCkpter ){
941
+ int bShutdown = 0; /* True if this is the last reference */
942
+
943
+ sqlite4_mutex_enter(sqlite4_mutex_alloc(pDb->pEnv,SQLITE4_MUTEX_STATIC_KV));
944
+ pCkpter->nRef--;
945
+ if( pCkpter->nRef==0 ){
946
+ bt_ckpter **pp;
947
+
948
+ *pp = pCkpter->pNext;
949
+ for(pp=&gBgc.pCkpter; *pp!=pCkpter; pp=&((*pp)->pNext));
950
+ bShutdown = 1;
951
+ }
952
+ sqlite4_mutex_leave(sqlite4_mutex_alloc(pDb->pEnv,SQLITE4_MUTEX_STATIC_KV));
953
+
954
+ if( bShutdown ){
955
+ void *pDummy;
956
+
957
+ /* Signal the checkpointer thread. */
958
+ pthread_mutex_lock(&pCkpter->ckpter_mutex);
959
+ pCkpter->bDoWork = 1;
960
+ pthread_cond_signal(&pCkpter->ckpter_cond);
961
+ pthread_mutex_unlock(&pCkpter->ckpter_mutex);
962
+
963
+ /* Join the checkpointer thread. */
964
+ pthread_join(pCkpter->ckpter_thread, &pDummy);
965
+ pthread_cond_destroy(&pCkpter->ckpter_cond);
966
+ pthread_mutex_destroy(&pCkpter->ckpter_mutex);
967
+
968
+ sqlite4_buffer_clear(&pCkpter->file);
969
+ sqlite4_buffer_clear(&pCkpter->spec);
970
+ testFree(pCkpter);
971
+ }
972
+
973
+ pDb->pCkpter = 0;
974
+ }
975
+ return rc;
976
+ }
977
+
978
+ /*
979
+ ** End of background checkpointer.
980
+ *************************************************************************/
local-test-sqlite3-delta-03/afc-sqlite3/ext/repair/test/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ To run these tests, first build sqlite3_checker:
2
+
3
+
4
+ > make sqlite3_checker
5
+
6
+
7
+ Then run the "test.tcl" script using:
8
+
9
+
10
+ > ./sqlite3_checker --test $path/test.tcl
11
+
12
+
13
+ Optionally add the full pathnames of individual *.test modules
local-test-sqlite3-delta-03/afc-sqlite3/ext/repair/test/checkindex01.test ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 2017-10-11
2
+ #
3
+ set testprefix checkindex
4
+
5
+ do_execsql_test 1.0 {
6
+ CREATE TABLE t1(a, b);
7
+ CREATE INDEX i1 ON t1(a);
8
+ INSERT INTO t1 VALUES('one', 2);
9
+ INSERT INTO t1 VALUES('two', 4);
10
+ INSERT INTO t1 VALUES('three', 6);
11
+ INSERT INTO t1 VALUES('four', 8);
12
+ INSERT INTO t1 VALUES('five', 10);
13
+
14
+ CREATE INDEX i2 ON t1(a DESC);
15
+ } {}
16
+
17
+ proc incr_index_check {idx nStep} {
18
+ set Q {
19
+ SELECT errmsg, current_key FROM incremental_index_check($idx, $after)
20
+ LIMIT $nStep
21
+ }
22
+
23
+ set res [list]
24
+ while {1} {
25
+ unset -nocomplain current_key
26
+ set res1 [db eval $Q]
27
+ if {[llength $res1]==0} break
28
+ set res [concat $res $res1]
29
+ set after [lindex $res end]
30
+ }
31
+
32
+ return $res
33
+ }
34
+
35
+ proc do_index_check_test {tn idx res} {
36
+ uplevel [list do_execsql_test $tn.1 "
37
+ SELECT errmsg, current_key FROM incremental_index_check('$idx');
38
+ " $res]
39
+
40
+ uplevel [list do_test $tn.2 "incr_index_check $idx 1" [list {*}$res]]
41
+ uplevel [list do_test $tn.3 "incr_index_check $idx 2" [list {*}$res]]
42
+ uplevel [list do_test $tn.4 "incr_index_check $idx 5" [list {*}$res]]
43
+ }
44
+
45
+
46
+ do_execsql_test 1.2.1 {
47
+ SELECT rowid, errmsg IS NULL, current_key FROM incremental_index_check('i1');
48
+ } {
49
+ 1 1 'five',5
50
+ 2 1 'four',4
51
+ 3 1 'one',1
52
+ 4 1 'three',3
53
+ 5 1 'two',2
54
+ }
55
+ do_execsql_test 1.2.2 {
56
+ SELECT errmsg IS NULL, current_key, index_name, after_key, scanner_sql
57
+ FROM incremental_index_check('i1') LIMIT 1;
58
+ } {
59
+ 1
60
+ 'five',5
61
+ i1
62
+ {}
63
+ {SELECT (SELECT a IS i.i0 FROM 't1' AS t WHERE "rowid" COLLATE BINARY IS i.i1), quote(i0)||','||quote(i1) FROM (SELECT (a) AS i0, ("rowid" COLLATE BINARY) AS i1 FROM 't1' INDEXED BY 'i1' ORDER BY 1,2) AS i}
64
+ }
65
+
66
+ do_index_check_test 1.3 i1 {
67
+ {} 'five',5
68
+ {} 'four',4
69
+ {} 'one',1
70
+ {} 'three',3
71
+ {} 'two',2
72
+ }
73
+
74
+ do_index_check_test 1.4 i2 {
75
+ {} 'two',2
76
+ {} 'three',3
77
+ {} 'one',1
78
+ {} 'four',4
79
+ {} 'five',5
80
+ }
81
+
82
+ do_test 1.5 {
83
+ set tblroot [db one { SELECT rootpage FROM sqlite_master WHERE name='t1' }]
84
+ sqlite3_imposter db main $tblroot {CREATE TABLE xt1(a,b)}
85
+ db eval {
86
+ UPDATE xt1 SET a='six' WHERE rowid=3;
87
+ DELETE FROM xt1 WHERE rowid = 5;
88
+ }
89
+ sqlite3_imposter db main
90
+ } {}
91
+
92
+ do_index_check_test 1.6 i1 {
93
+ {row missing} 'five',5
94
+ {} 'four',4
95
+ {} 'one',1
96
+ {row data mismatch} 'three',3
97
+ {} 'two',2
98
+ }
99
+
100
+ do_index_check_test 1.7 i2 {
101
+ {} 'two',2
102
+ {row data mismatch} 'three',3
103
+ {} 'one',1
104
+ {} 'four',4
105
+ {row missing} 'five',5
106
+ }
107
+
108
+ #--------------------------------------------------------------------------
109
+ do_execsql_test 2.0 {
110
+
111
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c, d);
112
+
113
+ INSERT INTO t2 VALUES(1, NULL, 1, 1);
114
+ INSERT INTO t2 VALUES(2, 1, NULL, 1);
115
+ INSERT INTO t2 VALUES(3, 1, 1, NULL);
116
+
117
+ INSERT INTO t2 VALUES(4, 2, 2, 1);
118
+ INSERT INTO t2 VALUES(5, 2, 2, 2);
119
+ INSERT INTO t2 VALUES(6, 2, 2, 3);
120
+
121
+ INSERT INTO t2 VALUES(7, 2, 2, 1);
122
+ INSERT INTO t2 VALUES(8, 2, 2, 2);
123
+ INSERT INTO t2 VALUES(9, 2, 2, 3);
124
+
125
+ CREATE INDEX i3 ON t2(b, c, d);
126
+ CREATE INDEX i4 ON t2(b DESC, c DESC, d DESC);
127
+ CREATE INDEX i5 ON t2(d, c DESC, b);
128
+ } {}
129
+
130
+ do_index_check_test 2.1 i3 {
131
+ {} NULL,1,1,1
132
+ {} 1,NULL,1,2
133
+ {} 1,1,NULL,3
134
+ {} 2,2,1,4
135
+ {} 2,2,1,7
136
+ {} 2,2,2,5
137
+ {} 2,2,2,8
138
+ {} 2,2,3,6
139
+ {} 2,2,3,9
140
+ }
141
+
142
+ do_index_check_test 2.2 i4 {
143
+ {} 2,2,3,6
144
+ {} 2,2,3,9
145
+ {} 2,2,2,5
146
+ {} 2,2,2,8
147
+ {} 2,2,1,4
148
+ {} 2,2,1,7
149
+ {} 1,1,NULL,3
150
+ {} 1,NULL,1,2
151
+ {} NULL,1,1,1
152
+ }
153
+
154
+ do_index_check_test 2.3 i5 {
155
+ {} NULL,1,1,3
156
+ {} 1,2,2,4
157
+ {} 1,2,2,7
158
+ {} 1,1,NULL,1
159
+ {} 1,NULL,1,2
160
+ {} 2,2,2,5
161
+ {} 2,2,2,8
162
+ {} 3,2,2,6
163
+ {} 3,2,2,9
164
+ }
165
+
166
+ #--------------------------------------------------------------------------
167
+ do_execsql_test 3.0 {
168
+
169
+ CREATE TABLE t3(w, x, y, z PRIMARY KEY) WITHOUT ROWID;
170
+ CREATE INDEX t3wxy ON t3(w, x, y);
171
+ CREATE INDEX t3wxy2 ON t3(w DESC, x DESC, y DESC);
172
+
173
+ INSERT INTO t3 VALUES(NULL, NULL, NULL, 1);
174
+ INSERT INTO t3 VALUES(NULL, NULL, NULL, 2);
175
+ INSERT INTO t3 VALUES(NULL, NULL, NULL, 3);
176
+
177
+ INSERT INTO t3 VALUES('a', NULL, NULL, 4);
178
+ INSERT INTO t3 VALUES('a', NULL, NULL, 5);
179
+ INSERT INTO t3 VALUES('a', NULL, NULL, 6);
180
+
181
+ INSERT INTO t3 VALUES('a', 'b', NULL, 7);
182
+ INSERT INTO t3 VALUES('a', 'b', NULL, 8);
183
+ INSERT INTO t3 VALUES('a', 'b', NULL, 9);
184
+
185
+ } {}
186
+
187
+ do_index_check_test 3.1 t3wxy {
188
+ {} NULL,NULL,NULL,1 {} NULL,NULL,NULL,2 {} NULL,NULL,NULL,3
189
+ {} 'a',NULL,NULL,4 {} 'a',NULL,NULL,5 {} 'a',NULL,NULL,6
190
+ {} 'a','b',NULL,7 {} 'a','b',NULL,8 {} 'a','b',NULL,9
191
+ }
192
+ do_index_check_test 3.2 t3wxy2 {
193
+ {} 'a','b',NULL,7 {} 'a','b',NULL,8 {} 'a','b',NULL,9
194
+ {} 'a',NULL,NULL,4 {} 'a',NULL,NULL,5 {} 'a',NULL,NULL,6
195
+ {} NULL,NULL,NULL,1 {} NULL,NULL,NULL,2 {} NULL,NULL,NULL,3
196
+ }
197
+
198
+ #--------------------------------------------------------------------------
199
+ # Test with an index that uses non-default collation sequences.
200
+ #
201
+ do_execsql_test 4.0 {
202
+ CREATE TABLE t4(a INTEGER PRIMARY KEY, c1 TEXT, c2 TEXT);
203
+ INSERT INTO t4 VALUES(1, 'aaa', 'bbb');
204
+ INSERT INTO t4 VALUES(2, 'AAA', 'CCC');
205
+ INSERT INTO t4 VALUES(3, 'aab', 'ddd');
206
+ INSERT INTO t4 VALUES(4, 'AAB', 'EEE');
207
+
208
+ CREATE INDEX t4cc ON t4(c1 COLLATE nocase, c2 COLLATE nocase);
209
+ }
210
+
211
+ do_index_check_test 4.1 t4cc {
212
+ {} 'aaa','bbb',1
213
+ {} 'AAA','CCC',2
214
+ {} 'aab','ddd',3
215
+ {} 'AAB','EEE',4
216
+ }
217
+
218
+ do_test 4.2 {
219
+ set tblroot [db one { SELECT rootpage FROM sqlite_master WHERE name='t4' }]
220
+ sqlite3_imposter db main $tblroot \
221
+ {CREATE TABLE xt4(a INTEGER PRIMARY KEY, c1 TEXT, c2 TEXT)}
222
+
223
+ db eval {
224
+ UPDATE xt4 SET c1='hello' WHERE rowid=2;
225
+ DELETE FROM xt4 WHERE rowid = 3;
226
+ }
227
+ sqlite3_imposter db main
228
+ } {}
229
+
230
+ do_index_check_test 4.3 t4cc {
231
+ {} 'aaa','bbb',1
232
+ {row data mismatch} 'AAA','CCC',2
233
+ {row missing} 'aab','ddd',3
234
+ {} 'AAB','EEE',4
235
+ }
236
+
237
+ #--------------------------------------------------------------------------
238
+ # Test an index on an expression.
239
+ #
240
+ do_execsql_test 5.0 {
241
+ CREATE TABLE t5(x INTEGER PRIMARY KEY, y TEXT, UNIQUE(y));
242
+ INSERT INTO t5 VALUES(1, '{"x":1, "y":1}');
243
+ INSERT INTO t5 VALUES(2, '{"x":2, "y":2}');
244
+ INSERT INTO t5 VALUES(3, '{"x":3, "y":3}');
245
+ INSERT INTO t5 VALUES(4, '{"w":4, "z":4}');
246
+ INSERT INTO t5 VALUES(5, '{"x":5, "y":5}');
247
+
248
+ CREATE INDEX t5x ON t5( json_extract(y, '$.x') );
249
+ CREATE INDEX t5y ON t5( json_extract(y, '$.y') DESC );
250
+ }
251
+
252
+ do_index_check_test 5.1.1 t5x {
253
+ {} NULL,4 {} 1,1 {} 2,2 {} 3,3 {} 5,5
254
+ }
255
+
256
+ do_index_check_test 5.1.2 t5y {
257
+ {} 5,5 {} 3,3 {} 2,2 {} 1,1 {} NULL,4
258
+ }
259
+
260
+ do_index_check_test 5.1.3 sqlite_autoindex_t5_1 {
261
+ {} {'{"w":4, "z":4}',4}
262
+ {} {'{"x":1, "y":1}',1}
263
+ {} {'{"x":2, "y":2}',2}
264
+ {} {'{"x":3, "y":3}',3}
265
+ {} {'{"x":5, "y":5}',5}
266
+ }
267
+
268
+ do_test 5.2 {
269
+ set tblroot [db one { SELECT rootpage FROM sqlite_master WHERE name='t5' }]
270
+ sqlite3_imposter db main $tblroot \
271
+ {CREATE TABLE xt5(a INTEGER PRIMARY KEY, c1 TEXT);}
272
+ db eval {
273
+ UPDATE xt5 SET c1='{"x":22, "y":11}' WHERE rowid=1;
274
+ DELETE FROM xt5 WHERE rowid = 4;
275
+ }
276
+ sqlite3_imposter db main
277
+ } {}
278
+
279
+ do_index_check_test 5.3.1 t5x {
280
+ {row missing} NULL,4
281
+ {row data mismatch} 1,1
282
+ {} 2,2
283
+ {} 3,3
284
+ {} 5,5
285
+ }
286
+
287
+ do_index_check_test 5.3.2 sqlite_autoindex_t5_1 {
288
+ {row missing} {'{"w":4, "z":4}',4}
289
+ {row data mismatch} {'{"x":1, "y":1}',1}
290
+ {} {'{"x":2, "y":2}',2}
291
+ {} {'{"x":3, "y":3}',3}
292
+ {} {'{"x":5, "y":5}',5}
293
+ }
294
+
295
+ #-------------------------------------------------------------------------
296
+ #
297
+ do_execsql_test 6.0 {
298
+ CREATE TABLE t6(x INTEGER PRIMARY KEY, y, z);
299
+ CREATE INDEX t6x1 ON t6(y, /* one,two,three */ z);
300
+ CREATE INDEX t6x2 ON t6(z, -- hello,world,
301
+ y);
302
+
303
+ CREATE INDEX t6x3 ON t6(z -- hello,world
304
+ , y);
305
+
306
+ INSERT INTO t6 VALUES(1, 2, 3);
307
+ INSERT INTO t6 VALUES(4, 5, 6);
308
+ }
309
+
310
+ do_index_check_test 6.1 t6x1 {
311
+ {} 2,3,1
312
+ {} 5,6,4
313
+ }
314
+ do_index_check_test 6.2 t6x2 {
315
+ {} 3,2,1
316
+ {} 6,5,4
317
+ }
318
+ do_index_check_test 6.2 t6x3 {
319
+ {} 3,2,1
320
+ {} 6,5,4
321
+ }
322
+
323
+ #-------------------------------------------------------------------------
324
+ #
325
+ do_execsql_test 7.0 {
326
+ CREATE TABLE t7(x INTEGER PRIMARY KEY, y, z);
327
+ INSERT INTO t7 VALUES(1, 1, 1);
328
+ INSERT INTO t7 VALUES(2, 2, 0);
329
+ INSERT INTO t7 VALUES(3, 3, 1);
330
+ INSERT INTO t7 VALUES(4, 4, 0);
331
+
332
+ CREATE INDEX t7i1 ON t7(y) WHERE z=1;
333
+ CREATE INDEX t7i2 ON t7(y) /* hello,world */ WHERE z=1;
334
+ CREATE INDEX t7i3 ON t7(y) WHERE -- yep
335
+ z=1;
336
+ CREATE INDEX t7i4 ON t7(y) WHERE z=1 -- yep;
337
+ }
338
+ do_index_check_test 7.1 t7i1 {
339
+ {} 1,1 {} 3,3
340
+ }
341
+ do_index_check_test 7.2 t7i2 {
342
+ {} 1,1 {} 3,3
343
+ }
344
+ do_index_check_test 7.3 t7i3 {
345
+ {} 1,1 {} 3,3
346
+ }
347
+ do_index_check_test 7.4 t7i4 {
348
+ {} 1,1 {} 3,3
349
+ }