oops.. only build it when it _is_ valid.
[AROS-Contrib.git] / regina / staticld.c
blob79e729a90be4872bee3ae73da5f20771a3444718
1 /*
2 * The Regina Rexx Interpreter
3 * Copyright (C) 1993-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "rexx.h"
21 #if defined( DYNAMIC_STATIC )
22 typedef void *(*RPFN)( char *);
24 #ifdef HAVE_REXXUTIL_PACKAGE
25 extern void *getRexxUtilFunctionAddress( char *name );
26 #endif
28 #ifdef HAVE_TEST_PACKAGE
29 extern void *getTest1FunctionAddress( char *name );
30 extern void *getTest2FunctionAddress( char *name );
31 #endif
33 #ifdef HAVE_REXXTK_PACKAGE
34 extern void *getRexxTkFunctionAddress( char *name );
35 #endif
37 #ifdef HAVE_REXXCURSES_PACKAGE
38 extern void *getRexxCursesFunctionAddress( char *name );
39 #endif
41 #ifdef HAVE_REXXGD_PACKAGE
42 extern void *getRexxGdFunctionAddress( char *name );
43 #endif
45 #ifdef HAVE_REXXISAM_PACKAGE
46 extern void *getRexxISAMFunctionAddress( char *name );
47 #endif
49 #ifdef HAVE_REXXCURL_PACKAGE
50 extern void *getRexxCURLFunctionAddress( char *name );
51 #endif
53 #ifdef HAVE_REXXSQL_PACKAGE
54 extern void *getRexxSQLFunctionAddress( char *name );
55 #endif
57 #ifdef HAVE_REXXEEC_PACKAGE
58 extern void *getRexxEECFunctionAddress( char *name );
59 #endif
61 #ifdef HAVE_REXXDW_PACKAGE
62 extern void *getRexxDWFunctionAddress( char *name );
63 #endif
65 #ifdef HAVE_RXSOCK_PACKAGE
66 extern void *getRxSockFunctionAddress( char *name );
67 #endif
69 #ifndef max
70 # define max(a,b) (((a) > (b)) ? (a) : (b))
71 #endif
73 #ifndef min
74 # define min(a,b) (((a) < (b)) ? (a) : (b))
75 #endif
77 static struct
79 char *name;
80 void *(*funcptr)(char *name);
81 } RexxPackages[] =
83 #ifdef HAVE_TEST_PACKAGE
84 { "test1", getTest1FunctionAddress} ,
85 { "test2", getTest2FunctionAddress} ,
86 #endif
87 #ifdef HAVE_REXXUTIL_PACKAGE
88 { "regutil", getRexxUtilFunctionAddress} ,
89 { "rexxutil", getRexxUtilFunctionAddress} ,
90 #endif
91 #ifdef HAVE_REXXTK_PACKAGE
92 { "rexxtk", getRexxTkFunctionAddress },
93 #endif
94 #ifdef HAVE_REXXCURSES_PACKAGE
95 { "rxcurses", getRexxCursesFunctionAddress },
96 #endif
97 #ifdef HAVE_REXXGD_PACKAGE
98 { "rexxgd", getRexxGdFunctionAddress },
99 #endif
100 #ifdef HAVE_REXXISAM_PACKAGE
101 { "rexxisam", getRexxISAMFunctionAddress },
102 #endif
103 #ifdef HAVE_REXXCURL_PACKAGE
104 { "rexxcurl", getRexxCURLFunctionAddress },
105 #endif
106 #ifdef HAVE_REXXSQL_PACKAGE
107 { "rexxsql", getRexxSQLFunctionAddress },
108 #endif
109 #ifdef HAVE_REXXEEC_PACKAGE
110 { "rexxeec", getRexxEECFunctionAddress },
111 #endif
112 #ifdef HAVE_RXSOCK_PACKAGE
113 { "rxsock", getRxSockFunctionAddress },
114 #endif
115 #ifdef HAVE_REXXDW_PACKAGE
116 { "rexxdw", getRexxDWFunctionAddress },
117 #endif
118 { "", NULL },
120 static int my_stricmp( char *str1,char *str2 )
122 int len1,len2,len,rc;
124 len1 = strlen( str1 );
125 len2 = strlen( str2 );
126 len = min( len1, len2 );
128 rc = mem_cmpic( str1, str2, len );
129 if ( rc != 0 )
130 return rc;
132 if ( len1 > len2 )
133 return(1);
134 if ( len1 < len2 )
135 return(-1);
136 return(0);
139 void *static_dlopen( char *name )
141 int i, num_packages ;
142 num_packages = sizeof( RexxPackages ) / sizeof( *RexxPackages );
143 for ( i = 0; i < num_packages; i++)
145 if ( my_stricmp( RexxPackages[i].name, name ) == 0 )
146 return RexxPackages[i].funcptr;
148 return NULL;
151 int static_dlsym( void *addr, char *name, void **faddr )
153 RPFN rpaddr = (RPFN)addr;
154 if ( rpaddr == NULL )
156 return 30;
158 *faddr = (*rpaddr)( name );
159 if (*faddr == NULL )
160 return 1;
161 else
162 return 0;
165 void static_list_packages()
167 int i, num_packages ;
168 num_packages = ( sizeof( RexxPackages ) / sizeof( *RexxPackages ) ) - 1;
169 for ( i = 0; i < num_packages; i++)
171 fprintf( stderr, " Statically loaded: %s\n", RexxPackages[i].name );
174 #endif