ocamlodbc-2.15/ 0000755 0027420 0051216 00000000000 10636407423 013264 5 ustar guesdon cristal ocamlodbc-2.15/Biniki/ 0000755 0027420 0051216 00000000000 10636407423 014471 5 ustar guesdon cristal ocamlodbc-2.15/Biniki/.cvsignore 0000644 0027420 0051216 00000000027 10127210446 016460 0 ustar guesdon cristal *.cm*
biniki.opt
biniki ocamlodbc-2.15/Biniki/.depend 0000644 0027420 0051216 00000000556 10024573456 015740 0 ustar guesdon cristal biniki.cmo: biniki_context.cmo biniki_window.cmo
biniki.cmx: biniki_context.cmx biniki_window.cmx
biniki_context.cmo: biniki_misc.cmo
biniki_context.cmx: biniki_misc.cmx
biniki_query_box.cmo: biniki_misc.cmo
biniki_query_box.cmx: biniki_misc.cmx
biniki_window.cmo: biniki_misc.cmo biniki_query_box.cmo
biniki_window.cmx: biniki_misc.cmx biniki_query_box.cmx
ocamlodbc-2.15/Biniki/Makefile 0000644 0027420 0051216 00000002423 10571243354 016131 0 ustar guesdon cristal
include ../master.Makefile
CMOFILES = biniki_messages.cmo\
biniki_misc.cmo\
biniki_context.cmo\
biniki_query_box.cmo\
biniki_window.cmo\
biniki.cmo
CMIFILES = $(CMOFILES:.cmo=.cmi)
CMXFILES = $(CMOFILES:.cmo=.cmx)
# Overriden flags
COMPFLAGS=-nolabels -I ../$(SUBDIR) $(INCLUDEGTK)
LINKFLAGS=-ccopt -L../$(SUBDIR) -I ../$(SUBDIR) $(LINKGTK)
####
BINIKI=biniki
BINIKI_OPT=biniki.opt
# targets for each database
mysql:
make BASE=MYSQL all
postgres:
make BASE=POSTGRES all
openingres:
make BASE=OPENINGRES all
db2:
make BASE=DB2 all
unixodbc:
make BASE=unixODBC all
oraclecfo:
make BASE=ORACLECFO all
all: exe opt
exe: $(BINIKI)
opt: $(BINIKI_OPT)
fr:
$(RM) biniki_messages.ml
ln -s biniki_messages_fr.ml biniki_messages.ml
en:
$(RM) biniki_messages.ml
ln -s biniki_messages_en.ml biniki_messages.ml
$(BINIKI): $(CMOFILES) $(CMIFILES)
$(OCAMLC) -o $@ $(LINKFLAGS) $(LIB) unix.cma str.cma $(LIBSGTK) $(CMOFILES)
$(BINIKI_OPT): $(CMXFILES) $(CMIFILES)
$(OCAMLOPT) -o $@ $(LINKFLAGS) $(LIB_OPT) unix.cmxa str.cmxa $(LIBSGTK_OPT) $(CMXFILES)
clean_all: clean
$(RM) $(CMOFILES) $(CMXFILES) $(CMIFILES) *.o
$(RM) $(BINIKI) $(BINIKI_OPT)
clean:
$(RM) *~ #*# *-
# common rules
.depend depend::
rm -f .depend
$(OCAMLDEP) $(INCLUDES) *.ml *.mli > .depend
include .depend
ocamlodbc-2.15/Biniki/biniki.ml 0000644 0027420 0051216 00000005503 10020610114 016247 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo] This is the main module of Biniki. [Mo]*)
let base =
try Sys.argv.(1)
with _ ->
output_string stderr Biniki_messages.mUsage;
exit 1
let user =
try Sys.argv.(2)
with _ -> Biniki_messages.login
let passwd =
try Sys.argv.(3)
with _ -> ""
(* create a database object *)
let db = new Ocamlodbc.data_base base user passwd
(* connect to data base *)
let _ =
try db#connect ()
with Ocamlodbc.SQL_Error s ->
output_string stderr (s^"\n");
exit 2
(* create a context object *)
let context = new Biniki_context.context base db
(* create the first window ; this function returns when all
windows are closed, not only the first one created.*)
let _ = Biniki_window.window context ()
(* disconnect from data base *)
let _ =
try db#disconnect ()
with Ocamlodbc.SQL_Error s ->
output_string stderr (s^"\n");
exit 3
ocamlodbc-2.15/Biniki/biniki_context.ml 0000644 0027420 0051216 00000006651 10020610114 020020 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo] This module contains the context class, used to
load, write and manage the history of queries.[Mo]*)
(*[Cl] This class is used to manage the history of queries
and provide access to the database
through all the application.[Cl]*)
class context (base : string) (db : Ocamlodbc.data_base) =
object (self)
(*[At] The name of the history file. [At]*)
val history_file =
Filename.concat Biniki_messages.home Biniki_messages.history_file
(*[At] The history of queries.[At]*)
val mutable history_queries = ([] : string list)
(*[Me] Access to the history of queries. [Me]*)
method history_queries = history_queries
(*[Me] This method adds a query to the history. [Me]*)
method add_query s =
let s2 = Biniki_misc.remove_trailing_spaces s in
if List.mem s2 history_queries then
()
else
(
history_queries <- s :: history_queries;
try
Biniki_misc.output_string_list history_file history_queries
with
Failure s ->
Biniki_misc.message_box Biniki_messages.mErreur s
)
(*[Me] Access to the database. [Me]*)
method database = db
(*[Me] Access to the database name. [Me]*)
method base = base
initializer
(* we must read the list of queries in the history file *)
try
history_queries <- Biniki_misc.input_string_list history_file
with
Failure s ->
(* couldn't read the history file *)
Biniki_misc.message_box Biniki_messages.mErreur s
end
ocamlodbc-2.15/Biniki/biniki_messages_en.ml 0000644 0027420 0051216 00000005700 10020610114 020617 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo]Module contenaing the messages of Biniki .[Mo]*)
let logiciel = "Biniki";;
let version = "1.0";;
let module_version = version;;
let module_name = logiciel;;
let module_author = "Maxence Guesdon";;
let mVersion = "Module "^module_name^" version "^module_version^" by "^module_author;;
let mUsage = "Usage : "^Sys.argv.(0)^" [ []]\n";;
let mAbout = logiciel^" "^version^" : \n\nCopyright (c) 2001 by "^module_author^"\nhttp://maxence.guesdon.free.fr\nmax@sbuilders.com\n\nDistributed under license GPL.";;
let mErreur = "Error";;
let history_file = ".biniki";;
let home = Sys.getenv "HOME";;
let login =
try
Unix.getlogin ()
with
| _ -> (* we get the basename of the $HOME directory *)
Filename.basename home
;;
let mOk = "Ok";;
let mCancel = "Cancel";;
let mWarning = "Warning ! ";;
let mExecute = "Execute";;
let m0 = "Unknown error";;
(* menus labels *)
let mn1 = "File";;
let mn2 = "Close";;
let mn3 = "?";;
let mn4 = "About ...";;
ocamlodbc-2.15/Biniki/biniki_messages_fr.ml 0000644 0027420 0051216 00000005724 10020610114 020632 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo]Module contenaing the messages of Biniki .[Mo]*)
let logiciel = "Biniki";;
let version = "1.0";;
let module_version = version;;
let module_name = logiciel;;
let module_author = "Maxence Guesdon";;
let mVersion = "Module "^module_name^" version "^module_version^" par "^module_author;;
let mUsage = "Usage : "^Sys.argv.(0)^" [ []]\n";;
let mAbout = logiciel^" "^version^" : \n\nCopyright (c) 2001 par "^module_author^"\nhttp://maxence.guesdon.free.fr\nmax@sbuilders.com\n\nDistribué sous licence GPL.";;
let mErreur = "Erreur";;
let history_file = ".biniki";;
let home = Sys.getenv "HOME";;
let login =
try
Unix.getlogin ()
with
| _ -> (* we get the basename of the $HOME directory *)
Filename.basename home
;;
let mOk = "Ok";;
let mCancel = "Annuler";;
let mWarning = "Attention ! ";;
let mExecute = "Exécuter";;
let m0 = "Erreur inconnue";;
(* menus labels *)
let mn1 = "Fichier";;
let mn2 = "Fermer";;
let mn3 = "?";;
let mn4 = "A propos";;
ocamlodbc-2.15/Biniki/biniki_misc.ml 0000644 0027420 0051216 00000012630 10020610114 017261 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo] This module contains misc functions used in biniki.[Mo]*)
(*[Fonc] This function takes a filename and returns
the list of strings (one string per line) read
from the file. Raises Failure if an error occurs.
[Fonc]*)
let input_string_list file =
try
let chanin = open_in file in
let rec iter () =
try
let s = input_line chanin in
s :: (iter ())
with
_ ->
close_in chanin;
[]
in
iter ()
with
Sys_error s ->
raise (Failure s)
| _ ->
raise (Failure Biniki_messages.m0)
(*[Fonc] This function takes a filename and a string list
and writes the strings in the file.
Raises Failure if an error occurs.
[Fonc]*)
let output_string_list file string_list =
try
let chanout = open_out file in
let rec iter = function
[] -> close_out chanout
| s :: q ->
output_string chanout
(s^(if q = [] then "" else "\n"));
iter q
in
iter string_list
with
Sys_error s ->
raise (Failure s)
| _ ->
raise (Failure Biniki_messages.m0)
(*[Fonc]This function is used to display a question in a dialog box,
with a parametrized list of buttons. The function returns the number
of the clicked button, or 0 if the window is savagedly destroyed.[Fonc]*)
let question_box title message button_list =
let button_nb = ref 0 in
let window = GWindow.window ~modal:true ~title: title () in
let box = GPack.vbox ~spacing:5 ~border_width:3 ~packing:window#add () in
let lMessage = GMisc.label ~text: message ~packing: (box#pack ~expand: true) () in
let bbox = GPack.hbox ~spacing: 5 ~border_width:3
~packing: (box#pack ~expand: false) ()
in
(* the function called to create each button by iterating *)
let rec iter_buttons n = function
[] ->
()
| button_label :: q ->
let b = GButton.button ~label: button_label
~packing:(bbox#pack ~expand: true ~fill:true ~padding:4) ()
in
let _ = b #connect#clicked
~callback: (fun _ -> button_nb := n; window #destroy ())
in
(* si c'est le premier bouton, on lui met le focus *)
if n = 1 then b#misc#grab_focus () else ();
iter_buttons (n+1) q
in
iter_buttons 1 button_list;
let _ = window #connect#destroy ~callback: GMain.Main.quit in
window#set_position `CENTER;
window # show ();
GMain.Main.main ();
!button_nb
;;
(*[Fonc]This function is used to display a message in a dialog box with just an Ok button.
We use the question box with just an ok button. [Fonc]*)
let message_box title message =
let _ = question_box title message [Biniki_messages.mOk] in
()
;;
(*[Fonc]This function takes a clist widget and set the width of each column
to be large enough for the largest string in the column and its title.[Fonc]*)
let autosize_clist wlist =
(* get the number of columns *)
let nb_columns = wlist#columns in
(* get the columns titles *)
let rec iter lacc i =
if i >= nb_columns then
lacc
else
let title = wlist#column_title i in
iter (lacc@[(" "^title^" ")]) (i+1)
in
let titles = iter [] 0 in
(* insert a row with the titles *)
let _ = wlist#insert ~pos:0 titles in
(* use to clist columns_autosize method *)
let _ = wlist#columns_autosize () in
(* remove the inserted row *)
let _ = wlist#remove 0 in
()
;;
(*[Fonc]This function removes the trailing spaces of a string.[Fonc]*)
let remove_trailing_spaces s =
Str.global_replace (Str.regexp "[' ']+$") "" s
;;
ocamlodbc-2.15/Biniki/biniki_query_box.ml 0000644 0027420 0051216 00000007544 10571243354 020376 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo] This module contains the box class, which allows to build
a box to display the results of a query.[Mo]*)
(*[Cl] This class builds a box to display the results of a query.
If the query is given, it is displayed.
The results of the query consist in two lists :
one list of couples (column name, column type),
one list of list of strings representing the returned records.
[Cl]*)
class box context ?(query : string option) column_list records =
let vbox = GPack.vbox () in
let wf = GBin.frame
~label: (match query with None -> "" | Some q -> q)
~packing: (vbox#pack ~expand: true ~padding: 4)
()
in
let wscroll = GBin.scrolled_window
~packing: wf#add
()
in
let wlist = GList.clist
~titles_show: true
~titles: (List.map fst column_list)
~packing: (wscroll#add)
()
in
object(self)
(*[Me] This method returns the vbox widget ready to packed.[Me]*)
method box = vbox#coerce
initializer
(* fill the wlist with the records *)
let f l =
let _ = wlist#append (List.map (function None -> "" | Some s -> s) l) in
()
in
List.iter f records;
Biniki_misc.autosize_clist wlist;
let rec iter n (name, typ) =
wlist#set_column
(*~title: (name^"\n"^(Ocamlodbc.SQL_column.string typ))*)
~justification:
(match typ with
Ocamlodbc.SQL_numeric
| Ocamlodbc.SQL_decimal
| Ocamlodbc.SQL_integer
| Ocamlodbc.SQL_smallint
| Ocamlodbc.SQL_float
| Ocamlodbc.SQL_real
| Ocamlodbc.SQL_double
| Ocamlodbc.SQL_bigint
| Ocamlodbc.SQL_tinyint
| Ocamlodbc.SQL_bit ->
`RIGHT
| _ ->
`LEFT
)
n;
n + 1
in
(*let _ = List.fold_left iter 0 column_list in*)
()
end
ocamlodbc-2.15/Biniki/biniki_window.ml 0000644 0027420 0051216 00000013704 10571243354 017663 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
(*[Mo] This module contains the function which builds abiniki window. [Mo]*)
(*[Fonc]This function builds a biniki main window.
If the query optional parameter is given, then the query
must be executed, and if it gives results, a window
must show them.
If there is no results or if an error occurs, no window
is displayed.
If the query is correct (no error occured when executed),
then it is added to the history.
If no query parameter is given, the window is displayed,
containing no "result box".
[Fonc]*)
let rec window context ?(query : string option) () =
try
let (n, columns, records) =
match query with
None ->
(0, [], [])
| Some q ->
context#database#execute_with_info q
in
if n = 0 then
(
(* the query, if any, was successfully executed ; add it to the history *)
let _ =
match query with
None -> ()
| Some q -> context#add_query q
in
(* create the window if there are results to display or
it is the initial window (no query) *)
match columns with
[] when query <> None ->
(* no result *)
()
| _ ->
(* create the window *)
let win = GWindow.window
~title: (Biniki_messages.logiciel^" "^Biniki_messages.version^" : "^context#base)
~width:500 ()
in
let _ = win#connect#destroy ~callback: GMain.Main.quit in
(* The main box *)
let vbox = GPack.vbox ~packing:win#add () in
(* The ... menubar ! *)
let menubar = GMenu.menu_bar ~packing: (vbox#pack ~expand: false) () in
let menuFile = GMenu.menu () in
let itemFile = GMenu.menu_item ~label: Biniki_messages.mn1 ~packing: menubar#add () in
let _ = itemFile#set_submenu menuFile in
let itemClose = GMenu.menu_item ~label: Biniki_messages.mn2
~packing: menuFile#add ()
in
let _ = itemClose#connect#activate win#destroy in
let menuHelp = GMenu.menu () in
let itemHelp = GMenu.menu_item ~label: Biniki_messages.mn3 ~packing: menubar#add () in
let _ = itemHelp#set_submenu menuHelp in
let itemAbout = GMenu.menu_item ~label: Biniki_messages.mn4
~packing: menuHelp#add ()
in
let _ = itemAbout#connect#activate
(fun () -> Biniki_misc.message_box Biniki_messages.mn4 Biniki_messages.mAbout)
in
let _ =
match query with
None -> ()
| Some q ->
(* add the query box *)
let query_box = new Biniki_query_box.box context ~query: q columns records in
let _ = vbox#pack ~expand: true query_box#box in
()
in
(* the box for the combo and the execute-button *)
let hbox = GPack.hbox ~packing: (vbox#pack ~expand: false ~padding: 2) () in
(* The combo box for queries *)
let wcombo_queries = GEdit.combo
~popdown_strings: ("" :: context#history_queries)
~value_in_list: false
~allow_empty: true
~packing: (hbox#pack ~expand: true ~padding: 2)
()
in
let wb_execute = GButton.button
~label: Biniki_messages.mExecute
~packing: (hbox#pack ~expand: false ~padding: 2)
()
in
(* the function called to execute the query in the combo *)
let f_exec_query () =
let string_query = wcombo_queries#entry#text in
window context ~query: string_query ()
in
let _ = wb_execute#connect#clicked f_exec_query in
win#show ();
GMain.Main.main ()
)
else
Biniki_misc.message_box Biniki_messages.mErreur Biniki_messages.m0
with
Ocamlodbc.SQL_Error s ->
Biniki_misc.message_box Biniki_messages.mErreur s
ocamlodbc-2.15/.cvsignore 0000644 0027420 0051216 00000000136 10634604637 015270 0 ustar guesdon cristal *.cm*
master.Makefile
config.status
config.log
unixodbc
mysql
postgres
oraclecfo
META
.depend
ocamlodbc-2.15/ChangeLog 0000644 0027420 0051216 00000002477 10634604537 015053 0 ustar guesdon cristal 2007-06-15 Christophe Troestler
* ocamlodbc.mli: Improved the documentation.
* INSTALL_WIN32.bat: added /DCAML_DLL to cl for the link to work.
2007-02-28 Maxence Guesdon
* rel: 2.12
* fix: examples to handle the small modification in interface
(string option for record values)
* fix: biniki now uses lablgtk2
2006-06-07 Maxence Guesdon
* add: Makefile.nt, configure.nt, Exemples/Makefile.nt by David Allsopp
for compiling under Windows/MinGW/Cygwin
2005-05-13 Maxence Guesdon
* rel: 2.10
* add: mingw support, thanks to Jeff Henrikson
* fix: use Unsigned_long_val instead of Long_val macros
in some C functions, thanls to chrisre@cs.washington.edu
for pointing this
* add: integrate patch from Alessandro Baretta
to enable support for dynamic linking
2004-10-01 Maxence Guesdon
* rel: 2.9
* add: Ocamlodbc.execute_gen, from the patch by Leonid Timochouk
* add: Ocamldoc.version available in interface
2004-03-13: Maxence
- Move to Gna!
2004-03-01: Maxence
- mod: licenses in all files
2003-11-02: Maxence
- add: WIN32 support, thanks to Clément Capel
2003-08-27: Maxence
- add: support for Oracle through the DataDirect "Connect for ODBC" driver
ocamlodbc-2.15/GPL 0000644 0027420 0051216 00000043127 07352134124 013634 0 ustar guesdon cristal GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program 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 2 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
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
ocamlodbc-2.15/INSTALL 0000644 0027420 0051216 00000005252 10571243354 014320 0 ustar guesdon cristal OCamlODBC : Accessing databases from OCaml via ODBC
*** What is OCamlODBC ***
OCamlODBC is a library allowing to acces databases via an Open
DataBase Connectivity (ODBC) driver from OCaml programs.
*** What you need ***
- OCaml >= 3.0x installed (3.01 or 3.02 for the Biniki example)
- ODBC driver installed (headers and libs), for example iODBC for
MySQL or the PostgreSQL-ODBC package for PostgreSQL
- LablGtk >= 2.6 installed for the Biniki example
- make ;-)
*** How to compile ***
- ./configure
(./configure --help to see options, or myconf for an example)
- make
where can be one or several of the following :
- mysql
- postgres
- db2
- openingres
- unixodbc
- oraclecfo
depending on which ODBC drivers are available on your system.
You may need to make some changes to compile successfully:
- in master.Makefile the -ldopt should be replaced by -Xlinker
You may have a look at the Makefile.nt, configure.nt and Exemples/Makefile.nt files
to compile under Windows with MinGW, thanks to David Allsopp which gave these
files with this comment:
>> I have produced a Makefile.nt with accompanying configure.nt scripts which
>> attempt to replicate the behaviour of Makefile. To build and install the
>> entire system under Windows, from a Cygwin bash prompt, execute
>> make -f Makefile.nt findlib_install
>> or
>> make -f Makefile.nt direct_install
>> depending on which installation method you wish to use. This builds the
>> bytecode library ocamlodbc.cma and native code library ocamlodbc.cmxa linked
>> with the Windows ODBC Interface.
>> Exemples/Makefile.nt compiles the four example programs using the library.
- make install
will install the compiled libraries in
/lib/ocaml/ocamlodbc/[mysql|postgres|db2|openingres|unixodbc|oraclecfo]
*** How to use ****
The directory 'Exemples' contains some examples.
- cd Exemples
- make BASE=XX PROG to create monitor.x
where XX can be MYSQL, POSTGRES, DB2, OPENINGRES or unixODBC, ORACLECFO
- monitor.x []' to connect to a
database ; you can type in commands on the prompt (select * from ...)
The directory Biniki contains a simple application to execute SQL
queries and display the results in a window. It needs LablGTK 1.2.
- cd Biniki
- make fr or make en to create a link to the messages file you want
- make to create biniki and biniki.opt
where can be mysql, postgres, db2, openingres or unixodbc
- biniki[.opt] [user [password]]
to connect to a database you're allowed to, and enjoy !
*** Author ***
Maxence Guesdon . Let me know if you use
OCamlODBC with another database system, so i can add it to the
distrib.
ocamlodbc-2.15/INSTALL_WIN32.bat 0000644 0027420 0051216 00000004522 10636267451 015754 0 ustar guesdon cristal @echo off
REM ocamlODBC installation script for Windows
REM Clement Capel, Oct 2003
REM Troestler Christophe, June 2007 (thanks to Dmitry Bely for suggestions)
set INSTALLDIR=%OCAMLLIB%\ocamlodbc
set STUBDIR=%OCAMLLIB%\stublibs
set ODBC3=
REM Uncomment if your system supports ODBC 3.0 or greater.
REM set ODBC3=/DODBC3
set DEBUG=
REM set DEBUG=/DDEBUG2
echo ----------------------------------------------------------------------
REM Please read the README.win32 file in the ocaml distribution,
REM get the appropriate software for MSVC and compile in a shell with the
REM appropriate PATH set. The latter is typically done by executing .bat :
REM
REM CALL "C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
REM CALL "c:\Program Files\Microsoft Platform SDK"\SetEnv.Cmd /SRV32
echo Assumes VC++ installed:
echo i.e. "cl", "link", and "lib" are available
echo ----------------------------------------------------------------------
REM set LIBODBC=libodbc32.lib
REM For Windows Server 2003:
set LIBODBC=odbc32.lib
REM set CUSTOM=-custom ocaml_odbc_c.obj -cclib -lodbc32
REM set CUSTOM=
REM See http://msdn2.microsoft.com/en-us/library/d91k01sh(VS.80).aspx
REM for the structure of DEF files
prompt $G$S
@echo on
@echo --- Compile the external functions and create the dll ---
cl /nologo /Ox /MT /DWIN32 %ODBC3% /I "%OCAMLLIB%" /c ocaml_odbc_c.c /Foocaml_odbc_c.s.obj
lib /nologo /out:libocamlodbc.lib ocaml_odbc_c.s.obj
cl /nologo /Ox /MD %DEBUG% /DWIN32 %ODBC3% /DCAML_DLL /I "%OCAMLLIB%" /c ocaml_odbc_c.c /Foocaml_odbc_c.d.obj
link /nologo /dll /out:dllocamlodbc.dll /def:ocamlodbc.DEF ocaml_odbc_c.d.obj /LIBPATH:"%OCAMLLIB%" ocamlrun.lib %LIBODBC%
@echo --- Make a byte code library ---
ocamlc -a -o ocamlodbc.cma %CUSTOM% ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -cclib -locamlodbc -cclib %LIBODBC%
@echo --- Make a native code library ---
ocamlopt -a -o ocamlodbc.cmxa ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -cclib -locamlodbc -cclib %LIBODBC%
@echo --- Install ---
mkdir "%INSTALLDIR%"
copy libocamlodbc.lib "%INSTALLDIR%" >NUL
copy dllocamlodbc.dll "%STUBDIR%" >NUL
copy ocamlodbc.mli "%INSTALLDIR%" >NUL
copy ocamlodbc.cmi "%INSTALLDIR%" >NUL
copy ocamlodbc.cma "%INSTALLDIR%" >NUL
copy ocamlodbc.cmxa "%INSTALLDIR%" >NUL
copy ocamlodbc.lib "%INSTALLDIR%" >NUL
@prompt $P$G$S
ocamlodbc-2.15/INSTALL_WIN32_WITH_OCAMLOPT 0000644 0027420 0051216 00000001431 07352134034 017323 0 ustar guesdon cristal ----------------------------------------------------------------------------
Instructions for acquiring and installing the MASM assemble in order to use
ocamlopt on Win32.
by John Small ( jsmall@laser.net )
----------------------------------------------------------------------------
Go to
http://www.easystreet.com/~jkirwan/pctools.html
and download
http://msdn.microsoft.com/vstudio/downloads/ppack/vcpp.exe
If you now run vcpp.exe at the first error don't click okay.
Instead go to a DOS window and type SET and see what
TEMP is set to. Then go to this directory in the Windows explorer
and find "ml.*" below this directory.
Copy the ml.exe and ml.err files to your ocaml/bin directory.
You can now type
ocamlopt -o myprog.exe file1.ml file2.ml
myprog.exe ocamlodbc-2.15/INSTALL_mingw.sh 0000755 0027420 0051216 00000002660 10635510403 016126 0 ustar guesdon cristal # ocamlODBC installation script for Windows
# Clement Capel Oct 2003
# -----------------------------------------
# Assumes VC++ installed
# variables set for "cl" and "link"
# -----------------------------------------
# Compile the external functions and create the dll
#cl /nologo /Ox /MD /DWIN32 -I %OCAMLLIB%\caml -c ocaml_odbc_c.c
#move ocaml_odbc_c.obj ocaml_odbc_c.d.obj
#link /nologo /dll /out:dllocamlodbc.dll /def:ocamlodbc.DEF ocaml_odbc_c.d.obj %OCAMLLIB%\ocamlrun.lib libodbc32.lib
#copy dllocamlodbc.dll %OCAMLLIB%\stublibs
#insert -DDEBUG2 for gobs of debugging output
gcc -mno-cygwin -g -DDEBUG_LIGHT -DODBC3 -I /cygdrive/c/ocaml/lib/caml -I /usr/include/w32api -DWIN32 -c ocaml_odbc_c.c
gcc -mno-cygwin -g -shared -L /cygdrive/c/ocaml/lib -o dllocamlodbc.dll /cygdrive/c/ocaml/bin/ocamlrun.dll ocaml_odbc_c.o -lodbc32
# Make a native code library
#ocamlopt -a -o ocamlodbc.cmxa ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml ocaml_odbc_c.obj -cclib -lodbc32
#copy ocamlodbc.cmxa %OCAMLLIB%
#copy ocamlodbc.cmi %OCAMLLIB%
# Make a custom runtime library
#ocamlc -a -o ocamlodbc.cma -custom ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml ocaml_odbc_c.obj -dllib -locamlodbc -cclib -lodbc32
#copy ocamlodbc.cma %OCAMLLIB%
#copy ocamlodbc.cmi %OCAMLLIB%
# Make a toplevel-dynlinked library
ocamlc -a -o ocamlodbc.cma ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -dllib -locamlodbc
cp *.cmi *.mli *.cma $HOME/ocaml/lib
cp *.dll $HOME/ocaml/bin
ocamlodbc-2.15/LGPL 0000644 0027420 0051216 00000063476 07352134124 013761 0 ustar guesdon cristal GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
ocamlodbc-2.15/LICENCE 0000644 0027420 0051216 00000000502 10020610114 014222 0 ustar guesdon cristal OCamlODBC is under Lesser GPL. A copy of this licence can be found in the file LGPL.
Biniki, the example which uses OCamlODBC, is under GPL. A copy of this licence can be found in the file GPL.
The examples (in directory Exemples) which use OCamlODBC, are under GPL. A copy of this licence can be found in the file GPL.
ocamlodbc-2.15/Makefile 0000644 0027420 0051216 00000014037 10634574312 014731 0 ustar guesdon cristal ###############################################################################
# OCamlODBC #
# #
# Copyright (C) 2004 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published #
# by the Free Software Foundation; either version 2.1 of the License, or #
# 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# #
# Contact: Maxence.Guesdon@inria.fr #
###############################################################################
include master.Makefile
OBJOCAML = ocaml_odbc.cmo
OBJOCAML_OPT = ocaml_odbc.cmx
LIBOBJ = ocamlodbc.cmo
LIBOBJ_OPT = ocamlodbc.cmx
LIBOBJI = ocamlodbc.cmi
OBJFILES = ocaml_odbc_c.o
####
# For different target databases
################################
mysql: dummy
make clean
make BASE=MYSQL LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
postgres: dummy
make clean
make BASE=POSTGRES LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
db2: dummy
make clean
make BASE=DB2 LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
openingres: dummy
make clean
make BASE=OPENINGRES LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
unixodbc: dummy
make clean
make BASE=unixODBC LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
oraclecfo: dummy
make clean
make BASE=ORACLECFO LIB_DIR=$@ all
mkdir -p $@
$(CP) $(LIB_C) $(LIB_A) $(LIB_CMI) $(LIB) $(LIB_OPT) $(DLL) META $@/
@echo Libs are in $@/
# For all databases
###################
all: lib opt
opt: lib_opt META
$(LIB_C): $(OBJFILES)
$(RM) $@
$(AR) $@ $(OBJFILES)
$(RANLIB) $@
$(LIB): $(OBJOCAML) $(LIBOBJ)
$(OCAMLC) -a -linkall -custom -o $@ -cclib -locamlodbc \
$(LINKFLAGS) $(OBJOCAML) $(LIBOBJ)
$(LIB_OPT): $(OBJOCAML_OPT) $(LIBOBJ_OPT) $(LIB_C)
$(OCAMLOPT) -a -linkall -o $(LIB_OPT) -cclib -locamlodbc \
$(LINKFLAGS) $(OBJOCAML_OPT) $(LIBOBJ_OPT)
META : DESTDIR=$(shell ocamlfind printconf destdir)
META :
@echo 'name="ocamlodbc_$(LIB_DIR)"' > $@
@echo 'version="'`grep "let version =" ocamlodbc.ml | cut -d'"' -f 2`'"' >> $@
@echo 'requires=""' >> $@
# echo 'directory="+ocamlodbc/$(LIB_DIR)"' >> $@
@echo 'archive(byte)="$(LIB)"' >> $@
@echo 'archive(native)="$(LIB_OPT)"' >> $@
@echo 'linkopts="-ccopt -L$(DESTDIR)/ocamlodbc_$(LIB_DIR)"' >> $@
#libocaml_odbc.cmo: $(OBJOCAML) $(LIBOBJ)
# cp libocaml_odbc.cmo libocaml_odbc.cmo
#libocaml_odbc.cmx: $(OBJOCAML_OPT) $(LIBOBJ_OPT)
# cp libocaml_odbc.cmx libocaml_odbc.cmx
lib: $(LIB_CMI) $(LIB)
lib_opt: $(LIB_CMI) $(LIB_OPT)
clean:
$(RM) *~ #*# *-
$(RM) *.o *.cmi *.cmo *.cma *.cmx *.cmxa *.a *.so META
distclean: clean
$(RM) master.Makefile config.*
# documentation :
#################
doc: dummy
$(MKDIR) doc
$(OCAMLDOC) $(OCAMLPP) $(COMPFLAGS) -d doc -html \
-dump doc/ocamlodbc.odoc ocamlodbc.mli ocamlodbc.ml
@echo Documentation is in doc/index.html
distribdoc:
$(MKDIR) $@
$(OCAMLDOC) $(OCAMLPP) $(COMPFLAGS) -d $@ -html \
-css-style "../style.css" ocamlodbc.mli ocamlodbc.ml
@echo Distrib documentation is in $@/
# headers :
###########
headers: dummy
headache -h lgpl_header -c ~/.headache_config *.ml *.mli *.c \
configure.in configure master.Makefile.in Makefile
headache -h gpl_header -c ~/.headache_config \
Biniki/*.ml \
Exemples/*.ml
noheaders: dummy
headache -r -c ~/.headache_config *.ml *.mli \
configure.in configure master.Makefile.in \
Exemples/*.ml \
Biniki/*.ml
# installation :
################
.PHONY : install
install:
@echo "Installation instructions:"
@echo ' To install using findlib type: "make findlib_install"'
@echo ' To install directly type : "make direct_install"'
direct_install: dummy
if test -d $(INSTALL_BINDIR); then : ; else $(MKDIR) $(INSTALL_BINDIR); fi
if test -d $(INSTALL_LIBDIR); then : ; else $(MKDIR) $(INSTALL_LIBDIR); fi
for i in mysql postgres db2 unixodbc openingres oraclecfo ; \
do (if test -d $$i ; then ($(MKDIR) $(INSTALL_LIBDIR)/$$i ; $(CP) $$i/* $(INSTALL_LIBDIR)/$$i/) fi) ; done
findlib_install: META dummy
for i in mysql postgres db2 unixodbc openingres oraclecfo ; do \
if [ -d $$i ]; then \
if (ocamlfind list | grep ocamlodbc_$$i >/dev/null); then ocamlfind remove ocamlodbc_$$i; fi; \
ocamlfind install ocamlodbc_$$i $$i/META `find $$i -not -name META -type f`; \
fi; \
done
# common rules
.depend depend:: $(wildcard *.ml) $(wildcard *.mli)
rm -f .depend
$(OCAMLDEP) $(INCLUDES) $^ > .depend
.SUFFIXES: .c .o
ocaml_odbc_c.o :ocaml_odbc_c.c
$(CC) -c $(C_COMPFLAGS) $<
dummy:
include .depend
ocamlodbc-2.15/Makefile.nt 0000644 0027420 0051216 00000010741 10635510403 015337 0 ustar guesdon cristal # ###########################################################################
# MetaStack Solutions Ltd. #
# ###########################################################################
# OCamlODBC Win32/MinGW Makefile #
# ###########################################################################
# Copyright (c) 2006 MetaStack Solutions Ltd. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as #
# published by the Free Software Foundation; either version 2.1 of the #
# License, or 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 #
# Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# #
# ###########################################################################
# Author: David Allsopp #
# 4-Jun-2006 #
# ###########################################################################
OCAMLC=ocamlc
OCAMLOPT=ocamlopt
OCAMLDEP=ocamldep
OCAMLDOC=ocamldoc
OCAMLFIND=ocamlfind
GCC=gcc -mno-cygwin
AR=ar
LIB=ocamlodbc
BYTE_LIB=$(LIB).cma
BYTE_LIB_DLL=dll$(LIB).dll
OPT_LIB=$(LIB).cmxa
OPT_LIB_A=lib$(LIB).a
MKDIR=mkdir -p
CP=cp -f
RM=@rm -f
include Makefile.config
all: lib lib_opt META
lib: ocamlodbc.cma dllocamlodbc.dll
lib_opt: ocamlodbc.cmxa libocamlodbc.a
$(BYTE_LIB): ocaml_odbc.cmi ocaml_odbc.cmo ocamlodbc.cmi ocamlodbc.cmo
$(OCAMLC) -a -o $@ ocaml_odbc.cmo ocamlodbc.cmo -dllib -locamlodbc
$(OPT_LIB): ocaml_odbc.cmi ocaml_odbc.cmx ocamlodbc.cmi ocamlodbc.cmx
$(OCAMLOPT) -a -o $@ ocaml_odbc.cmx ocamlodbc.cmx -cclib -locamlodbc -cclib -lodbc32
ocaml_odbc_c.o: ocaml_odbc_c.c
$(GCC) -c -DODBC3 -DWIN32 -I `cygpath $(OCAMLLIBDIR)/caml` -I /usr/include/w32api ocaml_odbc_c.c
$(BYTE_LIB_DLL): ocaml_odbc_c.o
$(GCC) -shared -L `cygpath $(OCAMLLIBDIR)` -L `which ocamlrun.dll | sed -e 's/\/ocamlrun.dll$$//'` -o $@ ocaml_odbc_c.o -lodbc32 -locamlrun
$(OPT_LIB_A): ocaml_odbc_c.o
$(GCC) -c -DODBC3 -DWIN32 -I `cygpath $(OCAMLLIBDIR)/caml` -I /usr/include/w32api ocaml_odbc_c.c
$(AR) rsc $(OPT_LIB_A) ocaml_odbc_c.o
META:
@echo 'name="$(LIB)"' > $@
@echo 'version="'`grep "let version =" ocamlodbc.ml | cut -d'"' -f 2`'"' >> $@
@echo 'requires=""' >> $@
@echo 'archive(byte)="$(BYTE_LIB)"' >> $@
@echo 'archive(native)="$(OPT_LIB)"' >> $@
doc: doc/index.html
doc/index.html: ocamlodbc.mli ocamlodbc.ml
$(MKDIR) doc
$(OCAMLDOC) -d doc -html -dump doc/ocamlodbc.odoc ocamlodbc.mli ocamlodbc.ml
@echo Documentation is in doc/index.html
install: all
@echo "Installation instructions:"
@echo ' To install OCamlODBC using findlib type: "make -f Makefile.nt findlib_install"'
@echo ' To install OCamlODBC directly type: "make -f Makefile.nt direct_install"'
direct_install: lib lib_opt
$(CP) ocamlodbc.cmi $(BYTE_LIB) $(OPT_LIB) $(OPT_LIB_A) $(LIB).a `cygpath $(OCAMLLIBDIR)`
$(CP) $(BYTE_LIB_DLL) `cygpath $(OCAMLLIBDIR)/stublibs`
findlib_install: lib lib_opt META
$(OCAMLFIND) install $(LIB) META ocamlodbc.cmi $(BYTE_LIB) $(OPT_LIB) $(LIB).a $(OPT_LIB_A) $(BYTE_LIB_DLL)
.depend: *.ml *.mli
$(OCAMLDEP) *.ml *.mli > .depend
Makefile.config:
./configure.nt
include .depend
clean:
$(RM) .depend Makefile.config $(BYTE_LIB) $(BYTE_LIB_DLL) $(OPT_LIB) $(OPT_LIB_A) $(LIB).a ocamlodbc.{o,cmi,cmx,cmo,cmi} ocaml_odbc.{o,cmi,cmx,cmo,cmi} ocaml_odbc_c.o
.PHONY: all clean install direct_install findlib_install
%.cmi: %.mli
$(OCAMLC) -c $<
%.cmo: %.ml
$(OCAMLC) -c $<
%.cmo %.cmi: %.ml
$(OCAMLC) -c $<
%.cmx: %.ml
$(OCAMLOPT) -c $<
%.cmx %.cmi: %.ml
$(OCAMLOPT) -c $<
ocamlodbc-2.15/configure 0000755 0027420 0051216 00000210123 10571054367 015175 0 ustar guesdon cristal ###############################################################################
# OCamlODBC #
# #
# Copyright (C) 2004 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published #
# by the Free Software Foundation; either version 2.1 of the License, or #
# 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# #
# Contact: Maxence.Guesdon@inria.fr #
###############################################################################
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
# Defaults:
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
ac_help="$ac_help
--with-pg-incs=INCLUDES (-I options to find PostgreSQL ODBC headers)"
ac_help="$ac_help
--with-pg-libs=DIRS (-L options to find PostgreSQL ODBC libs)"
ac_help="$ac_help
--with-mysql-incs=INCLUDES (-I options to find MySQL ODBC headers)"
ac_help="$ac_help
--with-mysql-libs=DIRS (-L options to find MySQL ODBC libs)"
ac_help="$ac_help
--with-unixodbc-incs=INCLUDES (-I options to find unixODBC headers)"
ac_help="$ac_help
--with-unixodbc-libs=DIRS (-L options to find unixODBC libs)"
ac_help="$ac_help
--with-db2-incs=INCLUDES (-I options to find DB2 headers)"
ac_help="$ac_help
--with-db2-libs=DIRS (-L options to find DB2 libs)"
ac_help="$ac_help
--with-ingres-incs=INCLUDES (-I options to find OPENINGRES headers)"
ac_help="$ac_help
--with-ingres-libs=DIRS (-L options to find OPENINGRES libs)"
ac_help="$ac_help
--with-oraclecfo-incs=INCLUDES (-I options to find Connect for ODBC headers)"
ac_help="$ac_help
--with-oraclecfo-libs=DIRS (-L options to find Connect for ODBC libs)"
# Initialize some variables set by options.
# The variables have the same names as the options, with
# dashes changed to underlines.
build=NONE
cache_file=./config.cache
exec_prefix=NONE
host=NONE
no_create=
nonopt=NONE
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
target=NONE
verbose=
x_includes=NONE
x_libraries=NONE
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
ac_prev=
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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case "$ac_option" in
-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 ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build="$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" ;;
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir="$ac_optarg" ;;
-disable-* | --disable-*)
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
eval "enable_${ac_feature}=no" ;;
-enable-* | --enable-*)
ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "enable_${ac_feature}='$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)
# 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 << EOF
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print \`checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
EOF
cat << EOF
Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed]
--target=TARGET configure for TARGET [TARGET=HOST]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
EOF
if test -n "$ac_help"; then
echo "--enable and --with options recognized:$ac_help"
fi
exit 0 ;;
-host | --host | --hos | --ho)
ac_prev=host ;;
-host=* | --host=* | --hos=* | --ho=*)
host="$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" ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
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)
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" ;;
-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 ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target="$ac_optarg" ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "with_${ac_package}='$ac_optarg'" ;;
-without-* | --without-*)
ac_package=`echo $ac_option|sed -e 's/-*without-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
eval "with_${ac_package}=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" ;;
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
;;
*)
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
echo "configure: warning: $ac_option: invalid host type" 1>&2
fi
if test "x$nonopt" != xNONE; then
{ echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
fi
nonopt="$ac_option"
;;
esac
done
if test -n "$ac_prev"; then
{ echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
fi
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 6 checking for... messages and results
# 5 compiler messages saved in config.log
if test "$silent" = yes; then
exec 6>/dev/null
else
exec 6>&1
fi
exec 5>./config.log
echo "\
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
" 1>&5
# Strip out --no-create and --no-recursion so they do not pile up.
# Also quote any args containing shell metacharacters.
ac_configure_args=
for ac_arg
do
case "$ac_arg" in
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c) ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
esac
done
# NLS nuisances.
# Only set these to C if already set. These must not be set unconditionally
# because not all systems understand e.g. LANG=C (notably SCO).
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
# Non-C LC_CTYPE values break the ctype check.
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo > confdefs.h
# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
ac_unique_file=ocaml_odbc.ml
# 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 its parent.
ac_prog=$0
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
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
if test "$ac_srcdir_defaulted" = yes; then
{ echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
else
{ echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
fi
fi
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
if test "x$prefix" != xNONE; then
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
else
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
fi
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
echo "loading site script $ac_site_file"
. "$ac_site_file"
fi
done
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
ac_exeext=
ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
ac_n= ac_c='
' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
else
ac_n= ac_c='\c' ac_t=
fi
# Check for Ocaml compilers
# we first look for ocamlc in the path; if not present, we fail
# Extract the first word of "ocamlc", so it can be a program name with args.
set dummy ocamlc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:549: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLC"; then
ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLC="`which ocamlc`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLC" && ac_cv_prog_OCAMLC="no"
fi
fi
OCAMLC="$ac_cv_prog_OCAMLC"
if test -n "$OCAMLC"; then
echo "$ac_t""$OCAMLC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLC" = no ; then
{ echo "configure: error: Cannot find ocamlc." 1>&2; exit 1; }
fi
# we look for the directory of ocamlc in $OCAMLC
OCAMLBIN=`dirname $OCAMLC`
# we extract Ocaml version number and library path
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
echo "ocaml version is $OCAMLVERSION"
OCAMLLIB=`$OCAMLC -v | tail -1 | cut -f 4 -d " "`
echo "ocaml library path is $OCAMLLIB"
# then we look for ocamlopt; if not present, we issue a warning
# if the version is not the same, we also discard it
# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not
# Extract the first word of "ocamlopt", so it can be a program name with args.
set dummy ocamlopt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:595: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLOPT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLOPT"; then
ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLOPT="`which ocamlopt`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLOPT" && ac_cv_prog_OCAMLOPT="no"
fi
fi
OCAMLOPT="$ac_cv_prog_OCAMLOPT"
if test -n "$OCAMLOPT"; then
echo "$ac_t""$OCAMLOPT" 1>&6
else
echo "$ac_t""no" 1>&6
fi
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
echo "configure: warning: Cannot find ocamlopt; bytecode compilation only." 1>&2
else
echo $ac_n "checking ocamlopt version""... $ac_c" 1>&6
echo "configure:627: checking ocamlopt version" >&5
TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
echo "$ac_t""differs from ocamlc; ocamlopt discarded." 1>&6
OCAMLOPT=no
else
echo "$ac_t""ok" 1>&6
OCAMLBEST=opt
fi
fi
# checking for ocamlc.opt
# Extract the first word of "ocamlc.opt", so it can be a program name with args.
set dummy ocamlc.opt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:642: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLCDOTOPT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLCDOTOPT"; then
ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLCDOTOPT="`which ocamlc.opt`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLCDOTOPT" && ac_cv_prog_OCAMLCDOTOPT="no"
fi
fi
OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT"
if test -n "$OCAMLCDOTOPT"; then
echo "$ac_t""$OCAMLCDOTOPT" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLCDOTOPT" != no ; then
echo $ac_n "checking ocamlc.opt version""... $ac_c" 1>&6
echo "configure:671: checking ocamlc.opt version" >&5
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
echo "$ac_t""differs from ocamlc; ocamlc.opt discarded." 1>&6
else
echo "$ac_t""ok" 1>&6
OCAMLC=$OCAMLCDOTOPT
fi
fi
# checking for ocamlopt.opt
if test "$OCAMLOPT" != no ; then
# Extract the first word of "ocamlopt.opt", so it can be a program name with args.
set dummy ocamlopt.opt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:686: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLOPTDOTOPT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLOPTDOTOPT"; then
ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLOPTDOTOPT="`which ocamlopt.opt`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLOPTDOTOPT" && ac_cv_prog_OCAMLOPTDOTOPT="no"
fi
fi
OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT"
if test -n "$OCAMLOPTDOTOPT"; then
echo "$ac_t""$OCAMLOPTDOTOPT" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLOPTDOTOPT" != no ; then
echo $ac_n "checking ocamlc.opt version""... $ac_c" 1>&6
echo "configure:715: checking ocamlc.opt version" >&5
TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVER" != "$OCAMLVERSION" ; then
echo "$ac_t""differs from ocamlc; ocamlopt.opt discarded." 1>&6
else
echo "$ac_t""ok" 1>&6
OCAMLOPT=$OCAMLOPTDOTOPT
fi
fi
fi
# ocamldep, ocamllex and ocamlyacc should also be present in the path
# Extract the first word of "ocamldep", so it can be a program name with args.
set dummy ocamldep; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:730: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLDEP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLDEP"; then
ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLDEP="`which ocamldep`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLDEP" && ac_cv_prog_OCAMLDEP="no"
fi
fi
OCAMLDEP="$ac_cv_prog_OCAMLDEP"
if test -n "$OCAMLDEP"; then
echo "$ac_t""$OCAMLDEP" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLDEP" = no ; then
{ echo "configure: error: Cannot find ocamldep." 1>&2; exit 1; }
fi
# Extract the first word of "ocamllex", so it can be a program name with args.
set dummy ocamllex; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:764: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLLEX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLLEX"; then
ac_cv_prog_OCAMLLEX="$OCAMLLEX" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLLEX="`which ocamllex`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLLEX" && ac_cv_prog_OCAMLLEX="no"
fi
fi
OCAMLLEX="$ac_cv_prog_OCAMLLEX"
if test -n "$OCAMLLEX"; then
echo "$ac_t""$OCAMLLEX" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLLEX" = no ; then
{ echo "configure: error: Cannot find ocamllex." 1>&2; exit 1; }
fi
# Extract the first word of "ocamlyacc", so it can be a program name with args.
set dummy ocamlyacc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:798: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLYACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLYACC"; then
ac_cv_prog_OCAMLYACC="$OCAMLYACC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLYACC="`which ocamlyacc`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLYACC" && ac_cv_prog_OCAMLYACC="no"
fi
fi
OCAMLYACC="$ac_cv_prog_OCAMLYACC"
if test -n "$OCAMLYACC"; then
echo "$ac_t""$OCAMLYACC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test "$OCAMLYACC" = no ; then
{ echo "configure: error: Cannot find ocamlyacc." 1>&2; exit 1; }
fi
# Extract the first word of "ocamldoc", so it can be a program name with args.
set dummy ocamldoc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:832: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OCAMLDOC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$OCAMLDOC"; then
ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_OCAMLDOC="`which ocamldoc`"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_OCAMLDOC" && ac_cv_prog_OCAMLDOC="no"
fi
fi
OCAMLDOC="$ac_cv_prog_OCAMLDOC"
if test -n "$OCAMLDOC"; then
echo "$ac_t""$OCAMLDOC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
# Check for databases
############ POSTGRES ##################
POSTGRES=yes
POSTGRES_LIBS=
echo "$ac_t""======== configure PostgreSQL ========" 1>&6
# Check whether --with-pg_incs or --without-pg_incs was given.
if test "${with_pg_incs+set}" = set; then
withval="$with_pg_incs"
if test "$withval" != "no" ; then
POSTGRES_INCS="$withval"
else
POSTGRES_INCS=""
fi
fi
# Check whether --with-pg_libs or --without-pg_libs was given.
if test "${with_pg_libs+set}" = set; then
withval="$with_pg_libs"
if test "$withval" != "no" ; then
POSTGRES_LIBDIRS="$withval"
else
POSTGRES_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $POSTGRES_INCS $POSTGRES_LIBDIRS"
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:890: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# This must be in double quotes, not single quotes, because CPP may get
# substituted into the Makefile and "${CC-cc}" will confuse make.
CPP="${CC-cc} -E"
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:911: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
CPP=/lib/cpp
fi
rm -f conftest*
fi
rm -f conftest*
fi
rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
else
ac_cv_prog_CPP="$CPP"
fi
echo "$ac_t""$CPP" 1>&6
for ac_hdr in iodbc.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:973: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:983: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
POSTGRES=no
fi
done
for ac_hdr in isql.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1014: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
POSTGRES=no
fi
done
for ac_hdr in isqlext.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1055: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1065: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
POSTGRES=no
fi
done
if test "$POSTGRES" = "no"; then
echo "$ac_t""PostgreSQL ODBC headers not found" 1>&6
else
echo "$ac_t""PostgreSQL ODBC headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -lpsqlodbc""... $ac_c" 1>&6
echo "configure:1097: checking for SQLAllocEnv in -lpsqlodbc" >&5
ac_lib_var=`echo psqlodbc'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lpsqlodbc $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
POSTGRES_LIBS=-lpsqlodbc
else
echo "$ac_t""no" 1>&6
fi
fi
if test "$POSTGRES_LIBS" = "no"; then
echo "$ac_t""No PostgreSQL ODBC support" 1>&6
else
echo "$ac_t""PostgreSQL ODBC support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ MYSQL ##################
MYSQL=yes
MYSQL_LIBS=no
echo "$ac_t""======== configure MySQL ========" 1>&6
# Check whether --with-mysql_incs or --without-mysql_incs was given.
if test "${with_mysql_incs+set}" = set; then
withval="$with_mysql_incs"
if test "$withval" != "no" ; then
MYSQL_INCS="$withval"
else
MYSQL_INCS=""
fi
fi
# Check whether --with-mysql_libs or --without-mysql_libs was given.
if test "${with_mysql_libs+set}" = set; then
withval="$with_mysql_libs"
if test "$withval" != "no" ; then
MYSQL_LIBDIRS="$withval"
else
MYSQL_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $MYSQL_INCS $MYSQL_LIBDIRS"
for ac_hdr in iodbc.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1176: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1186: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
MYSQL=no
fi
done
for ac_hdr in isql.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1217: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1227: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
MYSQL=no
fi
done
for ac_hdr in isqlext.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1258: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1268: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
MYSQL=no
fi
done
if test "$MYSQL" = "no"; then
echo "$ac_t""MySQL ODBC headers not found" 1>&6
else
echo "$ac_t""MySQL ODBC headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -lmyodbc_mysql""... $ac_c" 1>&6
echo "configure:1300: checking for SQLAllocEnv in -lmyodbc_mysql" >&5
ac_lib_var=`echo myodbc_mysql'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lmyodbc_mysql $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
MYSQL_LIBS=-lmyodbc_mysql
else
echo "$ac_t""no" 1>&6
fi
fi
if test "$MYSQL_LIBS" = "no"; then
echo "$ac_t""No MySQL ODBC support" 1>&6
else
echo "$ac_t""MySQL ODBC support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ UNIXODBC ##################
UNIXODBC=yes
UNIXODBC_LIBS=no
echo "$ac_t""======== configure unixODBC ========" 1>&6
# Check whether --with-unixodbc_incs or --without-unixodbc_incs was given.
if test "${with_unixodbc_incs+set}" = set; then
withval="$with_unixodbc_incs"
if test "$withval" != "no" ; then
UNIXODBC_INCS="$withval"
else
UNIXODBC_INCS=""
fi
fi
# Check whether --with-unixodbc_libs or --without-unixodbc_libs was given.
if test "${with_unixodbc_libs+set}" = set; then
withval="$with_unixodbc_libs"
if test "$withval" != "no" ; then
UNIXODBC_LIBDIRS="$withval"
else
UNIXODBC_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $UNIXODBC_INCS $UNIXODBC_LIBDIRS"
for ac_hdr in odbcinst.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1379: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1389: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
UNIXODBC=no
fi
done
for ac_hdr in sql.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1420: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1430: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
UNIXODBC=no
fi
done
for ac_hdr in sqlext.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1461: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
UNIXODBC=no
fi
done
if test "$UNIXODBC" = "no"; then
echo "$ac_t""unixODBC headers not found" 1>&6
else
echo "$ac_t""unixODBC headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -lodbc""... $ac_c" 1>&6
echo "configure:1503: checking for SQLAllocEnv in -lodbc" >&5
ac_lib_var=`echo odbc'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lodbc $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
UNIXODBC_LIBS=-lodbc
else
echo "$ac_t""no" 1>&6
fi
fi
if test "$UNIXODBC_LIBS" = "no"; then
echo "$ac_t""No unixODBC support" 1>&6
else
echo "$ac_t""unixODBC support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ DB2 ##################
DB2=yes
DB2_LIBS=no
echo "$ac_t""======== configure DB2 ========" 1>&6
# Check whether --with-db2_incs or --without-db2_incs was given.
if test "${with_db2_incs+set}" = set; then
withval="$with_db2_incs"
if test "$withval" != "no" ; then
DB2_INCS="$withval"
else
DB2_INCS=""
fi
fi
# Check whether --with-db2_libs or --without-db2_libs was given.
if test "${with_db2_libs+set}" = set; then
withval="$with_db2_libs"
if test "$withval" != "no" ; then
DB2_LIBDIRS="$withval"
else
DB2_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $DB2_INCS $DB2_LIBDIRS"
for ac_hdr in sqlcli1.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1582: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1592: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
DB2=no
fi
done
if test "$DB2" = "no"; then
echo "$ac_t""DB2 headers not found" 1>&6
else
echo "$ac_t""DB2 headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -ldb2""... $ac_c" 1>&6
echo "configure:1624: checking for SQLAllocEnv in -ldb2" >&5
ac_lib_var=`echo db2'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-ldb2 $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
DB2_LIBS=-ldb2
else
echo "$ac_t""no" 1>&6
fi
fi
if test "$DB2_LIBS" = "no"; then
echo "$ac_t""No DB2 support" 1>&6
else
echo "$ac_t""DB2 support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ OPENINGRES ##################
OPENINGRES=yes
OPENINGRES_LIBS=no
echo "$ac_t""======== configure OPENINGRES ========" 1>&6
# Check whether --with-db2_incs or --without-db2_incs was given.
if test "${with_db2_incs+set}" = set; then
withval="$with_db2_incs"
if test "$withval" != "no" ; then
OPENINGRES_INCS="$withval"
else
OPENINGRES_INCS=""
fi
fi
# Check whether --with-db2_libs or --without-db2_libs was given.
if test "${with_db2_libs+set}" = set; then
withval="$with_db2_libs"
if test "$withval" != "no" ; then
OPENINGRES_LIBDIRS="$withval"
else
OPENINGRES_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OPENINGRES_INCS $OPENINGRES_LIBDIRS"
for ac_hdr in sqlext.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1703: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1713: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
OPENINGRES=no
fi
done
if test "$OPENINGRES" = "no"; then
echo "$ac_t""OPENINGRES headers not found" 1>&6
else
echo "$ac_t""OPENINGRES headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -lodbc""... $ac_c" 1>&6
echo "configure:1745: checking for SQLAllocEnv in -lodbc" >&5
ac_lib_var=`echo odbc'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lodbc $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
OPENINGRES_LIBS=-lodbc
else
echo "$ac_t""no" 1>&6
fi
fi
if test "$OPENINGRES_LIBS" = "no"; then
echo "$ac_t""No OPENINGRES support" 1>&6
else
echo "$ac_t""OPENINGRES support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ ORACLE through DataDirect "Connect for ODBC" driver ##################
ORACLECFO=yes
ORACLECFO_LIBS=no
echo "$ac_t""======== configure ORACLE through DataDirect "Connect for ODBC" driver ========" 1>&6
# Check whether --with-oraclecfo_incs or --without-oraclecfo_incs was given.
if test "${with_oraclecfo_incs+set}" = set; then
withval="$with_oraclecfo_incs"
if test "$withval" != "no" ; then
ORACLECFO_INCS="$withval"
else
ORACLECFO_INCS=""
fi
fi
# Check whether --with-oraclecfo_libs or --without-oraclecfo_libs was given.
if test "${with_oraclecfo_libs+set}" = set; then
withval="$with_oraclecfo_libs"
if test "$withval" != "no" ; then
ORACLECFO_LIBDIRS="$withval"
else
ORACLECFO_LIBDIRS=""
fi
fi
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $ORACLECFO_INCS $ORACLECFO_LIBDIRS"
echo $ORACLECFO_INCS
for ac_hdr in odbcinst.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1824: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1834: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
ORACLECFO=no
fi
done
for ac_hdr in sql.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1865: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1875: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
ORACLECFO=no
fi
done
for ac_hdr in sqlext.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1906: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1916: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <&6
ORACLECFO=no
fi
done
if test "ORACLECFO" = "no"; then
echo "$ac_t""ORACLECFO headers not found" 1>&6
else
echo "$ac_t""ORACLECFO headers found" 1>&6
echo $ac_n "checking for SQLAllocEnv in -lodbc""... $ac_c" 1>&6
echo "configure:1948: checking for SQLAllocEnv in -lodbc" >&5
ac_lib_var=`echo odbc'_'SQLAllocEnv | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lodbc $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
ORACLECFO_LIBS=-lodbc
else
echo "$ac_t""no" 1>&6
fi
fi
if test "ORACLECFO_LIBS" = "no"; then
echo "$ac_t""No Oracle through DataDirect "Connect for ODBC" driver support" 1>&6
else
echo "$ac_t""ORACLECFO support" 1>&6
fi
CPP_FLAGS="$OLD_CPPFLAGS"
# substitutions to perform
# Finally create the master.Makefile from master.Makefile.in
trap '' 1 2 15
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Any assignment to VPATH causes Sun make to only execute
# the first set of double-colon rules, so remove it if not needed.
# If there is a colon in the path, we need to keep it.
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
echo creating $CONFIG_STATUS
rm -f $CONFIG_STATUS
cat > $CONFIG_STATUS </dev/null | sed 1q`:
#
# $0 $ac_configure_args
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
for ac_option
do
case "\$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
*) echo "\$ac_cs_usage"; exit 1 ;;
esac
done
ac_given_srcdir=$srcdir
trap 'rm -fr `echo "master.Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
s%@exec_prefix@%$exec_prefix%g
s%@prefix@%$prefix%g
s%@program_transform_name@%$program_transform_name%g
s%@bindir@%$bindir%g
s%@sbindir@%$sbindir%g
s%@libexecdir@%$libexecdir%g
s%@datadir@%$datadir%g
s%@sysconfdir@%$sysconfdir%g
s%@sharedstatedir@%$sharedstatedir%g
s%@localstatedir@%$localstatedir%g
s%@libdir@%$libdir%g
s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@OCAMLC@%$OCAMLC%g
s%@OCAMLOPT@%$OCAMLOPT%g
s%@OCAMLCDOTOPT@%$OCAMLCDOTOPT%g
s%@OCAMLOPTDOTOPT@%$OCAMLOPTDOTOPT%g
s%@OCAMLDEP@%$OCAMLDEP%g
s%@OCAMLLEX@%$OCAMLLEX%g
s%@OCAMLYACC@%$OCAMLYACC%g
s%@OCAMLDOC@%$OCAMLDOC%g
s%@CPP@%$CPP%g
s%@OCAMLBEST@%$OCAMLBEST%g
s%@OCAMLVERSION@%$OCAMLVERSION%g
s%@OCAMLLIB@%$OCAMLLIB%g
s%@OCAMLBIN@%$OCAMLBIN%g
s%@POSTGRES_INCS@%$POSTGRES_INCS%g
s%@POSTGRES_LIBDIRS@%$POSTGRES_LIBDIRS%g
s%@POSTGRES_LIBS@%$POSTGRES_LIBS%g
s%@MYSQL_INCS@%$MYSQL_INCS%g
s%@MYSQL_LIBDIRS@%$MYSQL_LIBDIRS%g
s%@MYSQL_LIBS@%$MYSQL_LIBS%g
s%@UNIXODBC_INCS@%$UNIXODBC_INCS%g
s%@UNIXODBC_LIBDIRS@%$UNIXODBC_LIBDIRS%g
s%@UNIXODBC_LIBS@%$UNIXODBC_LIBS%g
s%@DB2_INCS@%$DB2_INCS%g
s%@DB2_LIBDIRS@%$DB2_LIBDIRS%g
s%@DB2_LIBS@%$DB2_LIBS%g
s%@OPENINGRES_INCS@%$OPENINGRES_INCS%g
s%@OPENINGRES_LIBDIRS@%$OPENINGRES_LIBDIRS%g
s%@OPENINGRES_LIBS@%$OPENINGRES_LIBS%g
s%@ORACLECFO_INCS@%$ORACLECFO_INCS%g
s%@ORACLECFO_LIBDIRS@%$ORACLECFO_LIBDIRS%g
s%@ORACLECFO_LIBS@%$ORACLECFO_LIBS%g
CEOF
EOF
cat >> $CONFIG_STATUS <<\EOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
EOF
cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
EOF
cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
exit 0
EOF
chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
chmod a-w master.Makefile
ocamlodbc-2.15/configure.in 0000644 0027420 0051216 00000027776 10634574313 015621 0 ustar guesdon cristal ###############################################################################
# OCamlODBC #
# #
# Copyright (C) 2004 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published #
# by the Free Software Foundation; either version 2.1 of the License, or #
# 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# #
# Contact: Maxence.Guesdon@inria.fr #
###############################################################################
# autoconf input based on sample by Jean-Christophe Fillitre
# check for one particular file of the sources
define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl
AC_INIT(ocaml_odbc.ml)
# Check for Ocaml compilers
# we first look for ocamlc in the path; if not present, we fail
AC_CHECK_PROG(OCAMLC,ocamlc,`which ocamlc`,no)
if test "$OCAMLC" = no ; then
AC_MSG_ERROR(Cannot find ocamlc.)
fi
# we look for the directory of ocamlc in $OCAMLC
OCAMLBIN=`dirname $OCAMLC`
# we extract Ocaml version number and library path
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
echo "ocaml version is $OCAMLVERSION"
OCAMLLIB=`$OCAMLC -v | tail -1 | cut -f 4 -d " "`
echo "ocaml library path is $OCAMLLIB"
# then we look for ocamlopt; if not present, we issue a warning
# if the version is not the same, we also discard it
# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not
AC_CHECK_PROG(OCAMLOPT,ocamlopt,`which ocamlopt`,no)
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
else
AC_MSG_CHECKING(ocamlopt version)
TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.)
OCAMLOPT=no
else
AC_MSG_RESULT(ok)
OCAMLBEST=opt
fi
fi
# Now we need ocamlmklib
# if the version is not the same, we also discard it
# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not
AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,`which ocamlmklib`,no)
if test "$OCAMLMKLIB" = no ; then
AC_MSG_ERROR(Cannot find ocamlmklib)
fi
# checking for ocamlc.opt
AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,`which ocamlc.opt`,no)
if test "$OCAMLCDOTOPT" != no ; then
AC_MSG_CHECKING(ocamlc.opt version)
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.)
else
AC_MSG_RESULT(ok)
OCAMLC=$OCAMLCDOTOPT
fi
fi
# checking for ocamlopt.opt
if test "$OCAMLOPT" != no ; then
AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,`which ocamlopt.opt`,no)
if test "$OCAMLOPTDOTOPT" != no ; then
AC_MSG_CHECKING(ocamlc.opt version)
TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVER" != "$OCAMLVERSION" ; then
AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.)
else
AC_MSG_RESULT(ok)
OCAMLOPT=$OCAMLOPTDOTOPT
fi
fi
fi
# ocamldep, ocamllex and ocamlyacc should also be present in the path
AC_CHECK_PROG(OCAMLDEP,ocamldep,`which ocamldep`,no)
if test "$OCAMLDEP" = no ; then
AC_MSG_ERROR(Cannot find ocamldep.)
fi
AC_CHECK_PROG(OCAMLLEX,ocamllex,`which ocamllex`,no)
if test "$OCAMLLEX" = no ; then
AC_MSG_ERROR(Cannot find ocamllex.)
fi
AC_CHECK_PROG(OCAMLYACC,ocamlyacc,`which ocamlyacc`,no)
if test "$OCAMLYACC" = no ; then
AC_MSG_ERROR(Cannot find ocamlyacc.)
fi
AC_CHECK_PROG(OCAMLDOC,ocamldoc,`which ocamldoc`,no)
# Check for databases
############ POSTGRES ##################
POSTGRES=yes
POSTGRES_LIBS=
AC_MSG_RESULT(======== configure PostgreSQL ========)
AC_ARG_WITH(pg_incs, [ --with-pg-incs=INCLUDES (-I options to find PostgreSQL ODBC headers)],
if test "$withval" != "no" ; then
POSTGRES_INCS="$withval"
else
POSTGRES_INCS=""
fi)
AC_ARG_WITH(pg_libs, [ --with-pg-libs=DIRS (-L options to find PostgreSQL ODBC libs)],
if test "$withval" != "no" ; then
POSTGRES_LIBDIRS="$withval"
else
POSTGRES_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $POSTGRES_INCS $POSTGRES_LIBDIRS"
AC_CHECK_HEADERS(iodbc.h,,[POSTGRES=no])
AC_CHECK_HEADERS(isql.h,,[POSTGRES=no])
AC_CHECK_HEADERS(isqlext.h,,[POSTGRES=no])
if test "$POSTGRES" = "no"; then
AC_MSG_RESULT(PostgreSQL ODBC headers not found)
else
AC_MSG_RESULT(PostgreSQL ODBC headers found)
dnl Checking for PostgreSQL ODBC lib -lpsqlodbc
AC_CHECK_LIB(psqlodbc,SQLAllocEnv,POSTGRES_LIBS=-lpsqlodbc)
fi
if test "$POSTGRES_LIBS" = "no"; then
AC_MSG_RESULT(No PostgreSQL ODBC support)
else
AC_MSG_RESULT(PostgreSQL ODBC support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ MYSQL ##################
MYSQL=yes
MYSQL_LIBS=no
AC_MSG_RESULT(======== configure MySQL ========)
AC_ARG_WITH(mysql_incs, [ --with-mysql-incs=INCLUDES (-I options to find MySQL ODBC headers)],
if test "$withval" != "no" ; then
MYSQL_INCS="$withval"
else
MYSQL_INCS=""
fi)
AC_ARG_WITH(mysql_libs, [ --with-mysql-libs=DIRS (-L options to find MySQL ODBC libs)],
if test "$withval" != "no" ; then
MYSQL_LIBDIRS="$withval"
else
MYSQL_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $MYSQL_INCS $MYSQL_LIBDIRS"
AC_CHECK_HEADERS(iodbc.h,,[MYSQL=no])
AC_CHECK_HEADERS(isql.h,,[MYSQL=no])
AC_CHECK_HEADERS(isqlext.h,,[MYSQL=no])
if test "$MYSQL" = "no"; then
AC_MSG_RESULT(MySQL ODBC headers not found)
else
AC_MSG_RESULT(MySQL ODBC headers found)
dnl Checking for MySQL ODBC lib -lmyodbc_mysql
AC_CHECK_LIB(myodbc_mysql,SQLAllocEnv,MYSQL_LIBS=-lmyodbc_mysql)
fi
if test "$MYSQL_LIBS" = "no"; then
AC_MSG_RESULT(No MySQL ODBC support)
else
AC_MSG_RESULT(MySQL ODBC support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ UNIXODBC ##################
UNIXODBC=yes
UNIXODBC_LIBS=no
AC_MSG_RESULT(======== configure unixODBC ========)
AC_ARG_WITH(unixodbc_incs, [ --with-unixodbc-incs=INCLUDES (-I options to find unixODBC headers)],
if test "$withval" != "no" ; then
UNIXODBC_INCS="$withval"
else
UNIXODBC_INCS=""
fi)
AC_ARG_WITH(unixodbc_libs, [ --with-unixodbc-libs=DIRS (-L options to find unixODBC libs)],
if test "$withval" != "no" ; then
UNIXODBC_LIBDIRS="$withval"
else
UNIXODBC_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $UNIXODBC_INCS $UNIXODBC_LIBDIRS"
AC_CHECK_HEADERS(odbcinst.h,,[UNIXODBC=no])
AC_CHECK_HEADERS(sql.h,,[UNIXODBC=no])
AC_CHECK_HEADERS(sqlext.h,,[UNIXODBC=no])
if test "$UNIXODBC" = "no"; then
AC_MSG_RESULT(unixODBC headers not found)
else
AC_MSG_RESULT(unixODBC headers found)
dnl Checking for unixODBC lib -lodbc
AC_CHECK_LIB(odbc,SQLAllocEnv,UNIXODBC_LIBS=-lodbc)
fi
if test "$UNIXODBC_LIBS" = "no"; then
AC_MSG_RESULT(No unixODBC support)
else
AC_MSG_RESULT(unixODBC support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ DB2 ##################
DB2=yes
DB2_LIBS=no
AC_MSG_RESULT(======== configure DB2 ========)
AC_ARG_WITH(db2_incs, [ --with-db2-incs=INCLUDES (-I options to find DB2 headers)],
if test "$withval" != "no" ; then
DB2_INCS="$withval"
else
DB2_INCS=""
fi)
AC_ARG_WITH(db2_libs, [ --with-db2-libs=DIRS (-L options to find DB2 libs)],
if test "$withval" != "no" ; then
DB2_LIBDIRS="$withval"
else
DB2_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $DB2_INCS $DB2_LIBDIRS"
AC_CHECK_HEADERS(sqlcli1.h,,[DB2=no])
if test "$DB2" = "no"; then
AC_MSG_RESULT(DB2 headers not found)
else
AC_MSG_RESULT(DB2 headers found)
dnl Checking for DB2 lib -ldb2
AC_CHECK_LIB(db2,SQLAllocEnv,DB2_LIBS=-ldb2)
fi
if test "$DB2_LIBS" = "no"; then
AC_MSG_RESULT(No DB2 support)
else
AC_MSG_RESULT(DB2 support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ OPENINGRES ##################
OPENINGRES=yes
OPENINGRES_LIBS=no
AC_MSG_RESULT(======== configure OPENINGRES ========)
AC_ARG_WITH(db2_incs, [ --with-ingres-incs=INCLUDES (-I options to find OPENINGRES headers)],
if test "$withval" != "no" ; then
OPENINGRES_INCS="$withval"
else
OPENINGRES_INCS=""
fi)
AC_ARG_WITH(db2_libs, [ --with-ingres-libs=DIRS (-L options to find OPENINGRES libs)],
if test "$withval" != "no" ; then
OPENINGRES_LIBDIRS="$withval"
else
OPENINGRES_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OPENINGRES_INCS $OPENINGRES_LIBDIRS"
AC_CHECK_HEADERS(sqlext.h,,[OPENINGRES=no])
if test "$OPENINGRES" = "no"; then
AC_MSG_RESULT(OPENINGRES headers not found)
else
AC_MSG_RESULT(OPENINGRES headers found)
dnl Checking for OPENINGRES lib -lodbc
AC_CHECK_LIB(odbc,SQLAllocEnv,OPENINGRES_LIBS=-lodbc)
fi
if test "$OPENINGRES_LIBS" = "no"; then
AC_MSG_RESULT(No OPENINGRES support)
else
AC_MSG_RESULT(OPENINGRES support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
############ ORACLE through DataDirect "Connect for ODBC" driver ##################
ORACLECFO=yes
ORACLECFO_LIBS=no
AC_MSG_RESULT(======== configure ORACLE through DataDirect "Connect for ODBC" driver ========)
AC_ARG_WITH(oraclecfo_incs, [ --with-oraclecfo-incs=INCLUDES (-I options to find Connect for ODBC headers)],
if test "$withval" != "no" ; then
ORACLECFO_INCS="$withval"
else
ORACLECFO_INCS=""
fi)
AC_ARG_WITH(oraclecfo_libs, [ --with-oraclecfo-libs=DIRS (-L options to find Connect for ODBC libs)],
if test "$withval" != "no" ; then
ORACLECFO_LIBDIRS="$withval"
else
ORACLECFO_LIBDIRS=""
fi)
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $ORACLECFO_INCS $ORACLECFO_LIBDIRS"
AC_CHECK_HEADERS(odbcinst.h,,[ORACLECFO=no])
AC_CHECK_HEADERS(sql.h,,[ORACLECFO=no])
AC_CHECK_HEADERS(sqlext.h,,[ORACLECFO=no])
if test "ORACLECFO" = "no"; then
AC_MSG_RESULT(ORACLECFO headers not found)
else
AC_MSG_RESULT(ORACLECFO headers found)
dnl Checking for ORACLECFO lib -lodbc
AC_CHECK_LIB(odbc,SQLAllocEnv,ORACLECFO_LIBS=-lodbc)
fi
if test "ORACLECFO_LIBS" = "no"; then
AC_MSG_RESULT(No Oracle through DataDirect "Connect for ODBC" driver support)
else
AC_MSG_RESULT(Oracle through DataDirect "Connect for ODBC" driver support)
fi
CPP_FLAGS="$OLD_CPPFLAGS"
# substitutions to perform
AC_SUBST(OCAMLC)
AC_SUBST(OCAMLOPT)
AC_SUBST(OCAMLDEP)
AC_SUBST(OCAMLLEX)
AC_SUBST(OCAMLYACC)
AC_SUBST(OCAMLBEST)
AC_SUBST(OCAMLVERSION)
AC_SUBST(OCAMLLIB)
AC_SUBST(OCAMLDOC)
AC_SUBST(OCAMLBIN)
AC_SUBST(POSTGRES_INCS)
AC_SUBST(POSTGRES_LIBDIRS)
AC_SUBST(POSTGRES_LIBS)
AC_SUBST(MYSQL_INCS)
AC_SUBST(MYSQL_LIBDIRS)
AC_SUBST(MYSQL_LIBS)
AC_SUBST(UNIXODBC_INCS)
AC_SUBST(UNIXODBC_LIBDIRS)
AC_SUBST(UNIXODBC_LIBS)
AC_SUBST(DB2_INCS)
AC_SUBST(DB2_LIBDIRS)
AC_SUBST(DB2_LIBS)
AC_SUBST(OPENINGRES_INCS)
AC_SUBST(OPENINGRES_LIBDIRS)
AC_SUBST(OPENINGRES_LIBS)
AC_SUBST(ORACLECFO_INCS)
AC_SUBST(ORACLECFO_LIBDIRS)
AC_SUBST(ORACLECFO_LIBS)
# Finally create the master.Makefile from master.Makefile.in
AC_OUTPUT(master.Makefile)
chmod a-w master.Makefile
ocamlodbc-2.15/configure.nt 0000755 0027420 0051216 00000004416 10441505025 015607 0 ustar guesdon cristal #!/bin/sh
# ################################################################################################ #
# MetaStack Solutions Ltd. #
# ################################################################################################ #
# OCamlODBC Win32/MinGW Configure Script #
# ################################################################################################ #
# Copyright (c) 2006 MetaStack Solutions Ltd. #
# #
# This program is free software; you can redistribute it and/or modify it under the terms of the #
# GNU Lesser General Public License as published by the Free Software Foundation; either version #
# 2.1 of the License, or 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# ################################################################################################ #
# Author: David Allsopp #
# 5-Jun-2006 #
# ################################################################################################ #
OCAMLLIBDIR=`ocamlc -where`
echo OCAMLLIBDIR=`cygpath $OCAMLLIBDIR`> Makefile.config
ocamlodbc-2.15/gpl_header 0000644 0027420 0051216 00000003053 10020610114 015256 0 ustar guesdon cristal OCamlODBC
Copyright (C) 2004 Institut National de Recherche en Informatique et
en Automatique. All rights reserved.
This program 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 2.1 of the License, or
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 Lesser 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
Contact: Maxence.Guesdon@inria.fr
ocamlodbc-2.15/lgpl_header 0000644 0027420 0051216 00000003040 10020610114 015426 0 ustar guesdon cristal OCamlODBC
Copyright (C) 2004 Institut National de Recherche en Informatique et
en Automatique. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser 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
Contact: Maxence.Guesdon@inria.fr ocamlodbc-2.15/master.Makefile.in 0000644 0027420 0051216 00000012624 10634574313 016631 0 ustar guesdon cristal ###############################################################################
# OCamlODBC #
# #
# Copyright (C) 2004 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published #
# by the Free Software Foundation; either version 2.1 of the License, or #
# 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# #
# Contact: Maxence.Guesdon@inria.fr #
###############################################################################
# OCAML compilation tools
OCAMLBIN= @OCAMLBIN@
OCAMLC = @OCAMLC@ -verbose
OCAMLOPT = @OCAMLOPT@
OCAMLMKLIB = @OCAMLMKLIB@
OCAMLDEP = @OCAMLDEP@
OCAMLLEX = @OCAMLLEX@
OCAMLYACC= @OCAMLYACC@
OCAMLLIB = @OCAMLLIB@
OCAMLBEST= @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
EXTRAC_CRC = $(OCAMLLIB)/extract_crc
OCAMLDOC= @OCAMLDOC@
OCAMLPP=-pp 'grep -v DEBUG'
# For installation
##############
MKDIR=mkdir -p
CP=cp -f
LIB=ocamlodbc.cma
LIB_OPT=$(LIB:.cma=.cmxa)
LIB_A=ocamlodbc.a
LIB_C=libocamlodbc.a
LIB_CMI=$(LIB:.cma=.cmi)
INSTALL_LIBDIR=$(OCAMLLIB)/ocamlodbc
INSTALL_BINDIR=$(OCAMLBIN)
RM=@rm -f
MV=@mv -f
#################################
# For Biniki
LABLGTKDIR=$(OCAMLLIB)/lablgtk2
LIBSGTK=$(LABLGTKDIR)/lablgtk.cma $(LABLGTKDIR)/gtkInit.cmo #$(OCAMLLIB)/lablgl.cma
LIBSGTK_OPT=$(LABLGTKDIR)/lablgtk.cmxa $(LABLGTKDIR)/gtkInit.cmx #$(OCAMLLIB)/lablgl.cmxa
#LINKGTK=-ccopt "${GLIB_LIBS} $(shell gtk-config --libs) -L$(LABLGTKDIR) -llablgtk "
LINKGTK=-ccopt "-L$(OCAMLLIB)/lablgtk2"
INCLUDEGTK= -I $(LABLGTKDIR)
BINIKI=biniki
BINIKI_OPT=biniki.opt
# End of Biniki definitions
##################################
# The target database system
#BASE=MYSQL
#BASE=POSTGRES
#BASE=OPENINGRES
#BASE=DB2
BASE=unixODBC
MYSQL_SUB=mysql
POSTGRES_SUB=postgres
OPENINGRES_SUB=openingres
DB2_SUB=db2
unixODBC_SUB=unixodbc
ORACLECFO_SUB=oraclecfo
SUBDIR=$($(BASE)_SUB)
# include options for each database
MYSQL_ODBCINCLUDE=@MYSQL_INCS@
POSTGRES_ODBCINCLUDE=@POSTGRES_INCS@
OPENINGRES_ODBCINCLUDE=@OPENINGRES_INCS #/export/GNU/odbc/include
DB2_ODBCINCLUDE=@DB2_INCS@ #/usr/IBMdb2/V7.1/include
unixODBC_ODBCINCLUDE=@UNIXODBC_INCS@ #/gnu/unixODBC/include
ORACLECFO_ODBCINCLUDE=@ORACLECFO_INCS@
ODBCINCLUDE=$($(BASE)_ODBCINCLUDE)
# the options for the directores with the libs
MYSQL_ODBCLIB=@MYSQL_LIBDIRS@
POSTGRES_ODBCLIB=@POSTGRES_LIBDIRS@
OPENINGRES_ODBCLIB=@OPENINGRES_LIBDIRS@ #-L/export/GNU/odbc/lib
DB2_ODBCLIB=@DB2_LIBDIRS@ #-L/usr/IBMdb2/V7.1/lib
unixODBC_ODBCLIB=@UNIXODBC_LIBDIRS@ #-L/gnu/unixODBC/lib
ORACLECFO_ODBCLIB=@ORACLECFO_LIBDIRS@ #-L/export/GNU/odbc/lib
ODBCLIB=$($(BASE)_ODBCLIB)
# the type of odbc driver
MYSQL_OPTODBC= -D iODBC # -D DEBUG2
POSTGRES_OPTODBC= -D iODBC
OPENINGRES_OPTODBC= -D INTERSOLV
DB2_OPTODBC= -D DB2 -D DEBUG2
unixODBC_OPTODBC= -D unixODBC
ORACLECFO_OPTODBC= -D unixODBC
OPTODBC=$($(BASE)_OPTODBC) #-D DEBUG2
# Options for compilation and link
CC = gcc
C_COMPFLAGS= -pthread $(OPTODBC) $(ODBCINCLUDE) -I $(OCAMLLIB)
#MYSQL_C_LINKFLAGS= -L$(ODBCLIB) -L$(ODBCLIB)/mysql
#POSTGRES_C_LINKFLAGS=-L$(ODBCLIB)
#OPENINGRES_C_LINKFLAGS= -L$(ODBCLIB)
#DB2_C_LINKFLAGS= -L $(ODBCLIB)
#unixODBC_C_LINKFLAGS= -L $(ODBCLIB)
#C_LINKFLAGS=$($(BASE)_C_LINKFLAGS)
C_DEBUGFLAGS=-g
COMPFLAGS=
MYSQL_LINKFLAGS= -ccopt "$(ODBCLIB) @MYSQL_LIBS@ -ldopt $(ODBCLIB) @MYSQL_LIBS@"
POSTGRES_LINKFLAGS= -ccopt "$(ODBCLIB) @POSTGRES_LIBS@ -ldopt $(ODBCLIB) @POSTGRES_LIBS@"
OPENINGRES_LINKFLAGS= -ccopt "$(ODBCLIB) @OPENINGRES_LIBS@ -ldopt $(ODBCLIB) @OPENINGRES_LIBS@"
DB2_LINKFLAGS= -ccopt "$(ODBCLIB) @DB2_LIBS@ -ldopt $(ODBCLIB) @DB2_LIBS@"
unixODBC_LINKFLAGS= -ccopt "$(ODBCLIB) @UNIXODBC_LIBS@ "
ORACLECFO_LINKFLAGS= -ccopt "$(ODBCLIB) @ORACLECFO_LIBS@ -ldopt $(ODBCLIB) @ORACLECFO_LIBS@"
LINKFLAGS= $($(BASE)_LINKFLAGS)
DEBUGFLAGS=
# Autres commandes
AR = ar rc
RANLIB = ranlib
# generic rules :
#################
.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly
%.cmi:%.mli
$(OCAMLC) $(OCAMLPP) $(COMPFLAGS) -c $<
%.cmo:%.ml
$(OCAMLC) $(OCAMLPP) $(COMPFLAGS) -c $<
%.cmi %.cmo:%.ml
$(OCAMLC) $(OCAMLPP) $(COMPFLAGS) -c $<
%.cmx %.o:%.ml
$(OCAMLOPT) $(OCAMLPP) $(COMPFLAGS) -c $<
%.ml:%.mll
$(OCAMLLEX) $<
%.mli %.ml:%.mly
$(OCAMLYACC) -v $<
ocamlodbc-2.15/myconf 0000644 0027420 0051216 00000000326 07764060046 014507 0 ustar guesdon cristal ./configure --with-unixodbc-incs="-I /usr/local/unixODBC/include/" --with-unixodbc-libs="-L/usr/local/unixODBC/lib" --with-pg-incs="-I /usr/include/pgsql/iodbc" --with-oraclecfo-incs="-I /work/ODBCdrivers/include"
ocamlodbc-2.15/ocaml_odbc.ml 0000644 0027420 0051216 00000010720 10634574313 015701 0 ustar guesdon cristal (*****************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as published *)
(* by the Free Software Foundation; either version 2.1 of the License, or *)
(* 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 Lesser General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(*****************************************************************************)
(** Low level part of OCamlODBC. Do not use directly. *)
(* Definitions des types abstraits *)
type sQLHENV
(** Database environment *)
type sQLHDBC
(** Database context *)
type env
(** Result handle *)
module type Sql_column_type =
sig
type t
val string : t -> string
end
module Interface (Sql_col : Sql_column_type) =
struct
(* Constructeurs des types abstraits (valeur vide) *)
external value_SQLHENV : unit -> sQLHENV = "ocamlodbc_HENV_c" "noalloc"
external value_SQLHDBC : unit -> sQLHDBC = "ocamlodbc_HDBC_c" "noalloc"
(* Fonctions C utilisées *)
external initDB : string -> string -> string -> (int * sQLHENV * sQLHDBC)
= "ocamlodbc_initDB_c"
(** [initDB database user password] initializes a DB access.
@return (err, phEnv, phDbc) where [err <> 0] in case of error,
and [phEnv], [phDbc] are DB environment and context. *)
external initDB_driver : string -> bool -> (int * sQLHENV * sQLHDBC)
= "ocamlodbc_initDB_driver_c"
(** [initDB_driver conn prompt] initializes a DB access where
[conn] is a ODBC driver connection string and [prompt = true]
if the driver should raise a dialog box to request username
and password. The return value is the same as [initDB]. *)
external exitDB : sQLHENV -> sQLHDBC -> int
= "ocamlodbc_exitDB_c"
(** [exitDB phEnv phDbc] closes the DB access. Return [0] in case
of success and a non-null number otherwise. *)
external execDB : sQLHENV -> sQLHDBC -> string -> int * env
= "ocamlodbc_execDB_c"
(** [execDB phEnv phDbc sql] retruns [(err, r)] where [r] is a
handle to the results of the [sql] statement and
- [err = 1] if there are no columns;
- [err = 0] if theare are columns and the statement was
executes properly;
- other values of [err] indicate an error (in which case
[r] cannot be used). *)
external free_execDB : env -> unit
= "ocamlodbc_free_execDB_c"
(** [free_execDB r] free the resources associated with the request
handle [r]. *)
external get_infoDB : env -> (string * Sql_col.t) list
= "ocamlodbc_get_infoDB_c"
(** [get_infoDB r] returns a list of pairs for each column in [r],
where the pair [(cn, t)] means that the column name is [cn]
and its SQL type is [t]. *)
external itereDB : env -> int -> int * string option list list
= "ocamlodbc_itere_execDB_c"
(** [itereDB r nmax] returns a pair [(n, l)] where [n] is the
number of returned rows and [l] is the list of rows (of length
[n <= nmax]). If [n < n_max], you must NOT call again
[itereDB] on [r] -- this may result in a Segmentation
fault. *)
end
ocamlodbc-2.15/ocaml_odbc_c.c 0000644 0027420 0051216 00000111377 10635510403 016016 0 ustar guesdon cristal /*****************************************************************************/
/* OCamlODBC */
/* */
/* Copyright (C) 2004 Institut National de Recherche en Informatique et */
/* en Automatique. All rights reserved. */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation; either version 2.1 of the License, or */
/* 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 Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser 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 */
/* */
/* Contact: Maxence.Guesdon@inria.fr */
/*****************************************************************************/
#ifndef lint
static char vcid[]="$Id: ocaml_odbc_c.c,v 1.16 2007/06/18 14:04:51 chris Exp $";
#endif /* lint */
//#define DEBUG_LIGHT 1
//#define DEBUG2 1
//#define DEBUG3 1
//in makefile, or not: #define ODBC3 1
#ifndef ODBC3
#define OLD_POINTERS 1
#endif
/*---| includes (common) |---*/
#include
#include
#include
#include
/* Includes pour OCAML */
#include
#include
#include
#include
/*---| includes (unixODBC/DB2/iODBC/mSQL/Oracle/Intersolv/WIN32) |----------*/
#ifdef iODBC
# include
# include
# include
#endif
#ifdef unixODBC
# include
# include
# include
#endif
#ifdef DB2
# include "sqlcli1.h"
#endif
#ifdef mSQL
# include
#endif
#ifdef ORACLE
# include
#endif
#ifdef INTERSOLV
# include
#endif
#ifdef WIN32
#include
#include
#include
#endif
#define MAX_COLUMNS 128
#define COLUMN_SIZE 8000
/* The constants used to represent the OCaml constructors for Column
types. In the OCaml type (Libocaml_odbc.sql_column_type), the
constructors must appear in the same order. */
/* unknown type */
#define OCAML_SQL_UNKNOWN 0
/* these are standard SQL datatypes */
#define OCAML_SQL_CHAR 1
#define OCAML_SQL_NUMERIC 2
#define OCAML_SQL_DECIMAL 3
#define OCAML_SQL_INTEGER 4
#define OCAML_SQL_SMALLINT 5
#define OCAML_SQL_FLOAT 6
#define OCAML_SQL_REAL 7
#define OCAML_SQL_DOUBLE 8
#define OCAML_SQL_VARCHAR 9
/* extend SQL datatypes */
#define OCAML_SQL_DATE 10
#define OCAML_SQL_TIME 11
#define OCAML_SQL_TIMESTAMP 12
#define OCAML_SQL_LONGVARCHAR 13
#define OCAML_SQL_BINARY 14
#define OCAML_SQL_VARBINARY 15
#define OCAML_SQL_LONGVARBINARY 16
#define OCAML_SQL_BIGINT 17
#define OCAML_SQL_TINYINT 18
#define OCAML_SQL_BIT 19
/* later : add database specific types */
/* Prototype */
void displayError( HENV hEnv,
HDBC hDbc,
HSTMT hStmt,
int iRC,
int iLineNum
);
void print_sql_info(SQLHDBC hdbc);
/* Constructeurs des types abstraits ODBC */
CAMLprim
value ocamlodbc_HENV_c ()
{
return(Val_int(SQL_NULL_HENV));
}
CAMLprim
value ocamlodbc_HDBC_c ()
{
return(Val_int(SQL_NULL_HDBC));
}
/*-----------------------------------------------------------------------------
* initDB_c
*-----------------------------------------------------------------------------
* function: initialisation of DB access
* input: char *pszDB (not null)
* pointer to string containing the database name
* char *pszUser (not null)
* pointer to string containing the user name
* char *pszPassword
* pointer to string containing the password
* output: int
* != 0 - error
* == 0 - no error
* HENV *phEnv
* pointer to DB environment
* HDBC *phDbc
* pointer to DB context
*-----------------------------------------------------------------------------
*/
CAMLprim
value ocamlodbc_initDB_c(value v_nom_base, value v_nom_user, value v_password)
{
CAMLparam3(v_nom_base, v_nom_user, v_password);
CAMLlocal1(res);
char *nom_base = String_val(v_nom_base);
char *nom_user = String_val(v_nom_user);
char *password = String_val(v_password);
RETCODE result;
HENV *phEnv = SQL_NULL_HENV;
HDBC *phDbc = SQL_NULL_HDBC;
#ifdef DEBUG2
printf("initDB nombase : \"%s\", nom_user : \"%s\", Password : \"%s\"\n",
nom_base, nom_user, password);
fflush(stdout);
#endif
/* Allocation de la structure de retour */
res = alloc_tuple(3);
/* Test des parametres */
if( NULL == nom_base || NULL == nom_user ) {
#ifdef DEBUG2
printf(" Erreur de parametre\n");
fflush(stdout);
#endif
Field(res,0) = Val_int ((int) -1);
Field(res,1) = Val_long ((long) SQL_NULL_HENV);
Field(res,2) = Val_long ((long) SQL_NULL_HDBC);
CAMLreturn(res);
}
/* Allocation memoire des structures HDBC, HENV */
phDbc = (HDBC *) malloc(sizeof(HDBC));
phEnv = (HENV *) malloc(sizeof(HENV));
if( phDbc == (HDBC *)NULL || phEnv == (HENV *) NULL) {
#ifdef DEBUG2
printf(" Erreur allocation memoire \n");
fflush(stdout);
#endif
caml_raise_out_of_memory();
}
/*
** get DB environment
*/
result = SQLAllocEnv( phEnv );
if( SQL_SUCCESS != result )
{
#ifdef DEBUG2
printf(" Erreur SQLAlloctEnv\n");
fflush(stdout);
displayError( *phEnv, SQL_NULL_HDBC, SQL_NULL_HENV, result, __LINE__ );
#endif
Field(res,0) = Val_int ((int) result);
Field(res,1) = Val_long ((long) SQL_NULL_HENV);
Field(res,2) = Val_long ((long) SQL_NULL_HDBC);
CAMLreturn(res);
}
/*
** allocate a connection handle
*/
result = SQLAllocConnect( *phEnv, phDbc );
if( SQL_SUCCESS != result )
{
#ifdef DEBUG2
printf(" Erreur SQLAllocConnect\n");
fflush(stdout);
displayError( *phEnv, *phDbc, SQL_NULL_HENV, result, __LINE__ );
#endif
Field(res,0) = Val_int ((int) result);
Field(res,1) = Val_long ((long) SQL_NULL_HENV);
Field(res,2) = Val_long ((long) SQL_NULL_HDBC);
CAMLreturn(res);
}
/*
** connect to server
*/
#ifdef DEBUG2
printf(" ...connecting to server \"%s\" as user \"%s\" (%s)\n",
nom_base,
nom_user,
(NULL != password) ? password : ""
);
#endif
result = SQLConnect(*phDbc, nom_base, SQL_NTS,
nom_user, SQL_NTS,
password, SQL_NTS
);
if( SQL_SUCCESS != result && SQL_SUCCESS_WITH_INFO != result )
{
#ifdef DEBUG2
printf(" Erreur SQLConnect\n");
fflush(stdout);
displayError( *phEnv, *phDbc, SQL_NULL_HENV, result, __LINE__ );
#endif
Field(res,0) = Val_int ((int) result);
Field(res,1) = Val_long ((long) SQL_NULL_HENV);
Field(res,2) = Val_long ((long) SQL_NULL_HDBC);
CAMLreturn(res);
}
Field(res,0) = Val_int ((int) 0);
Field(res,1) = Val_long ((long) phEnv);
Field(res,2) = Val_long ((long) phDbc);
CAMLreturn(res);
}
#define MAXBUFLEN 1024
/*-----------------------------------------------------------------------------
* initDB_driver_c
*-----------------------------------------------------------------------------
* function: initialisation of DB access
* input: char *connect_string (not null)
* pointer to ODBC driver connection string. The string is driver
* dependent. It includes the username and password if applicable.
* int prompt
* != 0 if the driver should raise a dialog box to request username
* and password
* == 0 if the driver should not prompt
* output: int
* != 0 - error
* == 0 - no error
* HENV *phEnv
* pointer to DB environment
* HDBC *phDbc
* pointer to DB context
*-----------------------------------------------------------------------------
*/
CAMLprim
value ocamlodbc_initDB_driver_c(value v_connect_string, value v_prompt)
{
CAMLparam2 (v_connect_string,v_prompt);
CAMLlocal1 (res);
char *connect_string = String_val(v_connect_string);
int prompt = Bool_val(v_prompt);
RETCODE result;
//HENV *phEnv = SQL_NULL_HENV;
//HDBC *phDbc = SQL_NULL_HDBC;
SQLHENV henv = SQL_NULL_HENV;
SQLHDBC hdbc1 = SQL_NULL_HDBC;
SQLHSTMT hstmt1 = SQL_NULL_HSTMT;
SQLCHAR ConnStrIn[MAXBUFLEN] = "";
SQLCHAR ConnStrOut[MAXBUFLEN];
SQLSMALLINT cbConnStrOut = 0;
SQLRETURN cliRC = SQL_SUCCESS;
/* allocate an environment handle */
cliRC = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
res = alloc_tuple(3);
if (cliRC != SQL_SUCCESS)
{
#ifdef DEBUG2
printf("\n--ERROR while allocating the environment handle.\n");
printf(" cliRC = %d\n", cliRC);
printf(" line = %d\n", __LINE__);
printf(" file = %s\n", __FILE__);
fflush(stdout);
#endif
caml_failwith("Ocaml_odbc.initDB_driver: error while allocating the environment handle");
}
/* set attribute to enable application to run as OCBC 3.0 application */
#ifdef ODBC3
cliRC = SQLSetEnvAttr(henv,
SQL_ATTR_ODBC_VERSION,
(void *)SQL_OV_ODBC2,
0);
#endif
//ENV_HANDLE_CHECK(henv, cliRC);
cliRC = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
if (cliRC != SQL_SUCCESS)
{
#ifdef DEBUG2
printf("\n--ERROR while allocating the environment handle.\n");
printf(" cliRC = %d\n", cliRC);
printf(" line = %d\n", __LINE__);
printf(" file = %s\n", __FILE__);
fflush(stdout);
#endif
caml_failwith("Ocaml_odbc.initDB_driver: error while allocating the environment handle");
}
// Make connection without data source. Ask that driver
// prompt if insufficient information. Driver returns
// SQL_ERROR and application prompts user
// for missing information. Window handle not needed for
// SQL_DRIVER_NOPROMPT.
result = SQLDriverConnect(hdbc1, // Connection handle
NULL, // Window handle
connect_string, // Input connect string
SQL_NTS, // Null-terminated string
ConnStrOut, // Address of output buffer
MAXBUFLEN, // Size of output buffer
&cbConnStrOut, // Address of output length
(prompt ? SQL_DRIVER_PROMPT : SQL_DRIVER_NOPROMPT));
if(result == SQL_SUCCESS_WITH_INFO)
print_sql_info(hdbc1);
Field(res,0) = Val_int (result);
if(result == SQL_SUCCESS_WITH_INFO) {Field(res,0) = Val_int (0);}
if(result == SQL_NO_DATA) {Field(res,0) = Val_int (-11);}
if(result == SQL_ERROR) {Field(res,0) = Val_int (-12);}
if(result == SQL_INVALID_HANDLE) {Field(res,0) = Val_int (-13);}
Field(res,1) = Val_long ((long) henv);
Field(res,2) = Val_long ((long) hdbc1);
//printf("henv=%0x, hdbc=%0x\n",henv,hdbc1); fflush(stdout);
CAMLreturn(res);
}
/*-----------------------------------------------------------------------------
* exitDB
*-----------------------------------------------------------------------------
* function: withdraw of DB access
* input: HENV *phEnv
* pointer to DB environment
* HDBC *phDbc
* pointer to DB context
* output: int
* != 0 - error
* == 0 - no error
*-----------------------------------------------------------------------------
*/
CAMLprim
value ocamlodbc_exitDB_c(value v_phEnv, value v_phDbc)
{
CAMLparam2 (v_phEnv, v_phDbc);
HENV *phEnv = (HENV *) (Unsigned_long_val(v_phEnv));
HDBC *phDbc = (HDBC *) (Unsigned_long_val(v_phDbc));
RETCODE result;
#ifdef DEBUG2
printf("exitDB\n");
fflush(stdout);
#endif
/* Test des parametres */
if( SQL_NULL_HENV == phEnv || SQL_NULL_HDBC == phDbc ) {
#ifdef DEBUG2
printf(" Erreur parametres\n");
fflush(stdout);
#endif
CAMLreturn (Val_int ((int)-1));
}
#ifdef DEBUG3
printf("<1>"); fflush(stdout);
#endif
/*
** commit transactions
*/
#ifdef OLD_POINTERS
result = SQLTransact( *phEnv, *phDbc, SQL_COMMIT );
#else
result = SQLTransact( phEnv, phDbc, SQL_COMMIT );
#endif
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
printf(" Erreur SQLTransact\n");
fflush(stdout);
displayError( *phEnv, *phDbc, SQL_NULL_HENV, result, __LINE__ );
#endif
}
/*
** disconnect from DB
*/
#ifdef DEBUG3
printf("<2>"); fflush(stdout);
#endif
#ifdef OLD_POINTERS
result = SQLDisconnect( *phDbc );
#else
result = SQLDisconnect( phDbc );
#endif
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
printf(" Erreur SQLDisconnect\n");
fflush(stdout);
displayError( *phEnv, *phDbc, SQL_NULL_HENV, result, __LINE__ );
#endif
}
/*
** free connection to DB
*/
#ifdef DEBUG3
printf("<3>"); fflush(stdout);
#endif
#ifdef OLD_POINTERS
result = SQLFreeConnect( *phDbc );
#else
result = SQLFreeConnect( phDbc );
#endif
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
printf(" Erreur SQLFreeConnect\n");
fflush(stdout);
displayError( *phEnv, *phDbc, SQL_NULL_HENV, result, __LINE__ );
#endif
}
else
*phDbc = SQL_NULL_HDBC;
/*
** free environment
*/
#ifdef DEBUG3
printf("<4>"); fflush(stdout);
#endif
#ifdef OLD_POINTERS
result = SQLFreeEnv( *phEnv );
#else
result = SQLFreeEnv( phEnv );
#endif
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
printf(" Erreur SQLFreeEnv\n");
fflush(stdout);
displayError( *phEnv, SQL_NULL_HDBC, SQL_NULL_HENV, result, __LINE__ );
#endif
}
else
*phEnv = SQL_NULL_HENV;
#ifdef DEBUG3
printf("<5>"); fflush(stdout);
#endif
CAMLreturn(Val_int((int) 0));
}
/*-----------------------------------------------------------------------------
* execDB_c
*-----------------------------------------------------------------------------
* function: execution of a command, display of results
* input: HENV hEnv
* handle for DB environment
* HDBC hDbc
* handle for DB context
* char *pszSqlStmt
* pointer to string containing the SQL statement
* output: int
* != 0 - error
* == 0 - no error
* int list
*-----------------------------------------------------------------------------
*/
typedef struct {
HSTMT exec_hstmt; /* handle for statement */
SWORD exec_iResColumns; /* number of result cols */
int exec_iRowCount; /* number of rows affected */
SQLPOINTER exec_pData[MAX_COLUMNS+1];
/* pointer to results exec_pData[1..exec_iResColumns]
(column 0 is not used) */
SQLINTEGER exec_indicator[MAX_COLUMNS+1]; /* [1..exec_iResColumns] */
HENV *phEnv;
HDBC *phDbc;
} env ;
/* Allocate the result pair (in case of error) and return it. */
#define execDB_return_error(result) \
retour = alloc_tuple (2) ; \
Store_field (retour, 0, Val_int((int) result)); \
Store_field (retour, 1, caml_q_env); \
CAMLreturn(retour)
CAMLprim
value ocamlodbc_execDB_c(value v_phEnv, value v_phDbc, value v_cmd)
{
CAMLparam3(v_phEnv, v_phDbc, v_cmd);
CAMLlocal1(caml_q_env) ;
CAMLlocal1(retour) ;
char *cmd = String_val(v_cmd);
int exec_ci = 0;
SQLCHAR exec_szColName[COLUMN_SIZE]; /* name of column */
SQLSMALLINT exec_cbColName; /* length of column name */
SQLSMALLINT exec_fColType; /* type of column */
SQLUINTEGER exec_uiColPrecision; /* precision of column */
SQLSMALLINT exec_iColScaling; /* scaling of column */
SQLSMALLINT exec_fColNullable; /* is column nullable? */
SQLINTEGER collen;
RETCODE result = 0;
env* q_env = (env*) malloc(sizeof(env));
caml_q_env = (value) q_env;
q_env->exec_iResColumns = 0;
q_env->exec_iRowCount = 0;
q_env->exec_pData[0] = NULL;
q_env->phEnv = (HENV *) (Unsigned_long_val(v_phEnv));
q_env->phDbc = (HDBC *) (Unsigned_long_val(v_phDbc));
//printf("phEnv=%0x, phDbc=%0x\n",q_env->phEnv,q_env->phDbc); fflush(stdout);
/* caml_q_env = alloc (sizeof(env*), Abstract_tag);
Store_field (caml_q_env, 0, (value) q_env);
*/
#ifdef DEBUG2
printf("execDB cmd: \"%s\"\n", cmd);
fflush(stdout);
#endif
#ifdef DEBUG3
printf("<1>"); fflush(stdout);
#endif
/*
** check parameter list
*/
if( '\0' == cmd[0]
|| q_env->phEnv == SQL_NULL_HENV
|| q_env->phDbc == SQL_NULL_HDBC ) {
#ifdef DEBUG2
printf(" Erreur parametres\n");
fflush(stdout);
#endif
execDB_return_error(-1);
}
#ifdef DEBUG3
printf("<2>"); fflush(stdout);
#endif
/*
** get statement handle
*/
#ifdef ODBC3
#ifdef DEBUG3
int x = (int)(*(q_env->phDbc));
printf("<2.5,%0x>", x); fflush(stdout);
#endif
result = SQLAllocHandle(SQL_HANDLE_STMT,
q_env->phDbc, &(q_env->exec_hstmt) );
#else
result = SQLAllocStmt(*(q_env->phDbc), &(q_env->exec_hstmt) );
#endif
#ifdef DEBUG3
printf("<3>"); fflush(stdout);
#endif
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
#ifdef ODBC3
printf(" Erreur SQLAllocHandle (ODBC 3): are you sure ODBC 3 is"
" supported by your platform?\n");
#else
printf(" Erreur SQLAllocStmt (ODBC 2)\n");
#endif
fflush(stdout);
displayError( *(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
execDB_return_error(result);
}
/*
** prepare statement
*/
if( SQL_SUCCESS != (result=SQLPrepare(q_env->exec_hstmt, cmd, SQL_NTS)) ) {
#ifdef DEBUG2
printf(" Erreur SQLPrepare\n");
printf(" %s\n", cmd);
fflush(stdout);
displayError(*(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
execDB_return_error(result);
}
/*
** execute statement
*/
result = SQLExecute(q_env->exec_hstmt);
if( result == SQL_SUCCESS) {}
else if(result == SQL_SUCCESS_WITH_INFO)
print_sql_info(q_env->phDbc);
else {
#ifdef DEBUG2
printf(" Erreur SQLExecute\n");
fflush(stdout);
displayError( *(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
execDB_return_error(result);
}
/*
** get number of rows affected / columns returned
*/
q_env->exec_iRowCount = 0;
result = SQLRowCount(q_env->exec_hstmt,
(SQLINTEGER FAR *) &(q_env->exec_iRowCount) );
#ifdef DEBUG_LIGHT
printf(" number of rows affected : %d\n",
(SQL_SUCCESS == result) ? q_env->exec_iRowCount : -1);
#endif
q_env->exec_iResColumns = 0;
result = SQLNumResultCols(q_env->exec_hstmt,
(SWORD FAR *) &(q_env->exec_iResColumns) );
#ifdef DEBUG_LIGHT
printf(" number of columns returned : %d\n",
(SQL_SUCCESS == result) ? q_env->exec_iResColumns : -1);
fflush(stdout);
#endif
/*
** get table description and create list with pointers
*/
if( 0 < q_env->exec_iResColumns )
{
#ifdef DEBUG2
printf(" Binding result columns:\n" );
#endif
for( exec_ci = q_env->exec_iResColumns; exec_ci >=1; exec_ci-- )
{
if( SQL_SUCCESS !=
(result = SQLDescribeCol(
q_env->exec_hstmt,
exec_ci, /* ColumnNumber */
&(exec_szColName[0]), /* ColumnName */
sizeof(exec_szColName) - 1, /* BufferLength */
&(exec_cbColName), /* NameLengthPtr */
&(exec_fColType), /* DataTypePtr */
(SQLUINTEGER*) &exec_uiColPrecision, /* ColumnSizePtr (length) */
&(exec_iColScaling), /* DecimalDigitsPtr (scale) */
&(exec_fColNullable) /* NullablePtr */
))
)
{
#ifdef DEBUG2
printf(" Erreur SQLDescribeCol\n");
fflush(stdout);
displayError( *(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
execDB_return_error(result);
}
/*
** Bind the columns
**
** See: http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cli/rzadpfndecol.htm
*/
SQLColAttributes(q_env->exec_hstmt, exec_ci, SQL_COLUMN_DISPLAY_SIZE,
NULL, 0, NULL, &collen);
collen++; /* Final \0 */
(q_env->exec_pData)[exec_ci] = NULL;
(q_env->exec_indicator)[exec_ci] = 0;
if( NULL == ((q_env->exec_pData)[exec_ci] = malloc(collen)) )
{
caml_raise_out_of_memory();
}
//memset( (q_env->exec_pData)[exec_ci], 0, exec_uiColPrecision +1 );
result = SQLBindCol(
q_env->exec_hstmt,
exec_ci,
SQL_C_CHAR, /* TargetType */
(q_env->exec_pData)[exec_ci], /* TargetValuePtr */
collen, /* BufferLength */
&(q_env->exec_indicator[exec_ci]) /* StrLen_or_IndPtr */
);
#ifdef DEBUG2
printf(" q_env->exec_pData[%i] = %p\t(collen=%i, result=%i)\n",
exec_ci, (q_env->exec_pData)[exec_ci], collen, result);
#endif
}
}
/* on retourne 1 s'il n'y a pas de colonnes, ou 0 sinon. (1 =
SQL_SUCCESS_WITH_INFO thus won't conflict with another return
value.) */
if ( 0 < q_env->exec_iResColumns )
{
retour = alloc_tuple (2) ;
Store_field (retour, 0, Val_int(0));
Store_field (retour, 1, caml_q_env);
CAMLreturn(retour);
}
else
{
retour = alloc_tuple (2) ;
Store_field (retour, 0, Val_int(1));
Store_field (retour, 1, caml_q_env);
CAMLreturn(retour);
}
}
/* free_ExecDB_c : fonction de désallocation des structures allouées par
execDB_c */
CAMLprim
value ocamlodbc_free_execDB_c(value caml_q_env)
{
CAMLparam1(caml_q_env);
int result;
int exec_ci = 0;
/*env* q_env = (env*) Field (caml_q_env, 0);*/
env* q_env = (env*) caml_q_env ;
#ifdef DEBUG2
printf("free_execDB_c\n");
#endif
/*
** free allocated memory
*/
for( exec_ci = 1; exec_ci <= q_env->exec_iResColumns; exec_ci++ )
{
#ifdef DEBUG2
fprintf(stderr, " free(q_env->exec_pData[%i] %s NULL)", exec_ci,
(q_env->exec_pData[exec_ci] == NULL) ? "==" : "!=");
fflush(stderr);
#endif
free( q_env->exec_pData[exec_ci] );
#ifdef DEBUG2
fprintf(stderr, " Ok\n"); fflush(stderr);
#endif
q_env->exec_pData[exec_ci] = NULL;
} /* for */
#ifdef DEBUG2
fprintf(stderr, " free\n");
fflush(stderr);
#endif
/*
** free statement handle
*/
result = SQLFreeStmt(q_env->exec_hstmt, SQL_DROP );
if( SQL_SUCCESS != result ) {
#ifdef DEBUG2
printf(" Erreur SQLFreeStmt\n");
fflush(stdout);
displayError( *(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
}
free(q_env);
#ifdef DEBUG2
fprintf(stderr, "end free_execDB_c\n");
fflush(stderr);
#endif
CAMLreturn(Val_unit);
}
/* Fonction prenant un code de type SQL et retournant la constante
correspondant au bon constructeur OCaml. */
static
int get_OCaml_SQL_type_code (int code)
{
switch (code)
{
case SQL_CHAR: return (OCAML_SQL_CHAR);
case SQL_BINARY: return (OCAML_SQL_BINARY);
case SQL_DATE: return (OCAML_SQL_DATE);
case SQL_DECIMAL: return (OCAML_SQL_DECIMAL);
case SQL_DOUBLE: return (OCAML_SQL_DOUBLE);
case SQL_FLOAT: return (OCAML_SQL_FLOAT);
case SQL_INTEGER: return (OCAML_SQL_INTEGER);
case SQL_LONGVARCHAR: return (OCAML_SQL_LONGVARCHAR);
case SQL_LONGVARBINARY: return (OCAML_SQL_LONGVARBINARY);
case SQL_NUMERIC: return (OCAML_SQL_NUMERIC);
case SQL_REAL: return (OCAML_SQL_REAL);
case SQL_SMALLINT: return (OCAML_SQL_SMALLINT);
case SQL_TIME: return (OCAML_SQL_TIME);
case SQL_TIMESTAMP: return (OCAML_SQL_TIMESTAMP);
case SQL_VARCHAR: return (OCAML_SQL_VARCHAR);
case SQL_VARBINARY: return (OCAML_SQL_VARBINARY);
case SQL_TINYINT: return (OCAML_SQL_TINYINT);
default: return (OCAML_SQL_UNKNOWN);
}
}
/* Fonction retournant la liste des couples (nom, type) pour chaque
champ retourné par la dernière requête exécutée et non encore
libérée. */
CAMLprim
value ocamlodbc_get_infoDB_c(value caml_q_env)
{
CAMLparam1(caml_q_env);
CAMLlocal2(info_temp, info_l_head);
CAMLlocal1(info_cpl);
int exec_ci = 0;
SQLCHAR exec_szColName[COLUMN_SIZE]; /* name of column */
SQLSMALLINT exec_cbColName; /* length of column name */
SQLSMALLINT exec_fColType; /* type of column */
SQLUINTEGER exec_uiColPrecision; /* precision of column */
SQLSMALLINT exec_iColScaling; /* scaling of column */
SQLSMALLINT exec_fColNullable; /* is column nullable? */
RETCODE result = 0;
/*env* q_env = (env*) Field (caml_q_env, 0);*/
env* q_env = (env*) caml_q_env ;
#ifdef DEBUG2
printf("get_infoDB\n");
fflush(stdout);
#endif
/*
** check parameter list
*/
if( (q_env->phEnv) == SQL_NULL_HENV || (q_env->phDbc) == SQL_NULL_HDBC ) {
#ifdef DEBUG2
printf(" Erreur paramètres\n");
fflush(stdout);
#endif
/* On retourne une liste vide */
info_l_head = Val_int (0);
CAMLreturn(info_l_head);
}
/*
** get table description and create list with pointers
*/
if(q_env->exec_iResColumns <= 0) {
caml_failwith("Ocamlodbc.execute: no columns in the result!");
}
#ifdef DEBUG2
printf(" result columns:\n");
#endif
/* Initialisation de la liste des descriptions de colonnes */
info_l_head = Val_int(0);
for( exec_ci = q_env->exec_iResColumns; exec_ci >=1; exec_ci-- ) {
/*
** display table info
*/
#ifdef DEBUG2
printf( " [%03u] ", exec_ci ); fflush( stdout );
#endif
if( SQL_SUCCESS !=
(result=SQLDescribeCol(q_env->exec_hstmt,
exec_ci,
&(exec_szColName[0]),
sizeof(exec_szColName) - 1,
&(exec_cbColName),
&(exec_fColType),
(UDWORD FAR *) &(exec_uiColPrecision),
&(exec_iColScaling),
&(exec_fColNullable) )
)) {
#ifdef DEBUG2
printf(" Erreur SQLDescribeCol\n");
fflush(stdout);
displayError( *(q_env->phEnv),
*(q_env->phDbc),
q_env->exec_hstmt,
result, __LINE__ );
#endif
/* Allocation de la structure de retour */
info_l_head = Val_int(0);
CAMLreturn(info_l_head);
}
#ifdef DEBUG2
printf( " %s type=", exec_szColName );
switch( exec_fColType ) {
#ifndef INTERSOLV
/* case SQL_BLOB: printf( "BLOB" ); break;
case SQL_BLOB_LOCATOR: printf( "BLOB_LOCATOR" ); break;*/
case SQL_CHAR: printf( "CHAR" ); break;
case SQL_BINARY: printf( "BINARY" ); break;
/* case SQL_CLOB: printf( "CLOB" ); break;
case SQL_CLOB_LOCATOR: printf( "CLOB_LOCATOR" ); break;*/
case SQL_DATE: printf( "DATE" ); break;
/* case SQL_DBCLOB: printf( "DBCLOB" ); break;
case SQL_DBCLOB_LOCATOR: printf( "DBCLOB_LOCATOR" ); break;*/
case SQL_DECIMAL: printf( "DECIMAL" ); break;
case SQL_DOUBLE: printf( "DOUBLE" ); break;
case SQL_FLOAT: printf( "FLOAT" ); break;
/* case SQL_GRAPHIC: printf( "GRAPHIC" ); break;*/
case SQL_INTEGER: printf( "INTEGER" ); break;
case SQL_LONGVARCHAR: printf( "LONGVARCHAR" ); break;
case SQL_LONGVARBINARY: printf( "LONGVARBINARY" ); break;
/* case SQL_LONGVARGRAPHIC: printf( "LONGVARGRAPHIC" ); break;*/
case SQL_NUMERIC: printf( "NUMERIC" ); break;
case SQL_REAL: printf( "REAL" ); break;
case SQL_SMALLINT: printf( "SMALLINT" ); break;
case SQL_TIME: printf( "TIME" ); break;
case SQL_TIMESTAMP: printf( "TIMESTAMP" ); break;
case SQL_VARCHAR: printf( "VARCHAR" ); break;
case SQL_VARBINARY: printf( "VARBINARY" ); break;
/* case SQL_VARGRAPHIC: printf( "VARGRAPHIC" ); break;*/
case SQL_TINYINT: printf( "TINYINT" ); break;
default: printf( "unknown" );
#endif
} /* switch */
printf( " precision=%u scaling=%d nullable=%s\n",
exec_uiColPrecision, exec_iColScaling,
(SQL_NO_NULLS == exec_fColNullable) ? "YES" : "NO"
);
#endif
/* Construction des éléments de la liste */
info_temp = alloc_tuple (2);
info_cpl = alloc_tuple (2);
Store_field (info_cpl, 0, copy_string(exec_szColName));
Store_field (info_cpl, 1,
Val_int(get_OCaml_SQL_type_code ((int)exec_fColType)));
Store_field (info_temp, 0, info_cpl);
Store_field (info_temp, 1, info_l_head);
info_l_head = info_temp;
}
#ifdef DEBUG2
printf(" Point N\n");
#endif
CAMLreturn(info_l_head);
}
/* itere_execDB_c : fonction récupérant un certain nombre
d'enregistrements, pour la requête exécutée par la fonction execDB.
*/
CAMLprim
value ocamlodbc_itere_execDB_c (value caml_q_env, value vnb_records)
{
CAMLparam2(caml_q_env, vnb_records);
CAMLlocal1(exec_res);
CAMLlocal2(exec_string_list_list, some);
CAMLlocal5(exec_temp, exec_temp2, exec_l_head, exec_l_head2,
exec_string_list);
RETCODE result = 0;
int i;
int exec_ci = 0;
int nb_records = Int_val(vnb_records);
/*env* q_env = (env*) Field (caml_q_env, 0);*/
env* q_env = (env*) caml_q_env;
#ifdef DEBUG2
printf( "itere_execDB_c\n");
#endif
exec_l_head2 = Val_int(0);
exec_string_list_list = exec_l_head2;
exec_temp2 = Val_int(0);
#ifdef DEBUG2
printf( " nb_records = %d (max)\n", nb_records );
#endif
if (0 < q_env->exec_iResColumns)
{
#ifdef DEBUG2
printf(" 0 < q_env->exec_iResColumns = %i\n", q_env->exec_iResColumns);
#endif
for(i = 0; i < nb_records; i++)
{
result = SQLFetch(q_env->exec_hstmt);
if (SQL_SUCCESS != result && SQL_SUCCESS_WITH_INFO != result)
{
break;
}
#ifdef DEBUG2
printf( " --> " );
#endif
exec_l_head = Val_int(0); /* empty list */
for( exec_ci = q_env->exec_iResColumns; exec_ci >= 1; exec_ci-- )
{
exec_temp = alloc_tuple (2);
Store_field (exec_temp, 1, exec_l_head);
exec_l_head = exec_temp;
if (q_env->exec_indicator[exec_ci] == SQL_NULL_DATA) {
#ifdef DEBUG2
printf ("NULL");
#endif
/* Return [None] */
Store_field(exec_temp,0, Val_int(0));
}
else {
#ifdef DEBUG2
printf("'%s' ", (NULL == q_env->exec_pData[exec_ci]) ?
"" : q_env->exec_pData[exec_ci] );
fflush(stdout);
#endif
/* Return [Some(data)] */
some = caml_alloc(1, 0);
Store_field(some, 0,
copy_string((NULL == q_env->exec_pData[exec_ci]) ?
"" :
q_env->exec_pData[exec_ci]));
Store_field(exec_temp, 0, some);
}
} /* for */
#ifdef DEBUG2
printf( "<--\n" );
#endif
exec_string_list = exec_l_head;
exec_l_head2 = alloc_tuple(2);
Store_field (exec_l_head2, 0, exec_string_list);
Store_field (exec_l_head2, 1, Val_int(0));
if (exec_temp2 != Val_int(0) ) {
Store_field (exec_temp2, 1, exec_l_head2);
}
exec_temp2 = exec_l_head2;
if (exec_string_list_list == Val_int(0)) {
#ifdef DEBUG2
printf(" on crée la tête\n");
#endif
exec_string_list_list = exec_temp2;
}
} /* for */
} /* if(0 < q_env->exec_iResColumns) */
/*
** display last return code
*/
#ifdef DEBUG2
switch( result )
{
case SQL_SUCCESS: printf(" SQL_SUCCESS\n" ); break;
case SQL_SUCCESS_WITH_INFO: printf(" SQL_SUCCESS_WITH_INFO\n" ); break;
case SQL_ERROR: printf(" SQL_ERROR\n" );
displayError(*(q_env->phEnv), *(q_env->phDbc), q_env->exec_hstmt,
result, __LINE__ );
break;
case SQL_INVALID_HANDLE: printf(" SQL_INVALID_HANDLE\n" ); break;
case SQL_NO_DATA_FOUND: printf(" SQL_NO_DATA_FOUND\n" ); break;
default: printf(" unknown result = %d\n", result );
} /* switch */
#endif
/* on renvoie le nombre de records retournés */
exec_res = alloc_tuple(2);
Store_field(exec_res,0, Val_int(i));
#ifdef DEBUG2
printf(" Number of returned rows: %i\n", i);
#endif
Store_field(exec_res,1, exec_string_list_list);
CAMLreturn(exec_res);
}
/*-----------------------------------------------------------------------------
* displayError
*-----------------------------------------------------------------------------
* function: display an error message for a given error code
* input: HENV hEnv
* DB environment handle
* HDBC hDbc
* DB context handle
* HSTMT hStmt
* statement handle
* int iRC
* error code
* int iLineNum
* line number, where error occurred
* output:
*-----------------------------------------------------------------------------
*/
void displayError( HENV hEnv, HDBC hDbc, HSTMT hStmt,
int iRC, int iLineNum
)
{ /*---| variables |---*/
SQLCHAR szBuffer[ SQL_MAX_MESSAGE_LENGTH ]; /* msg. buffer */
SQLCHAR szSqlState[ 8 /*SQL_SQLSTATE_SIZE*/ ]; /* statement buf. */
SQLINTEGER iSqlCode; /* return code */
SQLSMALLINT iLength; /* return length */
/*---| program |---*/
/*
** display native error code
*/
/* fprintf( stderr, "\a-----------------------\n" ); */
fprintf( stdout, "-----------------------\n" );
fprintf( stdout, "SQL error : %d\n", iRC );
fprintf( stdout, "line number : %d\n", iLineNum );
/*
** display all error messages corresponding to this code
*/
while( SQL_SUCCESS == SQLError( hEnv, hDbc, hStmt, szSqlState,
&iSqlCode, szBuffer,
SQL_MAX_MESSAGE_LENGTH - 1, &iLength
)
)
{
fprintf( stdout, "SQL state : %s\n", szSqlState );
fprintf( stdout, "native error code : %ld\n", iSqlCode );
fprintf( stdout, "%s\n", szBuffer );
} /* while */
fprintf( stderr, "-----------------------\n" );
/* fprintf( stderr, "\a-----------------------\n" ); */
fflush(stderr);
fflush(stdout);
} /* displayError */
void print_sql_info(SQLHDBC hdbc)
{
SQLRETURN res2;
SQLCHAR state = 0;
SQLINTEGER nativeState = 0;
SQLCHAR msg[MAXBUFLEN+1];
SQLSMALLINT msgLength = 0;
do {
res2 = SQLGetDiagRec(SQL_HANDLE_DBC,
hdbc,
1, //SQLSMALLINT RecNumber,
&state, //SQLCHAR * Sqlstate,
&nativeState, //SQLINTEGER * NativeErrorPtr,
msg, // SQLCHAR * MessageText,
MAXBUFLEN, // SQLSMALLINT BufferLength,
&msgLength //SQLSMALLINT * TextLengthPtr
);
printf("state=%0xh, nativeState=%0xh, msg=%s\n", state, nativeState, msg);
} while(res2==SQL_SUCCESS_WITH_INFO);;
fflush(stdout);
}
ocamlodbc-2.15/ocamlodbc.DEF 0000644 0027420 0051216 00000000417 10634574313 015532 0 ustar guesdon cristal LIBRARY dllocamlodbc.dll
EXPORTS
ocamlodbc_HENV_c @1
ocamlodbc_HDBC_c @2
ocamlodbc_initDB_c @3
ocamlodbc_execDB_c @4
ocamlodbc_itere_execDB_c @5
ocamlodbc_free_execDB_c @6
ocamlodbc_get_infoDB_c @7
ocamlodbc_exitDB_c @8
ocamlodbc_initDB_driver_c @9
ocamlodbc-2.15/ocamlodbc.ml 0000644 0027420 0051216 00000016210 10636270723 015542 0 ustar guesdon cristal (*****************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as published *)
(* by the Free Software Foundation; either version 2.1 of the License, or *)
(* 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 Lesser General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(*****************************************************************************)
(* $Id: ocamlodbc.ml,v 1.18 2007/06/20 18:28:35 chris Exp $ *)
(** The software name *)
let logiciel = "OCamlODBC"
(** The software version *)
let version = "2.15"
exception SQL_Error of string
(* BEWARE: Keep constructor in the right order w.r.t. OCAML_SQL_*
constants in ocaml_odbc_c.c *)
type sql_column_type =
| SQL_unknown
| SQL_char
| SQL_numeric
| SQL_decimal
| SQL_integer
| SQL_smallint
| SQL_float
| SQL_real
| SQL_double
| SQL_varchar
| SQL_date
| SQL_time
| SQL_timestamp
| SQL_longvarchar
| SQL_binary
| SQL_varbinary
| SQL_longvarbinary
| SQL_bigint
| SQL_tinyint
| SQL_bit
(** The module for the column type and its conversion into a string. *)
module SQL_column =
struct
type t = sql_column_type
let string col_type =
match col_type with
| SQL_unknown -> "SQL_unknown"
| SQL_char -> "SQL_char"
| SQL_numeric -> "SQL_numeric"
| SQL_decimal -> "SQL_decimal"
| SQL_integer -> "SQL_integer"
| SQL_smallint -> "SQL_smallint"
| SQL_float -> "SQL_float"
| SQL_real -> "SQL_real"
| SQL_double -> "SQL_double"
| SQL_varchar -> "SQL_varchar"
| SQL_date -> "SQL_date"
| SQL_time -> "SQL_time"
| SQL_timestamp -> "SQL_timestamp"
| SQL_longvarchar -> "SQL_longvarchar"
| SQL_binary -> "SQL_binary"
| SQL_varbinary -> "SQL_varbinary"
| SQL_longvarbinary -> "SQL_longvarbinary"
| SQL_bigint -> "SQL_bigint"
| SQL_tinyint -> "SQL_tinyint"
| SQL_bit -> "SQL_bit"
end
module SQLInterface = Ocaml_odbc.Interface(SQL_column)
module OCamlODBC_messages =
struct
let disconnect = "ODBC : problem while disconnecting"
let connection nom_base nom_user pzPasswd iRC1 =
"Error while connecting to database " ^ nom_base ^ " as "
^ nom_user ^ " with password <" ^ pzPasswd ^ "> : "
^ (string_of_int iRC1)
let connection_driver connect_string iRC1 =
"Error while connecting to database with connection string "
^ connect_string ^ "> : " ^ (string_of_int iRC1)
end
type connection = {
phEnv : Ocaml_odbc.sQLHENV ;
phDbc : Ocaml_odbc.sQLHDBC ;
base : string ;
user : string ;
passwd : string ;
}
let connect base user passwd =
let (iRC1,hEnv,pHDbc) = SQLInterface.initDB base user passwd in
if iRC1 = 0 then
{
phEnv = hEnv;
phDbc = pHDbc;
base = base ;
user = user ;
passwd = passwd ;
}
else
raise (SQL_Error (OCamlODBC_messages.connection base user passwd iRC1))
let connect_driver ?(prompt=false) connect_string =
let (iRC1,hEnv,pHDbc) = SQLInterface.initDB_driver connect_string prompt in
if iRC1 = 0 then
{
phEnv = hEnv;
phDbc = pHDbc;
base = connect_string ;
user = "" ;
passwd = "" ;
}
else
raise (SQL_Error (OCamlODBC_messages.connection_driver connect_string iRC1))
let disconnect connection =
let iRC = SQLInterface.exitDB connection.phEnv connection.phDbc in
if iRC <> 0 then raise(SQL_Error OCamlODBC_messages.disconnect)
(** Cette fonction exécute une requête interrompue par des appels
réguliers au GC. Elle retourne un triplet : code d'erreur (0 si
ok), liste de couples (nom, type) pour décrire les colonnes
retournées, liste de liste de chaines représentant les
enregistrements.
*)
let execute_gen conn ?(get_info=false) ?(n_rec=40) req callback =
if req = "" then
(-1, ([] : (string * sql_column_type) list))
else (
let (ret, env) = SQLInterface.execDB conn.phEnv conn.phDbc req in
match ret with
| 0 ->
let l_desc_col =
if get_info then SQLInterface.get_infoDB env
(* récupérer les informations sur les champs retournés
(nom et type) par la dernière requête exécutée *)
else [] in
(* récupérer les records en plusieurs fois *)
let rec iter () =
let (n, ll_res) = SQLInterface.itereDB env n_rec in
(*Gc.minor();*)
callback ll_res;
if n >= n_rec (* maybe more rows *) then iter() in
iter();
SQLInterface.free_execDB env;
(ret, l_desc_col)
| 1 ->
(* pas de colonne, donc pas d'enregistrements à récupérer *)
SQLInterface.free_execDB env;
(0, [])
| _ ->
SQLInterface.free_execDB env;
(ret, [])
)
let execute_fetchall conn get_info req =
let res = ref [] in
let callback ll = res := !res @ ll in
let (code, info) = execute_gen conn ~get_info:get_info req callback in
(code, info, !res)
let execute conn req =
let (c, _, l) = execute_fetchall conn false req in
(c, l)
let execute_with_info conn req =
execute_fetchall conn true req
(** Object-oriented interface. *)
(**
@param base the database to connect to
@param user the user to use when connecting
@param passwd the password to use when connecting, can be [""]
*)
class data_base base user passwd =
object (self)
(** The connection, initialized when the object is created. *)
val connection = connect base user passwd
(** The flag to indicates whether we are connected or not,
used not to disconnect more than once.*)
val mutable connected = true
method connect () = ()
method disconnect () =
if connected then (
connected <- false;
disconnect connection
)
method execute req = execute connection req
method execute_with_info req = execute_with_info connection req
method execute_gen ?(get_info=false) ?(n_rec=1) req
(callback : string option list list -> unit) =
execute_gen connection ~get_info:get_info ~n_rec:n_rec req callback
end
ocamlodbc-2.15/ocamlodbc.mli 0000644 0027420 0051216 00000015604 10635510403 015710 0 ustar guesdon cristal (*****************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as published *)
(* by the Free Software Foundation; either version 2.1 of the License, or *)
(* 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 Lesser General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(*****************************************************************************)
(* $Id: ocamlodbc.mli,v 1.14 2007/06/18 14:04:51 chris Exp $ *)
(** Interface to ODBC databases.
See http://home.gna.org/ocamlodbc/configuring.html for
configutation information. *)
(** Version of the library. *)
val version : string
(** To report errors. *)
exception SQL_Error of string
(** The various SQL types for columns. *)
type sql_column_type =
| SQL_unknown
| SQL_char
| SQL_numeric
| SQL_decimal
| SQL_integer
| SQL_smallint
| SQL_float
| SQL_real
| SQL_double
| SQL_varchar
| SQL_date
| SQL_time
| SQL_timestamp
| SQL_longvarchar
| SQL_binary
| SQL_varbinary
| SQL_longvarbinary
| SQL_bigint
| SQL_tinyint
| SQL_bit
module SQL_column :
sig
type t = sql_column_type
val string : sql_column_type -> string
end
(** {2 Classic interface} *)
(** The type of connections to databases. *)
type connection
val connect : string -> string -> string -> connection
(** [connect base user passwd] creates a connection to data source
[base], as user [user], with password [passwd].
@raise SQL_Error if the connection to the database failed. *)
val connect_driver : ?prompt:bool -> string -> connection
(** [connect_driver conn_string] exposes the SQLDriverConnect
function to OCaml (for ODBC v2 or greater under MinGW). This
allows SQLServer "trusted authentication" mode based on NT
domain identities. An example of [conn_string] is ["Driver={SQL
Server};SERVER=FOOSERVER;Trusted_Connection=yes;Database=MYDB"].
@param prompt tells whether the if the driver should raise a
dialog box to request username and password. Default: [false].
@raise SQL_Error if the connection to the database failed. *)
val disconnect : connection -> unit
(** Disconnect from a database. The given connection should not be
used after this function was called.
@raise SQL_Error if an error occured while disconnecting.*)
val execute : connection -> string -> int * string option list list
(** [execute c q] executes query [q] through connection [c] and
returns the result as a pair [(error_code, recordlist)], where a
record is a [string option list]. The [error_code] is 0 if no
error occured. Each field of a record can be [None], which
represents the SQL NULL, or [Some v] where [v] is a string holding
the field value. *)
val execute_with_info :
connection -> string
-> int * (string * sql_column_type) list * string option list list
(** [execute_with_info c q] executes query [q] through connection [c] and
returns the result as a tuple [(error_code, type_list, record list)],
where [type_list] indicates the SQL types of the returned columns,
and a record is a [string list].
The [error_code] is [>= 0] if no error occured.*)
val execute_gen :
connection -> ?get_info:bool -> ?n_rec:int -> string ->
(string option list list -> unit) -> int * (string * sql_column_type) list
(** [execute_gen c get_info n_rec q callback] executes query [q] over
the connection [c], and invokes [callback] on successful blocks of
the results (of [n_rec] records each). Each record is a [string
list] of fields.
The result is a tuple [(error_code, type_list)]. The
[error_code] is [>= 0] if no error occurred, [type_list] is
empty if [get_info] is [false]. *)
(** {2 Object-oriented interface} *)
(** The class which represents a connection to a database. The
connection occurs when the object is created.
@raise SQL_Error if an error occured during the connection to the
database. *)
class data_base :
string ->
string ->
string ->
object
method connect : unit -> unit
(** @deprecated The connection to the database oocurs when the
object is created.*)
method disconnect : unit -> unit
(** Disconnect from the database. The objet should not be used
after calling this method.
@raise SQL_Error if an error occurs while disconnecting.*)
method execute : string -> int * (string option list list)
(** [#execute q] executes query [q] and returns the result as a pair
[(error_code, recordlist)], where a record is a [string
list]. The [error_code] is 0 if no error occured.*)
method execute_with_info :
string -> int * ((string * sql_column_type) list)
* (string option list list)
(** [#execute_with_info q] executes query [q] and returns the result
as a tuple [(error_code, type_list, record list)], where
[type_list] indicates the SQL types of the returned columns, and
a record is a [string list].
The [error_code] is 0 if no error occured.*)
method execute_gen :
?get_info:bool -> ?n_rec:int -> string ->
(string option list list -> unit) -> int * (string * sql_column_type) list
(** [#execute_gen get_info n_rec q callback] executes query [q] and
invokes [callback] on successful blocks of the results (of
[n_rec] records each). Each record is a [string list] of fields.
The result is a tuple [(error_code, type_list)]. The
[error_code] is 0 if no error occurred, [type_list] is empty if
[get_info] is [false]. *)
end
ocamlodbc-2.15/Exemples/ 0000755 0027420 0051216 00000000000 10636407423 015046 5 ustar guesdon cristal ocamlodbc-2.15/Exemples/.cvsignore 0000644 0027420 0051216 00000000042 10127210446 017032 0 ustar guesdon cristal *.cm*
ltest
monitor
ptest
ptest_mt ocamlodbc-2.15/Exemples/Makefile 0000644 0027420 0051216 00000003522 10335415142 016501 0 ustar guesdon cristal
include ../master.Makefile
CMOFILES = monitor.cmo
CMIFILES = $(CMOFILES:.cmo=.cmi)
CMXFILES = $(CMOFILES:.cmo=.cmx)
CMOFILES2 = test.cmo
CMIFILES2 = $(CMOFILES2:.cmo=.cmi)
CMXFILES2 = $(CMOFILES2:.cmo=.cmx)
PROG=monitor
PROG_OPT=monitor_opt
PROG2=ptest
PROG2_OPT=ptest_opt
PROG3=ptest_mt
PROG3_OPT=ptest_mt_opt
PROG4=ltest
PROG4_OPT=ltest_opt
####
COMPFLAGS=-I ../$(SUBDIR) -ccopt -L../$(SUBDIR)
LINKFLAGS=-ccopt -L../$(SUBDIR) -I ../$(SUBDIR)
all: $(PROG) $(PROG2) $(PROG3) $(PROG4)
opt: $(PROG_OPT) $(PROG2_OPT) $(PROG3_OPT) $(PROG4_OPT)
$(PROG): $(CMOFILES)
$(OCAMLC) -custom -o $@ $(LINKFLAGS) $(LIB) $(CMOFILES) \
-cclib -ldl -cclib -lunix
$(PROG_OPT): $(CMXFILES)
$(OCAMLOPT) -o $@ $(LINKFLAGS) $(LIB_OPT) $(CMXFILES) \
-cclib -ldl -cclib -lunix
$(PROG2): $(CMOFILES2)
$(OCAMLC) -custom -o $@ $(COMPFLAGS) unix.cma $(LIB) $(CMOFILES2) \
-cclib -ldl -cclib -lunix $(LINKFLAGS)
$(PROG2_OPT): $(CMXFILES2)
$(OCAMLOPT) -o $@ $(COMPFLAGS) unix.cmxa $(LIB_OPT) $(CMXFILES2) \
-cclib -ldl -cclib -lunix $(LINKFLAGS)
$(PROG3): test_mt.ml
$(OCAMLC) $(COMPFLAGS) -thread -custom -o $@ unix.cma threads.cma $(LIB) $< \
-cclib -ldl -cclib -lunix $(LINKFLAGS)
$(PROG3_OPT): test_mt.ml
$(OCAMLOPT) $(COMPFLAGS) -thread -o $@ unix.cmxa threads.cmxa $(LIB_OPT) $< \
-cclib -ldl -cclib -lunix $(LINKFLAGS)
$(PROG4): large.ml
$(OCAMLC) -custom -o $@ $(LINKFLAGS) unix.cma $(LIB) \
-cclib -ldl -cclib -lunix $<
$(PROG4_OPT): large.ml
$(OCAMLOPT) -o $@ $(LINKFLAGS) unix.cmxa $(LIB_OPT) \
-cclib -ldl -cclib -lunix $<
clean_all: clean
$(RM) *.cmo *.cmx *.cmi *.o
$(RM) $(PROG) $(PROG_OPT) $(PROG2) $(PROG2_OPT) $(PROG3) $(PROG3_OPT) $(PROG4) $(PROG4_OPT)
clean:
$(RM) *~ #*# *-
$(RM) *.o *.cmi *.cmo *.cma *.cmx *.cmxa *.a
$(RM) $(PROG) $(PROG2) $(PROG3) $(PROG4)
$(RM) $(PROG_OPT) $(PROG2_OPT) $(PROG3_OPT) $(PROG4_OPT)
# common rules
ocamlodbc-2.15/Exemples/Makefile.nt 0000644 0027420 0051216 00000006715 10441505025 017126 0 ustar guesdon cristal # ################################################################################################ #
# MetaStack Solutions Ltd. #
# ################################################################################################ #
# OCamlODBC Win32/MinGW Examples Makefile #
# ################################################################################################ #
# Copyright (c) 2006 MetaStack Solutions Ltd. #
# #
# This program is free software; you can redistribute it and/or modify it under the terms of the #
# GNU Lesser General Public License as published by the Free Software Foundation; either version #
# 2.1 of the License, or 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser 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 #
# ################################################################################################ #
# Author: David Allsopp #
# 5-Jun-2006 #
# ################################################################################################ #
OCAMLC=ocamlc
OCAMLOPT=ocamlopt
OCAMLDEP=ocamldep
OCAMLCFLAGS=-I ..
OCAMLOPTFLAGS=-I ..
LIB=ocamlodbc.cma
OPT_LIB=ocamlodbc.cmxa
RM=@rm -f
all: byte opt
byte: monitor.exe test.exe large.exe test_mt.exe
opt: monitor.opt.exe test.opt.exe large.opt.exe test_mt.opt.exe
clean:
$(RM) *.o *.cmx *.cmo *.cmi *.exe .depend
monitor.exe: monitor.cmo
$(OCAMLC) $(OCAMLCFLAGS) -o $@ $(LIB) $+
monitor.opt.exe: monitor.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -o $@ $(OPT_LIB) $+
large.exe: large.cmo
$(OCAMLC) $(OCAMLCFLAGS) -o $@ $(LIB) unix.cma $+
large.opt.exe: large.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -o $@ $(OPT_LIB) unix.cmxa $+
test.exe: test.cmo
$(OCAMLC) $(OCAMLCFLAGS) -o $@ $(LIB) unix.cma $+
test.opt.exe: test.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -o $@ $(OPT_LIB) unix.cmxa $+
test_mt.cmo: test_mt.ml
$(OCAMLC) $(OCAMLCFLAGS) -thread -c $+
test_mt.cmx: test_mt.ml
$(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -c $+
test_mt.exe: test_mt.cmo
$(OCAMLC) $(OCAMLCFLAGS) -thread -o $@ $(LIB) unix.cma threads.cma $+
test_mt.opt.exe: test_mt.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -o $@ $(OPT_LIB) unix.cmxa threads.cmxa $+
.depend: *.ml
$(OCAMLDEP) *.ml > .depend
include .depend
.PHONY: all clean byte opt
%.cmo: %.ml
$(OCAMLC) $(OCAMLCFLAGS) -c $<
%.cmx: %.ml
$(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
ocamlodbc-2.15/Exemples/large.ml 0000644 0027420 0051216 00000007362 10571243354 016501 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
open Ocamlodbc
let string_of_opt = function
None -> ""
| Some s -> s
let affiche iRC result =
if iRC = 0
then
(
print_newline();
begin
let p_row row = (List.iter (function s -> print_string ((string_of_opt s)^" ")) row) in
let p_rows rows = (List.iter (function row -> p_row row; print_newline()) rows) in
begin
print_string "Resultats :\n";
p_rows result;
print_newline()
end;
end
)
else
print_int iRC
;;
let usage = Sys.argv.(0) ^ " database user [password]"
let main () =
let tab = Sys.argv in
let (pszDB, pszUser) =
try tab.(1), tab.(2)
with _ -> prerr_endline usage ; exit 1
in
let pszPassword = if (Array.length tab) < 4 then "" else tab.(3) in
(* Affichage parametre base *)
print_string ("nom base : "^pszDB^"\n");
print_string ("nom util : "^pszUser^"\n");
print_string ("passwd : "^pszPassword^"\n");
(* Connection *)
let connection = connect pszDB pszUser pszPassword in
let req_create = "create table large_test (chaine TEXT, bin BLOB)" in
let _ = execute connection req_create in
let s = String.make 50000 'a' in
let v = Marshal.to_string [ 1 ; 2 ; 1000 ; 5000 ; 20000 ; 3 ] [] in
prerr_endline ("v="^v);
let req_insert = "insert into large_test (chaine, bin) values ('"^s^"', '"^v^"')" in
let (n,_) = execute connection req_insert in
if n <> 0 then prerr_endline "erreur insert";
let req_select = "select * from large_test" in
let (a,c) = execute connection req_select in
affiche a c ;
let req_destroy = "drop table large_test" in
let _ = execute connection req_destroy in
disconnect connection
;;
try
main();
Unix.sleep(5)
with
SQL_Error(s) -> print_string s; print_newline()
| _ -> print_string "Erreur inconnue.\n"
;;
ocamlodbc-2.15/Exemples/monitor.ml 0000644 0027420 0051216 00000007320 10571243355 017071 0 ustar guesdon cristal (****************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(****************************************************************************)
open Ocamlodbc
let usage = Sys.argv.(0) ^ " database user [password]"
let main () =
let (pszDB, pszUser) =
try Sys.argv.(1), Sys.argv.(2)
with _ -> prerr_endline usage; exit 1
and pszPassword = try Sys.argv.(3) with _ -> "" in
(* Affichage parametre base *)
print_string ("database : " ^ pszDB ^ "\n");
print_string ("user : " ^ pszUser ^ "\n");
print_string ("password : " ^ pszPassword ^ "\n");
(* Creation instance de la base *)
let db = new data_base pszDB pszUser pszPassword in
(* Initialisation de la base *)
db#connect() ;
(* Boucle infinie de traitement *)
let sortie = ref false and str = ref "" in
while not(!sortie = true) do
begin
print_string "»»» ";
str := read_line ();
if !str = "" then (
sortie := true;
)
else (
let (iRC, l_nom_type, result) = db#execute_with_info !str in
if iRC = 0 then (
let p_col row =
let print (s,col_type) =
print_string(s^" : "^(SQL_column.string col_type)^"\n") in
List.iter print row in
print_string "Columns : \n";
p_col l_nom_type;
print_newline();
print_newline();
let string_of_opt = function
None -> ""
| Some s -> s
in
let p_row row = List.iter (function s -> print_string ((string_of_opt s)^" ")) row in
let p_rows rows =
List.iter (function row -> p_row row; print_newline()) rows in
print_string "Results :\n";
p_rows result;
print_newline()
)
else (
print_int iRC; print_newline()
)
)
end
done;
db#disconnect()
let () =
try main()
with
| SQL_Error(s) -> print_string s; print_newline()
| e -> prerr_endline(Printexc.to_string e)
ocamlodbc-2.15/Exemples/test.ml 0000644 0027420 0051216 00000007656 10571243355 016375 0 ustar guesdon cristal (****************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(****************************************************************************)
open Ocamlodbc
let string_of_opt = function
None -> ""
| Some s -> s
let affiche iRC result =
if iRC = 0 then (
print_newline();
let p_row row = List.iter (function s -> print_string ((string_of_opt s)^" ")) row in
let p_rows rows =
List.iter (function row -> p_row row; print_newline()) rows in
print_string "Resultats :\n";
p_rows result;
print_newline()
)
else (
print_int iRC;
print_newline()
)
let usage = Sys.argv.(0) ^ " database user [password]"
let main () =
let (pszDB, pszUser) =
try Sys.argv.(1), Sys.argv.(2)
with _ -> prerr_endline usage ; exit 1 in
let pszPassword = if Array.length Sys.argv < 4 then "" else Sys.argv.(3) in
(* Affichage parametre base *)
print_string ("nom base : " ^ pszDB ^ "\n");
print_string ("nom util : " ^ pszUser ^ "\n");
print_string ("passwd : " ^ pszPassword ^ "\n");
(* Connection *)
let connection = connect pszDB pszUser pszPassword in
(*
let (a1,b1,c1) = db#execute("select * from pet") in
let (a2,b2,c2) = db#execute("select * from pet where sex = 1") in
let (a3,b3,c3) = db#execute("select * from pet where species = \"dog\"") in
let (a4,b4,c4) = db#execute("select name from pet where owner = \"lucky luke\"") in
affiche a1 b1 c1;
affiche a4 b4 c4;
affiche a3 b3 c3;
affiche a2 b2 c2;
*)
let req_create = "create table base_test (cle integer)" in
let _ = execute connection req_create in
let req_insert i =
"insert into base_test (cle) values ("^(string_of_int i)^")" in
for i = 1 to 1500 do
ignore(execute connection (req_insert i))
done;
let req_select i =
"select * from base_test where cle > " ^ (string_of_int i)
^ " and cle < "^(string_of_int (i+100)) in
for i = 1 to 1500 do
let (a,c) = execute connection (req_select i) in
affiche a c
done;
let req_destroy = "drop table base_test" in
let _ = execute connection req_destroy in
disconnect connection
;;
let () =
try
main();
Unix.sleep(5)
with
| SQL_Error(s) -> print_string s; print_newline()
| e -> prerr_endline(Printexc.to_string e)
ocamlodbc-2.15/Exemples/test_mt.ml 0000644 0027420 0051216 00000010367 10571243355 017066 0 ustar guesdon cristal (*********************************************************************************)
(* OCamlODBC *)
(* *)
(* Copyright (C) 2004 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. *)
(* *)
(* This program 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 2.1 of the License, or *)
(* 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 Lesser 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 *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************)
open Ocamlodbc
let string_of_opt = function
None -> ""
| Some s -> s
let affiche iRC result =
if iRC = 0
then
(
print_newline();
begin
let p_row row = (List.iter (function s -> print_string ((string_of_opt s)^" ")) row) in
let p_rows rows = (List.iter (function row -> p_row row; print_newline()) rows) in
begin
print_string "Resultats :\n";
p_rows result;
print_newline()
end;
end
)
else
print_int iRC
;;
let usage = Sys.argv.(0) ^ " database user [password]"
let tab = Sys.argv
let (pszDB, pszUser) =
try tab.(1), tab.(2)
with _ -> prerr_endline usage ; exit 1
let pszPassword = if (Array.length tab) < 4 then "" else tab.(3) ;;
let main () =
let id = try Thread.id (Thread.self ()) with _ -> 0 in
print_string ("Thread "^(string_of_int id)^" created!");
print_newline ();
(* Affichage paramètre base *)
print_string ("nom base : "^pszDB^"\n");
print_string ("nom util : "^pszUser^"\n");
print_string ("passwd : "^pszPassword);
print_newline ();
(* Connection *)
let connection =
try connect pszDB pszUser pszPassword
with SQL_Error(s) -> print_string s; print_newline() ; exit 1
in
let req_create = "create table base_test (cle integer)" in
let _ = execute connection req_create in
let req_insert i = "insert into base_test (cle) values ("^(string_of_int i)^")" in
for i = 1 to 10000 do
let _ = execute connection (req_insert i) in
()
done;
print_string ("Thread "^(string_of_int id)^" finished insertions!");
print_newline ();
let req_select i =
let i = 100 in
"select * from base_test where cle > "^(string_of_int i)^" and cle < "^(string_of_int (i+100))
in
for i = 1 to 3000 do
let (a,_,c) = execute_with_info connection (req_select i) in
affiche a c
done;
(*
let req_destroy = "drop table base_test" in
let _ = execute connection req_destroy in
*)
disconnect connection;
print_string ("Thread "^(string_of_int id)^" terminated!");
print_newline ()
;;
try
for i = 1 to 4 do
let t = Thread.create main () in
print_string "One thread created.";
print_newline ();
done;
let _ = read_line () in
()
with
SQL_Error(s) -> print_string s; print_newline()
| _ -> print_string "Erreur inconnue.\n"
;;