# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+-include ../../config.make
include $(GNUSTEP_MAKEFILES)/common.make
+include ../Version
+include ./Version
BUNDLE_NAME = SQLite3
SQLite3_PRINCIPAL_CLASS = SQLiteAdaptor
BUNDLE_INSTALL = SQLite3
-BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Libraries/Adaptors
+BUNDLE_INSTALL_DIR = $(GNUSTEP_INSTALLATION_DIR)/Library/GDLAdaptors-$(MAJOR_VERSION).$(MINOR_VERSION)/
# Use .gdladaptor as the bundle extension
BUNDLE_EXTENSION = .gdladaptor
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/bundle.make
-#include $(GNUSTEP_MAKEFILES)/tool.make
+ifeq ($(test),yes)
+include $(GNUSTEP_MAKEFILES)/tool.make
+endif
-include GNUmakefile.postamble
+include fhs.make
return (self->_connection != NULL) ? YES : NO;
}
+- (int)maxOpenConnectionCount {
+ static int MaxOpenConnectionCount = -1;
+
+ if (MaxOpenConnectionCount == -1) {
+ MaxOpenConnectionCount =
+ [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"SQLiteMaxOpenConnectionCount"];
+ if (MaxOpenConnectionCount == 0) {
+ MaxOpenConnectionCount = 15;
+ }
+ }
+ return MaxOpenConnectionCount;
+}
+
- (BOOL)openChannel {
SQLiteAdaptor *adaptor;
int rc;
openConnectionCount);
#endif
{
- static int MaxOpenConnectionCount = -1;
-
- if (MaxOpenConnectionCount == -1) {
- MaxOpenConnectionCount =
- [[NSUserDefaults standardUserDefaults]
- integerForKey:@"SQLiteMaxOpenConnectionCount"];
- if (MaxOpenConnectionCount == 0) {
- MaxOpenConnectionCount = 15;
- }
- }
- if (openConnectionCount > MaxOpenConnectionCount) {
- [SQLiteCouldNotOpenChannelException raise:
- @"NoMoreConnections"
- format:
- @"cannot open a additional connection !"];
+ if (openConnectionCount > [self maxOpenConnectionCount]) {
+ [SQLiteCouldNotOpenChannelException
+ raise:@"NoMoreConnections"
+ format:@"cannot open a additional connection !"];
return NO;
}
}
-//
+/*
+ SQLiteValues.h
+
+ Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess
+
+ Author: Helge Hess (helge@mdlink.de)
+
+ This file is part of the SQLite Adaptor Library
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
#import <Foundation/Foundation.h>
#import <GDLAccess/GDLAccess.h>
#include <NGExtensions/NGExtensions.h>
-int main(int argc, char **argv, char **env) {
- EOModel *m = nil;
- EOAdaptor *a;
+static void runtestInOpenChannel(EOAdaptorChannel *ch) {
EOAdaptorContext *ctx;
- EOAdaptorChannel *ch;
- NSDictionary *conDict;
- NSString *expr;
-
- [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+ EOModel *m;
+ NSString *expr;
- NS_DURING {
-
- conDict = [NSDictionary dictionaryWithContentsOfFile:@"condict.plist"];
- NSLog(@"condict is %@", conDict);
-
- if ((a = [EOAdaptor adaptorWithName:@"SQLite3"]) == nil) {
- NSLog(@"found no SQLite3 adaptor ..");
- exit(1);
- }
-
- NSLog(@"got adaptor %@", a);
- [a setConnectionDictionary:conDict];
- NSLog(@"got adaptor with condict %@", a);
-
- ctx = [a createAdaptorContext];
- ch = [ctx createAdaptorChannel];
+ ctx = [ch adaptorContext];
+ m = [[ctx adaptor] model];
-#if 1
- m = AUTORELEASE([[EOModel alloc] initWithContentsOfFile:@"test.eomodel"]);
- if (m) {
- [a setModel:m];
- [a setConnectionDictionary:conDict];
- }
-#endif
-
expr = [[NSUserDefaults standardUserDefaults] stringForKey:@"sql"];
- NSLog(@"opening channel ..");
-
- [ch setDebugEnabled:YES];
-
- if ([ch openChannel]) {
- NSLog(@"channel is open");
+ NSLog(@"channel is open");
- if ([ctx beginTransaction]) {
+ if ([ctx beginTransaction]) {
NSLog(@"began tx ..");
/* do something */
#endif
/* fetch some doof records */
- e = [m entityNamed:@"Doof"];
+ e = [m entityNamed:@"MyEntity"];
NSLog(@"entity: %@", e);
if (e == nil)
exit(1);
else
NSLog(@" commit failed.");
}
+}
+
+static void runtest(void) {
+ EOModel *m = nil;
+ EOAdaptor *a;
+ EOAdaptorContext *ctx;
+ EOAdaptorChannel *ch;
+ NSDictionary *conDict;
+
+ NS_DURING {
+
+ conDict = [NSDictionary dictionaryWithContentsOfFile:@"condict.plist"];
+ NSLog(@"condict is %@", conDict);
+
+ if ((a = [EOAdaptor adaptorWithName:@"SQLite3"]) == nil) {
+ NSLog(@"found no SQLite3 adaptor ..");
+ exit(1);
+ }
+
+ NSLog(@"got adaptor %@", a);
+ [a setConnectionDictionary:conDict];
+ NSLog(@"got adaptor with condict %@", a);
+
+ ctx = [a createAdaptorContext];
+ ch = [ctx createAdaptorChannel];
+
+#if 1
+ m = AUTORELEASE([[EOModel alloc] initWithContentsOfFile:@"test.eomodel"]);
+ if (m) {
+ [a setModel:m];
+ [a setConnectionDictionary:conDict];
+ }
+#endif
+
+ NSLog(@"opening channel ..");
+
+ [ch setDebugEnabled:YES];
+
+ if ([ch openChannel]) {
+ runtestInOpenChannel(ch);
NSLog(@"closing channel ..");
[ch closeChannel];
abort();
}
NS_ENDHANDLER;
+}
+
+int main(int argc, char **argv, char **env) {
+ NSAutoreleasePool *pool;
+
+ pool = [[NSAutoreleasePool alloc] init];
+ [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+ runtest();
+ [pool release];
return 0;
}