Compare commits

..

1 commit

Author SHA1 Message Date
GNUstep Maintainer
31e7cdff2b This commit was manufactured by cvs2svn to create tag 'Release1_1'.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/tags/Release1_1@20792 72102866-910b-0410-8b05-ffd578937521
2005-02-24 17:30:00 +00:00
33 changed files with 11598 additions and 19480 deletions

View file

@ -1,166 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.]
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.
Preamble
0. Additional Definitions.
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.
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.
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.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
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.
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.
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.
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".
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.
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.
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 "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.
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.
1. Exception to Section 3 of the GNU GPL.
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.
You may convey a covered work under sections 3 and 4 of this License
without being bound by 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.
2. Conveying Modified Versions.
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.
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:
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.
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
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.
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
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.
3. Object Code Incorporating Material from Library Header Files.
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
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:
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".
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.
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.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
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".)
4. Combined Works.
"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.
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
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
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!

1623
ChangeLog

File diff suppressed because it is too large Load diff

322
ECPG.pgm
View file

@ -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 Lesser General Public
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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.
@ -40,9 +40,6 @@
#include <Foundation/NSAutoreleasePool.h>
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
@interface SQLClientECPG : SQLClient
@ -111,18 +108,18 @@ void SQLErrorHandler()
const char *e1 = "Error in transaction processing";
sqlca.sqlcode = 0; // Reset error code
NSLog (@"Raising an exception, %d, %s", code, sqlca.sqlerrm.sqlerrmc);
NSLog (@"Raising an exception, %ld, %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=(%d): %s", code, ptr];
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
}
else
{
[NSException raise: SQLException
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
}
}
@ -137,7 +134,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];
[future retain];
RETAIN(future);
}
}
@ -248,20 +245,20 @@ static NSDate *future = nil;
}
}
- (NSInteger) backendExecute: (NSArray*)info
- (void) backendExecute: (NSArray*)info
{
EXEC SQL BEGIN DECLARE SECTION;
char *statement;
char *handle;
EXEC SQL END DECLARE SECTION;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(arp);
unsigned int length;
NSString *stmt = [info objectAtIndex: 0];
length = [stmt length];
if (length == 0)
{
[arp release];
RELEASE (arp);
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
@ -279,9 +276,9 @@ static NSDate *future = nil;
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
if ([self backendConnect] == NO)
{
[arp release];
RELEASE (arp);
[NSException raise: SQLException
format: @"Unable to connect to '%@' to execute statement %@",
[self name], stmt];
@ -299,7 +296,7 @@ static NSDate *future = nil;
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
/*
* remove line number information from database exception message
@ -325,14 +322,13 @@ static NSDate *future = nil;
[self debug: @"Error executing statement:\n%@\n%@",
stmt, localException];
}
[localException retain];
[arp release];
[localException autorelease];
RETAIN (localException);
RELEASE (arp);
AUTORELEASE (localException);
[localException raise];
}
NS_ENDHANDLER
[arp release];
return -1;
DESTROY(arp);
}
static unsigned int trim(char *str)
@ -360,8 +356,6 @@ static unsigned int trim(char *str)
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
EXEC SQL BEGIN DECLARE SECTION;
bool aBool;
@ -383,7 +377,7 @@ static unsigned int trim(char *str)
char *query;
char *handle;
EXEC SQL END DECLARE SECTION;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(arp);
NSMutableArray *records;
BOOL isOpen = NO;
BOOL localTransaction = NO;
@ -391,21 +385,21 @@ static unsigned int trim(char *str)
length = [stmt length];
if (length == 0)
{
[arp release];
RELEASE (arp);
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
query = (char*)[hackForPrepare(stmt) UTF8String];
handle = (char*)[[self clientName] UTF8String];
records = [[ltype alloc] initWithCapacity: 32];
records = [[NSMutableArray alloc] initWithCapacity: 32];
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
if ([self backendConnect] == NO)
{
[arp release];
RELEASE (arp);
[NSException raise: SQLException
format: @"Unable to connect to '%@' to run query %@",
[self name], stmt];
@ -557,10 +551,7 @@ static unsigned int trim(char *str)
case SQL3_CHARACTER_VARYING:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
if (_shouldTrim)
{
trim(aString);
}
trim(aString);
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
@ -589,10 +580,7 @@ static unsigned int trim(char *str)
default:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
if (_shouldTrim)
{
trim(aString);
}
trim(aString);
v = [NSString stringWithUTF8String: aString];
free(aString);
if ([self debugging] > 0)
@ -609,11 +597,11 @@ static unsigned int trim(char *str)
keys[index-1] = [NSString stringWithUTF8String:
fieldName];
}
record = [rtype newWithValues: values
keys: keys
count: count];
record = [SQLRecord newWithValues: values
keys: keys
count: count];
[records addObject: record];
[record release];
RELEASE(record);
}
}
@ -631,8 +619,7 @@ static unsigned int trim(char *str)
NSString *n = [localException name];
NSString *msg = [localException reason];
[records release];
records = nil;
DESTROY(records);
NS_DURING
{
@ -651,14 +638,14 @@ static unsigned int trim(char *str)
if ([e isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
}
NS_ENDHANDLER
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
/*
@ -680,15 +667,15 @@ static unsigned int trim(char *str)
userInfo: nil];
}
}
[localException retain];
[arp release];
[localException autorelease];
RETAIN(localException);
RELEASE(arp);
AUTORELEASE(localException);
[localException raise];
}
NS_ENDHANDLER
[arp release];
DESTROY(arp);
return [records autorelease];
return AUTORELEASE(records);
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
@ -822,7 +809,7 @@ static unsigned int trim(char *str)
}
}
dst[dLen] = '\0';
return (const char*)dst; // Owned by autoreleased NSMutableData
return dst; // Owned by autoreleased NSMutableData
}
- (NSData *) dataFromBlob: (const char *)blob
@ -946,13 +933,9 @@ static unsigned int trim(char *str)
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
{
char buf[l+32]; /* Allow space to expand buffer. */
NSCalendarDate *d;
BOOL milliseconds = NO;
BOOL timezone = NO;
NSString *s;
int i;
int e;
char buf[l+32]; /* Allow space to expend buffer. */
NSString *s;
int i;
memcpy(buf, b, l);
b = buf;
@ -975,153 +958,98 @@ static unsigned int trim(char *str)
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
s = [self dbToStringFromBuffer: b length: l];
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
{
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';
}
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;
/*
* 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';
}
}
}
if (isdigit(b[i-1]))
{
/*
* Make space between seconds and timezone.
*/
memmove(&b[i+1], &b[i], l - i);
b[i++] = ' ';
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 (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';
}
}
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];
}
/* 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];
}
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
@ -1139,8 +1067,8 @@ static unsigned int trim(char *str)
}
d = [[NSData alloc] initWithBytes: b length: l];
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
[d release];
return [s autorelease];
RELEASE(d);
return AUTORELEASE(s);
}
@end

View file

@ -1,59 +1,30 @@
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.9
SQLClient_INTERFACE_VERSION=1.1
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="";}'
SQLClient_OBJC_FILES = SQLClient.m WebServer.m WebServerBundles.m
SQLClient_LIBRARIES_DEPEND_UPON =
SQLClient_HEADER_FILES = SQLClient.h WebServer.h
# 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_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
BUNDLE_INSTALL_DIR=$(GNUSTEP_INSTALLATION_DIR)/Library/Bundles/SQLClient
# In some systems and situations the dynamic linker needs to haved the
# SQLClient, gnustep-base, and objc libraries explicityly linked into
@ -61,147 +32,61 @@ BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
# 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./$(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_LIB_DIRS = -L./obj
ECPG_BUNDLE_LIBS += -lecpg
ECPG_PRINCIPAL_CLASS = SQLClientECPG
BUNDLE_NAME += ECPG_libs
ECPG_libs_OBJC_FILES = ECPG.m
ECPG_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
$(FND_LIBS) $(OBJC_LIBS) -lecpg
ECPG_libs_LIB_DIRS = -L./obj
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lecpg
ECPG_libs_PRINCIPAL_CLASS = SQLClientECPG_libs
endif
TEST_TOOL_NAME += testECPG
testECPG_OBJC_FILES = testECPG.m
testECPG_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
testECPG_TOOL_LIBS += -lSQLClient -lPerformance
testECPG_TOOL_LIBS += -lSQLClient
testECPG_LIB_DIRS += -L./obj
endif
ifneq ($(POSTGRES),)
ifeq ($(LINKSQLCLIENT),1)
BUNDLE_NAME += Postgres
Postgres_OBJC_FILES = Postgres.m
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_LIB_DIRS = -L./obj
Postgres_BUNDLE_LIBS += -lpq
Postgres_PRINCIPAL_CLASS = SQLClientPostgres
BUNDLE_NAME += Postgres_libs
Postgres_libs_OBJC_FILES = Postgres.m
Postgres_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
$(FND_LIBS) $(OBJC_LIBS) -lpq
Postgres_libs_LIB_DIRS = -L./obj
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lpq
Postgres_libs_PRINCIPAL_CLASS = SQLClientPostgres_libs
endif
TEST_TOOL_NAME += testPostgres
testPostgres_OBJC_FILES = testPostgres.m
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
testPostgres_LIB_DIRS += -L./obj
testPostgres_TOOL_LIBS += -lSQLClient
endif
ifneq ($(MYSQL),)
ifeq ($(LINKSQLCLIENT),1)
BUNDLE_NAME += MySQL
MySQL_OBJC_FILES = MySQL.m
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_LIB_DIRS = -L./obj
MySQL_BUNDLE_LIBS += -lmysqlclient
MySQL_PRINCIPAL_CLASS = SQLClientMySQL
BUNDLE_NAME += MySQL_libs
MySQL_libs_OBJC_FILES = MySQL.m
MySQL_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
$(FND_LIBS) $(OBJC_LIBS) -lmysqlclient
MySQL_libs_LIB_DIRS = -L./obj
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lgnustep-base -lobjc -lmysqlclient
MySQL_libs_PRINCIPAL_CLASS = SQLClientMySQL_libs
endif
TEST_TOOL_NAME += testMySQL
testMySQL_OBJC_FILES = testMySQL.m
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
testMySQL_LIB_DIRS += -L./obj
testMySQL_TOOL_LIBS += -lSQLClient
endif
ifneq ($(ORACLE_HOME),)
BUNDLE_NAME += Oracle
Oracle_OBJC_FILES = Oracle.m
Oracle_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
Oracle_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./obj \
$(shell cat $(ORACLE_HOME)/lib/ldflags)
Oracle_BUNDLE_LIBS += -lclntsh \
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
@ -209,10 +94,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./$(GNUSTEP_OBJ_DIR) \
Oracle_libs_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./obj \
$(shell cat $(ORACLE_HOME)/lib/ldflags)
Oracle_libs_BUNDLE_LIBS += -lclntsh \
-lSQLClient -lPerformance $(FND_LIBS) $(OBJC_LIBS) \
-lSQLClient -lgnustep-base -lobjc \
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
-ldl -lm
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
@ -222,10 +107,6 @@ 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

View file

@ -13,7 +13,9 @@ ifneq ($(ECPG),)
%.m: %.pgm
ecpg -o $@ $< $(ADDITIONAL_INCLUDE_DIRS)
.PRECIOUS: %.m
# if you need to see the .m files for debugging, uncomment
# the following line
#.PRECIOUS: %.m
endif
@ -23,7 +25,9 @@ ifneq ($(ORACLE_HOME),)
%.m: %.pm
proc iname=$< oname=$@ mode=ansi parse=none
.PRECIOUS: %.m
# if you need to see the .m files for debugging, uncomment
# the following line
#.PRECIOUS: %.m
endif
@ -66,10 +70,6 @@ after-distclean::
# Things to do after checking
# after-check::
config.make: config.status
if [ -x config.status ]; then \
./config.status --recheck; \
else \
./configure; \
fi
config.make: config.make.in
./configure

View file

@ -12,7 +12,7 @@
#
# Additional flags to pass to the preprocessor
ADDITIONAL_CPPFLAGS += -DSOVERSION=\"$(SQLClient_INTERFACE_VERSION)\"
# ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler
# ADDITIONAL_OBJCFLAGS +=

View file

@ -1,2 +0,0 @@
LIBRARIES_DEPEND_UPON += -lPerformance.A
ADDITIONAL_LIB_DIRS = -L../../$(GNUSTEP_OBJ_DIR)

1942
JDBC.m

File diff suppressed because it is too large Load diff

268
MySQL.m
View file

@ -9,40 +9,36 @@
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
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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$
*/
#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 <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>
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
#include <mysql/mysql.h>
@ -62,12 +58,12 @@ static NSNull *null = nil;
{
if (future == nil)
{
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00"
calendarFormat: @"%Y-%m-%d %H:%M:%S"
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
[future retain];
RETAIN(future);
null = [NSNull null];
[null retain];
RETAIN(null);
}
}
@ -101,11 +97,9 @@ 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],
@ -113,13 +107,23 @@ static NSNull *null = nil;
[dbase UTF8String],
[port intValue],
NULL,
CLIENT_MULTI_STATEMENTS) == 0)
0
) == 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;
@ -164,7 +168,6 @@ static NSNull *null = nil;
}
NS_HANDLER
{
extra = 0;
[self debug: @"Error disconnecting from database (%@): %@",
[self clientName], localException];
}
@ -173,30 +176,28 @@ static NSNull *null = nil;
}
}
- (NSInteger) backendExecute: (NSArray*)info
- (void) backendExecute: (NSArray*)info
{
NSString *stmt;
NSInteger rowCount = 0;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *stmt;
CREATE_AUTORELEASE_POOL(arp);
stmt = [info objectAtIndex: 0];
if ([stmt length] == 0)
{
[arp release];
RELEASE (arp);
[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 connect] == NO)
if ([self backendConnect] == NO)
{
[NSException raise: SQLException
format: @"Unable to connect to '%@' to execute statement %@",
@ -208,38 +209,14 @@ static NSNull *null = nil;
statement = [self insertBLOBs: info
intoStatement: statement
length: length
withMarker: "'?'''?'"
length: 7
withMarker: "'''"
length: 3
giving: &length];
if (mysql_real_query(connection, statement, length) != 0)
{
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);
}
[NSException raise: SQLException format: @"%s",
mysql_error(connection)];
}
}
NS_HANDLER
@ -248,21 +225,20 @@ static NSNull *null = nil;
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
if ([self debugging] > 0)
{
[self debug: @"Error executing statement:\n%@\n%@",
stmt, localException];
}
[localException retain];
[arp release];
[localException autorelease];
RETAIN (localException);
RELEASE (arp);
AUTORELEASE (localException);
[localException raise];
}
NS_ENDHANDLER
[arp release];
return rowCount;
DESTROY(arp);
}
static unsigned int trim(char *str)
@ -290,16 +266,14 @@ static unsigned int trim(char *str)
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(arp);
NSMutableArray *records = nil;
MYSQL_RES *result = 0;
if ([stmt length] == 0)
{
[arp release];
RELEASE (arp);
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
@ -311,7 +285,7 @@ static unsigned int trim(char *str)
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
if ([self backendConnect] == NO)
{
[NSException raise: SQLException
format: @"Unable to connect to '%@' to run query %@",
@ -330,10 +304,10 @@ static unsigned int trim(char *str)
for (i = 0; i < fieldCount; i++)
{
keys[i] = [NSString stringWithUTF8String: (char*)fields[i].name];
keys[i] = [NSString stringWithUTF8String: fields[i].name];
}
records = [[ltype alloc] initWithCapacity: recordCount];
records = [[NSMutableArray alloc] initWithCapacity: recordCount];
for (i = 0; i < recordCount; i++)
{
SQLRecord *record;
@ -345,7 +319,7 @@ static unsigned int trim(char *str)
for (j = 0; j < fieldCount; j++)
{
id v = null;
unsigned char *p = (unsigned char*)row[j];
unsigned char *p = row[j];
if (p != 0)
{
@ -361,55 +335,60 @@ 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)
{
size = 19;
f = @"%Y-%m-%d %H:%M:%S %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S"
locale: nil];
}
else if (size == 14)
{
f = @"%Y%m%d%H%M%S %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y%m%d%H%M%S"
locale: nil];
}
else if (size == 12)
{
f = @"%y%m%d%H%M%S %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y%m%d%H%M%S"
locale: nil];
}
else if (size == 10)
{
f = @"%y%m%d%H%M %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y%m%d%H%M"
locale: nil];
}
else if (size == 8)
{
f = @"%y%m%d%H %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y%m%d%H"
locale: nil];
}
else if (size == 6)
{
f = @"%y%m%d %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y%m%d"
locale: nil];
}
else if (size == 4)
{
f = @"%y%m %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y%m"
locale: nil];
}
else
{
f = @"%y %z";
v = [NSCalendarDate dateWithString: s
calendarFormat: @"%y"
locale: nil];
}
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];
RELEASE(s);
[v setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
if ([self debugging] > 1)
[self debug: @"Parsed '%@' as '%@'\n", s, v];
[s release];
}
break;
@ -421,49 +400,28 @@ static unsigned int trim(char *str)
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
if (63 == fields[j].charsetnr)
{
v = [NSData dataWithBytes: p length: size];
}
else
{
v = [[[NSString alloc] initWithBytes: p
length: size
encoding: NSUTF8StringEncoding] autorelease];
}
v = [NSData dataWithBytes: p length: size];
break;
default:
if (YES == _shouldTrim)
{
trim((char*)p);
}
v = [NSString stringWithUTF8String: (char*)p];
trim(p);
v = [NSString stringWithUTF8String: p];
break;
}
}
values[j] = v;
}
record = [rtype newWithValues: values
keys: keys
count: fieldCount];
record = [SQLRecord newWithValues: values
keys: keys
count: fieldCount];
[records addObject: record];
[record release];
RELEASE(record);
}
}
else
{
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];
}
[NSException raise: SQLException format: @"%s",
mysql_error(connection)];
}
}
NS_HANDLER
@ -472,7 +430,7 @@ static unsigned int trim(char *str)
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
if ([self debugging] > 0)
{
@ -483,20 +441,19 @@ static unsigned int trim(char *str)
{
mysql_free_result(result);
}
[records release];
records = nil;
[localException retain];
[arp release];
[localException autorelease];
DESTROY(records);
RETAIN (localException);
RELEASE (arp);
AUTORELEASE (localException);
[localException raise];
}
NS_ENDHANDLER
[arp release];
DESTROY(arp);
if (result != 0)
{
mysql_free_result(result);
}
return [records autorelease];
return AUTORELEASE(records);
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
@ -549,38 +506,5 @@ 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

271
Oracle.pm
View file

@ -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 Lesser General Public
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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.
@ -216,7 +216,7 @@ void SQLClientOracleErrorHandler()
}
}
- (NSInteger) backendExecute: (NSArray*)info
- (void) backendExecute: (NSArray*)info
{
EXEC SQL BEGIN DECLARE SECTION;
char *statement;
@ -240,7 +240,7 @@ void SQLClientOracleErrorHandler()
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
if ([self backendConnect] == NO)
{
[NSException raise: SQLException
format: @"(Oracle) Unable to connect to database"];
@ -273,7 +273,7 @@ void SQLClientOracleErrorHandler()
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
/*
* remove line number information from database exception message
@ -300,7 +300,6 @@ void SQLClientOracleErrorHandler()
}
NS_ENDHANDLER
DESTROY(arp);
return -1;
}
static unsigned int trim(char *str)
@ -327,7 +326,7 @@ static unsigned int trim(char *str)
return (str - start);
}
- (NSMutableArray*) backendQuery: (NSString*)stmt recordClass: (Class)rClass
- (NSMutableArray*) backendQuery: (NSString*)stmt
{
EXEC SQL BEGIN DECLARE SECTION;
int count;
@ -369,7 +368,7 @@ static unsigned int trim(char *str)
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
if ([self backendConnect] == NO)
{
[NSException raise: SQLException
format: @"(Oracle) Unable to connect to database"];
@ -554,10 +553,7 @@ static unsigned int trim(char *str)
/* \0-pad the string. */
aString[octetLength] = '\0';
if (YES == _shouldTrim)
{
trim (aString);
}
trim (aString);
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
@ -588,10 +584,7 @@ static unsigned int trim(char *str)
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aString = DATA;
aString[octetLength] = '\0';
if (YES == _shouldTrim)
{
trim (aString);
}
trim (aString);
v = [NSString stringWithUTF8String: aString];
free (aString);
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",
@ -604,9 +597,9 @@ static unsigned int trim(char *str)
keys[index - 1] = [NSString stringWithUTF8String:
fieldName];
}
record = [rClass newWithValues: values
keys: keys
count: count];
record = [SQLRecord newWithValues: values
keys: keys
count: count];
[records addObject: record];
RELEASE(record);
}
@ -651,7 +644,7 @@ static unsigned int trim(char *str)
}
if ([e isEqual: SQLConnectionException] == YES)
{
[self disconnect];
[self backendDisconnect];
}
}
NS_ENDHANDLER
@ -674,7 +667,7 @@ static unsigned int trim(char *str)
if ([n isEqual: SQLConnectionException] == YES)
{
_inTransaction = NO;
[self disconnect];
[self backendDisconnect];
}
/*
@ -899,15 +892,14 @@ 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 expand buffer. */
NSCalendarDate *d;
BOOL milliseconds = NO;
BOOL timezone = NO;
NSString *s;
int i;
int e;
char buf[l+32]; /* Allow space to expend buffer. */
NSString *s;
int i;
memcpy(buf, b, l);
b = buf;
@ -930,153 +922,98 @@ static unsigned int trim(char *str)
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
s = [self dbToStringFromBuffer: b length: l];
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
{
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';
}
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;
/*
* 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';
}
}
}
if (isdigit(b[i-1]))
{
/*
* Make space between seconds and timezone.
*/
memmove(&b[i+1], &b[i], l - i);
b[i++] = ' ';
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 (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';
}
}
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];
}
/* 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];
}
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;
}
/**

View file

@ -1,3 +0,0 @@
import gnu.gnustep.Performance.*;

1829
Postgres.m

File diff suppressed because it is too large Load diff

49
README
View file

@ -49,13 +49,6 @@ 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.
@ -63,16 +56,16 @@ Current backend bundles are -
Where can you get it? How can you install it?
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).
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
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.
* The Performance library (from the dev-libs area in GNUstep CVS)
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.
* 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.
@ -87,3 +80,35 @@ 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

File diff suppressed because it is too large Load diff

View file

@ -1,81 +0,0 @@
{ /* -*-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"
);
}
);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

370
SQLite.m
View file

@ -1,370 +0,0 @@
/* -*-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 Normal file
View file

@ -0,0 +1,530 @@
/**
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 ('&lt;!--' and '--&gt;') 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 Normal file

File diff suppressed because it is too large Load diff

248
WebServerBundles.m Normal file
View file

@ -0,0 +1,248 @@
/**
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 Executable file

File diff suppressed because it is too large Load diff

View file

@ -1,117 +1,13 @@
/* 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
/* config.h.in. Generated from configure.in by autoheader. */
/* 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

View file

@ -1,10 +1,6 @@
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 Executable file

File diff suppressed because it is too large Load diff

7573
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -3,499 +3,157 @@ dnl Process this file with autoconf to produce configure.
AC_INIT(SQLClient.h)
AC_CONFIG_HEADER(config.h)
if test -z "$GNUSTEP_MAKEFILES"; then
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
export GNUSTEP_MAKEFILES
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"
fi
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)
],
echo "Postgres development support"
AC_ARG_WITH(postgres-dir,
[ --with-postgres-dir=PATH specify postgres installation dir],
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
# 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])
AC_CHECK_HEADERS(mysql/mysql.h)
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
MYSQL=yes
else
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
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
echo "*********************************************************"
echo "Unable to locate mysqlclient headers (are they installed)"
echo "*********************************************************"
fi
if test "$MYSQL" = "yes"; then
AC_CHECK_LIB(mysqlclient,mysql_init)
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
MYSQL=
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
echo "******************************************************"
echo "Unable to locate mysqlclient library (is it installed)"
echo "******************************************************"
fi
fi
AC_SUBST(MYSQL)
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=
AC_CHECK_HEADERS(libpq-fe.h)
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
POSTGRES=yes
else
AC_MSG_RESULT([no: build if possible])
AC_CHECK_HEADERS(sqlite3.h)
if test "$ac_cv_header_sqlite3_h" = "yes"; then
SQLITE=yes
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
else
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
CPPFLAGS="$CPPFLAGS -I/usr/include/pgsql"
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
CPPFLAGS="$save_CPPFLAGS"
CPPFLAGS="$old"
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
INCD="$INCD -I/usr/include/pgsql"
POSTGRES=yes
fi
fi
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
if test -d /usr/local/lib/pgsql ; then
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
LIBD="$LIBD -L/usr/local/lib/pgsql"
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
if test -d /usr/local/pgsql/lib ; then
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
LIBD="$LIBD -L/usr/local/pgsql/lib"
fi
CPPFLAGS="$save_CPPFLAGS"
POSTGRES=
echo "**************************************************************"
echo "Unable to locate libpq (postgres) headers (are they installed)"
echo "**************************************************************"
fi
fi
AC_CHECK_LIB(pq,PQfformat)
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
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
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
else
CPPFLAGS="$save_CPPFLAGS"
ECPG=
echo "*************************************************************"
echo "Unable to locate ecpg (postgres) headers (are they installed)"
echo "*************************************************************"
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
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
# End POSTGRES checks
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
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)
@ -503,13 +161,6 @@ 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
@ -517,13 +168,6 @@ 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 Executable file
View file

@ -0,0 +1,250 @@
#! /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

View file

@ -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 Lesser General Public
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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$
*/
#import <Foundation/Foundation.h>
#import "SQLClient.h"
#include <Foundation/Foundation.h>
#include "SQLClient.h"
int
main()
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(pool);
SQLClient *db;
NSUserDefaults *defs;
NSMutableArray *records;
@ -109,7 +109,7 @@ main()
if ([records count] != 2)
{
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
NSLog(@"Expected 2 records but got %u", [records count]);
}
else
{
@ -128,7 +128,7 @@ main()
NSLog(@"Records - %@", records);
[pool release];
RELEASE(pool);
return 0;
}

View file

@ -1,338 +0,0 @@
/**
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;
}

View file

@ -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 Lesser General Public
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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$
*/
#import <Foundation/Foundation.h>
#import "SQLClient.h"
#include <Foundation/Foundation.h>
#include "SQLClient.h"
int
main()
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(pool);
SQLClient *db;
NSUserDefaults *defs;
NSMutableArray *records;
@ -109,7 +109,7 @@ main()
if ([records count] != 2)
{
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
NSLog(@"Expected 2 records but got %u", [records count]);
}
else
{
@ -128,7 +128,7 @@ main()
NSLog(@"Records - %@", records);
[pool release];
RELEASE(pool);
return 0;
}

View file

@ -7,42 +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 Lesser General Public
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
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.
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
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$
*/
#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
#include <Foundation/Foundation.h>
#include "SQLClient.h"
int
main()
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
SQLClientPool *sp;
CREATE_AUTORELEASE_POOL(pool);
SQLClient *db;
NSUserDefaults *defs;
NSMutableArray *records;
@ -51,7 +38,6 @@ main()
unsigned int i;
NSData *data;
NSString *name;
Logger *l;
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults:
@ -69,84 +55,7 @@ main()
nil]
];
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];
db = [SQLClient clientWithConfiguration: nil name: @"test"];
if ((name = [defs stringForKey: @"Producer"]) != nil)
{
@ -160,7 +69,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:
@ -184,35 +93,23 @@ main()
NSLog(@"Start producing");
for (i = 0; i < 100000; i++)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(arp);
NSString *destination = [NSString stringWithFormat: @"%d", i];
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
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];
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
@"'helo there'", @")", nil];
RELEASE(arp);
}
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;)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
CREATE_AUTORELEASE_POOL(arp);
unsigned count;
int j;
@ -225,7 +122,7 @@ main()
if (count == 0)
{
[db commit];
[NSThread sleepForTimeInterval: 1.0];
sleep(1);
[db begin];
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
[db quote: name],
@ -254,7 +151,7 @@ main()
}
[db commit];
i += count;
[arp release];
RELEASE(arp);
}
NSLog(@"End consuming (%d records)", i);
/*
@ -267,20 +164,6 @@ 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;
@ -296,64 +179,31 @@ 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,"
@"extra1 int[],"
@"extra2 varchar[],"
@"extra3 bytea[],"
@"extra4 boolean[],"
@"extra5 timestamp with time zone[]"
@"b bytea"
@")",
nil];
if (1 != [db execute: @"INSERT into xxx (id, k, char1, boolval, intval,"
@" when1, when2, b, extra1, extra2, extra3, extra4, extra5) "
@"values (1,"
@"'{hello', "
[db execute: @"insert into xxx "
@"(k, char1, boolval, intval, when1, when2, b) "
@"values ("
@"'hello', "
@"'X', "
@"TRUE, "
@"1, "
@"CURRENT_TIMESTAMP, "
@"CURRENT_TIMESTAMP, ",
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,"
data,
@")",
nil];
[db execute: @"insert into xxx "
@"(k, char1, boolval, intval, when1, when2, b) "
@"values ("
@"'hello', "
@"'X', "
@"TRUE, "
@ -363,46 +213,17 @@ 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];
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"];
records = [db query: @"select * from xxx", nil];
[db execute: @"drop table xxx", nil];
if ([records count] != 3)
if ([records count] != 2)
{
NSLog(@"Expected 3 records but got %lu", [records count]);
NSLog(@"Expected 2 records but got %u", [records count]);
}
else
{
int i;
record = [records objectAtIndex: 0];
if ([[record objectForKey: @"b"] isEqual: data] == NO)
{
@ -414,105 +235,12 @@ 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 - %@", [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);
NSLog(@"Records - %@", records);
}
NSLog(@"Pool stats:\n%@", [sp statistics]);
[pool release];
RELEASE(pool);
return 0;
}

View file

@ -1,129 +0,0 @@
/**
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;
}