]> err.no Git - sope/blob - sope-gdl1/GDLAccess/load-EOAdaptor.m
minor changes to Xcode project layout
[sope] / sope-gdl1 / GDLAccess / load-EOAdaptor.m
1 /* 
2    EOAdaptorChannel.m
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: October 1996
8
9    This file is part of the GNUstep Database Library.
10
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.
15
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.
20
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.
25 */
26 // $Id: load-EOAdaptor.m 1 2004-08-20 10:38:46Z znek $
27
28 #import <Foundation/Foundation.h>
29 #include <GDLAccess/EOAdaptor.h>
30 #include <stdio.h>
31
32 int main(int argc, char **argv, char **env) {
33   NSAutoreleasePool *pool;
34   NSArray   *args;
35   NSString  *adaptorName;
36   EOAdaptor *adaptor;
37   
38   pool = [[NSAutoreleasePool alloc] init];
39 #if LIB_FOUNDATION_LIBRARY
40   [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
41 #endif
42   
43   args = [[NSProcessInfo processInfo] arguments];
44   if ([args count] < 2) {
45     fprintf(stderr, "usage: %s adaptorname\n", argv[0]);
46     exit(10);
47   }
48   
49   adaptorName = [args objectAtIndex:1];
50   
51   NS_DURING {
52     adaptor = [EOAdaptor adaptorWithName:adaptorName];
53   }
54   NS_HANDLER {
55     fprintf(stderr, "ERROR: %s: %s\n",
56             [[localException name]   cString],
57             [[localException reason] cString]);
58     adaptor = nil;
59   }
60   NS_ENDHANDLER;
61
62   if (adaptor) {
63     printf("did load adaptor: %s\n", [[adaptor name] cString]);
64     exit(0);
65   }
66   
67   fprintf(stderr, "ERROR: failed to load adaptor '%s'.\n", 
68           [adaptorName cString]);
69   
70   exit (1);
71   return 1;
72 }