mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-04-21 13:21:03 +00:00
Compare commits
447 commits
Release1_1
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
db1ff663f6 | ||
|
9f90bdc755 | ||
|
1ec70f9323 | ||
|
f84f1f0487 | ||
|
78a66c1a75 | ||
|
2c9070cfd0 | ||
|
936410c7e6 | ||
|
848c1fa4ac | ||
|
aa3262a521 | ||
|
527735d95a | ||
|
c307374590 | ||
|
68678b864e | ||
|
3e35662803 | ||
|
16d56c5395 | ||
|
218578aa95 | ||
|
14dcbf5c7f | ||
|
465bcaa70d | ||
|
346f114fc6 | ||
|
36fe235dba | ||
|
4f622fb975 | ||
|
34aec94427 | ||
|
a8f405c563 | ||
|
267987d01c | ||
|
4c2a293640 | ||
|
ce149e7ee3 | ||
|
8335ce336a | ||
|
a496d0dd8e | ||
|
869cfda7d1 | ||
|
7a142e57c4 | ||
|
d7a3c06c8b | ||
|
cd7daff661 | ||
|
76fd64f7c3 | ||
|
76e72d3c0f | ||
|
76ea8d486e | ||
|
da1b900b92 | ||
|
dc7955472e | ||
|
1b44a32f31 | ||
|
7851639677 | ||
|
535914366a | ||
|
1a0d338a78 | ||
|
ca2f44a323 | ||
|
c3557e74be | ||
|
a9588e8073 | ||
|
fea9797591 | ||
|
94f644590a | ||
|
bb47241044 | ||
|
ec590a5253 | ||
|
5d099c8557 | ||
|
46cf998afc | ||
|
085c36c340 | ||
|
4fdcad1440 | ||
|
6c64e4cb9d | ||
|
0fa39b65e0 | ||
|
d6e4ccdb3e | ||
|
0bb38c5def | ||
|
97216727ff | ||
|
7b7d207f45 | ||
|
9ba41b6d5b | ||
|
b176015f28 | ||
|
048b1a76f8 | ||
|
92e2b06efc | ||
|
cfae0876cc | ||
|
e0fdb1ce9a | ||
|
debbd3c763 | ||
|
e8eeb75eca | ||
|
b9a45a2fc4 | ||
|
8302102928 | ||
|
1138287eb0 | ||
|
d82d973983 | ||
|
5201c42e01 | ||
|
d52ddbd2f3 | ||
|
aeb14dc493 | ||
|
43bf08a70f | ||
|
f570253b40 | ||
|
cdf753373f | ||
|
9c2fcd8816 | ||
|
a35a811727 | ||
|
14e6d5a928 | ||
|
9e68a4d102 | ||
|
1cc4f410e7 | ||
|
2900203c67 | ||
|
e23f3b66a5 | ||
|
2be5efdd46 | ||
|
d33b4b5114 | ||
|
174af22f97 | ||
|
d3a5c50890 | ||
|
9e722821c8 | ||
|
1dcbdc7226 | ||
|
8b5db03110 | ||
|
24cb65059f | ||
|
48c8018343 | ||
|
09526be014 | ||
|
017a6165ee | ||
|
396dcb0355 | ||
|
b4dd6312fe | ||
|
6102dddbcc | ||
|
c48ce0e78e | ||
|
086c59480d | ||
|
9c86e53072 | ||
|
9ba044c0ea | ||
|
85cc5451be | ||
|
2dc662177e | ||
|
e98ab6d200 | ||
|
48a6cc9419 | ||
|
bee12ae4ee | ||
|
5727f252d5 | ||
|
d75ff81bba | ||
|
b6cd1305b3 | ||
|
e7dc1e2dc2 | ||
|
549ba3d96a | ||
|
9174ee9ad7 | ||
|
0c3fd3449d | ||
|
013c068a52 | ||
|
311884bb4a | ||
|
9c2b980170 | ||
|
db5ac54036 | ||
|
c533e6e14c | ||
|
828c5e8ae5 | ||
|
c546062424 | ||
|
eb58bd0d78 | ||
|
8095873ae4 | ||
|
23d6fea4b1 | ||
|
e284891e92 | ||
|
8f6ed04196 | ||
|
db4f1f32cb | ||
|
823f329413 | ||
|
fe7d8e2d9e | ||
|
552d190f31 | ||
|
caebc38b3d | ||
|
7fa072df70 | ||
|
70be58d959 | ||
|
83d4873389 | ||
|
e5d3ea6f6b | ||
|
1ce3253a97 | ||
|
efd9f26947 | ||
|
8e12a18ec2 | ||
|
52bedc89b3 | ||
|
eac59b0d77 | ||
|
e1b855d2f2 | ||
|
a272f2cffa | ||
|
efa86d441e | ||
|
8735bd4ab8 | ||
|
5576e55028 | ||
|
3bb76c9230 | ||
|
88ece98e6c | ||
|
316dca8d3f | ||
|
7ab46148d9 | ||
|
905aa5c4a3 | ||
|
677a8e69d8 | ||
|
6f69ad8b20 | ||
|
88d8226d7b | ||
|
19a0effa92 | ||
|
a436122915 | ||
|
637653cd0c | ||
|
eecb706229 | ||
|
03eca5e288 | ||
|
ea01e0cb85 | ||
|
3fefb489fe | ||
|
50a8a2ca59 | ||
|
182fa71ff3 | ||
|
bd4f1bcf96 | ||
|
42839ca9f1 | ||
|
c391097b05 | ||
|
3c0f8a4840 | ||
|
14c31894a0 | ||
|
fb23a2d5fd | ||
|
39c084eb1c | ||
|
8939b86ba4 | ||
|
37447b55b9 | ||
|
896f6df0d6 | ||
|
4f374e0150 | ||
|
36533d3527 | ||
|
5a4d4f3fce | ||
|
88796e18bc | ||
|
3bde5e99a8 | ||
|
55e33d0f29 | ||
|
023cba96ea | ||
|
917150afd9 | ||
|
08376ad7b9 | ||
|
b949cbd9c8 | ||
|
ad45131796 | ||
|
a074b69395 | ||
|
097c71a9c9 | ||
|
2e27c77f1a | ||
|
53a51aa60a | ||
|
eba637c00e | ||
|
08808d55b8 | ||
|
e472d45d38 | ||
|
a2f7d330b9 | ||
|
97982d2d72 | ||
|
25a0a1220e | ||
|
11bf21a930 | ||
|
85d8389ba0 | ||
|
c47c323a7f | ||
|
9282a5134d | ||
|
6eee4f014a | ||
|
35ee61bad9 | ||
|
a5ce6c870e | ||
|
855171a26f | ||
|
23870a60a2 | ||
|
1fd4b0abe9 | ||
|
bffc581dc0 | ||
|
754b6547a9 | ||
|
b10c6c592d | ||
|
28f18d26a4 | ||
|
d70286f339 | ||
|
19a68d1abd | ||
|
fe1d368d66 | ||
|
17ce0ccf78 | ||
|
dcbcc92993 | ||
|
3d4c775f41 | ||
|
0836cc15ad | ||
|
950252a37f | ||
|
63ff9b2bfd | ||
|
a35f4cee92 | ||
|
f312d036d0 | ||
|
2db59e861c | ||
|
78764f0ce1 | ||
|
bd63d63d0f | ||
|
7aafa6f372 | ||
|
391b543e6c | ||
|
069b1b1e95 | ||
|
9d13495a8a | ||
|
3bdf2686b5 | ||
|
edc1a8310a | ||
|
19b900d172 | ||
|
7f64902d1f | ||
|
e3429d9079 | ||
|
6ae8df20b7 | ||
|
c035f9cf39 | ||
|
0f06c9b7fc | ||
|
c6fc158f34 | ||
|
e03ba02d29 | ||
|
9d1157b9c0 | ||
|
832e22bc45 | ||
|
f065c65fab | ||
|
e062fabf15 | ||
|
b1ccabeb7e | ||
|
90476078d5 | ||
|
0f84c574d5 | ||
|
3a502f17bf | ||
|
6ac6b7033f | ||
|
5f54b5fad3 | ||
|
39130494be | ||
|
e54378f320 | ||
|
698b359608 | ||
|
aa159b1455 | ||
|
3c56d1fa82 | ||
|
c46336e96c | ||
|
2c37086861 | ||
|
92b29b8ed0 | ||
|
c8c192c738 | ||
|
10478732e6 | ||
|
1a68bf02c2 | ||
|
ab9010db3b | ||
|
fd50180862 | ||
|
613de3c660 | ||
|
38bf6cbe72 | ||
|
3c49c76afe | ||
|
ac0e231c9a | ||
|
2c40163ef2 | ||
|
7f19e9e996 | ||
|
9a00a62842 | ||
|
2a8895805f | ||
|
f4f2b640f9 | ||
|
bf33b6d564 | ||
|
9f3394e3a4 | ||
|
840679cff1 | ||
|
9feb78e6af | ||
|
415aa4a3ad | ||
|
1d93696eb4 | ||
|
0b8dc96fa2 | ||
|
f3cc52bc43 | ||
|
d1beaed950 | ||
|
bd40e7b084 | ||
|
17c3da4489 | ||
|
631183a672 | ||
|
4b43448d28 | ||
|
0c1eebfc6c | ||
|
3a3f32d920 | ||
|
254d26adac | ||
|
da40485fe2 | ||
|
1db8d56643 | ||
|
0469ba48fb | ||
|
5b64b5c3bf | ||
|
ca230f1ae4 | ||
|
803a67ff54 | ||
|
1e02d0189f | ||
|
272491adc9 | ||
|
56fc0088ad | ||
|
da909810ee | ||
|
a4ec0e036b | ||
|
2e84577b69 | ||
|
1f11ea97a9 | ||
|
1fdb15cfb0 | ||
|
e455a6d65b | ||
|
11194d702d | ||
|
85d5fbfecf | ||
|
5db99986be | ||
|
3be013e271 | ||
|
940b3a5fd1 | ||
|
383478b346 | ||
|
306bdeb027 | ||
|
e72041ce6c | ||
|
f47e5833e6 | ||
|
b00d51e017 | ||
|
837ddf035f | ||
|
10a8ac3164 | ||
|
6543cd6314 | ||
|
e54505f057 | ||
|
1d4fdce501 | ||
|
c252834070 | ||
|
6fe56d2e1e | ||
|
e307f93142 | ||
|
ba81d9f082 | ||
|
2f54d889e4 | ||
|
72ca578ca0 | ||
|
1006966504 | ||
|
1b88d7bb36 | ||
|
543cb6d43b | ||
|
9c041a164a | ||
|
30edde0a7a | ||
|
cc233b6ba0 | ||
|
258efaeaf7 | ||
|
799c2de9f2 | ||
|
ae4c868169 | ||
|
b3a84626e6 | ||
|
f71418098c | ||
|
0023174259 | ||
|
306b48c2bf | ||
|
2e858a3b55 | ||
|
64abeac596 | ||
|
18bb5590ce | ||
|
6b6a5ed928 | ||
|
9a126738ed | ||
|
29c3fa5061 | ||
|
269223af2f | ||
|
7428af2adc | ||
|
65d09b350c | ||
|
a00b7f88f7 | ||
|
a664ef852c | ||
|
bcd242f388 | ||
|
d66ae7e9be | ||
|
7f296031ba | ||
|
fd1357a5a9 | ||
|
ef6dc82428 | ||
|
314416a39a | ||
|
e85df9167e | ||
|
e19d2ab734 | ||
|
9ad6b08ed8 | ||
|
1f30daee2d | ||
|
d1ae32b83b | ||
|
52b5f575cf | ||
|
e175fb6ed0 | ||
|
acd1603b67 | ||
|
e5217a11e7 | ||
|
41c74233c9 | ||
|
6bab4c4daf | ||
|
2dc9e99bc2 | ||
|
896e7f5d86 | ||
|
d4693f2397 | ||
|
a461b3da3b | ||
|
a2182c46ff | ||
|
fc46f3a865 | ||
|
90cbc3a46b | ||
|
aa891e7a6a | ||
|
08456b4a80 | ||
|
07b82dba68 | ||
|
5e2991ca45 | ||
|
1aeb216ed9 | ||
|
b7dd7a659a | ||
|
983774ecce | ||
|
2a45d0226e | ||
|
f7b9cc59d2 | ||
|
99d65a01a7 | ||
|
0762f61120 | ||
|
f180b1c6ca | ||
|
073f4242f1 | ||
|
6fa297b461 | ||
|
e6c648aa39 | ||
|
37111f260d | ||
|
563e93f83e | ||
|
94f9151f12 | ||
|
bf3c2e5c38 | ||
|
6956570428 | ||
|
305e7715c5 | ||
|
a4b1bbfc99 | ||
|
db2d235c42 | ||
|
aa30a2b0d0 | ||
|
9e7142bde6 | ||
|
2731b9ee3f | ||
|
17b05c9f97 | ||
|
66bfe32e1b | ||
|
b8a2cd5f0a | ||
|
3460e25451 | ||
|
7444679fde | ||
|
b168cfc003 | ||
|
fd883799a8 | ||
|
f1e4b002a3 | ||
|
3bde04197d | ||
|
92d4031698 | ||
|
832e2bfdbd | ||
|
e0edc9e21a | ||
|
67b9859bc8 | ||
|
29de615f8b | ||
|
0c537df227 | ||
|
119c1993dc | ||
|
b7b7e38a6a | ||
|
a9de728fa0 | ||
|
96a28fa22b | ||
|
cdfcb0e78d | ||
|
56bfea7a6e | ||
|
f9f44c7aad | ||
|
567ea1756f | ||
|
f42028ad00 | ||
|
4516b9b9d1 | ||
|
65c4b6015f | ||
|
d62edc6002 | ||
|
a6356d78ce | ||
|
c5697eafaa | ||
|
dfffb8e5f5 | ||
|
c67e01ab7d | ||
|
0ef78e48ef | ||
|
4ba19049b3 | ||
|
d4f8c6d2a7 | ||
|
f9fc2a6ee9 | ||
|
7dabe7d8da | ||
|
dc896321a8 | ||
|
1c63231f37 | ||
|
e1f1c87e86 | ||
|
56131fc572 | ||
|
5c44a76439 | ||
|
4da9b3ba28 | ||
|
6e63e622ce | ||
|
2d123b3b54 | ||
|
9f7710abc7 | ||
|
51fa3d864d | ||
|
6c65810e52 | ||
|
ed84e87806 | ||
|
d4d7428dc8 | ||
|
84a3492d08 | ||
|
fb6bdb5b92 | ||
|
d9c511e1b0 | ||
|
daf6b5c848 | ||
|
9bf2560ae9 | ||
|
d288d00918 | ||
|
508af4e4c4 |
33 changed files with 19532 additions and 11650 deletions
620
COPYING.LIB
620
COPYING.LIB
|
@ -1,504 +1,166 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
0. Additional Definitions.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
4. Combined Works.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
|
|
326
ECPG.pgm
326
ECPG.pgm
|
@ -9,16 +9,16 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
|
@ -40,6 +40,9 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
@interface SQLClientECPG : SQLClient
|
||||
|
@ -108,18 +111,18 @@ void SQLErrorHandler()
|
|||
const char *e1 = "Error in transaction processing";
|
||||
|
||||
sqlca.sqlcode = 0; // Reset error code
|
||||
NSLog (@"Raising an exception, %ld, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
NSLog (@"Raising an exception, %d, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
|
||||
if (strncmp(ptr, e0, strlen(e0)) == 0
|
||||
|| strncmp(ptr, e1, strlen(e1)) == 0)
|
||||
{
|
||||
[NSException raise: SQLConnectionException
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +137,7 @@ static NSDate *future = nil;
|
|||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
RETAIN(future);
|
||||
[future retain];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,20 +248,20 @@ static NSDate *future = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
unsigned int length;
|
||||
NSString *stmt = [info objectAtIndex: 0];
|
||||
|
||||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -276,9 +279,9 @@ static NSDate *future = nil;
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
[self name], stmt];
|
||||
|
@ -296,7 +299,7 @@ static NSDate *future = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -322,13 +325,14 @@ static NSDate *future = nil;
|
|||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
[arp release];
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -356,6 +360,8 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
bool aBool;
|
||||
|
@ -377,7 +383,7 @@ static unsigned int trim(char *str)
|
|||
char *query;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableArray *records;
|
||||
BOOL isOpen = NO;
|
||||
BOOL localTransaction = NO;
|
||||
|
@ -385,21 +391,21 @@ static unsigned int trim(char *str)
|
|||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
query = (char*)[hackForPrepare(stmt) UTF8String];
|
||||
handle = (char*)[[self clientName] UTF8String];
|
||||
records = [[NSMutableArray alloc] initWithCapacity: 32];
|
||||
records = [[ltype alloc] initWithCapacity: 32];
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
[self name], stmt];
|
||||
|
@ -551,7 +557,10 @@ static unsigned int trim(char *str)
|
|||
case SQL3_CHARACTER_VARYING:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
trim(aString);
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -580,7 +589,10 @@ static unsigned int trim(char *str)
|
|||
default:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
trim(aString);
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
if ([self debugging] > 0)
|
||||
|
@ -597,11 +609,11 @@ static unsigned int trim(char *str)
|
|||
keys[index-1] = [NSString stringWithUTF8String:
|
||||
fieldName];
|
||||
}
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
[records addObject: record];
|
||||
RELEASE(record);
|
||||
[record release];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,7 +631,8 @@ static unsigned int trim(char *str)
|
|||
NSString *n = [localException name];
|
||||
NSString *msg = [localException reason];
|
||||
|
||||
DESTROY(records);
|
||||
[records release];
|
||||
records = nil;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -638,14 +651,14 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -667,15 +680,15 @@ static unsigned int trim(char *str)
|
|||
userInfo: nil];
|
||||
}
|
||||
}
|
||||
RETAIN(localException);
|
||||
RELEASE(arp);
|
||||
AUTORELEASE(localException);
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
[arp release];
|
||||
|
||||
return AUTORELEASE(records);
|
||||
return [records autorelease];
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -809,7 +822,7 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
}
|
||||
dst[dLen] = '\0';
|
||||
return dst; // Owned by autoreleased NSMutableData
|
||||
return (const char*)dst; // Owned by autoreleased NSMutableData
|
||||
}
|
||||
|
||||
- (NSData *) dataFromBlob: (const char *)blob
|
||||
|
@ -933,9 +946,13 @@ static unsigned int trim(char *str)
|
|||
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -958,98 +975,153 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l
|
||||
|
@ -1067,8 +1139,8 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
d = [[NSData alloc] initWithBytes: b length: l];
|
||||
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
|
||||
RELEASE(d);
|
||||
return AUTORELEASE(s);
|
||||
[d release];
|
||||
return [s autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
175
GNUmakefile
175
GNUmakefile
|
@ -1,30 +1,59 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(error You need to set GNUSTEP_MAKEFILES before compiling!)
|
||||
endif
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
# Force sequential build to prevent different versions of the same
|
||||
# bundle overwriting each other's temporary files during building.
|
||||
GNUSTEP_MAKE_PARALLEL_BUILDING=no
|
||||
|
||||
-include config.make
|
||||
|
||||
PACKAGE_NAME = SQLClient
|
||||
PACKAGE_VERSION = 1.9.0
|
||||
CVS_MODULE_NAME = gnustep/dev-libs/SQLClient
|
||||
CVS_TAG_NAME = SQLClient
|
||||
SVN_BASE_URL=svn+ssh://svn.gna.org/svn/gnustep/libs
|
||||
SVN_MODULE_NAME=sqlclient
|
||||
|
||||
NEEDS_GUI = NO
|
||||
|
||||
TEST_TOOL_NAME=
|
||||
|
||||
LIBRARY_NAME=SQLClient
|
||||
DOCUMENT_NAME=SQLClient
|
||||
|
||||
SQLClient_INTERFACE_VERSION=1.1
|
||||
SQLClient_INTERFACE_VERSION=1.9
|
||||
|
||||
SQLClient_OBJC_FILES = SQLClient.m WebServer.m WebServerBundles.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON =
|
||||
SQLClient_HEADER_FILES = SQLClient.h WebServer.h
|
||||
SQLClient_OBJC_FILES = SQLClient.m SQLClientPool.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance $(FND_LIBS) $(OBJC_LIBS)
|
||||
SQLClient_HEADER_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FLAGS = -WordMap '{SQLCLIENT_PRIVATE="";}'
|
||||
|
||||
# Optional Java wrappers for the library
|
||||
JAVA_WRAPPER_NAME = SQLClient
|
||||
|
||||
SQLClient_HEADER_FILES_INSTALL_DIR = SQLClient
|
||||
|
||||
|
||||
DOCUMENT_NAME=SQLClient
|
||||
SQLClient_AGSDOC_FILES = SQLClient.h WebServer.h
|
||||
|
||||
|
||||
BUNDLE_NAME=
|
||||
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_INSTALLATION_DIR)/Library/Bundles/SQLClient
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
|
||||
|
||||
# In some systems and situations the dynamic linker needs to haved the
|
||||
# SQLClient, gnustep-base, and objc libraries explicityly linked into
|
||||
|
@ -32,61 +61,147 @@ BUNDLE_INSTALL_DIR=$(GNUSTEP_INSTALLATION_DIR)/Library/Bundles/SQLClient
|
|||
# To handle that, we create two versions of each bundle, the seond version
|
||||
# has _libs appended to the bundle name, and has the extra libraries linked.
|
||||
|
||||
ifeq ($(LINKSQLCLIENT),)
|
||||
LINKSQLCLIENT=0
|
||||
ifeq ($(findstring darwin, $(GNUSTEP_TARGET_OS)), darwin)
|
||||
LINKSQLCLIENT=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(ECPG),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += ECPG
|
||||
ECPG_OBJC_FILES = ECPG.m
|
||||
ECPG_LIB_DIRS = -L./obj
|
||||
ECPG_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
ECPG_BUNDLE_LIBS += -lSQLClient -lecpg
|
||||
ECPG_PRINCIPAL_CLASS = SQLClientECPG
|
||||
else
|
||||
BUNDLE_NAME += ECPG
|
||||
ECPG_OBJC_FILES = ECPG.m
|
||||
ECPG_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
ECPG_BUNDLE_LIBS += -lecpg
|
||||
ECPG_PRINCIPAL_CLASS = SQLClientECPG
|
||||
BUNDLE_NAME += ECPG_libs
|
||||
ECPG_libs_OBJC_FILES = ECPG.m
|
||||
ECPG_libs_LIB_DIRS = -L./obj
|
||||
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lecpg
|
||||
ECPG_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lecpg
|
||||
ECPG_libs_PRINCIPAL_CLASS = SQLClientECPG_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testECPG
|
||||
testECPG_OBJC_FILES = testECPG.m
|
||||
testECPG_TOOL_LIBS += -lSQLClient
|
||||
testECPG_LIB_DIRS += -L./obj
|
||||
testECPG_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testECPG_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(POSTGRES),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += Postgres
|
||||
Postgres_OBJC_FILES = Postgres.m
|
||||
Postgres_LIB_DIRS = -L./obj
|
||||
Postgres_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
Postgres_BUNDLE_LIBS += -lSQLClient -lpq
|
||||
Postgres_PRINCIPAL_CLASS = SQLClientPostgres
|
||||
else
|
||||
BUNDLE_NAME += Postgres
|
||||
Postgres_OBJC_FILES = Postgres.m
|
||||
Postgres_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
Postgres_BUNDLE_LIBS += -lpq
|
||||
Postgres_PRINCIPAL_CLASS = SQLClientPostgres
|
||||
BUNDLE_NAME += Postgres_libs
|
||||
Postgres_libs_OBJC_FILES = Postgres.m
|
||||
Postgres_libs_LIB_DIRS = -L./obj
|
||||
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lpq
|
||||
Postgres_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lpq
|
||||
Postgres_libs_PRINCIPAL_CLASS = SQLClientPostgres_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testPostgres
|
||||
testPostgres_OBJC_FILES = testPostgres.m
|
||||
testPostgres_LIB_DIRS += -L./obj
|
||||
testPostgres_TOOL_LIBS += -lSQLClient
|
||||
testPostgres_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testPostgres_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(JDBC),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += JDBC
|
||||
JDBC_OBJC_FILES = JDBC.m
|
||||
JDBC_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_BUNDLE_LIBS += -lSQLClient $(JDBC_VM_LIBS)
|
||||
JDBC_PRINCIPAL_CLASS = SQLClientJDBC
|
||||
else
|
||||
BUNDLE_NAME += JDBC
|
||||
JDBC_OBJC_FILES = JDBC.m
|
||||
JDBC_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_BUNDLE_LIBS += $(JDBC_VM_LIBS)
|
||||
JDBC_PRINCIPAL_CLASS = SQLClientJDBC
|
||||
BUNDLE_NAME += JDBC_libs
|
||||
JDBC_libs_OBJC_FILES = JDBC.m
|
||||
JDBC_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) $(JDBC_VM_LIBS)
|
||||
JDBC_libs_PRINCIPAL_CLASS = SQLClientJDBC_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testJDBC
|
||||
testJDBC_OBJC_FILES = testJDBC.m
|
||||
testJDBC_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testJDBC_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(MYSQL),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += MySQL
|
||||
MySQL_OBJC_FILES = MySQL.m
|
||||
MySQL_LIB_DIRS = -L./obj
|
||||
MySQL_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
MySQL_BUNDLE_LIBS += -lSQLClient -lmysqlclient
|
||||
MySQL_PRINCIPAL_CLASS = SQLClientMySQL
|
||||
else
|
||||
BUNDLE_NAME += MySQL
|
||||
MySQL_OBJC_FILES = MySQL.m
|
||||
MySQL_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
MySQL_BUNDLE_LIBS += -lmysqlclient
|
||||
MySQL_PRINCIPAL_CLASS = SQLClientMySQL
|
||||
BUNDLE_NAME += MySQL_libs
|
||||
MySQL_libs_OBJC_FILES = MySQL.m
|
||||
MySQL_libs_LIB_DIRS = -L./obj
|
||||
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lmysqlclient
|
||||
MySQL_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lmysqlclient
|
||||
MySQL_libs_PRINCIPAL_CLASS = SQLClientMySQL_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testMySQL
|
||||
testMySQL_OBJC_FILES = testMySQL.m
|
||||
testMySQL_LIB_DIRS += -L./obj
|
||||
testMySQL_TOOL_LIBS += -lSQLClient
|
||||
testMySQL_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testMySQL_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(SQLITE),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += SQLite
|
||||
SQLite_OBJC_FILES = SQLite.m
|
||||
SQLite_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
SQLite_BUNDLE_LIBS += -lSQLClient -lsqlite3
|
||||
SQLite_PRINCIPAL_CLASS = SQLClientSQLite
|
||||
else
|
||||
BUNDLE_NAME += SQLite
|
||||
SQLite_OBJC_FILES = SQLite.m
|
||||
SQLite_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
SQLite_BUNDLE_LIBS += -lsqlite3
|
||||
SQLite_PRINCIPAL_CLASS = SQLClientSQLite
|
||||
BUNDLE_NAME += SQLite_libs
|
||||
SQLite_libs_OBJC_FILES = SQLite.m
|
||||
SQLite_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
SQLite_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lsqlite3
|
||||
SQLite_libs_PRINCIPAL_CLASS = SQLClientSQLite_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testSQLite
|
||||
testSQLite_OBJC_FILES = testSQLite.m
|
||||
testSQLite_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testSQLite_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(ORACLE_HOME),)
|
||||
BUNDLE_NAME += Oracle
|
||||
Oracle_OBJC_FILES = Oracle.m
|
||||
Oracle_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./obj \
|
||||
Oracle_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
|
||||
$(shell cat $(ORACLE_HOME)/lib/ldflags)
|
||||
Oracle_BUNDLE_LIBS += -lclntsh \
|
||||
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
|
||||
|
@ -94,10 +209,10 @@ Oracle_BUNDLE_LIBS += -lclntsh \
|
|||
Oracle_PRINCIPAL_CLASS = SQLClientOracle
|
||||
BUNDLE_NAME += Oracle_libs
|
||||
Oracle_libs_OBJC_FILES = Oracle.m
|
||||
Oracle_libs_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./obj \
|
||||
Oracle_libs_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
|
||||
$(shell cat $(ORACLE_HOME)/lib/ldflags)
|
||||
Oracle_libs_BUNDLE_LIBS += -lclntsh \
|
||||
-lSQLClient -lgnustep-base -lobjc \
|
||||
-lSQLClient -lPerformance $(FND_LIBS) $(OBJC_LIBS) \
|
||||
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
|
||||
-ldl -lm
|
||||
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
|
||||
|
@ -107,6 +222,10 @@ endif
|
|||
|
||||
include $(GNUSTEP_MAKEFILES)/library.make
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
# If JIGS is installed, automatically generate Java wrappers as well.
|
||||
# Because of the '-', should not complain if java-wrapper.make can't be
|
||||
# found ... simply skip generation of java wrappers in that case.
|
||||
-include $(GNUSTEP_MAKEFILES)/java-wrapper.make
|
||||
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||
include $(GNUSTEP_MAKEFILES)/documentation.make
|
||||
|
||||
|
|
|
@ -13,9 +13,7 @@ ifneq ($(ECPG),)
|
|||
%.m: %.pgm
|
||||
ecpg -o $@ $< $(ADDITIONAL_INCLUDE_DIRS)
|
||||
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -25,9 +23,7 @@ ifneq ($(ORACLE_HOME),)
|
|||
%.m: %.pm
|
||||
proc iname=$< oname=$@ mode=ansi parse=none
|
||||
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -70,6 +66,10 @@ after-distclean::
|
|||
# Things to do after checking
|
||||
# after-check::
|
||||
|
||||
config.make: config.make.in
|
||||
./configure
|
||||
config.make: config.status
|
||||
if [ -x config.status ]; then \
|
||||
./config.status --recheck; \
|
||||
else \
|
||||
./configure; \
|
||||
fi
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
# ADDITIONAL_CPPFLAGS +=
|
||||
ADDITIONAL_CPPFLAGS += -DSOVERSION=\"$(SQLClient_INTERFACE_VERSION)\"
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
# ADDITIONAL_OBJCFLAGS +=
|
||||
|
|
2
GNUmakefile.wrapper.objc.preamble
Normal file
2
GNUmakefile.wrapper.objc.preamble
Normal file
|
@ -0,0 +1,2 @@
|
|||
LIBRARIES_DEPEND_UPON += -lPerformance.A
|
||||
ADDITIONAL_LIB_DIRS = -L../../$(GNUSTEP_OBJ_DIR)
|
268
MySQL.m
268
MySQL.m
|
@ -9,36 +9,40 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSCalendarDate.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
|
@ -58,12 +62,12 @@ static NSNull *null = nil;
|
|||
{
|
||||
if (future == nil)
|
||||
{
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
RETAIN(future);
|
||||
[future retain];
|
||||
null = [NSNull null];
|
||||
RETAIN(null);
|
||||
[null retain];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,9 +101,11 @@ static NSNull *null = nil;
|
|||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Connect to '%@' as %@", [self database], [self name]];
|
||||
[self debug: @"Connect to '%@' as %@",
|
||||
[self database], [self name]];
|
||||
}
|
||||
extra = mysql_init(0);
|
||||
mysql_options(connection, MYSQL_SET_CHARSET_NAME, "utf8");
|
||||
if (mysql_real_connect(connection,
|
||||
[host UTF8String],
|
||||
[[self user] UTF8String],
|
||||
|
@ -107,23 +113,13 @@ static NSNull *null = nil;
|
|||
[dbase UTF8String],
|
||||
[port intValue],
|
||||
NULL,
|
||||
0
|
||||
) == 0)
|
||||
CLIENT_MULTI_STATEMENTS) == 0)
|
||||
{
|
||||
[self debug: @"Error connecting to '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#if 0
|
||||
else if (mysql_query(connection, "SET CHARACTER SET utf8") != 0)
|
||||
{
|
||||
[self debug: @"Error setting utf8 support for '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
connected = YES;
|
||||
|
@ -168,6 +164,7 @@ static NSNull *null = nil;
|
|||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
extra = 0;
|
||||
[self debug: @"Error disconnecting from database (%@): %@",
|
||||
[self clientName], localException];
|
||||
}
|
||||
|
@ -176,28 +173,30 @@ static NSNull *null = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *stmt;
|
||||
NSInteger rowCount = 0;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
const char *statement;
|
||||
unsigned length;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -209,14 +208,38 @@ static NSNull *null = nil;
|
|||
statement = [self insertBLOBs: info
|
||||
intoStatement: statement
|
||||
length: length
|
||||
withMarker: "'''"
|
||||
length: 3
|
||||
withMarker: "'?'''?'"
|
||||
length: 7
|
||||
giving: &length];
|
||||
|
||||
if (mysql_real_query(connection, statement, length) != 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
}
|
||||
/* See how many rows were modified.
|
||||
*/
|
||||
rowCount = mysql_affected_rows(connection);
|
||||
/* discard any results.
|
||||
*/
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
while (mysql_more_results(connection))
|
||||
{
|
||||
if (mysql_next_result(connection) == 0)
|
||||
{
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -225,20 +248,21 @@ static NSNull *null = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
[arp release];
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -266,14 +290,16 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableArray *records = nil;
|
||||
MYSQL_RES *result = 0;
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
RELEASE (arp);
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -285,7 +311,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -304,10 +330,10 @@ static unsigned int trim(char *str)
|
|||
|
||||
for (i = 0; i < fieldCount; i++)
|
||||
{
|
||||
keys[i] = [NSString stringWithUTF8String: fields[i].name];
|
||||
keys[i] = [NSString stringWithUTF8String: (char*)fields[i].name];
|
||||
}
|
||||
|
||||
records = [[NSMutableArray alloc] initWithCapacity: recordCount];
|
||||
records = [[ltype alloc] initWithCapacity: recordCount];
|
||||
for (i = 0; i < recordCount; i++)
|
||||
{
|
||||
SQLRecord *record;
|
||||
|
@ -319,7 +345,7 @@ static unsigned int trim(char *str)
|
|||
for (j = 0; j < fieldCount; j++)
|
||||
{
|
||||
id v = null;
|
||||
unsigned char *p = row[j];
|
||||
unsigned char *p = (unsigned char*)row[j];
|
||||
|
||||
if (p != 0)
|
||||
{
|
||||
|
@ -335,60 +361,55 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
case FIELD_TYPE_TIMESTAMP:
|
||||
{
|
||||
char b[32];
|
||||
NSString *f;
|
||||
NSString *s;
|
||||
|
||||
s = [[NSString alloc] initWithBytes: p
|
||||
length: size encoding: NSASCIIStringEncoding];
|
||||
if (size > 14)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
size = 19;
|
||||
f = @"%Y-%m-%d %H:%M:%S %z";
|
||||
}
|
||||
else if (size == 14)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
f = @"%Y%m%d%H%M%S %z";
|
||||
}
|
||||
else if (size == 12)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
f = @"%y%m%d%H%M%S %z";
|
||||
}
|
||||
else if (size == 10)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M"
|
||||
locale: nil];
|
||||
f = @"%y%m%d%H%M %z";
|
||||
}
|
||||
else if (size == 8)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H"
|
||||
locale: nil];
|
||||
f = @"%y%m%d%H %z";
|
||||
}
|
||||
else if (size == 6)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d"
|
||||
locale: nil];
|
||||
f = @"%y%m%d %z";
|
||||
}
|
||||
else if (size == 4)
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m"
|
||||
locale: nil];
|
||||
f = @"%y%m %z";
|
||||
}
|
||||
else
|
||||
{
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y"
|
||||
locale: nil];
|
||||
f = @"%y %z";
|
||||
}
|
||||
RELEASE(s);
|
||||
strncpy(b, (char*)p, size);
|
||||
strncpy(b + size, (char*)" +0000", 6);
|
||||
s = [[NSString alloc] initWithBytes: b
|
||||
length: size + 6
|
||||
encoding: NSASCIIStringEncoding];
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: f
|
||||
locale: nil];
|
||||
[v setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
if ([self debugging] > 1)
|
||||
[self debug: @"Parsed '%@' as '%@'\n", s, v];
|
||||
[s release];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -400,28 +421,49 @@ static unsigned int trim(char *str)
|
|||
case FIELD_TYPE_TINY_BLOB:
|
||||
case FIELD_TYPE_MEDIUM_BLOB:
|
||||
case FIELD_TYPE_LONG_BLOB:
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
if (63 == fields[j].charsetnr)
|
||||
{
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
}
|
||||
else
|
||||
{
|
||||
v = [[[NSString alloc] initWithBytes: p
|
||||
length: size
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
trim(p);
|
||||
v = [NSString stringWithUTF8String: p];
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim((char*)p);
|
||||
}
|
||||
v = [NSString stringWithUTF8String: (char*)p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
values[j] = v;
|
||||
}
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: fieldCount];
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: fieldCount];
|
||||
[records addObject: record];
|
||||
RELEASE(record);
|
||||
[record release];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -430,7 +472,7 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
|
@ -441,19 +483,20 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
DESTROY(records);
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[records release];
|
||||
records = nil;
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
[arp release];
|
||||
if (result != 0)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
return AUTORELEASE(records);
|
||||
return [records autorelease];
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -506,5 +549,38 @@ static unsigned int trim(char *str)
|
|||
return length;
|
||||
}
|
||||
|
||||
- (NSString*) quote: (id)obj
|
||||
{
|
||||
/* MySQL doesn't support timezones ... convert dates to simple GMT.
|
||||
*/
|
||||
if ([obj isKindOfClass: [NSDate class]] == YES)
|
||||
{
|
||||
NSString *fmt = nil;
|
||||
static NSTimeZone *gmt = nil;
|
||||
|
||||
if (nil == gmt)
|
||||
{
|
||||
gmt = [[NSTimeZone timeZoneForSecondsFromGMT: 0] retain];
|
||||
}
|
||||
if ([obj isKindOfClass: [NSCalendarDate class]] == YES)
|
||||
{
|
||||
fmt = [obj calendarFormat];
|
||||
if ([fmt length] > 17)
|
||||
{
|
||||
fmt = nil; // bad format ... had timezone
|
||||
}
|
||||
}
|
||||
if (nil == fmt)
|
||||
{
|
||||
fmt = @"%Y-%m-%d %H:%M:%S";
|
||||
}
|
||||
fmt = [NSString stringWithFormat: @"'%@'", fmt];
|
||||
return [obj descriptionWithCalendarFormat: fmt
|
||||
timeZone: gmt
|
||||
locale: nil];
|
||||
}
|
||||
return [super quote: obj];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
275
Oracle.pm
275
Oracle.pm
|
@ -10,16 +10,16 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
|
@ -216,7 +216,7 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
}
|
||||
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
|
@ -240,7 +240,7 @@ void SQLClientOracleErrorHandler()
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -273,7 +273,7 @@ void SQLClientOracleErrorHandler()
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -300,6 +300,7 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -326,7 +327,7 @@ static unsigned int trim(char *str)
|
|||
return (str - start);
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt recordClass: (Class)rClass
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int count;
|
||||
|
@ -368,7 +369,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self backendConnect] == NO)
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -553,7 +554,10 @@ static unsigned int trim(char *str)
|
|||
|
||||
/* \0-pad the string. */
|
||||
aString[octetLength] = '\0';
|
||||
trim (aString);
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -584,7 +588,10 @@ static unsigned int trim(char *str)
|
|||
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
|
||||
:aString = DATA;
|
||||
aString[octetLength] = '\0';
|
||||
trim (aString);
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free (aString);
|
||||
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",
|
||||
|
@ -597,9 +604,9 @@ static unsigned int trim(char *str)
|
|||
keys[index - 1] = [NSString stringWithUTF8String:
|
||||
fieldName];
|
||||
}
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
record = [rClass newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
[records addObject: record];
|
||||
RELEASE(record);
|
||||
}
|
||||
|
@ -644,7 +651,7 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
@ -667,7 +674,7 @@ static unsigned int trim(char *str)
|
|||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
_inTransaction = NO;
|
||||
[self backendDisconnect];
|
||||
[self disconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -892,14 +899,15 @@ static unsigned int trim(char *str)
|
|||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from a database character buffer to an NSDate.
|
||||
*/
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -922,98 +930,153 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
3
Performance.import
Normal file
3
Performance.import
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
import gnu.gnustep.Performance.*;
|
||||
|
1835
Postgres.m
1835
Postgres.m
File diff suppressed because it is too large
Load diff
49
README
49
README
|
@ -49,6 +49,13 @@ Current backend bundles are -
|
|||
I don't use MySQL... but the test program ran successfully with a
|
||||
vanilla install of the MySQL packages for recent Debian unstable.
|
||||
|
||||
* SQLite - a bundle using the sqlite3 library which supports an
|
||||
SQL-like API for direct access to a database file (rather than
|
||||
acting as a client of a database server process).
|
||||
Not as functional as the other backends (doesn't support dates
|
||||
for instance), but good enough for many purposes and very
|
||||
'lightweight'. See http://www.sqlite.org
|
||||
|
||||
* Oracle - a bundle using embedded SQL for Oracle.
|
||||
Completely untested... may even need some work to compile...
|
||||
but this *is* based on code which was working about a year ago.
|
||||
|
@ -56,16 +63,16 @@ Current backend bundles are -
|
|||
|
||||
Where can you get it? How can you install it?
|
||||
|
||||
The SQLClient library is currently only available via CVS from the GNUstep CVS repository.
|
||||
See <https://savannah.gnu.org/cvs/?group=gnustep>
|
||||
You need to check out gnustep/dev-libs/SQLClient
|
||||
The SQLClient library is currently available at
|
||||
<ftp://ftp.gnustep.org/pub/gnustep/libs>
|
||||
or via CVS from the GNUstep CVS repository (See <https://savannah.gnu.org/cvs/?group=gnustep>. Check out gnustep/dev-libs/SQLClient).
|
||||
|
||||
To build this library you must have a basic GNUstep environment set up...
|
||||
|
||||
* The gnustep-make package must have been built and installed.
|
||||
* The gnustep-base package must have been built and installed.
|
||||
* You must hace sourced the GNUstep.sh script (from gnustep-make)
|
||||
to set up environment variables needed for building this.
|
||||
* The Performance library (from the dev-libs area in GNUstep CVS)
|
||||
must have been built and installed.
|
||||
* If this environment is in place, all you should need to do is
|
||||
run 'make' to configure and build the library, 'make install'
|
||||
to install it.
|
||||
|
@ -80,35 +87,3 @@ should be entered on the GNUstep project page
|
|||
<http://savannah.gnu.org/support/?group-gnustep>
|
||||
|
||||
|
||||
|
||||
The WebServer class provides the framework for a GNUstep program to act as
|
||||
an HTTP or HTTPS server for simple applications.
|
||||
It does not attempt to be a general-purpose web server, but is rather
|
||||
intended to permit a program to easily handle requests from automated
|
||||
systems which are intended to control, monitor, or use the services
|
||||
provided by the program in which the class is embedded.
|
||||
The emphasis is on making it robust/reliable/simple, so you can rapidly
|
||||
develop software using it. It is a single-threaded, single-process
|
||||
system using asynchronous I/O, so you can easily run it under debug
|
||||
in gdb to fix any bugs in your delegate object.
|
||||
In particular of course, it may be used in conjunction with the
|
||||
SQLClient class to implement web-based database applications.
|
||||
|
||||
The class is controlled by a few straightforward settings and basically
|
||||
operates by handing over requests to its delegate. The delegate must at
|
||||
least implement the -processRequest:response:for: method.
|
||||
|
||||
Built-in facilities include -
|
||||
|
||||
* Parsing of parameter string in request URL
|
||||
* Parsing of url encoded form data in a POST request
|
||||
* Parsing of form encoded data in a POST request
|
||||
* Substitution into template pages on output
|
||||
* SSL support
|
||||
* Limit access by IP address
|
||||
* Limit total number of simultaneous connections
|
||||
* Limit number of simultaneous connectionsform one address
|
||||
* Limit idle time permitted on a connection
|
||||
* Limit size of request headers permitted
|
||||
* Limit size of request body permitted
|
||||
|
||||
|
|
1678
SQLClient.h
1678
SQLClient.h
File diff suppressed because it is too large
Load diff
81
SQLClient.jigs
Normal file
81
SQLClient.jigs
Normal file
|
@ -0,0 +1,81 @@
|
|||
{ /* -*-c-*- */
|
||||
"prerequisite libraries" = (
|
||||
"gnustep-base",
|
||||
"Performance"
|
||||
);
|
||||
types = {
|
||||
NSTimeInterval = double;
|
||||
};
|
||||
classes = (
|
||||
{
|
||||
"file to include in preamble java code" = "Performance.import";
|
||||
"java name" = "gnu.gnustep.SQLClient.SQLClient";
|
||||
"objective-c name" = "SQLClient";
|
||||
"class methods" = (
|
||||
"allClients",
|
||||
"clientWithConfiguration:name:",
|
||||
"existingClient:",
|
||||
"maxConnections",
|
||||
"purgeConnections:",
|
||||
"setMaxConnections:",
|
||||
);
|
||||
"instance methods" = (
|
||||
"begin",
|
||||
"cache",
|
||||
"cache:query:with:",
|
||||
"cache:simpleQuery:",
|
||||
"clientName",
|
||||
"commit",
|
||||
"connect",
|
||||
"connected",
|
||||
"database",
|
||||
"debugging",
|
||||
"disconnect",
|
||||
"durationLogging",
|
||||
"isInTransaction",
|
||||
"lastOperation",
|
||||
"name",
|
||||
"password",
|
||||
"query:with:",
|
||||
"quote:",
|
||||
"quoteChar:",
|
||||
"quoteFloat:",
|
||||
"quoteInteger:",
|
||||
"rollback",
|
||||
"setCache:",
|
||||
"setDatabase:",
|
||||
"setDebugging:",
|
||||
"setDurationLogging:",
|
||||
"setName:",
|
||||
"setPassword:",
|
||||
"setUser:",
|
||||
"simpleExecute:",
|
||||
"simpleQuery:",
|
||||
"singletons:",
|
||||
"transaction",
|
||||
"user"
|
||||
);
|
||||
},
|
||||
{
|
||||
"java name" = "gnu.gnustep.SQLClient.SQLRecord";
|
||||
"objective-c name" = "SQLRecord";
|
||||
"instance methods" = (
|
||||
"allKeys",
|
||||
"dictionary",
|
||||
"sizeInBytes:"
|
||||
);
|
||||
},
|
||||
{
|
||||
"java name" = "gnu.gnustep.SQLClient.SQLTransaction";
|
||||
"objective-c name" = "SQLTransaction";
|
||||
"instance methods" = (
|
||||
"add:with:",
|
||||
"append:",
|
||||
"count",
|
||||
"owner",
|
||||
"execute",
|
||||
"reset"
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
5869
SQLClient.m
5869
SQLClient.m
File diff suppressed because it is too large
Load diff
1526
SQLClientPool.m
Normal file
1526
SQLClientPool.m
Normal file
File diff suppressed because it is too large
Load diff
370
SQLite.m
Normal file
370
SQLite.m
Normal file
|
@ -0,0 +1,370 @@
|
|||
/* -*-objc-*- */
|
||||
|
||||
/** Implementation of SQLClientSQLite for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: Nov 2005
|
||||
|
||||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
@interface SQLClientSQLite : SQLClient
|
||||
@end
|
||||
|
||||
@implementation SQLClientSQLite
|
||||
|
||||
/* use [self database] as path to database file */
|
||||
- (BOOL) backendConnect
|
||||
{
|
||||
if (connected == NO)
|
||||
{
|
||||
if ([self database] != nil)
|
||||
{
|
||||
NSString *dbase = [self database];
|
||||
sqlite3 *sql;
|
||||
int result;
|
||||
|
||||
[[self class] purgeConnections: nil];
|
||||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Connect to '%@' as %@",
|
||||
[self database], [self name]];
|
||||
}
|
||||
result = sqlite3_open([dbase fileSystemRepresentation], &sql);
|
||||
if (result != 0)
|
||||
{
|
||||
[self debug: @"Error connecting to '%@' (%@) - %s",
|
||||
[self name], [self database], sqlite3_errmsg(sql)];
|
||||
sqlite3_close(sql);
|
||||
extra = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
connected = YES;
|
||||
extra = sql;
|
||||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Connected to '%@'", [self name]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self debug: @"Connect to '%@' with no database configured",
|
||||
[self name]];
|
||||
}
|
||||
}
|
||||
return connected;
|
||||
}
|
||||
|
||||
- (void) backendDisconnect
|
||||
{
|
||||
if (connected == YES)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
if ([self isInTransaction] == YES)
|
||||
{
|
||||
[self rollback];
|
||||
}
|
||||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Disconnecting client %@", [self clientName]];
|
||||
}
|
||||
sqlite3_close((sqlite3 *)extra);
|
||||
extra = 0;
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Disconnected client %@", [self clientName]];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
extra = 0;
|
||||
[self debug: @"Error disconnecting from database (%@): %@",
|
||||
[self clientName], localException];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
connected = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
const char *statement;
|
||||
unsigned length;
|
||||
int result;
|
||||
char *err;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
[self name], stmt];
|
||||
}
|
||||
|
||||
statement = (char*)[stmt UTF8String];
|
||||
length = strlen(statement);
|
||||
statement = [self insertBLOBs: info
|
||||
intoStatement: statement
|
||||
length: length
|
||||
withMarker: "'?'''?'"
|
||||
length: 7
|
||||
giving: &length];
|
||||
|
||||
result = sqlite3_exec((sqlite3 *)extra, statement, 0, 0, &err);
|
||||
if (result != SQLITE_OK)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%s", err];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSString *n = [localException name];
|
||||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableArray *records = [[ltype alloc] initWithCapacity: 2];
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
char *statement;
|
||||
int result;
|
||||
sqlite3_stmt *prepared;
|
||||
const char *stmtEnd;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
[self name], stmt];
|
||||
}
|
||||
|
||||
statement = (char*)[stmt UTF8String];
|
||||
result = sqlite3_prepare((sqlite3 *)extra,
|
||||
statement, strlen(statement), &prepared, &stmtEnd);
|
||||
if (result != SQLITE_OK)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to prepare '%@'", stmt];
|
||||
}
|
||||
if ((result = sqlite3_step(prepared)) == SQLITE_ROW)
|
||||
{
|
||||
int columns = sqlite3_column_count(prepared);
|
||||
NSString *keys[columns];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < columns; i++)
|
||||
{
|
||||
keys[i] = [NSString stringWithUTF8String:
|
||||
sqlite3_column_name(prepared, i)];
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
id values[columns];
|
||||
SQLRecord *record;
|
||||
|
||||
for (i = 0; i < columns; i++)
|
||||
{
|
||||
int type = sqlite3_column_type(prepared, i);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SQLITE_INTEGER:
|
||||
values[i] = [NSNumber numberWithInt:
|
||||
sqlite3_column_int(prepared, i)];
|
||||
break;
|
||||
|
||||
case SQLITE_FLOAT:
|
||||
values[i] = [NSNumber numberWithDouble:
|
||||
sqlite3_column_double(prepared, i)];
|
||||
break;
|
||||
|
||||
case SQLITE_TEXT:
|
||||
values[i] = [NSString stringWithUTF8String:
|
||||
(char *)sqlite3_column_text(prepared, i)];
|
||||
break;
|
||||
|
||||
case SQLITE_BLOB:
|
||||
values[i] = [NSData dataWithBytes:
|
||||
sqlite3_column_blob(prepared, i)
|
||||
length: sqlite3_column_bytes(prepared, i)];
|
||||
break;
|
||||
|
||||
case SQLITE_NULL:
|
||||
values[i] = nil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: columns];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
}
|
||||
while ((result = sqlite3_step(prepared)) == SQLITE_ROW);
|
||||
}
|
||||
if (result != SQLITE_DONE)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"%s", sqlite3_errmsg((sqlite3 *)extra)];
|
||||
}
|
||||
sqlite3_finalize(prepared);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSString *n = [localException name];
|
||||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return [records autorelease];
|
||||
}
|
||||
|
||||
static char hex[16] = "0123456789ABCDEF";
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
{
|
||||
const unsigned char *bytes = [blob bytes];
|
||||
unsigned char *ptr = buf;
|
||||
unsigned length = [blob length];
|
||||
unsigned i;
|
||||
|
||||
*ptr++ = 'X';
|
||||
*ptr++ = '\'';
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
unsigned char c = bytes[i];
|
||||
|
||||
*ptr++ = hex[c / 16];
|
||||
*ptr++ = hex[c % 16];;
|
||||
}
|
||||
*ptr++ = '\'';
|
||||
return ((void*)ptr - buf);
|
||||
}
|
||||
|
||||
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob
|
||||
{
|
||||
/*
|
||||
* A blob is X'xx' where xx is hexadecimal encoded binary data ...
|
||||
* two hex digits per byte.
|
||||
*/
|
||||
return 3 + [blob length] * 2;
|
||||
}
|
||||
|
||||
- (NSString*) quote: (id)obj
|
||||
{
|
||||
if ([obj isKindOfClass: [NSDate class]] == YES)
|
||||
{
|
||||
obj = [NSNumber numberWithDouble: [obj timeIntervalSinceReferenceDate]];
|
||||
}
|
||||
return [super quote: obj];
|
||||
}
|
||||
|
||||
@end
|
||||
|
530
WebServer.h
530
WebServer.h
|
@ -1,530 +0,0 @@
|
|||
/**
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: June 2004
|
||||
|
||||
This file is part of the SQLClient 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; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
<title>WebServer documentation</title>
|
||||
<chapter>
|
||||
<heading>The WebServer class</heading>
|
||||
<section>
|
||||
<heading>What is the WebServer class?</heading>
|
||||
<p>
|
||||
The WebServer class provides the framework for a GNUstep program to
|
||||
act as an HTTP or HTTPS server for simple applications.<br />
|
||||
It does not attempt to be a general-purpose web server, but is rather
|
||||
intended to permit a program to easily handle requests from automated
|
||||
systems which are intended to control, monitor, or use the services
|
||||
provided by the program in which the class is embedded.<br />
|
||||
The emphasis is on making it robust/reliable/simple, so you can rapidly
|
||||
develop software using it. It is a single-threaded, single-process
|
||||
system using asynchronous I/O, so you can easily run it under
|
||||
debug in gdb to fix any bugs in your delegate object.<br />
|
||||
In particular of course, it may be used in conjunction with the
|
||||
[SQLClient] class to implement web-based database applications.
|
||||
</p>
|
||||
<p>
|
||||
The class is controlled by a few straightforward settings and
|
||||
basically operates by handing over requests to its delegate.
|
||||
The delegate must at least implement the
|
||||
[(WebServerDelegate)-processRequest:response:for:] method.
|
||||
</p>
|
||||
<p>
|
||||
Built-in facilities include -
|
||||
</p>
|
||||
<list>
|
||||
<item>Parsing of parameter string in request URL</item>
|
||||
<item>Parsing of url encoded form data in a POST request</item>
|
||||
<item>Parsing of form encoded data in a POST request</item>
|
||||
<item>Substitution into template pages on output</item>
|
||||
<item>SSL support</item>
|
||||
<item>Limit access by IP address</item>
|
||||
<item>Limit total number of simultaneous connections</item>
|
||||
<item>Limit number of simultaneous connectionsform one address</item>
|
||||
<item>Limit idle time permitted on a connection</item>
|
||||
<item>Limit size of request headers permitted</item>
|
||||
<item>Limit size of request body permitted</item>
|
||||
</list>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_WEBSERVER_H
|
||||
#define INCLUDED_WEBSERVER_H
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <GNUstepBase/GSMime.h>
|
||||
|
||||
@class WebServer;
|
||||
|
||||
/**
|
||||
* This protocol is implemented by a delegate of a WebServer instance
|
||||
* in order to allow the delegate to process requests which arrive
|
||||
* at the server.
|
||||
*/
|
||||
@protocol WebServerDelegate
|
||||
/**
|
||||
* Process the http request whose headers and data are provided in
|
||||
* a GSMimeDocument.<br />
|
||||
* Extra headers are created as follows -
|
||||
* <deflist>
|
||||
* <term>x-http-method</term>
|
||||
* <desc>The method from the HTTP request (eg. GET or POST)</desc>
|
||||
* <term>x-http-path</term>
|
||||
* <desc>The path from the HTTP request, or an empty string if
|
||||
* there was no path.</desc>
|
||||
* <term>x-http-query</term>
|
||||
* <desc>The query string from the HTTP request or an empty string
|
||||
* if there was no query.</desc>
|
||||
* <term>x-http-version</term>
|
||||
* <desc>The version from the HTTP request.</desc>
|
||||
* <term>x-local-address</term>
|
||||
* <desc>The IP address of the local host receiving the request.</desc>
|
||||
* <term>x-local-port</term>
|
||||
* <desc>The port of the local host receiving the request.</desc>
|
||||
* <term>x-remote-address</term>
|
||||
* <desc>The IP address of the host that the request came from.</desc>
|
||||
* <term>x-remote-port</term>
|
||||
* <desc>The port of the host that the request came from.</desc>
|
||||
* <term>x-http-username</term>
|
||||
* <desc>The username from the 'authorization' header if the request
|
||||
* supplied http basic authentication.</desc>
|
||||
* <term>x-http-password</term>
|
||||
* <desc>The password from the 'authorization' header if the request
|
||||
* supplied http basic authentication.</desc>
|
||||
* </deflist>
|
||||
* On completion, the method must modify response to contain the data
|
||||
* and headers to be sent out.<br />
|
||||
* The 'content-length' header need not be set in the response as it will
|
||||
* be overridden anyway.<br />
|
||||
* The special 'http' header will be used as the response/status line.
|
||||
* If not supplied, 'HTTP/1.1 200 Success' or 'HTTP/1.1 204 No Content' will
|
||||
* be used as the response line, depending on whether the data is empty or
|
||||
* not.<br />
|
||||
* If an exception is raised by this method, the response produced will
|
||||
* be set to 'HTTP/1.0 500 Internal Server Error' and the connection will
|
||||
* be closed.
|
||||
*/
|
||||
- (BOOL) processRequest: (GSMimeDocument*)request
|
||||
response: (GSMimeDocument*)response
|
||||
for: (WebServer*)http;
|
||||
/**
|
||||
* Log an error or warning ... if the delegate does not implement this
|
||||
* method, the message is logged to stderr using the NSLog function.
|
||||
*/
|
||||
- (void) webAlert: (NSString*)message for: (WebServer*)http;
|
||||
@end
|
||||
|
||||
/**
|
||||
* <p>You create an instance of the WebServer class in order to handle
|
||||
* incoming http or https requests on a single port.
|
||||
* </p>
|
||||
* <p>Before use, it must be configured using the -setPort:secure: method
|
||||
* to specify the port and if/how ssl is to be used.
|
||||
* </p>
|
||||
* <p>You must also set a delegate to handle incoming requests,
|
||||
* and may specify a maximum number of simultaneous connections
|
||||
* which may be in progress etc.
|
||||
* </p>
|
||||
* <p>In addition to the options which may be set directly in the class,
|
||||
* you can provide some configuration via the standard NSDefaults class.
|
||||
* This information is set at initialisation of an instance and the
|
||||
* class recognises the following defaults keys -
|
||||
* </p>
|
||||
* <deflist>
|
||||
* <term>WebServerHosts</term>
|
||||
* <desc>An array of host IP addresses to list the mhosts permitted to
|
||||
* send requests to the server. If defined, requests from other hosts
|
||||
* will be rejected. It's better to use firewalling to control this
|
||||
* sort of thing.
|
||||
* </desc>
|
||||
* <term>WebServerQuiet</term>
|
||||
* <desc>An array of host IP addresses to refrain from logging ...
|
||||
* this is useful if (for instance) you have a monitoring process which
|
||||
* sends requests to the server to be sure it's alive, and don't want
|
||||
* to log all the connections from this monitor.<br />
|
||||
* Not only do we refrain from logging anything but exceptional events
|
||||
* about these hosts, connections and requests by these hosts are not
|
||||
* counted in statistics we generate.
|
||||
* </desc>
|
||||
* </deflist>
|
||||
*/
|
||||
@interface WebServer : NSObject
|
||||
{
|
||||
@private
|
||||
NSNotificationCenter *_nc;
|
||||
NSString *_port;
|
||||
BOOL _accepting;
|
||||
BOOL _verbose;
|
||||
NSDictionary *_sslConfig;
|
||||
NSArray *_quiet;
|
||||
NSArray *_hosts;
|
||||
unsigned int _substitutionLimit;
|
||||
unsigned int _maxBodySize;
|
||||
unsigned int _maxRequestSize;
|
||||
unsigned int _maxSessions;
|
||||
unsigned int _maxPerHost;
|
||||
id _delegate;
|
||||
NSFileHandle *_listener;
|
||||
NSMapTable *_sessions;
|
||||
unsigned _handled;
|
||||
unsigned _requests;
|
||||
NSString *_root;
|
||||
NSTimer *_ticker;
|
||||
NSTimeInterval _sessionTimeout;
|
||||
NSTimeInterval _ticked;
|
||||
NSCountedSet *_perHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode an application/x-www-form-urlencoded form and store its
|
||||
* contents into the supplied dictionary.<br />
|
||||
* The resulting dictionary keys are strings.<br />
|
||||
* The resulting dictionary values are arrays of NSData objects.<br />
|
||||
* You probably don't need to call this method yourself ... more likely
|
||||
* you will use the -parameters: method instead.<br />
|
||||
* NB. For forms POSTed using <code>multipart/form-data</code> you don't
|
||||
* need to perform any explicit decoding as this will already have been
|
||||
* done for you and the decoded form will be presented as the request
|
||||
* GSMimeDocument. The fields of the form will be the component parts
|
||||
* of the content of the request and can be accessed using the standard
|
||||
* GSMimeDocument methods.<br />
|
||||
* This method returns the number of fields actually decoded.
|
||||
*/
|
||||
- (unsigned) decodeURLEncodedForm: (NSData*)data
|
||||
into: (NSMutableDictionary*)dict;
|
||||
|
||||
/**
|
||||
* Returns YES if the server is for HTTPS (encrypted connections),
|
||||
* NO otherwise.
|
||||
*/
|
||||
- (BOOL) isSecure;
|
||||
|
||||
/**
|
||||
* Extracts request parameters from the http query string and from the
|
||||
* request body (if it was application/x-www-form-urlencoded or
|
||||
* multipart/form-data) and return the extracted parameters as a
|
||||
* mutable dictionary whose keys are the parameter names and whose
|
||||
* values are arrays containing the data for each parameter.<br />
|
||||
* You should call this no more than once per request, storing the result
|
||||
* and using it as an argument to the methods used to extract particular
|
||||
* parameters.<br />
|
||||
* Parameters from the request data are <em>added</em> to any found in the
|
||||
* query string.<br />
|
||||
* Values provided as <code>multipart/form-data</code> are also available
|
||||
* in a more flexible format as the content of the request.
|
||||
*/
|
||||
- (NSMutableDictionary*) parameters: (GSMimeDocument*)request;
|
||||
|
||||
/**
|
||||
* Returns the index'th data parameter for the specified name.<br />
|
||||
* Matching of names is case-insensitive<br />
|
||||
* If there are no data items for the name, or if the index is
|
||||
* too large for the number of items which exist, this returns nil.
|
||||
*/
|
||||
- (NSData*) parameter: (NSString*)name
|
||||
at: (unsigned)index
|
||||
from: (NSDictionary*)params;
|
||||
|
||||
/**
|
||||
* Calls -parameter:at:from: with an index of zero.
|
||||
*/
|
||||
- (NSData*) parameter: (NSString*)name from: (NSDictionary*)params;
|
||||
|
||||
/**
|
||||
* Calls -parameterString:at:from:charset: with a nil charset so that
|
||||
* UTF-8 encoding is used for string conversion.
|
||||
*/
|
||||
- (NSString*) parameterString: (NSString*)name
|
||||
at: (unsigned)index
|
||||
from: (NSDictionary*)params;
|
||||
/**
|
||||
* Calls -parameter:at:from: and, if the result is non-nil
|
||||
* converts the data to a string using the specified mime
|
||||
* characterset, (if charset is nil, UTF-8 is used).
|
||||
*/
|
||||
- (NSString*) parameterString: (NSString*)name
|
||||
at: (unsigned)index
|
||||
from: (NSDictionary*)params
|
||||
charset: (NSString*)charset;
|
||||
/**
|
||||
* Calls -parameterString:at:from:charset: with an index of zero and
|
||||
* a nil value for charset (which causes data to be treated as UTF-8).
|
||||
*/
|
||||
- (NSString*) parameterString: (NSString*)name
|
||||
from: (NSDictionary*)params;
|
||||
|
||||
/**
|
||||
* Calls -parameterString:at:from:charset: with an index of zero.
|
||||
*/
|
||||
- (NSString*) parameterString: (NSString*)name
|
||||
from: (NSDictionary*)params
|
||||
charset: (NSString*)charset;
|
||||
|
||||
/**
|
||||
* Loads a template file from disk and places it in aResponse as content
|
||||
* whose mime type is determined from the file extension using the
|
||||
* provided mapping (or a simple built-in default mapping if map is nil).<br />
|
||||
* If you have a dedicated web server for handling static pages (eg images)
|
||||
* it is better to use that rather than vending static pages using this
|
||||
* method. It's unlikley that this method can be as efficient as a dedicated
|
||||
* server. However this mechanism is adequate for moderate throughputs.
|
||||
*/
|
||||
- (BOOL) produceResponse: (GSMimeDocument*)aResponse
|
||||
fromStaticPage: (NSString*)aPath
|
||||
using: (NSDictionary*)map;
|
||||
|
||||
/**
|
||||
* Loads a template file from disk and places it in aResponse as content
|
||||
* of type 'text/html' with a charset of 'utf-8'.<br />
|
||||
* The argument aPath is a path relative to the root path set using
|
||||
* the -setRoot: method.<br />
|
||||
* Substitutes values into the template from map using the
|
||||
* -substituteFrom:using:into:depth: method.<br />
|
||||
* Returns NO if them template could not be read or if any substitution
|
||||
* failed. In this case no value is set in the response.<br />
|
||||
* If the response is actually text of another type, or you want another
|
||||
* characterset used, you can change the content type header in the
|
||||
* request after you call this method.
|
||||
*/
|
||||
- (BOOL) produceResponse: (GSMimeDocument*)aResponse
|
||||
fromTemplate: (NSString*)aPath
|
||||
using: (NSDictionary*)map;
|
||||
|
||||
/**
|
||||
* Sets the delegate object which processes requests for the receiver.
|
||||
*/
|
||||
- (void) setDelegate: (id)anObject;
|
||||
|
||||
/**
|
||||
* Sets the maximum size of an uploaded request body.<br />
|
||||
* The default is 4M bytes.<br />
|
||||
*/
|
||||
- (void) setMaxBodySize: (unsigned)max;
|
||||
|
||||
/**
|
||||
* Sets the maximum size of an incoming request (including all headers,
|
||||
* but not the body).<br />
|
||||
* The default is 8K bytes.<br />
|
||||
*/
|
||||
- (void) setMaxRequestSize: (unsigned)max;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of simultaneous sessions with clients.<br />
|
||||
* The default is 32.<br />
|
||||
* A value of zero permits unlimited connections.
|
||||
*/
|
||||
- (void) setMaxSessions: (unsigned)max;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of simultaneous sessions with a particular
|
||||
* remote host.<br />
|
||||
* The default is 8.<br />
|
||||
* A value of zero permits unlimited connections.
|
||||
*/
|
||||
- (void) setMaxSessionsPerHost: (unsigned)max;
|
||||
|
||||
/**
|
||||
* Sets the port and security information for the receiver ... without
|
||||
* this the receiver will not listen for incoming requests.<br />
|
||||
* If secure is nil then the receiver listens on aPort for HTTP requests.<br />
|
||||
* If secure is not nil, the receiver listens for HTTPS instead.<br />
|
||||
* If secure is a dictionary containing <code>CertificateFile</code>,
|
||||
* <code>KeyFile</code> and <code>Password</code> then the server will
|
||||
* use the specified certificate and key files (which it will access
|
||||
* using the password).<br />
|
||||
* This method returns YES on success, NO on failure ... if it returns NO
|
||||
* then the receiver will <em>not</em> be capable of handling incoming
|
||||
* web requests!<br />
|
||||
* Typically a failure will be due to an invalid port being specified ...
|
||||
* a port may not already be in use and may not be in the range up to 1024
|
||||
* (unless running as the super-user).
|
||||
*/
|
||||
- (BOOL) setPort: (NSString*)aPort secure: (NSDictionary*)secure;
|
||||
|
||||
/**
|
||||
* Sets the maximum recursion depth allowed for subsititutions into
|
||||
* templates. This defaults to 4.
|
||||
*/
|
||||
- (void) setSubstitutionLimit: (unsigned)depth;
|
||||
|
||||
/**
|
||||
* Set root path for loading template files from.<br />
|
||||
* Templates may only be loaded from within this directory.
|
||||
*/
|
||||
- (void) setRoot: (NSString*)aPath;
|
||||
|
||||
/**
|
||||
* Sets the time after which an idle session should be shut down.<br />
|
||||
* Default is 30.0
|
||||
*/
|
||||
- (void) setSessionTimeout: (NSTimeInterval)aDelay;
|
||||
|
||||
/**
|
||||
* Sets a flag to determine whether verbose logging is to be performed.<br />
|
||||
* If this is YES then all incming requests and their responses will
|
||||
* be logged using the NSLog function. This is useful for debugging
|
||||
* and where a full audit trail is required.
|
||||
*/
|
||||
- (void) setVerbose: (BOOL)aFlag;
|
||||
|
||||
/**
|
||||
* Perform substituations replacing the markup in aTemplate with the
|
||||
* values supplied by map and appending the results to the result.<br />
|
||||
* Substitutions are recursive, and the depth argument is used to
|
||||
* specify the current recursion depth (you should normally call this
|
||||
* method with a depth of zero at the start of processing a template).<br />
|
||||
* Any value inside SGML comment delimiters ('<!--' and '-->') is
|
||||
* treated as a possible key in map and the entire comment is replaced
|
||||
* by the corresponding map value (unless it is nil). Recursive substitution
|
||||
* is done unless the mapped value <em>starts</em> with an SGML comment.<br />
|
||||
* While the map is nominally a dictionary, in fact it may be any
|
||||
* object which responds to the objectForKey: method by returning
|
||||
* an NSString or nil.<br />
|
||||
* The method returns YES on success, NO on failure (depth too great).<br />
|
||||
* You don't normally need to use this method directly ... call the
|
||||
* -produceResponse:fromTemplate:using: method instead.
|
||||
*/
|
||||
- (BOOL) substituteFrom: (NSString*)aTemplate
|
||||
using: (NSDictionary*)map
|
||||
into: (NSMutableString*)result
|
||||
depth: (unsigned)depth;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* WebServerBundles is an example delegate for the WebServer class.<br />
|
||||
* This is intended to act as a convenience for a scheme where the
|
||||
* WebServer instance in a program is configured by values obtained
|
||||
* from the user defaults system, and incoming requests may be handled
|
||||
* by different delegate objects depending on the path information
|
||||
* supplied in the request. The WebServerBundles intance is responsible
|
||||
* for loading the bundles (based on information in the WebServerBundles
|
||||
* dictionary in the user defaults system) and for forwarding requests
|
||||
* to the appropriate bundles for processing.<br />
|
||||
* If a request comes in which is not an exact match for the path of any
|
||||
* handler, the request path is repeatedly shortened by chopping off the
|
||||
* last path component until a matching handler is found.<br />
|
||||
* The paths in the dictionary must <em>not</em> end with a slash...
|
||||
* an empty string will match all requests which do not match a handler
|
||||
* with a longer path.
|
||||
* <example>
|
||||
* </example>
|
||||
*/
|
||||
@interface WebServerBundles : NSObject <WebServerDelegate>
|
||||
{
|
||||
NSMutableDictionary *_handlers;
|
||||
WebServer *_http;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a notification that the defaults have been updated ... change
|
||||
* WebServer configuration if necessary.<br />
|
||||
* <list>
|
||||
* <item>
|
||||
* WebServerPort must be used to specify the port that the server
|
||||
* listens on. See [WebServer-setPort:secure:] for details.
|
||||
* </item>
|
||||
* <item>
|
||||
* WebServerSecure may be supplied to make the server operate as an
|
||||
* HTTPS server rather than an HTTP server.
|
||||
* See [WebServer-setPort:secure:] for details.
|
||||
* </item>
|
||||
* <item>
|
||||
* WebServerBundles is a dictionary keyed on path strings, whose
|
||||
* values are dictionaries, each containing per-handler configuration
|
||||
* information and the name of the bundle containing the code to handle
|
||||
* requests sent to the path. NB. the bundle name listed should
|
||||
* omit the <code>.bundle</code> extension.
|
||||
* </item>
|
||||
* </list>
|
||||
* Returns YES on success, NO on failure (if the port of the WebServer
|
||||
* cannot be set).
|
||||
*/
|
||||
- (BOOL) defaultsUpdate: (NSNotification *)aNotification;
|
||||
|
||||
/**
|
||||
* Returns the handler to be used for the specified path, or nil if there
|
||||
* is no handler available.<br />
|
||||
* If the info argument is non-null, it is used to return additional
|
||||
* information, either the path actually matched, or an error string.
|
||||
*/
|
||||
- (id) handlerForPath: (NSString*)path info: (NSString**)info;
|
||||
|
||||
/**
|
||||
* Return dictionary of all handlers by name (path in request which maps
|
||||
* to that handler instance).
|
||||
*/
|
||||
- (NSMutableDictionary*) handlers;
|
||||
|
||||
/**
|
||||
* Return the WebServer instance that the receiver is acting as a
|
||||
* delegate for.
|
||||
*/
|
||||
- (WebServer*) http;
|
||||
|
||||
/** <init />
|
||||
* Initialises the receiver as the delegate of http and configures
|
||||
* the WebServer based upon the settings found in the user defaults
|
||||
* system by using the -defaultsUpdate: method.
|
||||
*/
|
||||
- (id) initAsDelegateOf: (WebServer*)http;
|
||||
|
||||
/**
|
||||
* Handles an incoming request by forwarding it to another handler.<br />
|
||||
* If a direct mapping is available from the path in the request to
|
||||
* an existing handler, that handler is used to process the request.
|
||||
* Otherwise, the WebServerBundles dictionary (obtained from the
|
||||
* defaults system) is used to map the request path to configuration
|
||||
* information listing the bundle containing the handler to be used.<br />
|
||||
* The configuration information is a dictionary containing the name
|
||||
* of the bundle (keyed on 'Name'), and this is used to locate the
|
||||
* bundle in the applications resources.<br />
|
||||
* Before a request is passed on to a handler, two extra headers are set
|
||||
* in it ... <code>x-http-path-base</code> and <code>x-http-path-info</code>
|
||||
* being the actual path matched for the handler, and the remainder of the
|
||||
* path after that base part.
|
||||
*/
|
||||
- (BOOL) processRequest: (GSMimeDocument*)request
|
||||
response: (GSMimeDocument*)response
|
||||
for: (WebServer*)http;
|
||||
|
||||
/**
|
||||
* Registers an object as the handler for a particular path.<br />
|
||||
* Registering a nil handler destroys any existing handler for the path.
|
||||
*/
|
||||
- (void) registerHandler: (id)handler forPath: (NSString*)path;
|
||||
|
||||
/**
|
||||
* Just write to stderr using NSLog.
|
||||
*/
|
||||
- (void) webAlert: (NSString*)message for: (WebServer*)http;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
1533
WebServer.m
1533
WebServer.m
File diff suppressed because it is too large
Load diff
|
@ -1,248 +0,0 @@
|
|||
/**
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: June 2004
|
||||
|
||||
This file is part of the SQLClient 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; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "WebServer.h"
|
||||
|
||||
@implementation WebServerBundles
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_http);
|
||||
RELEASE(_handlers);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) defaultsUpdate: (NSNotification *)aNotification
|
||||
{
|
||||
NSUserDefaults *defs = [aNotification object];
|
||||
NSString *port;
|
||||
NSDictionary *secure;
|
||||
|
||||
port = [defs stringForKey: @"WebServerPort"];
|
||||
if ([port length] == 0)
|
||||
{
|
||||
return NO; // Can't make web server active.
|
||||
}
|
||||
secure = [defs dictionaryForKey: @"WebServerSecure"];
|
||||
return [_http setPort: port secure: secure];
|
||||
}
|
||||
|
||||
- (id) handlerForPath: (NSString*)path info: (NSString**)info
|
||||
{
|
||||
NSString *error = nil;
|
||||
NSMutableDictionary *handlers;
|
||||
id handler;
|
||||
|
||||
if (info != 0)
|
||||
{
|
||||
*info = path;
|
||||
}
|
||||
handlers = [self handlers];
|
||||
handler = [handlers objectForKey: path];
|
||||
if (handler == nil)
|
||||
{
|
||||
NSUserDefaults *defs;
|
||||
NSDictionary *conf;
|
||||
NSDictionary *byPath;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
conf = [defs dictionaryForKey: @"WebServerBundles"];
|
||||
byPath = [conf objectForKey: path];
|
||||
if ([byPath isKindOfClass: [NSDictionary class]] == NO)
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
r = [path rangeOfString: @"/" options: NSBackwardsSearch];
|
||||
if (r.length > 0)
|
||||
{
|
||||
path = [path substringToIndex: r.location];
|
||||
handler = [self handlerForPath: path info: info];
|
||||
}
|
||||
else
|
||||
{
|
||||
error = [NSString stringWithFormat:
|
||||
@"Unable to find handler in Bundles config for '%@'", path];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
name = [byPath objectForKey: @"Name"];
|
||||
|
||||
if ([name length] == 0)
|
||||
{
|
||||
error = [NSString stringWithFormat:
|
||||
@"Unable to find Name in Bundles config for '%@'", path];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSBundle *mb = [NSBundle mainBundle];
|
||||
NSString *p = [mb pathForResource: name ofType: @"bundle"];
|
||||
NSBundle *b = [NSBundle bundleWithPath: p];
|
||||
Class c = [b principalClass];
|
||||
|
||||
if (c == 0)
|
||||
{
|
||||
error = [NSString stringWithFormat:
|
||||
@"Unable to find class in '%@' for '%@'", p, path];
|
||||
}
|
||||
else
|
||||
{
|
||||
handler = [c new];
|
||||
[self registerHandler: handler forPath: path];
|
||||
RELEASE(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (handler == nil && info != 0)
|
||||
{
|
||||
*info = error;
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary*) handlers
|
||||
{
|
||||
if (_handlers == nil)
|
||||
{
|
||||
_handlers = [NSMutableDictionary new];
|
||||
}
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
- (WebServer*) http
|
||||
{
|
||||
return _http;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initAsDelegateOf: nil];
|
||||
}
|
||||
|
||||
- (id) initAsDelegateOf: (WebServer*)http
|
||||
{
|
||||
if (http == nil)
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
NSNotification *n;
|
||||
|
||||
ASSIGN(_http, http);
|
||||
[_http setDelegate: self];
|
||||
|
||||
/*
|
||||
* Watch for config changes, and set initial config by sending a
|
||||
* faked change notification.
|
||||
*/
|
||||
[nc addObserver: self
|
||||
selector: @selector(defaultsUpdate:)
|
||||
name: NSUserDefaultsDidChangeNotification
|
||||
object: defs];
|
||||
n = [NSNotification
|
||||
notificationWithName: NSUserDefaultsDidChangeNotification
|
||||
object: defs
|
||||
userInfo: nil];
|
||||
if ([self defaultsUpdate: n] == NO)
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* We handle the incoming requests here.
|
||||
*/
|
||||
- (BOOL) processRequest: (GSMimeDocument*)request
|
||||
response: (GSMimeDocument*)response
|
||||
for: (WebServer*)http
|
||||
{
|
||||
NSString *path;
|
||||
NSString *info;
|
||||
id handler;
|
||||
|
||||
path = [[request headerNamed: @"x-http-path"] value];
|
||||
handler = [self handlerForPath: path info: &info];
|
||||
if (handler == nil)
|
||||
{
|
||||
NSString *error = @"bad path";
|
||||
|
||||
/*
|
||||
* Log the error message.
|
||||
*/
|
||||
[self webAlert: info for: (WebServer*)http];
|
||||
|
||||
/*
|
||||
* Return status code 400 (Bad Request) with the informative error
|
||||
*/
|
||||
error = [NSString stringWithFormat: @"HTTP/1.0 400 %@", error];
|
||||
[response setHeader: @"http" value: error parameters: nil];
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *extra = [path substringFromIndex: [info length]];
|
||||
|
||||
/*
|
||||
* Provide extra information about the exact path used to match
|
||||
* the handler, and any remaining path information beyond it.
|
||||
*/
|
||||
[request setHeader: @"x-http-path-base"
|
||||
value: info
|
||||
parameters: nil];
|
||||
[request setHeader: @"x-http-path-info"
|
||||
value: extra
|
||||
parameters: nil];
|
||||
|
||||
return [handler processRequest: request
|
||||
response: response
|
||||
for: http];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) registerHandler: (id)handler forPath: (NSString*)path
|
||||
{
|
||||
if (handler == nil)
|
||||
{
|
||||
[[self handlers] removeObjectForKey: path];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self handlers] setObject: handler forKey: path];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) webAlert: (NSString*)message for: (WebServer*)http
|
||||
{
|
||||
NSLog(@"%@", message);
|
||||
}
|
||||
@end
|
||||
|
1326
config.guess
vendored
1326
config.guess
vendored
File diff suppressed because it is too large
Load diff
106
config.h.in
106
config.h.in
|
@ -1,13 +1,117 @@
|
|||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <ecpglib.h> header file. */
|
||||
#undef HAVE_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <jni.h> header file. */
|
||||
#undef HAVE_JNI_H
|
||||
|
||||
/* Define to 1 if you have the `ecpg' library (-lecpg). */
|
||||
#undef HAVE_LIBECPG
|
||||
|
||||
/* Define to 1 if you have the `jvm' library (-ljvm). */
|
||||
#undef HAVE_LIBJVM
|
||||
|
||||
/* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */
|
||||
#undef HAVE_LIBMYSQLCLIENT
|
||||
|
||||
/* Define to 1 if you have the `pq' library (-lpq). */
|
||||
#undef HAVE_LIBPQ
|
||||
|
||||
/* Define to 1 if you have the <libpq-fe.h> header file. */
|
||||
#undef HAVE_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */
|
||||
#undef HAVE_LIBSQLITE3
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <mysql/mysql.h> header file. */
|
||||
#undef HAVE_MYSQL_MYSQL_H
|
||||
|
||||
/* Define to 1 if you have the `PQescapeStringConn' function. */
|
||||
#undef HAVE_PQESCAPESTRINGCONN
|
||||
|
||||
/* Define to 1 if you have the <sqlite3.h> header file. */
|
||||
#undef HAVE_SQLITE3_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/pgsql/ecpglib.h> header file. */
|
||||
#undef HAVE__USR_INCLUDE_PGSQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/pgsql/libpq-fe.h> header file. */
|
||||
#undef HAVE__USR_INCLUDE_PGSQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/8.0/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/8.0/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/include/pgsql/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/include/pgsql/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/pgsql/include/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_PGSQL_INCLUDE_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/pgsql/include/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_PGSQL_INCLUDE_LIBPQ_FE_H
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
|
||||
ECPG=@ECPG@
|
||||
JDBC=@JDBC@
|
||||
JDBC_VM_LIBS=@JDBC_VM_LIBS@
|
||||
JDBC_VM_LIBDIRS=@JDBC_VM_LIBDIRS@
|
||||
MYSQL=@MYSQL@
|
||||
SQLITE=@SQLITE@
|
||||
ORACLE_HOME=@ORACLE_HOME@
|
||||
POSTGRES=@POSTGRES@
|
||||
|
||||
|
|
1451
config.sub
vendored
1451
config.sub
vendored
File diff suppressed because it is too large
Load diff
570
configure.ac
570
configure.ac
|
@ -3,157 +3,499 @@ dnl Process this file with autoconf to produce configure.
|
|||
AC_INIT(SQLClient.h)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_ARG_WITH(additional-include-dir,
|
||||
[ --with-additional-include-dir=PATH specify additional include dirs to use],
|
||||
additional_include_dir="$withval", additional_include_dir="no")
|
||||
|
||||
if test "$additional_include_dir" != "no"; then
|
||||
CPPFLAGS="$CPPFLAGS $additional_include_dir"
|
||||
INCD="$INCD $additional_include_dir"
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
|
||||
export GNUSTEP_MAKEFILES
|
||||
fi
|
||||
|
||||
echo "Postgres development support"
|
||||
AC_ARG_WITH(postgres-dir,
|
||||
[ --with-postgres-dir=PATH specify postgres installation dir],
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
|
||||
else
|
||||
. $GNUSTEP_MAKEFILES/GNUstep.sh
|
||||
fi
|
||||
|
||||
if test "x$GNUSTEP_HOST_OS" = "x"; then
|
||||
GNUSTEP_HOST_OS=`gnustep-config --variable=GNUSTEP_HOST_OS`
|
||||
GNUSTEP_HOST_CPU=`gnustep-config --variable=GNUSTEP_HOST_CPU`
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
AC_ARG_WITH(additional-include, [
|
||||
--with-additional-include=flags
|
||||
Specifies additional include compiler flags to use.
|
||||
If configure can not find your database library headers,
|
||||
you may want to use this flag to help it find them. For
|
||||
example:
|
||||
--with-additional-include=-I/usr/local/include
|
||||
],
|
||||
additional_include="$withval", additional_include="no")
|
||||
|
||||
if test "$additional_include" != "no"; then
|
||||
CPPFLAGS="$CPPFLAGS $additional_include"
|
||||
INCD="$INCD $additional_include"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(additional-lib, [
|
||||
--with-additional-lib=flags
|
||||
Specifies additional library compiler flags to use.
|
||||
If configure can not find your database libraries,
|
||||
you may want to use this flag to help it find them. For
|
||||
example:
|
||||
--with-additional-lib=-L/usr/local/lib/mysql
|
||||
],
|
||||
additional_lib="$withval", additional_lib="no")
|
||||
|
||||
if test "$additional_lib" != "no"; then
|
||||
LDFLAGS="$LDFLAGS $additional_lib"
|
||||
LIBD="$LIBD $additional_lib"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(postgres-dir, [
|
||||
--with-postgres-dir=PATH
|
||||
Specifies the postgres installation dir; configure
|
||||
will add the appropriate additional include and lib
|
||||
flags. Useful when you installed postgres in some
|
||||
unusual place and want to help configure find it. For
|
||||
example:
|
||||
--with-postgres-dir=/usr/local/pgsql
|
||||
(which is equivalent to
|
||||
--with-additional-include=-L/usr/local/pgsql/include
|
||||
--with-additional-lib=-L/usr/local/pgsql/lib)
|
||||
],
|
||||
postgres_topdir="$withval", postgres_topdir="no")
|
||||
|
||||
if test "$postgres_topdir" != "no"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$postgres_topdir/include -L$postgres_topdir/lib"
|
||||
INCD="$INCD -I$postgres_topdir/include"
|
||||
LIBD="$LIBD -L$postgres_topdir/lib"
|
||||
else
|
||||
PGINC=`pg_config --includedir`
|
||||
if test "$PGINC" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -I$PGINC"
|
||||
INCD="$INCD -I$PGINC"
|
||||
fi
|
||||
PGLIB=`pg_config --libdir`
|
||||
if test "$PGLIB" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -L$PGLIB"
|
||||
LIBD="$LIBD -I$PGLIB"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
# Call AC_CHECK_HEADERS here as a workaround for a configure bug/feature
|
||||
# which messes up all subsequent tests if the first occurrence in the
|
||||
# file does not get called ... as would otherwise be the case if jdbc
|
||||
# support is disabled.
|
||||
AC_CHECK_HEADERS(stdio.h)
|
||||
|
||||
AC_MSG_CHECKING([if Jdbc support was manually disabled])
|
||||
AC_ARG_ENABLE(jdbc-bundle, [
|
||||
--disable-jdbc-bundle
|
||||
Disable creating the Jdbc bundle.
|
||||
Use this option to force the Jdbc bundle not to be built
|
||||
even if the Jdbc libraries look like being present.
|
||||
],
|
||||
ac_cv_jdbc_bundle=$enableval,
|
||||
ac_cv_jdbc_bundle="yes")
|
||||
|
||||
if test "$ac_cv_jdbc_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
else
|
||||
MYSQL=
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Get likely subdirectory for system specific java include
|
||||
case "$GNUSTEP_HOST_OS" in
|
||||
bsdi*) _JNI_SUBDIR="bsdos";;
|
||||
linux*) _JNI_SUBDIR="linux";;
|
||||
osf*) _JNI_SUBDIR="alpha";;
|
||||
solaris*) _JNI_SUBDIR="solaris";;
|
||||
mingw*) _JNI_SUBDIR="win32";;
|
||||
cygwin*) _JNI_SUBDIR="win32";;
|
||||
*) _JNI_SUBDIR="genunix";;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH(jre-architecture, [
|
||||
--with-jre-architecture=value
|
||||
Specifies the CPU architecture to use for the JRE
|
||||
(only used when building the JDBC module). Example
|
||||
values are i386, amd64 and sparc.
|
||||
],
|
||||
jre_architecture="$withval", jre_architecture="")
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
|
||||
AC_CHECK_HEADERS(jni.h)
|
||||
if test "$ac_cv_header_jni_h" = "yes"; then
|
||||
JDBC_VM_LIBS="-ljvm"
|
||||
jre_lib="$JAVA_HOME/jre/lib"
|
||||
|
||||
if test "$jre_architecture" = ""; then
|
||||
|
||||
# If on a 32/64bit system and compiling for the 64bit model
|
||||
# adjust the cpu type to be the 64bit version
|
||||
case "$CFLAGS" in
|
||||
*-m64*)
|
||||
if test "$GNUSTEP_HOST_CPU" = "ix86"; then
|
||||
_CPU="x86_64"
|
||||
else
|
||||
_CPU="$GNUSTEP_HOST_CPU"
|
||||
fi;;
|
||||
*) _CPU="$GNUSTEP_HOST_CPU";;
|
||||
esac
|
||||
case "$_CPU" in
|
||||
ix86) JAVA_CPU=i386;;
|
||||
x86_64) JAVA_CPU=amd64;;
|
||||
sparc) JAVA_CPU=sparc;;
|
||||
*) JAVA_CPU=i386;;
|
||||
esac
|
||||
else
|
||||
JAVA_CPU="$jre_architecture"
|
||||
fi
|
||||
|
||||
jre_cpu="$jre_lib/$JAVA_CPU"
|
||||
JDBC_VM_LIBDIRS="-L$jre_cpu/server"
|
||||
CFLAGS="$CFLAGS $JDBC_VM_LIBDIRS"
|
||||
AC_CHECK_LIB(jvm,JNI_CreateJavaVM)
|
||||
if test "$ac_cv_lib_jvm_JNI_CreateJavaVM" = "yes"; then
|
||||
INCD="$INCD -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
|
||||
JDBC=yes
|
||||
else
|
||||
JDBC=
|
||||
JDBC_VM_LIBS=
|
||||
JDBC_VM_LIBDIRS=
|
||||
echo "**********************************************"
|
||||
echo "Unable to locate jvm library (is it installed)"
|
||||
echo "**********************************************"
|
||||
fi
|
||||
else
|
||||
JDBC=
|
||||
JDBC_VM_LIBS=
|
||||
JDBC_VM_LIBDIRS=
|
||||
echo "*********************************************"
|
||||
echo "Unable to locate jni header (is it installed)"
|
||||
echo "*********************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
AC_SUBST(JDBC)
|
||||
AC_SUBST(JDBC_VM_LIBS)
|
||||
AC_SUBST(JDBC_VM_LIBDIRS)
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
AC_MSG_CHECKING([if Mysql support was manually disabled])
|
||||
AC_ARG_ENABLE(mysql-bundle, [
|
||||
--disable-mysql-bundle
|
||||
Disable creating the Mysql bundle.
|
||||
Use this option to force the Mysql bundle not to be built
|
||||
even if the Mysql libraries look like being present.
|
||||
],
|
||||
ac_cv_mysql_bundle=$enableval,
|
||||
ac_cv_mysql_bundle="yes")
|
||||
|
||||
if test "$ac_cv_mysql_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
MYSQL=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
else
|
||||
MYSQL=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
if test -d /usr/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/local/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/mysql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/mysql/lib"
|
||||
LIBD="$LIBD -L/usr/local/mysql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
MYSQL=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(MYSQL)
|
||||
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
|
||||
AC_MSG_CHECKING([if Sqllite support was manually disabled])
|
||||
AC_ARG_ENABLE(sqllite-bundle, [
|
||||
--disable-sqllite-bundle
|
||||
Disable creating the Sqllite bundle.
|
||||
Use this option to force the Sqllite bundle not to be built
|
||||
even if the Sqllite libraries look like being present.
|
||||
],
|
||||
ac_cv_sqllite_bundle=$enableval,
|
||||
ac_cv_sqllite_bundle="yes")
|
||||
|
||||
if test "$ac_cv_sqllite_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
SQLLITE=
|
||||
else
|
||||
old="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/postgresql"
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$old"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(sqlite3.h)
|
||||
if test "$ac_cv_header_sqlite3_h" = "yes"; then
|
||||
SQLITE=yes
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/pgsql"
|
||||
SQLITE=
|
||||
echo "*****************************************************"
|
||||
echo "Unable to locate sqlite3 headers (are they installed)"
|
||||
echo "*****************************************************"
|
||||
fi
|
||||
if test "$SQLITE" = "yes"; then
|
||||
AC_CHECK_LIB(sqlite3,sqlite3_open)
|
||||
if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
|
||||
SQLITE=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate sqlite3 library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(SQLITE)
|
||||
|
||||
AC_MSG_CHECKING([if Postgres support was manually disabled])
|
||||
AC_ARG_ENABLE(postgres-bundle, [
|
||||
--disable-postgres-bundle
|
||||
Disable creating the Postgres bundle.
|
||||
Use this option to force the Postgres bundle not to be built
|
||||
even if the Postgres libraries look like being present.
|
||||
],
|
||||
ac_cv_postgres_bundle=$enableval,
|
||||
ac_cv_postgres_bundle="yes")
|
||||
|
||||
if test "$ac_cv_postgres_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
POSTGRES=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Start POSTGRES checks
|
||||
POSTGRES=
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$old"
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
POSTGRES=yes
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/local/include/pgsql"
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$old"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
else
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
POSTGRES=
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
else
|
||||
old="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/postgresql"
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
CPPFLAGS="$old"
|
||||
if test "$ac_cv_header__usr_include_postgresql_ecpglib_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/pgsql"
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
CPPFLAGS="$old"
|
||||
if test "$ac_cv_header__usr_include_pgsql_ecpglib_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/local/include/pgsql"
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
CPPFLAGS="$old"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_ecpglib_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
ECPG=
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
POSTGRES=
|
||||
AC_CHECK_LIB(pq,PQclear)
|
||||
echo "******************************************************"
|
||||
if test "$ac_cv_lib_pq_PQclear" != "yes"; then
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
else
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
fi
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "******************************************************"
|
||||
else
|
||||
AC_CHECK_FUNCS(PQescapeStringConn)
|
||||
fi
|
||||
fi
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
# End POSTGRES checks
|
||||
fi
|
||||
|
||||
AC_SUBST(POSTGRES)
|
||||
|
||||
AC_MSG_CHECKING([if ECPG (Old Postgres) support was manually disabled])
|
||||
AC_ARG_ENABLE(ecpg-bundle, [
|
||||
--disable-ecpg-bundle
|
||||
Disable creating the ECPG bundle.
|
||||
Use this option to force the ECPG bundle not to be built
|
||||
even if the Postgres libraries look like being present.
|
||||
],
|
||||
ac_cv_ecpg_bundle=$enableval,
|
||||
ac_cv_ecpg_bundle="yes")
|
||||
|
||||
if test "$ac_cv_ecpg_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
ECPG=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Start ECPG checks
|
||||
ECPG=
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
if test "$ECPG" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
fi
|
||||
# End ECPG checks
|
||||
fi
|
||||
AC_SUBST(ECPG)
|
||||
|
||||
|
||||
|
||||
ORACLE_HOME=
|
||||
AC_SUBST(ORACLE_HOME)
|
||||
|
||||
|
@ -161,6 +503,13 @@ AC_SUBST(INCD)
|
|||
AC_SUBST(LIBD)
|
||||
AC_SUBST(LIBS)
|
||||
|
||||
if test "$JDBC" = "yes"; then
|
||||
BUNDLE="The JDBC backend bundle will be built"
|
||||
else
|
||||
BUNDLE="The JDBC backend bundle will NOT be built"
|
||||
fi
|
||||
AC_MSG_RESULT(${BUNDLE})
|
||||
|
||||
if test "$MYSQL" = "yes"; then
|
||||
BUNDLE="The MySQL backend bundle will be built"
|
||||
else
|
||||
|
@ -168,6 +517,13 @@ else
|
|||
fi
|
||||
AC_MSG_RESULT(${BUNDLE})
|
||||
|
||||
if test "$SQLITE" = "yes"; then
|
||||
BUNDLE="The SQLite backend bundle will be built"
|
||||
else
|
||||
BUNDLE="The SQLite backend bundle will NOT be built"
|
||||
fi
|
||||
AC_MSG_RESULT(${BUNDLE})
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
BUNDLE="The Postgres backend bundle will be built"
|
||||
else
|
||||
|
|
250
install-sh
250
install-sh
|
@ -1,250 +0,0 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
18
testECPG.m
18
testECPG.m
|
@ -7,29 +7,29 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
RELEASE(pool);
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
338
testJDBC.m
Normal file
338
testJDBC.m
Normal file
|
@ -0,0 +1,338 @@
|
|||
/**
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: August 2006
|
||||
|
||||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date: 2006-05-25 12:34:03 +0100 (Thu, 25 May 2006) $ $Revision: 22982 $
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Performance/GSCache.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
SQLRecord *record;
|
||||
unsigned char dbuf[256];
|
||||
unsigned int i;
|
||||
NSData *data;
|
||||
NSString *name;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"org.postgresql.Driver:jdbc:postgresql://localhost/template1",
|
||||
@"Database",
|
||||
@"postgres", @"User",
|
||||
@"postgres", @"Password",
|
||||
@"JDBC", @"ServerType",
|
||||
nil],
|
||||
@"test",
|
||||
nil],
|
||||
@"SQLClientReferences",
|
||||
nil]
|
||||
];
|
||||
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
[db connect];
|
||||
|
||||
if ((name = [defs stringForKey: @"Producer"]) != nil)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
[db execute: @"CREATE TABLE Queue ( "
|
||||
@"ID SERIAL, "
|
||||
@"Consumer CHAR(40) NOT NULL, "
|
||||
@"ServiceID INT NOT NULL, "
|
||||
@"Status CHAR(1) DEFAULT 'Q' NOT NULL, "
|
||||
@"Delivery TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
|
||||
@"Reference CHAR(128), "
|
||||
@"Destination CHAR(15) NOT NULL, "
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL"
|
||||
@")",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE UNIQUE INDEX QueueIDX ON Queue (ID)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ServiceIDX ON Queue (ServiceID)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ConsumerIDX ON Queue (Consumer,Status,Delivery)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ReferenceIDX ON Queue (Reference,Consumer)",
|
||||
nil];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"%@", localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
|
||||
{
|
||||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
@" AND Status = 'Q' AND Delivery < CURRENT_TIMESTAMP",
|
||||
@" ORDER BY Delivery LIMIT 1000 FOR UPDATE" , nil];
|
||||
count = [records count];
|
||||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
@" AND Status = 'Q' AND Delivery < CURRENT_TIMESTAMP",
|
||||
@" ORDER BY Delivery LIMIT 50 FOR UPDATE" , nil];
|
||||
count = [records count];
|
||||
if (count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
SQLRecord *record = [records objectAtIndex: j];
|
||||
NSString *reference = [record objectForKey: @"ID"];
|
||||
|
||||
[db execute: @"UPDATE Queue SET Status = 'S', Reference = ",
|
||||
[db quote: reference], @" WHERE ID = ",
|
||||
[record objectForKey: @"ID"], nil];
|
||||
|
||||
[db execute: @"UPDATE Queue SET Status = 'D'",
|
||||
@" WHERE Consumer = ", [db quote: name],
|
||||
@" AND Reference = ", [db quote: reference],
|
||||
nil];
|
||||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
[db execute: @"DROP INDEX ReferenceIDX", nil];
|
||||
[db execute: @"DROP INDEX ServiceIDX", nil];
|
||||
[db execute: @"DROP INDEX ConsumerIDX", nil];
|
||||
[db execute: @"DROP INDEX QueueIDX", nil];
|
||||
[db execute: @"DROP TABLE Queue", nil];
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLTransaction *t;
|
||||
NSString *oddChars;
|
||||
NSString *nonLatin;
|
||||
id r0;
|
||||
id r1;
|
||||
|
||||
oddChars = @"'a\\b'c\r\nd'\\ed\\";
|
||||
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dbuf[i] = i;
|
||||
}
|
||||
data = [NSData dataWithBytes: dbuf length: i];
|
||||
|
||||
NS_DURING
|
||||
[db execute: @"drop table xxx", nil];
|
||||
NS_HANDLER
|
||||
NS_ENDHANDLER
|
||||
|
||||
[db setDurationLogging: 0];
|
||||
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, "
|
||||
@"CURRENT_TIMESTAMP, "
|
||||
@"CURRENT_TIMESTAMP, ",
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db commit];
|
||||
|
||||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %"PRIuPTR, [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved data does not match saved data %@ %@",
|
||||
data, [record objectForKey: @"b"]);
|
||||
}
|
||||
record = [records objectAtIndex: 1];
|
||||
if ([[record objectForKey: @"b"] isEqual: [NSData data]] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved empty data does not match saved data");
|
||||
}
|
||||
record = [records objectAtIndex: 2];
|
||||
if ([[record objectForKey: @"char1"] isEqual: nonLatin] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved non-latin does not match saved string");
|
||||
}
|
||||
if ([[record objectForKey: @"k"] isEqual: oddChars] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved odd chars does not match saved string");
|
||||
}
|
||||
}
|
||||
|
||||
[db execute: @"create table xxx ( "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
t = [db transaction];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"0, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"2, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t execute];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
NSLog(@"Records - %@", [GSCache class]);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
18
testMySQL.m
18
testMySQL.m
|
@ -7,29 +7,29 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
RELEASE(pool);
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
338
testPostgres.m
338
testPostgres.m
|
@ -7,29 +7,42 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
version 3 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.
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Performance/GSCache.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
@interface Logger : NSObject
|
||||
- (void) notified: (NSNotification*)n;
|
||||
@end
|
||||
|
||||
@implementation Logger
|
||||
- (void) notified: (NSNotification*)n
|
||||
{
|
||||
NSLog(@"Received %@", n);
|
||||
}
|
||||
@end
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClientPool *sp;
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -38,6 +51,7 @@ main()
|
|||
unsigned int i;
|
||||
NSData *data;
|
||||
NSString *name;
|
||||
Logger *l;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
|
@ -55,7 +69,84 @@ main()
|
|||
nil]
|
||||
];
|
||||
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
sp = [[[SQLClientPool alloc] initWithConfiguration: nil
|
||||
name: @"test"
|
||||
max: 2
|
||||
min: 1] autorelease];
|
||||
#if 0
|
||||
{
|
||||
NSAutoreleasePool *p;
|
||||
NSAutoreleasePool *q;
|
||||
SQLClient *c0;
|
||||
SQLClient *c1;
|
||||
|
||||
[sp setDebugging: 4];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Got two clients from pool");
|
||||
[c0 connect];
|
||||
[c1 connect];
|
||||
NSLog(@"Now putting clients back in pool again");
|
||||
[sp swallowClient: c0];
|
||||
[sp swallowClient: c1];
|
||||
NSLog(@"And emptying autorelease pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
[sp setPurgeAll: 60 min: 1];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
NSLog(@"Expecting purge to disconnect one client");
|
||||
[sp purge];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Expecting connected: %@", [c0 connected] ? @"YES" : @"NO");
|
||||
NSLog(@"Expecting not connected: %@", [c1 connected] ? @"NO" : @"YES");
|
||||
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool ... clients should be put back in pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
NSLog(@"Getting two clients again");
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool again");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClient];
|
||||
q = [NSAutoreleasePool new];
|
||||
c1 = [sp provideClient];
|
||||
if (c0 != c1)
|
||||
{
|
||||
NSLog(@"ERROR was expecting provideClient to give the same object");
|
||||
exit(1);
|
||||
}
|
||||
[q release];
|
||||
[c0 connect];
|
||||
[p release];
|
||||
|
||||
NSLog(@"Expect to get client immediately");
|
||||
}
|
||||
#endif
|
||||
db = [sp provideClientExclusive];
|
||||
[sp swallowClient: db];
|
||||
|
||||
[sp queryString: @"SELECT CURRENT_TIMESTAMP", nil];
|
||||
db = [sp provideClientExclusive];
|
||||
|
||||
l = [Logger new];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidConnectNotification
|
||||
object: db];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidDisconnectNotification
|
||||
object: db];
|
||||
|
||||
if ((name = [defs stringForKey: @"Producer"]) != nil)
|
||||
{
|
||||
|
@ -69,7 +160,7 @@ main()
|
|||
@"Delivery TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
|
||||
@"Reference CHAR(128), "
|
||||
@"Destination CHAR(15) NOT NULL, "
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL"
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL,"
|
||||
@")",
|
||||
nil];
|
||||
[db execute:
|
||||
|
@ -93,23 +184,35 @@ main()
|
|||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
RELEASE(arp);
|
||||
if (i % 1000 == 999)
|
||||
{
|
||||
[db postNotificationName: @"Producing"
|
||||
payload: [NSString stringWithFormat: @"%d", i]];
|
||||
}
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination,"
|
||||
@" ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ",
|
||||
[db quote: destination], @", ",
|
||||
sid, @", ",
|
||||
@"'helo there'",
|
||||
@")", nil];
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
|
||||
{
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"Producing"];
|
||||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
|
@ -122,7 +225,7 @@ main()
|
|||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
sleep(1);
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
|
@ -151,7 +254,7 @@ main()
|
|||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
RELEASE(arp);
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
|
@ -164,6 +267,20 @@ main()
|
|||
}
|
||||
else
|
||||
{
|
||||
NSString *oddChars;
|
||||
NSString *oddNoNul;
|
||||
NSString *nonLatin;
|
||||
id e1, e2, e3, e4, e5;
|
||||
id d;
|
||||
id d0;
|
||||
id d1;
|
||||
id d2;
|
||||
id r0;
|
||||
id r1;
|
||||
|
||||
oddChars = @"'a\\b'c\0\r\nd'\\ed\\";
|
||||
oddNoNul = @"'a\\b'c\r\nd'\\ed\\";
|
||||
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dbuf[i] = i;
|
||||
|
@ -179,31 +296,64 @@ main()
|
|||
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea"
|
||||
@"b bytea,"
|
||||
@"extra1 int[],"
|
||||
@"extra2 varchar[],"
|
||||
@"extra3 bytea[],"
|
||||
@"extra4 boolean[],"
|
||||
@"extra5 timestamp with time zone[]"
|
||||
@")",
|
||||
nil];
|
||||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
if (1 != [db execute: @"INSERT into xxx (id, k, char1, boolval, intval,"
|
||||
@" when1, when2, b, extra1, extra2, extra3, extra4, extra5) "
|
||||
@"values (1,"
|
||||
@"'{hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, "
|
||||
@"CURRENT_TIMESTAMP, "
|
||||
@"CURRENT_TIMESTAMP, ",
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
data, @", ",
|
||||
[db quoteArray:
|
||||
(e1 = [NSArray arrayWithObjects: @"1", @"2", [NSNull null], nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e2 = [NSArray arrayWithObjects: @"on,e", @"t'wo", @"many", nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e3 = [NSArray arrayWithObjects: data, nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e4 =[NSArray arrayWithObjects: @"TRUE", @"FALSE", nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e5 = [NSArray arrayWithObjects: [NSDate date], nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @")",
|
||||
nil])
|
||||
{
|
||||
NSLog(@"Insert failed to return row count");
|
||||
}
|
||||
|
||||
[db setDebugging: 0];
|
||||
[db query: @"select * from xxx", nil];
|
||||
[db setDebugging: 0];
|
||||
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (2,"
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
|
@ -213,17 +363,46 @@ main()
|
|||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (3,",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db commit];
|
||||
|
||||
records = [db query: @"select * from xxx", nil];
|
||||
r0 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
db = [[[SQLClient alloc] initWithConfiguration: nil
|
||||
name: @"test"] autorelease];
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"foo"];
|
||||
|
||||
[db postNotificationName: @"foo" payload: @"hello"];
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 2)
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
NSLog(@"Expected 3 records but got %lu", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
|
@ -235,12 +414,105 @@ main()
|
|||
{
|
||||
NSLog(@"Retrieved empty data does not match saved data");
|
||||
}
|
||||
record = [records objectAtIndex: 2];
|
||||
if ([[record objectForKey: @"char1"] isEqual: nonLatin] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved non-latin does not match saved string");
|
||||
}
|
||||
id o = [[record objectForKey: @"k"] stringByTrimmingSpaces];
|
||||
if ([o isEqual: oddNoNul] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved odd chars (%@) does not match oddNoNul (%@)",
|
||||
o, oddNoNul);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Embedded nul correctly removed");
|
||||
}
|
||||
record = [records objectAtIndex: 0];
|
||||
o = [record objectForKey: @"extra1"];
|
||||
if ([o isEqual: e1] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra1 (%@) does not match saved (%@)", o, e1);
|
||||
}
|
||||
o = [record objectForKey: @"extra2"];
|
||||
if ([o isEqual: e2] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra2 (%@) does not match saved (%@)", o, e2);
|
||||
}
|
||||
o = [record objectForKey: @"extra3"];
|
||||
if ([o isEqual: e3] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra3 (%@) does not match saved (%@)", o, e3);
|
||||
}
|
||||
o = [record objectForKey: @"extra4"];
|
||||
if ([o count] != [e4 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)", o, e4);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if ([[o objectAtIndex: i] boolValue]
|
||||
!= [[e4 objectAtIndex: i] boolValue])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)",
|
||||
o, e4);
|
||||
}
|
||||
}
|
||||
o = [record objectForKey: @"extra5"];
|
||||
if ([o count] != [e5 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)", o, e5);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if (floor([[o objectAtIndex: i] timeIntervalSinceReferenceDate])
|
||||
!= floor([[e5 objectAtIndex: i] timeIntervalSinceReferenceDate]))
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)",
|
||||
o, e5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"Records - %@", records);
|
||||
NSLog(@"Records - %@", [GSCache class]);
|
||||
|
||||
d = [NSCalendarDate date];
|
||||
[d setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 240]];
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"when0 timestamp with time zone, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp)",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx (id, when0, when1, when2) "
|
||||
@"values (99,",
|
||||
d, @", ",
|
||||
[NSDate distantPast], @", ",
|
||||
[NSDate distantFuture], @")",
|
||||
nil];
|
||||
r0 = [[db query: @"select * from xxx where id=99", nil] lastObject];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
[db commit];
|
||||
|
||||
d0 = [r0 objectForKey:@"when0"];
|
||||
NSCAssert(floor([d0 timeIntervalSinceReferenceDate])
|
||||
== floor([d timeIntervalSinceReferenceDate]),
|
||||
NSInternalInconsistencyException);
|
||||
d1 = [r0 objectForKey:@"when1"];
|
||||
NSCAssert([d1 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantPast] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
d2 = [r0 objectForKey:@"when2"];
|
||||
NSCAssert([d2 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantFuture] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
}
|
||||
|
||||
RELEASE(pool);
|
||||
NSLog(@"Pool stats:\n%@", [sp statistics]);
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
129
testSQLite.m
Normal file
129
testSQLite.m
Normal file
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: April 2005
|
||||
|
||||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
SQLRecord *record;
|
||||
unsigned char dbuf[256];
|
||||
unsigned int i;
|
||||
NSData *data;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"test", @"Database",
|
||||
@"", @"User",
|
||||
@"", @"Password",
|
||||
@"SQLite", @"ServerType",
|
||||
nil],
|
||||
@"test",
|
||||
nil],
|
||||
@"SQLClientReferences",
|
||||
nil]
|
||||
];
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dbuf[i] = i;
|
||||
}
|
||||
data = [NSData dataWithBytes: dbuf length: i];
|
||||
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
[db setDurationLogging: 0];
|
||||
|
||||
NS_DURING
|
||||
[db execute: @"drop table xxx", nil];
|
||||
NS_HANDLER
|
||||
NS_ENDHANDLER
|
||||
|
||||
[db execute: @"create table xxx ( "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"intval int, "
|
||||
@"realval real, "
|
||||
@"b blob)",
|
||||
nil];
|
||||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, intval, realval, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"1, "
|
||||
@"9.99, ",
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
|
||||
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
|
||||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, intval, realval, b) "
|
||||
@"values (",
|
||||
[db quoteString: @"hello"], @", "
|
||||
@"'X', "
|
||||
@"1, ",
|
||||
@"12345.6789, ",
|
||||
[NSData dataWithBytes: "" length: 0], @")",
|
||||
nil];
|
||||
|
||||
records = [db query: @"select * from xxx", nil];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved data does not match saved data %@ %@",
|
||||
data, [record objectForKey: @"b"]);
|
||||
}
|
||||
record = [records objectAtIndex: 1];
|
||||
if ([[record objectForKey: @"b"] isEqual: [NSData data]] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved empty data does not match saved data");
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue