4 Copyright (C) 1996 Free Software Foundation, Inc.
6 Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
9 This file is part of the GNUstep Database Library.
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
21 You should have received a copy of the GNU Library General Public
22 License along with this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 // $Id: connect-EOAdaptor.m 1 2004-08-20 10:38:46Z znek $
28 #import <Foundation/Foundation.h>
29 #include <GDLAccess/EOAdaptor.h>
30 #include <GDLAccess/EOAdaptorContext.h>
31 #include <GDLAccess/EOAdaptorChannel.h>
34 int main(int argc, char **argv, char **env) {
35 NSAutoreleasePool *pool;
37 NSString *adaptorName;
39 NSDictionary *condict;
41 EOAdaptorContext *adctx;
42 EOAdaptorChannel *adch;
45 pool = [[NSAutoreleasePool alloc] init];
46 #if LIB_FOUNDATION_LIBRARY
47 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
50 args = [[NSProcessInfo processInfo] arguments];
51 if ([args count] < 3) {
52 fprintf(stderr, "usage: %s adaptorname condict\n", argv[0]);
56 adaptorName = [args objectAtIndex:1];
57 condictstr = [args objectAtIndex:2];
62 adaptor = [EOAdaptor adaptorWithName:adaptorName];
65 fprintf(stderr, "ERROR: %s: %s\n",
66 [[localException name] cString],
67 [[localException reason] cString]);
73 fprintf(stderr, "ERROR: failed to load adaptor '%s'.\n",
74 [adaptorName cString]);
78 printf("did load adaptor: %s\n", [[adaptor name] cString]);
80 /* setup connection dictionary */
82 if ((condict = [condictstr propertyList]) == nil) {
83 fprintf(stderr, "ERROR: invalid connection dictionary '%s'.\n",
84 [condictstr cString]);
87 [adaptor setConnectionDictionary:condict];
89 /* setup connection */
91 if ((adctx = [adaptor createAdaptorContext]) == nil) {
92 fprintf(stderr, "ERROR: could not create adaptor context.");
95 if ((adch = [adctx createAdaptorChannel]) == nil) {
96 fprintf(stderr, "ERROR: could not create adaptor channel.");
104 ok = [adch openChannel];
107 fprintf(stderr, "ERROR: could not connect to database %s: %s\n",
108 [[localException name] cString],
109 [[localException reason] cString]);
115 fprintf(stderr, "ERROR: could not connect to database.\n");
119 printf("connection could be established.\n");