ruby-odbc-supported 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,156 @@
1
+ require 'mkmf'
2
+
3
+ if ! defined? PLATFORM
4
+ PLATFORM = RUBY_PLATFORM
5
+ end
6
+
7
+ def have_library_ex(lib, func="main", headers=nil)
8
+ checking_for "#{func}() in -l#{lib}" do
9
+ libs = append_library($libs, lib)
10
+ if !func.nil? && !func.empty? && COMMON_LIBS.include?(lib)
11
+ true
12
+ elsif try_func(func, libs, headers)
13
+ $libs = libs
14
+ true
15
+ else
16
+ false
17
+ end
18
+ end
19
+ end
20
+
21
+ def try_func_nolink(func, libs, headers = nil, &b)
22
+ headers = cpp_include(headers)
23
+ try_compile(<<"SRC", libs, &b)
24
+ #{COMMON_HEADERS}
25
+ #{headers}
26
+ /*top*/
27
+ int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
28
+ SRC
29
+ end
30
+
31
+ def have_func_nolink(func, headers = nil, &b)
32
+ checking_for "#{func}()" do
33
+ if try_func_nolink(func, $libs, headers, &b)
34
+ $defs.push(format("-DHAVE_%s", func.upcase))
35
+ true
36
+ else
37
+ false
38
+ end
39
+ end
40
+ end
41
+
42
+ dir_config("odbc")
43
+ have_header("sql.h") || begin
44
+ puts "ERROR: sql.h not found"
45
+ exit 1
46
+ end
47
+ have_header("sqlext.h") || begin
48
+ puts "ERROR: sqlext.h not found"
49
+ exit 1
50
+ end
51
+ testdlopen = enable_config("dlopen", false)
52
+ begin
53
+ if PLATFORM !~ /(mingw|cygwin)/ then
54
+ header = "sqltypes.h"
55
+ else
56
+ header = ["windows.h", "sqltypes.h"]
57
+ end
58
+ if defined? have_type
59
+ have_type("SQLTCHAR", header)
60
+ else
61
+ throw
62
+ end
63
+ rescue
64
+ puts "WARNING: please check sqltypes.h for SQLTCHAR manually,"
65
+ puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
66
+ puts "WARNING: the option -DHAVE_TYPE_SQLTCHAR"
67
+ end
68
+ begin
69
+ if PLATFORM !~ /(mingw|cygwin)/ then
70
+ header = "sqltypes.h"
71
+ else
72
+ header = ["windows.h", "sqltypes.h"]
73
+ end
74
+ if defined? have_type
75
+ have_type("SQLLEN", header)
76
+ else
77
+ throw
78
+ end
79
+ rescue
80
+ puts "WARNING: please check sqltypes.h for SQLLEN manually,"
81
+ puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
82
+ puts "WARNING: the option -DHAVE_TYPE_SQLLEN"
83
+ end
84
+ begin
85
+ if PLATFORM !~ /(mingw|cygwin)/ then
86
+ header = "sqltypes.h"
87
+ else
88
+ header = ["windows.h", "sqltypes.h"]
89
+ end
90
+ if defined? have_type
91
+ have_type("SQLULEN", header)
92
+ else
93
+ throw
94
+ end
95
+ rescue
96
+ puts "WARNING: please check sqltypes.h for SQLULEN manually,"
97
+ puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
98
+ puts "WARNING: the option -DHAVE_TYPE_SQLULEN"
99
+ end
100
+ $have_odbcinst_h = have_header("odbcinst.h")
101
+
102
+ if PLATFORM =~ /mswin32/ then
103
+ if !have_library_ex("odbc32", "SQLAllocConnect", "sql.h") ||
104
+ !have_library_ex("odbccp32", "SQLConfigDataSource", "odbcinst.h") ||
105
+ !have_library_ex("odbccp32", "SQLInstallerError", "odbcinst.h") ||
106
+ !have_library("user32", "CharUpper") then
107
+ puts "Can not locate odbc libraries"
108
+ exit 1
109
+ end
110
+ have_func("SQLConfigDataSourceW", "odbcinst.h")
111
+ have_func("SQLWriteFileDSNW", "odbcinst.h")
112
+ have_func("SQLReadFileDSNW", "odbcinst.h")
113
+ have_func("SQLInstallerError", "odbcinst.h")
114
+ have_func("SQLInstallerErrorW", "odbcinst.h")
115
+ elsif PLATFORM =~ /(mingw|cygwin)/ then
116
+ have_library("odbc32")
117
+ have_library("odbccp32")
118
+ have_library("user32")
119
+ header = ["windows.h", "odbcinst.h"]
120
+ have_func("SQLConfigDataSourceW", header)
121
+ have_func("SQLWriteFileDSNW", header)
122
+ have_func("SQLReadFileDSNW", header)
123
+ have_func("SQLInstallerError", header)
124
+ have_func("SQLInstallerErrorW", header)
125
+ elsif (testdlopen && PLATFORM !~ /(macos|darwin)/ && CONFIG["CC"] =~ /gcc/ && have_func("dlopen", "dlfcn.h") && have_library("dl", "dlopen")) then
126
+ $LDFLAGS+=" -Wl,-init -Wl,ruby_odbc_init -Wl,-fini -Wl,ruby_odbc_fini"
127
+ $CPPFLAGS+=" -DHAVE_SQLCONFIGDATASOURCE"
128
+ $CPPFLAGS+=" -DHAVE_SQLINSTALLERERROR"
129
+ $CPPFLAGS+=" -DUSE_DLOPEN_FOR_ODBC_LIBS"
130
+ # but test the UNICODE installer functions w/o linking
131
+ # in case we need to provide fwd declarations
132
+ have_func_nolink("SQLConfigDataSourceW", "odbcinst.h")
133
+ have_func_nolink("SQLWriteFileDSNW", "odbcinst.h")
134
+ have_func_nolink("SQLReadFileDSNW", "odbcinst.h")
135
+ have_func_nolink("SQLInstallerErrorW", "odbcinst.h")
136
+ else
137
+ $CPPFLAGS+=" -DUNICODE -D_UNICODE"
138
+ have_library("odbc", "SQLAllocConnect") ||
139
+ have_library("iodbc", "SQLAllocConnect")
140
+ ($have_odbcinst_h &&
141
+ have_library("odbcinst", "SQLConfigDataSource")) ||
142
+ ($have_odbcinst_h &&
143
+ have_library("iodbcinst", "SQLConfigDataSource"))
144
+ $have_odbcinst_h &&
145
+ have_func("SQLConfigDataSourceW", "odbcinst.h")
146
+ $have_odbcinst_h &&
147
+ have_func("SQLWriteFileDSNW", "odbcinst.h")
148
+ $have_odbcinst_h &&
149
+ have_func("SQLReadFileDSNW", "odbcinst.h")
150
+ $have_odbcinst_h &&
151
+ have_func("SQLInstallerError", "odbcinst.h")
152
+ $have_odbcinst_h &&
153
+ have_func("SQLInstallerErrorW", "odbcinst.h")
154
+ end
155
+
156
+ create_makefile("odbc_utf8")
data/ext/utf8/init.c ADDED
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Part of ODBC-Ruby binding
3
+ * Copyright (c) 2006-2007 Christian Werner <chw@ch-werner.de>
4
+ *
5
+ * See the file "COPYING" for information on usage
6
+ * and redistribution of this file and for a
7
+ * DISCLAIMER OF ALL WARRANTIES.
8
+ *
9
+ * $Id: init.c,v 1.2 2007/04/07 09:39:08 chw Exp chw $
10
+ */
11
+
12
+ #include "../init.c"
data/ext/utf8/odbc.c ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * ODBC-Ruby binding
3
+ * Copyright (c) 2001-2011 Christian Werner <chw@ch-werner.de>
4
+ *
5
+ * See the file "COPYING" for information on usage
6
+ * and redistribution of this file and for a
7
+ * DISCLAIMER OF ALL WARRANTIES.
8
+ *
9
+ * $Id: odbc.c,v 1.6 2011/01/15 08:02:55 chw Exp chw $
10
+ */
11
+
12
+ #undef UNICODE
13
+ #undef _UNICODE
14
+ #define UNICODE
15
+ #define _UNICODE
16
+
17
+ #include "../odbc.c"