SQLClient-1.7.3/ 0000775 0000765 0000765 00000000000 12341127267 013223 5 ustar brains99 brains99 SQLClient-1.7.3/testJDBC.m 0000664 0000765 0000765 00000021054 11300754615 015002 0 ustar brains99 brains99 /**
Copyright (C) 2006 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
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
#import
#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];
sleep(1);
[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");
sleep(2);
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 %u", [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;
}
SQLClient-1.7.3/.cvsignore 0000664 0000765 0000765 00000000217 10377047517 015231 0 ustar brains99 brains99 *obj
ECPG.bundle
ECPG.m
MySQL.bundle
Oracle.bundle
Oracle.lis
Oracle.m
Postgres.bundle
SQLClient
config.h
config.log
config.make
config.status
SQLClient-1.7.3/testECPG.m 0000664 0000765 0000765 00000006521 12106213333 015010 0 ustar brains99 brains99 /**
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2013-02-11 16:05:47 +0000 (Mon, 11 Feb 2013) $ $Revision: 36111 $
*/
#import
#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:
@"template1@localhost", @"Database",
@"postgres", @"User",
@"postgres", @"Password",
@"ECPG", @"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), "
@"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];
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;
}
SQLClient-1.7.3/configure 0000775 0000765 0000765 00000727516 11641375200 015146 0 ustar brains99 brains99 #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
if test "x$CONFIG_SHELL" = x; then
if (eval ":") 2>/dev/null; then
as_have_required=yes
else
as_have_required=no
fi
if test $as_have_required = yes && (eval ":
(as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=\$LINENO
as_lineno_2=\$LINENO
test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
") 2> /dev/null; then
:
else
as_candidate_shells=
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
case $as_dir in
/*)
for as_base in sh bash ksh sh5; do
as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
done;;
esac
done
IFS=$as_save_IFS
for as_shell in $as_candidate_shells $SHELL; do
# Try only shells that exist, to save several forks.
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ ("$as_shell") 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
_ASEOF
}; then
CONFIG_SHELL=$as_shell
as_have_required=yes
if { "$as_shell" 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
(as_func_return () {
(exit $1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = "$1" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test $exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
_ASEOF
}; then
break
fi
fi
done
if test "x$CONFIG_SHELL" != x; then
for as_var in BASH_ENV ENV
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fi
if test $as_have_required = no; then
echo This script requires a shell more modern than all the
echo shells that I found on your system. Please install a
echo modern shell, or manually run the script under such a
echo shell if you do have one.
{ (exit 1); exit 1; }
fi
fi
fi
(eval "as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0") || {
echo No shell found that supports shell functions.
echo Please tell bug-autoconf@gnu.org about your system,
echo including any error possibly output before this message.
echo This can help us improve future autoconf versions.
echo Configuration will now proceed without shell functions.
}
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 7<&0 &1
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME=
PACKAGE_TARNAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_BUGREPORT=
ac_unique_file="SQLClient.h"
# Factoring default headers for most tests.
ac_includes_default="\
#include
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_SYS_STAT_H
# include
#endif
#ifdef STDC_HEADERS
# include
# include
#else
# ifdef HAVE_STDLIB_H
# include
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include
# endif
# include
#endif
#ifdef HAVE_STRINGS_H
# include
#endif
#ifdef HAVE_INTTYPES_H
# include
#endif
#ifdef HAVE_STDINT_H
# include
#endif
#ifdef HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='LTLIBOBJS
LIBOBJS
LIBD
INCD
ORACLE_HOME
ECPG
POSTGRES
SQLITE
MYSQL
JDBC_VM_LIBDIRS
JDBC_VM_LIBS
JDBC
EGREP
GREP
CPP
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
with_additional_include
with_additional_lib
with_postgres_dir
enable_jdbc_bundle
with_jre_architecture
enable_mysql_bundle
enable_sqllite_bundle
enable_postgres_bundle
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) { $as_echo "$as_me: error: unrecognized option: $ac_option
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; }
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
{ (exit 1); exit 1; }; }
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
{ $as_echo "$as_me: error: missing argument to $ac_option" >&2
{ (exit 1); exit 1; }; }
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
{ (exit 1); exit 1; }; } ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
{ $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; }
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used." >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
{ $as_echo "$as_me: error: working directory cannot be determined" >&2
{ (exit 1); exit 1; }; }
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
{ $as_echo "$as_me: error: pwd does not report name of working directory" >&2
{ (exit 1); exit 1; }; }
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then the parent directory.
ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_myself" : 'X\(//\)[^/]' \| \
X"$as_myself" : 'X\(//\)$' \| \
X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r "$srcdir/$ac_unique_file"; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
{ $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
{ (exit 1); exit 1; }; }
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
{ (exit 1); exit 1; }; }
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
eval ac_env_${ac_var}_set=\${${ac_var}+set}
eval ac_env_${ac_var}_value=\$${ac_var}
eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
eval ac_cv_env_${ac_var}_value=\$${ac_var}
done
#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print \`checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_ACEOF
cat <<\_ACEOF
_ACEOF
fi
if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--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.
--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.
--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.
--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.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--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
--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
--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)
--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.
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested configure.
if test -f "$ac_srcdir/configure.gnu"; then
echo &&
$SHELL "$ac_srcdir/configure.gnu" --help=recursive
elif test -f "$ac_srcdir/configure"; then
echo &&
$SHELL "$ac_srcdir/configure" --help=recursive
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit
fi
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*\'*)
ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
2)
ac_configure_args1="$ac_configure_args1 '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
ac_configure_args="$ac_configure_args '$ac_arg'"
;;
esac
done
done
$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
cat <<\_ASBOX
## ---------------- ##
## Cache variables. ##
## ---------------- ##
_ASBOX
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
cat <<\_ASBOX
## ----------------- ##
## Output variables. ##
## ----------------- ##
_ASBOX
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
cat <<\_ASBOX
## ------------------- ##
## File substitutions. ##
## ------------------- ##
_ASBOX
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
cat <<\_ASBOX
## ----------- ##
## confdefs.h. ##
## ----------- ##
_ASBOX
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
ac_site_file1=$CONFIG_SITE
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test -r "$ac_site_file"; then
{ $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special
# files actually), so we avoid doing that.
if test -f "$cache_file"; then
{ $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val=\$ac_cv_env_${ac_var}_value
eval ac_new_val=\$ac_env_${ac_var}_value
case $ac_old_set,$ac_new_set in
set,)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
{ { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h"
if test -z "$GNUSTEP_MAKEFILES"; then
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
export GNUSTEP_MAKEFILES
fi
if test -z "$GNUSTEP_MAKEFILES"; then
{ { $as_echo "$as_me:$LINENO: 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!" >&5
$as_echo "$as_me: 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!" >&2;}
{ (exit 1); exit 1; }; }
else
. $GNUSTEP_MAKEFILES/GNUstep.sh
fi
#--------------------------------------------------------------------
# Check whether --with-additional-include was given.
if test "${with_additional_include+set}" = set; then
withval=$with_additional_include; additional_include="$withval"
else
additional_include="no"
fi
if test "$additional_include" != "no"; then
CPPFLAGS="$CPPFLAGS $additional_include"
INCD="$INCD $additional_include"
fi
# Check whether --with-additional-lib was given.
if test "${with_additional_lib+set}" = set; then
withval=$with_additional_lib; additional_lib="$withval"
else
additional_lib="no"
fi
if test "$additional_lib" != "no"; then
LDFLAGS="$LDFLAGS $additional_lib"
LIBD="$LIBD $additional_lib"
fi
# Check whether --with-postgres-dir was given.
if test "${with_postgres_dir+set}" = set; then
withval=$with_postgres_dir; postgres_topdir="$withval"
else
postgres_topdir="no"
fi
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_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&5
$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
# Provide some information about the compiler.
$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
{ (ac_try="$ac_compiler --version >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler --version >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -v >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -v >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -V >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -V >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { (ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
if test -z "$ac_file"; then
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C compiler cannot create executables
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }; }
fi
ac_exeext=$ac_cv_exeext
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
if { ac_try='./$ac_file'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
rm -f conftest$ac_cv_exeext
{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if test "${ac_cv_objext+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if test "${ac_cv_c_compiler_gnu+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_compiler_gnu=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if test "${ac_cv_prog_cc_g+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
CFLAGS=""
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if test "${ac_cv_prog_cc_c89+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_c89=$ac_arg
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:$LINENO: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:$LINENO: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
:
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if test "${ac_cv_path_GREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if test "${ac_cv_path_EGREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if test "${ac_cv_header_stdc+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_header_stdc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then
:
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
:
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_header_stdc=no
fi
rm -rf conftest.dSYM
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
cat >>confdefs.h <<\_ACEOF
#define STDC_HEADERS 1
_ACEOF
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
eval "$as_ac_Header=yes"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_Header=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in stdio.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
{ $as_echo "$as_me:$LINENO: checking if Jdbc support was manually disabled" >&5
$as_echo_n "checking if Jdbc support was manually disabled... " >&6; }
# Check whether --enable-jdbc-bundle was given.
if test "${enable_jdbc_bundle+set}" = set; then
enableval=$enable_jdbc_bundle; ac_cv_jdbc_bundle=$enableval
else
ac_cv_jdbc_bundle="yes"
fi
if test "$ac_cv_jdbc_bundle" = "no"; then
{ $as_echo "$as_me:$LINENO: result: yes: disabled from the command-line" >&5
$as_echo "yes: disabled from the command-line" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no: build if possible" >&5
$as_echo "no: build if possible" >&6; }
# 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
# Check whether --with-jre-architecture was given.
if test "${with_jre_architecture+set}" = set; then
withval=$with_jre_architecture; jre_architecture="$withval"
else
jre_architecture=""
fi
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
for ac_header in jni.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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"
{ $as_echo "$as_me:$LINENO: checking for JNI_CreateJavaVM in -ljvm" >&5
$as_echo_n "checking for JNI_CreateJavaVM in -ljvm... " >&6; }
if test "${ac_cv_lib_jvm_JNI_CreateJavaVM+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ljvm $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char JNI_CreateJavaVM ();
int
main ()
{
return JNI_CreateJavaVM ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_jvm_JNI_CreateJavaVM=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_jvm_JNI_CreateJavaVM=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_jvm_JNI_CreateJavaVM" >&5
$as_echo "$ac_cv_lib_jvm_JNI_CreateJavaVM" >&6; }
if test "x$ac_cv_lib_jvm_JNI_CreateJavaVM" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBJVM 1
_ACEOF
LIBS="-ljvm $LIBS"
fi
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
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
CPPFLAGS="$save_CPPFLAGS"
fi
{ $as_echo "$as_me:$LINENO: checking if Mysql support was manually disabled" >&5
$as_echo_n "checking if Mysql support was manually disabled... " >&6; }
# Check whether --enable-mysql-bundle was given.
if test "${enable_mysql_bundle+set}" = set; then
enableval=$enable_mysql_bundle; ac_cv_mysql_bundle=$enableval
else
ac_cv_mysql_bundle="yes"
fi
if test "$ac_cv_mysql_bundle" = "no"; then
{ $as_echo "$as_me:$LINENO: result: yes: disabled from the command-line" >&5
$as_echo "yes: disabled from the command-line" >&6; }
MYSQL=
else
{ $as_echo "$as_me:$LINENO: result: no: build if possible" >&5
$as_echo "no: build if possible" >&6; }
for ac_header in mysql/mysql.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
MYSQL=yes
else
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
{ $as_echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; }
if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmysqlclient $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char mysql_init ();
int
main ()
{
return mysql_init ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_mysqlclient_mysql_init=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_mysqlclient_mysql_init=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5
$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; }
if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBMYSQLCLIENT 1
_ACEOF
LIBS="-lmysqlclient $LIBS"
fi
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
MYSQL=
echo "******************************************************"
echo "Unable to locate mysqlclient library (is it installed)"
echo "******************************************************"
fi
fi
fi
{ $as_echo "$as_me:$LINENO: checking if Sqllite support was manually disabled" >&5
$as_echo_n "checking if Sqllite support was manually disabled... " >&6; }
# Check whether --enable-sqllite-bundle was given.
if test "${enable_sqllite_bundle+set}" = set; then
enableval=$enable_sqllite_bundle; ac_cv_sqllite_bundle=$enableval
else
ac_cv_sqllite_bundle="yes"
fi
if test "$ac_cv_sqllite_bundle" = "no"; then
{ $as_echo "$as_me:$LINENO: result: yes: disabled from the command-line" >&5
$as_echo "yes: disabled from the command-line" >&6; }
SQLLITE=
else
{ $as_echo "$as_me:$LINENO: result: no: build if possible" >&5
$as_echo "no: build if possible" >&6; }
for ac_header in sqlite3.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_header_sqlite3_h" = "yes"; then
SQLITE=yes
else
SQLITE=
echo "*****************************************************"
echo "Unable to locate sqlite3 headers (are they installed)"
echo "*****************************************************"
fi
if test "$SQLITE" = "yes"; then
{ $as_echo "$as_me:$LINENO: checking for sqlite3_open in -lsqlite3" >&5
$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; }
if test "${ac_cv_lib_sqlite3_sqlite3_open+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsqlite3 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sqlite3_open ();
int
main ()
{
return sqlite3_open ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_sqlite3_sqlite3_open=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_sqlite3_sqlite3_open=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5
$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; }
if test "x$ac_cv_lib_sqlite3_sqlite3_open" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSQLITE3 1
_ACEOF
LIBS="-lsqlite3 $LIBS"
fi
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
{ $as_echo "$as_me:$LINENO: checking if Postgres support was manually disabled" >&5
$as_echo_n "checking if Postgres support was manually disabled... " >&6; }
# Check whether --enable-postgres-bundle was given.
if test "${enable_postgres_bundle+set}" = set; then
enableval=$enable_postgres_bundle; ac_cv_postgres_bundle=$enableval
else
ac_cv_postgres_bundle="yes"
fi
if test "$ac_cv_postgres_bundle" = "no"; then
{ $as_echo "$as_me:$LINENO: result: yes: disabled from the command-line" >&5
$as_echo "yes: disabled from the command-line" >&6; }
POSTGRES=
else
{ $as_echo "$as_me:$LINENO: result: no: build if possible" >&5
$as_echo "no: build if possible" >&6; }
# Start POSTGRES checks
POSTGRES=
if test "$POSTGRES" = ""; then
for ac_header in libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
POSTGRES=yes
fi
fi
if test "$ECPG" = ""; then
for ac_header in ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$ac_cv_header_ecpglib_h" = "yes"; then
ECPG=yes
fi
fi
if test "$POSTGRES" = ""; then
for ac_header in /usr/include/postgresql/libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$ECPG" = ""; then
for ac_header in /usr/include/postgresql/ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$POSTGRES" = ""; then
for ac_header in /usr/include/postgresql/8.0/libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$ECPG" = ""; then
for ac_header in /usr/include/postgresql/8.0/ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$POSTGRES" = ""; then
for ac_header in /usr/include/pgsql/libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
CPPFLAGS="$save_CPPFLAGS"
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 "$ECPG" = ""; then
for ac_header in /usr/include/pgsql/ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$POSTGRES" = ""; then
for ac_header in /usr/local/include/pgsql/libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$ECPG" = ""; then
for ac_header in /usr/local/include/pgsql/ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$POSTGRES" = ""; then
for ac_header in /usr/local/pgsql/include/libpq-fe.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$ECPG" = ""; then
for ac_header in /usr/local/pgsql/include/ecpglib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
as_val=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
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 "$POSTGRES" = ""; then
echo "**************************************************************"
echo "Unable to locate libpq (postgres) headers (are they installed)"
echo "**************************************************************"
fi
if test "$ECPG" = ""; then
echo "*************************************************************"
echo "Unable to locate ecpg (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"
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
{ $as_echo "$as_me:$LINENO: checking for PQfformat in -lpq" >&5
$as_echo_n "checking for PQfformat in -lpq... " >&6; }
if test "${ac_cv_lib_pq_PQfformat+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpq $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char PQfformat ();
int
main ()
{
return PQfformat ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_pq_PQfformat=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pq_PQfformat=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pq_PQfformat" >&5
$as_echo "$ac_cv_lib_pq_PQfformat" >&6; }
if test "x$ac_cv_lib_pq_PQfformat" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPQ 1
_ACEOF
LIBS="-lpq $LIBS"
fi
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
POSTGRES=
{ $as_echo "$as_me:$LINENO: checking for PQclear in -lpq" >&5
$as_echo_n "checking for PQclear in -lpq... " >&6; }
if test "${ac_cv_lib_pq_PQclear+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpq $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char PQclear ();
int
main ()
{
return PQclear ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_pq_PQclear=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pq_PQclear=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pq_PQclear" >&5
$as_echo "$ac_cv_lib_pq_PQclear" >&6; }
if test "x$ac_cv_lib_pq_PQclear" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPQ 1
_ACEOF
LIBS="-lpq $LIBS"
fi
echo "******************************************************"
if test "$ac_cv_lib_pq_PQclear" != "yes"; then
echo "Unable to locate postgres pq library (is it installed)"
else
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
for ac_func in PQescapeStringConn
do
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
$as_echo_n "checking for $ac_func... " >&6; }
if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case declares $ac_func.
For example, HP-UX 11i declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $ac_func
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$ac_func || defined __stub___$ac_func
choke me
#endif
int
main ()
{
return $ac_func ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
eval "$as_ac_var=yes"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
ac_res=`eval 'as_val=${'$as_ac_var'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
as_val=`eval 'as_val=${'$as_ac_var'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
fi
{ $as_echo "$as_me:$LINENO: checking for ECPGconnect in -lecpg" >&5
$as_echo_n "checking for ECPGconnect in -lecpg... " >&6; }
if test "${ac_cv_lib_ecpg_ECPGconnect+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lecpg $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ECPGconnect ();
int
main ()
{
return ECPGconnect ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_ecpg_ECPGconnect=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_ecpg_ECPGconnect=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ecpg_ECPGconnect" >&5
$as_echo "$ac_cv_lib_ecpg_ECPGconnect" >&6; }
if test "x$ac_cv_lib_ecpg_ECPGconnect" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBECPG 1
_ACEOF
LIBS="-lecpg $LIBS"
fi
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 POSTGRES checks
fi
ORACLE_HOME=
if test "$JDBC" = "yes"; then
BUNDLE="The JDBC backend bundle will be built"
else
BUNDLE="The JDBC backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
if test "$MYSQL" = "yes"; then
BUNDLE="The MySQL backend bundle will be built"
else
BUNDLE="The MySQL backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
if test "$SQLITE" = "yes"; then
BUNDLE="The SQLite backend bundle will be built"
else
BUNDLE="The SQLite backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
if test "$POSTGRES" = "yes"; then
BUNDLE="The Postgres backend bundle will be built"
else
BUNDLE="The Postgres backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
if test "$ECPG" = "yes"; then
BUNDLE="The ECPG backend bundle will be built"
else
BUNDLE="The ECPG backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
if test "$ORACLE" = "yes"; then
BUNDLE="The Oracle backend bundle will be built"
else
BUNDLE="The Oracle backend bundle will NOT be built"
fi
{ $as_echo "$as_me:$LINENO: result: ${BUNDLE}" >&5
$as_echo "${BUNDLE}" >&6; }
ac_config_files="$ac_config_files config.make"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;; #(
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
test "x$cache_file" != "x/dev/null" &&
{ $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
cat confcache >$cache_file
else
{ $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
# Save the log message, to keep $[0] and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by $as_me, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTION]... [FILE]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
-q, --quiet, --silent
do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to ."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
config.status
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
Copyright (C) 2008 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
{ $as_echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { $as_echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"config.make") CONFIG_FILES="$CONFIG_FILES config.make" ;;
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp=
trap 'exit_status=$?
{ test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} ||
{
$as_echo "$as_me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr='
'
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\).*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\).*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
|| { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
$as_echo "$as_me: error: could not setup config files machinery" >&2;}
{ (exit 1); exit 1; }; }
_ACEOF
# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/
s/:*\${srcdir}:*/:/
s/:*@srcdir@:*/:/
s/^\([^=]*=[ ]*\):*/\1/
s/:*$//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_t=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_t"; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' >$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
{ { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
{ (exit 1); exit 1; }; }
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
{ (exit 1); exit 1; }; };;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
{ { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
{ (exit 1); exit 1; }; };;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
ac_file_inputs="$ac_file_inputs '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:$LINENO: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
{ as_dir="$ac_dir"
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p
'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_datarootdir_hack='
s&@datadir@&$datadir&g
s&@docdir@&$docdir&g
s&@infodir@&$infodir&g
s&@localedir@&$localedir&g
s&@mandir@&$mandir&g
s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&2;}
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out" && rm -f "$tmp/out";;
*) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
esac \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
} >"$tmp/config.h" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$tmp/config.h" "$ac_file" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
|| { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
$as_echo "$as_me: error: could not create -" >&2;}
{ (exit 1); exit 1; }; }
fi
;;
esac
done # for ac_tag
{ (exit 0); exit 0; }
_ACEOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
{ { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
SQLClient-1.7.3/SQLClient.m 0000664 0000765 0000765 00000237401 12336347526 015214 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClient for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2014-05-19 10:31:02 +0100 (Mon, 19 May 2014) $ $Revision: 37893 $
*/
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#define SQLCLIENT_PRIVATE @public
#include
#include "SQLClient.h"
#if defined(GNUSTEP_BASE_LIBRARY)
#define SUBCLASS_RESPONSIBILITY [self subclassResponsibility: _cmd];
#else
#define SUBCLASS_RESPONSIBILITY
#endif
NSString * const SQLClientDidConnectNotification
= @"SQLClientDidConnectNotification";
NSString * const SQLClientDidDisconnectNotification
= @"SQLClientDidDisconnectNotification";
static NSNull *null = nil;
static NSArray *queryModes = nil;
static NSThread *mainThread = nil;
static Class NSStringClass = 0;
static Class NSArrayClass = 0;
static Class NSDateClass = 0;
static Class NSSetClass = 0;
@interface _ConcreteSQLRecord : SQLRecord
{
unsigned count;
}
@end
@interface CacheQuery : NSObject
{
@public
NSString *query;
id recordType;
id listType;
unsigned lifetime;
}
@end
@implementation CacheQuery
- (void) dealloc
{
[query release];
[super dealloc];
}
@end
@interface SQLClientPool : NSObject
{
unsigned pool;
NSString *name;
NSString *serv;
NSString *user;
NSString *pass;
NSString *path;
NSHashTable *idle;
NSHashTable *used;
}
- (BOOL) isSingle;
- (BOOL) makeIdle: (SQLClient*)c;
- (BOOL) makeUsed: (SQLClient*)c;
- (void) setConfiguration: (NSDictionary*)o;
@end
@implementation SQLClientPool
- (void) dealloc
{
if (idle != 0)
{
NSFreeHashTable(idle);
idle = 0;
}
if (used != 0)
{
NSFreeHashTable(used);
used = 0;
}
[name release]; name = nil;
[serv release]; serv = nil;
[user release]; user = nil;
[pass release]; pass = nil;
[path release]; path = nil;
[super dealloc];
}
- (id) initWithConfiguration: (NSDictionary*)config
name: (NSString*)reference
{
name = [reference copy];
idle = NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 16);
used = NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 16);
[self setConfiguration: config];
return self;
}
- (BOOL) isSingle
{
if (pool == 1)
{
return YES;
}
return NO;
}
- (BOOL) makeIdle: (SQLClient*)c
{
if (NSHashGet(idle, (void*)c) == (void*)c)
{
return YES; // Already idle
}
if (NSHashGet(used, (void*)c) == (void*)c)
{
NSHashRemove(used, (void*)c);
}
if (NSCountHashTable(idle) + NSCountHashTable(used) < pool)
{
NSHashInsert(idle, (void*)c);
return YES;
}
return NO;
}
- (BOOL) makeUsed: (SQLClient*)c
{
if (NSHashGet(used, (void*)c) == (void*)c)
{
return YES; // Already used
}
if (NSHashGet(idle, (void*)c) == (void*)c)
{
NSHashRemove(idle, (void*)c);
}
if (NSCountHashTable(idle) + NSCountHashTable(used) < pool)
{
NSHashInsert(used, (void*)c);
return YES;
}
return NO;
}
- (void) setConfiguration: (NSDictionary*)o
{
NSDictionary *d;
NSString *s;
BOOL change = NO;
int capacity;
/*
* get dictionary containing config info for this client by name.
*/
d = [o objectForKey: @"SQLClientReferences"];
if ([d isKindOfClass: [NSDictionary class]] == NO)
{
d = nil;
}
d = [d objectForKey: name];
if ([d isKindOfClass: [NSDictionary class]] == NO)
{
d = nil;
}
s = [d objectForKey: @"ServerType"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"Postgres";
}
if (s != serv && [s isEqual: serv] == NO)
{
s = [s copy];
[serv release];
serv = s;
change = YES;
}
s = [d objectForKey: @"Database"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"Database"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = nil;
}
}
if (s != path && [s isEqual: path] == NO)
{
s = [s copy];
[path release];
path = s;
change = YES;
}
s = [d objectForKey: @"User"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"User"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"";
}
}
if (s != user && [s isEqual: user] == NO)
{
s = [s copy];
[user release];
user = s;
change = YES;
}
s = [d objectForKey: @"Password"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"Password"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"";
}
}
if (s != pass && [s isEqual: pass] == NO)
{
s = [s copy];
[pass release];
pass = s;
change = YES;
}
s = [d objectForKey: @"Password"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"1";
}
capacity = [s intValue];
if (capacity < 1) capacity = 1;
if (capacity > 100) capacity = 100;
if (change == YES)
{
NSResetHashTable(idle);
NSResetHashTable(used);
}
if (pool > capacity)
{
unsigned ic = NSCountHashTable(idle);
unsigned uc = NSCountHashTable(used);
if (ic + uc > capacity)
{
NSHashEnumerator e = NSEnumerateHashTable(idle);
void *c;
while (ic + uc > capacity
&& (c = NSNextHashEnumeratorItem(&e)) != nil)
{
NSHashRemove(idle, c);
ic--;
}
NSEndHashTableEnumeration(&e);
if (uc > capacity)
{
NSHashEnumerator e = NSEnumerateHashTable(used);
void *c;
while (uc > capacity
&& (c = NSNextHashEnumeratorItem(&e)) != nil)
{
NSHashRemove(used, c);
uc--;
}
NSEndHashTableEnumeration(&e);
}
}
}
pool = capacity;
}
@end
static Class aClass = 0;
static Class rClass = 0;
@implementation SQLRecord
+ (id) allocWithZone: (NSZone*)aZone
{
NSLog(@"Illegal attempt to allocate an SQLRecord");
return nil;
}
+ (void) initialize
{
GSTickerTimeNow();
if (null == nil)
{
null = [NSNull new];
aClass = [NSMutableArray class];
rClass = [_ConcreteSQLRecord class];
}
}
+ (id) newWithValues: (id*)v keys: (NSString**)k count: (unsigned int)c
{
return [rClass newWithValues: v keys: k count: c];
}
- (NSArray*) allKeys
{
unsigned count = [self count];
id buf[count];
while (count-- > 0)
{
buf[count] = [self keyAtIndex: count];
}
return [NSArray arrayWithObjects: buf count: count];
}
- (id) copyWithZone: (NSZone*)z
{
return [self retain];
}
- (NSUInteger) count
{
SUBCLASS_RESPONSIBILITY
return 0;
}
- (NSMutableDictionary*) dictionary
{
unsigned count = [self count];
id keys[count];
id vals[count];
[self getKeys: keys];
[self getObjects: vals];
return [NSMutableDictionary dictionaryWithObjects: vals
forKeys: keys
count: count];
}
- (void) getKeys: (id*)buf
{
unsigned i = [self count];
while (i-- > 0)
{
buf[i] = [self keyAtIndex: i];
}
}
- (void) getObjects: (id*)buf
{
unsigned i = [self count];
while (i-- > 0)
{
buf[i] = [self objectAtIndex: i];
}
}
- (id) init
{
NSLog(@"Illegal attempt to -init an SQLRecord");
[self release];
return nil;
}
- (NSString*) keyAtIndex: (NSUInteger)index
{
SUBCLASS_RESPONSIBILITY
return nil;
}
- (id) objectAtIndex: (NSUInteger)index
{
SUBCLASS_RESPONSIBILITY
return nil;
}
- (id) objectForKey: (NSString*)key
{
unsigned count = [self count];
unsigned pos;
id keys[count];
[self getKeys: keys];
for (pos = 0; pos < count; pos++)
{
if ([key isEqualToString: keys[pos]] == YES)
{
break;
}
}
if (pos == count)
{
for (pos = 0; pos < count; pos++)
{
if ([key caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
{
break;
}
}
}
if (pos == count)
{
return nil;
}
else
{
return [self objectAtIndex: pos];
}
}
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
{
SUBCLASS_RESPONSIBILITY
}
- (void) setObject: (id)anObject forKey: (NSString*)aKey
{
unsigned count = [self count];
unsigned pos;
id keys[count];
if (anObject == nil)
{
anObject = null;
}
[self getKeys: keys];
for (pos = 0; pos < count; pos++)
{
if ([aKey isEqualToString: keys[pos]] == YES)
{
break;
}
}
if (pos == count)
{
for (pos = 0; pos < count; pos++)
{
if ([aKey caseInsensitiveCompare: keys[pos]] == NSOrderedSame)
{
break;
}
}
}
if (pos == count)
{
[NSException raise: NSInvalidArgumentException
format: @"Bad key (%@) in -setObject:forKey:", aKey];
}
else
{
[self replaceObjectAtIndex: pos withObject: anObject];
}
}
- (NSUInteger) sizeInBytes: (NSMutableSet*)exclude
{
NSUInteger size = [super sizeInBytes: exclude];
if (size > 0)
{
NSUInteger pos;
NSUInteger count = [self count];
id vals[count];
[self getObjects: vals];
for (pos = 0; pos < count; pos++)
{
size += [vals[pos] sizeInBytes: exclude];
}
}
return size;
}
@end
@implementation SQLRecord (KVC)
- (void) setValue: (id)aValue forKey: (NSString*)aKey
{
[self setObject: aValue forKey: aKey];
}
- (id) valueForKey: (NSString*)aKey
{
id v = [self objectForKey: aKey];
if (v == nil)
{
v = [super valueForKey: aKey];
}
return v;
}
@end
@implementation _ConcreteSQLRecord
+ (id) newWithValues: (id*)v keys: (NSString**)k count: (unsigned int)c
{
id *ptr;
_ConcreteSQLRecord *r;
unsigned pos;
r = (_ConcreteSQLRecord*)NSAllocateObject(self,
c*2*sizeof(id), NSDefaultMallocZone());
r->count = c;
ptr = ((void*)&(r->count)) + sizeof(r->count);
for (pos = 0; pos < c; pos++)
{
if (v[pos] == nil)
{
ptr[pos] = [null retain];
}
else
{
ptr[pos] = [v[pos] retain];
}
ptr[pos + c] = [k[pos] retain];
}
return r;
}
- (NSArray*) allKeys
{
id *ptr;
ptr = ((void*)&count) + sizeof(count);
return [NSArray arrayWithObjects: &ptr[count] count: count];
}
- (id) copyWithZone: (NSZone*)z
{
return [self retain];
}
- (NSUInteger) count
{
return count;
}
- (void) dealloc
{
id *ptr;
unsigned pos;
ptr = ((void*)&count) + sizeof(count);
for (pos = 0; pos < count; pos++)
{
[ptr[pos] release]; ptr[pos] = nil;
[ptr[count + pos] release]; ptr[count + pos] = nil;
}
[super dealloc];
}
- (NSMutableDictionary*) dictionary
{
NSMutableDictionary *d;
unsigned pos;
id *ptr;
ptr = ((void*)&count) + sizeof(count);
d = [NSMutableDictionary dictionaryWithCapacity: count];
for (pos = 0; pos < count; pos++)
{
[d setObject: ptr[pos] forKey: [ptr[pos + count] lowercaseString]];
}
return d;
}
- (void) getKeys: (id*)buf
{
id *ptr;
unsigned pos;
ptr = ((void*)&count) + sizeof(count);
ptr += count; // Step past objects to keys.
for (pos = 0; pos < count; pos++)
{
buf[pos] = ptr[pos];
}
}
- (void) getObjects: (id*)buf
{
id *ptr;
unsigned pos;
ptr = ((void*)&count) + sizeof(count);
for (pos = 0; pos < count; pos++)
{
buf[pos] = ptr[pos];
}
}
- (id) init
{
NSLog(@"Illegal attempt to -init an SQLRecord");
[self release];
return nil;
}
- (NSString*) keyAtIndex: (NSUInteger)pos
{
id *ptr;
if (pos >= count)
{
[NSException raise: NSRangeException
format: @"Array index too large"];
}
ptr = ((void*)&count) + sizeof(count);
ptr += count;
return ptr[pos];
}
- (id) objectAtIndex: (NSUInteger)pos
{
id *ptr;
if (pos >= count)
{
[NSException raise: NSRangeException
format: @"Array index too large"];
}
ptr = ((void*)&count) + sizeof(count);
return ptr[pos];
}
- (id) objectForKey: (NSString*)key
{
id *ptr;
unsigned int pos;
ptr = ((void*)&count) + sizeof(count);
for (pos = 0; pos < count; pos++)
{
if ([key isEqualToString: ptr[pos + count]] == YES)
{
return ptr[pos];
}
}
for (pos = 0; pos < count; pos++)
{
if ([key caseInsensitiveCompare: ptr[pos + count]] == NSOrderedSame)
{
return ptr[pos];
}
}
return nil;
}
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
{
id *ptr;
if (index >= count)
{
[NSException raise: NSRangeException
format: @"Array index too large"];
}
if (anObject == nil)
{
anObject = null;
}
ptr = ((void*)&count) + sizeof(count);
ptr += index;
[anObject retain];
[*ptr release];
*ptr = anObject;
}
- (void) setObject: (id)anObject forKey: (NSString*)aKey
{
id *ptr;
unsigned int pos;
if (anObject == nil)
{
anObject = null;
}
ptr = ((void*)&count) + sizeof(count);
for (pos = 0; pos < count; pos++)
{
if ([aKey isEqualToString: ptr[pos + count]] == YES)
{
[anObject retain];
[ptr[pos] release];
ptr[pos] = anObject;
return;
}
}
for (pos = 0; pos < count; pos++)
{
if ([aKey caseInsensitiveCompare: ptr[pos + count]] == NSOrderedSame)
{
[anObject retain];
[ptr[pos] release];
ptr[pos] = anObject;
return;
}
}
[NSException raise: NSInvalidArgumentException
format: @"Bad key (%@) in -setObject:forKey:", aKey];
}
- (NSUInteger) sizeInBytes: (NSMutableSet*)exclude
{
if ([exclude member: self] != nil)
{
return 0;
}
else
{
NSUInteger size = [super sizeInBytes: exclude];
NSUInteger pos;
id *ptr;
ptr = ((void*)&count) + sizeof(count);
for (pos = 0; pos < count; pos++)
{
size += [ptr[pos] sizeInBytes: exclude];
}
return size;
}
}
@end
/**
* Exception raised when an error with the remote database server occurs.
*/
NSString *SQLException = @"SQLException";
/**
* Exception for when a connection to the server is lost.
*/
NSString *SQLConnectionException = @"SQLConnectionException";
/**
* Exception for when a query is supposed to return data and doesn't.
*/
NSString *SQLEmptyException = @"SQLEmptyException";
/**
* Exception for when an insert/update would break the uniqueness of a
* field or index.
*/
NSString *SQLUniqueException = @"SQLUniqueException";
@implementation SQLClient (Logging)
static unsigned int classDebugging = 0;
static NSTimeInterval classDuration = -1;
+ (unsigned int) debugging
{
return classDebugging;
}
+ (NSTimeInterval) durationLogging
{
return classDuration;
}
+ (void) setDebugging: (unsigned int)level
{
classDebugging = level;
}
+ (void) setDurationLogging: (NSTimeInterval)threshold
{
classDuration = threshold;
}
- (void) debug: (NSString*)fmt, ...
{
va_list ap;
va_start(ap, fmt);
NSLogv(fmt, ap);
va_end(ap);
}
- (unsigned int) debugging
{
return _debugging;
}
- (NSTimeInterval) durationLogging
{
return _duration;
}
- (void) setDebugging: (unsigned int)level
{
_debugging = level;
}
- (void) setDurationLogging: (NSTimeInterval)threshold
{
_duration = threshold;
}
@end
/**
* Container for all instances.
*/
static NSMapTable *clientsMap = 0;
static NSRecursiveLock *clientsMapLock = nil;
static NSString *beginString = @"begin";
static NSArray *beginStatement = nil;
static NSString *commitString = @"commit";
static NSArray *commitStatement = nil;
static NSString *rollbackString = @"rollback";
static NSArray *rollbackStatement = nil;
@interface SQLClient (Private)
- (void) _configure: (NSNotification*)n;
- (void) _populateCache: (CacheQuery*)a;
- (NSArray*) _prepare: (NSString*)stmt args: (va_list)args;
- (void) _recordMainThread;
- (NSArray*) _substitute: (NSString*)str with: (NSDictionary*)vals;
+ (void) _tick: (NSTimer*)t;
@end
@interface SQLClient (GSCacheDelegate)
- (BOOL) shouldKeepItem: (id)anObject
withKey: (id)aKey
lifetime: (unsigned)lifetime
after: (unsigned)delay;
@end
@implementation SQLClient
static unsigned int maxConnections = 8;
+ (NSArray*) allClients
{
NSArray *a;
[clientsMapLock lock];
a = NSAllMapTableValues(clientsMap);
[clientsMapLock unlock];
return a;
}
+ (SQLClient*) clientWithConfiguration: (NSDictionary*)config
name: (NSString*)reference
{
SQLClient *o;
if ([reference isKindOfClass: NSStringClass] == NO)
{
if (config == nil)
{
reference = [[NSUserDefaults standardUserDefaults] objectForKey:
@"SQLClientName"];
}
else
{
reference = [config objectForKey: @"SQLClientName"];
}
if ([reference isKindOfClass: NSStringClass] == NO)
{
reference = @"Database";
}
}
o = [self existingClient: reference];
if (o == nil)
{
o = [[SQLClient alloc] initWithConfiguration: config name: reference];
[o autorelease];
}
return o;
}
+ (SQLClient*) existingClient: (NSString*)reference
{
SQLClient *existing;
if ([reference isKindOfClass: NSStringClass] == NO)
{
reference = [[NSUserDefaults standardUserDefaults] stringForKey:
@"SQLClientName"];
if (reference == nil)
{
reference = @"Database";
}
}
[clientsMapLock lock];
existing = (SQLClient*)NSMapGet(clientsMap, reference);
[[existing retain] autorelease];
[clientsMapLock unlock];
return existing;
}
+ (void) initialize
{
static id modes[1];
modes[0] = NSDefaultRunLoopMode;
queryModes = [[NSArray alloc] initWithObjects: modes count: 1];
GSTickerTimeNow();
[SQLRecord class]; // Force initialisation
if (clientsMap == 0)
{
clientsMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSNonRetainedObjectMapValueCallBacks, 0);
clientsMapLock = [NSRecursiveLock new];
beginStatement = [[NSArray arrayWithObject: beginString] retain];
commitStatement = [[NSArray arrayWithObject: commitString] retain];
rollbackStatement = [[NSArray arrayWithObject: rollbackString] retain];
NSStringClass = [NSString class];
NSArrayClass = [NSArray class];
NSSetClass = [NSSet class];
[NSTimer scheduledTimerWithTimeInterval: 1.0
target: self
selector: @selector(_tick:)
userInfo: 0
repeats: YES];
}
}
+ (unsigned int) maxConnections
{
return maxConnections;
}
+ (void) purgeConnections: (NSDate*)since
{
NSMapEnumerator e;
NSString *n;
SQLClient *o;
unsigned int connectionCount = 0;
NSTimeInterval t = [since timeIntervalSinceReferenceDate];
[clientsMapLock lock];
e = NSEnumerateMapTable(clientsMap);
while (NSNextMapEnumeratorPair(&e, (void**)&n, (void**)&o) != 0)
{
if (since != nil)
{
NSTimeInterval when = o->_lastOperation;
if (when < t)
{
[o disconnect];
}
}
if ([o connected] == YES)
{
connectionCount++;
}
}
NSEndMapTableEnumeration(&e);
[clientsMapLock unlock];
while (connectionCount >= maxConnections)
{
SQLClient *other = nil;
NSTimeInterval oldest = 0.0;
connectionCount = 0;
[clientsMapLock lock];
e = NSEnumerateMapTable(clientsMap);
while (NSNextMapEnumeratorPair(&e, (void**)&n, (void**)&o))
{
if ([o connected] == YES)
{
NSTimeInterval when = o->_lastOperation;
connectionCount++;
if (oldest == 0.0 || when < oldest)
{
oldest = when;
other = o;
}
}
}
NSEndMapTableEnumeration(&e);
[clientsMapLock unlock];
connectionCount--;
if ([other debugging] > 0)
{
[other debug:
@"Force disconnect of '%@' because pool size (%d) reached",
other, maxConnections];
}
[other disconnect];
}
}
+ (void) setMaxConnections: (unsigned int)c
{
if (c > 0)
{
maxConnections = c;
[self purgeConnections: nil];
}
}
- (void) begin
{
[lock lock];
if (_inTransaction == NO)
{
_inTransaction = YES;
NS_DURING
{
[self simpleExecute: beginStatement];
/* NB. We leave the lock locked ... until a matching -commit
* or -rollback is called. This prevents other threads from
* interfering with this transaction.
*/
}
NS_HANDLER
{
_inTransaction = NO;
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
}
else
{
[lock unlock];
[NSException raise: NSInternalInconsistencyException
format: @"begin used inside transaction"];
}
}
- (NSString*) buildQuery: (NSString*)stmt, ...
{
va_list ap;
NSString *sql = nil;
/*
* First check validity and concatenate parts of the query.
*/
va_start (ap, stmt);
sql = [[self _prepare: stmt args: ap] objectAtIndex: 0];
va_end (ap);
return sql;
}
- (NSString*) buildQuery: (NSString*)stmt with: (NSDictionary*)values
{
NSString *sql = nil;
sql = [[self _substitute: stmt with: values] objectAtIndex: 0];
return sql;
}
- (NSString*) clientName
{
return _client;
}
- (void) commit
{
[lock lock];
if (_inTransaction == NO)
{
[lock unlock];
[NSException raise: NSInternalInconsistencyException
format: @"commit used outside transaction"];
}
/* Since we are in a transaction we must be doubly locked right now,
* so we unlock once, and we still have the lock (which was locked
* in the earlier call to the -begin method).
*/
[lock unlock];
_inTransaction = NO;
NS_DURING
{
[self simpleExecute: commitStatement];
[_statements removeAllObjects];
[lock unlock]; // Locked by -begin
}
NS_HANDLER
{
[_statements removeAllObjects];
[lock unlock]; // Locked by -begin
[localException raise];
}
NS_ENDHANDLER
}
- (BOOL) connect
{
if (NO == connected)
{
[lock lock];
if (NO == connected)
{
NS_DURING
{
if (_connectFails > 1)
{
NSTimeInterval delay;
NSTimeInterval elapsed;
/* If we have repeated connection failures, we enforce a
* delay of up to 30 seconds between connection attempts
* to avoid overloading the system with too frequent
* connection attempts.
*/
delay = (_connectFails < 30) ? _connectFails : 30;
elapsed = GSTickerTimeNow() - _lastOperation;
if (elapsed < delay)
{
[NSThread sleepForTimeInterval: delay - elapsed];
}
}
[self backendConnect];
/* On establishng a new connection, we must restore any
* listen instructions in the backend.
*/
if (nil != _names)
{
NSEnumerator *e;
NSString *n;
e = [_names objectEnumerator];
while (nil != (n = [e nextObject]))
{
[self backendListen: n];
}
}
_connectFails = 0;
}
NS_HANDLER
{
_lastOperation = GSTickerTimeNow();
_connectFails++;
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
}
[lock unlock];
if (YES == connected)
{
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: SQLClientDidConnectNotification
object: self];
}
}
return connected;
}
- (BOOL) connected
{
return connected;
}
- (NSString*) database
{
return _database;
}
- (void) dealloc
{
NSNotificationCenter *nc;
if (_name != nil)
{
[clientsMapLock lock];
NSMapRemove(clientsMap, (void*)_name);
[clientsMapLock unlock];
}
nc = [NSNotificationCenter defaultCenter];
[nc removeObserver: self];
[self disconnect];
[lock release]; lock = nil;
[_client release]; _client = nil;
[_database release]; _database = nil;
[_password release]; _password = nil;
[_user release]; _user = nil;
[_name release]; _name = nil;
[_statements release]; _statements = nil;
[_cache release]; _cache = nil;
[_cacheThread release]; _cacheThread = nil;
if (0 != _observers)
{
NSNotificationCenter *nc;
NSMapEnumerator e;
NSMutableSet *n;
id o;
nc = [NSNotificationCenter defaultCenter];
e = NSEnumerateMapTable(_observers);
while (NSNextMapEnumeratorPair(&e, (void**)&o, (void**)&n) != 0)
{
NSEnumerator *ne = [n objectEnumerator];
NSString *name;
while (nil != (name = [ne nextObject]))
{
[nc removeObserver: o name: name object: nil];
}
}
NSEndMapTableEnumeration(&e);
NSFreeMapTable(_observers);
_observers = 0;
}
[_names release]; _names = 0;
[super dealloc];
}
- (NSString*) description
{
NSMutableString *s = [[NSMutableString new] autorelease];
[lock lock];
NS_DURING
{
[s appendFormat: @"Database - %@\n", [self clientName]];
[s appendFormat: @" Name - %@\n", [self name]];
[s appendFormat: @" DBase - %@\n", [self database]];
[s appendFormat: @" DB User - %@\n", [self user]];
[s appendFormat: @" Password - %@\n",
[self password] == nil ? @"unknown" : @"known"];
[s appendFormat: @" Connected - %@\n", connected ? @"yes" : @"no"];
[s appendFormat: @" Transaction - %@\n",
_inTransaction ? @"yes" : @"no"];
if (_cache == nil)
{
[s appendString: @"\n"];
}
else
{
[s appendFormat: @" Cache - %@\n", _cache];
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
return s;
}
- (void) disconnect
{
if (YES == connected)
{
NSNotificationCenter *nc;
[lock lock];
if (YES == _inTransaction)
{
/* If we are inside a transaction we must be doubly locked,
* so we do an unlock corresponding to the -begin before we
* disconnect (the disconnect implicitly rolls back the
* transaction).
*/
_inTransaction = NO;
[lock unlock];
}
if (YES == connected)
{
NS_DURING
{
[self backendDisconnect];
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
}
[lock unlock];
nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: SQLClientDidDisconnectNotification
object: self];
}
}
- (NSInteger) execute: (NSString*)stmt, ...
{
NSArray *info;
va_list ap;
va_start (ap, stmt);
info = [self _prepare: stmt args: ap];
va_end (ap);
return [self simpleExecute: info];
}
- (NSInteger) execute: (NSString*)stmt with: (NSDictionary*)values
{
NSArray *info;
info = [self _substitute: stmt with: values];
return [self simpleExecute: info];
}
- (id) init
{
return [self initWithConfiguration: nil name: nil];
}
- (id) initWithConfiguration: (NSDictionary*)config
{
return [self initWithConfiguration: config name: nil];
}
- (id) initWithConfiguration: (NSDictionary*)config
name: (NSString*)reference
{
NSNotification *n;
NSDictionary *conf = config;
id existing;
if (conf == nil)
{
// Pretend the defaults object is a dictionary.
conf = (NSDictionary*)[NSUserDefaults standardUserDefaults];
}
if ([reference isKindOfClass: NSStringClass] == NO)
{
reference = [conf objectForKey: @"SQLClientName"];
if ([reference isKindOfClass: NSStringClass] == NO)
{
reference = [conf objectForKey: @"Database"];
}
}
[clientsMapLock lock];
existing = (SQLClient*)NSMapGet(clientsMap, reference);
if (nil == existing)
{
lock = [NSRecursiveLock new]; // Ensure thread-safety.
[self setDebugging: [[self class] debugging]];
[self setDurationLogging: [[self class] durationLogging]];
[self setName: reference]; // Set name and store in cache.
_statements = [NSMutableArray new];
if ([conf isKindOfClass: [NSUserDefaults class]] == YES)
{
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self
selector: @selector(_configure:)
name: NSUserDefaultsDidChangeNotification
object: conf];
}
n = [NSNotification
notificationWithName: NSUserDefaultsDidChangeNotification
object: conf
userInfo: nil];
[self _configure: n]; // Actually set up the configuration.
}
else
{
[self release];
self = [existing retain];
}
[clientsMapLock unlock];
return self;
}
- (NSUInteger) hash
{
return [[self database] hash] + [[self user] hash];
}
- (BOOL) isEqual: (id)other
{
if (self == other)
{
return YES;
}
if ([self class] != [other class])
{
return NO;
}
if (NO == [[self database] isEqual: [other database]])
{
return NO;
}
if (NO == [[self user] isEqual: [other user]])
{
return NO;
}
return YES;
}
- (BOOL) isInTransaction
{
return _inTransaction;
}
- (NSDate*) lastOperation
{
if (_lastOperation > 0.0 && _connectFails == 0)
{
return [NSDate dateWithTimeIntervalSinceReferenceDate: _lastOperation];
}
return nil;
}
- (NSString*) name
{
return _name;
}
- (NSString*) password
{
return _password;
}
- (NSMutableArray*) query: (NSString*)stmt, ...
{
va_list ap;
NSMutableArray *result = nil;
/*
* First check validity and concatenate parts of the query.
*/
va_start (ap, stmt);
stmt = [[self _prepare: stmt args: ap] objectAtIndex: 0];
va_end (ap);
result = [self simpleQuery: stmt];
return result;
}
- (NSMutableArray*) query: (NSString*)stmt with: (NSDictionary*)values
{
NSMutableArray *result = nil;
stmt = [[self _substitute: stmt with: values] objectAtIndex: 0];
result = [self simpleQuery: stmt];
return result;
}
- (NSString*) quote: (id)obj
{
/**
* For a nil object, we return NULL.
*/
if (obj == nil || obj == null)
{
return @"NULL";
}
else if ([obj isKindOfClass: NSStringClass] == NO)
{
/**
* For a number, we simply convert directly to a string.
*/
if ([obj isKindOfClass: [NSNumber class]] == YES)
{
return [obj description];
}
/**
* For a date, we convert to the text format used by the database,
* and add leading and trailing quotes.
*/
if ([obj isKindOfClass: NSDateClass] == YES)
{
return [obj descriptionWithCalendarFormat:
@"'%Y-%m-%d %H:%M:%S.%F %z'" timeZone: nil locale: nil];
}
/**
* For a data object, we don't quote ... the other parts of the code
* need to know they have an NSData object and pass it on unchanged
* to the -backendExecute: method.
*/
if ([obj isKindOfClass: [NSData class]] == YES)
{
return obj;
}
/**
* Just in case an NSNull subclass has been created by someone.
* The normal NSNull instance should have been handled earlier.
*/
if ([obj isKindOfClass: [NSNull class]] == YES)
{
return @"NULL";
}
/**
* For an NSArray or NSSet, we produce a bracketed list of the
* (quoted) objects in the array.
*/
if ([obj isKindOfClass: NSArrayClass] == YES ||
[obj isKindOfClass: NSSetClass] == YES)
{
NSMutableString *ms = [NSMutableString stringWithCapacity: 100];
NSEnumerator *enumerator = [obj objectEnumerator];
id value = [enumerator nextObject];
[ms appendString: @"("];
if (value != nil)
{
[ms appendString: [self quote: value]];
}
while ((value = [enumerator nextObject]) != nil)
{
[ms appendString: @","];
[ms appendString: [self quote: value]];
}
[ms appendString: @")"];
return ms;
}
/**
* For any other type of data, we just produce a quoted string
* representation of the objects description.
*/
obj = [obj description];
}
/* Get a string description of the object. */
obj = [self quoteString: obj];
return obj;
}
- (NSString*) quotef: (NSString*)fmt, ...
{
va_list ap;
NSString *str;
NSString *quoted;
va_start(ap, fmt);
str = [[NSString allocWithZone: NSDefaultMallocZone()]
initWithFormat: fmt arguments: ap];
va_end(ap);
quoted = [self quoteString: str];
[str release];
return quoted;
}
- (NSString*) quoteBigInteger: (int64_t)i
{
return [NSString stringWithFormat: @"%"PRId64, i];
}
- (NSString*) quoteCString: (const char *)s
{
NSString *str;
NSString *quoted;
if (s == 0)
{
s = "";
}
str = [[NSString alloc] initWithCString: s];
quoted = [self quoteString: str];
[str release];
return quoted;
}
- (NSString*) quoteChar: (char)c
{
NSString *str;
NSString *quoted;
if (c == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"Attempt to quote a nul character in -quoteChar:"];
}
str = [[NSString alloc] initWithFormat: @"%c", c];
quoted = [self quoteString: str];
[str release];
return quoted;
}
- (NSString*) quoteFloat: (float)f
{
return [NSString stringWithFormat: @"%f", f];
}
- (NSString*) quoteInteger: (int)i
{
return [NSString stringWithFormat: @"%d", i];
}
- (NSString*) quoteString: (NSString *)s
{
static NSCharacterSet *special = nil;
NSMutableString *m;
NSRange r;
unsigned l;
if (special == nil)
{
NSString *stemp;
/*
* NB. length of C string is 2, so we include a nul character as a
* special.
*/
stemp = [[NSString alloc] initWithBytes: "'"
length: 2
encoding: NSASCIIStringEncoding];
special = [NSCharacterSet characterSetWithCharactersInString: stemp];
[stemp release];
[special retain];
}
/*
* Step through string removing nul characters
* and escaping quote characters as required.
*/
m = [[s mutableCopy] autorelease];
l = [m length];
r = NSMakeRange(0, l);
r = [m rangeOfCharacterFromSet: special options: NSLiteralSearch range: r];
while (r.length > 0)
{
unichar c = [m characterAtIndex: r.location];
if (c == 0)
{
r.length = 1;
[m replaceCharactersInRange: r withString: @""];
l--;
}
else
{
r.length = 0;
[m replaceCharactersInRange: r withString: @"'"];
l++;
r.location += 2;
}
r = NSMakeRange(r.location, l - r.location);
r = [m rangeOfCharacterFromSet: special
options: NSLiteralSearch
range: r];
}
/* Add quoting around it. */
[m replaceCharactersInRange: NSMakeRange(0, 0) withString: @"'"];
[m appendString: @"'"];
return m;
}
- (oneway void) release
{
/* We lock the table while checking, to prevent
* another thread from grabbing this object while we are
* checking it.
* If we are going to deallocate the object, we first remove
* it from the table so that no other thread will find it
* and try to use it while it is being deallocated.
*/
[clientsMapLock lock];
if (NSDecrementExtraRefCountWasZero(self))
{
[self dealloc];
}
[clientsMapLock unlock];
}
- (void) rollback
{
[lock lock];
if (NO == _inTransaction)
{
[lock unlock]; // Not in a transaction ... nothing to do.
return;
}
/* Since we are in a transaction we must be doubly locked right now,
* so we unlock once, and we still have the lock (which was locked
* in the earlier call to the -begin method).
*/
[lock unlock];
_inTransaction = NO;
NS_DURING
{
[self simpleExecute: rollbackStatement];
[_statements removeAllObjects];
[lock unlock]; // Locked by -begin
}
NS_HANDLER
{
[_statements removeAllObjects];
[lock unlock]; // Locked by -begin
[localException raise];
}
NS_ENDHANDLER
}
- (void) setDatabase: (NSString*)s
{
[lock lock];
NS_DURING
{
if ([s isEqual: _database] == NO)
{
if (connected == YES)
{
[self disconnect];
}
s = [s copy];
[_database release];
_database = s;
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) setName: (NSString*)s
{
[lock lock];
NS_DURING
{
if ([s isEqual: _name] == NO)
{
[clientsMapLock lock];
if (NSMapGet(clientsMap, s) != 0)
{
[clientsMapLock unlock];
[lock unlock];
if ([self debugging] > 0)
{
[self debug: @"Error attempt to re-use client name %@", s];
}
NS_VOIDRETURN;
}
if (connected == YES)
{
[self disconnect];
}
if (_name != nil)
{
[[self retain] autorelease];
NSMapRemove(clientsMap, (void*)_name);
}
s = [s copy];
[_name release];
_name = s;
[_client release];
_client = [[[NSProcessInfo processInfo] globallyUniqueString] retain];
NSMapInsert(clientsMap, (void*)_name, (void*)self);
[clientsMapLock unlock];
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) setPassword: (NSString*)s
{
[lock lock];
NS_DURING
{
if ([s isEqual: _password] == NO)
{
if (connected == YES)
{
[self disconnect];
}
s = [s copy];
[_password release];
_password = s;
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) setShouldTrim: (BOOL)aFlag
{
_shouldTrim = (YES == aFlag) ? YES : NO;
}
- (void) setUser: (NSString*)s
{
[lock lock];
NS_DURING
{
if ([s isEqual: _client] == NO)
{
if (connected == YES)
{
[self disconnect];
}
s = [s copy];
[_user release];
_user = s;
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (NSInteger) simpleExecute: (NSArray*)info
{
NSInteger result;
NSString *debug = nil;
[lock lock];
NS_DURING
{
NSTimeInterval start = 0.0;
NSString *statement;
BOOL isCommit = NO;
BOOL isRollback = NO;
statement = [info objectAtIndex: 0];
if ([statement isEqualToString: commitString])
{
isCommit = YES;
}
if ([statement isEqualToString: rollbackString])
{
isRollback = YES;
}
if (_duration >= 0)
{
start = GSTickerTimeNow();
}
result = [self backendExecute: info];
_lastOperation = GSTickerTimeNow();
[_statements addObject: statement];
if (_duration >= 0)
{
NSTimeInterval d;
d = _lastOperation - start;
if (d >= _duration)
{
if (isCommit || isRollback)
{
NSEnumerator *e = [_statements objectEnumerator];
NSMutableString *m;
if (isCommit)
{
m = [NSMutableString stringWithFormat:
@"Duration %g for transaction commit ...\n", d];
}
else
{
m = [NSMutableString stringWithFormat:
@"Duration %g for transaction rollback ...\n", d];
}
while ((statement = [e nextObject]) != nil)
{
[m appendFormat: @" %@;\n", statement];
}
debug = m;
}
else if ([self debugging] > 1)
{
/*
* For higher debug levels, we log data objects as well
* as the query string, otherwise we omit them.
*/
debug = [NSString stringWithFormat:
@"Duration %g for statement %@", d, info];
}
else
{
debug = [NSString stringWithFormat:
@"Duration %g for statement %@", d, statement];
}
}
}
if (_inTransaction == NO)
{
[_statements removeAllObjects];
}
}
NS_HANDLER
{
result = -1;
if (_inTransaction == NO)
{
[_statements removeAllObjects];
}
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
if (nil != debug)
{
[self debug: @"%@", debug];
}
return result;
}
- (NSMutableArray*) simpleQuery: (NSString*)stmt
{
return [self simpleQuery: stmt recordType: rClass listType: aClass];
}
- (NSMutableArray*) simpleQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
NSMutableArray *result = nil;
NSString *debug = nil;
if (rtype == 0) rtype = rClass;
if (ltype == 0) ltype = aClass;
[lock lock];
NS_DURING
{
NSTimeInterval start = 0.0;
if (_duration >= 0)
{
start = GSTickerTimeNow();
}
result = [self backendQuery: stmt recordType: rtype listType: ltype];
_lastOperation = GSTickerTimeNow();
if (_duration >= 0)
{
NSTimeInterval d;
d = _lastOperation - start;
if (d >= _duration)
{
debug = [NSString stringWithFormat:
@"Duration %g for query %@", d, stmt];
}
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
if (nil != debug)
{
[self debug: @"%@", debug];
}
return result;
}
- (NSString*) user
{
return _user;
}
@end
@implementation SQLClient (Subclass)
- (BOOL) backendConnect
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
return NO;
}
- (void) backendDisconnect
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
}
- (NSInteger) backendExecute: (NSArray*)info
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
return -1;
}
- (void) backendListen: (NSString*)name
{
return;
}
- (void) backendNotify: (NSString*)name payload: (NSString*)more
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle implementation",
NSStringFromSelector(_cmd)];
return;
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
{
return [self backendQuery: stmt recordType: rClass listType: aClass];
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
return nil;
}
- (void) backendUnlisten: (NSString*)name
{
return;
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
return 0;
}
- (const void*) insertBLOBs: (NSArray*)blobs
intoStatement: (const void*)statement
length: (unsigned)sLength
withMarker: (const void*)marker
length: (unsigned)mLength
giving: (unsigned*)result
{
unsigned count = [blobs count];
unsigned length = sLength;
if (count > 1)
{
unsigned i;
unsigned char *buf;
unsigned char *ptr;
const unsigned char *from = (const unsigned char*)statement;
/*
* Calculate length of buffer needed.
*/
for (i = 1; i < count; i++)
{
length += [self lengthOfEscapedBLOB: [blobs objectAtIndex: i]];
length -= mLength;
}
buf = NSZoneMalloc(NSDefaultMallocZone(), length + 1);
[NSData dataWithBytesNoCopy: buf length: length + 1]; // autoreleased
ptr = buf;
/*
* Merge quoted data objects into statement.
*/
i = 1;
from = (unsigned char*)statement;
while (*from != 0)
{
if (*from == *(unsigned char*)marker
&& memcmp(from, marker, mLength) == 0)
{
NSData *d = [blobs objectAtIndex: i++];
from += mLength;
ptr += [self copyEscapedBLOB: d into: ptr];
}
else
{
*ptr++ = *from++;
}
}
*ptr = '\0';
statement = buf;
}
*result = length;
return statement;
}
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob
{
[NSException raise: NSInternalInconsistencyException
format: @"Called -%@ without backend bundle loaded",
NSStringFromSelector(_cmd)];
return 0;
}
@end
@implementation SQLClient (Private)
/**
* Internal method to handle configuration using the notification object.
* This object may be either a configuration front end or a user defaults
* object ... so we have to be careful that we work with both.
*/
- (void) _configure: (NSNotification*)n
{
NSDictionary *o;
NSDictionary *d;
NSString *s;
Class c;
[lock lock];
NS_DURING
{
o = [n object];
/*
* get dictionary containing config info for this client by name.
*/
d = [o objectForKey: @"SQLClientReferences"];
if ([d isKindOfClass: [NSDictionary class]] == NO)
{
[self debug: @"Unable to find SQLClientReferences config dictionary"];
d = nil;
}
d = [d objectForKey: _name];
if ([d isKindOfClass: [NSDictionary class]] == NO)
{
[self debug: @"Unable to find config for client '%@'", _name];
d = nil;
}
s = [d objectForKey: @"ServerType"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"Postgres";
}
c = NSClassFromString([@"SQLClient" stringByAppendingString: s]);
if (c == nil)
{
NSString *path;
NSBundle *bundle;
NSArray *paths;
NSMutableArray *tried;
unsigned count;
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSAllDomainsMask, YES);
count = [paths count];
tried = [NSMutableArray arrayWithCapacity: count];
while (count-- > 0)
{
path = [paths objectAtIndex: count];
path = [path stringByAppendingPathComponent: @"Bundles"];
path = [path stringByAppendingPathComponent: @"SQLClient"];
path = [path stringByAppendingPathComponent: s];
path = [path stringByAppendingPathExtension: @"bundle"];
bundle = [NSBundle bundleWithPath: path];
if (bundle != nil)
{
[tried addObject: path];
if ((c = [bundle principalClass]) != nil)
{
break; // Found it.
}
}
/* Try alternative version with more libraries linked in.
* In some systems and situations the dynamic linker needs
* to haved the SQLClient, gnustep-base, and objc libraries
* explicitly linked into the bundle, but in others it
* requires them to not be linked. 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.
*/
path = [path stringByDeletingPathExtension];
path = [path stringByAppendingString: @"_libs"];
path = [path stringByAppendingPathExtension: @"bundle"];
bundle = [NSBundle bundleWithPath: path];
if (bundle != nil)
{
[tried addObject: path];
if ((c = [bundle principalClass]) != nil)
{
break; // Found it.
}
}
}
if (c == nil)
{
if ([tried count] == 0)
{
[self debug: @"unable to load bundle for '%@' server type"
@" ... failed to locate bundle in %@", s, paths];
}
else
{
[self debug: @"unable to load backend class for '%@' server"
@" type ... dynamic library load failed in %@", s, tried];
}
[lock unlock];
NS_VOIDRETURN;
}
}
if (c != [self class])
{
[self disconnect];
#ifdef GNUSTEP
GSDebugAllocationRemove(object_getClass(self), self);
#endif
object_setClass(self, c);
#ifdef GNUSTEP
GSDebugAllocationAdd(object_getClass(self), self);
#endif
}
s = [d objectForKey: @"Database"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"Database"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = nil;
}
}
[self setDatabase: s];
s = [d objectForKey: @"User"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"User"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"";
}
}
[self setUser: s];
s = [d objectForKey: @"Password"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = [o objectForKey: @"Password"];
if ([s isKindOfClass: NSStringClass] == NO)
{
s = @"";
}
}
[self setPassword: s];
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
/** Internal method to populate the cache with the result of a query.
*/
- (void) _populateCache: (CacheQuery*)a
{
GSCache *cache;
id result;
[lock lock];
NS_DURING
{
result = [self backendQuery: a->query
recordType: a->recordType
listType: a->listType];
}
NS_HANDLER
{
result = nil;
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
cache = [self cache];
[cache setObject: result
forKey: a->query
lifetime: a->lifetime];
}
/**
* Internal method to build an sql string by quoting any non-string objects
* and concatenating the resulting strings in a nil terminated list.
* Returns an array containing the statement as the first object and
* any NSData objects following. The NSData objects appear in the
* statement strings as the marker sequence - '?'''?'
*/
- (NSArray*) _prepare: (NSString*)stmt args: (va_list)args
{
NSMutableArray *ma = [NSMutableArray arrayWithCapacity: 2];
NSString *tmp = va_arg(args, NSString*);
NSAutoreleasePool *arp = [NSAutoreleasePool new];
if (tmp != nil)
{
NSMutableString *s = [NSMutableString stringWithCapacity: 1024];
[s appendString: stmt];
/*
* Append any values from the nil terminated varargs
*/
while (tmp != nil)
{
if ([tmp isKindOfClass: NSStringClass] == NO)
{
if ([tmp isKindOfClass: [NSData class]] == YES)
{
[ma addObject: tmp];
[s appendString: @"'?'''?'"]; // Marker.
}
else
{
[s appendString: [self quote: tmp]];
}
}
else
{
[s appendString: tmp];
}
tmp = va_arg(args, NSString*);
}
stmt = s;
}
[ma insertObject: stmt atIndex: 0];
[arp release];
return ma;
}
- (void) _recordMainThread
{
mainThread = [NSThread currentThread];
}
/**
* Internal method to substitute values from the dictionary into
* a string containing markup identifying where the values should
* appear by name. Non-string objects in the dictionary are quoted.
* Returns an array containing the statement as the first object and
* any NSData objects following. The NSData objects appear in the
* statement strings as the marker sequence - '?'''?'
*/
- (NSArray*) _substitute: (NSString*)str with: (NSDictionary*)vals
{
unsigned int l = [str length];
NSRange r;
NSMutableArray *ma = [NSMutableArray arrayWithCapacity: 2];
NSAutoreleasePool *arp = [NSAutoreleasePool new];
if (l < 2)
{
[ma addObject: str]; // Can't contain a {...} sequence
}
else if ((r = [str rangeOfString: @"{"]).length == 0)
{
[ma addObject: str]; // No '{' markup
}
else if (l - r.location < 2)
{
[ma addObject: str]; // Can't contain a {...} sequence
}
else if ([str rangeOfString: @"}" options: NSLiteralSearch
range: NSMakeRange(r.location, l - r.location)].length == 0
&& [str rangeOfString: @"{{" options: NSLiteralSearch
range: NSMakeRange(0, l)].length == 0)
{
[ma addObject: str]; // No closing '}' or repeated '{{'
}
else if (r.length == 0)
{
[ma addObject: str]; // Nothing to do.
}
else
{
NSMutableString *mtext = [[str mutableCopy] autorelease];
/*
* Replace {FieldName} with the value of the field
*/
while (r.length > 0)
{
unsigned pos = r.location;
unsigned nxt;
unsigned vLength;
NSArray *a;
NSRange s;
NSString *v;
NSString *alt;
id o;
unsigned i;
r.length = l - pos;
/*
* If the length of the string from the '{' onwards is less than two,
* there is nothing to do and we can end processing.
*/
if (r.length < 2)
{
break;
}
if ([mtext characterAtIndex: r.location + 1] == '{')
{
// Got '{{' ... remove one of them.
r.length = 1;
[mtext replaceCharactersInRange: r withString: @""];
l--;
r.location++;
r.length = l - r.location;
r = [mtext rangeOfString: @"{"
options: NSLiteralSearch
range: r];
continue;
}
r = [mtext rangeOfString: @"}"
options: NSLiteralSearch
range: r];
if (r.length == 0)
{
break; // No closing bracket
}
nxt = NSMaxRange(r);
r = NSMakeRange(pos, nxt - pos);
s.location = r.location + 1;
s.length = r.length - 2;
v = [mtext substringWithRange: s];
/*
* If the value contains a '?', it is actually in two parts,
* the first part is the field name, and the second part is
* an alternative text to be used if the value from the
* dictionary is empty.
*/
s = [v rangeOfString: @"?"];
if (s.length == 0)
{
alt = @""; // No alternative value.
}
else
{
alt = [v substringFromIndex: NSMaxRange(s)];
v = [v substringToIndex: s.location];
}
/*
* If the value we are substituting contains dots, we split it apart.
* We use the value to make a reference into the dictionary we are
* given.
*/
a = [v componentsSeparatedByString: @"."];
o = vals;
for (i = 0; i < [a count]; i++)
{
NSString *k = [a objectAtIndex: i];
if ([k length] > 0)
{
o = [(NSDictionary*)o objectForKey: k];
}
}
if (o == vals)
{
v = nil; // Mo match found.
}
else
{
if ([o isKindOfClass: NSStringClass] == YES)
{
v = (NSString*)o;
}
else
{
if ([o isKindOfClass: [NSData class]] == YES)
{
[ma addObject: o];
v = @"'?'''?'";
}
else
{
v = [self quote: o];
}
}
}
if ([v length] == 0)
{
v = alt;
if (v == nil)
{
v = @"";
}
}
vLength = [v length];
[mtext replaceCharactersInRange: r withString: v];
l += vLength; // Add length of string inserted
l -= r.length; // Remove length of string replaced
r.location += vLength;
if (r.location >= l)
{
break;
}
r.length = l - r.location;
r = [mtext rangeOfString: @"{"
options: NSLiteralSearch
range: r];
}
[ma insertObject: mtext atIndex: 0];
}
[arp release];
return ma;
}
/*
* Called at one second intervals to ensure that our current timestamp
* is reasonably accurate.
*/
+ (void) _tick: (NSTimer*)t
{
(void) GSTickerTimeNow();
}
@end
@implementation SQLClient (GSCacheDelegate)
- (BOOL) shouldKeepItem: (id)anObject
withKey: (id)aKey
lifetime: (unsigned)lifetime
after: (unsigned)delay
{
CacheQuery *a;
NSDictionary *d;
a = [CacheQuery new];
aKey = [aKey copy];
[a->query release];
a->query = aKey;
d = [[NSThread currentThread] threadDictionary];
a->recordType = [d objectForKey: @"SQLClientRecordType"];
a->listType = [d objectForKey: @"SQLClientListType"];
a->lifetime = lifetime;
[a autorelease];
if (_cacheThread == nil)
{
[self _populateCache: a];
}
else
{
/* We schedule an asynchronous update if the item is not too old,
* otherwise (more than lifetime seconds past its expiry) we wait
* for the update to complete.
*/
[self performSelectorOnMainThread: @selector(_populateCache:)
withObject: a
waitUntilDone: (delay > lifetime) ? YES : NO
modes: queryModes];
}
return YES; // Always keep items ...
}
@end
@implementation SQLClient(Convenience)
- (SQLTransaction*) batch: (BOOL)stopOnFailure
{
SQLTransaction *transaction;
transaction = (SQLTransaction*)NSAllocateObject([SQLTransaction class], 0,
NSDefaultMallocZone());
transaction->_db = [self retain];
transaction->_info = [NSMutableArray new];
transaction->_batch = YES;
transaction->_stop = stopOnFailure;
return [(SQLTransaction*)transaction autorelease];
}
- (NSMutableArray*) columns: (NSMutableArray*)records
{
SQLRecord *r = [records lastObject];
unsigned rowCount = [records count];
unsigned colCount = [r count];
NSMutableArray *m;
if (rowCount == 0 || colCount == 0)
{
m = [NSMutableArray array];
}
else
{
NSMutableArray *cols[colCount];
unsigned i;
m = [NSMutableArray arrayWithCapacity: colCount];
for (i = 0; i < colCount; i++)
{
cols[i] = [[NSMutableArray alloc] initWithCapacity: rowCount];
[m addObject: cols[i]];
[cols[i] release];
}
for (i = 0; i < rowCount; i++)
{
unsigned j;
r = [records objectAtIndex: i];
for (j = 0; j < colCount; j++)
{
[cols[j] addObject: [r objectAtIndex: j]];
}
}
}
return m;
}
- (SQLRecord*) queryRecord: (NSString*)stmt, ...
{
va_list ap;
NSArray *result = nil;
SQLRecord *record;
va_start (ap, stmt);
stmt = [[self _prepare: stmt args: ap] objectAtIndex: 0];
va_end (ap);
result = [self simpleQuery: stmt];
if ([result count] > 1)
{
[NSException raise: NSInvalidArgumentException
format: @"Query returns more than one record -\n%@\n", stmt];
}
record = [result lastObject];
if (record == nil)
{
[NSException raise: SQLEmptyException
format: @"Query returns no data -\n%@\n", stmt];
}
return record;
}
- (NSString*) queryString: (NSString*)stmt, ...
{
va_list ap;
NSArray *result = nil;
SQLRecord *record;
va_start (ap, stmt);
stmt = [[self _prepare: stmt args: ap] objectAtIndex: 0];
va_end (ap);
result = [self simpleQuery: stmt];
if ([result count] > 1)
{
[NSException raise: NSInvalidArgumentException
format: @"Query returns more than one record -\n%@\n", stmt];
}
record = [result lastObject];
if (record == nil)
{
[NSException raise: SQLEmptyException
format: @"Query returns no data -\n%@\n", stmt];
}
if ([record count] > 1)
{
[NSException raise: NSInvalidArgumentException
format: @"Query returns multiple fields -\n%@\n", stmt];
}
return [[record lastObject] description];
}
- (void) singletons: (NSMutableArray*)records
{
unsigned c = [records count];
while (c-- > 0)
{
[records replaceObjectAtIndex: c
withObject: [[records objectAtIndex: c] lastObject]];
}
}
- (SQLTransaction*) transaction
{
SQLTransaction *transaction;
transaction = (SQLTransaction*)NSAllocateObject([SQLTransaction class], 0,
NSDefaultMallocZone());
transaction->_db = [self retain];
transaction->_info = [NSMutableArray new];
return [(SQLTransaction*)transaction autorelease];
}
@end
@interface SQLClientCacheInfo : NSObject
{
@public
NSString *query;
NSMutableArray *result;
NSTimeInterval expires;
}
@end
@implementation SQLClientCacheInfo
- (void) dealloc
{
[query release]; query = nil;
[result release]; result = nil;
[super dealloc];
}
- (NSUInteger) hash
{
return [query hash];
}
- (BOOL) isEqual: (id)other
{
return [query isEqual: ((SQLClientCacheInfo*)other)->query];
}
@end
@implementation SQLClient (Caching)
- (GSCache*) cache
{
GSCache *c;
[lock lock];
if (nil == _cache)
{
_cache = [GSCache new];
if (_cacheThread != nil)
{
[_cache setDelegate: self];
}
}
c = [_cache retain];
[lock unlock];
return [c autorelease];
}
- (NSMutableArray*) cache: (int)seconds
query: (NSString*)stmt,...
{
va_list ap;
va_start (ap, stmt);
stmt = [[self _prepare: stmt args: ap] objectAtIndex: 0];
va_end (ap);
return [self cache: seconds simpleQuery: stmt];
}
- (NSMutableArray*) cache: (int)seconds
query: (NSString*)stmt
with: (NSDictionary*)values
{
stmt = [[self _substitute: stmt with: values] objectAtIndex: 0];
return [self cache: seconds simpleQuery: stmt];
}
- (NSMutableArray*) cache: (int)seconds
simpleQuery: (NSString*)stmt
{
return [self cache: seconds
simpleQuery: stmt
recordType: nil
listType: nil];
}
- (NSMutableArray*) cache: (int)seconds
simpleQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
NSMutableArray *result;
NSMutableDictionary *md;
NSTimeInterval start;
GSCache *c;
id toCache;
if (rtype == 0) rtype = rClass;
if (ltype == 0) ltype = aClass;
md = [[NSThread currentThread] threadDictionary];
[md setObject: rtype forKey: @"SQLClientRecordType"];
[md setObject: ltype forKey: @"SQLClientListType"];
start = GSTickerTimeNow();
c = [self cache];
toCache = nil;
if (seconds < 0)
{
seconds = -seconds;
result = nil;
}
else
{
result = [c objectForKey: stmt];
}
if (result == nil)
{
CacheQuery *a;
a = [CacheQuery new];
a->query = [stmt copy];
a->recordType = rtype;
a->listType = ltype;
a->lifetime = seconds;
[a autorelease];
if (_cacheThread == nil)
{
[self _populateCache: a];
}
else
{
/* Not really an asynchronous query becuse we wait until it's
* done in order to have a result we can return.
*/
[self performSelectorOnMainThread: @selector(_populateCache:)
withObject: a
waitUntilDone: YES
modes: queryModes];
}
result = [c objectForKey: stmt];
_lastOperation = GSTickerTimeNow();
if (_duration >= 0)
{
NSTimeInterval d;
d = _lastOperation - start;
if (d >= _duration)
{
[self debug: @"Duration %g for query %@", d, stmt];
}
}
}
if (seconds == 0)
{
// We have been told to remove the existing cached item.
[c setObject: nil forKey: stmt lifetime: seconds];
toCache = nil;
}
if (toCache != nil)
{
// We have a newly retrieved object ... cache it.
[c setObject: toCache forKey: stmt lifetime: seconds];
}
if (result != nil)
{
/*
* Return an autoreleased copy ... not the original cached data.
*/
result = [[result mutableCopy] autorelease];
}
return result;
}
- (void) setCache: (GSCache*)aCache
{
[lock lock];
NS_DURING
{
if (_cacheThread != nil)
{
[_cache setDelegate: nil];
}
[aCache retain];
[_cache release];
_cache = aCache;
if (_cacheThread != nil)
{
[_cache setDelegate: self];
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) setCacheThread: (NSThread*)aThread
{
if (mainThread == nil)
{
[self performSelectorOnMainThread: @selector(_recordMainThread)
withObject: nil
waitUntilDone: NO
modes: queryModes];
}
if (aThread != nil && aThread != mainThread)
{
NSLog(@"SQLClient: only the main thread is usable as cache thread");
aThread = mainThread;
}
[lock lock];
NS_DURING
{
if (_cacheThread != nil)
{
[_cache setDelegate: nil];
}
[aThread retain];
[_cacheThread release];
_cacheThread = aThread;
if (_cacheThread != nil)
{
[_cache setDelegate: self];
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
@end
@implementation SQLTransaction
- (void) _addSQL: (NSMutableString*)sql andArgs: (NSMutableArray*)args
{
unsigned count = [_info count];
unsigned index;
for (index = 0; index < count; index++)
{
id o = [_info objectAtIndex: index];
if ([o isKindOfClass: NSArrayClass] == YES)
{
unsigned c = [(NSArray*)o count];
if (c > 0)
{
unsigned i;
[sql appendString: [(NSArray*)o objectAtIndex: 0]];
[sql appendString: @";"];
for (i = 1; i < c; i++)
{
[args addObject: [(NSArray*)o objectAtIndex: i]];
}
}
}
else
{
[(SQLTransaction*)o _addSQL: sql andArgs: args];
}
}
}
- (void) _addPrepared: (NSArray*)statement
{
[_info addObject: statement];
_count++;
}
- (void) _countLength: (unsigned*)length andArgs: (unsigned*)args
{
unsigned count = [_info count];
unsigned index;
for (index = 0; index < count; index++)
{
id o = [_info objectAtIndex: index];
if ([o isKindOfClass: NSArrayClass] == YES)
{
unsigned c = [(NSArray*)o count];
if (c > 0)
{
length += [[(NSArray*)o objectAtIndex: 0] length] + 1;
args += c - 1;
}
}
else
{
[(SQLTransaction*)o _countLength: length andArgs: args];
}
}
}
- (void) add: (NSString*)stmt,...
{
va_list ap;
va_start (ap, stmt);
[_info addObject: [_db _prepare: stmt args: ap]];
_count++;
va_end (ap);
}
- (void) add: (NSString*)stmt with: (NSDictionary*)values
{
[_info addObject: [_db _substitute: stmt with: values]];
_count++;
}
- (void) append: (SQLTransaction*)other
{
if (other != nil && other->_count > 0)
{
if (NO == [_db isEqual: other->_db])
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] database client missmatch",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
other = [other copy];
[_info addObject: other];
_count += other->_count;
[other release];
}
}
- (id) copyWithZone: (NSZone*)z
{
SQLTransaction *c;
c = (SQLTransaction*)NSCopyObject(self, 0, z);
c->_db = [c->_db retain];
c->_info = [c->_info mutableCopy];
return c;
}
- (NSUInteger) count
{
return [_info count];
}
- (SQLClient*) db
{
return _db;
}
- (void) dealloc
{
[_db release]; _db = nil;
[_info release]; _info = nil;
[super dealloc];
}
- (NSString*) description
{
return [NSString stringWithFormat: @"%@ with SQL '%@' for %@",
[super description],
(_count == 0 ? (id)@"" : (id)_info), _db];
}
- (void) execute
{
if (_count > 0)
{
NSMutableArray *info = nil;
NS_DURING
{
NSMutableString *sql;
unsigned sqlSize = 0;
unsigned argCount = 0;
[self _countLength: &sqlSize andArgs: &argCount];
/* Allocate and initialise the transaction statement.
*/
info = [[NSMutableArray alloc] initWithCapacity: argCount + 1];
sql = [[NSMutableString alloc] initWithCapacity: sqlSize + 13];
[info addObject: sql];
[sql release];
if ([_db isInTransaction] == NO)
{
[sql appendString: @"begin;"];
}
[self _addSQL: sql andArgs: info];
if ([_db isInTransaction] == NO)
{
[sql appendString: @"commit;"];
}
[_db simpleExecute: info];
[info release]; info = nil;
}
NS_HANDLER
{
[info release];
[localException raise];
}
NS_ENDHANDLER
}
}
- (unsigned) executeBatch
{
return [self executeBatchReturningFailures: nil logExceptions: NO];
}
- (unsigned) executeBatchReturningFailures: (SQLTransaction*)failures
logExceptions: (BOOL)log
{
unsigned executed = 0;
if (_count > 0)
{
NS_DURING
{
[self execute];
executed = _count;
}
NS_HANDLER
{
if (log == YES || [_db debugging] > 0)
{
[_db debug: @"Initial failure executing batch %@: %@",
self, localException];
}
if (_batch == YES)
{
SQLTransaction *wrapper = nil;
unsigned count = [_info count];
unsigned i;
for (i = 0; i < count; i++)
{
BOOL success = NO;
id o = [_info objectAtIndex: i];
if ([o isKindOfClass: NSArrayClass] == YES)
{
NS_DURING
{
/* Wrap the statement inside a transaction so
* its context will still be that of a statement
* in a transaction rather than a standalone
* statement. This might be important if the
* statement is actually a call to a stored
* procedure whose code must all be executed
* with the visibility rules of a single
* transaction.
*/
if (wrapper == nil)
{
wrapper = [_db transaction];
}
[wrapper reset];
[wrapper _addPrepared: o];
[wrapper execute];
executed++;
success = YES;
}
NS_HANDLER
{
if (failures != nil)
{
[failures _addPrepared: o];
}
if (log == YES || [_db debugging] > 0)
{
[_db debug:
@"Failure of %d executing batch %@: %@",
i, self, localException];
}
success = NO;
}
NS_ENDHANDLER
}
else
{
unsigned result;
result = [(SQLTransaction*)o
executeBatchReturningFailures: failures
logExceptions: log];
executed += result;
if (result == [(SQLTransaction*)o totalCount])
{
success = YES;
}
}
if (success == NO && _stop == YES)
{
/* We are configured to stop after a failure,
* so we need to add all the subsequent statements
* or transactions to the list of those which have
* not been done.
*/
i++;
while (i < count)
{
id o = [_info objectAtIndex: i++];
if ([o isKindOfClass: NSArrayClass] == YES)
{
[failures _addPrepared: o];
}
else
{
[failures append: (SQLTransaction*)o];
}
}
break;
}
}
}
}
NS_ENDHANDLER
}
return executed;
}
- (void) insertTransaction: (SQLTransaction*)trn atIndex: (unsigned)index
{
if (index > [_info count])
{
[NSException raise: NSRangeException
format: @"[%@-%@] index too large",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
if (trn == nil || trn->_count == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] attempt to insert nil/empty transaction",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
if (NO == [_db isEqual: trn->_db])
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] database client missmatch",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
trn = [trn copy];
[_info addObject: trn];
_count += trn->_count;
[trn release];
}
- (void) removeTransactionAtIndex: (unsigned)index
{
id o;
if (index >= [_info count])
{
[NSException raise: NSRangeException
format: @"[%@-%@] index too large",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
o = [_info objectAtIndex: index];
if ([o isKindOfClass: NSArrayClass] == YES)
{
_count--;
}
else
{
_count -= [(SQLTransaction*)o totalCount];
}
[_info removeObjectAtIndex: index];
}
- (void) reset
{
[_info removeAllObjects];
_count = 0;
}
- (unsigned) totalCount
{
return _count;
}
- (SQLTransaction*) transactionAtIndex: (unsigned)index
{
id o;
if (index >= [_info count])
{
[NSException raise: NSRangeException
format: @"[%@-%@] index too large",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
}
o = [_info objectAtIndex: index];
if ([o isKindOfClass: NSArrayClass] == YES)
{
SQLTransaction *t = [[self db] transaction];
[t _addPrepared: o];
return t;
}
else
{
o = [o copy];
return [o autorelease];
}
}
@end
@implementation SQLClient (Notifications)
static NSString *
validName(NSString *name)
{
const char *ptr;
if (NO == [name isKindOfClass: [NSString class]])
{
[NSException raise: NSInvalidArgumentException
format: @"Notification name must be a string"];
}
ptr = [name UTF8String];
if (!isalpha(*ptr))
{
[NSException raise: NSInvalidArgumentException
format: @"Notification name must begin with letter"];
}
ptr++;
while (0 != *ptr)
{
if (!isdigit(*ptr) && !isalpha(*ptr) && *ptr != '_')
{
[NSException raise: NSInvalidArgumentException
format: @"Notification name must contain only letters,"
@" digits, and underscores"];
}
ptr++;
}
return [name lowercaseString];
}
- (void) addObserver: (id)anObserver
selector: (SEL)aSelector
name: (NSString*)name
{
NSMutableSet *set;
name = validName(name);
[lock lock];
NS_DURING
{
if (nil == _observers)
{
_observers = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
_names = [NSCountedSet new];
}
set = (NSMutableSet*)NSMapGet(_observers, (void*)anObserver);
if (nil == set)
{
set = [NSMutableSet new];
NSMapInsert(_observers, anObserver, set);
[set release];
}
if (nil == [set member: name])
{
NSUInteger count = [_names countForObject: name];
[set addObject: name];
[_names addObject: name];
if (0 == count)
{
[self backendListen: name];
}
}
[[NSNotificationCenter defaultCenter] addObserver: anObserver
selector: aSelector
name: name
object: self];
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) postNotificationName: (NSString*)name payload: (NSString*)more
{
name = validName(name);
if (nil != more)
{
if (NO == [more isKindOfClass: [NSString class]])
{
[NSException raise: NSInvalidArgumentException
format: @"Notification payload is not a string"];
}
}
[lock lock];
NS_DURING
{
[self backendNotify: name payload: more];
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
- (void) removeObserver: (id)anObserver name: (NSString*)name
{
if (nil != name)
{
name = validName(name);
}
[lock lock];
NS_DURING
{
if (_observers != nil)
{
NSNotificationCenter *nc;
NSMutableSet *set;
NSEnumerator *e;
nc = [NSNotificationCenter defaultCenter];
set = (NSMutableSet*)NSMapGet(_observers, (void*)anObserver);
if (nil == name)
{
e = [[set allObjects] objectEnumerator];
name = [e nextObject];
}
else
{
e = nil;
name = [[name retain] autorelease];
}
while (nil != name)
{
if (nil != [set member: name])
{
[nc removeObserver: anObserver
name: name
object: self];
[[name retain] autorelease];
[set removeObject: name];
[_names removeObject: name];
if (0 == [_names countForObject: name])
{
[self backendUnlisten: name];
}
}
name = [e nextObject];
}
if ([set count] == 0)
{
NSMapRemove(_observers, (void*)anObserver);
}
}
}
NS_HANDLER
{
[lock unlock];
[localException raise];
}
NS_ENDHANDLER
[lock unlock];
}
@end
@implementation SQLDictionaryBuilder
- (void) addObject: (id)anObject
{
return;
}
- (id) alloc
{
return [self retain];
}
- (NSMutableDictionary*) content
{
return content;
}
- (void) dealloc
{
[content release];
[super dealloc];
}
- (id) initWithCapacity: (NSUInteger)capacity
{
DESTROY(content);
content = [[NSMutableDictionary alloc] initWithCapacity: capacity];
return self;
}
- (id) mutableCopyWithZone: (NSZone*)aZone
{
return [content mutableCopyWithZone: aZone];
}
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count
{
if (count != 2)
{
[NSException raise: NSInvalidArgumentException
format: @"Query did not return key/value pairs"];
}
[content setObject: values[1] forKey: values[0]];
return nil;
}
@end
@implementation SQLSetBuilder
- (NSUInteger) added
{
return added;
}
- (void) addObject: (id)anObject
{
return;
}
- (id) alloc
{
return [self retain];
}
- (NSCountedSet*) content
{
return content;
}
- (void) dealloc
{
[content release];
[super dealloc];
}
- (id) initWithCapacity: (NSUInteger)capacity
{
DESTROY(content);
content = [[NSCountedSet alloc] initWithCapacity: capacity];
added = 0;
return self;
}
- (id) mutableCopyWithZone: (NSZone*)aZone
{
return [content mutableCopyWithZone: aZone];
}
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count
{
if (count != 1)
{
[NSException raise: NSInvalidArgumentException
format: @"Query did not return a single value"];
}
added++;
[content addObject: values[0]];
return nil;
}
@end
@implementation SQLSingletonBuilder
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count
{
/* Instead of creating an object to hold the supplied record,
* we use the field from the record as the value to be used.
*/
if (count != 1)
{
[NSException raise: NSInvalidArgumentException
format: @"Query did not return singleton values"];
}
return [values[0] retain];
}
@end
SQLClient-1.7.3/testMySQL.m 0000664 0000765 0000765 00000006435 12106213333 015243 0 ustar brains99 brains99 /**
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2013-02-11 16:05:47 +0000 (Mon, 11 Feb 2013) $ $Revision: 36111 $
*/
#import
#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",
@"MySQL", @"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, "
@"when2 timestamp"
@")",
nil];
[db execute: @"insert into xxx "
@"(k, char1, intval, realval, b, when2) "
@"values ("
@"'hello', "
@"'X', "
@"1, "
@"9.99, ",
data, @", ",
@"CURRENT_TIMESTAMP",
@")",
nil];
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
[db execute: @"insert into xxx "
@"(k, char1, intval, realval, b, when2) "
@"values ("
@"'hello', "
@"'X', "
@"1, ",
@"12345.6789, ",
[NSData dataWithBytes: "" length: 0], @", ",
[NSDate date],
@")",
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;
}
SQLClient-1.7.3/COPYING.LIB 0000664 0000765 0000765 00000016730 10672503115 014665 0 ustar brains99 brains99
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
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.
0. Additional Definitions.
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.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
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.
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".
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.
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.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
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:
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
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) 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.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
SQLClient-1.7.3/config.sub 0000775 0000765 0000765 00000070736 10672503115 015216 0 ustar brains99 brains99 #! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-02-12'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;;
--version | -v )
echo "$version" ; exit 0 ;;
--help | --h* | -h )
echo "$usage"; exit 0 ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit 0;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis)
os=
basic_machine=$1
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| c4x | clipper \
| d10v | d30v | dsp16xx \
| fr30 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| m32r | m68000 | m68k | m88k | mcore \
| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el | mips64vr4300 \
| mips64vr4300el | mips64vr5000 | mips64vr5000el \
| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
| mipsisa32 \
| mn10200 | mn10300 \
| ns16k | ns32k \
| openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| sh | sh[34] | sh[34]eb | shbe | shle | sh64 \
| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armv*-* \
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c54x-* \
| clipper-* | cray2-* | cydra-* \
| d10v-* | d30v-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| m32r-* \
| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \
| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| ymp-* \
| z8k-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | ymp)
basic_machine=ymp-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[cjt]90)
basic_machine=${basic_machine}-cray
os=-unicos
;;
crds | unos)
basic_machine=m68k-crds
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
or32 | or32-*)
basic_machine=or32-unknown
os=-coff
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentiumii | pentium2)
basic_machine=i686-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=t3e-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
windows32)
basic_machine=i386-pc
os=-windows32-msvcrt
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
mips)
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sh3 | sh4 | sh3eb | sh4eb)
basic_machine=sh-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto*)
os=-nto-qnx
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-ibm)
os=-aix
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
SQLClient-1.7.3/MySQL.m 0000664 0000765 0000765 00000031676 12131277533 014362 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientMySQL for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2013-04-10 16:03:55 +0100 (Wed, 10 Apr 2013) $ $Revision: 36500 $
*/
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
#include
@interface SQLClientMySQL : SQLClient
@end
@implementation SQLClientMySQL
#define connection ((MYSQL*)(self->extra))
static NSDate *future = nil;
static NSNull *null = nil;
+ (void) initialize
{
if (future == nil)
{
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00"
calendarFormat: @"%Y-%m-%d %H:%M:%S"
locale: nil];
[future retain];
null = [NSNull null];
[null retain];
}
}
- (BOOL) backendConnect
{
if (connected == NO)
{
if ([self database] != nil
&& [self user] != nil
&& [self password] != nil)
{
NSString *host = nil;
NSString *port = nil;
NSString *dbase = [self database];
NSRange r;
[[self class] purgeConnections: nil];
r = [dbase rangeOfString: @"@"];
if (r.length > 0)
{
host = [dbase substringFromIndex: NSMaxRange(r)];
dbase = [dbase substringToIndex: r.location];
r = [host rangeOfString: @":"];
if (r.length > 0)
{
port = [host substringFromIndex: NSMaxRange(r)];
host = [host substringToIndex: r.location];
}
}
if ([self debugging] > 0)
{
[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],
[[self password] UTF8String],
[dbase UTF8String],
[port intValue],
NULL,
CLIENT_MULTI_STATEMENTS) == 0)
{
[self debug: @"Error connecting to '%@' (%@) - %s",
[self name], [self database], mysql_error(connection)];
mysql_close(connection);
extra = 0;
}
else
{
connected = YES;
if ([self debugging] > 0)
{
[self debug: @"Connected to '%@'", [self name]];
}
}
}
else
{
[self debug:
@"Connect to '%@' with no user/password/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]];
}
mysql_close(connection);
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;
NSInteger rowCount = 0;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
stmt = [info objectAtIndex: 0];
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
NS_DURING
{
MYSQL_RES *result;
const char *statement;
unsigned length;
/*
* Ensure we have a working connection.
*/
if ([self 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];
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);
}
}
}
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 rowCount;
}
static unsigned int trim(char *str)
{
char *start = str;
while (isspace(*str))
{
str++;
}
if (str != start)
{
strcpy(start, str);
}
str = start;
while (*str != '\0')
{
str++;
}
while (str > start && isspace(str[-1]))
{
*--str = '\0';
}
return (str - start);
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (Class)rtype
listType: (Class)ltype
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSMutableArray *records = nil;
MYSQL_RES *result = 0;
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
NS_DURING
{
char *statement;
/*
* 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];
if (mysql_query(connection, statement) == 0
&& (result = mysql_store_result(connection)) != 0)
{
int recordCount = mysql_num_rows(result);
int fieldCount = mysql_num_fields(result);
MYSQL_FIELD *fields = mysql_fetch_fields(result);
NSString *keys[fieldCount];
int i;
for (i = 0; i < fieldCount; i++)
{
keys[i] = [NSString stringWithUTF8String: (char*)fields[i].name];
}
records = [[ltype alloc] initWithCapacity: recordCount];
for (i = 0; i < recordCount; i++)
{
SQLRecord *record;
MYSQL_ROW row = mysql_fetch_row(result);
unsigned long *lengths = mysql_fetch_lengths(result);
id values[fieldCount];
int j;
for (j = 0; j < fieldCount; j++)
{
id v = null;
unsigned char *p = (unsigned char*)row[j];
if (p != 0)
{
int size = lengths[j];
if ([self debugging] > 1)
{
[self debug: @"%@ type:%d size: %d val:%*.*s\n",
keys[j], fields[j].type, size, size, size, p];
}
switch (fields[j].type)
{
case FIELD_TYPE_TIMESTAMP:
{
char b[32];
NSString *f;
NSString *s;
if (size > 14)
{
size = 19;
f = @"%Y-%m-%d %H:%M:%S %z";
}
else if (size == 14)
{
f = @"%Y%m%d%H%M%S %z";
}
else if (size == 12)
{
f = @"%y%m%d%H%M%S %z";
}
else if (size == 10)
{
f = @"%y%m%d%H%M %z";
}
else if (size == 8)
{
f = @"%y%m%d%H %z";
}
else if (size == 6)
{
f = @"%y%m%d %z";
}
else if (size == 4)
{
f = @"%y%m %z";
}
else
{
f = @"%y %z";
}
strncpy(b, (char*)p, size);
strncpy(b + size, (char*)" +0000", 6);
s = [[NSString alloc] initWithBytes: b
length: size + 6
encoding: NSASCIIStringEncoding];
v = [NSCalendarDate dateWithString: s
calendarFormat: f
locale: nil];
[v setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
if ([self debugging] > 1)
[self debug: @"Parsed '%@' as '%@'\n", s, v];
[s release];
}
break;
case FIELD_TYPE_TINY:
v = [NSString stringWithFormat: @"%u", *p];
break;
case FIELD_TYPE_BLOB:
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];
}
break;
default:
if (YES == _shouldTrim)
{
trim((char*)p);
}
v = [NSString stringWithUTF8String: (char*)p];
break;
}
}
values[j] = v;
}
record = [rtype newWithValues: values
keys: keys
count: fieldCount];
[records addObject: record];
[record release];
}
}
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];
}
}
}
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];
}
if (result != 0)
{
mysql_free_result(result);
}
[records release];
records = nil;
[localException retain];
[arp release];
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER
[arp release];
if (result != 0)
{
mysql_free_result(result);
}
return [records autorelease];
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
{
const unsigned char *bytes = [blob bytes];
unsigned char *ptr = buf;
unsigned l = [blob length];
unsigned i;
*ptr++ = '\'';
for (i = 0; i < l; i++)
{
unsigned char c = bytes[i];
if (c == '\0')
{
*ptr++ = '\\';
*ptr++ = '0';
}
else if (c == '\\' || c == '\'' || c == '"')
{
*ptr++ = '\\';
*ptr++ = c;
}
else
{
*ptr++ = c;
}
}
*ptr++ = '\'';
return ((void*)ptr - buf);
}
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob
{
const unsigned char *bytes = [blob bytes];
unsigned l = [blob length];
unsigned length = 2; // Quotes around BLOB
while (l-- > 0)
{
unsigned char c = bytes[l];
if (c == '\0' || c == '\\' || c == '\'' || c == '"')
{
length++;
}
length++;
}
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
SQLClient-1.7.3/README 0000664 0000765 0000765 00000010537 10377047517 014117 0 ustar brains99 brains99 What is the SQLClient library?
The SQLClient library is designed to provide a simple interface to SQL
databases for GNUstep applications. It does not attempt the sort of
abstraction provided by the much more sophisticated GDL2 library
but rather allows applications to directly execute SQL queries and statements.
SQLClient provides for the Objective-C programmer much the same thing that
JDBC provides for the Java programmer (though SQLClient is a bit faster,
easier to use, and easier to add new database backends for than JDBC).
The major features of the SQLClient library are -
* Simple API for executing queries and statements...
a variable length sequence of comma separated strings and other
objects (NSNumber, NSDate, NSData) are concatenated into a single
SQL statement and executed.
* Simple API for combining multiple SQL statements into a single
transaction which can be used to minimise client-server interactions
to get the best possible performance from your database.
* Supports multiple sumultaneous named connections to a database server
in a thread-safe manner.
* Supports multiple simultaneous connections to different database
servers with backend driver bundles loaded for different database
engines. Clear, simple subclassing of the abstract base class to
enable easy implementation of new backend bundles.
* Configuration for all connections held in one place and referenced
by connection name for ease of configuration control. Changes via
NSUserDefaults can even allow reconfiguration of client instances
within a running application.
* Thread safe operation... The base class supports locking such that
a single instance can be shared between multiple threads.
What backend bundles are available?
Current backend bundles are -
* ECPG - a bundle using the embedded SQL interface for postgres.
This is based on a similar code which has been in production
use for over eighteen months, so it should be reliable.
* Postgres - a bundle using the libpq native interface for postgres.
This is the preferred backend as it allows 'SELECT FOR UPDATE',
which the ECPG backend cannot support due to limitations in the
postgres implementation of cursors. Now well tested efficient,
and in use in large commercial systems.
* MySQL - a bundle using the mysqlclient library for *recent* MySQL.
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.
No support for BLOBs yet.
Where can you get it? How can you install it?
The SQLClient library is currently available at
or via CVS from the GNUstep CVS repository (See . 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.
* 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.
* Then you can run the test programs.
* Your most likely problems are that the configure script may
not detect the database libraries you want... Please figure
out how to modify configure.ac so that it will detect the
required headers and libraries on your system, and supply a patch.
Bug reports, patches, and contributions (eg a backend bundle for a new database)
should be entered on the GNUstep project page
SQLClient-1.7.3/GNUmakefile.wrapper.objc.preamble 0000664 0000765 0000765 00000000132 10511405247 021444 0 ustar brains99 brains99 LIBRARIES_DEPEND_UPON += -lPerformance.A
ADDITIONAL_LIB_DIRS = -L../../$(GNUSTEP_OBJ_DIR)
SQLClient-1.7.3/config.guess 0000775 0000765 0000765 00000113144 10672503115 015542 0 ustar brains99 brains99 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002 Free Software Foundation, Inc.
timestamp='2002-02-12'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner .
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;;
--version | -v )
echo "$version" ; exit 0 ;;
--help | --h* | -h )
echo "$usage"; exit 0 ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
dummy=dummy-$$
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 ; do
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
if test $? = 0 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
rm -f $dummy.c $dummy.o $dummy.rel ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
UNAME_MACHINE_ARCH=`(uname -p) 2>/dev/null` || \
UNAME_MACHINE_ARCH=unknown
case "${UNAME_MACHINE_ARCH}" in
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# The OS release
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
macppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvmeppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mipseb-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
cat <$dummy.s
.data
\$Lformat:
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
.text
.globl main
.align 4
.ent main
main:
.frame \$30,16,\$26,0
ldgp \$29,0(\$27)
.prologue 1
.long 0x47e03d80 # implver \$0
lda \$2,-1
.long 0x47e20c21 # amask \$2,\$1
lda \$16,\$Lformat
mov \$0,\$17
not \$1,\$18
jsr \$26,printf
ldgp \$29,0(\$26)
mov 0,\$16
jsr \$26,exit
.end main
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
1-0)
UNAME_MACHINE="alphaev5"
;;
1-1)
UNAME_MACHINE="alphaev56"
;;
1-101)
UNAME_MACHINE="alphapca56"
;;
2-303)
UNAME_MACHINE="alphaev6"
;;
2-307)
UNAME_MACHINE="alphaev67"
;;
2-1307)
UNAME_MACHINE="alphaev68"
;;
esac
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit 0;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit 0 ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
i86pc:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit 0 ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit 0 ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit 0 ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit 0 ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit 0 ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit 0 ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit 0 ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit 0 ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit 0 ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit 0 ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit 0 ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit 0 ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit 0 ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit 0 ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit 0 ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
*:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit 0 ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit 0 ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit 0 ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit 0 ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit 0 ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
rm -f $dummy.c $dummy
fi ;;
esac
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit 0 ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit 0 ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit 0 ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit 0 ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3D:*:*:*)
echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit 0 ;;
i*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit 0 ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit 0 ;;
x86:Interix*:3*)
echo i386-pc-interix3
exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i386-pc-interix
exit 0 ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit 0 ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
mips:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
rm -f $dummy.c
test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit 0 ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit 0 ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit 0 ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
esac
exit 0 ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit 0 ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit 0 ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit 0 ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0 ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0 ;;
"")
# Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help.
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
exit 0 ;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#ifdef __INTEL_COMPILER
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
rm -f $dummy.c
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit 0 ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
i*86:*:5:[78]*)
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit 0 ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
paragon:*:*:*)
echo i860-intel-osf1
exit 0 ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit 0 ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit 0 ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit 0 ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit 0 ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit 0 ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit 0 ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit 0 ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit 0 ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit 0 ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
echo `uname -p`-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
if test "${UNAME_MACHINE}" = "x86pc"; then
UNAME_MACHINE=pc
echo i386-${UNAME_MACHINE}-nto-qnx
else
echo `uname -p`-${UNAME_MACHINE}-nto-qnx
fi
exit 0 ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit 0 ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit 0 ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit 0 ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit 0 ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit 0 ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit 0 ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit 0 ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit 0 ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit 0 ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit 0 ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <
# include
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit 0 ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
c34*)
echo c34-convex-bsd
exit 0 ;;
c38*)
echo c38-convex-bsd
exit 0 ;;
c4*)
echo c4-convex-bsd
exit 0 ;;
esac
fi
cat >&2 < in order to provide the needed
information to handle your system.
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = ${UNAME_MACHINE}
UNAME_RELEASE = ${UNAME_RELEASE}
UNAME_SYSTEM = ${UNAME_SYSTEM}
UNAME_VERSION = ${UNAME_VERSION}
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
SQLClient-1.7.3/testSQLite.m 0000664 0000765 0000765 00000006312 12115132001 015421 0 ustar brains99 brains99 /**
Copyright (C) 2005 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
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: 2013-03-04 14:47:29 +0000 (Mon, 04 Mar 2013) $ $Revision: 36261 $
*/
#import
#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;
}
SQLClient-1.7.3/ECPG.pgm 0000664 0000765 0000765 00000062425 12213611701 014444 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientECPG for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2013-09-10 13:42:41 +0100 (Tue, 10 Sep 2013) $ $Revision: 37063 $
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
@interface SQLClientECPG : SQLClient
@end
@interface SQLClientECPG(Embedded)
- (const char *) blobFromData: (NSData*)data;
- (NSData *) dataFromBlob: (const char *)blob;
- (BOOL) dbFromDate: (NSDate*)d toBuffer: (char*)b length: (int)l;
- (BOOL) dbFromString: (NSString*)s toBuffer: (char*)b length: (int)l;
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l;
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l;
@end
/* This looks like a Postgres specific issue/feature/bug - for some
* reason, ':' inside a string often causes the string to be
* horribly mutilated before being handed to the database
* ... probably postgres is trying to replace variables or something
* - avoid all these problems by replacing ':' with its octal code
* \\072.
*/
static NSString *
hackForPrepare(NSString *s)
{
NSRange r;
r = [s rangeOfString: @":"];
if (r.length > 0)
{
s = [s stringByReplacingString: @":" withString: @"\\072"];
}
return s;
}
EXEC SQL INCLUDE sql3types;
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR CALL SQLErrorHandler();
/**
* Return YES of the last SQL error indicated we are out of data,
* NO otherwise.
*/
BOOL SQLOutOfData()
{
if (sqlca.sqlcode == 100)
{
return YES;
}
else
{
return NO;
}
}
/**
* This error handler is called for most errors ... so we can get it to
* raise an exception for us.
*/
void SQLErrorHandler()
{
int code = sqlca.sqlcode;
const char *ptr = sqlca.sqlerrm.sqlerrmc;
const char *e0 = "'no connection to the server'";
const char *e1 = "Error in transaction processing";
sqlca.sqlcode = 0; // Reset error code
NSLog (@"Raising an exception, %d, %s", code, sqlca.sqlerrm.sqlerrmc);
if (strncmp(ptr, e0, strlen(e0)) == 0
|| strncmp(ptr, e1, strlen(e1)) == 0)
{
[NSException raise: SQLConnectionException
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
}
else
{
[NSException raise: SQLException
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
}
}
@implementation SQLClientECPG
static NSDate *future = nil;
+ (void) initialize
{
if (future == nil)
{
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
[future retain];
}
}
- (BOOL) backendConnect
{
if (connected == NO)
{
if ([self database] != nil
&& [self user] != nil
&& [self password] != nil)
{
Class c = NSClassFromString(@"CmdClient");
[[self class] purgeConnections: nil];
NS_DURING
{
EXEC SQL BEGIN DECLARE SECTION;
const char *database_c;
const char *user_c;
const char *password_c;
const char *client_c;
EXEC SQL END DECLARE SECTION;
database_c = [[self database] UTF8String];
user_c = [[self user] UTF8String];
password_c = [[self password] UTF8String];
client_c = [[self clientName] UTF8String];
if (c != 0)
{
if ([self debugging] > 0)
{
[self debug:
@"Connect to '%@' database %s user %s as %s",
[self name], database_c, user_c, client_c];
}
}
EXEC SQL CONNECT TO :database_c
AS :client_c
USER :user_c
USING :password_c;
connected = YES;
if (c != 0)
{
if ([self debugging] > 0)
{
[self debug: @"Connected to '%@' (%s)",
[self name], client_c];
}
}
EXEC SQL AT :client_c SET AUTOCOMMIT TO ON;
// For backwards compat, make this the default
EXEC SQL SET CONNECTION TO :client_c;
}
NS_HANDLER
{
[self debug: @"Error connecting to '%@' database: %@",
[self name], localException];
}
NS_ENDHANDLER
}
else
{
[self debug:
@"Connect to '%@' with no user/password/database configured",
[self name]];
}
}
return connected;
}
- (void) backendDisconnect
{
if (connected == YES)
{
NS_DURING
{
EXEC SQL BEGIN DECLARE SECTION;
const char *client_c;
EXEC SQL END DECLARE SECTION;
if ([self isInTransaction] == YES)
{
[self rollback];
}
client_c = [[self clientName] UTF8String];
if ([self debugging] > 0)
{
[self debug: @"Disconnecting client %@", [self clientName]];
}
EXEC SQL DISCONNECT :client_c;
if ([self debugging] > 0)
{
[self debug: @"Disconnected client %@", [self clientName]];
}
}
NS_HANDLER
{
[self debug: @"Error disconnecting from database (%@): %@",
[self clientName], localException];
}
NS_ENDHANDLER
connected = NO;
}
}
- (NSInteger) backendExecute: (NSArray*)info
{
EXEC SQL BEGIN DECLARE SECTION;
char *statement;
char *handle;
EXEC SQL END DECLARE SECTION;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
unsigned int length;
NSString *stmt = [info objectAtIndex: 0];
length = [stmt length];
if (length == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
statement = (char*)[hackForPrepare(stmt) UTF8String];
length = strlen(statement);
statement = (char*)[self insertBLOBs: info
intoStatement: statement
length: length
withMarker: "'''"
length: 3
giving: &length];
handle = (char*)[[self clientName] UTF8String];
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[arp release];
[NSException raise: SQLException
format: @"Unable to connect to '%@' to execute statement %@",
[self name], stmt];
}
NS_DURING
{
EXEC SQL PREPARE command from :statement;
EXEC SQL AT :handle EXECUTE command;
}
NS_HANDLER
{
NSString *n = [localException name];
NSString *msg = [localException reason];
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
/*
* remove line number information from database exception message
* since it's meaningless to the developer as it's the line number
* in this file rather than the code which is calling us.
*/
if ([n isEqual: SQLException] == YES
|| [n isEqual: SQLConnectionException] == YES)
{
NSRange r;
r = [msg rangeOfString: @" in line " options: NSBackwardsSearch];
if (r.length > 0)
{
msg = [msg substringToIndex: r.location];
localException = [NSException exceptionWithName: n
reason: msg
userInfo: nil];
}
}
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;
}
static unsigned int trim(char *str)
{
char *start = str;
while (isspace(*str))
{
str++;
}
if (str != start)
{
strcpy(start, str);
}
str = start;
while (*str != '\0')
{
str++;
}
while (str > start && isspace(str[-1]))
{
*--str = '\0';
}
return (str - start);
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
EXEC SQL BEGIN DECLARE SECTION;
bool aBool;
int anInt;
int count;
int index;
int indicator;
int type;
int length;
int octetLength;
int precision;
int scale;
int returnedOctetLength;
int dtiCode;
char fieldName[120];
char *aString;
float aFloat;
double aDouble;
char *query;
char *handle;
EXEC SQL END DECLARE SECTION;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSMutableArray *records;
BOOL isOpen = NO;
BOOL localTransaction = NO;
length = [stmt length];
if (length == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
query = (char*)[hackForPrepare(stmt) UTF8String];
handle = (char*)[[self clientName] UTF8String];
records = [[ltype alloc] initWithCapacity: 32];
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[arp release];
[NSException raise: SQLException
format: @"Unable to connect to '%@' to run query %@",
[self name], stmt];
}
NS_DURING
{
EXEC SQL ALLOCATE DESCRIPTOR myDesc;
EXEC SQL PREPARE myQuery from :query;
if ([self isInTransaction] == NO)
{
EXEC SQL AT :handle BEGIN;
localTransaction = YES;
}
EXEC SQL AT :handle DECLARE myCursor CURSOR FOR myQuery;
EXEC SQL AT :handle OPEN myCursor;
isOpen = YES;
while (1)
{
EXEC SQL AT :handle FETCH IN myCursor INTO SQL DESCRIPTOR myDesc;
if (sqlca.sqlcode)
{
break;
}
EXEC SQL GET DESCRIPTOR myDesc :count = COUNT;
if (count > 0)
{
SQLRecord *record;
id keys[count];
id values[count];
for (index = 1; index <= count; ++index)
{
id v;
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:indicator = INDICATOR,
:length = LENGTH,
:fieldName = NAME,
:octetLength = OCTET_LENGTH,
:precision = PRECISION,
:returnedOctetLength = RETURNED_OCTET_LENGTH,
:scale = SCALE,
:type = TYPE;
// printf("%s type:%d scale:%d\n", fieldName, type, scale);
if (indicator == -1)
{
v = [NSNull null];
}
else
{
/*
* HACK ... for some reason date/time data seems to
* get a negative type returned, so we check any
* negative time to see if it is really date/time
* and bodg the type code to fit.
*/
if (type < 0)
{
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:dtiCode = DATETIME_INTERVAL_CODE;
if (dtiCode != SQL3_DDT_ILLEGAL)
{
type = SQL3_DATE_TIME_TIMESTAMP;
}
}
aString = 0;
switch (type)
{
case SQL3_BOOLEAN:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aBool = DATA;
if (aBool == 1)
{
v = [NSNumber numberWithBool: YES];
}
else if (aBool == 0)
{
v = [NSNumber numberWithBool: NO];
}
else
{
[NSException raise: NSGenericException
format: @"Bad bool for '%s' - '%d'",
fieldName, aBool];
}
break;
case SQL3_NUMERIC:
case SQL3_DECIMAL:
if (scale == 0)
{
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:anInt = DATA;
v = [NSNumber numberWithInt: anInt];
}
else
{
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aFloat = DATA;
v = [NSNumber numberWithFloat: aFloat];
}
break;
case SQL3_INTEGER:
case SQL3_SMALLINT:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:anInt = DATA;
v = [NSNumber numberWithInt: anInt];
break;
case SQL3_FLOAT:
case SQL3_REAL:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aFloat = DATA;
v = [NSNumber numberWithFloat: aFloat];
break;
case SQL3_DOUBLE_PRECISION:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aDouble = DATA;
v = [NSNumber numberWithDouble: aDouble];
break;
case SQL3_DATE_TIME_TIMESTAMP:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:dtiCode = DATETIME_INTERVAL_CODE,
:aString = DATA;
v = [self dbToDateFromBuffer: aString
length: trim(aString)];
free(aString);
break;
case SQL3_INTERVAL:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
trim(aString);
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
case SQL3_CHARACTER:
case SQL3_CHARACTER_VARYING:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
if (_shouldTrim)
{
trim(aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
case -17:
/*
* HACK ... BYTEA type determined by experiment.
* who knows how/why this might change.
*/
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
v = [self dataFromBlob: aString];
free(aString);
break;
case -20:
/*
* HACK ... by experiment this seems to be an
* integer returned by a function.
*/
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:anInt = DATA;
v = [NSNumber numberWithInt: anInt];
break;
default:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
if (_shouldTrim)
{
trim(aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
if ([self debugging] > 0)
{
[self debug:
@"Unknown data type (%d) for '%s' ... '%@'",
type, fieldName, v];
}
break;
}
}
values[index-1] = v;
keys[index-1] = [NSString stringWithUTF8String:
fieldName];
}
record = [rtype newWithValues: values
keys: keys
count: count];
[records addObject: record];
[record release];
}
}
isOpen = NO;
EXEC SQL AT :handle CLOSE myCursor;
if (localTransaction == YES)
{
EXEC SQL AT :handle COMMIT;
localTransaction = NO;
}
EXEC SQL DEALLOCATE DESCRIPTOR myDesc;
}
NS_HANDLER
{
NSString *n = [localException name];
NSString *msg = [localException reason];
[records release];
records = nil;
NS_DURING
{
if (isOpen == YES)
{
EXEC SQL AT :handle CLOSE myCursor;
}
if (localTransaction == YES)
{
EXEC SQL AT :handle ROLLBACK;
}
}
NS_HANDLER
{
NSString *e = [localException name];
if ([e isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
}
NS_ENDHANDLER
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
/*
* remove line number information from database exception message
* since it's meaningless to the developer as it's the line number
* in this file rather than the code which is calling us.
*/
if ([n isEqual: SQLException] == YES
|| [n isEqual: SQLConnectionException] == YES)
{
NSRange r;
r = [msg rangeOfString: @" in line " options: NSBackwardsSearch];
if (r.length > 0)
{
msg = [msg substringToIndex: r.location];
localException = [NSException exceptionWithName: n
reason: msg
userInfo: nil];
}
}
[localException retain];
[arp release];
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER
[arp release];
return [records autorelease];
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
{
const unsigned char *src = [blob bytes];
unsigned sLen = [blob length];
unsigned char *ptr = (unsigned char*)buf;
unsigned length = 0;
unsigned i;
ptr[length++] = '\'';
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126 || c == ':')
{
ptr[length] = '\\';
ptr[length+1] = '\\';
ptr[length + 4] = (c & 7) + '0';
c >>= 3;
ptr[length + 3] = (c & 7) + '0';
c >>= 3;
ptr[length + 2] = (c & 7) + '0';
length += 5;
}
else if (c == '\\')
{
ptr[length++] = '\\';
ptr[length++] = '\\';
ptr[length++] = '\\';
ptr[length++] = '\\';
}
else if (c == '\'')
{
ptr[length++] = '\\';
ptr[length++] = '\'';
}
else
{
ptr[length++] = c;
}
}
ptr[length++] = '\'';
return length;
}
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob
{
unsigned int sLen = [blob length];
unsigned char *src = (unsigned char*)[blob bytes];
unsigned int length = 2;
unsigned int i;
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126 || c == ':')
{
length += 5;
}
else if (c == '\\')
{
length += 4;
}
else if (c == '\'')
{
length += 2;
}
else
{
length += 1;
}
}
return length;
}
- (const char *) blobFromData: (NSData*)data
{
NSMutableData *md;
unsigned sLen = [data length];
unsigned char *src = (unsigned char*)[data bytes];
unsigned dLen = 0;
unsigned char *dst;
unsigned i;
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126)
{
dLen += 4;
}
else if (c == 92)
{
dLen += 2;
}
else
{
dLen += 1;
}
}
md = [NSMutableData dataWithLength: dLen + 1];
dst = (unsigned char*)[md mutableBytes];
dLen = 0;
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126)
{
dst[dLen] = '\\';
dst[dLen + 3] = (c & 7) + '0';
c >>= 3;
dst[dLen + 2] = (c & 7) + '0';
c >>= 3;
dst[dLen + 1] = (c & 7) + '0';
dLen += 4;
}
else if (c == 92)
{
dst[dLen++] = '\\';
dst[dLen++] = '\\';
}
else
{
dst[dLen++] = c;
}
}
dst[dLen] = '\0';
return (const char*)dst; // Owned by autoreleased NSMutableData
}
- (NSData *) dataFromBlob: (const char *)blob
{
NSMutableData *md;
unsigned sLen = strlen(blob == 0 ? "" : blob);
unsigned dLen = 0;
unsigned char *dst;
unsigned i;
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
dLen++;
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
i += 2; // Skip 2 digits octal
}
}
}
md = [NSMutableData dataWithLength: dLen];
dst = (unsigned char*)[md mutableBytes];
dLen = 0;
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
c = c - '0';
c <<= 3;
c += blob[++i] - '0';
c <<= 3;
c += blob[++i] - '0';
}
}
dst[dLen++] = c;
}
return md;
}
- (BOOL) dbFromDate: (NSDate*)d toBuffer: (char*)b length: (int)l
{
NSString *s;
/*
* Ensure we have a four digit year.
*/
if ([d timeIntervalSinceDate: future] > 0)
{
d = future;
}
s = [d descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
timeZone: nil
locale: nil];
return [self dbFromString: s toBuffer: b length: l];
}
- (BOOL) dbFromString: (NSString*)s toBuffer: (char*)b length: (int)l
{
NSData *d;
BOOL ok = YES;
unsigned size = l;
if (l <= 0)
{
[NSException raise: NSInvalidArgumentException
format: @"-%@: length too small (%d)",
NSStringFromSelector(_cmd), l];
}
if (b == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"-%@: buffer is null",
NSStringFromSelector(_cmd)];
}
if (s == nil)
{
s = @"";
}
d = [s dataUsingEncoding: NSUTF8StringEncoding];
if (l < (int)[d length])
{
/*
* As the data is UTF8, we need to avoid truncating in the
* middle of a multibyte character, so we shorten the
* original string and reconvert to UTF8 until we find a
* string that fits.
*/
if ((int)[s length] > l)
{
s = [s substringToIndex: l];
d = [s dataUsingEncoding: NSUTF8StringEncoding];
}
while ((int)[d length] > l)
{
s = [s substringToIndex: [s length] - 1];
d = [s dataUsingEncoding: NSUTF8StringEncoding];
}
ok = NO;
}
size = [d length];
memcpy(b, (const char*)[d bytes], size);
/*
* Pad with nuls and ensure there is a nul terminator.
*/
while ((int)size <= l)
{
b[size++] = '\0';
}
return ok;
}
- (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;
memcpy(buf, b, l);
b = buf;
/*
* Find end of string.
*/
for (i = 0; i < l; i++)
{
if (b[i] == '\0')
{
l = i;
break;
}
}
while (l > 0 && isspace(b[l-1]))
{
l--;
}
b[l] = '\0';
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
return [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d"
locale: nil];
}
i = l;
/* Convert +/-HH:SS timezone to +/-HHSS
*/
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
{
b[i-3] = b[i-2];
b[i-2] = b[i-1];
b[--i] = '\0';
}
while (i-- > 0)
{
if (b[i] == '+' || b[i] == '-')
{
break;
}
if (b[i] == ':' || b[i] == ' ')
{
i = 0;
break; /* No time zone found */
}
}
if (i == 0)
{
e = l;
}
else
{
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';
}
/*
* Ensure we have a four digit timezone value.
*/
if (isdigit(b[i+1]) && isdigit(b[i+2]))
{
if (b[i+3] == '\0')
{
// Two digit time zone ... append zero minutes
b[l++] = '0';
b[l++] = '0';
b[l] = '\0';
}
else if (b[i+3] == ':')
{
// Zone with colon before minutes ... remove it
b[i+3] = b[i+4];
b[i+4] = b[i+5];
b[--l] = '\0';
}
}
}
/* kludge for timestamps with fractional second information.
* Force it to 3 digit millisecond */
while (i-- > 0)
{
if (b[i] == '.')
{
milliseconds = YES;
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+3], &b[i], e-i);
l += 3;
memcpy(&b[i], "000", 3);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+2], &b[i], e-i);
l += 2;
memcpy(&b[i], "00", 2);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+1], &b[i], e-i);
l += 1;
memcpy(&b[i], "0", 1);
}
i++;
break;
}
}
if (i > 0 && i < e)
{
memmove(&b[i], &b[e], l - e);
l -= (e - i);
}
b[l] = '\0';
if (l == 0)
{
return nil;
}
s = [NSString stringWithUTF8String: b];
if (YES == timezone)
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
}
}
else
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S"
locale: nil];
}
}
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
return d;
}
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l
{
NSData *d;
NSString *s;
/*
* Database fields are padded to the full field size with spaces or nuls ...
* we need to remove that padding before placing in a string.
*/
while (l > 0 && b[l-1] <= ' ')
{
l--;
}
d = [[NSData alloc] initWithBytes: b length: l];
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
[d release];
return [s autorelease];
}
@end
SQLClient-1.7.3/install-sh 0000775 0000765 0000765 00000012721 10377047517 015240 0 ustar brains99 brains99 #! /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
SQLClient-1.7.3/config.h.in 0000664 0000765 0000765 00000006737 11040367343 015257 0 ustar brains99 brains99 /* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the header file. */
#undef HAVE_ECPGLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the 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 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 header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the 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 header file. */
#undef HAVE_SQLITE3_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the header file. */
#undef HAVE__USR_INCLUDE_PGSQL_ECPGLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE__USR_INCLUDE_PGSQL_LIBPQ_FE_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_ECPGLIB_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_LIBPQ_FE_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_INCLUDE_POSTGRESQL_ECPGLIB_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_INCLUDE_POSTGRESQL_LIBPQ_FE_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_ECPGLIB_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_LIBPQ_FE_H
/* Define to 1 if you have the header
file. */
#undef HAVE__USR_LOCAL_PGSQL_INCLUDE_ECPGLIB_H
/* Define to 1 if you have the 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
SQLClient-1.7.3/SQLClient.html 0000664 0000765 0000765 00000226537 10377047517 015734 0 ustar brains99 brains99
SQLClient documentation
Authors
- Richard Frith-Macdonald (
rfm@gnu.org
)
-
Version: 1.4
Date: 2004/05/07 08:16:16
Copyright: (C) 2004 Free Software Foundation, Inc.
The SQLClient library is designed to provide a simple
interface to SQL databases for GNUstep
applications. It does not attempt the sort of
abstraction provided by the much more
sophisticated GDL2 library, but rather allows
applications to directly execute SQL queries and
statements.
The major features of the SQLClient library are -
-
Simple API for executing queries and statements... a
variable length sequence of comma separated
strings and other objects (NSNumber, NSDate,
NSData) are concatenated into a single SQL
statement and executed.
-
Support multiple sumultaneous named connections to
a database server in a thread-safe manner.
-
Support multiple simultaneous connections to
different database servers with backend driver
bundles loaded for different database engines.
Clear, simple subclassing of the abstract base class
to enable easy implementation of new backend bundles.
-
Configuration for all connections held in one
place and referenced by connection name for ease of
configuration control. Changes via
NSUserDefaults can even allow
reconfiguration of client instances within
a running application.
-
Thread safe operation... The base class supports
locking such that a single instance can be shared
between multiple threads.
Current backend bundles are -
-
ECPG - a bundle using the embedded SQL interface for
postgres.
This is based on a similar code
which has been in production use for over eighteen
months, so it should be reliable.
-
Postgres - a bundle using the libpq native
interface for postgres.
This is the
preferred backend as it allows 'SELECT FOR
UPDATE', which the ECPG backend cannot support due
to limitations in the postgres implementation of
cursors. The code is however not as well tested as
the ECPG interface.
-
MySQL - a bundle using the mysqlclient library for
*recent* MySQL.
I don't use MySQL... but
the test program ran successfully with a vanilla
install of the MySQL packages for recent Debian
unstable.
-
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.
No support for
BLOBs yet.
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.
-
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.
-
Then you can run the test programs.
-
Your most likely problems are that the configure
script may not detect the database libraries you
want... Please figure out how to modify
configure.ac
so that it will detect the
required headers and libraries on your system, and
supply na patch.
-
Once the library is installed, you can include the
header file
<SQLClient/SQLClient.h%gt;
and link
your programs with the SQLClient
library
to use it.
Bug reports, patches, and contributions (eg a backend
bundle for a new database) should be entered on the
GNUstep project page
<http://savannah.gnu.org/projects/gnustep>
and the bug reporting page
<http://savannah.gnu.org/bugs/?group=gnustep>
- Declared in:
- SQLClient.h
The SQLClient class encapsulates dynamic SQL access to
relational database systems. A shared instance
of the class is used for each database (as identified by
the name of the database), and the number of
simultanous database connections is managed
too.
SQLClient is an abstract base class... when you
create an instance of it, you are actually creating
an instance of a concrete subclass whose implementation
is loaded from a bundle.
Instance Variables for SQLClient Class
@private NSString* _client;
Identifier within backend
@private NSString* _database;
The configured database name/host
@private unsigned int _debugging;
The current debugging level
@private NSTimeInterval _duration;
Description forthcoming.
@private BOOL _inTransaction;
A flag indicating whether this instance is currently
within a transaction. This variable must
only be set by the
-begin
, -commit
or
-rollback
methods.
Are we inside a transaction?
@private NSDate* _lastOperation;
Timestamp of last operation.
Maintained by
the
-simpleExecute:
and
-simpleQuery:
methods.
@private NSString* _name;
Unique identifier for instance
@private NSString* _password;
The configured password
@private NSString* _user;
The configured user
@private BOOL connected;
A flag indicating whether this instance is currently
connected to the backend database server. This
variable must only be set by the
-backendConnect
or
-backendDisconnect
methods.
@private void* extra;
For subclass specific data
@private NSRecursiveLock* lock;
Maintain thread-safety
Method summary
+ (NSArray*) allClients;
Returns an array containing all the SQLClient
instances.
+ (SQLClient*) clientWithConfiguration: (NSDictionary*)config name: (NSString*)reference;
Return an existing SQLClient instance (using
+existingClient:) if possible, or creates
one, initialises it using
-initWithConfiguration:name:
, and returns the new instance (autoreleased).
Returns nil
on failure.
+ (SQLClient*) existingClient: (NSString*)reference;
Return an existing SQLClient instance for the
specified name if one exists, otherwise returns
nil
.
+ (unsigned int) maxConnections;
Return the maximum number of simultaneous database
connections permitted (set by
+setMaxConnections:
and defaults to 8)
+ (void) purgeConnections: (NSDate*)since;
Use this method to reduce the number of database
connections currently active so that it is
less than the limit set by the
+setMaxConnections:
method. This mechanism is used internally by the
class to ensure that, when it is about to open a
new connection, the limit is not exceeded.
If since is not nil
, then any
connection which has not been used more
recently than that date is disconnected anyway.
You can (and probably should) use this
periodically to purge idle connections, but
you can also pass a date in the future to close all
connections.
+ (void) setMaxConnections: (unsigned int)c;
Set the maximum number of simultaneous database
connections permitted (defaults to 8 and may
not be set less than 1).
This value is used by the
+purgeConnections:
method to determine how many connections should be
disconnected when it is called.
- (void) begin;
Start a transaction for this database client.
You must match this with either a
-commit
or a -rollback
.
Normally, if you execute an SQL statement
without using this method first, the
autocommit feature is employed, and the
statement takes effect immediately. Use of this
method permits you to execute several statements
in sequence, and only have them take effect (as a
single operation) when you call the
-commit
method.
NB. You must not execute an SQL
statement which would start a transaction
directly... use only this method.
- (NSString*) clientName;
Return the client name for this instance.
Normally this is useful only for
debugging/reporting purposes, but if
you are using multiple instances of this class in your
application, and you are using embedded SQL,
you will need to use this method to fetch the
client/connection name and store its
C-string representation in a variable
'connectionName' declared to the sql
preprocessor, so you can then have statements
of the form - 'exec sql at :connectionName...'.
- (void) commit;
Complete a transaction for this database client.
This must match an earlier
-begin
.
NB. You must not execute an SQL
statement which would commit or rollback a
transaction directly... use only this method
or the
-rollback
method.
- (BOOL) connect;
If the connected instance variable is
NO
, this method calls
-backendConnect
to ensure that there is a connection to the database
server established. Returns the result.
Performs any necessary locking for thread safety.
- (BOOL) connected;
Return a flag to say whether a connection to the
database server is currently live. This is mostly
useful for debug/reporting, but is used internally
to keep track of active connections.
- (NSString*) database;
Return the database name for this instance (or
nil
).
- (void) disconnect;
If the connected instance variable is
YES
, this method calls
-backendDisconnect
to ensure that the connection to the database server is
dropped.
Performs any necessary locking for
thread safety.
- (void) execute: (NSString*)stmt,...;
Perform arbitrary operation
which does not return any value.
This
arguments to this method are a nil
terminated list which are concatenated in the
manner of the *
-prepare:args:
method.
Any string arguments are assumed to
have been quoted appropriately already, but non-string
arguments are automatically quoted using the
-quote:
method.
[db execute: @"UPDATE ", table, @" SET Name = ",
myName, " WHERE ID = ", myId, nil];
- (void) execute: (NSString*)stmt with: (NSDictionary*)values;
Takes the statement and substitutes in
values from the dictionary where markup of
the format {key} is found.
Passes the result to
the
-execute:,...
method.
[db execute: @"UPDATE {Table} SET Name = {Name} WHERE ID = {ID}"
with: values];
Any non-string values in the dictionary will
be replaced by the results of the
-quote:
method.
The markup format may also be
{key?default} where default is a
string to be used if there is no value for the
key in the dictionary.
- (id) initWithConfiguration: (NSDictionary*)config;
Calls
-initWithConfiguration:name:
passing a nil
reference name.
- (id) initWithConfiguration: (NSDictionary*)config name: (NSString*)reference;
Initialise using the supplied configuration, or
if that is nil
, try to use values from
NSUserDefaults (and automatically update
when the defaults change).
Uses the
reference name to determine configuration
information... and if a nil
name
is supplied, defaults to the value of the SQLClientName
as a user default string or 'Database' if no other name
is provided.
If a SQLClient instance already
exists with the name used for this instance, the
receiver is deallocated and the existing instance
is retained and returned... there may only ever be one
instance for a particular reference
name.
The config argument
(or the SQLClientReferences user default) is a
dictionary with names as keys and dictionaries
as its values. Configuration entries from the dictionary
corresponding to the database client are used
if possible, general entries are used otherwise.
Database... is the name of the database to use, if
it is missing then 'Database' may be used instead.
User... is the name of the database user to
use, if it is missing then 'User' may be used instead.
Password... is the name of the database user
password, if it is missing then 'Password' may be
used instead.
ServerType... is the name of the
backend server to be used... by convention the name
of a bundle containing the interface to that backend. If
this is missing then 'Postgres' is used.
- (BOOL) isInTransaction;
Return the state of the flag indicating whether the
library thinks a transaction is in progress. This
flag is normally maintained by
-begin
, -commit
, and
-rollback
.
- (NSDate*) lastOperation;
Returns the date/time stamp of the last database
operation performed by the receiver, or
nil
if no operation has ever been done
by it.
Simply connecting to or disconnecting from
the databsse does not count as an operation.
- (NSString*) name;
Return the database reference name for this instance
(or nil
).
- (NSString*) password;
Return the database password for this instance (or
nil
).
- (NSMutableArray*) query: (NSString*)stmt,...;
Perform arbitrary query
which returns values.
This method has at least one argument, the string
starting the statement to be executed (which
must have the prefix 'select ').
Additional arguments are a nil
terminated list which also be strings, and
these are appended to the statement.
Any
string arguments are assumed to have been quoted
appropriately already, but non-string
arguments are automatically quoted using the
-quote:
method.
result = [db query: @"SELECT Name FROM ", table, nil];
Upon error, an exception is raised.
The query returns an array of records (each of which
is represented by an SQLRecord object).
Each SQLRecord object contains one or more fields,
in the order in which they occurred in the query.
Fields may also be retrieved by name.
NULL field items are returned as NSNull objects.
Most other field items are returned as NSString
objects.
Date and timestamp field items are returned as
NSDate objects.
- (NSMutableArray*) query: (NSString*)stmt with: (NSDictionary*)values;
Takes the query statement and substitutes in
values from the dictionary where markup of
the format {key} is found.
Passes the result to
the
-query:,...
method to execute.
result = [db query: @"SELECT Name FROM {Table} WHERE ID = {ID}"
with: values];
Any non-string values in the dictionary will
be replaced by the results of the
-quote:
method.
The markup format may also be
{key?default} where default is a
string to be used if there is no value for the
key in the dictionary.
- (NSString*) quote: (id)obj;
Convert an object to a string suitable for use in
an SQL query.
Normally the
-execute:,...
, and
-query:,...
methods will call this method automatically for
everything apart from string objects.
Strings have to be handled specially, because they
are used both for parts of the SQL command, and as
values (where they need to be quoted). So where you
need to pass a string value which needs quoting, you
must call this method explicitly.
Subclasses
may override this method to provide appropriate quoting
for types of object which need database backend
specific quoting conventions. However, the defalt
implementation should be OK for most cases.
The base class implementation formats NSDate
objects as
YYYY-MM-DD hh:mm:ss.mmm ?ZZZZ
NSData objects are not quoted... they must
not appear in queries, and where used for insert/update
operations, they need to be passed to the
-backendExecute:
method unchanged.
For a nil
or
NSNull object, we return NULL.
For a number,
we simply convert directly to a string.
For a
date, we convert to the text format used by the
database, and add leading and trailing quotes.
For a data object, we don't quote... the
other parts of the code need to know they have an
NSData object and pass it on unchanged to the
-backendExecute:
method.
For any other type of data, we just
produce a quoted string representation.
- (NSString*) quoteCString: (const char*)s;
Convert a 'C' string to a string suitable for use
in an SQL query.
- (NSString*) quoteChar: (char)c;
Convert a single character to a string suitable for
use in an SQL query.
- (NSString*) quoteFloat: (float)f;
Convert a float to a string suitable for use in an
SQL query.
- (NSString*) quoteInteger: (int)i;
Convert an integer to a string suitable for use in
an SQL query.
- (void) rollback;
Revert a transaction for this database client.
This must match an earlier
-begin
.
NB. You must not execute an SQL
statement which would commit or rollback a
transaction directly... use only this method
or the
-rollback
method.
- (void) setDatabase: (NSString*)s;
Set the database host/name for this object.
This
is called automatically to configure the connection...
you normally shouldn't need to call it yourself.
- (void) setName: (NSString*)s;
Set the database reference name for this object. This
is used to differentiate between multiple connections to
the database.
This is called automatically to
configure the connection... you normally
shouldn't need to call it yourself.
NB.
attempts to change the name of an instance to that
of an existing instance are ignored.
- (void) setPassword: (NSString*)s;
Set the database password for this object.
This
is called automatically to configure the connection...
you normally shouldn't need to call it yourself.
- (void) setUser: (NSString*)s;
Set the database user for this object.
This is
called automatically to configure the connection...
you normally shouldn't need to call it yourself.
- (void) simpleExecute: (NSArray*)info;
Calls
-backendExecute:
in a safe manner.
Handles locking.
Maintains
-lastOperation
date.
- (NSMutableArray*) simpleQuery: (NSString*)stmt;
Calls
-backendQuery:
in a safe manner.
Handles locking.
Maintains
-lastOperation
date.
- (NSString*) user;
Return the database user for this instance (or
nil
).
- Declared in:
- SQLClient.h
An enhanced array to represent a record returned from a
query. You should NOT try to create instances
of this class except via the
+newWithValues:keys:count:
method.
Instance Variables for SQLRecord Class
@private unsigned int count;
Description forthcoming.
Method summary
+ (id) newWithValues: (id*)v keys: (id*)k count: (unsigned int)c;
Description forthcoming.
- (NSArray*) allKeys;
Returns an array containing the names of all the
fields in the record, in the order in which they
occur in the record.
- (id) objectForKey: (NSString*)key;
Returns the first field in the record whose name
matches the specified key. Uses an exact
match in preference to a case-insensitive match.
- Declared in:
- SQLClient.h
This category contains convenience methods including
those for frequently performed database operations...
message logging etc.
Method summary
- (SQLRecord*) queryRecord: (NSString*)stmt,...;
Executes a query (like the
-query:,...
method) and checks the result (raising an exception
if the query did not contain a single record) and
returns the resulting record.
- (NSString*) queryString: (NSString*)stmt,...;
Executes a query (like the
-query:,...
method) and checks the result.
Raises an
exception if the query did not contain a single
record, or if the record did not contain a single
field.
Returns the resulting field as a
string.
- (void) singletons: (NSMutableArray*)records;
Convenience method to deal with the results of
a query where each record contains a single field... it
converts the array of records returned
by the query to an array containing the fields.
- Declared in:
- SQLClient.h
This category porovides basic methods for logging debug
information.
Method summary
+ (unsigned int) debugging;
Return the class-wide debugging level, which is
inherited by all newly created instances.
+ (NSTimeInterval) durationLogging;
Return the class-wide duration logging threshold,
which is inherited by all newly created instances.
+ (void) setDebugging: (unsigned int)level;
Set the debugging level to be inherited by
all new instances.
+ (void) setDurationLogging: (NSTimeInterval)threshold;
Set the duration logging threshold to be
inherited by all new instances.
- (void) debug: (NSString*)fmt,...;
The default implementation calls NSLogv to log a debug
message.
Override this in a category to
provide more sophisticated logging.
- (unsigned int) debugging;
Return the current debugging level.
- (NSTimeInterval) durationLogging;
Returns the threshold above which queries and
statements taking a long time to execute are
logged. A negative value (default) indicates that
this logging is disabled. A value of zero means that
all statements are logged.
- (void) setDebugging: (unsigned int)level;
Set the debugging level of this instance...
overrides the default level inherited
from the class.
- (void) setDurationLogging: (NSTimeInterval)threshold;
Set a threshold above which queries and
statements taking a long time to execute are
logged. A negative value (default) disables this
logging. A value of zero logs all statements.
- Declared in:
- SQLClient.h
This category contains the methods which a subclass
must override to provide a working instance,
and helper methods for the backend implementations.
Application programmers should not
call the backend methods directly.
When subclassing to produce a backend driver bundle,
please be aware that the subclass must NOT
introduce additional instance variables. Instead
the extra instance variable is provided for
use as a pointer to subclass specific data.
Method summary
- (BOOL) backendConnect;
Subclasses should override this method.
Attempts to establish a connection to the database
server.
Returns a flag to indicate whether
the connection has been established.
If a
connection was already established, returns
YES
and does nothing.
You should
not need to use this method normally, as it is called
for you automatically when necessary.
Subclasses must implement
this method to establish a connection to the
database server process (and initialise the
extra instance variable if necessary),
setting the connected instance variable
to indicate the state of the object.
This method must call
+purgeConnections:
to ensure that there is a free slot for the new
connection.
Application code must not call this
method directly, it is for internal use only. The
-connect
method calls this method if the connected
instance variable is NO
.
- (void) backendDisconnect;
Subclasses should override this method.
Disconnect from the database unless already
disconnected.
This method is called automatically when the
receiver is deallocated or reconfigured, and may
also be called automatically when there are too many
database connections active.
If the receiver is an instance of a subclass which
uses the extra instance variable, it
must clear that variable in the
-backendDisconnect
method, because a reconfiguration may cause the
class of the receiver to change.
This method must set the connected instance
variable to NO
.
Application code must not call this
method directly, it is for internal use only. The
-disconnect
method calls this method if the connected
instance variable is YES
.
- (void) backendExecute: (NSArray*)info;
Subclasses should override this method.
Perform arbitrary operation
which does not return any value.
This
method has a single argument, an array containing
the string representing the statement to be executed as
its first object, and an optional sequence of data
objects following it.
[db backendExecute: [NSArray arrayWithObject:
@"UPDATE MyTable SET Name = 'The name' WHERE ID = 123"]];
The backend implementation is required to perform the
SQL statement using the supplied NSData objects at
the points in the statement marked by the
'''
sequence. The marker saequences
are inserted into the statement at an earlier stage
by the
-execute:,...
and
-execute:with:
methods.
This method should lock the instance using the
lock instance variable for the duration of
the operation, and unlock it afterwards.
NB. callers (other than the
-begin
, -commit
, and
-rollback
methods) should not pass any statement to this
method which would cause a transaction to begin or
end.
Application code must not call this
method directly, it is for internal use only.
- (NSMutableArray*) backendQuery: (NSString*)stmt;
Subclasses should override this method.
Perform arbitrary query
which returns values.
result = [db backendQuery: @"SELECT Name FROM Table"];
Upon error, an exception is raised.
The query returns an array of records (each of which
is represented by an SQLRecord object).
Each SQLRecord object contains one or more fields,
in the order in which they occurred in the query.
Fields may also be retrieved by name.
NULL field items are returned as NSNull objects.
This method should lock the instance using the
lock instance variable for the duration of
the operation, and unlock it afterwards.
Application code must not call this
method directly, it is for internal use only.
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf;
Subclasses should override this method.
This method is only for the use of the
-insertBLOBs:intoStatement:length:withMarker:length:giving:
method.
Subclasses which need to insert binary data into a statement must implement this method to copy the escaped data into place and return the number of bytes actually copied.
- (const void*) insertBLOBs: (NSArray*)blobs intoStatement: (const void*)statement length: (unsigned)sLength withMarker: (const void*)marker length: (unsigned)mLength giving: (unsigned*)result;
This method is a convenience method provided for
subclasses which need to insert escaped binary
data into an SQL statement before sending
the statement to a backend server process.
This method makes use of the
-copyEscapedBLOB:into:
and
-lengthOfEscapedBLOB:
methods, which must be implemented by
the subclass.
The blobs array is an array containing the
original SQL statement string (unused
by this method) followed by the data items to be
inserted.
The statement and sLength
arguments specify the datastream to be copied
and into which the BLOBs are to be inserted.
The marker and mLength
arguments specify the sequence of
marker bytes in the statement
which indicate a position for insertion of a n
escaped BLOB.
The method returns either the original
statement or a copy containing the
escaped BLOBs. The length of the returned data is
stored in result.
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob;
Subclasses should override this method.
This method is only for the use of the
-insertBLOBs:intoStatement:length:withMarker:length:giving:
method.
Subclasses which need to insert binary data into a statement must implement this method to return the length of the escaped bytestream which will be inserted.
NSString* SQLConnectionException;
Exception for when a connection to the server is
lost.
NSString* SQLEmptyException;
Exception for when a query is supposed to return
data and doesn't.
NSString* SQLException;
Exception raised when an error with the remote
database server occurs.
NSString* SQLUniqueException;
Exception for when an insert/update would break the
uniqueness of a field or index.
SQLClient-1.7.3/GNUmakefile.preamble 0000664 0000765 0000765 00000001746 10377047517 017101 0 ustar brains99 brains99 #
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
# ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler
# ADDITIONAL_OBJCFLAGS +=
# Additional flags to pass to the C compiler
# ADDITIONAL_CFLAGS +=
# Additional include directories the compiler should search
# ADDITIONAL_INCLUDE_DIRS +=
# Additional LDFLAGS to pass to the linker
# ADDITIONAL_LDFLAGS +=
# Additional library directories the linker should search
# ADDITIONAL_LIB_DIRS +=
# Additional libraries when linking tools
# ADDITIONAL_TOOL_LIBS +=
# Additional libraries when linking applications
# ADDITIONAL_GUI_LIBS +=
#
# Flags dealing with installing and uninstalling
#
# Additional directories to be created during installation
# ADDITIONAL_INSTALL_DIRS +=
SQLClient-1.7.3/testPostgres.m 0000664 0000765 0000765 00000021033 12041266404 016100 0 ustar brains99 brains99 /**
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2012-10-22 16:57:56 +0100 (Mon, 22 Oct 2012) $ $Revision: 35732 $
*/
#import
#import
#import "SQLClient.h"
@interface Logger : NSObject
- (void) notified: (NSNotification*)n;
@end
@implementation Logger
- (void) notified: (NSNotification*)n
{
NSLog(@"Received %@", n);
}
@end
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;
Logger *l;
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSDictionary dictionaryWithObjectsAndKeys:
@"template1@localhost", @"Database",
@"postgres", @"User",
@"postgres", @"Password",
@"Postgres", @"ServerType",
nil],
@"test",
nil],
@"SQLClientReferences",
nil]
];
db = [SQLClient clientWithConfiguration: nil name: @"test"];
l = [Logger new];
[[NSNotificationCenter defaultCenter] addObserver: l
selector: @selector(notified:)
name: SQLClientDidConnectNotification
object: db];
[[NSNotificationCenter defaultCenter] addObserver: l
selector: @selector(notified:)
name: SQLClientDidDisconnectNotification
object: db];
if ((name = [defs stringForKey: @"Producer"]) != nil)
{
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];
if (i % 1000 == 999)
{
[db postNotificationName: @"Producing"
payload: [NSString stringWithFormat: @"%d", i]];
}
[db execute: @"INSERT INTO Queue (Consumer, Destination,"
@" ServiceID, Payload) VALUES (",
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
@"'helo there'", @")", nil];
[arp release];
}
NSLog(@"End producing");
}
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
{
[db addObserver: l
selector: @selector(notified:)
name: @"Producing"];
NSLog(@"Start consuming");
for (i = 0; i < 100000;)
{
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
{
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];
if (1 != [db execute: @"insert into xxx "
@"(k, char1, boolval, intval, when1, when2, b) "
@"values ("
@"'hello', "
@"'X', "
@"TRUE, "
@"1, "
@"CURRENT_TIMESTAMP, "
@"CURRENT_TIMESTAMP, ",
data,
@")",
nil])
{
NSLog(@"Insert failed to return row count");
}
[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 addObserver: l
selector: @selector(notified:)
name: @"foo"];
[db postNotificationName: @"foo" payload: @"hello"];
[db execute: @"drop table xxx", nil];
if ([records count] != 3)
{
NSLog(@"Expected 3 records but got %lu", [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");
}
}
NSLog(@"Records - %@", [GSCache class]);
}
[pool release];
return 0;
}
SQLClient-1.7.3/JDBC.m 0000664 0000765 0000765 00000131335 12040317340 014076 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientJDBC for GNUStep
Copyright (C) 2006 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
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-06-04 10:19:28 +0100 (Sun, 04 Jun 2006) $ $Revision: 23028 $
*/
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
@interface _JDBCTransaction : SQLTransaction
@end
#include
static NSString *JDBCException = @"SQLClientJDBCException";
/*
* Cache connection information
*/
typedef struct {
jobject connection;
jmethodID commit;
jmethodID rollback;
jmethodID prepare;
jobject statement;
jmethodID executeUpdate;
jmethodID executeQuery;
jmethodID addBatch;
jmethodID clearBatch;
jmethodID executeBatch;
} JInfo;
/* SQLClientJVM shamelessly stolen from JIGS ... written by Nicola Pero
* and copyright the Free Software Foundation.
*/
@interface SQLClientJVM : NSObject
{
}
+ (void) startVirtualMachineWithClassPath: (NSString *)classPath
libraryPath: (NSString *)libraryPath;
+ (void) destroyVirtualMachine;
+ (BOOL) isVirtualMachineRunning;
+ (NSString *) defaultClassPath;
+ (NSString *) defaultLibraryPath;
+ (void) attachCurrentThread;
+ (void) detachCurrentThread;
+ (void) registerJavaVM: (JavaVM *)javaVMHandle;
@end
/*
* A fast function to get the (JNIEnv *) variable.
*/
static JNIEnv *SQLClientJNIEnv ();
static JavaVM *SQLClientJavaVM = NULL;
/*
* Return the (JNIEnv *) associated with the current thread,
* or NULL if no java virtual machine is running (or if the thread
* is not attached to the JVM).
*
* NB: This function performs a call. Better use your (JNIEnv *) if
* you already have it.
*
*/
JNIEnv *SQLClientJNIEnv ()
{
JNIEnv *penv;
if ((*SQLClientJavaVM)->GetEnv (SQLClientJavaVM, (void **)&penv,
JNI_VERSION_1_2) == JNI_OK)
{
return penv;
}
else
{
return NULL;
}
}
@implementation SQLClientJVM (GNUstepInternals)
+ (void) _attachCurrentThread: (NSNotification *)not
{
[self attachCurrentThread];
}
+ (void) _detachCurrentThread: (NSNotification *)not
{
[self detachCurrentThread];
}
@end
@implementation SQLClientJVM
+ (void) startVirtualMachineWithClassPath: (NSString *)classPath
libraryPath: (NSString *)libraryPath
{
JavaVMInitArgs jvm_args;
JavaVMOption options[32];
int args = 0;
jint result;
JNIEnv *env;
NSString *path;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if (SQLClientJavaVM != NULL)
{
[NSException raise: NSGenericException
format: @"Only one Java Virtual Machine "
@"can be running at each time"];
}
// If we don't pass these options, it assumes they are really @""
if (classPath == nil)
{
classPath = [self defaultClassPath];
if (classPath == nil)
{
classPath = @"";
}
}
if (libraryPath == nil)
{
libraryPath = [self defaultLibraryPath];
if (libraryPath == nil)
{
libraryPath = @"";
}
}
path = [NSString stringWithFormat: @"-Djava.library.path=%@", libraryPath];
options[args].optionString = strdup([path UTF8String]);
options[args++].extraInfo = 0;
path = [NSString stringWithFormat: @"-Djava.class.path=%@", classPath];
options[args].optionString = strdup([path UTF8String]);
options[args++].extraInfo = 0;
path = [NSString stringWithFormat: @"-Xbootclasspath/a:%@", classPath];
options[args].optionString = strdup([path UTF8String]);
options[args++].extraInfo = 0;
options[args].optionString = "-verbose:class,jni";
options[args++].extraInfo = 0;
jvm_args.nOptions = args;
jvm_args.version = JNI_VERSION_1_2;
jvm_args.options = options;
jvm_args.ignoreUnrecognized = JNI_FALSE;
result = JNI_CreateJavaVM (&SQLClientJavaVM, (void **)&env, &jvm_args);
if (result < 0)
{
[NSException raise: NSGenericException
format: @"Could not start Java Virtual Machine"];
}
/* Whenever a thread start or ends, we want to automatically attach
or detach it to/from the JVM */
[nc addObserver: self selector: @selector (_attachCurrentThread:)
name: NSThreadDidStartNotification object: nil];
[nc addObserver: self selector: @selector (_detachCurrentThread:)
name: NSThreadWillExitNotification object: nil];
return;
}
+ (void) destroyVirtualMachine
{
jint result;
if (SQLClientJavaVM == NULL)
{
[NSException raise: NSGenericException
format: @"destroyJVM called without a JVM running"];
}
result = (*SQLClientJavaVM)->DestroyJavaVM (SQLClientJavaVM);
if (result < 0)
{
[NSException raise: NSGenericException
format: @"Could not destroy Java Virtual Machine"];
}
else
{
SQLClientJavaVM = NULL;
}
}
+ (BOOL) isVirtualMachineRunning
{
if (SQLClientJavaVM == NULL)
{
return NO;
}
else
{
return YES;
}
}
+ (NSString *) defaultClassPath
{
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
return [environment objectForKey: @"CLASSPATH"];
}
+ (NSString *) defaultLibraryPath
{
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
return [environment objectForKey: @"LD_LIBRARY_PATH"];
}
+ (void) attachCurrentThread
{
static int count = 0;
JNIEnv *env;
JavaVMAttachArgs args;
jint result;
if (SQLClientJavaVM == NULL)
{
/* No JVM - nothing to do */
return;
}
if (SQLClientJNIEnv () != NULL)
{
/* The thread is already attached */
return;
}
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
args.version = JNI_VERSION_1_2;
args.name = (char *)[[NSString stringWithFormat:
@"GNUstepThread-%d", count] cString];
args.group = NULL;
result = (*SQLClientJavaVM)->AttachCurrentThread
(SQLClientJavaVM, (void **)&env, &args);
[pool release];
}
if (result < 0)
{
[NSException raise: NSGenericException
format: @"Could not attach thread to the Java VM"];
}
count++;
if (count > 100000)
{
/* Duplicated names shouldn't cause any problem */
count = 0;
}
return;
}
+ (void) detachCurrentThread
{
jint result;
if (SQLClientJavaVM == NULL)
{
/* No JVM - nothing to do */
return;
}
if (SQLClientJNIEnv () == NULL)
{
/* The thread is not attached */
return;
}
result = (*SQLClientJavaVM)->DetachCurrentThread (SQLClientJavaVM);
if (result < 0)
{
[NSException raise: NSGenericException
format: @"Could not detach thread from the Java VM"];
}
return;
}
+ (void) registerJavaVM: (JavaVM *)javaVMHandle
{
if (javaVMHandle == NULL)
{
[NSException raise: NSInvalidArgumentException
format: @"Trying to register a NULL Java VM"];
}
if (SQLClientJavaVM != NULL)
{
if (javaVMHandle == SQLClientJavaVM)
{
return;
}
else
{
[NSException raise: NSGenericException
format: @"Trying to register a Java VM "
@"while one is already running"];
}
}
SQLClientJavaVM = javaVMHandle;
// Safety check. If javaVMHandle is invalid, the following will crash
// your app. The app would crash anyway later on, so it's better to crash
// it here, where it is easier to debug.
SQLClientJNIEnv ();
return;
}
@end
static jstring
JStringFromNSString (JNIEnv *env, NSString *string)
{
jstring javaString;
int length = [string length];
/* We allocate strings of up to 10k on the stack - others using
malloc. */
if (length < 10000)
{
unichar uniString[length];
// Get a unicode representation of the string in the buffer
[string getCharacters: uniString];
// Create a java string using the buffer
javaString = (*env)->NewString (env, uniString, length);
// NB: if javaString is NULL, an exception has been thrown.
}
else
{
unichar *uniString;
uniString = malloc (sizeof (unichar) * length);
[string getCharacters: uniString];
javaString = (*env)->NewString (env, uniString, length);
free (uniString);
}
return javaString;
}
static NSString*
NSStringFromJString (JNIEnv *env, jstring string)
{
unichar *uniString;
jsize length;
NSString *gnustepString;
// Get a Unicode string from the jstring
uniString = (unichar *)(*env)->GetStringChars (env, string, NULL);
if (uniString == NULL)
{
// OutOfMemoryError thrown
return NULL;
}
// Get the Unicode string length
length = (*env)->GetStringLength (env, string);
// Create a GNUstep string from the Unicode string
gnustepString = [NSString stringWithCharacters: uniString length: length];
// Release the temporary string
(*env)->ReleaseStringChars (env, string, uniString);
return gnustepString;
}
static NSData *
NSDataFromByteArray (JNIEnv *env, jbyteArray array)
{
NSData *returnData;
jbyte *bytes;
unsigned length;
length = (*env)->GetArrayLength (env, array);
bytes = (*env)->GetByteArrayElements (env, array, NULL);
if (bytes == NULL)
{
/* OutOfMemoryError */
return nil;
}
returnData = [NSData dataWithBytes: bytes length: length];
(*env)->ReleaseByteArrayElements (env, array, bytes, 0);
return returnData;
}
static jbyteArray
ByteArrayFromNSData (JNIEnv *env, NSData *data)
{
const jbyte *bytes;
unsigned length;
jbyteArray javaArray;
length = [data length];
bytes = [data bytes];
javaArray = (*env)->NewByteArray (env, length);
if (javaArray == NULL)
{
/* OutOfMemory exception thrown */
return NULL;
}
(*env)->SetByteArrayRegion (env, javaArray, 0, length, (jbyte *)bytes);
if ((*env)->ExceptionCheck (env))
{
/* No reason for this to happen - except a bug in NSData */
return NULL;
}
return javaArray;
}
static NSString *JExceptionClear (JNIEnv *env)
{
NSString *desc = nil;
jthrowable exc = (*env)->ExceptionOccurred (env);
if (exc != NULL)
{
static jclass java_lang_Exception = NULL;
jmethodID jid = NULL;
jstring jstr = NULL;
// (*env)->ExceptionDescribe (env);
// We need to clear the exception before doing anything else.
(*env)->ExceptionClear (env);
java_lang_Exception = (*env)->FindClass(env, "java/lang/Exception");
if (java_lang_Exception == NULL)
{
(*env)->DeleteLocalRef (env, exc);
(*env)->ExceptionDescribe (env);
desc = @"Could not get global reference to "
@"java/lang/Exception to describe exception";
goto done;
}
jid = (*env)->GetMethodID (env, java_lang_Exception, "getMessage",
"()Ljava/lang/String;");
if (jid == NULL)
{
(*env)->DeleteLocalRef (env, exc);
desc = @"Could not get the jmethodID of getMessage"
@"of java/lang/Exception to describe exception";
goto done;
}
if ((*env)->PushLocalFrame (env, 1) < 0)
{
(*env)->DeleteLocalRef (env, exc);
(*env)->ExceptionDescribe (env);
desc = @"Could not create enough JNI local references "
@"to get a description of the exception";
goto done;
}
// Get the message
jstr = (*env)->CallObjectMethod (env, exc, jid);
if ((*env)->ExceptionOccurred (env))
{
(*env)->ExceptionDescribe (env);
(*env)->PopLocalFrame (env, NULL);
desc = @"Exception occurred while getting a description of exception";
goto done;
}
(*env)->DeleteLocalRef (env, exc);
if ((*env)->ExceptionOccurred (env))
{
(*env)->ExceptionDescribe (env);
(*env)->PopLocalFrame (env, NULL);
desc = @"Exception occurred while getting a description of exception";
goto done;
}
if (jstr == NULL) // Oh oh - something really wrong here
{
(*env)->PopLocalFrame (env, NULL);
desc = @"NULL description of exception";
goto done;
}
desc = NSStringFromJString (env, jstr);
if (desc == nil)
{
(*env)->PopLocalFrame (env, NULL);
desc = @"Exception while converting string of exception";
}
(*env)->PopLocalFrame (env, NULL);
}
done:
return desc;
}
// Throw an exception if one occurred
static void JException (JNIEnv *env)
{
NSString *text = JExceptionClear (env);
if (text != nil)
{
[NSException raise: JDBCException format: @"%@", text];
}
}
static NSDate* NSDateFromNSString (NSString *s)
{
NSDate *d;
char b[32];
BOOL milliseconds = NO;
int l;
int i;
strcpy(b, [s UTF8String]);
l = strlen(b);
for (i = 0; i < l; i++)
{
if (b[i] == '\0')
{
l = i;
break;
}
}
while (l > 0 && isspace(b[l-1]))
{
l--;
}
b[l] = '\0';
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
return [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d"
locale: nil];
}
else
{
int e;
/* 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;
}
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)
{
/* A date and time without a timezone ... assume gmt */
strcpy(b + l, " +0000");
i = l + 1;
l += 6;
}
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';
}
/*
* 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';
}
}
/* FIXME ... horrible 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 (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];
}
return d;
}
}
@interface SQLClientJDBC : SQLClient
@end
static NSDate *future = nil;
static NSNull *null = nil;
@implementation SQLClientJDBC
static int JDBCDATE = 0;
static int JDBCTIME = 0;
static int JDBCTIMESTAMP = 0;
static int JDBCBOOLEAN = 0;
static int JDBCBLOB = 0;
static int JDBCBINARY = 0;
static int JDBCVARBINARY = 0;
static int JDBCLONGVARBINARY = 0;
static int JDBCVARCHAR = 0;
+ (void) initialize
{
if (future == nil)
{
JNIEnv *env;
jclass jc;
jfieldID jf;
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
[future retain];
null = [NSNull null];
[null retain];
[SQLClientJVM startVirtualMachineWithClassPath: nil libraryPath: nil];
env = SQLClientJNIEnv();
jc = (*env)->FindClass(env, "java/sql/Types");
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "DATE", "I");
JException (env);
JDBCDATE = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "TIME", "I");
JException (env);
JDBCTIME = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "TIMESTAMP", "I");
JException (env);
JDBCTIMESTAMP = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "BOOLEAN", "I");
JException (env);
JDBCBOOLEAN = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "BLOB", "I");
JException (env);
JDBCBLOB = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "BINARY", "I");
JException (env);
JDBCBINARY = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "VARBINARY", "I");
JException (env);
JDBCVARBINARY = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "LONGVARBINARY", "I");
JException (env);
JDBCLONGVARBINARY = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
jf = (*env)->GetStaticFieldID(env, jc, "VARCHAR", "I");
JException (env);
JDBCVARCHAR = (*env)->GetStaticIntField(env, jc, jf);
JException (env);
}
}
/* Disconnect and deallocate all resources used.
* Do NOT raise an exception.
*/
- (void) _backendDisconnect
{
if (extra != 0)
{
JNIEnv *env = SQLClientJNIEnv();
JInfo *ji = (JInfo*)extra;
jclass jc;
jmethodID jm;
if ((*env)->PushLocalFrame (env, 16) >= 0)
{
if (ji->statement != 0)
{
jc = (*env)->GetObjectClass(env, ji->statement);
jm = (*env)->GetMethodID (env, jc, "close", "()V");
if (jm == 0) JExceptionClear(env);
else (*env)->CallVoidMethod (env, ji->statement, jm);
if (jm == 0) JExceptionClear(env);
(*env)->DeleteGlobalRef (env, ji->statement);
if (jm == 0) JExceptionClear(env);
}
if (ji->connection != 0)
{
jc = (*env)->GetObjectClass(env, ji->connection);
jm = (*env)->GetMethodID (env, jc, "close", "()V");
if (jm == 0) JExceptionClear(env);
else (*env)->CallVoidMethod (env, ji->connection, jm);
if (jm == 0) JExceptionClear(env);
(*env)->DeleteGlobalRef (env, ji->connection);
if (jm == 0) JExceptionClear(env);
}
(*env)->PopLocalFrame (env, NULL);
}
NSZoneFree(NSDefaultMallocZone(), extra);
extra = 0;
}
}
- (JInfo*) _backendExtra
{
return (JInfo*)extra;
}
- (BOOL) backendConnect
{
if (extra == 0)
{
connected = NO;
if ([self database] != nil)
{
NSString *dbase = [self database];
NSRange r;
[[self class] purgeConnections: nil];
r = [dbase rangeOfString: @":"];
if (r.length > 0)
{
NSString *url;
NSString *cname;
JNIEnv *env;
jclass jc;
jmethodID jm;
jobject jo;
url = [dbase substringFromIndex: NSMaxRange(r)];
cname = [dbase substringToIndex: r.location];
env = SQLClientJNIEnv();
if (env == 0)
{
NSLog(@"Connect to '%@' failed to set up Java runtime",
[self name]);
return NO;
}
/* Ensure the driver for the database is loaded.
*/
cname = [cname stringByReplacingString: @"." withString: @"/"];
if ((*env)->FindClass(env, [cname UTF8String]) == 0)
{
JExceptionClear (env);
NSLog(@"Connect to '%@' failed to load driver '%@'.\n"
@"Perhaps you need to set your CLASSPATH environment "
@"variable to point to the location of your JDBC library.",
[self name], cname);
return NO;
}
if ((*env)->PushLocalFrame (env, 32) < 0)
{
JExceptionClear (env);
[self debug: @"Connect to '%@' failed memory allocation '%@'",
[self name], cname];
return NO;
}
/* Get the driver manager class.
*/
jc = (*env)->FindClass(env, "java/sql/DriverManager");
if (jc == 0)
{
JExceptionClear (env);
(*env)->PopLocalFrame (env, NULL);
NSLog(@"Connect to '%@' failed to load DriverManager\n"
@"Perhaps you need to set your CLASSPATH environment "
@"variable to point to the location of your JDBC library.",
[self name]);
return NO;
}
/* Get the method to get a connection.
*/
jm = (*env)->GetStaticMethodID(env, jc, "getConnection",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)"
"Ljava/sql/Connection;");
if (jm == 0)
{
JExceptionClear (env);
(*env)->PopLocalFrame (env, NULL);
[self debug: @"Connect to '%@' failed to get connect method",
[self name]];
return NO;
}
/* Get the new connection object
*/
jobject js1 = JStringFromNSString(env, url);
jobject js2 = JStringFromNSString(env, [self user]);
jobject js3 = JStringFromNSString(env, [self password]);
/*
NSLog(@"CONNECT '%@', '%@', '%@'",
NSStringFromJString(env, js1),
NSStringFromJString(env, js2),
NSStringFromJString(env, js3));
*/
jo = (*env)->CallStaticObjectMethod(env, jc, jm, js1, js2, js3);
if (jo == 0)
{
JExceptionClear (env);
(*env)->PopLocalFrame (env, NULL);
[self debug: @"Connect to '%@' failed to get connection",
[self name]];
return NO;
}
/* Make a reference so it can't be garbage collected.
*/
jo = (*env)->NewGlobalRef(env, jo);
if (jo == 0)
{
JExceptionClear (env);
(*env)->PopLocalFrame (env, NULL);
[self debug: @"Connect to '%@' failed to get global ref",
[self name]];
return NO;
}
else
{
JInfo *ji;
ji = NSZoneMalloc(NSDefaultMallocZone(), sizeof(JInfo));
memset(ji, '\0', sizeof(*ji));
extra = ji;
NS_DURING
{
ji->connection = jo;
jc = (*env)->GetObjectClass(env, ji->connection);
/* Get the method to set autocommit.
*/
jm = (*env)->GetMethodID(env, jc,
"setAutoCommit", "(Z)V");
JException (env);
/* Turn off autocommit
*/
(*env)->CallVoidMethod (env, ji->connection,
jm, JNI_FALSE);
JException (env);
ji->commit = (*env)->GetMethodID (env, jc,
"commit", "()V");
JException(env);
ji->rollback = (*env)->GetMethodID (env, jc,
"rollback", "()V");
JException(env);
ji->prepare = (*env)->GetMethodID (env, jc,
"prepareStatement",
"(Ljava/lang/String;)Ljava/sql/PreparedStatement;");
JException(env);
jm = (*env)->GetMethodID (env, jc,
"createStatement",
"()Ljava/sql/Statement;");
JException(env);
jo = (*env)->CallObjectMethod (env, ji->connection, jm);
JException(env);
ji->statement = (*env)->NewGlobalRef(env, jo);
JException(env);
jc = (*env)->GetObjectClass(env, ji->statement);
ji->executeUpdate = (*env)->GetMethodID (env, jc,
"executeUpdate",
"(Ljava/lang/String;)I");
JException(env);
ji->executeQuery = (*env)->GetMethodID (env, jc,
"executeQuery",
"(Ljava/lang/String;)Ljava/sql/ResultSet;");
JException(env);
(*env)->PopLocalFrame (env, NULL);
jc = (*env)->GetObjectClass(env, ji->connection);
jm = (*env)->GetMethodID (env, jc,
"getMetaData", "()Ljava/sql/DatabaseMetaData;");
JException(env);
jo = (*env)->CallObjectMethod (env, ji->connection, jm);
JException(env);
jc = (*env)->GetObjectClass(env, jo);
jm = (*env)->GetMethodID (env, jc,
"supportsBatchUpdates", "()Z");
JException(env);
if ((*env)->CallBooleanMethod (env, jo, jm) == JNI_TRUE)
{
jc = (*env)->GetObjectClass(env, ji->statement);
ji->addBatch = (*env)->GetMethodID (env, jc,
"addBatch", "(Ljava/lang/String;)V");
JException(env);
ji->clearBatch = (*env)->GetMethodID (env, jc,
"clearBatch", "()V");
JException(env);
ji->executeBatch = (*env)->GetMethodID (env, jc,
"executeBatch", "()[I");
JException(env);
}
else
{
ji->addBatch = 0;
ji->clearBatch = 0;
ji->executeBatch = 0;
}
}
NS_HANDLER
{
(*env)->PopLocalFrame (env, NULL);
[self _backendDisconnect];
[self debug: @"Connect to '%@' using '%@' problem: %@",
[self name], [self database], localException];
return NO;
}
NS_ENDHANDLER
connected = YES;
}
}
else
{
[self debug: @"Connect to '%@' using '%@' has no class",
[self name], [self database]];
return NO;
}
}
else
{
[self debug:
@"Connect to '%@' with no user/password/database configured",
[self name]];
}
}
return connected;
}
- (void) backendDisconnect
{
if (extra != 0)
{
NS_DURING
{
if ([self isInTransaction] == YES)
{
[self rollback];
}
if ([self debugging] > 0)
{
[self debug: @"Disconnecting client %@", [self clientName]];
}
[self _backendDisconnect];
if ([self debugging] > 0)
{
[self debug: @"Disconnected client %@", [self clientName]];
}
}
NS_HANDLER
{
[self _backendDisconnect];
[self debug: @"Error disconnecting from database (%@): %@",
[self clientName], localException];
}
NS_ENDHANDLER
connected = NO;
}
}
- (NSInteger) backendExecute: (NSArray*)info
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *stmt = [info objectAtIndex: 0];
JNIEnv *env = SQLClientJNIEnv();
JInfo *ji;
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
if ((*env)->PushLocalFrame (env, 32) < 0)
{
JExceptionClear(env);
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"No java memory for execute"];
}
NS_DURING
{
jmethodID jm;
jobject js;
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[NSException raise: SQLException
format: @"Unable to connect to '%@' to execute statement %@",
[self name], stmt];
}
ji = (JInfo*)extra;
if ([info count] > 1)
{
unsigned i;
jclass jc;
stmt = [stmt stringByReplacingString: @"'?'''?'" withString: @"?"];
js = (*env)->CallObjectMethod (env, ji->connection, ji->prepare,
JStringFromNSString(env, stmt));
JException(env);
jc = (*env)->GetObjectClass(env, js);
JException(env);
jm = (*env)->GetMethodID (env, jc, "setBytes", "(I[B)V");
JException(env);
for (i = 1; i < [info count]; i++)
{
(*env)->CallIntMethod (env, js, jm, i,
ByteArrayFromNSData(env, [info objectAtIndex: i]));
JException(env);
}
jm = (*env)->GetMethodID (env, jc, "executeUpdate", "()I");
JException(env);
(*env)->CallIntMethod (env, js, jm);
}
else
{
(*env)->CallIntMethod (env, ji->statement,
ji->executeUpdate, JStringFromNSString(env, stmt));
}
JException(env);
if (_inTransaction == NO)
{
// Not in a transaction ... commit at once.
(*env)->CallVoidMethod (env, ji->connection, ji->commit);
JException (env);
}
(*env)->PopLocalFrame (env, NULL);
}
NS_HANDLER
{
if (connected == YES)
{
if (_inTransaction == NO)
{
ji = (JInfo*)extra;
// Not in a transaction ... rollback to clear error state
(*env)->CallVoidMethod (env, ji->connection, ji->rollback);
JExceptionClear (env);
}
(*env)->PopLocalFrame (env, NULL);
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
{
NSMutableArray *records = nil;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
JNIEnv *env = SQLClientJNIEnv();
JInfo *ji;
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
if ((*env)->PushLocalFrame (env, 32) < 0)
{
JExceptionClear(env);
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"No java memory for query"];
}
NS_DURING
{
int fieldCount;
jclass resultClass;
jobject result;
jclass metaDatlType;
jobject metaData;
jmethodID jm;
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[NSException raise: SQLException
format: @"Unable to connect to '%@' to run query %@",
[self name], stmt];
}
ji = (JInfo*)extra;
result = (*env)->CallObjectMethod (env, ji->statement, ji->executeQuery,
JStringFromNSString(env, stmt));
JException (env);
resultClass = (*env)->GetObjectClass(env, result);
JException (env);
jm = (*env)->GetMethodID (env, resultClass,
"getMetaData", "()Ljava/sql/ResultSetMetaData;");
JException (env);
metaData = (*env)->CallObjectMethod (env, result, jm);
JException (env);
metaDatlType = (*env)->GetObjectClass(env, metaData);
JException (env);
jm = (*env)->GetMethodID (env, metaDatlType,
"getColumnCount", "()I");
JException (env);
fieldCount = (*env)->CallIntMethod (env, metaData, jm);
JException (env);
if (fieldCount > 0)
{
NSString *keys[fieldCount];
int types[fieldCount];
unsigned i;
jmethodID next;
jmethodID wasNull;
jmethodID getBinaryStream;
jmethodID getBoolean;
jmethodID getBytes;
jmethodID getString;
/* Get the names of each field
*/
jm = (*env)->GetMethodID (env, metaDatlType,
"getColumnName", "(I)Ljava/lang/String;");
JException (env);
for (i = 0; i < fieldCount; i++)
{
jstring js = (*env)->CallObjectMethod (env, metaData, jm, i+1);
JException (env);
keys[i] = NSStringFromJString (env, js);
}
/* Get the types of each field.
* We treat most as strings.
*/
jm = (*env)->GetMethodID (env, metaDatlType,
"getColumnType", "(I)I");
JException (env);
for (i = 0; i < fieldCount; i++)
{
int v = (*env)->CallIntMethod (env, metaData, jm, i+1);
if (v == JDBCDATE || v == JDBCTIME || v == JDBCTIMESTAMP)
{
types[i] = JDBCTIMESTAMP;
}
else if (v == JDBCBOOLEAN)
{
types[i] = JDBCBOOLEAN;
}
else if (v == JDBCBLOB || v == JDBCBINARY || v == JDBCVARBINARY
|| v == JDBCLONGVARBINARY)
{
types[i] = JDBCBLOB;
}
else
{
types[i] = JDBCVARCHAR;
}
}
/* Iterate through the result set
*/
wasNull = (*env)->GetMethodID (env, resultClass,
"wasNull", "()Z");
JException (env);
getBinaryStream = (*env)->GetMethodID (env, resultClass,
"getBinaryStream", "(I)Ljava/io/InputStream;");
JException (env);
getBoolean = (*env)->GetMethodID (env, resultClass,
"getBoolean", "(I)Z");
JException (env);
getBytes = (*env)->GetMethodID (env, resultClass,
"getBytes", "(I)[B");
JException (env);
getString = (*env)->GetMethodID (env, resultClass,
"getString", "(I)Ljava/lang/String;");
JException (env);
next = (*env)->GetMethodID (env, resultClass,
"next", "()Z");
JException (env);
records = [[lType alloc] initWithCapacity: 2];
while ((*env)->CallBooleanMethod (env, result, next) == JNI_TRUE)
{
SQLRecord *record;
id values[fieldCount];
int j;
if ((*env)->PushLocalFrame (env, fieldCount * 2) < 0)
{
JExceptionClear(env);
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"No java memory for query"];
}
NS_DURING
{
for (j = 0; j < fieldCount; j++)
{
id v = null;
if (types[j] == JDBCBOOLEAN)
{
BOOL b = NO;
if ((*env)->CallBooleanMethod (env, result,
getBoolean, j+1) == JNI_TRUE)
{
b = YES;
}
JException (env);
if ((*env)->CallBooleanMethod (env, result,
wasNull) == JNI_FALSE)
{
if (b == YES)
{
v = @"Y";
}
else
{
v = @"N";
}
}
JException (env);
}
else if (types[j] == JDBCTIMESTAMP)
{
jobject jo;
jo = (*env)->CallObjectMethod (env, result,
getString, j+1);
JException (env);
if ((*env)->CallBooleanMethod (env, result,
wasNull) == JNI_FALSE)
{
v = NSStringFromJString(env, jo);
v = NSDateFromNSString(v);
}
JException (env);
}
else if (types[j] == JDBCBLOB)
{
jbyteArray jo;
jo = (*env)->CallObjectMethod (env, result,
getBytes, j+1);
JException (env);
if ((*env)->CallBooleanMethod (env, result,
wasNull) == JNI_FALSE)
{
v = NSDataFromByteArray(env, jo);
}
JException (env);
}
else
{
jobject jo;
jo = (*env)->CallObjectMethod (env, result,
getString, j+1);
JException (env);
if ((*env)->CallBooleanMethod (env, result,
wasNull) == JNI_FALSE)
{
v = NSStringFromJString(env, jo);
}
JException (env);
}
values[j] = v;
}
(*env)->PopLocalFrame (env, NULL);
}
NS_HANDLER
{
(*env)->PopLocalFrame (env, NULL);
[localException raise];
}
NS_ENDHANDLER
record = [rType newWithValues: values
keys: keys
count: fieldCount];
[records addObject: record];
[record release];
}
}
else
{
records = [[lType alloc] initWithCapacity: 0];
}
(*env)->PopLocalFrame (env, NULL);
}
NS_HANDLER
{
NSString *n = [localException name];
if (connected == YES)
{
(*env)->PopLocalFrame (env, NULL);
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
if ([self debugging] > 0)
{
[self debug: @"Error executing statement:\n%@\n%@",
stmt, localException];
}
}
[records release];
records = nil;
[localException retain];
[arp release];
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER
[arp release];
return [records autorelease];
}
- (SQLTransaction*) batch: (BOOL)stopOnFailure
{
_JDBCTransaction *transaction;
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
NSDefaultMallocZone());
transaction->_db = [self retain];
transaction->_info = [NSMutableArray new];
transaction->_batch = YES;
transaction->_stop = stopOnFailure;
return [(SQLTransaction*)transaction autorelease];
}
- (void) begin
{
[lock lock];
if (_inTransaction == NO)
{
_inTransaction = YES;
// Leave us locked so the transaction can't be interfered with
}
else
{
[lock unlock];
[NSException raise: NSInternalInconsistencyException
format: @"begin used inside transaction"];
}
}
- (void) commit
{
[lock lock];
if (_inTransaction == NO)
{
[lock unlock];
[NSException raise: NSInternalInconsistencyException
format: @"commit used outside transaction"];
}
NS_DURING
{
JNIEnv *env = SQLClientJNIEnv();
JInfo *ji = (JInfo*)extra;
(*env)->CallVoidMethod (env, ji->connection, ji->commit);
JException(env);
_inTransaction = NO;
[lock unlock]; // Locked at start of -commit
[lock unlock]; // Locked by -begin
}
NS_HANDLER
{
_inTransaction = NO;
[lock unlock]; // Locked at start of -commit
[lock unlock]; // Locked by -begin
[localException raise];
}
NS_ENDHANDLER
}
- (void) dealloc
{
[self disconnect];
[super dealloc];
}
- (NSString*) quoteString: (NSString *)s
{
static NSCharacterSet *special = nil;
NSMutableString *m;
NSRange r;
unsigned l;
if (special == nil)
{
NSString *stemp;
/*
* NB. length of C string is 3, so we include a nul character as a
* special.
*/
stemp = [[NSString alloc] initWithBytes: "'\\"
length: 3
encoding: NSASCIIStringEncoding];
special = [NSCharacterSet characterSetWithCharactersInString: stemp];
[stemp release];
[special retain];
}
/*
* Step through string removing nul characters
* and escaping quote characters as required.
*/
m = [[s mutableCopy] autorelease];
l = [m length];
r = NSMakeRange(0, l);
r = [m rangeOfCharacterFromSet: special options: NSLiteralSearch range: r];
while (r.length > 0)
{
unichar c = [m characterAtIndex: r.location];
if (c == 0)
{
r.length = 1;
[m replaceCharactersInRange: r withString: @""];
l--;
}
else if (c == '\\')
{
r.length = 0;
[m replaceCharactersInRange: r withString: @"\\"];
l++;
r.location += 2;
}
else
{
r.length = 0;
[m replaceCharactersInRange: r withString: @"'"];
l++;
r.location += 2;
}
r = NSMakeRange(r.location, l - r.location);
r = [m rangeOfCharacterFromSet: special
options: NSLiteralSearch
range: r];
}
/* Add quoting around it. */
[m replaceCharactersInRange: NSMakeRange(0, 0) withString: @"'"];
[m appendString: @"'"];
return m;
}
- (void) rollback
{
[lock lock];
if (_inTransaction == YES)
{
_inTransaction = NO;
NS_DURING
{
JNIEnv *env = SQLClientJNIEnv();
JInfo *ji = (JInfo*)extra;
(*env)->CallVoidMethod (env, ji->connection, ji->rollback);
JException(env);
[lock unlock]; // Locked at start of -rollback
[lock unlock]; // Locked by -begin
}
NS_HANDLER
{
[lock unlock]; // Locked at start of -rollback
[lock unlock]; // Locked by -begin
[localException raise];
}
NS_ENDHANDLER
}
}
- (SQLTransaction*) transaction
{
_JDBCTransaction *transaction;
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
NSDefaultMallocZone());
transaction->_db = [self retain];
transaction->_info = [NSMutableArray new];
return [(SQLTransaction*)transaction autorelease];
}
@end
@implementation _JDBCTransaction
- (BOOL) _batchable: (NSArray*)a
{
unsigned c = [a count];
unsigned i;
for (i = 0; i < c; i++)
{
if ([[a objectAtIndex: i] count] > 1)
{
return NO;
}
}
return YES;
}
- (void) _merge: (NSMutableArray*)a
{
unsigned c = [_info count];
unsigned i;
for (i = 0; i < c; i++)
{
id o = [_info objectAtIndex: i];
if ([o isKindOfClass: [NSArray class]] == YES)
{
[a addObject: o];
}
else
{
[(_JDBCTransaction*)o _merge: a];
}
}
}
- (void) execute
{
if (_count > 0)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
BOOL wrapped = NO;
BOOL batched = NO;
JNIEnv *env;
JInfo *ji;
/*
* Ensure we have a working connection.
*/
if ([_db connect] == NO)
{
[NSException raise: SQLException
format: @"Unable to connect to '%@' to execute transaction %@",
[_db name], self];
}
env = SQLClientJNIEnv();
if ((*env)->PushLocalFrame (env, 32) < 0)
{
JExceptionClear(env);
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"No java memory for execute"];
}
ji = [(SQLClientJDBC*)_db _backendExtra];
NS_DURING
{
NSMutableArray *statements;
unsigned numberOfStatements;
unsigned statement;
NSTimeInterval _duration = [_db durationLogging];
NSTimeInterval start = 0.0;
statements = [NSMutableArray arrayWithCapacity: 100];
[self _merge: statements];
numberOfStatements = [statements count];
if (_duration >= 0)
{
start = GSTickerTimeNow();
}
if ([_db isInTransaction] == NO)
{
wrapped = YES;
}
if (numberOfStatements > 1 && ji->addBatch != 0
&& [self _batchable: statements] == YES)
{
jintArray ja;
jint *array;
int status = 0;
for (statement = 0; statement < numberOfStatements; statement++)
{
NSString *stmt = [statements objectAtIndex: statement];
jobject js;
js = (*env)->CallObjectMethod(env, ji->statement,
ji->addBatch, JStringFromNSString(env, stmt));
JException(env);
batched = YES;
}
ja = (*env)->CallObjectMethod(env, ji->statement,
ji->executeBatch);
JException(env);
array = (*env)->GetIntArrayElements(env, ja, 0);
for (statement = 0; statement < numberOfStatements; statement++)
{
status = array[statement];
if (status < 0 && status != -2)
{
break;
}
}
(*env)->ReleaseIntArrayElements(env, ja, array, 0);
batched = NO;
(*env)->CallVoidMethod(env, ji->statement, ji->clearBatch);
JException(env);
if (statement != numberOfStatements)
{
[NSException raise: NSGenericException
format: @"Statement %d error %d in batch with %@",
statement, status, [statements objectAtIndex: statement]];
}
}
else
{
/* Not batchable ... execute as a transaction without
* batching :-(
*/
for (statement = 0; statement < numberOfStatements; statement++)
{
NSArray *info = [statements objectAtIndex: statement];
NSString *stmt = [info objectAtIndex: 0];
unsigned c = [info count];
jmethodID jm;
jobject js;
if (c == 1)
{
(*env)->CallIntMethod (env, ji->statement,
ji->executeUpdate, JStringFromNSString(env, stmt));
}
else
{
unsigned i;
jclass jc;
stmt = [stmt stringByReplacingString: @"'?'''?'"
withString: @"?"];
js = (*env)->CallObjectMethod
(env, ji->connection, ji->prepare,
JStringFromNSString(env, stmt));
JException(env);
jc = (*env)->GetObjectClass(env, js);
JException(env);
jm = (*env)->GetMethodID (env, jc, "setBytes", "(I[B)V");
JException(env);
/* Get data arguments for statement.
*/
for (i = 1; i < c; i++)
{
NSData *data;
data = [info objectAtIndex: i];
(*env)->CallIntMethod (env, js, jm, i,
ByteArrayFromNSData(env, data));
JException(env);
}
jm = (*env)->GetMethodID(env, jc, "executeUpdate", "()I");
JException(env);
(*env)->CallIntMethod (env, js, jm);
}
JException(env);
}
}
if (wrapped == YES)
{
wrapped = NO;
(*env)->CallVoidMethod (env, ji->connection, ji->commit);
JException(env);
}
(*env)->PopLocalFrame (env, NULL);
_db->_lastOperation = GSTickerTimeNow();
if (_duration >= 0)
{
NSTimeInterval d;
d = _db->_lastOperation - start;
if (d >= _duration)
{
[_db debug: @"Duration %g for transaction %@",
d, statements];
}
}
}
NS_HANDLER
{
if (wrapped == YES)
{
(*env)->CallVoidMethod (env, ji->connection, ji->rollback);
JException(env);
}
if (batched == YES)
{
(*env)->CallVoidMethod(env, ji->statement, ji->clearBatch);
JException(env);
}
(*env)->PopLocalFrame (env, NULL);
[localException raise];
}
NS_ENDHANDLER
[arp release];
}
}
@end
SQLClient-1.7.3/GNUmakefile.postamble 0000664 0000765 0000765 00000002254 11470771347 017273 0 ustar brains99 brains99 #
# Makefile.postamble
#
# Project specific makefile rules
#
# Uncomment the targets you want.
# The double colons (::) are important, do not make them single colons
# otherwise the normal makefile rules will not be performed.
#
ifneq ($(ECPG),)
%.m: %.pgm
ecpg -o $@ $< $(ADDITIONAL_INCLUDE_DIRS)
.PRECIOUS: %.m
endif
ifneq ($(ORACLE_HOME),)
%.m: %.pm
proc iname=$< oname=$@ mode=ansi parse=none
.PRECIOUS: %.m
endif
# Things to do before compiling
# before-all::
# Things to do after compiling
# after-all::
# Things to do before installing
# before-install::
# Things to do after installing
# after-install::
# Things to do before uninstalling
# before-uninstall::
# Things to do after uninstalling
# after-uninstall::
# Things to do before cleaning
# before-clean::
# Things to do after cleaning
# after-clean::
# Things to do before distcleaning
# before-distclean::
# Things to do after distcleaning
after-distclean::
-rm -f ECPG.m Oracle.m
-rm -f config.h config.make config.log config.status
-rm -rf autom4te.cache
# Things to do before checking
# before-check::
# Things to do after checking
# after-check::
config.make: config.make.in
./configure
SQLClient-1.7.3/Oracle.pm 0000664 0000765 0000765 00000063640 12147673455 015010 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientOracle for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Written by: Nicola Pero
Date: April 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 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: 2013-05-24 15:20:29 +0100 (Fri, 24 May 2013) $ $Revision: 36655 $
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "SQLClient.h"
/*
* Example configuration for an Oracle database:
*
* oracle-test = {
* ServerType = "Oracle"
* SQLDatabase = "nicola";
* SQLPassword = "mbrand";
* SQLUser = "mbrand";
* };
*
* Where SQLDatabase is the Unique database Identifier.
*
*/
@interface SQLClientOracle : SQLClient
@end
@interface SQLClientOracle(Embedded)
- (const char *) blobFromData: (NSData*)data;
- (NSData *) dataFromBlob: (const char *)blob;
- (BOOL) dbFromDate: (NSDate*)d toBuffer: (char*)b length: (int)l;
- (BOOL) dbFromString: (NSString*)s toBuffer: (char*)b length: (int)l;
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l;
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l;
@end
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR DO SQLClientOracleErrorHandler();
/**
* Return YES of the last SQL error indicated we are out of data,
* NO otherwise.
*/
BOOL SQLClientOracleOutOfData()
{
if (sqlca.sqlcode == 100)
{
return YES;
}
else
{
return NO;
}
}
/**
* This error handler is called for most errors ... so we can get it to
* raise an exception for us.
*/
void SQLClientOracleErrorHandler()
{
int code = sqlca.sqlcode;
const char *ptr = sqlca.sqlerrm.sqlerrmc;
const char *e0 = "'no connection to the server'";
const char *e1 = "Error in transaction processing";
sqlca.sqlcode = 0; // Reset error code
NSLog (@"(Oracle) 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: @"(Oracle) SQL Error: SQLCODE=(%ld): %s", code, ptr];
}
else
{
[NSException raise: SQLException
format: @"(Oracle) SQL Error: SQLCODE=(%ld): %s", code, ptr];
}
}
@implementation SQLClientOracle
- (BOOL) backendConnect
{
if (connected == NO)
{
if ([self database] != nil
&& [self user] != nil
&& [self password] != nil)
{
Class c = NSClassFromString(@"CmdClient");
[[self class] purgeConnections: nil];
NS_DURING
{
EXEC SQL BEGIN DECLARE SECTION;
const char *database_c;
const char *user_c;
const char *password_c;
const char *client_c;
EXEC SQL END DECLARE SECTION;
/* Database is the Oracle Net identifier for the database. */
database_c = [[self database] UTF8String];
/* User and password are used to connect to the database. */
user_c = [[self user] UTF8String];
password_c = [[self password] UTF8String];
/* Client is only used to give this connection a name
* and distinguish it from other connections.
*/
client_c = [[self clientName] UTF8String];
if (c != 0)
{
[self debug: @"(Oracle) Connect to database %s user %s as %s",
database_c, user_c, client_c];
}
EXEC SQL CONNECT :user_c IDENTIFIED BY :password_c
AT :client_c USING :database_c;
if (c != 0)
{
[self debug: @"(Oracle) Connected (%s)", client_c];
}
connected = YES;
}
NS_HANDLER
{
[self error: @"(Oracle) Error connecting to database: %@",
localException];
}
NS_ENDHANDLER
}
else
{
[self error:
@"(Oracle) Connect with no user/password/database configured"];
}
}
return connected;
}
- (void) backendDisconnect
{
if (connected == YES)
{
NS_DURING
{
EXEC SQL BEGIN DECLARE SECTION;
const char *client_c;
EXEC SQL END DECLARE SECTION;
if ([self isInTransaction] == YES)
{
[self rollback];
}
client_c = [[self clientName] UTF8String];
[self debug: @"(Oracle) Disconnecting client %@", [self clientName]];
/* To disconnect from the database, we issuse a COMMIT
* statement with the RELEASE option. The RELEASE option
* causes it to disconnect after the COMMIT.
*/
EXEC SQL AT :client_c COMMIT WORK RELEASE;
[self debug: @"(Oracle) Disconnected client %@", [self clientName]];
}
NS_HANDLER
{
[self error: @"(Oracle) Error disconnecting from database (%@): %@",
[self clientName], localException];
}
NS_ENDHANDLER
connected = NO;
}
}
- (NSInteger) backendExecute: (NSArray*)info
{
EXEC SQL BEGIN DECLARE SECTION;
char *statement;
char *handle;
EXEC SQL END DECLARE SECTION;
CREATE_AUTORELEASE_POOL(arp);
NSString *stmt = [info objectAtIndex: 0];
unsigned int length;
BOOL manuallyAutoCommit = NO;
length = [stmt length];
if (length == 0)
{
[NSException raise: NSInternalInconsistencyException
format: @"(Oracle) Statement produced null string"];
}
statement = (char*)[stmt UTF8String];
handle = (char*)[[self clientName] UTF8String];
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[NSException raise: SQLException
format: @"(Oracle) Unable to connect to database"];
}
NS_DURING
{
if ([self isInTransaction] == NO)
{
manuallyAutoCommit = YES;
}
EXEC SQL AT :handle PREPARE command FROM :statement;
EXEC SQL AT :handle EXECUTE command;
if (manuallyAutoCommit)
{
EXEC SQL AT :handle COMMIT;
}
}
NS_HANDLER
{
NSString *n = [localException name];
NSString *msg = [localException reason];
if (manuallyAutoCommit)
{
EXEC SQL AT :handle ROLLBACK;
}
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
/*
* remove line number information from database exception message
* since it's meaningless to the developer as it's the line number
* in this file rather than the code which is calling us.
*/
if ([n isEqual: SQLException] == YES
|| [n isEqual: SQLConnectionException] == YES)
{
NSRange r;
r = [msg rangeOfString: @" in line " options: NSBackwardsSearch];
if (r.length > 0)
{
msg = [msg substringToIndex: r.location];
localException = [NSException exceptionWithName: n
reason: msg
userInfo: nil];
}
}
[self error: @"(Oracle) Error executing statement:\n%@\n%@",
stmt, localException];
[localException raise];
}
NS_ENDHANDLER
DESTROY(arp);
return -1;
}
static unsigned int trim(char *str)
{
char *start = str;
while (isspace(*str))
{
str++;
}
if (str != start)
{
strcpy(start, str);
}
str = start;
while (*str != '\0')
{
str++;
}
while (str > start && isspace(str[-1]))
{
*--str = '\0';
}
return (str - start);
}
- (NSMutableArray*) backendQuery: (NSString*)stmt recordClass: (Class)rClass
{
EXEC SQL BEGIN DECLARE SECTION;
int count;
int index;
short int indicator;
int type;
int length;
int octetLength;
short int returnedOctetLength;
char fieldName[120];
char *aString;
/* This holds a string representation of numbers returned by Oracle.
* 128 seems a safe bound - else they'll be truncated. */
char aNumber[128];
char *query;
char *handle;
EXEC SQL END DECLARE SECTION;
CREATE_AUTORELEASE_POOL(arp);
NSMutableArray *records;
BOOL isOpen = NO;
BOOL wasInTransaction = [self isInTransaction];
BOOL allocatedDescriptor = NO;
length = [stmt length];
if (length == 0)
{
[NSException raise: NSInternalInconsistencyException
format: @"(Oracle) Statement produced null string"];
}
handle = (char*)[[self clientName] UTF8String];
query = (char*)[stmt UTF8String];
records = [[NSMutableArray alloc] initWithCapacity: 32];
/*
* Ensure we have a working connection.
*/
if ([self connect] == NO)
{
[NSException raise: SQLException
format: @"(Oracle) Unable to connect to database"];
}
NS_DURING
{
/* This is really the output descriptor. We do not use input
* descriptors; all the input is in the SQL statement.
*/
EXEC SQL ALLOCATE DESCRIPTOR 'myDesc';
allocatedDescriptor = YES;
EXEC SQL AT :handle PREPARE myQuery from :query;
if ([self isInTransaction] == NO)
{
/* EXEC SQL AT :handle BEGIN; */
_inTransaction = YES;
}
EXEC SQL AT :handle DECLARE myCursor CURSOR FOR myQuery;
EXEC SQL AT :handle OPEN myCursor;
isOpen = YES;
EXEC SQL AT :handle DESCRIBE OUTPUT myQuery USING DESCRIPTOR 'myDesc';
EXEC SQL GET DESCRIPTOR 'myDesc' :count = COUNT;
if (count > 0)
{
/* Now we do what the Oracle examples do, which is we forcefully
* require to the library to convert everything into types
* chosen by us (mostly strings). The reason we do it is that
* managing the 'internal' Oracle datatypes is a daunting task
* (for example numbers are returned in a 22 byte representation
* used internally by Oracle ...) and apparently it's now how
* they expect you to use it - they provide no examples or
* explanations of how to do it btw! They expect you to choose
* which 'external' Oracle representation you want, by using SET
* DESCRIPTOR as we do here, and then FETCH comfortably data
* which is returned in the representation you chose. So we do
* that way.
*/
int originalType[count];
for (index = 1; index <= count; index++)
{
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:length = LENGTH,
:octetLength = OCTET_LENGTH,
:type = TYPE;
/* Save the original type so that we know later what's
* inside each returned value. */
originalType[index - 1] = type;
switch (type)
{
/* Negative values of 'type' are used for Oracle
* proprietary extensions; positive values for ANSI
* types. */
/* We get character types as they are. */
case 1 /* CHARACTER */:
case 12 /* CHARACTER_VARYING */:
case -1 /* Oracle VARCHAR2 */:
type = -1; /* Oracle VARCHAR2 */
EXEC SQL SET DESCRIPTOR 'myDesc' VALUE :index
TYPE = :type;
break;
/* We get a string representation (128 bytes long)
* of any number. */
case 2 /* NUMERIC */:
case 3 /* DECIMAL */:
case 4 /* INTEGER */:
case 5 /* SMALLINT*/:
case 6 /* FLOAT */:
case 7 /* REAL */:
case 8 /* DOUBLE_PRECISION */:
type = 12; /* ANSI CHARACTER_VARYING */
octetLength = 128;
EXEC SQL SET DESCRIPTOR 'myDesc' VALUE :index
LENGTH = :octetLength,
TYPE = :type;
break;
}
}
while (1)
{
SQLRecord *record;
id keys[count];
id values[count];
EXEC SQL AT :handle FETCH myCursor INTO SQL DESCRIPTOR 'myDesc';
if (sqlca.sqlcode)
{
break;
}
for (index = 1; index <= count; ++index)
{
id v;
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:indicator = INDICATOR,
:length = LENGTH,
:fieldName = NAME,
:octetLength = OCTET_LENGTH,
:returnedOctetLength = RETURNED_OCTET_LENGTH,
:type = TYPE;
if (indicator == -1)
{
v = [NSNull null];
}
else
{
switch (originalType[index - 1])
{
case 3 /* DECIMAL */:
case 4 /* INTEGER */:
case 5 /* SMALLINT*/:
{
int aInt;
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aNumber = DATA;
aInt = [[NSString stringWithUTF8String: aNumber] intValue];
v = [NSNumber numberWithInt: aInt];
break;
}
case 2 /* NUMERIC */:
case 6 /* FLOAT */:
case 7 /* REAL */:
case 8 /* DOUBLE_PRECISION */:
{
float aFloat;
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aNumber = DATA;
aFloat = [[NSString stringWithUTF8String: aNumber] floatValue];
v = [NSNumber numberWithFloat: aFloat];
break;
}
case 1 /* CHARACTER */:
case 12 /* CHARACTER_VARYING */:
case -1 /* Oracle VARCHAR2 */:
/* For unclear reasons, returnedOctetLength is always 0. */
/* This code (patchy and experimentally
* determined) really works if the database
* field contains something like UTF-8,
* returned as UTF-8 (such as for CHAR(20)
* fields). If UNICODE stuff is returned,
* then it's not the right way. We might
* need to make a different depending on the
* originalField type.
*/
/* Add 1 byte to \0-pad the string. */
aString = malloc (octetLength + 1);
if (aString == NULL)
{
[NSException
raise: @"OutOfMemoryException"
format: @"(Oracle) could not malloc %d bytes",
octetLength];
}
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aString = DATA;
/* \0-pad the string. */
aString[octetLength] = '\0';
if (YES == _shouldTrim)
{
trim (aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
/* TODO: DATES */
/*
TODO TODO
case BLOB:
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aString = DATA;
v = [self dataFromBlob: aString];
free(aString);
break;
*/
default:
aString = malloc (octetLength + 1);
if (aString == NULL)
{
[NSException
raise: @"OutOfMemoryException"
format: @"(Oracle) could not malloc %d bytes",
octetLength];
}
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aString = DATA;
aString[octetLength] = '\0';
if (YES == _shouldTrim)
{
trim (aString);
}
v = [NSString stringWithUTF8String: aString];
free (aString);
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",
type, fieldName, v);
break;
}
}
values[index - 1] = v;
keys[index - 1] = [NSString stringWithUTF8String:
fieldName];
}
record = [rClass newWithValues: values
keys: keys
count: count];
[records addObject: record];
RELEASE(record);
}
}
isOpen = NO;
EXEC SQL AT :handle CLOSE myCursor;
if (wasInTransaction == NO && [self isInTransaction] == YES)
{
EXEC SQL AT :handle COMMIT;
_inTransaction = NO;
}
EXEC SQL DEALLOCATE DESCRIPTOR 'myDesc';
allocatedDescriptor = NO;
}
NS_HANDLER
{
NSString *n = [localException name];
NSString *msg = [localException reason];
DESTROY(records);
NS_DURING
{
if (isOpen == YES)
{
EXEC SQL AT :handle CLOSE myCursor;
}
if (wasInTransaction == NO && [self isInTransaction] == YES)
{
EXEC SQL AT :handle ROLLBACK;
_inTransaction = NO;
}
}
NS_HANDLER
{
NSString *e = [localException name];
if (wasInTransaction == NO && [self isInTransaction] == YES)
{
_inTransaction = NO;
}
if ([e isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
}
NS_ENDHANDLER
NS_DURING
{
if (allocatedDescriptor)
{
EXEC SQL DEALLOCATE DESCRIPTOR 'myDesc';
allocatedDescriptor = NO;
}
}
NS_HANDLER
{
NSLog (@"Can't deallocate descriptor ... serious problem.");
}
NS_ENDHANDLER
if ([n isEqual: SQLConnectionException] == YES)
{
_inTransaction = NO;
[self disconnect];
}
/*
* remove line number information from database exception message
* since it's meaningless to the developer as it's the line number
* in this file rather than the code which is calling us.
*/
if ([n isEqual: SQLException] == YES
|| [n isEqual: SQLConnectionException] == YES)
{
NSRange r;
r = [msg rangeOfString: @" in line " options: NSBackwardsSearch];
if (r.length > 0)
{
msg = [msg substringToIndex: r.location];
localException = [NSException exceptionWithName: n
reason: msg
userInfo: nil];
}
}
RETAIN(localException);
RELEASE(arp);
AUTORELEASE(localException);
[localException raise];
}
NS_ENDHANDLER
DESTROY(arp);
return AUTORELEASE(records);
}
/**
* Convert NSData object with raw binary data into escaped sequence
*/
- (const char *) blobFromData: (NSData*)data
{
NSMutableData *md;
unsigned sLen = [data length];
unsigned char *src = (unsigned char*)[data bytes];
unsigned dLen = 0;
unsigned char *dst;
unsigned i;
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126)
{
dLen += 4;
}
else if (c == 92)
{
dLen += 2;
}
else
{
dLen += 1;
}
}
md = [NSMutableData dataWithLength: dLen + 1];
dst = (unsigned char*)[md mutableBytes];
dLen = 0;
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126)
{
dst[dLen] = '\\';
dst[dLen + 3] = (c & 7) + '0';
c >>= 3;
dst[dLen + 2] = (c & 7) + '0';
c >>= 3;
dst[dLen + 1] = (c & 7) + '0';
dLen += 4;
}
else if (c == 92)
{
dst[dLen++] = '\\';
dst[dLen++] = '\\';
}
else
{
dst[dLen++] = c;
}
}
dst[dLen] = '\0';
return dst; // Owned by autoreleased NSMutableData
}
/**
* Convert escaped sequence to raw binary data in NSData object
*/
- (NSData *) dataFromBlob: (const char *)blob
{
NSMutableData *md;
unsigned sLen = strlen(blob == 0 ? "" : blob);
unsigned dLen = 0;
unsigned char *dst;
unsigned i;
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
dLen++;
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
i += 2; // Skip 2 digits octal
}
}
}
md = [NSMutableData dataWithLength: dLen];
dst = (unsigned char*)[md mutableBytes];
dLen = 0;
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
c = c - '0';
c <<= 3;
c += blob[++i] - '0';
c <<= 3;
c += blob[++i] - '0';
}
}
dst[dLen++] = c;
}
return md;
}
/**
* Convert an NSdate into a buffer for sending to the database.
* Return YES if the conversion fitted, NO if it was truncated.
* The value of l is expected to be one less than the size of the buffer.
* A nul character is appended to the bytes in the buffer.
*/
- (BOOL) dbFromDate: (NSDate*)d toBuffer: (char*)b length: (int)l
{
NSString *s;
s = [d descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"
timeZone: nil
locale: nil];
return [self dbFromString: s toBuffer: b length: l];
}
/**
* Convert an NSString into a buffer for sending to the database.
* Return YES if the conversion fitted, NO if it was truncated.
* If s is nil, it is treated as an empty string.
* The value of l is expected to be one less than the size of the buffer
* and must be at least 1.
* The pointer b must not be null.
* A nul character is appended to the bytes in the buffer.
* Raises an exception when passed invalid arguments.
*/
- (BOOL) dbFromString: (NSString*)s toBuffer: (char*)b length: (int)l
{
NSData *d;
BOOL ok = YES;
unsigned size = l;
if (l <= 0)
{
[NSException raise: NSInvalidArgumentException
format: @"(Oracle) -%@: length too small (%d)",
NSStringFromSelector(_cmd), l];
}
if (b == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"(Oracle) -%@: buffer is null",
NSStringFromSelector(_cmd)];
}
if (s == nil)
{
s = @"";
}
d = [s dataUsingEncoding: NSUTF8StringEncoding];
if (l < (int)[d length])
{
/*
* As the data is UTF8, we need to avoid truncating in the
* middle of a multibyte character, so we shorten the
* original string and reconvert to UTF8 until we find a
* string that fits.
*/
if ((int)[s length] > l)
{
s = [s substringToIndex: l];
d = [s dataUsingEncoding: NSUTF8StringEncoding];
}
while ((int)[d length] > l)
{
s = [s substringToIndex: [s length] - 1];
d = [s dataUsingEncoding: NSUTF8StringEncoding];
}
ok = NO;
}
size = [d length];
memcpy(b, (const char*)[d bytes], size);
/*
* Pad with nuls and ensure there is a nul terminator.
*/
while ((int)size <= l)
{
b[size++] = '\0';
}
return ok;
}
- (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;
memcpy(buf, b, l);
b = buf;
/*
* Find end of string.
*/
for (i = 0; i < l; i++)
{
if (b[i] == '\0')
{
l = i;
break;
}
}
while (l > 0 && isspace(b[l-1]))
{
l--;
}
b[l] = '\0';
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
return [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d"
locale: nil];
}
i = l;
/* Convert +/-HH:SS timezone to +/-HHSS
*/
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
{
b[i-3] = b[i-2];
b[i-2] = b[i-1];
b[--i] = '\0';
}
while (i-- > 0)
{
if (b[i] == '+' || b[i] == '-')
{
break;
}
if (b[i] == ':' || b[i] == ' ')
{
i = 0;
break; /* No time zone found */
}
}
if (i == 0)
{
e = l;
}
else
{
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';
}
/*
* Ensure we have a four digit timezone value.
*/
if (isdigit(b[i+1]) && isdigit(b[i+2]))
{
if (b[i+3] == '\0')
{
// Two digit time zone ... append zero minutes
b[l++] = '0';
b[l++] = '0';
b[l] = '\0';
}
else if (b[i+3] == ':')
{
// Zone with colon before minutes ... remove it
b[i+3] = b[i+4];
b[i+4] = b[i+5];
b[--l] = '\0';
}
}
}
/* kludge for timestamps with fractional second information.
* Force it to 3 digit millisecond */
while (i-- > 0)
{
if (b[i] == '.')
{
milliseconds = YES;
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+3], &b[i], e-i);
l += 3;
memcpy(&b[i], "000", 3);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+2], &b[i], e-i);
l += 2;
memcpy(&b[i], "00", 2);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+1], &b[i], e-i);
l += 1;
memcpy(&b[i], "0", 1);
}
i++;
break;
}
}
if (i > 0 && i < e)
{
memmove(&b[i], &b[e], l - e);
l -= (e - i);
}
b[l] = '\0';
if (l == 0)
{
return nil;
}
s = [NSString stringWithUTF8String: b];
if (YES == timezone)
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
}
}
else
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S"
locale: nil];
}
}
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
return d;
}
/**
* Convert from a database character buffer to an NSString.
*/
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l
{
NSData *d;
NSString *s;
/*
* Database fields are padded to the full field size with spaces or nuls ...
* we need to remove that padding before placing in a string.
*/
while (l > 0 && b[l-1] <= ' ')
{
l--;
}
d = [[NSData alloc] initWithBytes: b length: l];
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
RELEASE(d);
return AUTORELEASE(s);
}
@end
SQLClient-1.7.3/Performance.import 0000664 0000765 0000765 00000000045 10377047517 016725 0 ustar brains99 brains99
import gnu.gnustep.Performance.*;
SQLClient-1.7.3/SQLite.m 0000664 0000765 0000765 00000020750 12115132001 014523 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientSQLite for GNUStep
Copyright (C) 2005 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
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: 2013-03-04 14:47:29 +0000 (Mon, 04 Mar 2013) $ $Revision: 36261 $
*/
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
#include
#include
@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
SQLClient-1.7.3/configure.ac 0000664 0000765 0000765 00000034607 11641375200 015515 0 ustar brains99 brains99 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
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
#--------------------------------------------------------------------
AC_ARG_WITH(additional-include, [
--with-additional-include=flags
Specifies additional include compiler flags to use.
If configure can not find your database library headers,
you may want to use this flag to help it find them. For
example:
--with-additional-include=-I/usr/local/include
],
additional_include="$withval", additional_include="no")
if test "$additional_include" != "no"; then
CPPFLAGS="$CPPFLAGS $additional_include"
INCD="$INCD $additional_include"
fi
AC_ARG_WITH(additional-lib, [
--with-additional-lib=flags
Specifies additional library compiler flags to use.
If configure can not find your database libraries,
you may want to use this flag to help it find them. For
example:
--with-additional-lib=-L/usr/local/lib/mysql
],
additional_lib="$withval", additional_lib="no")
if test "$additional_lib" != "no"; then
LDFLAGS="$LDFLAGS $additional_lib"
LIBD="$LIBD $additional_lib"
fi
AC_ARG_WITH(postgres-dir, [
--with-postgres-dir=PATH
Specifies the postgres installation dir; configure
will add the appropriate additional include and lib
flags. Useful when you installed postgres in some
unusual place and want to help configure find it. For
example:
--with-postgres-dir=/usr/local/pgsql
(which is equivalent to
--with-additional-include=-L/usr/local/pgsql/include
--with-additional-lib=-L/usr/local/pgsql/lib)
],
postgres_topdir="$withval", postgres_topdir="no")
if test "$postgres_topdir" != "no"; then
CPPFLAGS="$CPPFLAGS -I$postgres_topdir/include -L$postgres_topdir/lib"
INCD="$INCD -I$postgres_topdir/include"
LIBD="$LIBD -L$postgres_topdir/lib"
else
PGINC=`pg_config --includedir`
if test "$PGINC" != ""; then
CPPFLAGS="$CPPFLAGS -I$PGINC"
INCD="$INCD -I$PGINC"
fi
PGLIB=`pg_config --libdir`
if test "$PGLIB" != ""; then
CPPFLAGS="$CPPFLAGS -L$PGLIB"
LIBD="$LIBD -I$PGLIB"
fi
fi
# Call AC_CHECK_HEADERS here as a workaround for a configure bug/feature
# which messes up all subsequent tests if the first occurrence in the
# file does not get called ... as would otherwise be the case if jdbc
# support is disabled.
AC_CHECK_HEADERS(stdio.h)
AC_MSG_CHECKING([if Jdbc support was manually disabled])
AC_ARG_ENABLE(jdbc-bundle, [
--disable-jdbc-bundle
Disable creating the Jdbc bundle.
Use this option to force the Jdbc bundle not to be built
even if the Jdbc libraries look like being present.
],
ac_cv_jdbc_bundle=$enableval,
ac_cv_jdbc_bundle="yes")
if test "$ac_cv_jdbc_bundle" = "no"; then
AC_MSG_RESULT([yes: disabled from the command-line])
else
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
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
fi
AC_SUBST(MYSQL)
fi
AC_MSG_CHECKING([if Sqllite support was manually disabled])
AC_ARG_ENABLE(sqllite-bundle, [
--disable-sqllite-bundle
Disable creating the Sqllite bundle.
Use this option to force the Sqllite bundle not to be built
even if the Sqllite libraries look like being present.
],
ac_cv_sqllite_bundle=$enableval,
ac_cv_sqllite_bundle="yes")
if test "$ac_cv_sqllite_bundle" = "no"; then
AC_MSG_RESULT([yes: disabled from the command-line])
SQLLITE=
else
AC_MSG_RESULT([no: build if possible])
AC_CHECK_HEADERS(sqlite3.h)
if test "$ac_cv_header_sqlite3_h" = "yes"; then
SQLITE=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
AC_SUBST(SQLITE)
fi
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 "$ECPG" = ""; then
AC_CHECK_HEADERS(ecpglib.h)
if test "$ac_cv_header_ecpglib_h" = "yes"; then
ECPG=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 "$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 "$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 "$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 "$POSTGRES" = ""; then
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
CPPFLAGS="$save_CPPFLAGS"
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 "$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 "$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 "$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 "$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 "$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 "$POSTGRES" = ""; then
echo "**************************************************************"
echo "Unable to locate libpq (postgres) headers (are they installed)"
echo "**************************************************************"
fi
if test "$ECPG" = ""; then
echo "*************************************************************"
echo "Unable to locate ecpg (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"
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)
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)"
else
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
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 POSTGRES checks
fi
AC_SUBST(POSTGRES)
AC_SUBST(ECPG)
ORACLE_HOME=
AC_SUBST(ORACLE_HOME)
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
BUNDLE="The MySQL backend bundle will NOT be built"
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
BUNDLE="The Postgres backend bundle will NOT be built"
fi
AC_MSG_RESULT(${BUNDLE})
if test "$ECPG" = "yes"; then
BUNDLE="The ECPG backend bundle will be built"
else
BUNDLE="The ECPG backend bundle will NOT be built"
fi
AC_MSG_RESULT(${BUNDLE})
if test "$ORACLE" = "yes"; then
BUNDLE="The Oracle backend bundle will be built"
else
BUNDLE="The Oracle backend bundle will NOT be built"
fi
AC_MSG_RESULT(${BUNDLE})
AC_OUTPUT(config.make)
SQLClient-1.7.3/GNUmakefile 0000664 0000765 0000765 00000015765 12341126673 015313 0 ustar brains99 brains99
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
-include config.make
PACKAGE_NAME = SQLClient
PACKAGE_VERSION = 1.7.3
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.7
SQLClient_OBJC_FILES = SQLClient.m
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance
SQLClient_HEADER_FILES = SQLClient.h
SQLClient_AGSDOC_FILES = SQLClient.h
SQLClient_AGSDOC_FLAGS = -WordMap '{SQLCLIENT_PRIVATE="";}'
# Optional Java wrappers for the library
JAVA_WRAPPER_NAME = SQLClient
SQLClient_HEADER_FILES_INSTALL_DIR = SQLClient
BUNDLE_NAME=
BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient
# In some systems and situations the dynamic linker needs to haved the
# SQLClient, gnustep-base, and objc libraries explicityly linked into
# the bundle, but in others it requires them to not be linked.
# 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_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_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
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_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_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
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_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_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
endif
ifneq ($(ORACLE_HOME),)
BUNDLE_NAME += Oracle
Oracle_OBJC_FILES = Oracle.m
Oracle_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
$(shell cat $(ORACLE_HOME)/lib/ldflags)
Oracle_BUNDLE_LIBS += -lclntsh \
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
-ldl -lm
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) \
$(shell cat $(ORACLE_HOME)/lib/ldflags)
Oracle_libs_BUNDLE_LIBS += -lclntsh \
-lSQLClient -lPerformance $(FND_LIBS) $(OBJC_LIBS) \
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
-ldl -lm
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
endif
-include GNUmakefile.preamble
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
-include GNUmakefile.postamble
SQLClient-1.7.3/SQLClient.h 0000664 0000765 0000765 00000200033 12341126673 015170 0 ustar brains99 brains99 /**
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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.
SQLClient documentation
The SQLClient library
What is the SQLClient library?
The SQLClient library is designed to provide a simple interface to SQL
databases for GNUstep applications. It does not attempt the sort of
abstraction provided by the much more sophisticated GDL2 library, but
rather allows applications to directly execute SQL queries and
statements.
SQLClient provides for the Objective-C programmer much the same thing
that JDBC provides for the Java programmer (though SQLClient is a bit
faster, easier to use, and easier to add new database backends for
than JDBC).
The major features of the SQLClient library are -
-
Simple API for executing queries and statements ... a variable
length sequence of comma separated strings and other objects
(NSNumber, NSDate, NSData) are concatenated into a single SQL
statement and executed.
-
Simple API ([SQLTransaction])for combining multiple SQL statements
into a single transaction which can be used to minimise client-server
interactions to get the best possible performance from your database.
-
Supports multiple sumultaneous named connections to a database
server in a thread-safe manner.
-
Supports multiple simultaneous connections to different database
servers with backend driver bundles loaded for different database
engines. Clear, simple subclassing of the abstract base class to
enable easy implementation of new backend bundles.
-
Configuration for all connections held in one place and referenced
by connection name for ease of configuration control.
Changes via NSUserDefaults can even allow reconfiguration of
client instances within a running application.
-
Thread safe operation ... The base class supports locking such that
a single instance can be shared between multiple threads.
-
Support for standalone web applications ... eg to allow data to be
added to the database by people posting web forms to the application.
-
Supports notification of connection to and disconnection from the
database server.
What backend bundles are available?
Current backend bundles are -
-
ECPG - a bundle using the embedded SQL interface for postgres.
This is based on a similar code which was in production use
for over eighteen months, so it should be reliable, but inefficient.
-
Postgres - a bundle using the libpq native interface for postgres.
This is the preferred backend as it allows 'SELECT FOR UPDATE', which
the ECPG backend cannot support due to limitations in the postgres
implementation of cursors. The code is now well tested and known
to be efficient.
-
MySQL - a bundle using the mysqlclient library for *recent* MySQL.
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.
No support for BLOBs yet.
Where can you get it? How can you install it?
The SQLClient library is currently only available via CVS from the
GNUstep CVS repository.
See <https://savannah.gnu.org/cvs/?group=gnustep>
You need to check out gnustep/dev-libs/SQLClient
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.
-
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.
-
Then you can run the test programs.
-
Your most likely problems are that the configure script may not
detect the database libraries you want ... Please figure out how
to modify
configure.ac
so that it will detect the
required headers and libraries on your system, and supply na patch.
-
Once the library is installed, you can include the header file
<SQLClient/SQLClient.h%gt;
and link your programs
with the SQLClient
library to use it.
Bug reports, patches, and contributions (eg a backend bundle for a
new database) should be entered on the GNUstep project page
<http://savannah.gnu.org/projects/gnustep> and the bug
reporting page <http://savannah.gnu.org/bugs/?group=gnustep>
$Date: 2014-05-27 16:22:35 +0100 (Tue, 27 May 2014) $ $Revision: 37913 $
*/
#ifndef INCLUDED_SQLClient_H
#define INCLUDED_SQLClient_H
#import
#import
@class NSCountedSet;
@class NSMapTable;
@class NSMutableDictionary;
@class NSMutableSet;
@class NSString;
@class NSThread;
@class GSCache;
@class SQLTransaction;
/**
* Notification sent when an instance becomes connected to the database
* server. The notification object is the instance connected.
*/
extern NSString * const SQLClientDidConnectNotification;
/**
* Notification sent when an instance becomes disconnected from the database
* server. The notification object is the instance disconnected.
*/
extern NSString * const SQLClientDidDisconnectNotification;
#if !defined(SQLCLIENT_PRIVATE)
#define SQLCLIENT_PRIVATE @private
#endif
/**
* An enhanced array to represent a record returned from a query.
* You should NOT try to create instances of this class
* except via the +newWithValues:keys:count: method.
*
* SQLRecord is the abstract base class of a class cluster.
* If you wish to subclass it you must implement the primitive methods
* +newWithValues:keys:count: -count -keyAtIndex: -objectAtIndex:
* and -replaceObjectAtIndex:withObject:
*
* NB. You do not need to use SQLRecord (or a subclass of it), all you
* actually need to supply is a class which responds to the
* +newWithValues:keys:count: method that the system uses to create
* new records ... none of the other methods of the SQLRecord class
* are used internally by the SQLClient system.
*
*/
@interface SQLRecord : NSArray
/**
* Create a new SQLRecord containing the specified fields.
* NB. The values and keys are retained by the record rather
* than being copied.
* A nil value is represented by [NSNull null].
* Keys must be unique string values (case insensitive comparison).
*/
+ (id) newWithValues: (id*)v
keys: (NSString**)k
count: (unsigned int)c;
/**
* Returns an array containing the names of all the fields in the record.
*/
- (NSArray*) allKeys;
/**
* Returns the number of items in the record.
* Subclasses must implement this method.
*/
- (NSUInteger) count;
/**
* Return the record as a mutable dictionary with the keys as the
* record field names standardised to be lowercase strings.
*/
- (NSMutableDictionary*) dictionary;
/**
* Optimised mechanism for retrieving all keys in order.
*/
- (void) getKeys: (id*)buf;
/**
* Optimised mechanism for retrieving all objects.
*/
- (void) getObjects: (id*)buf;
/**
* Returns the key at the specified indes.
*/
- (NSString*) keyAtIndex: (NSUInteger)index;
/**
* Returns the object at the specified indes.
*/
- (id) objectAtIndex: (NSUInteger)index;
/**
* Returns the value of the named field.
* The field name is case insensitive.
*/
- (id) objectForKey: (NSString*)key;
/**
* Replaces the value at the specified index.
* Subclasses must implement this method.
*/
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject;
/**
* Replaces the value of the named field.
* The field name is case insensitive.
* NB. You must be careful not to change the contents of a record which
* has been cached (unless you are sure you really want to), as you will
* be changing the contents of the cache, not just a private copy.
*/
- (void) setObject: (id)anObject forKey: (NSString*)aKey;
/**
* Return approximate size of this record in bytes.
* The exclude set is used to specify objects to exclude from the
* calculation (to prevent recursion etc).
*/
- (NSUInteger) sizeInBytes: (NSMutableSet*)exclude;
@end
extern NSString *SQLException;
extern NSString *SQLConnectionException;
extern NSString *SQLEmptyException;
extern NSString *SQLUniqueException;
/**
* Returns the timestamp of the most recent call to SQLClientTimeNow().
*/
extern NSTimeInterval SQLClientTimeLast();
/**
* Convenience function to provide timing information quickly.
* This returns the current date/time, and stores the value for use
* by the SQLClientTimeLast() function.
*/
extern NSTimeInterval SQLClientTimeNow();
/**
* This returns the timestamp from which any of the SQLClient classes was
* first used or SQLClientTimeNow() was first called (whichever came first).
*/
extern NSTimeInterval SQLClientTimeStart();
/**
* A convenience method to return the current clock 'tick' ... which is
* the current second based on the time we started. This does not
* check the current time, but relies on SQLClientTimeLast() returning an
* up to date value (so if you need an accurate tick, you should ensure
* that SQLClientTimeNow() is called at least once a second).
* The returned value is always greater than zero, and is basically
* calculated as (SQLClientTimeLast() - SQLClientTimeStart() + 1).
* In the event that the system clock is reset into the past, the value
* of SQLClientTimeStart() is automatically adjusted to ensure that the
* result of a call to SQLClientTimeTick() is never less than the result
* of any earlier call to the function.
*/
extern unsigned SQLClientTimeTick();
/**
* The SQLClient class encapsulates dynamic SQL access to relational
* database systems. A shared instance of the class is used for
* each database (as identified by the name of the database), and
* the number of simultanous database connections is managed too.
*
* SQLClient is an abstract base class ... when you create an instance
* of it, you are actually creating an instance of a concrete subclass
* whose implementation is loaded from a bundle.
*
*/
@interface SQLClient : NSObject
{
SQLCLIENT_PRIVATE
void *extra; /** For subclass specific data */
NSRecursiveLock *lock; /** Maintain thread-safety */
/**
* A flag indicating whether this instance is currently connected to
* the backend database server. This variable must only be
* set by the -backendConnect or -backendDisconnect methods.
*/
BOOL connected;
/**
* A flag indicating whether this instance is currently within a
* transaction. This variable must only be
* set by the -begin, -commit or -rollback methods.
*/
BOOL _inTransaction; /** Are we inside a transaction? */
/**
* A flag indicating whether leading and trailing white space in values
* read from the database should automatically be removed.
* This should only be modified by the -setShouldTrim: method.
*/
BOOL _shouldTrim; /** Should whitespace be trimmed? */
NSString *_name; /** Unique identifier for instance */
NSString *_client; /** Identifier within backend */
NSString *_database; /** The configured database name/host */
NSString *_password; /** The configured password */
NSString *_user; /** The configured user */
NSMutableArray *_statements; /** Uncommitted statements */
/**
* Timestamp of last operation.
* Maintained by -simpleExecute: -simpleQuery:recordType:listType:
* and -cache:simpleQuery:recordType:listType:
* Also set for a failed connection attempt, but not reported by the
* -lastOperation method in that case.
*/
NSTimeInterval _lastOperation;
NSTimeInterval _duration;
unsigned int _debugging; /** The current debugging level */
GSCache *_cache; /** The cache for query results */
NSThread *_cacheThread; /** Thread for cache queries */
unsigned int _connectFails; /** The count of connection failures */
NSMapTable *_observers; /** Observations of async events */
NSCountedSet *_names; /** Track notification names */
/** Allow for extensions by allocating memory and pointing to it from
* the _extra ivar. That way we can avoid binary incompatibility between
* minor releases.
*/
void *_extra;
}
/**
* Returns an array containing all the SQLClient instances .
*/
+ (NSArray*) allClients;
/**
* Return an existing SQLClient instance (using +existingClient:) if possible,
* or creates one, initialises it using -initWithConfiguration:name:, and
* returns the new instance (autoreleased).
* Returns nil on failure.
*/
+ (SQLClient*) clientWithConfiguration: (NSDictionary*)config
name: (NSString*)reference;
/**
* Return an existing SQLClient instance for the specified name
* if one exists, otherwise returns nil.
*/
+ (SQLClient*) existingClient: (NSString*)reference;
/**
* Return the maximum number of simultaneous database connections
* permitted (set by +setMaxConnections: and defaults to 8)
*/
+ (unsigned int) maxConnections;
/**
* Use this method to reduce the number of database connections
* currently active so that it is less than the limit set by the
* +setMaxConnections: method. This mechanism is used internally
* by the class to ensure that, when it is about to open a new
* connection, the limit is not exceeded.
*
* If since is not nil, then any connection which has not been
* used more recently than that date is disconnected anyway.
* You can (and probably should) use this periodically to purge
* idle connections, but you can also pass a date in the future to
* close all connections.
*
*/
+ (void) purgeConnections: (NSDate*)since;
/**
* Set the maximum number of simultaneous database connections
* permitted (defaults to 8 and may not be set less than 1).
*
* This value is used by the +purgeConnections: method to determine how
* many connections should be disconnected when it is called.
*
*/
+ (void) setMaxConnections: (unsigned int)c;
/**
* Start a transaction for this database client.
* You must match this with either a -commit
* or a -rollback.
* Normally, if you execute an SQL statement without using this
* method first, the autocommit feature is employed, and
* the statement takes effect immediately. Use of this method
* permits you to execute several statements in sequence, and
* only have them take effect (as a single operation) when you
* call the -commit method.
*
* NB. You must not execute an SQL statement
* which would start a transaction directly ... use only this
* method.
*
* Where possible, consider using the [SQLTransaction] class rather
* than calling -begin -commit or -rollback yourself.
*
*/
- (void) begin;
/**
* Build an sql query string using the supplied arguments.
*
* This method has at least one argument, the string starting the
* query to be executed (which must have the prefix 'select ').
*
* Additional arguments are a nil terminated list which also be strings,
* and these are appended to the statement.
* Any string arguments are assumed to have been quoted appropriately
* already, but non-string arguments are automatically quoted using the
* -quote: method.
*
*
* sql = [db buildQuery: @"SELECT Name FROM ", table, nil];
*
* Upon error, an exception is raised.
*
* The method returns a string containing sql suitable for passing to
* the -simpleQuery:recordType:listType:
* or -cache:simpleQuery:recordType:listType: methods.
*
*/
- (NSString*) buildQuery: (NSString*)stmt,...;
/**
* Takes the query statement and substitutes in values from
* the dictionary where markup of the format {key} is found.
* Returns the resulting query string.
*
* sql = [db buildQuery: @"SELECT Name FROM {Table} WHERE ID = {ID}"
* with: values];
*
* Any non-string values in the dictionary will be replaced by
* the results of the -quote: method.
* The markup format may also be {key?default} where default
* is a string to be used if there is no value for the key
* in the dictionary.
*
* The method returns a string containing sql suitable for passing to
* the -simpleQuery:recordType:listType:
* or -cache:simpleQuery:recordType:listType: methods.
*
*/
- (NSString*) buildQuery: (NSString*)stmt with: (NSDictionary*)values;
/**
* Return the client name for this instance.
* Normally this is useful only for debugging/reporting purposes, but
* if you are using multiple instances of this class in your application,
* and you are using embedded SQL, you will need to use this
* method to fetch the client/connection name and store its C-string
* representation in a variable 'connectionName' declared to the sql
* preprocessor, so you can then have statements of the form -
* 'exec sql at :connectionName ...'.
*/
- (NSString*) clientName;
/**
* Complete a transaction for this database client.
* This must match an earlier -begin.
* NB. You must not execute an SQL statement
* which would commit or rollback a transaction directly ... use
* only this method or the -rollback method.
*
* Where possible, consider using the [SQLTransaction] class rather
* than calling -begin -commit or -rollback yourself.
*
*/
- (void) commit;
/**
* If the connected instance variable is NO, this method
* calls -backendConnect to ensure that there is a connection to the
* database server established. Returns the result.
* Performs any necessary locking for thread safety.
* This method also counts the number of consecutive failed connection
* attempts. A delay is enforced between each connection attempt, with
* the length of the delay growing with each failure. This ensures
* that applications which fail to deal with connection failures, and
* just keep trying to reconnect, will not overload the system/server.
* The maximum delay is 30 seconds, so when the database server is restarted,
* the application can reconnect reasonably quickly.
*/
- (BOOL) connect;
/**
* Return a flag to say whether a connection to the database server is
* currently live. This is mostly useful for debug/reporting, but is
* used internally to keep track of active connections.
*/
- (BOOL) connected;
/**
* Return the database name for this instance (or nil).
*/
- (NSString*) database;
/**
* If the connected instance variable is YES, this method
* calls -backendDisconnect to ensure that the connection to the
* database server is dropped.
* Performs any necessary locking for thread safety.
*/
- (void) disconnect;
/**
* Perform arbitrary operation which does not return any value.
* This arguments to this method are a nil terminated list which are
* concatenated in the manner of the -query:,... method.
* Any string arguments are assumed to have been quoted appropriately
* already, but non-string arguments are automatically quoted using the
* -quote: method.
*
* [db execute: @"UPDATE ", table, @" SET Name = ",
* myName, " WHERE ID = ", myId, nil];
*
* Where the database backend support it, this method returns the count of
* the number of rows to which the operation applied. Otherwise this
* returns -1.
*/
- (NSInteger) execute: (NSString*)stmt,...;
/**
* Takes the statement and substitutes in values from
* the dictionary where markup of the format {key} is found.
* Passes the result to the -execute:,... method.
*
* [db execute: @"UPDATE {Table} SET Name = {Name} WHERE ID = {ID}"
* with: values];
*
* Any non-string values in the dictionary will be replaced by
* the results of the -quote: method.
* The markup format may also be {key?default} where default
* is a string to be used if there is no value for the key
* in the dictionary.
* Where the database backend support it, this method returns the count of
* the number of rows to which the operation applied. Otherwise this
* returns -1.
*/
- (NSInteger) execute: (NSString*)stmt with: (NSDictionary*)values;
/**
* Calls -initWithConfiguration:name: passing a nil reference name.
*/
- (id) initWithConfiguration: (NSDictionary*)config;
/**
* Initialise using the supplied configuration, or if that is nil, try to
* use values from NSUserDefaults (and automatically update when the
* defaults change).
* Uses the reference name to determine configuration information ... and if
* a nil name is supplied, defaults to the value of SQLClientName in the
* configuration dictionary (or in the standard user defaults). If there is
* no value for SQLClientName, uses the string 'Database'.
* If a SQLClient instance already exists with the name used for this
* instance, the receiver is deallocated and the existing instance is
* retained and returned ... there may only ever be one instance for a
* particular reference name.
*
* The config argument (or the SQLClientReferences user default)
* is a dictionary with names as keys and dictionaries
* as its values. Configuration entries from the dictionary corresponding
* to the database client are used if possible, general entries are used
* otherwise.
* Database ... is the name of the database to use, if it is missing
* then 'Database' may be used instead.
* User ... is the name of the database user to use, if it is missing
* then 'User' may be used instead.
* Password ... is the name of the database user password, if it is
* missing then 'Password' may be used instead.
* ServerType ... is the name of the backend server to be used ... by
* convention the name of a bundle containing the interface to that backend.
* If this is missing then 'Postgres' is used.
* The database name may be of the format 'name@host:port' when you wish to
* connect to a database on a different host over the network.
*/
- (id) initWithConfiguration: (NSDictionary*)config
name: (NSString*)reference;
/** Two clients are considered equal if they refer to the same database
* and are logged in as the same database user using the same protocol.
* These are the general criteria for transactions to be compatoible so
* that an SQLTransaction object generated by one client can be used by
* the other.
*/
- (BOOL) isEqual: (id)other;
/**
* Return the state of the flag indicating whether the library thinks
* a transaction is in progress. This flag is normally maintained by
* -begin, -commit, and -rollback.
*/
- (BOOL) isInTransaction;
/**
* Returns the date/time stamp of the last database operation performed
* by the receiver, or nil if no operation has ever been done by it.
* Simply connecting to or disconnecting from the databsse does not
* count as an operation.
*/
- (NSDate*) lastOperation;
/**
* Return the database reference name for this instance (or nil).
*/
- (NSString*) name;
/**
* Return the database password for this instance (or nil).
*/
- (NSString*) password;
/**
* Perform arbitrary query which returns values.
*
* This method handles its arguments in the same way as the -buildQuery:,...
* method and returns the result of the query.
*
*
* result = [db query: @"SELECT Name FROM ", table, nil];
*
* Upon error, an exception is raised.
*
* The query returns an array of records (each of which is represented
* by an SQLRecord object).
*
* Each SQLRecord object contains one or more fields, in the order in
* which they occurred in the query. Fields may also be retrieved by name.
*
* NULL field items are returned as NSNull objects.
*
* Most other field items are returned as NSString objects.
*
* Date and timestamp field items are returned as NSDate objects.
*
*/
- (NSMutableArray*) query: (NSString*)stmt,...;
/**
* Takes the query statement and substitutes in values from
* the dictionary (in the same manner as the -buildQuery:with: method)
* then executes the query and returns the response.
*
* result = [db query: @"SELECT Name FROM {Table} WHERE ID = {ID}"
* with: values];
*
* Any non-string values in the dictionary will be replaced by
* the results of the -quote: method.
* The markup format may also be {key?default} where default
* is a string to be used if there is no value for the key
* in the dictionary.
*/
- (NSMutableArray*) query: (NSString*)stmt with: (NSDictionary*)values;
/**
* Convert an object to a string suitable for use in an SQL query.
* Normally the -execute:,..., and -query:,... methods will call this
* method automatically for everything apart from string objects.
* Strings have to be handled specially, because they are used both for
* parts of the SQL command, and as values (where they need to be quoted).
* So where you need to pass a string value which needs quoting,
* you must call this method explicitly.
* Subclasses may override this method to provide appropriate quoting for
* types of object which need database backend specific quoting conventions.
* However, the defalt implementation should be OK for most cases.
* This method makes use of -quoteString: to quote literal strings.
* The base class implementation formats NSDate objects as
* YYYY-MM-DD hh:mm:ss.mmm ?ZZZZ
* NSData objects are not quoted ... they must not appear in queries, and
* where used for insert/update operations, they need to be passed to the
* -backendExecute: method unchanged.
*/
- (NSString*) quote: (id)obj;
/**
* Produce a quoted string from the supplied arguments (printf style).
*/
- (NSString*) quotef: (NSString*)fmt, ...;
/**
* Convert a big (64 bit) integer to a string suitable for use in an SQL query.
*/
- (NSString*) quoteBigInteger: (int64_t)i;
/**
* Convert a 'C' string to a string suitable for use in an SQL query
* by using -quoteString: to convert it to a literal string format.
* NB. a null pointer is treated as an empty string.
*/
- (NSString*) quoteCString: (const char *)s;
/**
* Convert a single character to a string suitable for use in an SQL query
* by using -quoteString: to convert it to a literal string format.
* NB. a nul character is not allowed and will cause an exception.
*/
- (NSString*) quoteChar: (char)c;
/**
* Convert a float to a string suitable for use in an SQL query.
*/
- (NSString*) quoteFloat: (float)f;
/**
* Convert an integer to a string suitable for use in an SQL query.
*/
- (NSString*) quoteInteger: (int)i;
/**
* Convert a string to a form suitable for use as a string
* literal in an SQL query.
* Subclasses may override this for non-standard literal string
* quoting conventions.
*/
- (NSString*) quoteString: (NSString *)s;
/**
* Revert a transaction for this database client.
* If there is no transaction in progress, this method does nothing.
* NB. You must not execute an SQL statement
* which would commit or rollback a transaction directly ... use
* only this method or the -rollback method.
*
* Where possible, consider using the [SQLTransaction] class rather
* than calling -begin -commit or -rollback yourself.
*
*/
- (void) rollback;
/**
* Set the database host/name for this object.
* This is called automatically to configure the connection ...
* you normally shouldn't need to call it yourself.
*/
- (void) setDatabase: (NSString*)s;
/**
* Set the database reference name for this object. This is used to
* differentiate between multiple connections to the database.
* This is called automatically to configure the connection ...
* you normally shouldn't need to call it yourself.
* NB. attempts to change the name of an instance to that of an existing
* instance are ignored.
*/
- (void) setName: (NSString*)s;
/**
* Set the database password for this object.
* This is called automatically to configure the connection ...
* you normally shouldn't need to call it yourself.
*/
- (void) setPassword: (NSString*)s;
/** Sets an internal flag to indicate whether leading and trailing white
* space characters should be removed from values retrieved from the
* database by the receiver.
*/
- (void) setShouldTrim: (BOOL)aFlag;
/**
* Set the database user for this object.
* This is called automatically to configure the connection ...
* you normally shouldn't need to call it yourself.
*/
- (void) setUser: (NSString*)s;
/**
* Calls -backendExecute: in a safe manner.
* Handles locking.
* Maintains -lastOperation date.
* Returns the result of -backendExecute:
*/
- (NSInteger) simpleExecute: (NSArray*)info;
/**
* Calls -simpleQuery:recordType:listType: with the default record class
* and default array class.
*/
- (NSMutableArray*) simpleQuery: (NSString*)stmt;
/**
* Calls -backendQuery:recordType:listType: in a safe manner.
* Handles locking.
* Maintains -lastOperation date.
* The value of rtype must respond to the
* [SQLRecord+newWithValues:keys:count:] method.
* If rtype is nil then the [SQLRecord] class is used.
* The value of ltype must respond to the [NSObject+alloc] method to produce
* a container which must repond to the [NSMutableArray-initWithCapacity:]
* method to initialise itsself and the [NSMutableArray-addObject:] method
* to add records to the list.
* If ltype is nil then the [NSMutableArray] class is used.
* This library provides a few helper classes to provide alternative
* values for rtype and ltype.
*/
- (NSMutableArray*) simpleQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype;
/**
* Return the database user for this instance (or nil).
*/
- (NSString*) user;
@end
/**
* This category contains the methods which a subclass must
* override to provide a working instance, and helper methods for the
* backend implementations.
* Application programmers should not call the backend
* methods directly.
* When subclassing to produce a backend driver bundle, please be
* aware that the subclass must NOT introduce additional
* instance variables. Instead the extra instance variable
* is provided for use as a pointer to subclass specific data.
*
*/
@interface SQLClient(Subclass)
/**
* Attempts to establish a connection to the database server.
* Returns a flag to indicate whether the connection has been established.
* If a connection was already established, returns YES and does nothing.
* You should not need to use this method normally, as it is called for you
* automatically when necessary.
* Subclasses must implement this method to establish a
* connection to the database server process (and initialise the
* extra instance variable if necessary), setting the
* connected instance variable to indicate the state of the object.
*
* This method must call +purgeConnections: to ensure that there is a
* free slot for the new connection.
*
* Application code must not call this method directly, it is
* for internal use only. The -connect method calls this method if the
* connected instance variable is NO.
*
*/
- (BOOL) backendConnect;
/**
* Disconnect from the database unless already disconnected.
* This method is called automatically when the receiver is deallocated
* or reconfigured, and may also be called automatically when there are
* too many database connections active.
*
* If the receiver is an instance of a subclass which uses the
* extra instance variable, it must clear that
* variable in the -backendDisconnect method, because a reconfiguration
* may cause the class of the receiver to change.
*
* This method must set the connected instance variable to NO.
*
* Application code must not call this method directly, it is
* for internal use only. The -disconnect method calls this method if the
* connected instance variable is YES.
*
*/
- (void) backendDisconnect;
/**
* Perform arbitrary operation which does not return any value.
* This method has a single argument, an array containing the string
* representing the statement to be executed as its first object, and an
* optional sequence of data objects following it.
*
* [db backendExecute: [NSArray arrayWithObject:
* @"UPDATE MyTable SET Name = 'The name' WHERE ID = 123"]];
*
* The backend implementation is required to perform the SQL statement
* using the supplied NSData objects at the points in the statement
* marked by the '?'''?'
sequence. The marker saequences are
* inserted into the statement at an earlier stage by the -execute:,...
* and -execute:with: methods.
*
* Callers should lock the instance using the lock
* instance variable for the duration of the operation, and unlock
* it afterwards.
*
* NB. callers (other than the -begin, -commit, and -rollback methods)
* should not pass any statement to this method which would cause a
* transaction to begin or end.
*
* Application code must not call this method directly, it is
* for internal use only.
*
* Where the database backend support it, this method returns the count of
* the number of rows to which the operation applied. Otherwise this
* returns -1.
*
*/
- (NSInteger) backendExecute: (NSArray*)info;
/**
* Perform arbitrary query which returns values.
*
*
* result = [db backendQuery: @"SELECT Name FROM Table"
* recordType: [SQLRecord class]]
* listType: [NSMutableArray class]];
*
* Upon error, an exception is raised.
*
* The query returns an array of records (each of which is represented
* by an SQLRecord object).
*
* Each SQLRecord object contains one or more fields, in the order in
* which they occurred in the query. Fields may also be retrieved by name.
*
* NULL field items are returned as NSNull objects.
*
* Callers should lock the instance using the lock
* instance variable for the duration of the operation, and unlock
* it afterwards.
*
* Application code must not call this method directly, it is
* for internal use only.
*
* The rtype argument specifies an object to be used to
* create the records produced by the query.
* This is provided as a performance optimisation when you want to store
* data directly into a special class of your own.
* The object must respond to the [SQLRecord +newWithValues:keys:count:]
* method to produce a new record initialised with the supplied data.
*
* The ltype argument specifies an object to be used to create objects to
* store the records produced by the query.
* The should be a subclass of NSMutableArray. It must at least
* implement the [NSObject+alloc] method to create an instnce to store
* records. The instance must implement [NSMutableArray-initWithCapacity:]
* to initialise itsself and [NSMutableArray-addObject:] to allow the
* backend to add records to it.
* For caching to work, it must be possible to make a mutable copy of the
* instance using the mutableCopy method.
*
*/
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype;
/**
* Calls -backendQuery:recordType:listType: with the default record class
* and array class.
*/
- (NSMutableArray*) backendQuery: (NSString*)stmt;
/**
* Called to enable asynchronous notification of database events using the
* specified name (which must be a valid identifier consisting of ascii
* letters, digits, and underscore characters, starting with a letter).
* Names are not case sensitive (so AAA is the same as aaa).
* Repeated calls to list on the same name should be treated as a single
* call.
* The backend is responsible for implicitly unlistening when a connection
* is closed.
* There is a default implementation which does nothing ... for backends
* which don't support asynchronous notifications.
* If a backend does support asynchronous notifications,
* it should do so by posting NSNotification instances to
* [NSNotificationCenter defaultCenter] using the SQLClient instance as
* the notification object and supplying any payload as a string using
* the 'Payload' key in the NSNotification userInfo dictionary.
* The userInfo dictionary should also contain a boolean (NSNumber) value,
* using the 'Local' key, to indicate whether the notification was sent by
* the current SQLClient instance or by some other client/
*/
- (void) backendListen: (NSString*)name;
/**
* The backend should implement this to send asynchronous notifications
* to anything listening for them. The name of the notification is an
* SQL identifier used for listening for the asynchronous data.
* The payload string may be nil if no additional information is
* needed in the notification.
*/
- (void) backendNotify: (NSString*)name payload: (NSString*)more;
/**
* Called to disable asynchronous notification of database events using the
* specified name. This has no effect if the name has not been used in an
* earlier call to -backendListen:, or if the name has already been
* unlistened since the last call to listen. on it.
* There is a default implementation which does nothing ... for backends
* which don't support asynchronous notifications.
*/
- (void) backendUnlisten: (NSString*)name;
/**
* This method is only for the use of the
* -insertBLOBs:intoStatement:length:withMarker:length:giving:
* method.
* Subclasses which need to insert binary data into a statement
* must implement this method to copy the escaped data into place
* and return the number of bytes actually copied.
*/
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf;
/**
* This method is a convenience method provided for subclasses which need
* to insert escaped binary data into an SQL statement before sending the
* statement to a backend server process. This method makes use of the
* -copyEscapedBLOB:into: and -lengthOfEscapedBLOB: methods, which
* must be implemented by the subclass.
*
* The blobs array is an array containing the original SQL statement
* string (unused by this method) followed by the data items to be inserted.
*
* The statement and sLength arguments specify the datastream to be
* copied and into which the BLOBs are to be inserted.
*
* The marker and mLength arguments specify the sequence of marker bytes
* in the statement which indicate a position for insertion of an escaped BLOB.
*
* The method returns either the original statement or a copy containing
* the escaped BLOBs. The length of the returned data is stored in result.
*
*/
- (const void*) insertBLOBs: (NSArray*)blobs
intoStatement: (const void*)statement
length: (unsigned)sLength
withMarker: (const void*)marker
length: (unsigned)mLength
giving: (unsigned*)result;
/**
* This method is only for the use of the
* -insertBLOBs:intoStatement:length:withMarker:length:giving:
* method.
* Subclasses which need to insert binary data into a statement
* must implement this method to return the length of the escaped
* bytestream which will be inserted.
*/
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob;
@end
/**
* This category contains methods for asynchronous notification of
* events via the database (for those database backends which support
* it: currently only PostgreSQL).
*/
@interface SQLClient (Notifications)
/** Adds anObserver to receive notifications when the backend database
* server sends an asynchronous event identified by the specified name
* (which must be a valid database identifier).
* When a notification (NSNotification instance) is received by the method
* specified by aSelector, its object will be the SQLClient
* instance to which anObserver was added and its userInfo dictionary
* will contain the key 'Local' and possibly the key 'Payload'.
* If the 'Local' value is the boolean YES, the notification originated
* as an action by this SQLClient instance.
* If the 'Payload' value is not nil, then it is a string providing extra
* information about the notification.
* NB. At the point when the observer is notified about an event the
* database client object will be locked and may not be used to query
* or modify the database (typically a database query will already be
* in progress). The method handling the notification must therefore
* handle any database operations in a later timeout.
*/
- (void) addObserver: (id)anObserver
selector: (SEL)aSelector
name: (NSString*)name;
/** Posts a notification via the database. The name is an SQL identifier
* (for which observers may have registered) and the extra payload
* information may be nil if not required.
*/
- (void) postNotificationName: (NSString*)name payload: (NSString*)more;
/** Removes anObserver as an observer for asynchronous notifications from
* the database server. If name is omitted, the observer will be removed
* for all names.
*/
- (void) removeObserver: (id)anObserver name: (NSString*)name;
@end
/**
* This category contains convenience methods including those for
* frequently performed database operations ... message logging etc.
*/
@interface SQLClient (Convenience)
/**
* Returns a transaction object configured to handle batching and
* execute part of a batch of statements if execution of the whole
* using the [SQLTransaction-executeBatch] method fails.
* If stopOnFailure is YES than execution of the transaction will
* stop with the first statement to fail, otherwise it will execute
* all the statements it can, skipping any failed statements.
*/
- (SQLTransaction*) batch: (BOOL)stopOnFailure;
/**
* Convenience method to deal with the results of a query converting the
* normal array of records into an array of record columns. Each column
* in the array is an array containing all the values from that column.
*/
- (NSMutableArray*) columns: (NSMutableArray*)records;
/**
* Executes a query (like the -query:,... method) and checks the result
* (raising an exception if the query did not contain a single record)
* and returns the resulting record.
*/
- (SQLRecord*) queryRecord: (NSString*)stmt,...;
/**
* Executes a query (like the -query:,... method) and checks the result.
* Raises an exception if the query did not contain a single record, or
* if the record did not contain a single field.
* Returns the resulting field as a string.
*/
- (NSString*) queryString: (NSString*)stmt,...;
/**
* Convenience method to deal with the results of a query where each
* record contains a single field ... it converts the array of records
* returned by the query to an array containing the fields.
* NB. This does not check that the contents of the records array are
* actually instances of [SQLRecord], so you must ensure you don't
* call it more than once on the same array (something that may happen
* if you retrieve the array using a cache based query).
*/
- (void) singletons: (NSMutableArray*)records;
/**
* Creates and returns an autoreleased SQLTransaction instance which will
* use the receiver as the database connection to perform transactions.
*/
- (SQLTransaction*) transaction;
@end
/**
* This category porovides basic methods for logging debug information.
*/
@interface SQLClient (Logging)
/**
* Return the class-wide debugging level, which is inherited by all
* newly created instances.
*/
+ (unsigned int) debugging;
/**
* Return the class-wide duration logging threshold, which is inherited by all
* newly created instances.
*/
+ (NSTimeInterval) durationLogging;
/**
* Set the debugging level to be inherited by all new instances.
* See [SQLClient(Logging)-setDebugging:]
* for controlling an individual instance of the class.
*/
+ (void) setDebugging: (unsigned int)level;
/**
* Set the duration logging threshold to be inherited by new instances.
* See [SQLClient(Logging)-setDurationLogging:]
* for controlling an individual instance of the class.
*/
+ (void) setDurationLogging: (NSTimeInterval)threshold;
/**
* The default implementation calls NSLogv to log a debug message.
* Override this in a category to provide more sophisticated logging.
* Do NOT override with code which can be slow or which calls (directly
* or indirectly) any SQLCLient methods, since this method will be used
* inside locked regions of the SQLClient code and you could cause
* deadlocks or long delays to other threads using the class.
*/
- (void) debug: (NSString*)fmt, ...;
/**
* Return the current debugging level.
* A level of zero (default) means that no debug output is produced,
* except for that concerned with logging the database transactions
* taking over a certain amount of time (see the -setDurationLogging: method).
*/
- (unsigned int) debugging;
/**
* Returns the threshold above which queries and statements taking a long
* time to execute are logged. A negative value (default) indicates that
* this logging is disabled. A value of zero means that all statements
* are logged.
*/
- (NSTimeInterval) durationLogging;
/**
* Set the debugging level of this instance ... overrides the default
* level inherited from the class.
*/
- (void) setDebugging: (unsigned int)level;
/**
* Set a threshold above which queries and statements taking a long
* time to execute are logged. A negative value (default) disables
* this logging. A value of zero logs all statements.
*/
- (void) setDurationLogging: (NSTimeInterval)threshold;
@end
/**
* This category provides methods for caching the results of queries
* in order to reduce the number of client-server trips and the database
* load produced by an application which needs update its information
* from the database frequently.
*/
@interface SQLClient (Caching)
/**
* Returns the cache used by the receiver for storing the results of
* requests made through it. Creates a new cache if necessary.
*/
- (GSCache*) cache;
/**
* Calls -cache:simpleQuery:recordType:listType: with the default
* record class, array class, and with a query string formed from
* stmt and the following values (if any).
*/
- (NSMutableArray*) cache: (int)seconds
query: (NSString*)stmt,...;
/**
* Calls -cache:simpleQuery:recordType:listType: with the default
* record class array class and with a query string formed from stmt
* and values.
*/
- (NSMutableArray*) cache: (int)seconds
query: (NSString*)stmt
with: (NSDictionary*)values;
/**
* Calls -cache:simpleQuery:recordType:listType: with the default
* record class and array class.
*/
- (NSMutableArray*) cache: (int)seconds simpleQuery: (NSString*)stmt;
/**
* If the result of the query is already cached and has not expired,
* return it. Otherwise, perform the query and cache the result
* giving it the specified lifetime in seconds.
* If seconds is negative, the query is performed irrespective of
* whether it is already cached, and its absolute value is used to
* set the lifetime of the results.
* If seconds is zero, the cache for this query is emptied.
* Handles locking.
* Maintains -lastOperation date.
* The value of rtype must respond to the
* [SQLRecord+newWithValues:keys:count:] method.
* If rtype is nil then the [SQLRecord] class is used.
* The value of ltype must respond to the [NSObject+alloc] method to produce
* a container which must repond to the [NSMutableArray-initWithCapacity:]
* method to initialise itsself and the [NSMutableArray-addObject:] method
* to add records to the list.
* If ltype is nil then the [NSMutableArray] class is used.
* The list produced by this argument is used as the return value of
* this method.
* If a cache thread has been set using the -setCacheThread: method, and the
* -cache:simpleQuery:recordType:listType: method is called from a
* thread other than the cache thread, then any query to retrieve
* uncached data will be performed in the cache thread, and for cached
* (but expired) data, the old (expired) results may be returned ...
* in which case an asynchronous query to update the cache will be
* executed as soon as possible in the cache thread.
*/
- (NSMutableArray*) cache: (int)seconds
simpleQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype;
/**
* Sets the cache to be used by the receiver for storing the results of
* requests made through it.
* If aCache is nil, the current cache is released, and a new cache will
* be automatically created as soon as there is a need to cache anything.
*/
- (void) setCache: (GSCache*)aCache;
/** Sets the thread to be used to retrieve data to populate the cache.
* All cached queries will be performed in this thread (if non-nil).
* The setting of a thread for the cache also implies that expired items in
* the cache may not be removed when they are queried from another thread,
* rather they can be kept (if they are not too old) and an
* asynchronous query to update them will be run on the cache thread.
* The rule is that, if the item's age is more than twice its nominal
* lifetime, it will be retrieved immediately, otherwise it will be
* retrieved asynchrnonously.
* Currently this may only be the main thread or nil. Any attempt to set
* another thread will use the main thread instead.
*/
- (void) setCacheThread: (NSThread*)aThread;
@end
/**
* The SQLTransaction transaction class provides a convenient mechanism
* for grouping together a series of SQL statements to be executed as a
* single transaction. It avoids the need for handling begin/commit,
* and should be as efficient as reasonably possible.
* You obtain an instance by calling [SQLClient-transaction], add SQL
* statements to it using the -add:,... and/or -add:with: methods, and
* then use the -execute method to perform all the statements as a
* single operation.
* Any exception is caught and re-raised in the -execute method after any
* tidying up to leave the database in a consistent state.
* NB. This class is not in itsself thread-safe, though the underlying
* database operations should be. If you have multiple threads, you
* should create multiple SQLTransaction instances, at least one per thread.
*/
@interface SQLTransaction : NSObject
{
SQLCLIENT_PRIVATE
SQLClient *_db;
NSMutableArray *_info;
unsigned _count;
BOOL _batch;
BOOL _stop;
}
/**
* Adds an SQL statement to the transaction. This is similar to
* [SQLClient-execute:,...] but does not cause any database operation
* until -execute is called, so it will not raise a database exception.
*/
- (void) add: (NSString*)stmt,...;
/**
* Adds an SQL statement to the transaction. This is similar to
* [SQLClient-execute:with:] but does not cause any database operation
* until -execute is called, so it will not raise a database exception.
*/
- (void) add: (NSString*)stmt with: (NSDictionary*)values;
/**
* Appends a copy of the other transaction to the receiver.
* This provides a convenient way of merging transactions which have been
* built by different code modules, in order to have them all executed
* together in a single operation (for efficiency etc).
* This does not alter the other transaction, so if the execution of
* a group of merged transactions fails, it is then possible to attempt
* to commit the individual transactions separately.
* NB. All transactions appended must be using the same database
* connection (SQLClient instance).
*/
- (void) append: (SQLTransaction*)other;
/**
* Make a copy of the receiver.
*/
- (id) copyWithZone: (NSZone*)z;
/**
* Returns the number of individual statements ond/r subsidiary transactions
* which have been added to the receiver. For a count of the total number
* of statements, use the -totalCount method.
*/
- (NSUInteger) count;
/**
* Returns the database client with which this instance operates.
* This client is retained by the transaction.
*/
- (SQLClient*) db;
/**
* Performs any statements added to the transaction as a single operation.
* If any problem occurs, an NSException is raised, but the database connection
* is left in a consistent state and a partially completed operation is
* rolled back.
*
* NB. If the database is not already in a transaction, this implicitly
* calls the -begin method to start the transaction before executing the
* statements.
* The method always commits the transaction, even if the transaction was
* begun earlier rather than in -execute.
* This behavior allows you to call [SQLClient-begin], then run one or more
* queries, build up a transaction based upon the query results, and then
* -execute that transaction, causing the entire process to be commited as
* a single transaction .
*
*/
- (void) execute;
/** Convenience method which calls
* -executeBatchReturningFailures:logExceptions: with
* a nil failures argument and exception logging off.
*/
- (unsigned) executeBatch;
/**
* This is similar to the -execute method, but may allow partial
* execution of the transaction if appropriate:
*
* If the transaction was created using the [SQLClient-batch:] method and
* the transaction as a whole fails, individual statements are retried.
* The stopOnFailure flag for the batch creation indicates whether the
* retries are stopped at the first statement to fail, or continue (skipping
* any failed statements).
*
* If the transaction has had transactions appended to it, those
* subsidiary transactions may succeed or fail atomically depending
* on their individual attributes.
*
* If the transaction was not created using [SQLClient-batch:], then
* calling this method is equivalent to calling the -execute method.
*
* If any statements/transactions in the batch fail, they are added to
* the transaction supplied in the failures parameter (if it's not nil)
* so that you can retry them later.
* NB. statements/transactions which are not executed at all (because the
* batch is set to stop on the first failure) are also added to
* the failures transaction.
*
* If the log argument is YES, then any exceptions encountered when
* executing the batch are logged using the [SQLClient-debug:,...] method,
* even if debug logging is not enabled with [SQLClient-setDebugging:].
*
* The method returns the number of statements which actually succeeded.
*/
- (unsigned) executeBatchReturningFailures: (SQLTransaction*)failures
logExceptions: (BOOL)log;
/**
* Insert trn at the index'th position in the receiver.
* The transaction trn must be non-empty and must use the same
* database client as the receiver.
*/
- (void) insertTransaction: (SQLTransaction*)trn atIndex: (unsigned)index;
/** Remove the index'th transaction or statement from the receiver.
*/
- (void) removeTransactionAtIndex: (unsigned)index;
/**
* Resets the transaction, removing all previously added statements.
* This allows the transaction object to be re-used for multiple
* transactions.
*/
- (void) reset;
/**
* Returns the total count of statements in this transaction including
* those in any subsidiary transactions. For a count of the statements
* and/or transactions directly added to the receiver, use the -count method.
*/
- (unsigned) totalCount;
/** Return an autoreleased copy of the index'th transaction or statement
* added to the receiver.
* Since the returned transaction contains a copy of the statement/transaction
* in the receiver, you can modify it without effecting the original.
*/
- (SQLTransaction*) transactionAtIndex: (unsigned)index;
@end
/* A helper for building a dictionary from an SQL query which returns
* key-value pairs (you can subclass it to handle other records).
* You create an instance of this class, and pass it as both the
* record and list class arguments of the low level SQLClient query.
* The query (which must return a number of records, each with two fields)
* will result in a mutable dictionary being built, with dictionary keys
* being the first field from each record and dictionary values being the
* second field of each record.
* You may use the same instance for more than one query, but a second query
* will replace the content dictionary produced by the first.
* If you want to handle records containing more than two values, you
* must create a subclass which overrides the -newWithValues:keys:count:
* method to create the record objects and add them to the content
* dictionary.
* See [SQLClient-simpleQuery:recordType:listType:] also.
* NB. When this class is used, the query will actually return an
* [NSMutableDictionary] instance rather than an [NSMutableArray] of
* [SQLRecord] objects.
*/
@interface SQLDictionaryBuilder : NSObject
{
NSMutableDictionary *content;
}
/** No need to do anything ... the object will already have been added by
* the -newWithValues:keys:count: method.
*/
- (void) addObject: (id)anObject;
/** When a container is supposed to be allocated, we just return the
* receiver (which will then quietly ignore -addObject: messages).
*/
- (id) alloc;
/** Returns the content dictionary for the receiver.
*/
- (NSMutableDictionary*) content;
/** Creates a new content dictionary ... this method will be called
* automatically by the SQLClient object when it performs a query,
* so there is no need to call it at any other time.
*/
- (id) initWithCapacity: (NSUInteger)capacity;
/** Makes a mutable copy of the content dictionary (called when a caching
* query uses this helper to produce the cached collection).
*/
- (id) mutableCopyWithZone: (NSZone*)aZone;
/** This is the main workhorse of the class ... it is called once for
* every record read from the database, and is responsible for adding
* that record to the content dictionary. The default implementation,
* instead of creating an object to hold the supplied record data,
* uses the two fields from the record as a key-value pair to add to
* the content dictionary, and returns nil as the record object.
* It's OK to return a nil object since we ignore the -addObject:
* argument.
*/
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count;
@end
/* A helper for building a counted set from an SQL query which returns
* individual values (you can subclass it to handle other records).
* You create an instance of this class, and pass it as both the
* record and list class arguments of the low level SQLClient query.
* The query (which must return a number of records, each with one field)
* will result in a counted set being built and a record of the number of
* added objects being kept.
* You may use the same instance for more than one query, but a second query
* will replace the content set produced by the first.
* If you want to handle records containing more than one value, you
* must create a subclass which overrides the -newWithValues:keys:count:
* method to create the record objects and add them to the content
* set, and increment the counter.
* See [SQLClient-simpleQuery:recordType:listType:] also.
* NB. When this class is used, the query will actually return an
* [NSCountedSet] instance rather than an [NSMutableArray] of
* [SQLRecord] objects.
*/
@interface SQLSetBuilder : NSObject
{
NSCountedSet *content;
NSUInteger added;
}
/** Returns the number of objects actually added to the counted set.
*/
- (NSUInteger) added;
/** No need to do anything ... the object will already have been added by
* the -newWithValues:keys:count: method.
*/
- (void) addObject: (id)anObject;
/** When a container is supposed to be allocated, we just return the
* receiver (which will then quietly ignore -addObject: messages).
*/
- (id) alloc;
/** Returns the counted set for the receiver.
*/
- (NSCountedSet*) content;
/** Creates a new content set ... this method will be called
* automatically by the SQLClient object when it performs a query,
* so there is no need to call it at any other time.
*/
- (id) initWithCapacity: (NSUInteger)capacity;
/** Makes a mutable copy of the content dictionary (called when a caching
* query uses this helper to produce the cached collection).
*/
- (id) mutableCopyWithZone: (NSZone*)aZone;
/** This is the main workhorse of the class ... it is called once for
* every record read from the database, and is responsible for adding
* that record to the content set. The default implementation,
* instead of creating an object to hold the supplied record data,
* uses the singe field from the record to add to
* the content set, and returns nil as the record object.
* It's OK to return a nil object since we ignore the -addObject:
* argument.
*/
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count;
@end
/* A helper for building a collection of singletons from an SQL query
* which returns singleton values.
* You create an instance of this class, and pass it as the record
* class argument of the low level SQLClient query.
* The query (which must return a number of records, each with one field)
* will result in the singleton values being stored in the list class.
* See [SQLClient-simpleQuery:recordType:listType:] also.
*/
@interface SQLSingletonBuilder : NSObject
- (id) newWithValues: (id*)values
keys: (NSString**)keys
count: (unsigned int)count;
@end
#endif
SQLClient-1.7.3/Postgres.m 0000664 0000765 0000765 00000055754 12341127151 015217 0 ustar brains99 brains99 /* -*-objc-*- */
/** Implementation of SQLClientPostgres for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald
Date: April 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 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: 2014-05-27 16:25:29 +0100 (Tue, 27 May 2014) $ $Revision: 37914 $
*/
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#import
#include "config.h"
#define SQLCLIENT_PRIVATE @public
#include "SQLClient.h"
#include
@interface SQLClientPostgres : SQLClient
@end
@interface SQLClientPostgres(Embedded)
- (NSData*) dataFromBLOB: (const char *)blob;
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l;
@end
typedef struct {
PGconn *_connection;
BOOL _escapeStrings; /* Can we use E'...' syntax? */
int _backendPID;
} ConnectionInfo;
#define cInfo ((ConnectionInfo*)(self->extra))
#define backendPID (cInfo->_backendPID)
#define connection (cInfo->_connection)
#define escapeStrings (cInfo->_escapeStrings)
static NSDate *future = nil;
static NSNull *null = nil;
@implementation SQLClientPostgres
+ (void) initialize
{
if (future == nil)
{
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
[future retain];
null = [NSNull null];
[null retain];
}
}
static NSString*
connectQuote(NSString *str)
{
NSMutableString *m;
m = [str mutableCopy];
[m replaceString: @"\\" withString: @"\\\\"];
[m replaceString: @"'" withString: @"\\'"];
[m replaceCharactersInRange: NSMakeRange(0, 0) withString: @"'"];
[m appendString: @"'"];
return [m autorelease];
}
- (BOOL) backendConnect
{
if (extra == 0)
{
extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(ConnectionInfo));
memset(extra, '\0', sizeof(ConnectionInfo));
}
if (connection == 0)
{
connected = NO;
if ([self database] != nil)
{
NSString *host = nil;
NSString *port = nil;
NSString *dbase = [self database];
NSString *str;
NSRange r;
NSMutableString *m;
[[self class] purgeConnections: nil];
r = [dbase rangeOfString: @"@"];
if (r.length > 0)
{
host = [dbase substringFromIndex: NSMaxRange(r)];
dbase = [dbase substringToIndex: r.location];
r = [host rangeOfString: @":"];
if (r.length > 0)
{
port = [host substringFromIndex: NSMaxRange(r)];
host = [host substringToIndex: r.location];
}
}
m = [NSMutableString stringWithCapacity: 156];
[m appendString: @"dbname="];
[m appendString: connectQuote(dbase)];
str = connectQuote(host);
if (str != nil)
{
unichar c = [str characterAtIndex: 1];
if (c >= '0' && c <= '9')
{
[m appendString: @" hostaddr="]; // Numeric IP
}
else
{
[m appendString: @" host="]; // Domain name
}
[m appendString: str];
}
str = connectQuote(port);
if (str != nil)
{
[m appendString: @" port="];
[m appendString: str];
}
str = connectQuote([self user]);
if (str != nil)
{
[m appendString: @" user="];
[m appendString: str];
}
str = connectQuote([self password]);
if (str != nil)
{
[m appendString: @" password="];
[m appendString: str];
}
if ([self debugging] > 0)
{
[self debug: @"Connect to '%@' as %@", m, [self name]];
}
connection = PQconnectdb([m UTF8String]);
if (PQstatus(connection) != CONNECTION_OK)
{
[self debug: @"Error connecting to '%@' (%@) - %s",
[self name], m, PQerrorMessage(connection)];
PQfinish(connection);
connection = 0;
}
else if (PQsetClientEncoding(connection, "UTF-8") < 0)
{
[self debug: @"Error setting UTF-8 with '%@' (%@) - %s",
[self name], m, PQerrorMessage(connection)];
PQfinish(connection);
connection = 0;
}
else
{
const char *p;
p = PQparameterStatus(connection, "standard_conforming_strings");
if (p != 0)
{
escapeStrings = YES;
}
else
{
escapeStrings = NO;
}
backendPID = PQbackendPID(connection);
connected = YES;
if ([self debugging] > 0)
{
[self debug: @"Connected to '%@'", [self name]];
}
}
}
else
{
[self debug:
@"Connect to '%@' with no user/password/database configured",
[self name]];
}
}
return connected;
}
- (void) backendDisconnect
{
if (extra != 0 && connection != 0)
{
NS_DURING
{
if ([self isInTransaction] == YES)
{
[self rollback];
}
if ([self debugging] > 0)
{
[self debug: @"Disconnecting client %@", [self clientName]];
}
PQfinish(connection);
connection = 0;
if ([self debugging] > 0)
{
[self debug: @"Disconnected client %@", [self clientName]];
}
}
NS_HANDLER
{
connection = 0;
[self debug: @"Error disconnecting from database (%@): %@",
[self clientName], localException];
}
NS_ENDHANDLER
connected = NO;
}
}
- (void) _checkNotifications
{
static NSNotificationCenter *nc;
PGnotify *notify;
while ((notify = PQnotifies(connection)) != 0)
{
NS_DURING
{
NSNotification *n;
NSMutableDictionary *userInfo;
NSString *name;
name = [[NSString alloc] initWithUTF8String: notify->relname];
userInfo = [[NSMutableDictionary alloc] initWithCapacity: 2];
if (0 != notify->extra)
{
NSString *payload;
payload = [[NSString alloc] initWithUTF8String: notify->extra];
if (nil != payload)
{
[userInfo setObject: payload forKey: @"Payload"];
[payload release];
}
}
if (notify->be_pid == backendPID)
{
static NSNumber *nY = nil;
if (nil == nY)
{
nY = [[NSNumber numberWithBool: YES] retain];
}
[userInfo setObject: nY forKey: @"Local"];
}
else
{
static NSNumber *nN = nil;
if (nil == nN)
{
nN = [[NSNumber numberWithBool: NO] retain];
}
[userInfo setObject: nN forKey: @"Local"];
}
n = [NSNotification notificationWithName: name
object: self
userInfo: (NSDictionary*)userInfo];
[name release];
[userInfo release];
if (nil == nc)
{
nc = [[NSNotificationCenter defaultCenter] retain];
}
[nc postNotification: n];
}
NS_HANDLER
{
NSLog(@"Problem handling asynchronous notification: %@",
localException);
}
NS_ENDHANDLER
PQfreemem(notify);
}
}
- (NSInteger) backendExecute: (NSArray*)info
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSInteger rowCount = -1;
PGresult *result = 0;
NSString *stmt = [info objectAtIndex: 0];
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
NS_DURING
{
const char *statement;
const char *tuples;
unsigned length;
/*
* 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 = PQexec(connection, statement);
if (0 == result || PQresultStatus(result) == PGRES_FATAL_ERROR)
{
NSString *str;
const char *cstr;
if (0 == result)
{
cstr = PQerrorMessage(connection);
}
else
{
cstr = PQresultErrorMessage(result);
}
str = [NSString stringWithUTF8String: cstr];
if (nil == str)
{
str = [NSString stringWithCString: cstr];
}
[self disconnect];
[NSException raise: SQLException format: @"Error executing %@: %@",
stmt, str];
}
if (PQresultStatus(result) != PGRES_COMMAND_OK
&& PQresultStatus(result) != PGRES_TUPLES_OK)
{
[NSException raise: SQLException format: @"Error executing %@: %s",
stmt, PQresultErrorMessage(result)];
}
tuples = PQcmdTuples(result);
if (0 != tuples)
{
rowCount = atol(tuples);
}
}
NS_HANDLER
{
NSString *n = [localException name];
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
if (result != 0)
{
PQclear(result);
}
[localException retain];
[arp release];
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER
if (result != 0)
{
PQclear(result);
}
[self _checkNotifications];
[arp release];
return rowCount;
}
- (void) backendListen: (NSString*)name
{
[self execute: @"LISTEN ", name, nil];
}
- (void) backendNotify: (NSString*)name payload: (NSString*)more
{
if (nil == more)
{
[self execute: @"NOTIFY ", name, nil];
}
else
{
[self execute: @"NOTIFY ", name, @",", [self quote: more], nil];
}
}
static unsigned int trim(char *str)
{
char *start = str;
while (isspace(*str))
{
str++;
}
if (str != start)
{
strcpy(start, str);
}
str = start;
while (*str != '\0')
{
str++;
}
while (str > start && isspace(str[-1]))
{
*--str = '\0';
}
return (str - start);
}
- (NSMutableArray*) backendQuery: (NSString*)stmt
recordType: (id)rtype
listType: (id)ltype
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
PGresult *result = 0;
NSMutableArray *records = nil;
if ([stmt length] == 0)
{
[arp release];
[NSException raise: NSInternalInconsistencyException
format: @"Statement produced null string"];
}
NS_DURING
{
char *statement;
/*
* 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 = PQexec(connection, statement);
if (0 == result || PQresultStatus(result) == PGRES_FATAL_ERROR)
{
NSString *str;
const char *cstr;
if (0 == result)
{
cstr = PQerrorMessage(connection);
}
else
{
cstr = PQresultErrorMessage(result);
}
str = [NSString stringWithUTF8String: cstr];
if (nil == str)
{
str = [NSString stringWithCString: cstr];
}
[self disconnect];
[NSException raise: SQLException format: @"Error executing %@: %@",
stmt, str];
}
if (PQresultStatus(result) == PGRES_TUPLES_OK)
{
int recordCount = PQntuples(result);
int fieldCount = PQnfields(result);
NSString *keys[fieldCount];
int types[fieldCount];
int modifiers[fieldCount];
int formats[fieldCount];
int i;
for (i = 0; i < fieldCount; i++)
{
keys[i] = [NSString stringWithUTF8String: PQfname(result, i)];
types[i] = PQftype(result, i);
modifiers[i] = PQfmod(result, i);
formats[i] = PQfformat(result, i);
}
records = [[ltype alloc] initWithCapacity: recordCount];
for (i = 0; i < recordCount; i++)
{
SQLRecord *record;
id values[fieldCount];
int j;
for (j = 0; j < fieldCount; j++)
{
id v = null;
if (PQgetisnull(result, i, j) == 0)
{
char *p = PQgetvalue(result, i, j);
int size = PQgetlength(result, i, j);
if ([self debugging] > 1)
{
[self debug: @"%@ type:%d mod:%d size: %d\n",
keys[j], types[j], modifiers[j], size];
}
if (formats[j] == 0) // Text
{
switch (types[j])
{
case 1082: // Date
case 1083: // Time
case 1114: // Timestamp without time zone.
case 1184: // Timestamp with time zone.
v = [self dbToDateFromBuffer: p
length: trim(p)];
break;
case 16: // BOOL
if (*p == 't')
{
v = @"YES";
}
else
{
v = @"NO";
}
break;
case 17: // BYTEA
v = [self dataFromBLOB: p];
break;
case 18: // "char"
v = [NSString stringWithUTF8String: p];
break;
case 20: // INT8
case 21: // INT2
case 23: // INT4
trim(p);
v = [NSString stringWithUTF8String: p];
break;
case 25: // TEXT
default:
if (YES == _shouldTrim)
{
trim(p);
}
v = [NSString stringWithUTF8String: p];
break;
}
}
else // Binary
{
NSLog(@"Binary data treated as NSNull "
@"in %@ type:%d mod:%d size:%d\n",
keys[j], types[j], modifiers[j], size);
}
}
values[j] = v;
}
record = [rtype newWithValues: values
keys: keys
count: fieldCount];
[records addObject: record];
[record release];
}
}
else
{
[NSException raise: SQLException format: @"Error executing %@: %s",
stmt, PQresultErrorMessage(result)];
}
}
NS_HANDLER
{
NSString *n = [localException name];
if ([n isEqual: SQLConnectionException] == YES)
{
[self disconnect];
}
if (result != 0)
{
PQclear(result);
}
[records release];
records = nil;
[localException retain];
[arp release];
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER
[arp release];
if (result != 0)
{
PQclear(result);
}
[self _checkNotifications];
return [records autorelease];
}
- (void) backendUnlisten: (NSString*)name
{
[self execute: @"UNLISTEN ", name, nil];
}
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
{
const unsigned char *src = [blob bytes];
unsigned sLen = [blob length];
unsigned char *ptr = (unsigned char*)buf;
unsigned length = 0;
unsigned i;
if (YES == escapeStrings)
{
ptr[length++] = 'E';
}
ptr[length++] = '\'';
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126 || c == '\'')
{
ptr[length] = '\\';
ptr[length+1] = '\\';
ptr[length + 4] = (c & 7) + '0';
c >>= 3;
ptr[length + 3] = (c & 7) + '0';
c >>= 3;
ptr[length + 2] = (c & 7) + '0';
length += 5;
}
else if (c == '\\')
{
ptr[length++] = '\\';
ptr[length++] = '\\';
ptr[length++] = '\\';
ptr[length++] = '\\';
}
else
{
ptr[length++] = c;
}
}
ptr[length++] = '\'';
return length;
}
- (unsigned) lengthOfEscapedBLOB: (NSData*)blob
{
unsigned int sLen = [blob length];
unsigned char *src = (unsigned char*)[blob bytes];
unsigned int length = sLen + 2;
unsigned int i;
if (YES == escapeStrings)
{
length++; // Allow for leading 'E'
}
for (i = 0; i < sLen; i++)
{
unsigned char c = src[i];
if (c < 32 || c > 126 || c == '\'')
{
length += 4;
}
else if (c == '\\')
{
length += 3;
}
}
return length;
}
- (NSData *) dataFromBLOB: (const char *)blob
{
NSMutableData *md;
unsigned sLen = strlen(blob == 0 ? "" : blob);
unsigned dLen = 0;
unsigned char *dst;
unsigned i;
if (sLen > 1 && '\\' == blob[0] && 'x' == blob[1])
{
dLen = (sLen - 2) / 2;
dst = (unsigned char*)NSAllocateCollectable(dLen, 0);
md = [NSMutableData dataWithBytesNoCopy: dst length: dLen];
dLen = 0;
for (i = 2; i < sLen; i += 2)
{
unsigned hi = blob[i];
unsigned lo = blob[i + 1];
hi = (hi > '9') ? (hi - 'a' + 10) : (hi - '0');
lo = (lo > '9') ? (lo - 'a' + 10) : (lo - '0');
dst[dLen++] = (hi << 4) + lo;
}
}
else
{
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
dLen++;
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
i += 2; // Skip 2 digits octal
}
}
}
dst = (unsigned char*)NSAllocateCollectable(i, dLen);
md = [NSMutableData dataWithBytesNoCopy: dst length: dLen];
dLen = 0;
for (i = 0; i < sLen; i++)
{
unsigned c = blob[i];
if (c == '\\')
{
c = blob[++i];
if (c != '\\')
{
c = c - '0';
c <<= 3;
c += blob[++i] - '0';
c <<= 3;
c += blob[++i] - '0';
}
}
dst[dLen++] = c;
}
}
return md;
}
- (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;
memcpy(buf, b, l);
b = buf;
/*
* Find end of string.
*/
for (i = 0; i < l; i++)
{
if (b[i] == '\0')
{
l = i;
break;
}
}
while (l > 0 && isspace(b[l-1]))
{
l--;
}
b[l] = '\0';
if (l == 10)
{
s = [NSString stringWithUTF8String: b];
return [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d"
locale: nil];
}
i = l;
/* Convert +/-HH:SS timezone to +/-HHSS
*/
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
{
b[i-3] = b[i-2];
b[i-2] = b[i-1];
b[--i] = '\0';
}
while (i-- > 0)
{
if (b[i] == '+' || b[i] == '-')
{
break;
}
if (b[i] == ':' || b[i] == ' ')
{
i = 0;
break; /* No time zone found */
}
}
if (i == 0)
{
e = l;
}
else
{
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';
}
/*
* Ensure we have a four digit timezone value.
*/
if (isdigit(b[i+1]) && isdigit(b[i+2]))
{
if (b[i+3] == '\0')
{
// Two digit time zone ... append zero minutes
b[l++] = '0';
b[l++] = '0';
b[l] = '\0';
}
else if (b[i+3] == ':')
{
// Zone with colon before minutes ... remove it
b[i+3] = b[i+4];
b[i+4] = b[i+5];
b[--l] = '\0';
}
}
}
/* kludge for timestamps with fractional second information.
* Force it to 3 digit millisecond */
while (i-- > 0)
{
if (b[i] == '.')
{
milliseconds = YES;
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+3], &b[i], e-i);
l += 3;
memcpy(&b[i], "000", 3);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+2], &b[i], e-i);
l += 2;
memcpy(&b[i], "00", 2);
}
i++;
if (!isdigit(b[i]))
{
memmove(&b[i+1], &b[i], e-i);
l += 1;
memcpy(&b[i], "0", 1);
}
i++;
break;
}
}
if (i > 0 && i < e)
{
memmove(&b[i], &b[e], l - e);
l -= (e - i);
}
b[l] = '\0';
if (l == 0)
{
return nil;
}
s = [NSString stringWithUTF8String: b];
if (YES == timezone)
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
locale: nil];
}
}
else
{
if (milliseconds == YES)
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
locale: nil];
}
else
{
d = [NSCalendarDate dateWithString: s
calendarFormat: @"%Y-%m-%d %H:%M:%S"
locale: nil];
}
}
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
return d;
}
- (void) dealloc
{
if (extra != 0)
{
[self disconnect];
NSZoneFree(NSDefaultMallocZone(), extra);
}
[super dealloc];
}
- (NSString*) quoteString: (NSString *)s
{
NSData *d = [s dataUsingEncoding: NSUTF8StringEncoding];
unsigned l = [d length];
unsigned char *to = NSZoneMalloc(NSDefaultMallocZone(), (l * 2) + 3);
#ifdef HAVE_PQESCAPESTRINGCONN
int err;
[self connect];
l = PQescapeStringConn(connection, (char*)(to + 1), [d bytes], l, &err);
#else
l = PQescapeString(to + 1, [d bytes], l);
#endif
to[0] = '\'';
to[l + 1] = '\'';
s = [[NSString alloc] initWithBytesNoCopy: to
length: l + 2
encoding: NSUTF8StringEncoding
freeWhenDone: YES];
return [s autorelease];
}
@end
SQLClient-1.7.3/ChangeLog 0000664 0000765 0000765 00000114432 12341126673 015002 0 ustar brains99 brains99 2014-05-27 Richard Frith-Macdonald
* SQLClient.h: Warn about not using the database inside a
notification handler.
* Postgres.m: Add locking around database operations caused
by asynchronous arrival of a notification.
* GNUmakefile: new subminor version for bugfix release
* Version 1.7.3: released
2014-05-19 Richard Frith-Macdonald
* SQLClient.m: More locking to try to protect all access to the
database connection.
* GNUmakefile: new subminor version for bugfix release
* Version 1.7.2: released
2014-05-13 Richard Frith-Macdonald
* SQLClient.m:
Fix tiny window in which a connection could be unlocked yet have
the flag set to say it is in a transaction (thus potentially
allowing a locking consistency error).
Add locking to protect setting/changing configuration.
2014-05-08 Richard Frith-Macdonald
* GNUmakefile: new subminor version for bugfix release
* Version 1.7.1: released
2014-04-12 Richard Frith-Macdonald
* SQLClient.m:
Fix error removing database observer when last name is removed.
2014-03-05 Wolfgang Lux
* Postgres.m (backendExecute:):
Fix incorrect comparison operator.
2014-02-21 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add mutable copy implementation so that set and dictionary builders
can be used by caching queries without raising an exception ... the
mutable copy of the helper's content is what gets cached.
2014-02-15 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add helper for building counted set from query.
2013-09-06 Richard Frith-Macdonald
* Version 1.7.0: released
2013-09-05 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Use NSUInteger for sizeInBytes:
2013-04-10 Richard Frith-Macdonald
* ECPG.pgm:
* MySQL.m:
* Oracle.pm:
* Postgres.m:
* SQLClient.h:
* SQLClient.m:
* GNUmakefile:
Change behavior to no longer trim leading and trailing space from
values retrieved from database by default.
Add method to restore automatic trimming for a connection if needed.
2013-03-04 Richard Frith-Macdonald
* Version 1.6.1: released
2013-03-04 Richard Frith-Macdonald
* SQLClient.h: Add helper classe interfaces.
* SQLClient.m: Add helper classe implementations.
Add performance helper classes for when querying a set of records
containing single values and when querying a dataset which contains
key/value pairs more naturally haqndled as a dictionary than an array.
2013-02-11 Sebastian Reitenbach
* ECPG.pgm
* testECPG.m
* testMySQL.m
* testSQLite.m
use PRIuPTR to NSLog NSUIntegers
2013-01-31 Richard Frith-Macdonald
* SQLClient.m: Check for -disconnect being called when inside a
transaction and handle locking properly in that case.
Change simple execute and query methods so they don't call -debug:
inside locked regions, in case the method has been overridden to
do something not safe in such locked sections (such as trying a
query in another thread to report extra debug info).
2012-11-29 Richard Frith-Macdonald
* Wrap more code in exception handlers where there is any potential
for an exception in a lock protected region.
2012-11-10 Niels Grewe
* GNUmakefile: Link against $(FND_LIBS) and $(OBJC_LIBS) instead
of -lgnustep-base and -lobjc.
2012-10-22 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* Postgres.m:
* GNUmakefile:
Add support for asynchronous notifications and bump version number.
2012-10-18 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* ECPG.pgm:
* MySQL.m:
* Postgres.m:
* Oracle.pm:
* SQLite.m:
* JDBC.m:
* testPostgres.m:
Change execute methods to return a count of the rows to which the
executed operation applies, or -1 if not supported.
Implement for postgresql and mysql.
2012-06-17 Richard Frith-Macdonald
* Improve check for compatibility of transactions between clients.
2011-09-30 Richard Frith-Macdonald
* configure.ac: try to use pg_config if available.
* configure: regenerate
* Postgres.m: Fix to handle new bytea with \x format
* GNUmakefile: Bump to 1.5.3
2011-04-01 Richard Frith-Macdonald
* SQLClient.m: Cleanup locking on -begin/-commit/-rollback
* Version 1.5.2: bump version number
2011-04-01 Richard Frith-Macdonald
* Version 1.5.1: bump version number
2010-11-17 Nicola Pero
* GNUmakefile.postamble: Uncommented .PRECIOUS for ECPG and
Oracle, so that typing 'make' does nothing when everything is
already built.
2010-08-13 Richard Frith-Macdonald
* MySQL.m: Try to recognise loss of connection.
Fix bug in timezone management.
2010-07-16 Richard Frith-Macdonald
* MySQL.m: Add support for TEXT data and for MySQL's failure to support
timezones. Also add support for multiple statements in a batch.
2010-07-16 Richard Frith-Macdonald
* configure.ac: Improve check for mysql library.
2010-02-15 Richard Frith-Macdonald
* SQLClient.h: Just include Foundation.h, fix minor doc errors
* GNUmakefile: Add documentation flag to avoid warning.
2010-01-29 Richard Frith-Macdonald
* Postgres.m: Fix to cope with a new date format in recent postgres.
2009-11-18 Richard Frith-Macdonald
Many tweaks to build under OSX snow leopard.
2009-10-27 Richard Frith-Macdonald
* ECPG.pgm:
* MySQL.m:
* Postgres.m:
* Oracle.pm:
* SQLite.m:
* JDBC.m:
Don't call -backendConnect or -backendDisconnect ... should be using
the public API so that notifications are sent properly.
2009-10-01 Richard Frith-Macdonald
* configure.ac: workaround autoconf bug.
* configure: regenerate
2009-09-16 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add convenience method to convert array of rows into an array of
columns.
2009-09-08 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add method for executing a batch of statements/transactions and
returning any failed statements/transactions to they can be
re-done. Also add methods to manipulate the statements in a
transaction so we can retry things intelligently.
2008-11-12 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add support for tracking the number of consecutive connection failures
and imposing a delay between connection attempts.
* JDBC.m: fix typo
* GNUMmakefile: bump version
2008-07-19 Nicola Pero
* configure.ac: Documented the --with-additional-include=,
--with-additional-lib=, --with-postgres-dir= and
--with-jre-architecture= options.
* configure: Regenerated.
* config.h.in: Regenerated.
2008-03-03 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* ECPG.pgm:
* MySQL.m:
* Postgres.m:
* SQLite.m:
* JDBC.m:
Alter to allow control of both the way records are strored and
the way they are listed ... so people can make performance
optimisations.
2008-02-21 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Experimental new method to set a thread to do all cached
queries on and to perform asynchronous updates if other
threads request information which is in the cache but
past its expiry date. Should allow threads to use
config information from a database without blocking
unnecessarily.
2008-02-15 Richard Frith-Macdonald
* SQLClient.m: Fix memory leak when executing transaction.
2007-10-23 Richard Frith-Macdonald
Postgres.m: Use E'...' syntax for bytea if it is available.
2007-09-14 Richard Frith-Macdonald
Update to LGPL3
2007-07-21 Richard Frith-Macdonald
* SQLClient.m: Fix retasin bug copying transactions.
* JDBC.m: Update for new batch code
2007-07-09 Richard Frith-Macdonald
* SQLClient.m: Post notifications upon connect and disconnect.
2007-07-07 Richard Frith-Macdonald
* SQLClient.m: Fix error causing loss of some debug output when an
exception occurs in a transaction.
Rewrite transaction code to support execution with automatic retry of
statements when batching.
* JDBC.m: Update for new transaction code
2007-04-01 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* testSQLite.m:
* testJDBC.m:
* MySQL.m:
* Postgres.m:
* GNUmakefile:
* SQLite.m:
* JDBC.m:
* testMySQL.m:
* testPostgres.m:
* testECPG.m:
Updates to build on MacOS-X with apple-apple-appple
2007-03-08 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* MySQL.m:
* ECPG.pgm:
* Postgres.m:
* Oracle.pm:
* SQLite.m:
* JDBC.m:
Add KVC support for SQLRecord. Make SQLRecord into a class cluster
with a single concrete implementation for now. Extend API to allow
specifying of an alternative SQLRecord subclass when doing a query
so that query results can be efficiently stored into custom subclasses
rather than having to first be retrieved into an SQLRecord and then
copied.
2007-02-14 Nicola Pero
* GNUmakefile (BUNDLE_INSTALL_DIR): Set using GNUSTEP_BUNDLES,
not GNUSTEP_INSTALLATION_DIR.
2007-01-29 Richard Frith-Macdonald
* JDBC.m: Add JDBC2.0 batching for when all statements in a
transaction are simple (ie no NSData arguments) and the batch
API is supported by the driver.
* testJDBC.m: Add simple transaction/batch test.
2007-01-29 Richard Frith-Macdonald
* JDBC.m: Add support for SQLTransaction class to batch JDBC
operations.
2006-12-24 Richard Frith-Macdonald
* JDBC.m: Don't store pointer to jni information in local variable
until after we have opened the connection to the database, or we
may be using a null pointer and generate a crash.
2006-12-22 Richard Frith-Macdonald
* configure.ac: save/restore LIBS after jdbc check so that other
tests don't try to link jre
2006-10-06 Nicola Pero
* GNUmakefile.wrapper.objc.preamble (ADDITIONAL_LIB_DIRS): Added
variable so that the wrapper compiles before the library is installed.
2006-10-02 Nicola Pero
* configure.ac: Do not read gnustep configuration which is never
used.
* configure.ac: Added --disable-jdbc-bundle,
--disable-mysql-bundle, --disable-sqllite-bundle,
--disable-postgres-bundle flags to be able to turn some bundles
off (regardless of config results).
* configure: Regenerated.
2006-10-01 Graham J Lee
* configure.ac: Fix to use GNUSTEP_CONFIG_FILE environment variable.
2006-09-14 Richard Frith-Macdonald
* JDBC push and pop local frames to avoid memory leaks.
2006-08-03 Nicola Pero
* SQLClient.m ([SQLClient -quoteString:]): Renamed local variable
that had the same name as the method argument.
2005-06-23 Richard Frith-Macdonald
* SQLClient.m: transaction efficiency tweak.
* GNUmakefile: bump version to 1.3 as the new blob marker changes and
postgres quoting changes alter behavior.
2005-06-04 Richard Frith-Macdonald
* SQLClient.m: avoid useless compiler warnings.
2005-05-25 Richard Frith-Macdonald
* configure.ac: Check for new postgres string escaping
* configure: Regenerate
* SQLClient.h: Add quoteString method for subclasses to override
* SQLClient.m: Add new method and change marker for blobs to be
one that shouldn't occur in a quoted string.
* SQLite.m: Use new blob marker
* MySQL.m: Use new blob marker
* config.h.in: Add new postgres escaping function
* Postgres.m: Handle new escaping
* testPostgres.m: Add check for escaping odd characters.
2005-02-22 Richard Frith-Macdonald
* SQLClient.m: Support quoting of NSArray and NSSet objects.
2006-01-11 Nicola Pero
* configure.ac: Do not source GNUSTEP_CONFIG_FILE if it doesn't
exist, so that the library can be used with older versions of
gnustep-make/gnustep-base too. :-)
* configure: Regenerated.
2005-11-23 Richard Frith-Macdonald
Added SQLite backend support.
2005-11-14 Richard Frith-Macdonald
Factor out WebServer into separate library, and timer and caching
stuff into Performance library. Make this library depend on the
Performance library.
2005-10-27 Richard Frith-Macdonald
* WebServer.m: Add more accurate timestamps and implement request
and session duration logging. Also add a unique session ID number
to each log to make it easy to track requests on a session.
2005-09-28 Richard Frith-Macdonald
* GNUmakefile.wrapper.objc.preamble: new file
* SQLClient.jigs: new file
* GNUmakefile: Provide java wrappings for SQLClient and friends
2005-09-28 Richard Frith-Macdonald
* SQLClient.m: boost performance of quoting a little.
Provide -count method for transactions.
2005-09-26 Richard Frith-Macdonald
* SQLClient.h: Clean up caching/timestamps.
* SQLClient.m: ditto.
2005-09-22 Richard Frith-Macdonald
* SQLClient.h: Rewrite caching, and expose cache for external use.
* SQLClient.m: ditto.
2005-09-20 Richard Frith-Macdonald
* SQLClient.h: make SQLRecord modifieable (replace values).
* SQLClient.m: ditto.
2005-09-15 Richard Frith-Macdonald
* configure.ac: Locate postgres 8.0 on debian
* configure: regenerate
2005-08-03 Richard Frith-Macdonald
* GNUmakefile: Add SQLClient_LIBRARIES_DEPEND_UPON for apple as
suggested by Yen-Ju Chen.
* SQLClient.m: Don't call allocation debug functions on apple,
and avoid bogus apple compiler warning.
Guard against nil object passed to NSMapRemove() ... the apple
implementation crashes on this.
2005-08-02 Richard Frith-Macdonald
* GNUmakefile: Don't build WebServer stuff on MacOS-X when using the
apple runtime (and presumably foundation).
2005-07-07 Richard Frith-Macdonald
* MySQL.m:
* SQLClient.m:
* WebServer.h:
* WebServer.m:
Tweaks to keep gcc-4 happy (signedness issues) and add support for
using separate ssl conmfig for different IP addresses.
2005-06-21 Richard Frith-Macdonald
* SQLClient.m: Expand tilde in paths searched for backend bundles.
2005-05-25 Richard Frith-Macdonald
* Postgres.m: Clear connection if an exception occurs while
disconnecting ... otherwise a failed disconnect can prevent
any new connection from being established.
Improve quoting of strings to be a bit more efficient and to
remove nul characters.
2005-05-09 Richard Frith-Macdonald
* WebServer.[hm]: Add method to encode a form from a dictionary
into a data object ... convenience for where form data is needed.
2005-03-02 Richard Frith-Macdonald
* WebServer.[hm]: Add support for basic http authentication either
via username/password pairs in property list or in database table.
* SQLClient.[hm]: Add methods to query database with local caching
of results, for use on systems needing high performance, where
database query (and/or database client-server comms) overheads are
important.
2005-02-25 Adam Fedor
* Version 1.1.0:
* GNUmakefile: Add version.
* README: Add ftp location.
Sat Feb 19 04:20:00 2004 Richard Frith-Macdonald
* Makefile: Build two versions of each bundle with different library
linkage for systems where dybnamic linker symbol visibility differs.
* SQLClient.m: Try alternative bundle versions.
Mon Jan 07 15:20:00 2004 Richard Frith-Macdonald
* Makefile: Bump version.
* SQLClient.h: Improve documentation.
Sat Dec 18 06:00:00 2004 Richard Frith-Macdonald
* WebServer.m: Fix bug in substitution of nil values into templates.
Add new method to vend static pages.
Wed Dec 15 13:10:00 2004 Richard Frith-Macdonald
* MySQL.m, Postgres.m, ECPG.pgm: Do NSLog() logging of field
information only when debug level is greater than 1.
Fri Dec 10 10:50:00 2004 Richard Frith-Macdonald
* GNUmakefile: Remove unnecessary libraries from link commands for
bundles. On Darwin, specifying these leads to multiply defined
symbols when an executable attempts to load the bundle.
Fri Nov 19 14:40:00 2004 Richard Frith-Macdonald
* WebServer.m: parse basic authentication infor and set it in extra
headers in request.
* WebServerBundles.m: support handling of paths longer than the
ones set for each bundle.
Tue Nov 11 14:48:05 2004 Nicola Pero
* GNUmakefile (BUNDLE_INSTALL_DIR): install bundles in
GNUSTEP_INSTALLATION_DIR, not GNUSTEP_LOCAL_ROOT.
Tue Nov 09 10:20:00 2004 Richard Frith-Macdonald
* SQLClient.hm: add ([-append:]) method to merge transactions.
Thu Oct 28 08:45:00 2004 Richard Frith-Macdonald
* WebServer.m: Don't generate alert about connection with empty
request if we have lready handled a request and reset.
Tue Oct 26 16:50:00 2004 Richard Frith-Macdonald
* SQLClient.m: debug and duration logging should be turned off
by default ... a different value crept in somehow.
Sat Oct 9 14:29:35 2004 Nicola Pero
* SQLClient.m ([SQLClient -simpleExecute:]): Fixed logging
durations and statements in transactions.
Thu Oct 08 10:30:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Add ([-quotef:,...]) to perform efficient quoting
of a string produced using printf style format and arguments.
Thu Oct 07 10:30:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Optimise timing operations somewhat.
Wed Oct 06 15:04:23 2004 Nicola Pero
* WebServer.h: Fixed typo in parameter name.
Wed Oct 06 13:10:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Allow a database transaction to already have been
begun when [SQLTransactiuon-execute] is called, so we can have
queries in the same database transaction as a list of statements.
Wed Oct 06 06:15:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Make the rollback opoeration a safe no-op if
there is no transaction in progress.
* Postgres.m: Improve exception text by reporting the offending
SQL statement(s).
Fri Sep 17 16:55:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: When reporting the duration of a commit or
rollback, report text of all the statements in the transaction.
Fri Aug 28 09:30:00 2004 Richard Frith-Macdonald
* WebServer.[hm]: Add support for limiting maximum number of incoming
sessions permitted from mone host.
Tue Aug 24 14:30:00 2004 Richard Frith-Macdonald
* WebServer.[hm]: Add support for HTTP/1.1 persistent connections.
Sun Aug 22 10:35:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Add ([SQLRecord-dictionary]) and tidy/comment the
class a bit better.
Sat Aug 07 14:25:00 2004 Richard Frith-Macdonald
* WebServer.m: Add session timeouts to kill off idle sessions.
Tue Jul 27 17:30:00 2004 Richard Frith-Macdonald
* configure.ac: Give more help when postgres is not found.
* configure: regenerate
Mon Jul 26 09:50:00 2004 Richard Frith-Macdonald
* SQLClient.h: Add -transaction method and SQLTransaction class
* SQLClient.m: Implement -transaction method and SQLTransaction class
to provide a simple convenient mechanism for executing a sequence
of statements as a single transaction.
Thu Jul 15 09:40:00 2004 Richard Frith-Macdonald
* WebServer.m: ([_didRead:]) more informative logging upon reading
an unexpected end-of-file
Wed Jul 14 12:07:00 2004 Richard Frith-Macdonald
* configure.ac: Check for PQfformat in libpq, if it is not there
but the library is there, warn that it is too old.
Thu Jul 02 17:40:00 2004 Richard Frith-Macdonald
* WebServer.m: Add control over character encoding used to
interpret form data.
Thu Jul 02 13:25:00 2004 Richard Frith-Macdonald
* WebServer.m: Fix error response when an exception occurs.
Thu Jul 01 18:00:00 2004 Richard Frith-Macdonald
* WebServer.m: Make ([setPort:secure:]) return a status.
* WebServerBundles.m: Check that web server is able to start.
* WebServer.h: ditto
Wed Jun 30 05:40:00 2004 Richard Frith-Macdonald
* GNUmakefile: Use ./obj as location for library to link,
for initial case where we link the bundles before installing
the library.
* WebServer.m: Add casts to prevent compiler warning.
* Postgres.m: Commented out NSLog() left over from debugging.
Tue Jun 29 18:10:00 2004 Richard Frith-Macdonald
* SQLClient.m: Fix code for retrieving reference name ... look in
the config dictionary first, and in user defaults if not found
there.
* SQLClient.h: Document change.
* GNUmakefile: Link bundles with the library to ensure that they
find the SQLRecord class when loaded.
Mon Jun 28 12:55:00 2004 Richard Frith-Macdonald
* WebServer.h: New file.
* WebServer.m: New file.
* WebServerBundles.m: New file.
* SQLClient.h: Mention WebServer.
* GNUmakefile: Build WebServer classes.
Added framework to make it easy to use SQLClient to produce
standalone http/https applications, such as accepting POST'ed
records for addition to a database.
Fri May 07 09:15:00 2004 Richard Frith-Macdonald
Add methods to log duration of any statements over a certain
limit.
Tidy instance variables ... prefix mprivate ones with underscore.
Install header!
Thu Apr 29 15:20:00 2004 Richard Frith-Macdonald
* SQLClient.h: Fix URLs in documentation as suggested by Adam.
* SQLClient.html: regenerate
Mon Apr 26 16:20:00 2004 Richard Frith-Macdonald
Initial checkin of library.
2009-10-01 Richard Frith-Macdonald
* configure.ac: workaround autoconf bug.
* configure: regenerate
2009-09-16 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add convenience method to convert array of rows into an array of
columns.
2009-09-08 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add method for executing a batch of statements/transactions and
returning any failed statements/transactions to they can be
re-done. Also add methods to manipulate the statements in a
transaction so we can retry things intelligently.
2008-11-12 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Add support for tracking the number of consecutive connection failures
and imposing a delay between connection attempts.
* JDBC.m: fix typo
* GNUMmakefile: bump version
2008-07-19 Nicola Pero
* configure.ac: Documented the --with-additional-include=,
--with-additional-lib=, --with-postgres-dir= and
--with-jre-architecture= options.
* configure: Regenerated.
* config.h.in: Regenerated.
2008-03-03 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* ECPG.pgm:
* MySQL.m:
* Postgres.m:
* SQLite.m:
* JDBC.m:
Alter to allow control of both the way records are strored and
the way they are listed ... so people can make performance
optimisations.
2008-02-21 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
Experimental new method to set a thread to do all cached
queries on and to perform asynchronous updates if other
threads request information which is in the cache but
past its expiry date. Should allow threads to use
config information from a database without blocking
unnecessarily.
2008-02-15 Richard Frith-Macdonald
* SQLClient.m: Fix memory leak when executing transaction.
2007-10-23 Richard Frith-Macdonald
Postgres.m: Use E'...' syntax for bytea if it is available.
2007-09-14 Richard Frith-Macdonald
Update to LGPL3
2007-07-21 Richard Frith-Macdonald
* SQLClient.m: Fix retasin bug copying transactions.
* JDBC.m: Update for new batch code
2007-07-09 Richard Frith-Macdonald
* SQLClient.m: Post notifications upon connect and disconnect.
2007-07-07 Richard Frith-Macdonald
* SQLClient.m: Fix error causing loss of some debug output when an
exception occurs in a transaction.
Rewrite transaction code to support execution with automatic retry of
statements when batching.
* JDBC.m: Update for new transaction code
2007-04-01 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* testSQLite.m:
* testJDBC.m:
* MySQL.m:
* Postgres.m:
* GNUmakefile:
* SQLite.m:
* JDBC.m:
* testMySQL.m:
* testPostgres.m:
* testECPG.m:
Updates to build on MacOS-X with apple-apple-appple
2007-03-08 Richard Frith-Macdonald
* SQLClient.h:
* SQLClient.m:
* MySQL.m:
* ECPG.pgm:
* Postgres.m:
* Oracle.pm:
* SQLite.m:
* JDBC.m:
Add KVC support for SQLRecord. Make SQLRecord into a class cluster
with a single concrete implementation for now. Extend API to allow
specifying of an alternative SQLRecord subclass when doing a query
so that query results can be efficiently stored into custom subclasses
rather than having to first be retrieved into an SQLRecord and then
copied.
2007-02-14 Nicola Pero
* GNUmakefile (BUNDLE_INSTALL_DIR): Set using GNUSTEP_BUNDLES,
not GNUSTEP_INSTALLATION_DIR.
2007-01-29 Richard Frith-Macdonald
* JDBC.m: Add JDBC2.0 batching for when all statements in a
transaction are simple (ie no NSData arguments) and the batch
API is supported by the driver.
* testJDBC.m: Add simple transaction/batch test.
2007-01-29 Richard Frith-Macdonald
* JDBC.m: Add support for SQLTransaction class to batch JDBC
operations.
2006-12-24 Richard Frith-Macdonald
* JDBC.m: Don't store pointer to jni information in local variable
until after we have opened the connection to the database, or we
may be using a null pointer and generate a crash.
2006-12-22 Richard Frith-Macdonald
* configure.ac: save/restore LIBS after jdbc check so that other
tests don't try to link jre
2006-10-06 Nicola Pero
* GNUmakefile.wrapper.objc.preamble (ADDITIONAL_LIB_DIRS): Added
variable so that the wrapper compiles before the library is installed.
2006-10-02 Nicola Pero
* configure.ac: Do not read gnustep configuration which is never
used.
* configure.ac: Added --disable-jdbc-bundle,
--disable-mysql-bundle, --disable-sqllite-bundle,
--disable-postgres-bundle flags to be able to turn some bundles
off (regardless of config results).
* configure: Regenerated.
2006-10-01 Graham J Lee
* configure.ac: Fix to use GNUSTEP_CONFIG_FILE environment variable.
2006-09-14 Richard Frith-Macdonald
* JDBC push and pop local frames to avoid memory leaks.
2006-08-03 Nicola Pero
* SQLClient.m ([SQLClient -quoteString:]): Renamed local variable
that had the same name as the method argument.
2005-06-23 Richard Frith-Macdonald
* SQLClient.m: transaction efficiency tweak.
* GNUmakefile: bump version to 1.3 as the new blob marker changes and
postgres quoting changes alter behavior.
2005-06-04 Richard Frith-Macdonald
* SQLClient.m: avoid useless compiler warnings.
2005-05-25 Richard Frith-Macdonald
* configure.ac: Check for new postgres string escaping
* configure: Regenerate
* SQLClient.h: Add quoteString method for subclasses to override
* SQLClient.m: Add new method and change marker for blobs to be
one that shouldn't occur in a quoted string.
* SQLite.m: Use new blob marker
* MySQL.m: Use new blob marker
* config.h.in: Add new postgres escaping function
* Postgres.m: Handle new escaping
* testPostgres.m: Add check for escaping odd characters.
2005-02-22 Richard Frith-Macdonald
* SQLClient.m: Support quoting of NSArray and NSSet objects.
2006-01-11 Nicola Pero
* configure.ac: Do not source GNUSTEP_CONFIG_FILE if it doesn't
exist, so that the library can be used with older versions of
gnustep-make/gnustep-base too. :-)
* configure: Regenerated.
2005-11-23 Richard Frith-Macdonald
Added SQLite backend support.
2005-11-14 Richard Frith-Macdonald
Factor out WebServer into separate library, and timer and caching
stuff into Performance library. Make this library depend on the
Performance library.
2005-10-27 Richard Frith-Macdonald
* WebServer.m: Add more accurate timestamps and implement request
and session duration logging. Also add a unique session ID number
to each log to make it easy to track requests on a session.
2005-09-28 Richard Frith-Macdonald
* GNUmakefile.wrapper.objc.preamble: new file
* SQLClient.jigs: new file
* GNUmakefile: Provide java wrappings for SQLClient and friends
2005-09-28 Richard Frith-Macdonald
* SQLClient.m: boost performance of quoting a little.
Provide -count method for transactions.
2005-09-26 Richard Frith-Macdonald
* SQLClient.h: Clean up caching/timestamps.
* SQLClient.m: ditto.
2005-09-22 Richard Frith-Macdonald
* SQLClient.h: Rewrite caching, and expose cache for external use.
* SQLClient.m: ditto.
2005-09-20 Richard Frith-Macdonald
* SQLClient.h: make SQLRecord modifieable (replace values).
* SQLClient.m: ditto.
2005-09-15 Richard Frith-Macdonald
* configure.ac: Locate postgres 8.0 on debian
* configure: regenerate
2005-08-03 Richard Frith-Macdonald
* GNUmakefile: Add SQLClient_LIBRARIES_DEPEND_UPON for apple as
suggested by Yen-Ju Chen.
* SQLClient.m: Don't call allocation debug functions on apple,
and avoid bogus apple compiler warning.
Guard against nil object passed to NSMapRemove() ... the apple
implementation crashes on this.
2005-08-02 Richard Frith-Macdonald
* GNUmakefile: Don't build WebServer stuff on MacOS-X when using the
apple runtime (and presumably foundation).
2005-07-07 Richard Frith-Macdonald
* MySQL.m:
* SQLClient.m:
* WebServer.h:
* WebServer.m:
Tweaks to keep gcc-4 happy (signedness issues) and add support for
using separate ssl conmfig for different IP addresses.
2005-06-21 Richard Frith-Macdonald
* SQLClient.m: Expand tilde in paths searched for backend bundles.
2005-05-25 Richard Frith-Macdonald
* Postgres.m: Clear connection if an exception occurs while
disconnecting ... otherwise a failed disconnect can prevent
any new connection from being established.
Improve quoting of strings to be a bit more efficient and to
remove nul characters.
2005-05-09 Richard Frith-Macdonald
* WebServer.[hm]: Add method to encode a form from a dictionary
into a data object ... convenience for where form data is needed.
2005-03-02 Richard Frith-Macdonald
* WebServer.[hm]: Add support for basic http authentication either
via username/password pairs in property list or in database table.
* SQLClient.[hm]: Add methods to query database with local caching
of results, for use on systems needing high performance, where
database query (and/or database client-server comms) overheads are
important.
2005-02-25 Adam Fedor
* Version 1.1.0:
* GNUmakefile: Add version.
* README: Add ftp location.
Sat Feb 19 04:20:00 2004 Richard Frith-Macdonald
* Makefile: Build two versions of each bundle with different library
linkage for systems where dybnamic linker symbol visibility differs.
* SQLClient.m: Try alternative bundle versions.
Mon Jan 07 15:20:00 2004 Richard Frith-Macdonald
* Makefile: Bump version.
* SQLClient.h: Improve documentation.
Sat Dec 18 06:00:00 2004 Richard Frith-Macdonald
* WebServer.m: Fix bug in substitution of nil values into templates.
Add new method to vend static pages.
Wed Dec 15 13:10:00 2004 Richard Frith-Macdonald
* MySQL.m, Postgres.m, ECPG.pgm: Do NSLog() logging of field
information only when debug level is greater than 1.
Fri Dec 10 10:50:00 2004 Richard Frith-Macdonald
* GNUmakefile: Remove unnecessary libraries from link commands for
bundles. On Darwin, specifying these leads to multiply defined
symbols when an executable attempts to load the bundle.
Fri Nov 19 14:40:00 2004 Richard Frith-Macdonald
* WebServer.m: parse basic authentication infor and set it in extra
headers in request.
* WebServerBundles.m: support handling of paths longer than the
ones set for each bundle.
Tue Nov 11 14:48:05 2004 Nicola Pero
* GNUmakefile (BUNDLE_INSTALL_DIR): install bundles in
GNUSTEP_INSTALLATION_DIR, not GNUSTEP_LOCAL_ROOT.
Tue Nov 09 10:20:00 2004 Richard Frith-Macdonald
* SQLClient.hm: add ([-append:]) method to merge transactions.
Thu Oct 28 08:45:00 2004 Richard Frith-Macdonald
* WebServer.m: Don't generate alert about connection with empty
request if we have lready handled a request and reset.
Tue Oct 26 16:50:00 2004 Richard Frith-Macdonald
* SQLClient.m: debug and duration logging should be turned off
by default ... a different value crept in somehow.
Sat Oct 9 14:29:35 2004 Nicola Pero
* SQLClient.m ([SQLClient -simpleExecute:]): Fixed logging
durations and statements in transactions.
Thu Oct 08 10:30:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Add ([-quotef:,...]) to perform efficient quoting
of a string produced using printf style format and arguments.
Thu Oct 07 10:30:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Optimise timing operations somewhat.
Wed Oct 06 15:04:23 2004 Nicola Pero
* WebServer.h: Fixed typo in parameter name.
Wed Oct 06 13:10:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Allow a database transaction to already have been
begun when [SQLTransactiuon-execute] is called, so we can have
queries in the same database transaction as a list of statements.
Wed Oct 06 06:15:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Make the rollback opoeration a safe no-op if
there is no transaction in progress.
* Postgres.m: Improve exception text by reporting the offending
SQL statement(s).
Fri Sep 17 16:55:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: When reporting the duration of a commit or
rollback, report text of all the statements in the transaction.
Fri Aug 28 09:30:00 2004 Richard Frith-Macdonald
* WebServer.[hm]: Add support for limiting maximum number of incoming
sessions permitted from mone host.
Tue Aug 24 14:30:00 2004 Richard Frith-Macdonald
* WebServer.[hm]: Add support for HTTP/1.1 persistent connections.
Sun Aug 22 10:35:00 2004 Richard Frith-Macdonald
* SQLClient.[hm]: Add ([SQLRecord-dictionary]) and tidy/comment the
class a bit better.
Sat Aug 07 14:25:00 2004 Richard Frith-Macdonald
* WebServer.m: Add session timeouts to kill off idle sessions.
Tue Jul 27 17:30:00 2004 Richard Frith-Macdonald