pax_global_header 0000666 0000000 0000000 00000000064 11231374124 0014510 g ustar 00root root 0000000 0000000 52 comment=2e17b67b3fc6f60b8522dc87e36dd4acde8360e0
dose2-1.4.2/ 0000775 0000000 0000000 00000000000 11231374124 0012530 5 ustar 00root root 0000000 0000000 dose2-1.4.2/COPYING 0000664 0000000 0000000 00000016727 11231374124 0013600 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
dose2-1.4.2/INSTALL 0000664 0000000 0000000 00000001707 11231374124 0013566 0 ustar 00root root 0000000 0000000 EDOS Dose 2: OCaml libs for managing packages and their dependencies
====================================================================
How to build and install
------------------------
1. Install the Ocaml compilers
2. Install ocamlfind and menhir
3. Make sure the following packages are known to ocamlfind:
pcre calendar zip bz2
4a. If you are compiling from SVN, run autoheader and autoconf
4b. Run ./configure
4c. You might have to run "make depend" (if you're running from SVN, or
after a "make clean")
5. Compile as follows: make (use GNU make)
6. Install (as root): make install (this will install an ocamlfind package
named dose2)
Prerequisites on a debian system:
----------------------------------
You have to install:
- the ocaml compiler packages
- ocaml-findlib
- camlp4
- menhir
- libpcre-ocaml-dev
- libcalendar-ocaml-dev
- libzip-ocaml-dev
- libbz2-ocaml-dev
- libpopt-dev
- librpm-dev
[Ralf/Jaap - last updated 27 Feb 2009]
dose2-1.4.2/META.in 0000664 0000000 0000000 00000004401 11231374124 0013605 0 ustar 00root root 0000000 0000000 description = "Package management libraries"
version = "@VERSION@"
package "conduit"
(
version = "[distributed with Dose2]"
archive(byte) = "conduit.cma"
archive(native) = "conduit.cmxa"
)
package "dosebase"
(
version = "[distributed with Dose2]"
archive(byte) = "dosebase.cma"
archive(native) = "dosebase.cmxa"
requires = "pcre,dbm,dose2.lifetime,dose2.napkin,dose2.io,dose2.util"
)
package "io"
(
version = "[distributed with Dose2]"
archive(byte) = "io.cma"
archive(native) = "io.cmxa"
)
package "lifetime"
(
version = "[distributed with Dose2]"
archive(byte) = "lifetime.cma"
archive(native) = "lifetime.cmxa"
requires = "calendar,dose2.io"
)
package "napkin"
(
version = "[distributed with Dose2]"
archive(byte) = "napkin.cma"
archive(native) = "napkin.cmxa"
requires = "dose2.io"
)
package "ocamldeb"
(
version = "[distributed with Dose2]"
archive(byte) = "ocamldeb.cma"
archive(native) = "ocamldeb.cmxa"
requires = "@OCAMLZIP@,bz2,pcre,num,str,dose2.progress,dose2.util"
)
package "ocamlrpm"
(
version = "[distributed with Dose2]"
archive(byte) = "ocamlrpm.cma"
archive(native) = "ocamlrpm.cmxa"
requires = "dose2.napkin,dose2.progress"
)
package "ocamlpkgsrc"
(
version = "[distributed with Dose2]"
archive(byte) = "ocamlpkgsrc.cma"
archive(native) = "ocamlpkgsrc.cmxa"
requires = "pcre"
)
package "packetology"
(
version = "[distributed with Dose2]"
archive(byte) = "packetology.cma"
archive(native) = "packetology.cmxa"
requires = "dose2.util,dose2.napkin,dose2.rapids,dose2.io,dose2.progress,dose2.satsolver"
)
package "progress"
(
version = "[distributed with Dose2]"
archive(byte) = "progress.cma"
archive(native) = "progress.cmxa"
requires="dose2.util"
)
package "rapids"
(
version = "[distributed with Dose2]"
archive(byte) = "rapids.cma"
archive(native) = "rapids.cmxa"
linkopts="-I +ocamlbuild"
requires="dose2.lifetime,dose2.napkin,dose2.conduit,dose2.io,dose2.dosebase,dose2.util,dose2.progress,dose2.ocamldeb,dose2.ocamlrpm,dose2.ocamlpkgsrc"
)
package "satsolver"
(
version = "[distributed with Dose2]"
archive(byte) = "satsolver.cma"
archive(native) = "satsolver.cmxa"
)
package "util"
(
version = "[distributed with Dose2]"
archive(byte)="util.cma"
archive(native)="util.cmxa"
requires="unix"
)
dose2-1.4.2/Makefile.config.in 0000664 0000000 0000000 00000003625 11231374124 0016047 0 ustar 00root root 0000000 0000000 CMOS= $(SOURCES:%.ml=%.cmo)
CMIS= $(MLIS:%.mli=%.cmi)
CMXS= $(SOURCES:%.ml=%.cmx)
OBJS= $(C_SOURCES:%.c=%.o)
OCAMLC= @OCAMLFIND@ ocamlc
OCAMLCP= @OCAMLFIND@ ocamlcp
OCAMLOPT= @OCAMLFIND@ ocamlopt
OCAMLMKLIB= @OCAMLMKLIB@
OCAMLFIND = @OCAMLFIND@
CFLAGS= @DEFS@ @CFLAGS@
CPPFLAGS= @CPPFLAGS@
LDFLAGS= @LDFLAGS@
LIBS= @LIBS@
ifeq ($(DESTDIR),)
INSTALLDIR = $(shell $(OCAMLFIND) printconf destdir)/dose2
STUBDIR = $(shell $(OCAMLC) -where)/stublibs
else
INSTALLDIR = $(DESTDIR)/dose2
STUBDIR = $(DESTDIR)/stublibs
endif
ifdef REQUIRES
OCAML_CFLAGS+= $(REQUIRES:%=-I ../%)
endif
ifdef PACKAGES
OCAML_CFLAGS+= -package $(PACKAGES)
OCAML_LFLAGS+= -linkpkg
endif
%.cmo: %.ml
ifdef PROFILE
$(OCAMLCP) $(OCAML_CFLAGS) -o $@ -c $<
else
$(OCAMLC) $(OCAML_CFLAGS) -o $@ -c $<
endif
%.cmi: %.mli
ifdef PROFILE
$(OCAMLCP) $(OCAML_CFLAGS) -o $@ -c $<
else
$(OCAMLC) $(OCAML_CFLAGS) -o $@ -c $<
endif
%.cmx: %.ml
$(OCAMLOPT) $(OCAML_CFLAGS) -o $@ -c $<
bcl: $(CMOS) $(OBJS)
ifndef C_SOURCES
$(OCAMLC) $(OCAMLLDFLAGS) -o $(NAME).cma -a $(CMOS)
else
$(OCAMLMKLIB) -o $(NAME) -oc $(NAME) $(CMOS) $(LDFLAGS) $(LIBS)
$(OCAMLMKLIB) -o $(NAME) $(OBJS) $(LDFLAGS) $(LIBS)
endif
ncl: $(CMXS)
ifndef C_SOURCES
$(OCAMLOPT) $(OCAMLLDFLAGS) -o $(NAME).cmxa -a $(CMXS)
else
$(OCAMLMKLIB) -o $(NAME) -oc $(NAME) $(CMXS) $(LDFLAGS) $(LIBS)
$(OCAMLMKLIB) -o $(NAME) $(OBJS) $(LDFLAGS) $(LIBS)
endif
.PHONY: clean depend cmi-install extra-install stub-install
clean:
@rm -f $(CMOS) $(CMIS) $(CMXS:.cmx=.o) $(CMXS) $(OBJS) $(NAME).a $(NAME).cma $(NAME).cmxa $(STUB_INSTALL) $(EXTRA_CLEAN) .depend
@touch .depend
depend:
@OCAMLDEP@ $(SOURCES) $(MLIS) > .depend
ifdef C_SOURCES
$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(C_SOURCES) >> .depend
endif
cmi-install:
install -m 644 $(CMIS) $(INSTALLDIR)
extra-install:
ifdef EXTRA_INSTALL
install $(EXTRA_INSTALL) $(INSTALLDIR)
endif
stub-install:
ifdef STUB_INSTALL
install $(STUB_INSTALL) $(STUBDIR)
endif
dose2-1.4.2/Makefile.in 0000664 0000000 0000000 00000002775 11231374124 0014610 0 ustar 00root root 0000000 0000000 DIRS= util io napkin progress ocamlrpm ocamldeb ocamlpkgsrc conduit lifetime \
dosebase rapids satsolver packetology
CMAS= util/util.cma ocamlrpm/ocamlrpm.cma ocamldeb/ocamldeb.cma \
ocamlpkgsrc/ocamlpkgsrc.cma conduit/conduit.cma io/io.cma \
lifetime/lifetime.cma napkin/napkin.cma dosebase/dosebase.cma \
progress/progress.cma rapids/rapids.cma satsolver/satsolver.cma \
packetology/packetology.cma
CMXAS= $(CMAS:%.cma=%.cmxa)
ARCHIVES= $(CMAS:%.cma=%.a)
OCAMLFIND = @OCAMLFIND@
ifeq ($(DESTDIR),)
INSTALL = $(OCAMLFIND) install
UNINSTALL = $(OCAMLFIND) remove
DESTDIR = $(shell $(OCAMLFIND) printconf destdir)
else
INSTALL = $(OCAMLFIND) install -destdir $(DESTDIR)
UNINSTALL = $(OCAMLFIND) remove -destdir $(DESTDIR)
endif
all: @BEST@
bcl:
@for i in $(DIRS); do \
$(MAKE) -C $$i bcl || exit; \
done
ncl:
@for i in $(DIRS); do \
$(MAKE) -C $$i ncl || exit; \
done
profile:
@for i in $(DIRS); do \
$(MAKE) PROFILE=yes -C $$i bcl || exit; \
done
.PHONY: clean depend install
clean:
@for i in $(DIRS); do \
$(MAKE) -C $$i clean; \
done
depend:
@for i in $(DIRS); do \
touch $$i/.depend; \
$(MAKE) -C $$i depend; \
done
install: @BEST@
-$(UNINSTALL) dose2
ifeq (@OCAMLBEST@, byte)
$(INSTALL) -patch-archives -patch-version @VERSION@ dose2 META $(CMAS)
else
$(INSTALL) -patch-version @VERSION@ dose2 META $(CMAS) $(CMXAS) $(ARCHIVES)
endif
install -d $(DESTDIR)/stublibs
@for i in $(DIRS); do \
$(MAKE) -C $$i cmi-install extra-install stub-install; \
done
dose2-1.4.2/Makefile.ocamlbuild 0000664 0000000 0000000 00000000362 11231374124 0016303 0 ustar 00root root 0000000 0000000 .PHONY: all clean anla
OCAMLBUILD= ocamlbuild
all: pkglab
pkglab: pkglab/pkglab.native
pkglab/pkglab.native:
$(OCAMLBUILD) pkglab/pkglab.native
anla: anla/anla.cma
anla/anla.cma:
$(OCAMLBUILD) anla/anla.cma
clean:
ocamlbuild -clean
dose2-1.4.2/README 0000664 0000000 0000000 00000004700 11231374124 0013411 0 ustar 00root root 0000000 0000000 EDOS Dose 2: OCaml libs for managing packages and their dependencies
====================================================================
Dose 2 is a framework made of several OCaml libraries for managing
distribution packages and their dependencies.
Though not tied to any particular distribution, Dose 2 forms a background of
libraries which enable injecting packages coming for various distribution.
Companion libraries (e.g. ceve) and tools (e.g. pkglab) rely on Dose 2 to
manage packages coming from various distributions, e.g. Debian and Red Hat.
Besides basic functionalities for querying and setting package properties, Dose
2 also implements algorithms for solving more complex problems (monitoring
package evolutions, correct and complete dependency resolution, repository-wide
uninstallability checks).
Dose 2 libraries
----------------
Here is a brief summary of the components of Dose 2, it also forms a
gentle introduction to the code base:
- conduit: channel-like abstraction for pretty printing facilities
- dosebase: package database, equipped with lifetime information
- io: input/output of structured data
- lifetime: life timelines, with support for disappearance/reappearance
- mmap: bindings to mmap
- napkin: abstract, distro-independent representation of package info
- ocamldeb: parsing of Debian package descriptions into napkins
- ocamlpkgsrc: parsing of NetBSD's pkgsrc packages into napkins
- ocamlrpm: parsing of RPM package descriptions into napkins
- packetology: core queries over repositories: (co-)installability, ...
- progress: textual progress bar widget
- rapids: data structure for storing historical metadata about napkins
- satsolver: SAT solving
- util: miscellaneous helpers
LICENSE
-------
Copyright (C) 2005-2008 Berke DURAK, INRIA Rocquencourt and Jaap BOENDER
Funded by the EDOS and MANCOOSI projects.
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU 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, see .
dose2-1.4.2/_tags 0000664 0000000 0000000 00000001116 11231374124 0013547 0 ustar 00root root 0000000 0000000 : camlp4o
: use_pcre
: use_pcre
: use_calendar
: use_calendar,use_pcre,use_dbm
: use_ocamlduce,use_ocsigen
: use_ocsigen
"conduit": include
"debparser": include
"debver": include
"dosebase": include
"dql": include
"io": include
"ledit": include
"lifetime": include
"napkin": include
"packetology": include
"progress": include
"rapids": include
"rpmver": include
"satsolver": include
"util": include
dose2-1.4.2/conduit/ 0000775 0000000 0000000 00000000000 11231374124 0014175 5 ustar 00root root 0000000 0000000 dose2-1.4.2/conduit/.depend 0000664 0000000 0000000 00000000102 11231374124 0015426 0 ustar 00root root 0000000 0000000 conduit.cmo: conduit.cmi
conduit.cmx: conduit.cmi
conduit.cmi:
dose2-1.4.2/conduit/Makefile 0000664 0000000 0000000 00000000146 11231374124 0015636 0 ustar 00root root 0000000 0000000 NAME = conduit
SOURCES= conduit.ml
MLIS = conduit.mli
include ../Makefile.config
include .depend
dose2-1.4.2/conduit/conduit.ml 0000664 0000000 0000000 00000002475 11231374124 0016204 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
type 'channel conduit = {
cd_out_channel : 'channel;
cd_print : 'a . 'channel -> ('a, 'channel, unit) format -> 'a;
cd_flush : 'channel -> unit;
};;
let stdoutcd = {
cd_out_channel = stdout;
cd_print = Printf.fprintf;
cd_flush = flush
};;
let stderrcd = {
cd_out_channel = stderr;
cd_print = Printf.fprintf;
cd_flush = flush
};;
let conduit_of_channel oc = {
cd_out_channel = oc;
cd_print = Printf.fprintf;
cd_flush = flush
};;
let conduit_of_buffer b =
{ cd_out_channel = b;
cd_print = Printf.bprintf;
cd_flush = ignore }
;;
let scribe_string cd oc u = cd.cd_print oc "%s" u;;
dose2-1.4.2/conduit/conduit.mli 0000664 0000000 0000000 00000002761 11231374124 0016353 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** A conduit is a channel for using formatting functions on buffers or channels. *)
type 'a conduit = {
cd_out_channel : 'a; (** Can be a buffer or a channel. *)
cd_print : 'b. 'a -> ('b, 'a, unit) format -> 'b; (** The print function. *)
cd_flush : 'a -> unit; (** The flush function. *)
}
val stdoutcd : out_channel conduit (** The conduit linked to standard output *)
val stderrcd : out_channel conduit (** The conduit linked to standard error *)
val conduit_of_channel : out_channel -> out_channel conduit (** Builds a conduit from an output channel. *)
val conduit_of_buffer : Buffer.t -> Buffer.t conduit (** Builds a conduit from a buffer. *)
val scribe_string : 'a conduit -> 'a -> string -> unit (** Writes a string into a conduit. *)
dose2-1.4.2/config.h.in 0000664 0000000 0000000 00000003756 11231374124 0014566 0 ustar 00root root 0000000 0000000 /* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the header file. */
#undef HAVE_CAML_ALLOC_H
/* Define to 1 if you have the header file. */
#undef HAVE_CAML_CUSTOM_H
/* Define to 1 if you have the header file. */
#undef HAVE_CAML_MEMORY_H
/* Define to 1 if you have the header file. */
#undef HAVE_CAML_MLVALUES_H
/* Define to 1 if you have the header file. */
#undef HAVE_FNMATCH_H
/* Define to 1 if you have the header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the header file. */
#undef HAVE_POPT_H
/* Define if rpmlead exists. */
#undef HAVE_RPMLEAD
/* Define to 1 if you have the header file. */
#undef HAVE_RPM_RPMIO_H
/* Define to 1 if you have the header file. */
#undef HAVE_RPM_RPMLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the header file. */
#undef HAVE_UNISTD_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
dose2-1.4.2/configure 0000775 0000000 0000000 00000610567 11231374124 0014456 0 ustar 00root root 0000000 0000000 #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.62 for dose2 1.4.2.
#
# Report bugs to .
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
if test "x$CONFIG_SHELL" = x; then
if (eval ":") 2>/dev/null; then
as_have_required=yes
else
as_have_required=no
fi
if test $as_have_required = yes && (eval ":
(as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=\$LINENO
as_lineno_2=\$LINENO
test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
") 2> /dev/null; then
:
else
as_candidate_shells=
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
case $as_dir in
/*)
for as_base in sh bash ksh sh5; do
as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
done;;
esac
done
IFS=$as_save_IFS
for as_shell in $as_candidate_shells $SHELL; do
# Try only shells that exist, to save several forks.
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ ("$as_shell") 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
_ASEOF
}; then
CONFIG_SHELL=$as_shell
as_have_required=yes
if { "$as_shell" 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
(as_func_return () {
(exit $1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = "$1" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test $exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
_ASEOF
}; then
break
fi
fi
done
if test "x$CONFIG_SHELL" != x; then
for as_var in BASH_ENV ENV
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fi
if test $as_have_required = no; then
echo This script requires a shell more modern than all the
echo shells that I found on your system. Please install a
echo modern shell, or manually run the script under such a
echo shell if you do have one.
{ (exit 1); exit 1; }
fi
fi
fi
(eval "as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0") || {
echo No shell found that supports shell functions.
echo Please tell bug-autoconf@gnu.org about your system,
echo including any error possibly output before this message.
echo This can help us improve future autoconf versions.
echo Configuration will now proceed without shell functions.
}
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 7<&0 &1
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='dose2'
PACKAGE_TARNAME='dose2'
PACKAGE_VERSION='1.4.2'
PACKAGE_STRING='dose2 1.4.2'
PACKAGE_BUGREPORT='boender@pps.jussieu.fr'
# Factoring default headers for most tests.
ac_includes_default="\
#include
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_SYS_STAT_H
# include
#endif
#ifdef STDC_HEADERS
# include
# include
#else
# ifdef HAVE_STDLIB_H
# include
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include
# endif
# include
#endif
#ifdef HAVE_STRINGS_H
# include
#endif
#ifdef HAVE_INTTYPES_H
# include
#endif
#ifdef HAVE_STDINT_H
# include
#endif
#ifdef HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='SHELL
PATH_SEPARATOR
PACKAGE_NAME
PACKAGE_TARNAME
PACKAGE_VERSION
PACKAGE_STRING
PACKAGE_BUGREPORT
exec_prefix
prefix
program_transform_name
bindir
sbindir
libexecdir
datarootdir
datadir
sysconfdir
sharedstatedir
localstatedir
includedir
oldincludedir
docdir
infodir
htmldir
dvidir
pdfdir
psdir
libdir
localedir
mandir
DEFS
ECHO_C
ECHO_N
ECHO_T
LIBS
build_alias
host_alias
target_alias
OCAMLC
OCAMLOPT
OCAMLCDOTOPT
OCAMLOPTDOTOPT
OCAMLDEP
OCAMLDOC
OCAMLMKLIB
OCAMLLEX
OCAMLFIND
CC
CFLAGS
LDFLAGS
CPPFLAGS
ac_ct_CC
EXEEXT
OBJEXT
CPP
GREP
EGREP
VERSION
BEST
OCAMLBEST
OCAMLZIP
LIBOBJS
LTLIBOBJS'
ac_subst_files=''
ac_user_opts='
enable_option_checking
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) { $as_echo "$as_me: error: unrecognized option: $ac_option
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; }
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
{ (exit 1); exit 1; }; }
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
{ $as_echo "$as_me: error: missing argument to $ac_option" >&2
{ (exit 1); exit 1; }; }
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) { $as_echo "$as_me: error: Unrecognized options: $ac_unrecognized_opts" >&2
{ (exit 1); exit 1; }; } ;;
*) $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
{ $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; }
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used." >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
{ $as_echo "$as_me: error: Working directory cannot be determined" >&2
{ (exit 1); exit 1; }; }
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
{ $as_echo "$as_me: error: pwd does not report name of working directory" >&2
{ (exit 1); exit 1; }; }
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then the parent directory.
ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_myself" : 'X\(//\)[^/]' \| \
X"$as_myself" : 'X\(//\)$' \| \
X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r "$srcdir/$ac_unique_file"; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
{ $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
{ (exit 1); exit 1; }; }
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
{ (exit 1); exit 1; }; }
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
eval ac_env_${ac_var}_set=\${${ac_var}+set}
eval ac_env_${ac_var}_value=\$${ac_var}
eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
eval ac_cv_env_${ac_var}_value=\$${ac_var}
done
#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures dose2 1.4.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print \`checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/dose2]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_ACEOF
cat <<\_ACEOF
_ACEOF
fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of dose2 1.4.2:";;
esac
cat <<\_ACEOF
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to .
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested configure.
if test -f "$ac_srcdir/configure.gnu"; then
echo &&
$SHELL "$ac_srcdir/configure.gnu" --help=recursive
elif test -f "$ac_srcdir/configure"; then
echo &&
$SHELL "$ac_srcdir/configure" --help=recursive
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
dose2 configure 1.4.2
generated by GNU Autoconf 2.62
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit
fi
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by dose2 $as_me 1.4.2, which was
generated by GNU Autoconf 2.62. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*\'*)
ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
2)
ac_configure_args1="$ac_configure_args1 '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
ac_configure_args="$ac_configure_args '$ac_arg'"
;;
esac
done
done
$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
cat <<\_ASBOX
## ---------------- ##
## Cache variables. ##
## ---------------- ##
_ASBOX
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
cat <<\_ASBOX
## ----------------- ##
## Output variables. ##
## ----------------- ##
_ASBOX
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
cat <<\_ASBOX
## ------------------- ##
## File substitutions. ##
## ------------------- ##
_ASBOX
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
cat <<\_ASBOX
## ----------- ##
## confdefs.h. ##
## ----------- ##
_ASBOX
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
ac_site_file1=$CONFIG_SITE
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test -r "$ac_site_file"; then
{ $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special
# files actually), so we avoid doing that.
if test -f "$cache_file"; then
{ $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val=\$ac_cv_env_${ac_var}_value
eval ac_new_val=\$ac_env_${ac_var}_value
case $ac_old_set,$ac_new_set in
set,)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
{ { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
VERSION=$PACKAGE_VERSION
{ $as_echo "$as_me:$LINENO: result: configuring $PACKAGE_STRING" >&5
$as_echo "configuring $PACKAGE_STRING" >&6; }
# find ocaml
# Extract the first word of "ocamlc", so it can be a program name with args.
set dummy ocamlc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_OCAMLC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$OCAMLC"; then
ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_OCAMLC="`which ocamlc`"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_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
{ $as_echo "$as_me:$LINENO: result: $OCAMLC" >&5
$as_echo "$OCAMLC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLC" = no ; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamlc." >&5
$as_echo "$as_me: error: Could not find ocamlc." >&2;}
{ (exit 1); exit 1; }; }
fi
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 -n 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
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLOPT+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLOPT in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLOPT="$OCAMLOPT" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLOPT="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLOPT" && ac_cv_path_OCAMLOPT="no"
;;
esac
fi
OCAMLOPT=$ac_cv_path_OCAMLOPT
if test -n "$OCAMLOPT"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLOPT" >&5
$as_echo "$OCAMLOPT" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
{ $as_echo "$as_me:$LINENO: WARNING: Could not find ocamlopt; bytecode compilation only." >&5
$as_echo "$as_me: WARNING: Could not find ocamlopt; bytecode compilation only." >&2;}
else
{ $as_echo "$as_me:$LINENO: checking ocamlopt version" >&5
$as_echo_n "checking ocamlopt version... " >&6; }
TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:$LINENO: result: differs from ocamlc; ocamlopt discarded." >&5
$as_echo "differs from ocamlc; ocamlopt discarded." >&6; }
OCAMLOPT=no
else
{ $as_echo "$as_me:$LINENO: result: ok" >&5
$as_echo "ok" >&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
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLCDOTOPT+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLCDOTOPT in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLCDOTOPT="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLCDOTOPT" && ac_cv_path_OCAMLCDOTOPT="no"
;;
esac
fi
OCAMLCDOTOPT=$ac_cv_path_OCAMLCDOTOPT
if test -n "$OCAMLCDOTOPT"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLCDOTOPT" >&5
$as_echo "$OCAMLCDOTOPT" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLCDOTOPT" != no ; then
{ $as_echo "$as_me:$LINENO: checking ocamlc.opt version" >&5
$as_echo_n "checking ocamlc.opt version... " >&6; }
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:$LINENO: result: differs from ocamlc; ocamlc.opt discarded." >&5
$as_echo "differs from ocamlc; ocamlc.opt discarded." >&6; }
else
{ $as_echo "$as_me:$LINENO: result: ok" >&5
$as_echo "ok" >&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
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLOPTDOTOPT+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLOPTDOTOPT in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLOPTDOTOPT="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLOPTDOTOPT" && ac_cv_path_OCAMLOPTDOTOPT="no"
;;
esac
fi
OCAMLOPTDOTOPT=$ac_cv_path_OCAMLOPTDOTOPT
if test -n "$OCAMLOPTDOTOPT"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLOPTDOTOPT" >&5
$as_echo "$OCAMLOPTDOTOPT" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLOPTDOTOPT" != no ; then
{ $as_echo "$as_me:$LINENO: checking ocamlc.opt version" >&5
$as_echo_n "checking ocamlc.opt version... " >&6; }
TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
if test "$TMPVER" != "$OCAMLVERSION" ; then
{ $as_echo "$as_me:$LINENO: result: differs from ocamlc; ocamlopt.opt discarded." >&5
$as_echo "differs from ocamlc; ocamlopt.opt discarded." >&6; }
else
{ $as_echo "$as_me:$LINENO: result: ok" >&5
$as_echo "ok" >&6; }
OCAMLOPT=$OCAMLOPTDOTOPT
fi
fi
fi
if test "$OCAMLOPT" = no ; then
BEST="bcl"
else
BEST="bcl ncl"
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
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLDEP+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLDEP in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLDEP="$OCAMLDEP" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLDEP="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLDEP" && ac_cv_path_OCAMLDEP="no"
;;
esac
fi
OCAMLDEP=$ac_cv_path_OCAMLDEP
if test -n "$OCAMLDEP"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLDEP" >&5
$as_echo "$OCAMLDEP" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLDEP" = no ; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamldep." >&5
$as_echo "$as_me: error: Could not find ocamldep." >&2;}
{ (exit 1); exit 1; }; }
fi
# Extract the first word of "ocamldoc", so it can be a program name with args.
set dummy ocamldoc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLDOC+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLDOC in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLDOC="$OCAMLDOC" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLDOC="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLDOC" && ac_cv_path_OCAMLDOC="no"
;;
esac
fi
OCAMLDOC=$ac_cv_path_OCAMLDOC
if test -n "$OCAMLDOC"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLDOC" >&5
$as_echo "$OCAMLDOC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
# Extract the first word of "ocamlmklib", so it can be a program name with args.
set dummy ocamlmklib; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLMKLIB+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLMKLIB in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLMKLIB="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLMKLIB" && ac_cv_path_OCAMLMKLIB="no"
;;
esac
fi
OCAMLMKLIB=$ac_cv_path_OCAMLMKLIB
if test -n "$OCAMLMKLIB"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLMKLIB" >&5
$as_echo "$OCAMLMKLIB" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLMKLIB" = no ; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamlmklib." >&5
$as_echo "$as_me: error: Could not find ocamlmklib." >&2;}
{ (exit 1); exit 1; }; }
fi
# Extract the first word of "ocamllex", so it can be a program name with args.
set dummy ocamllex; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLLEX+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLLEX in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLLEX="$OCAMLLEX" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLLEX="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLLEX" && ac_cv_path_OCAMLLEX="no"
;;
esac
fi
OCAMLLEX=$ac_cv_path_OCAMLLEX
if test -n "$OCAMLLEX"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLLEX" >&5
$as_echo "$OCAMLLEX" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLLEX" = no ; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamllex." >&5
$as_echo "$as_me: error: Could not find ocamllex." >&2;}
{ (exit 1); exit 1; }; }
fi
CAMLLIBPATH=`$OCAMLC -where`
# other progs
# Extract the first word of "ocamlfind", so it can be a program name with args.
set dummy ocamlfind; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_OCAMLFIND+set}" = set; then
$as_echo_n "(cached) " >&6
else
case $OCAMLFIND in
[\\/]* | ?:[\\/]*)
ac_cv_path_OCAMLFIND="$OCAMLFIND" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_OCAMLFIND="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_OCAMLFIND" && ac_cv_path_OCAMLFIND="no"
;;
esac
fi
OCAMLFIND=$ac_cv_path_OCAMLFIND
if test -n "$OCAMLFIND"; then
{ $as_echo "$as_me:$LINENO: result: $OCAMLFIND" >&5
$as_echo "$OCAMLFIND" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$OCAMLFIND" = no ; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamlfind." >&5
$as_echo "$as_me: error: Could not find ocamlfind." >&2;}
{ (exit 1); exit 1; }; }
fi
{ { $as_echo "$as_me:$LINENO: checking for zip with ocamlfind" >&5
$as_echo_n "checking for zip with ocamlfind... " >&6; }; \
if ( x=`$OCAMLFIND -query zip` ); \
then OCAMLZIP=zip; { $as_echo "$as_me:$LINENO: result: found" >&5
$as_echo "found" >&6; }; \
else OCAMLZIP=no; { $as_echo "$as_me:$LINENO: result: not found" >&5
$as_echo "not found" >&6; }; \
fi;
}
if test "$OCAMLZIP" = no; then
{ { $as_echo "$as_me:$LINENO: checking for camlzip with ocamlfind" >&5
$as_echo_n "checking for camlzip with ocamlfind... " >&6; }; \
if ( x=`$OCAMLFIND -query camlzip` ); \
then OCAMLZIP=camlzip; { $as_echo "$as_me:$LINENO: result: found" >&5
$as_echo "found" >&6; }; \
else OCAMLZIP=no; { $as_echo "$as_me:$LINENO: result: not found" >&5
$as_echo "not found" >&6; }; \
fi;
}
if test "$OCAMLZIP" = no; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamlzip." >&5
$as_echo "$as_me: error: Could not find ocamlzip." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
{ { $as_echo "$as_me:$LINENO: checking for bz2 with ocamlfind" >&5
$as_echo_n "checking for bz2 with ocamlfind... " >&6; }; \
if ( x=`$OCAMLFIND -query bz2` ); \
then OCAMLBZ2=bz2; { $as_echo "$as_me:$LINENO: result: found" >&5
$as_echo "found" >&6; }; \
else OCAMLBZ2=no; { $as_echo "$as_me:$LINENO: result: not found" >&5
$as_echo "not found" >&6; }; \
fi;
}
if test "$OCAMLBZ2" = no; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocamlbz2." >&5
$as_echo "$as_me: error: Could not find ocamlbz2." >&2;}
{ (exit 1); exit 1; }; }
fi
{ { $as_echo "$as_me:$LINENO: checking for pcre with ocamlfind" >&5
$as_echo_n "checking for pcre with ocamlfind... " >&6; }; \
if ( x=`$OCAMLFIND -query pcre` ); \
then OCAMLPCRE=pcre; { $as_echo "$as_me:$LINENO: result: found" >&5
$as_echo "found" >&6; }; \
else OCAMLPCRE=no; { $as_echo "$as_me:$LINENO: result: not found" >&5
$as_echo "not found" >&6; }; \
fi;
}
if test "$OCAMLPCRE" = no; then
{ { $as_echo "$as_me:$LINENO: error: Could not find ocaml-pcre." >&5
$as_echo "$as_me: error: Could not find ocaml-pcre." >&2;}
{ (exit 1); exit 1; }; }
fi
{ { $as_echo "$as_me:$LINENO: checking for calendar with ocamlfind" >&5
$as_echo_n "checking for calendar with ocamlfind... " >&6; }; \
if ( x=`$OCAMLFIND -query calendar` ); \
then OCAMLCALENDAR=calendar; { $as_echo "$as_me:$LINENO: result: found" >&5
$as_echo "found" >&6; }; \
else OCAMLCALENDAR=no; { $as_echo "$as_me:$LINENO: result: not found" >&5
$as_echo "not found" >&6; }; \
fi;
}
if test "$OCAMLCALENDAR" = no; then
{ { $as_echo "$as_me:$LINENO: error: Could not find calendar." >&5
$as_echo "$as_me: error: Could not find calendar." >&2;}
{ (exit 1); exit 1; }; }
else
if test `ocamlfind query -format "%v" calendar` \< "2"; then
{ { $as_echo "$as_me:$LINENO: error: Calendar >= 2.0.0 needed." >&5
$as_echo "$as_me: error: Calendar >= 2.0.0 needed." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
ac_config_headers="$ac_config_headers config.h"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet. If you think this
configuration is useful to you, please write to autoconf@gnu.org." >&5
$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet. If you think this
configuration is useful to you, please write to autoconf@gnu.org." >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet. If you think this
configuration is useful to you, please write to autoconf@gnu.org." >&5
$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet. If you think this
configuration is useful to you, please write to autoconf@gnu.org." >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&5
$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
# Provide some information about the compiler.
$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
{ (ac_try="$ac_compiler --version >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler --version >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -v >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -v >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -V >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -V >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { (ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
if test -z "$ac_file"; then
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C compiler cannot create executables
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
fi
ac_exeext=$ac_cv_exeext
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
if { ac_try='./$ac_file'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest$ac_cv_exeext
{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if test "${ac_cv_objext+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if test "${ac_cv_c_compiler_gnu+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_compiler_gnu=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if test "${ac_cv_prog_cc_g+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
CFLAGS=""
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if test "${ac_cv_prog_cc_c89+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_c89=$ac_arg
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:$LINENO: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:$LINENO: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
:
else
{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if test "${ac_cv_path_GREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if test "${ac_cv_path_EGREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if test "${ac_cv_header_stdc+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_header_stdc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then
:
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
:
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_header_stdc=no
fi
rm -rf conftest.dSYM
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
cat >>confdefs.h <<\_ACEOF
#define STDC_HEADERS 1
_ACEOF
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
eval "$as_ac_Header=yes"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_Header=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in fnmatch.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find fnmatch.h" >&5
$as_echo "$as_me: error: Could not find fnmatch.h" >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in popt.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find popt headers." >&5
$as_echo "$as_me: error: Could not find popt headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in rpm/rpmlib.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find RPM headers." >&5
$as_echo "$as_me: error: Could not find RPM headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in rpm/rpmio.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find RPM headers." >&5
$as_echo "$as_me: error: Could not find RPM headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in caml/mlvalues.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find OCaml headers." >&5
$as_echo "$as_me: error: Could not find OCaml headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in caml/memory.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find OCaml headers." >&5
$as_echo "$as_me: error: Could not find OCaml headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in caml/alloc.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find OCaml headers." >&5
$as_echo "$as_me: error: Could not find OCaml headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
for ac_header in caml/custom.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
$as_echo_n "checking $ac_header usability... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
$as_echo_n "checking $ac_header presence... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------- ##
## Report this to boender@pps.jussieu.fr ##
## ------------------------------------- ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
$as_echo_n "checking for $ac_header... " >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
if test `eval 'as_val=${'$as_ac_Header'}
$as_echo "$as_val"'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
{ { $as_echo "$as_me:$LINENO: error: Could not find OCaml headers." >&5
$as_echo "$as_me: error: Could not find OCaml headers." >&2;}
{ (exit 1); exit 1; }; }
fi
done
{ $as_echo "$as_me:$LINENO: checking for struct rpmlead.major" >&5
$as_echo_n "checking for struct rpmlead.major... " >&6; }
if test "${ac_cv_member_struct_rpmlead_major+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static struct rpmlead ac_aggr;
if (ac_aggr.major)
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_member_struct_rpmlead_major=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static struct rpmlead ac_aggr;
if (sizeof ac_aggr.major)
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_member_struct_rpmlead_major=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_member_struct_rpmlead_major=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_member_struct_rpmlead_major" >&5
$as_echo "$ac_cv_member_struct_rpmlead_major" >&6; }
if test $ac_cv_member_struct_rpmlead_major = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_RPMLEAD 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for library containing poptGetContext" >&5
$as_echo_n "checking for library containing poptGetContext... " >&6; }
if test "${ac_cv_search_poptGetContext+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char poptGetContext ();
int
main ()
{
return poptGetContext ();
;
return 0;
}
_ACEOF
for ac_lib in '' popt; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_search_poptGetContext=$ac_res
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext
if test "${ac_cv_search_poptGetContext+set}" = set; then
break
fi
done
if test "${ac_cv_search_poptGetContext+set}" = set; then
:
else
ac_cv_search_poptGetContext=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_poptGetContext" >&5
$as_echo "$ac_cv_search_poptGetContext" >&6; }
ac_res=$ac_cv_search_poptGetContext
if test "$ac_res" != no; then
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
{ { $as_echo "$as_me:$LINENO: error: Could not find popt library." >&5
$as_echo "$as_me: error: Could not find popt library." >&2;}
{ (exit 1); exit 1; }; }
fi
{ $as_echo "$as_me:$LINENO: checking for library containing fdWritable" >&5
$as_echo_n "checking for library containing fdWritable... " >&6; }
if test "${ac_cv_search_fdWritable+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char fdWritable ();
int
main ()
{
return fdWritable ();
;
return 0;
}
_ACEOF
for ac_lib in '' rpmio; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_search_fdWritable=$ac_res
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext
if test "${ac_cv_search_fdWritable+set}" = set; then
break
fi
done
if test "${ac_cv_search_fdWritable+set}" = set; then
:
else
ac_cv_search_fdWritable=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_fdWritable" >&5
$as_echo "$ac_cv_search_fdWritable" >&6; }
ac_res=$ac_cv_search_fdWritable
if test "$ac_res" != no; then
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
{ { $as_echo "$as_me:$LINENO: error: Could not find RPM library." >&5
$as_echo "$as_me: error: Could not find RPM library." >&2;}
{ (exit 1); exit 1; }; }
fi
{ $as_echo "$as_me:$LINENO: checking for library containing rpmdbOpen" >&5
$as_echo_n "checking for library containing rpmdbOpen... " >&6; }
if test "${ac_cv_search_rpmdbOpen+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char rpmdbOpen ();
int
main ()
{
return rpmdbOpen ();
;
return 0;
}
_ACEOF
for ac_lib in '' rpmdb; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib -lrpm $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_search_rpmdbOpen=$ac_res
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext
if test "${ac_cv_search_rpmdbOpen+set}" = set; then
break
fi
done
if test "${ac_cv_search_rpmdbOpen+set}" = set; then
:
else
ac_cv_search_rpmdbOpen=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_rpmdbOpen" >&5
$as_echo "$ac_cv_search_rpmdbOpen" >&6; }
ac_res=$ac_cv_search_rpmdbOpen
if test "$ac_res" != no; then
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
{ $as_echo "$as_me:$LINENO: checking for library containing rpmVerifyFile" >&5
$as_echo_n "checking for library containing rpmVerifyFile... " >&6; }
if test "${ac_cv_search_rpmVerifyFile+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char rpmVerifyFile ();
int
main ()
{
return rpmVerifyFile ();
;
return 0;
}
_ACEOF
for ac_lib in '' rpm; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_search_rpmVerifyFile=$ac_res
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext
if test "${ac_cv_search_rpmVerifyFile+set}" = set; then
break
fi
done
if test "${ac_cv_search_rpmVerifyFile+set}" = set; then
:
else
ac_cv_search_rpmVerifyFile=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_rpmVerifyFile" >&5
$as_echo "$ac_cv_search_rpmVerifyFile" >&6; }
ac_res=$ac_cv_search_rpmVerifyFile
if test "$ac_res" != no; then
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
{ { $as_echo "$as_me:$LINENO: error: Could not find RPM library." >&5
$as_echo "$as_me: error: Could not find RPM library." >&2;}
{ (exit 1); exit 1; }; }
fi
ac_config_files="$ac_config_files Makefile Makefile.config ocamldeb/Makefile io/Makefile META"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;; #(
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
test "x$cache_file" != "x/dev/null" &&
{ $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
cat confcache >$cache_file
else
{ $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
# Save the log message, to keep $[0] and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by dose2 $as_me 1.4.2, which was
generated by GNU Autoconf 2.62. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
-q, --quiet do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to ."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
dose2 config.status 1.4.2
configured by $0, generated by GNU Autoconf 2.62,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
Copyright (C) 2008 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
{ $as_echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { $as_echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
"ocamldeb/Makefile") CONFIG_FILES="$CONFIG_FILES ocamldeb/Makefile" ;;
"io/Makefile") CONFIG_FILES="$CONFIG_FILES io/Makefile" ;;
"META") CONFIG_FILES="$CONFIG_FILES META" ;;
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp=
trap 'exit_status=$?
{ test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} ||
{
$as_echo "$as_me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr='
'
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` = $ac_delim_num; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\).*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\).*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
|| { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
$as_echo "$as_me: error: could not setup config files machinery" >&2;}
{ (exit 1); exit 1; }; }
_ACEOF
# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/
s/:*\${srcdir}:*/:/
s/:*@srcdir@:*/:/
s/^\([^=]*=[ ]*\):*/\1/
s/:*$//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_t=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_t"; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' >$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
prefix = substr(line, 1, index(line, defundef) - 1)
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", line, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
{ { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
{ (exit 1); exit 1; }; }
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
$as_echo "$as_me: error: Invalid tag $ac_tag." >&2;}
{ (exit 1); exit 1; }; };;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
{ { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
{ (exit 1); exit 1; }; };;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
ac_file_inputs="$ac_file_inputs '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:$LINENO: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
{ as_dir="$ac_dir"
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p
'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_datarootdir_hack='
s&@datadir@&$datadir&g
s&@docdir@&$docdir&g
s&@infodir@&$infodir&g
s&@localedir@&$localedir&g
s&@mandir@&$mandir&g
s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&2;}
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out" && rm -f "$tmp/out";;
*) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
esac \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
} >"$tmp/config.h" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$tmp/config.h" "$ac_file" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
|| { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
$as_echo "$as_me: error: could not create -" >&2;}
{ (exit 1); exit 1; }; }
fi
;;
esac
done # for ac_tag
{ (exit 0); exit 0; }
_ACEOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
{ { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;}
fi
dose2-1.4.2/configure.ac 0000664 0000000 0000000 00000011610 11231374124 0015015 0 ustar 00root root 0000000 0000000 # Parts of this file shamelessly ripped from ocaml-ssl's configure.ac
AC_DEFUN([AC_CHECK_OCAMLFIND],
[{ AC_MSG_CHECKING([for $2 with ocamlfind]); \
if ( x=`$OCAMLFIND -query $2` ); \
then $1=$2; AC_MSG_RESULT([found]); \
else $1=$3; AC_MSG_RESULT([not found]); \
fi;
}])
# Package and version stuff
AC_INIT(dose2, 1.4.2, boender@pps.jussieu.fr)
VERSION=$PACKAGE_VERSION
AC_MSG_RESULT([configuring $PACKAGE_STRING])
# find ocaml
AC_CHECK_PROG(OCAMLC,ocamlc,`which ocamlc`,no)
if test "$OCAMLC" = no ; then
AC_MSG_ERROR(Could not find ocamlc.)
fi
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 -n 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_PATH_PROG(OCAMLOPT,ocamlopt,no)
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
AC_MSG_WARN(Could not 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
# checking for ocamlc.opt
AC_PATH_PROG(OCAMLCDOTOPT,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_PATH_PROG(OCAMLOPTDOTOPT,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
if test "$OCAMLOPT" = no ; then
BEST="bcl"
else
BEST="bcl ncl"
fi
# ocamldep, ocamllex and ocamlyacc should also be present in the path
AC_PATH_PROG(OCAMLDEP,ocamldep,no)
if test "$OCAMLDEP" = no ; then
AC_MSG_ERROR(Could not find ocamldep.)
fi
AC_PATH_PROG(OCAMLDOC,ocamldoc,no)
AC_PATH_PROG(OCAMLMKLIB,ocamlmklib,no)
if test "$OCAMLMKLIB" = no ; then
AC_MSG_ERROR(Could not find ocamlmklib.)
fi
AC_PATH_PROG(OCAMLLEX,ocamllex,no)
if test "$OCAMLLEX" = no ; then
AC_MSG_ERROR(Could not find ocamllex.)
fi
CAMLLIBPATH=`$OCAMLC -where`
# other progs
AC_PATH_PROG(OCAMLFIND,ocamlfind,no)
if test "$OCAMLFIND" = no ; then
AC_MSG_ERROR(Could not find ocamlfind.)
fi
AC_CHECK_OCAMLFIND(OCAMLZIP,zip,no)
if test "$OCAMLZIP" = no; then
AC_CHECK_OCAMLFIND(OCAMLZIP,camlzip,no)
if test "$OCAMLZIP" = no; then
AC_MSG_ERROR(Could not find ocamlzip.)
fi
fi
AC_CHECK_OCAMLFIND(OCAMLBZ2,bz2,no)
if test "$OCAMLBZ2" = no; then
AC_MSG_ERROR(Could not find ocamlbz2.)
fi
AC_CHECK_OCAMLFIND(OCAMLPCRE,pcre,no)
if test "$OCAMLPCRE" = no; then
AC_MSG_ERROR(Could not find ocaml-pcre.)
fi
AC_CHECK_OCAMLFIND(OCAMLCALENDAR,calendar,no)
if test "$OCAMLCALENDAR" = no; then
AC_MSG_ERROR(Could not find calendar.)
else
if test `ocamlfind query -format "%v" calendar` \< "2"; then
AC_MSG_ERROR(Calendar >= 2.0.0 needed.)
fi
fi
AC_CONFIG_HEADERS([config.h])
AC_CHECK_HEADERS([fnmatch.h],,AC_MSG_ERROR(Could not find fnmatch.h))
AC_CHECK_HEADERS([popt.h],,AC_MSG_ERROR(Could not find popt headers.))
AC_CHECK_HEADERS([rpm/rpmlib.h],,AC_MSG_ERROR(Could not find RPM headers.))
AC_CHECK_HEADERS([rpm/rpmio.h],,AC_MSG_ERROR(Could not find RPM headers.))
AC_CHECK_HEADERS([caml/mlvalues.h],,AC_MSG_ERROR(Could not find OCaml headers.))
AC_CHECK_HEADERS([caml/memory.h],,AC_MSG_ERROR(Could not find OCaml headers.))
AC_CHECK_HEADERS([caml/alloc.h],,AC_MSG_ERROR(Could not find OCaml headers.))
AC_CHECK_HEADERS([caml/custom.h],,AC_MSG_ERROR(Could not find OCaml headers.))
AC_CHECK_MEMBER([struct rpmlead.major],[AC_DEFINE([HAVE_RPMLEAD],[1],[Define if rpmlead exists.])])
AC_SEARCH_LIBS([poptGetContext],[popt],,AC_MSG_ERROR(Could not find popt library.))
AC_SEARCH_LIBS([fdWritable],[rpmio],,AC_MSG_ERROR(Could not find RPM library.))
AC_SEARCH_LIBS([rpmdbOpen],[rpmdb],,,[-lrpm],,AC_MSG_ERROR(Could not find RPM library.))
AC_SEARCH_LIBS([rpmVerifyFile],[rpm],,AC_MSG_ERROR(Could not find RPM library.))
AC_SUBST(VERSION)
AC_SUBST(BEST)
AC_SUBST(OCAMLC)
AC_SUBST(OCAMLOPT)
AC_SUBST(OCAMLBEST)
AC_SUBST(OCAMLMKLIB)
AC_SUBST(OCAMLLEX)
AC_SUBST(OCAMLZIP)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_CONFIG_FILES([Makefile Makefile.config ocamldeb/Makefile io/Makefile META])
AC_OUTPUT
dose2-1.4.2/dosebase/ 0000775 0000000 0000000 00000000000 11231374124 0014315 5 ustar 00root root 0000000 0000000 dose2-1.4.2/dosebase/.depend 0000664 0000000 0000000 00000000107 11231374124 0015553 0 ustar 00root root 0000000 0000000 dosebase.cmo: dosebase.cmi
dosebase.cmx: dosebase.cmi
dosebase.cmi:
dose2-1.4.2/dosebase/Makefile 0000664 0000000 0000000 00000000236 11231374124 0015756 0 ustar 00root root 0000000 0000000 NAME = dosebase
SOURCES= dosebase.ml
MLIS = dosebase.mli
PACKAGES= dbm,pcre
REQUIRES= lifetime napkin io util
include ../Makefile.config
include .depend
dose2-1.4.2/dosebase/TODO 0000664 0000000 0000000 00000000171 11231374124 0015004 0 ustar 00root root 0000000 0000000 TO DO
=====
Bug in joining intervals (e.g. 855resolution'0.3-4 : 2006-01-01 to 2006-07-30 then 2006-07-31 to 2006-12-01)
dose2-1.4.2/dosebase/dosebase.ml 0000664 0000000 0000000 00000046245 11231374124 0016447 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, Inria Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
open Napkin;;
module G = Generic_io;;
exception Warning of string;;
module Mmap =
struct
type t = Unix.file_descr
let unmap fd = ()
let map fd = fd
let sub fd off lgt =
ignore (Unix.LargeFile.lseek fd off Unix.SEEK_SET);
let u = String.create lgt in
let rec loop i m =
if m = 0 then
u
else
begin
let n = Unix.read fd u i m in
loop (i + n) (m - n)
end
in
loop 0 lgt
end
;;
let fmt = G.Asc;;
let sf = Printf.sprintf;;
(*** io_field_description, io_field *)
let io_field_description = io_pair io_int (io_list (io_triple io_string io_int64 io_int));;
let io_field = io_pair io_string (io_list io_string);;
let io_log = io_quadruple io_float io_int io_string io_string;;
(* ***)
let field_name_prefix = "field.";;
(*** sanitize_field_name, unsanitize_field_name *)
let sanitize_field_name b fn = Util.sanitize_filename ~buffer:b ~prefix:field_name_prefix fn;;
let unsanitize_field_name b fn = Util.unsanitize_filename ~buffer:b ~prefix:field_name_prefix fn;;
(* ***)
(*** packages_cat,lifetime_cat,count_cat *)
let packages_cat = "pkg";;
let lifetime_cat = "lf";;
let population_cat = "pop";;
let type_cat = "type";;
(* ***)
let separator = '\t';;
(*** make_key *)
let make_key b category elements =
Buffer.clear b;
List.iter
begin fun k ->
Buffer.add_char b separator;
Buffer.add_string b k
end
(category :: elements);
Buffer.contents b
;;
(* ***)
(*** make_lifetime_key *)
let make_lifetime_key ~buffer ~archive ~unit_name ~version ~architecture =
make_key buffer lifetime_cat [archive;unit_name;version;architecture]
;;
(* ***)
let make_package_key ~buffer ~unit_name ~version ~architecture =
make_key buffer packages_cat [unit_name;version;architecture]
;;
(* ***)
(*** decompose_key *)
let decompose_key k =
match Util.split_at separator k with
| category :: elements -> (category, elements)
| _ -> invalid_arg "decompose_key"
;;
(* ***)
(*** get_field *)
let rec get_field key = function
| [] -> raise Not_found
| (key',v1,v2)::rest ->
if Util.lowercase_compare key key' then
(v1,v2)
else
get_field key rest
;;
(* ***)
(*** get_field_first *)
let rec get_field_first key = function
| [] -> raise Not_found
| (key',v1,_)::rest ->
if Util.lowercase_compare key key' then
v1
else
get_field_first key rest
;;
(* ***)
(*** Out *)
module Out =
struct
type t = {
db_base : string;
db_timestamp : float;
mutable db_count : int;
mutable db_population : int;
mutable db_type : string;
db_dbm : Dbm.t;
db_fields : (string, out_channel) Hashtbl.t;
db_buffer : Buffer.t;
db_log : out_channel
}
(*** count_population *)
let count_population dbm =
let count = ref 0 in
Dbm.iter
begin fun key data ->
match decompose_key key with
| (category, _) when category = packages_cat -> incr count
| _ -> ()
end
dbm;
!count
;;
(* ***)
(*** open_out *)
let open_out ?set_type base =
if not (Sys.file_exists base) then
Unix.mkdir base 0o755;
let log_file =
Filename.concat base (Printf.sprintf "log.%s" (Util.string_of_iso_8601 (Util.today ())))
in
let dbm = Dbm.opendbm (Filename.concat base "index") [Dbm.Dbm_rdwr; Dbm.Dbm_create] 0o644 in
let population =
try
int_of_string (Dbm.find dbm population_cat)
with
| Not_found -> count_population dbm
in
let db_type =
try
Dbm.find dbm type_cat
with
| Not_found -> "unknown"
in
let type_to_set = match set_type with
None -> db_type
| Some s -> begin
if db_type = s then s
else if db_type = "unknown" then s
else raise (Failure (Printf.sprintf ("Type in database and type to set do not match (%s vs %s)") db_type s))
end
in
{ db_base = base;
db_timestamp = Unix.gettimeofday ();
db_log = open_out_gen [Open_wronly;Open_append;Open_creat;Open_binary] 0o644 log_file;
db_count = 0;
db_population = population;
db_type = type_to_set;
db_dbm = dbm;
db_buffer = Buffer.create 256;
db_fields = Hashtbl.create 256 }
;;
(* ***)
(*** get_field_file *)
let get_field_file db field =
try
Hashtbl.find db.db_fields field
with
| Not_found ->
let field' = String.lowercase field in
try
Hashtbl.find db.db_fields field'
with
| Not_found ->
(*let dbm = Dbm.opendbm ("field."^field^".database") [Dbm.Dbm_rdwr; Dbm.Dbm_create] 0o644 in*)
let fn = sanitize_field_name db.db_buffer field' in
let oc = open_out_gen [Open_wronly;Open_append;Open_creat;Open_binary] 0o644 (Filename.concat db.db_base fn) in
LargeFile.seek_out oc (LargeFile.out_channel_length oc);
Hashtbl.add db.db_fields field oc;
Hashtbl.add db.db_fields field' oc;
oc
;;
(* ***)
(*** dbm_replace *)
let dbm_replace db key data =
(*Printf.eprintf "%f %d %S (%d)\n%!" db.db_timestamp db.db_count key (String.length data);*)
G.save_to_channel ~header:false ~fmt io_log (db.db_timestamp,db.db_count,key,data) db.db_log;
output_char db.db_log '\n';
db.db_count <- 1 + db.db_count;
Dbm.replace db.db_dbm key data
;;
(* ***)
(*** close_out *)
let close_out db =
dbm_replace db type_cat db.db_type;
close_out db.db_log;
Dbm.close db.db_dbm;
Hashtbl.iter (fun _ oc -> close_out oc) db.db_fields
;;
(* ***)
(*** rebuild_index *)
(* Rebuild the index from log files. *)
let rebuild_index base =
let fn = Filename.concat base "index" in
let attempt f = try ignore (Lazy.force f) with _ -> () in
attempt (lazy (Unix.unlink (fn^".dir")));
attempt (lazy (Unix.unlink (fn^".pag")));
let dbm = Dbm.opendbm (Filename.concat base "index") [Dbm.Dbm_rdwr; Dbm.Dbm_create] 0o644 in
let dir = Unix.opendir base in
try
let times = Hashtbl.create 16384 in
while true do
let fn = Unix.readdir dir in
if Util.is_prefix "log." fn then
begin
Printf.printf "Processing %S...\n%!" fn;
let ic = open_in_bin (Filename.concat base fn) in
let n = in_channel_length ic in
begin
try
let i = G.in_from_channel ~header:false ~fmt ic in
while pos_in ic < n do
let (timestamp,count,key,data) = read io_log i in
Printf.printf "%f %d %S (%d)\n%!" timestamp count key (String.length data);
try
let old_timestamp = Hashtbl.find times key in
if (timestamp,count) > old_timestamp then
begin
Dbm.replace dbm key data;
Hashtbl.replace times key (timestamp,count)
end
else
()
with
| Not_found ->
Dbm.replace dbm key data;
Hashtbl.add times key (timestamp,count)
done;
Printf.printf "Processed %S OK.\n%!" fn
with
| x -> Printf.printf "Error: %s\n%!" (Printexc.to_string x)
end;
close_in ic
end
done
with
| End_of_file ->
Unix.closedir dir;
Dbm.close dbm
;;
(* ***)
(*** add_lifetime *)
let add_lifetime db ~archive ~unit_name ~version ~architecture ~day =
let key = make_lifetime_key ~buffer:db.db_buffer ~archive ~unit_name ~version ~architecture in
let lf =
try
G.from_string ~header:false ~fmt Lifetime.io_lifetime (Dbm.find db.db_dbm key)
with
| Not_found -> Lifetime.empty
in
let lf = Lifetime.add_day lf day in
dbm_replace db key (G.to_string ~header:false ~fmt Lifetime.io_lifetime lf)
;;
(* ***)
(*** add_package *)
let add_package db ~archive ~day fields =
let unit_name = get_field_first "package" fields
and version = get_field_first "version" fields
and architecture = get_field_first "architecture" fields
in
add_lifetime db ~archive ~unit_name ~version ~architecture ~day;
let key = make_package_key ~buffer:db.db_buffer ~unit_name ~version ~architecture in
try
ignore (Dbm.find db.db_dbm key)
with
| Not_found ->
let package_id = db.db_population in
db.db_population <- 1 + db.db_population;
let mp =
List.map
begin fun (field, first, rest) ->
let oc = get_field_file db field in
let x = (first, rest) in
let u = G.to_string ~header:false ~fmt io_field x in
let m = String.length u in
let entry = (field, LargeFile.pos_out oc, m) in
output_string oc u;
output_char oc '\n';
entry
end
fields
in
let mp' = G.to_string ~header:false ~fmt io_field_description (package_id, mp) in
dbm_replace db key mp';
dbm_replace db population_cat (sf "%d" db.db_population)
;;
(* ***)
end
;;
(* ***)
(*** In *)
module In =
struct
type t = {
db_base : string;
db_dbm : Dbm.t;
db_fields : (string, Unix.file_descr * Mmap.t) Hashtbl.t;
db_known_fields : string list;
db_buffer : Buffer.t
};;
type package = int * (string * int64 * int) list;;
(*** known_fields *)
let known_fields db = db.db_known_fields;;
(* ***)
(*** scan_fields *)
let scan_fields base buffer =
let dir = Unix.opendir base in
let rec loop result =
match
try
Some(Unix.readdir dir)
with
| End_of_file ->
Unix.closedir dir;
None
with
| None -> result
| Some name ->
if Util.is_prefix field_name_prefix name then
begin
let field = unsanitize_field_name buffer name in
loop (field :: result)
end
else
loop result
in
loop []
;;
(* ***)
(*** open_in *)
let open_in base =
let buffer = Buffer.create 256 in
{ db_base = base;
db_dbm = Dbm.opendbm (Filename.concat base "index") [Dbm.Dbm_rdonly] 0o644;
db_buffer = buffer;
db_known_fields = scan_fields base buffer;
db_fields = Hashtbl.create 256 }
;;
(* ***)
(*** close_in *)
let close_in db =
Dbm.close db.db_dbm;
List.iter
begin fun field ->
try
let (fd,mp) = Hashtbl.find db.db_fields field in
Mmap.unmap mp;
Unix.close fd
with
| Not_found -> ()
end
db.db_known_fields
;;
(* ***)
(*** count_population *)
let count_population db =
int_of_string (Dbm.find db.db_dbm population_cat)
;;
(* ***)
let get_type db =
try
Dbm.find db.db_dbm type_cat
with Not_found -> "unknown"
;;
(*** iter *)
let iter
?(package = (fun ~unit_name ~version ~architecture _ -> ()))
?(lifetime = (fun ~archive ~unit_name ~version ~architecture _ -> ()))
db
=
Dbm.iter
begin fun key data ->
match decompose_key key with
| (category, [unit_name;version;architecture]) when category = packages_cat ->
let p = G.from_string ~header:false ~fmt io_field_description data in
package ~unit_name ~version ~architecture p
| (category, [archive;unit_name;version;architecture]) when category = lifetime_cat ->
let lf = G.from_string ~header:false ~fmt Lifetime.io_lifetime data in
lifetime ~archive ~unit_name ~version ~architecture lf
| _ -> ()
end
db.db_dbm
(* ***)
(*** find_package *)
let find_package db ~unit_name ~version ~architecture =
let key = make_package_key ~buffer:db.db_buffer ~unit_name ~version ~architecture in
let data = Dbm.find db.db_dbm key in
G.from_string ~header:false ~fmt io_field_description data
;;
(* ***)
(*** find_lifetime *)
let find_lifetime db ~architecture ~archive ~unit_name ~version =
let key = make_lifetime_key ~buffer:db.db_buffer ~archive ~unit_name ~version ~architecture in
let data = Dbm.find db.db_dbm key in
G.from_string ~header:false ~fmt Lifetime.io_lifetime data
;;
(* ***)
(*** get_field_map *)
let get_field_map db field =
try
let (_,mp) = Hashtbl.find db.db_fields field in mp
with
| Not_found ->
let field' = String.lowercase field in
try
let (_,mp) = Hashtbl.find db.db_fields field' in mp
with
| Not_found ->
let fn = sanitize_field_name db.db_buffer field' in
let fd = Unix.openfile (Filename.concat db.db_base fn) [Unix.O_RDONLY] 0o644 in
let mp = Mmap.map fd in
Hashtbl.add db.db_fields field (fd,mp);
Hashtbl.add db.db_fields field' (fd,mp);
mp
;;
(* ***)
(*** extract_field *)
let extract_field db field offset length =
let mp = get_field_map db field in
let x = Mmap.sub mp offset length in
try
G.from_string ~header:false ~fmt io_field x
with
| x ->
(*Printf.printf "SHIT: %s\n%!" (Printexc.to_string x);
Printf.printf "field=%s offset=%Ld length=%d\n%!" field offset length;*)
raise x
;;
(* ***)
(*** get_package_id *)
let get_package_id db (package_id,_) = package_id;;
(* ***)
(*** get_field *)
let get_field db (_,fds) field =
let (offset,length) = get_field field fds in
extract_field db field offset length
;;
(* ***)
(*** iter_over_fields *)
let iter_over_fields f db (_,pkg) =
List.iter
begin fun (field,offset,length) ->
let (first,rest) = extract_field db field offset length in
f (field,first,rest)
end
pkg
;;
(* ***)
(*** get_field_first *)
let get_field_first db fds field =
let (x,_) = get_field db fds field in x
;;
(* ***)
end
;;
(* ***)
let napkin_of_fields =
let rex0 = Pcre.regexp ~study:true "\\s*(\\S+)\\s*"
and rex1 = Pcre.regexp ~study:true "\\s*,\\s*"
and rex2 = Pcre.regexp ~study:true "\\s*\\|\\s*"
and rex3 = Pcre.regexp ~study:true "(\\S+)\\s*\\(\\s*(<|<<|<=|>=|>>|>|=)\\s*([0-9a-zA-Z.:+-~]+)\\s*\\)"
and rex4 = Pcre.regexp ~study:true "^\\s*(\\S+)\\s*\\((\\S+)\\)$"
in
fun assoc ->
let chump x =
let ss = Pcre.exec ~rex:rex0 x in
Pcre.get_substring ss 1
in
let (pk_unit, pk_version) =
let u = chump (assoc "Package") in
try
let v = chump (assoc "Version") in
(u,v)
with
| Not_found -> raise (Warning(sf "Package %S ignored because it has no version." u))
in
let get k =
try
Pcre.split ~rex:rex1 (assoc k)
with
| Not_found -> []
in
(*** Source *)
let pk_source =
try
let ss = assoc "Source" in
try
let suv = Pcre.exec ~rex:rex4 ss in
(Pcre.get_substring suv 1, Pcre.get_substring suv 2)
with
| Not_found -> (chump ss, pk_version)
with
| Not_found -> (pk_unit, pk_version)
in
(* ***)
(*** Get an integer value *)
let get_int64 field =
try
Int64.of_string (assoc field)
with
| Not_found|Invalid_argument _ -> 0L
in
(* ***)
(*** Get a boolean value *)
let get_bool field =
try
assoc field = "yes"
with
| Not_found -> false
in
(* ***)
let pk_architecture = assoc "Architecture" in
(*** Collect a conjunctive field *)
let collect_conjunctive field =
let stuff = get field in
List.map (fun x ->
try
let ss = Pcre.exec ~rex:rex3 x in
let (pn,op,v) = (Pcre.get_substring ss 1, Pcre.get_substring ss 2, Pcre.get_substring ss 3) in
match op with
| "<" -> Unit_version (pn, Sel_LT v) (* XXX *)
| "<<" -> Unit_version (pn, Sel_LT v)
| "<=" -> Unit_version (pn, Sel_LEQ v)
| "=" -> Unit_version (pn, Sel_EQ v)
| ">=" -> Unit_version (pn, Sel_GEQ v)
| ">" -> Unit_version (pn, Sel_GT v)
| ">>"|_ -> Unit_version (pn, Sel_GT v)
with
| Not_found -> Unit_version (chump x, Sel_ANY)) stuff
in
(* ***)
(*** Collect disjunctive field *)
let collect_disjunctive field =
let stuff = get field in
List.map (fun d ->
let l = Pcre.split ~rex:rex2 d in
List.map
(fun x ->
try
let ss = Pcre.exec ~rex:rex3 x in
let (pn,op,v) = (Pcre.get_substring ss 1, Pcre.get_substring ss 2, Pcre.get_substring ss 3) in
match op with
| "<" -> Unit_version (pn, Sel_LT v)
| "<<" -> Unit_version (pn, Sel_LT v)
| "<=" -> Unit_version (pn, Sel_LEQ v)
| "=" -> Unit_version (pn, Sel_EQ v)
| ">=" -> Unit_version (pn, Sel_GEQ v)
| ">" -> Unit_version (pn, Sel_GT v)
| ">>"|_ -> Unit_version (pn, Sel_GT v)
with
| Not_found ->
Unit_version (chump x, Sel_ANY)) l) stuff
in
(* ***)
(*** Essential, build-essential *)
{ pk_extra = ();
pk_unit = pk_unit;
pk_version = pk_version;
pk_architecture = pk_architecture;
pk_source = pk_source;
pk_essential = get_bool "Essential";
pk_build_essential = get_bool "Build-Essential";
pk_provides = collect_conjunctive "Provides";
pk_size = get_int64 "Size";
pk_installed_size = get_int64 "Installed-Size";
pk_conflicts = collect_conjunctive "Conflicts";
pk_breaks = collect_conjunctive "Breaks";
pk_replaces = collect_conjunctive "Replaces";
pk_depends = collect_disjunctive "Depends";
pk_pre_depends = collect_disjunctive "Pre-Depends";
pk_suggests = collect_disjunctive "Suggests";
pk_recommends = collect_disjunctive "Recommends";
pk_enhances = collect_disjunctive "Enhances";
}
;;
dose2-1.4.2/dosebase/dosebase.mli 0000664 0000000 0000000 00000004361 11231374124 0016611 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
val decompose_key : string -> string * string list
module Out :
sig
type t
val open_out : ?set_type:string -> string -> t
val close_out : t -> unit
val add_package :
t ->
archive:string ->
day:Lifetime.day ->
(string * string * string list) list ->
unit
val rebuild_index : string -> unit
end
module In :
sig
type t
type package
val open_in : string -> t
val close_in : t -> unit
val count_population: t -> int
val get_type: t -> string
val iter :
?package:(unit_name:string -> version:string -> architecture:string -> package -> unit) ->
?lifetime:(archive:string -> unit_name:string -> version:string ->
architecture:string -> Lifetime.lifetime -> unit) ->
t ->
unit
val iter_over_fields : (string * string * string list -> unit) -> t -> package -> unit
val find_package : t -> unit_name:string -> version:string -> architecture:string -> package
val find_lifetime : t -> architecture:string -> archive:string -> unit_name:string -> version:string -> Lifetime.lifetime
val get_package_id : t -> package -> int
val get_field : t -> package -> string -> string * string list
val get_field_first : t -> package -> string -> string
val known_fields : t -> string list
end
(** [napkin_of_fields assoc] parses a Dosebase package description given by a
function [assoc] that takes a field name and returns the first line of the
contents of the field. *)
val napkin_of_fields: (string -> string) -> Napkin.default_package
dose2-1.4.2/io/ 0000775 0000000 0000000 00000000000 11231374124 0013137 5 ustar 00root root 0000000 0000000 dose2-1.4.2/io/.depend 0000664 0000000 0000000 00000001545 11231374124 0014404 0 ustar 00root root 0000000 0000000 fragments.cmo: fragments.cmi
fragments.cmx: fragments.cmi
io.cmo: fragments.cmi io.cmi
io.cmx: fragments.cmx io.cmi
channels.cmo:
channels.cmx:
human_io.cmo: io.cmi fragments.cmi human_io.cmi
human_io.cmx: io.cmx fragments.cmx human_io.cmi
ascii_io.cmo: lexer.cmi io.cmi fragments.cmi channels.cmo ascii_io.cmi
ascii_io.cmx: lexer.cmi io.cmx fragments.cmx channels.cmx ascii_io.cmi
binary_io.cmo: io.cmi fragments.cmi channels.cmo binary_io.cmi
binary_io.cmx: io.cmx fragments.cmx channels.cmx binary_io.cmi
generic_io.cmo: io.cmi human_io.cmi binary_io.cmi ascii_io.cmi generic_io.cmi
generic_io.cmx: io.cmx human_io.cmx binary_io.cmx ascii_io.cmx generic_io.cmi
ascii_io.cmi: fragments.cmi
binary_io.cmi: fragments.cmi
fragments.cmi:
generic_io.cmi: io.cmi fragments.cmi
human_io.cmi: fragments.cmi
io.cmi: fragments.cmi
lexer.cmi: fragments.cmi
dose2-1.4.2/io/GRAMMAR 0000664 0000000 0000000 00000000507 11231374124 0014152 0 ustar 00root root 0000000 0000000
data ::=
| tuple
| atom
atom ::=
| int
| string
| char
| bool
| float
| int64
1
"44\n\n"
'5'
true
false
1.55e33
inf
-inf
nan
4536276345l
23894829348293L
3.14159265358
[1;2;3]
(1,2)
(1)
(1,2,3,4)
array 30490 [1;2;3]
hash 38293 [1;2;3;4;5]
collection 3333 [1;2;3;4;5]
Toto()
Toto(a,b)
Toto(a,b,c)
{alpha=33;beta=55;gamma=66}
dose2-1.4.2/io/Makefile.in 0000664 0000000 0000000 00000000725 11231374124 0015210 0 ustar 00root root 0000000 0000000 # Makefile
NAME= io
SOURCES= fragments.ml io.ml channels.ml human_io.ml lexer.ml ascii_io.ml \
binary_io.ml generic_io.ml
MLIS= ascii_io.mli binary_io.mli fragments.mli generic_io.mli human_io.mli \
io.mli lexer.mli
EXTRA_CLEAN= lexer.ml
include ../Makefile.config
include .depend
ascii_io.cmo: lexer.cmi
ascii_io.cmx: lexer.cmx
lexer.ml: lexer.mll
@OCAMLLEX@ -o $@ $<
lexer.cmo: fragments.cmi lexer.cmi
lexer.cmx: fragments.cmx lexer.cmi
dose2-1.4.2/io/README 0000664 0000000 0000000 00000000246 11231374124 0014021 0 ustar 00root root 0000000 0000000 Authors
=======
"io" has been written by Berke Durak funded by the EDOS
project, and is released under the GNU Library General Public License.
dose2-1.4.2/io/TODO 0000664 0000000 0000000 00000000300 11231374124 0013620 0 ustar 00root root 0000000 0000000 * Add support for circular data structures.
module H = Hashtbl.Make(
struct
type t = Obj.t
let equal = (==)
let hash o = Hashtbl.hash (magic o : int)
end)
* Add XML backend
dose2-1.4.2/io/ascii_io.ml 0000664 0000000 0000000 00000005720 11231374124 0015254 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
open Fragments;;
open Channels;;
let fp = Printf.fprintf;;
type 'channel printer = {
print : 'a . 'channel -> ('a, 'channel, unit) format -> 'a;
flush : 'channel -> unit
};;
(*** do_output *)
let do_output printer channel =
let fp = printer.print
and oc = channel
in
let space = ref true in
let need_space () =
if not !space then
begin
fp oc " ";
space := false
end
else
()
in
let no_space () = space := false in
let space_ok () = space := true in
create_io_out
~write_token:
begin function
| Int x -> need_space (); fp oc "%d" x; no_space ()
| Int64 x -> need_space (); fp oc "%LdL" x; no_space ()
| Char x -> fp oc "%C" x; space_ok ()
| String x -> fp oc "%S" x; space_ok ()
| Float x -> need_space (); fp oc "%F" x; no_space ()
| Bool x -> need_space (); fp oc "%b" x; no_space ()
| Tag t ->
if is_tag_voluminous t then
begin
need_space ();
fp oc "%s" (string_of_tag t);
no_space ()
end
else
begin
fp oc "%s" (string_of_tag t);
space_ok ()
end
| Constructor x ->
let y = String.copy x in
y.[0] <- Char.uppercase x.[0];
need_space ();
fp oc "%s" y;
no_space ();
| Field x ->
need_space ();
if is_word_reserved x then
fp oc "_%s" x
else
fp oc "%s" x;
no_space ()
| EOF -> ()
end
~flush:(fun () -> printer.flush oc)
()
;;
(* ***)
(*** out_of_channel *)
let out_of_channel ~out_channel () = do_output { print = Printf.fprintf; flush = Pervasives.flush } out_channel;;
(* ***)
(*** out_of_buffer *)
let out_of_buffer ~buffer () = do_output { print = Printf.bprintf; flush = ignore } buffer;;
(* ***)
(*** in_of_lexbuf *)
let in_of_lexbuf ~lexbuf () =
let l = lexbuf in
let token = ref None in
let peek_token () =
match !token with
| None ->
let t = Lexer.token l in
token := Some t;
t
| Some t -> t
in
create_io_in
~peek_token
~read_token:
begin fun () ->
let t = peek_token () in
token := None;
t
end
()
;;
(* ***)
dose2-1.4.2/io/ascii_io.mli 0000664 0000000 0000000 00000001621 11231374124 0015421 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
val out_of_channel : out_channel:out_channel -> unit -> Fragments.io_out
val out_of_buffer : buffer:Buffer.t -> unit -> Fragments.io_out
val in_of_lexbuf : lexbuf:Lexing.lexbuf -> unit -> Fragments.io_in
dose2-1.4.2/io/binary_io.ml 0000664 0000000 0000000 00000027006 11231374124 0015451 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
open Fragments;;
open Channels;;
let sf = Printf.sprintf;;
(*** CHUNK_OUT *)
module type CHUNK_OUT =
sig
include OUT
val output_int : o -> int -> unit
val output_int64 : o -> int64 -> unit
val output_string : o -> string -> unit
val output_float : o -> float -> unit
end
;;
(* ***)
(*** CHUNK_IN *)
module type CHUNK_IN =
sig
include IN
val input_int : i -> int
val input_int64 : i -> int64
val input_string : i -> string
val input_float : i -> float
end
;;
(* ***)
(*** Compact_in *)
module Compact_in(I : IN) =
struct
include I
(*** input_int *)
let input_int i =
let x = I.input_byte i in
let y =
if x land 0x40 = 0 then
x land 0x3f
else
let rec loop () =
let x = I.input_byte i in
if x land 0x80 = 0 then
x land 0x7f
else
(x land 0x7f) lor ((loop ()) lsl 7)
in
(x land 0x3f) lor ((loop ()) lsl 6)
in
if 0 <> x land 0x80 then
- y - 1
else
y
;;
(* ***)
(*** input_string *)
let input_string i =
let x = I.input_byte i in
if x = 0 then
""
else
if 1 <= x && x <= 26 then
String.make 1 (Char.chr (x + 95))
else
let n =
if 27 <= x && x <= 254 then
x - 25
else
input_int i
in
let u = String.create n in
I.input i u 0 n;
u
;;
(* ***)
(*** input_int64 *)
let input_int64 i =
let g o x = Int64.logor (Int64.shift_left (Int64.of_int (I.input_byte i)) o) x in
let x = g 56 0L in
let x = g 48 x in
let x = g 40 x in
let x = g 32 x in
let x = g 24 x in
let x = g 16 x in
let x = g 8 x in
let x = g 0 x in
x
;;
(* ***)
(*** input_float *)
let input_float i = Int64.float_of_bits (input_int64 i)
;;
(* ***)
end
;;
(* ***)
(*** Compact_out *)
module Compact_out(O : OUT) =
struct
include O
(*** output_int *)
let output_int o x =
let (sign,x) =
(if x < 0 then 0x80 else 0x00),
(if x < 0 then - (x + 1) else x)
in
let f = O.output_byte o in
if x < 64 then
f (sign lor x)
else
let rec loop q =
if q < 128 then
f q
else
begin
f (0x80 lor (q land 0x7f));
loop (q lsr 7)
end
in
f (0x40 lor sign lor (x land 0x3f));
loop (x lsr 6)
(* ***)
(*** output_string *)
let output_string o x =
let f = O.output_byte o in
let m = String.length x in
if m = 0 then
f 0
else
if m = 1 && 'a' <= x.[0] && x.[0] <= 'z' then
f ((Char.code x.[0]) - 95)
else
if 2 <= m && m < 229 then
begin
f (m + 25);
O.output o x 0 m
end
else
begin
f 255;
output_int o m;
O.output o x 0 m
end
(* ***)
(*** output_int64 *)
let output_int64 o x = (* little endian *)
let g s = output_byte o (Int64.to_int (Int64.logand (Int64.shift_right x s) 0xffL)) in
g 56; g 48; g 40; g 32; g 24; g 16; g 8; g 0
(* ***)
(*** output_float *)
let output_float o x =
output_int64 o (Int64.bits_of_float x)
(* ***)
end
;;
(* ***)
(*** code_{bool,char,...} *)
let code_bool = max_tag + 1
let code_char = max_tag + 2
let code_int = max_tag + 3
let code_float = max_tag + 4
let code_string = max_tag + 5
let code_int64 = max_tag + 6
let code_field = max_tag + 7
let code_field_ref = max_tag + 8
let code_constructor = max_tag + 9
let code_constructor_ref = max_tag + 10
;;
(* ***)
(*** Outputter *)
module Outputter(O : CHUNK_OUT) =
struct
open O;;
(*** create_out *)
let create_out o =
create_io_out
~write_token:
begin fun t ->
let c = output_byte o in
match t with
| Bool false -> c code_bool; output_byte o 0
| Bool true -> c code_bool; output_byte o 1
| Char x -> c code_int; output_byte o (Char.code x)
| Int x -> c code_int; output_int o x
| Int64 x -> c code_int64; output_int64 o x
| Float x -> c code_float; output_float o x
| String x -> c code_string; output_string o x
| Constructor x -> c code_constructor; output_string o x
| Field x -> c code_field; output_string o x
| Tag x -> c (int_of_tag x);
| EOF -> ()
end
~flush:
begin fun () ->
O.flush o
end
()
;;
(* ***)
end
;;
(* ***)
(*** Inputter *)
module Inputter(I : CHUNK_IN) =
struct
open I;;
(*** in_of_channel *)
let create_in i =
let token = ref None in
let peek_token () =
match !token with
| None ->
let t =
match input_byte i with
| x when x <= max_tag -> Tag(tag_of_int x)
| x when x = code_bool -> Bool(input_byte i = 1)
| x when x = code_int -> Int(input_int i)
| x when x = code_string -> String(input_string i)
| x when x = code_float -> Float(input_float i)
| x when x = code_field -> Field(input_string i)
| x when x = code_constructor -> Constructor(input_string i)
| x -> raise (Error(sf "Invalid tag byte %d" x))
in
token := Some t;
t
| Some t -> t
in
create_io_in
~peek_token
~read_token:
begin fun () ->
let t = peek_token () in
token := None;
t
end
()
(* ***)
end
;;
(* ***)
(*** Compressing_outputter *)
module Compressing_outputter(O : CHUNK_OUT) =
struct
open O;;
(*** create_out *)
let create_out o =
let token_id = ref 0 in
let dictionary = Hashtbl.create 256 in
let c = output_byte o in
let do_memorized code code_ref x =
try
let id = Hashtbl.find dictionary x in
c code_constructor_ref;
output_int o id
with
| Not_found ->
let id = !token_id in
incr token_id;
Hashtbl.add dictionary x id;
c code_constructor;
output_string o x
in
create_io_out
~write_token:
begin fun t ->
match t with
| Bool false -> c code_bool; output_byte o 0
| Bool true -> c code_bool; output_byte o 1
| Char x -> c code_int; output_byte o (Char.code x)
| Int x -> c code_int; output_int o x
| Int64 x -> c code_int64; output_int64 o x
| Float x -> c code_float; output_float o x
| String x -> c code_string; output_string o x
| Tag x -> c (int_of_tag x);
| Constructor x -> do_memorized code_constructor code_constructor_ref x
| Field x -> do_memorized code_field code_field_ref x
| EOF -> ()
end
~flush:
begin fun () ->
O.flush o
end
()
;;
(* ***)
end
;;
(* ***)
(*** Compressing_inputter *)
module Compressing_inputter(I : CHUNK_IN) =
struct
open I;;
(*** in_of_channel *)
let create_in i =
let token_id = ref 0 in
let dictionary = Hashtbl.create 256
and reverse_dictionary = Hashtbl.create 256
in
let get_and_memorize () =
let x = input_string i in
if not (Hashtbl.mem reverse_dictionary x) then
begin
let id = !token_id in
incr token_id;
Hashtbl.add dictionary id x;
Hashtbl.add reverse_dictionary x id;
x
end
else
raise (Error(sf "Ident %S already in dictionary." x));
in
let get_and_recall () =
let id = input_int i in
try
Hashtbl.find dictionary id
with
| Not_found -> raise (Error(sf "Invalid ident reference %d" id))
in
let token = ref None in
let peek_token () =
match !token with
| None ->
let t =
match input_byte i with
| x when x <= max_tag -> Tag(tag_of_int x)
| x when x = code_bool -> Bool(input_byte i = 1)
| x when x = code_int -> Int(input_int i)
| x when x = code_string -> String(input_string i)
| x when x = code_float -> Float(input_float i)
| x when x = code_field -> Field(get_and_memorize ())
| x when x = code_constructor -> Constructor(get_and_memorize ())
| x when x = code_field_ref -> Field(get_and_recall ())
| x when x = code_constructor_ref -> Constructor(get_and_recall ())
| x -> raise (Error(sf "Invalid tag byte %d" x))
in
token := Some t;
t
| Some t -> t
in
create_io_in
~peek_token
~read_token:
begin fun () ->
let t = peek_token () in
token := None;
t
end
()
(* ***)
end
;;
(* ***)
module O_CHANNEL = Outputter(Compact_out(CHANNEL_OUT));;
module O_STRING = Outputter(Compact_out(STRING_OUT));;
module I_CHANNEL = Inputter (Compact_in(CHANNEL_IN));;
module I_STRING = Inputter (Compact_in(STRING_IN));;
module C_O_CHANNEL = Compressing_outputter(Compact_out(CHANNEL_OUT));;
module C_O_STRING = Compressing_outputter(Compact_out(STRING_OUT));;
module C_I_CHANNEL = Compressing_inputter (Compact_in(CHANNEL_IN));;
module C_I_STRING = Compressing_inputter (Compact_in(STRING_IN));;
let out_of_channel ~out_channel ?(compress=false) () =
if compress then
C_O_CHANNEL.create_out out_channel
else
O_CHANNEL.create_out out_channel
;;
let in_of_channel ~in_channel ?(compress=false) () =
if compress then
C_I_CHANNEL.create_in in_channel
else
I_CHANNEL.create_in in_channel
;;
let in_of_string ~str ?offset ?length ?(compress=false) () =
let i = STRING_IN.of_string ?offset ?length str in
if compress then
C_I_STRING.create_in i
else
I_STRING.create_in i
;;
let out_to_string ?(size=128) ?(compress=false) () =
let o = STRING_OUT.create size in
if compress then
(C_O_STRING.create_out o,
fun () -> STRING_OUT.contents o)
else
(O_STRING.create_out o,
fun () -> STRING_OUT.contents o)
;;
dose2-1.4.2/io/binary_io.mli 0000664 0000000 0000000 00000002670 11231374124 0015622 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** I/O functions for binary data. *)
val out_of_channel : out_channel:out_channel -> ?compress:bool -> unit -> Fragments.io_out
(** Create a reader from an Ocaml input channel, which must be open in binary mode. *)
val in_of_channel : in_channel:in_channel -> ?compress:bool -> unit -> Fragments.io_in
(** Create a writer from an Ocaml output channel, which must be open in binary mode. *)
val in_of_string : str:string -> ?offset:int -> ?length:int -> ?compress:bool -> unit -> Fragments.io_in
(** Create a reader from an Ocaml string. *)
val out_to_string : ?size:int -> ?compress:bool -> unit -> Fragments.io_out * (unit -> string)
(** Create a writer fo a string. Returns the writer and a function that will return the generated string. *)
dose2-1.4.2/io/channels.ml 0000664 0000000 0000000 00000005651 11231374124 0015273 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(*** IN *)
module type IN =
sig
type i
val input_byte : i -> int
val input_char : i -> char
val input : i -> string -> int -> int -> unit
end
;;
(* ***)
(*** OUT *)
module type OUT =
sig
type o
val output_byte : o -> int -> unit
val output_char : o -> char -> unit
val output_string : o -> string -> unit
val output : o -> string -> int -> int -> unit
val flush : o -> unit
end
;;
(* ***)
(*** CHANNEL_IN *)
module CHANNEL_IN =
struct
type i = in_channel
let input_byte = input_byte
let input_char = input_char
let input = really_input
end
;;
(* ***)
(*** CHANNEL_OUT *)
module CHANNEL_OUT =
struct
type o = out_channel
let output_char = output_char
let output_byte = output_byte
let output_string = output_string
let output = output
let flush = Pervasives.flush
end
;;
(* ***)
(*** STRING_OUT *)
module STRING_OUT =
struct
type o = Buffer.t
let create = Buffer.create
let contents = Buffer.contents
let output_byte b x = Buffer.add_char b (Char.unsafe_chr x)
let output_char b x = Buffer.add_char b x
let output_string = Buffer.add_string
let output = Buffer.add_substring
let flush _ = ()
end
;;
(* ***)
(*** STRING_IN *)
module STRING_IN =
struct
type i = {
i_string : string;
i_length : int;
mutable i_pos : int
}
(*** of_string *)
let of_string ?(offset=0) ?length u =
let length =
match length with
| None -> String.length u - offset
| Some l -> l
in
if 0 <= offset &&
offset < String.length u &&
0 <= length &&
offset + length <= String.length u
then
{ i_string = u;
i_length = length;
i_pos = offset }
else
invalid_arg "STRING_IN.of_string"
;;
(* ***)
(*** input_char *)
let input_char i =
if i.i_pos >= i.i_length then
raise End_of_file
else
begin
let c = i.i_string.[i.i_pos] in
i.i_pos <- i.i_pos + 1;
c
end
;;
(* ***)
let input_byte i = Char.code (input_char i);;
let input i u o n =
String.blit i.i_string i.i_pos u o n;
i.i_pos <- i.i_pos + n
;;
end
;;
(* ***)
dose2-1.4.2/io/convert.ml 0000664 0000000 0000000 00000013231 11231374124 0015151 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
module G = Generic_io;;
open Fragments;;
let output_format = ref G.Asc;;
let input_format = ref None;;
let check = ref false;;
let old = ref false;;
(*** convert *)
let convert fmt ic oc =
let reader =
match !input_format with
| None -> G.in_from_channel ic
| Some fmt -> G.in_from_channel ~header:false ~fmt ic
in
let writer =
G.out_from_channel ~fmt oc
in
while true do
convert ~reader ~writer ()
done
;;
(* ***)
(*** convert_old *)
let convert_old fmt ic oc =
let i = G.in_from_channel ic in
let o = G.out_from_channel ~fmt oc in
let rec do_things ?(eat=false) stoppers =
let t = read_token i in
if not (t = EOF && eat) then
write_token o t;
match t with
| Tag T_List -> do_list (); do_things stoppers
| Tag T_Array -> do_array (); do_things stoppers
| Tag T_Record -> do_record (); do_things stoppers
| Tag T_Sum -> do_sum (); do_things stoppers
| Tag T_Hashtbl -> do_hashtbl (); do_things stoppers
| Ident x -> do_things stoppers
| Tag t ->
if List.mem t stoppers then
t
else
do_things stoppers
| t -> do_things stoppers
and do_sum () =
let x = read_ident i in
write_ident o x;
do_things ~eat:true [T_End]
and do_array () =
let m = read_int i in
write_int o m;
do_things [T_End]
and do_record () =
do_things [T_End]
and do_hashtbl () =
let m = read_int i in
write_int o m;
do_things [T_End]
and do_list2 () =
match do_things [T_More;T_End] with
| T_More -> do_list2 ()
| T_End -> ()
| _ -> assert false
and do_list () =
match read_tag i with
| T_More -> do_list2 ()
| T_End -> ()
| t -> failwith (sf "Unexpected token <%s> in do_list" (string_of_tag t))
in
(*inside "header" (read_this_tag i) T_Data;*)
ignore (do_things [T_Stop_data])
;;
(* ***)
(*** check_channel *)
let check_channel ic =
let indent = ref 0 in
let put_indent () =
for i = 1 to !indent do
Printf.printf " "
done
in
let inside what f x =
put_indent ();
Printf.printf "{\n";
try
incr indent;
let z = f x in
decr indent;
put_indent ();
Printf.printf "}\n";
z
with
| y ->
Printf.printf "While %s:\n%!" what;
raise y
in
let error msg =
Printf.printf "Error: %s\n%!" msg;
raise Exit
in
let i = G.in_from_channel ic in
let rec do_things stoppers =
let t = read_token i in
put_indent ();
Printf.printf "<%s>\n" (string_of_token t);
match t with
| Tag T_List -> inside "list" do_list (); do_things stoppers
| Tag T_Array -> inside "array" do_array (); do_things stoppers
| Tag T_Record -> inside "record" do_record (); do_things stoppers
| Tag T_Sum -> inside "sum" do_sum (); do_things stoppers
| Tag T_Hashtbl -> inside "hashtbl" do_hashtbl (); do_things stoppers
| Ident x ->
put_indent ();
Printf.printf "%s:\n" x;
do_things stoppers
| Tag t ->
if List.mem t stoppers then
t
else
do_things stoppers
| t -> do_things stoppers
and do_sum () =
let x = read_ident i in
put_indent ();
Printf.printf "|%s\n" x;
do_things [T_End]
and do_array () =
let m = read_int i in
do_things [T_End]
and do_record () =
do_things [T_End]
and do_hashtbl () =
let m = read_int i in
do_things [T_End]
and do_list2 () =
match do_things [T_More;T_End] with
| T_More -> do_list2 ()
| T_End -> ()
| _ -> assert false
and do_list () =
match read_tag i with
| T_More -> do_list2 ()
| T_End -> ()
| t -> error (sf "Unexpected token <%s> in do_list" (string_of_tag t))
in
(*inside "header" (read_this_tag i) T_Data;*)
ignore (do_things [T_Stop_data])
;;
(* ***)
(*** spec *)
let spec = [
"-check", Arg.Set check, " Do some syntactic checks.";
"-old", Arg.Set old, " Convert from old format.";
"-ifmt", Arg.String
begin fun fmt ->
try
input_format := Some(G.id_to_format fmt)
with
| G.Unknown_format ->
Printf.eprintf "Unknown format %S. Available formats: %s.\n%!"
fmt (String.concat " " (List.map (fun (_,y) -> y) G.format_list));
exit 1
end,
" Set input format.";
"-fmt", Arg.String
begin fun fmt ->
try
output_format := G.id_to_format fmt
with
| G.Unknown_format ->
Printf.eprintf "Unknown format %S. Available formats: %s.\n%!"
fmt (String.concat " " (List.map (fun (_,y) -> y) G.format_list));
exit 1
end,
" Set output format."
];;
(* ***)
(*** main *)
let _ =
Arg.parse
spec
begin fun x ->
Printf.eprintf "Extraneous argument %S.\n%!" x;
exit 1
end
(Printf.sprintf "Usage: %s [-fmt format] < infile > outfile" (Filename.basename Sys.argv.(0)));
if !check then
check_channel stdin
else
if !old then
convert_old !output_format stdin stdout
else
convert !output_format stdin stdout
;;
(* ***)
dose2-1.4.2/io/fragments.ml 0000664 0000000 0000000 00000016423 11231374124 0015465 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
exception Error of string;;
let sf = Printf.sprintf;;
(*** tag *)
type tag =
| T_LParen
| T_RParen
| T_LBrack
| T_RBrack
| T_LBrace
| T_RBrace
| T_Equal
| T_Comma
| T_Semicolon
| T_Array
| T_Hashtbl
| T_Set
;;
(* ***)
(*** tags *)
let tags = [
T_LParen;
T_RParen;
T_LBrack;
T_RBrack;
T_LBrace;
T_RBrace;
T_Equal;
T_Comma;
T_Semicolon;
T_Array;
T_Hashtbl;
T_Set;
];;
(* ***)
(*** string_of_tag *)
let string_of_tag = function
| T_LParen -> "("
| T_RParen -> ")"
| T_LBrack -> "["
| T_RBrack -> "]"
| T_LBrace -> "{"
| T_RBrace -> "}"
| T_Equal -> "="
| T_Comma -> ","
| T_Semicolon -> ";"
| T_Array -> "array"
| T_Hashtbl -> "hash"
| T_Set -> "set"
;;
(* ***)
let reserved_words = ["array";"hash";"set"];;
let is_word_reserved x = List.mem x reserved_words;;
(*** tag_of_string *)
let tag_of_string = function
| "(" -> T_LParen
| ")" -> T_RParen
| "[" -> T_LBrack
| "]" -> T_RBrack
| "{" -> T_LBrace
| "}" -> T_RBrace
| "=" -> T_Equal
| "," -> T_Comma
| ";" -> T_Semicolon
| "array" -> T_Array
| "hash" -> T_Hashtbl
| "set" -> T_Set
| x -> raise (Error(sf "Unknown tag %S" x))
;;
(* ***)
(*** is_tag_voluminous *)
let is_tag_voluminous = function
| T_LParen -> false
| T_RParen -> false
| T_LBrack -> false
| T_RBrack -> false
| T_LBrace -> false
| T_RBrace -> false
| T_Equal -> false
| T_Comma -> false
| T_Semicolon -> false
| T_Array -> true
| T_Hashtbl -> true
| T_Set -> true
;;
(* ***)
(*** int_of_tag *)
let int_of_tag = function
| T_LParen -> 0
| T_RParen -> 1
| T_LBrack -> 2
| T_RBrack -> 3
| T_LBrace -> 4
| T_RBrace -> 5
| T_Equal -> 6
| T_Comma -> 7
| T_Semicolon -> 8
| T_Array -> 9
| T_Hashtbl -> 10
| T_Set -> 11
;;
(* ***)
(*** tag_of_int *)
let tag_of_int = function
| 0 -> T_LParen
| 1 -> T_RParen
| 2 -> T_LBrack
| 3 -> T_RBrack
| 4 -> T_LBrace
| 5 -> T_RBrace
| 6 -> T_Equal
| 7 -> T_Comma
| 8 -> T_Semicolon
| 9 -> T_Array
| 10 -> T_Hashtbl
| 11 -> T_Set
| x -> raise (Error(sf "Unknown tag %d" x))
;;
(* ***)
(*** is_start_tag *)
let is_start_tag = function
| T_LParen | T_LBrack | T_LBrace -> true
| _ -> false
;;
(* ***)
(*** is_end_tag *)
let is_end_tag = function
| T_RParen | T_RBrack | T_RBrace -> true
| _ -> false
;;
(* ***)
let max_tag = 32;;
(*** token *)
type token =
| Bool of bool
| Char of char
| Int of int
| Int64 of int64
| Float of float
| String of string
| Tag of tag
| Field of string
| Constructor of string
| EOF
;;
(* ***)
(*** string_of_token *)
let string_of_token = function
| Bool b -> sf "Bool(%b)" b
| Char c -> sf "Char(%C)" c
| Int d -> sf "Int(%d)" d
| Int64 d -> sf "Int(%Ld)" d
| Float f -> sf "Float(%f)" f
| String s -> sf "String(%S)" s
| Tag x -> sf "Tag(%S)" (string_of_tag x)
| Field x -> sf "Field(%S)" x
| Constructor x -> sf "Constructor(%S)" x
| EOF -> "EOF"
;;
(* ***)
(*** io_in *)
type io_in = {
mutable io_lost : bool;
io_peek_token : (unit -> token);
io_read_token : (unit -> token);
io_drop_token : (unit -> unit);
mutable io_finish : (unit -> unit)
}
(* ***)
(*** io_out *)
type io_out = {
io_write_token : (token -> unit);
io_flush : (unit -> unit)
};;
(* ***)
(*** drop_token *)
let drop_token i = i.io_drop_token ();;
(* ***)
(*** peek_token *)
let peek_token i = i.io_peek_token ();;
(* ***)
(*** read_token *)
let read_token i = i.io_read_token ();;
(* ***)
(*** read_tag *)
let read_tag i =
match read_token i with
| Tag tag -> tag
| x -> raise (Error(sf "Expecting tag got %s" (string_of_token x)))
;;
(* ***)
(*** read_this_tag *)
let read_this_tag i tag =
let tag' = read_tag i in
if tag = tag' then
()
else
raise (Error(sf "Expecting tag <%s> got <%s>"
(string_of_tag tag)
(string_of_tag tag')))
;;
(* ***)
(*** start *)
let start i = ();; (* read_this_tag i T_Data;; XXX *)
(* ***)
(*** default_finish *)
let default_finish i () = ();; (* read_this_tag i T_Stop_data;; *)
(* ***)
(*** create_io_in *)
let create_io_in ~read_token ~peek_token ?finish () =
let i =
{ io_lost = false;
io_read_token = read_token;
io_drop_token = (fun i -> ignore (read_token i));
io_peek_token = peek_token;
io_finish = ignore }
in
i.io_finish <-
begin
match finish with
| None -> default_finish i
| Some f -> f i
end;
start i;
i
;;
(* ***)
(*** finish *)
let finish i = i.io_finish ();;
(* ***)
(*** read_int *)
let read_int i =
match read_token i with
| Int x -> x
| x -> raise (Error(sf "Expecting int got %s" (string_of_token x)))
;;
(* ***)
(*** read_int64 *)
let read_int64 i =
match read_token i with
| Int64 x -> x
| x -> raise (Error(sf "Expecting int64 got %s" (string_of_token x)))
;;
(* ***)
(*** read_float *)
let read_float i =
match read_token i with
| Float x -> x
| x -> raise (Error(sf "Expecting float got %s" (string_of_token x)))
;;
(* ***)
(*** read_bool *)
let read_bool i =
match read_token i with
| Bool x -> x
| x -> raise (Error(sf "Expecting bool got %s" (string_of_token x)))
;;
(* ***)
(*** read_char *)
let read_char i =
match read_token i with
| Char x -> x
| x -> raise (Error(sf "Expecting char got %s" (string_of_token x)))
;;
(* ***)
(*** read_constructor *)
let read_constructor i =
match read_token i with
| Constructor x -> x
| x -> raise (Error(sf "Expecting constructor got %s" (string_of_token x)))
;;
(* ***)
(*** read_field *)
let read_field i =
match read_token i with
| Field x -> x
| x -> raise (Error(sf "Expecting field got %s" (string_of_token x)))
;;
(* ***)
(*** read_string *)
let read_string i =
match read_token i with
| String x -> x
| x -> raise (Error(sf "Expecting string got %s" (string_of_token x)))
;;
(* ***)
(*** write_{token,int,char,string,bool,float,tag,ident} *)
let write_token o t = o.io_write_token t;;
let write_int o x = write_token o (Int x)
let write_int64 o x = write_token o (Int64 x)
let write_char o x = write_token o (Char x)
let write_string o x = write_token o (String x)
let write_bool o x = write_token o (Bool x)
let write_float o x = write_token o (Float x)
let write_tag o x = write_token o (Tag x)
let write_field o x = write_token o (Field x)
let write_constructor o x = write_token o (Constructor x)
(* ***)
(*** loss *)
let loss i = i.io_lost <- true;;
(* ***)
(*** lost *)
let lost i = i.io_lost;;
(* ***)
(*** create_io_out *)
let create_io_out ~write_token ?(flush=ignore) () =
{ io_write_token = write_token;
io_flush = flush }
;;
(* ***)
(*** default_flush *)
let default_flush o = ();; (* write_tag o T_Stop_data;; *)
(* ***)
(*** flush *)
let flush o =
default_flush o;
o.io_flush ()
;;
(* ***)
dose2-1.4.2/io/fragments.mli 0000664 0000000 0000000 00000011277 11231374124 0015640 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** General literate module
This module provides low-level functions for doing structured data I/O.
*)
exception Error of string
val sf : ('a, unit, string) format -> 'a
(** Data tags *)
type tag =
| T_LParen
| T_RParen
| T_LBrack
| T_RBrack
| T_LBrace
| T_RBrace
| T_Equal
| T_Comma
| T_Semicolon
| T_Array
| T_Hashtbl
| T_Set
;;
val tags : tag list (** List of all existing tags *)
(** Functions for interconverting tags and purely alphabetical lowercase strings *)
val string_of_tag : tag -> string
(*val short_string_of_tag : tag -> string*)
val tag_of_string : string -> tag
(** Functions for interconverting tags and integers between 0 and [max_tag] *)
val int_of_tag : tag -> int
val tag_of_int : int -> tag
val max_tag : int (** Note that in order to reserver space for future tags, max_tag can be higher than the number of
existing tags. *)
val is_start_tag : tag -> bool (** Suggest open a pretty-printing box *)
val is_end_tag : tag -> bool (** Suggest to close a pretty-printing box *)
(** Tokens used by the lower-level I/O functions *)
type token =
| Bool of bool
| Char of char
| Int of int
| Int64 of int64
| Float of float
| String of string
| Tag of tag
| Field of string
| Constructor of string
| EOF
val string_of_token : token -> string (** Build a string representation of a token (usually for debugging) *)
type io_in (** The type of input channels *)
type io_out (** The type of output channels *)
val string_of_token : token -> string
val create_io_in :
read_token:(unit -> token) ->
peek_token:(unit -> token) ->
?finish:(io_in -> unit -> unit) -> unit -> io_in
(** Create an input channel from the given functions *)
val flush : io_out -> unit
val is_word_reserved : string -> bool
(** Is this a reserved word, such as array, hash or set ? *)
val is_tag_voluminous : tag -> bool
(** Does this tag require space around it ? *)
(** On failure, the following functions raise an Error(...) exception containing a useful message. *)
val drop_token : io_in -> unit
(** Remove a token from an input channel *)
val peek_token : io_in -> token
(** Peek a token from an input channel *)
val read_token : io_in -> token
(** Read a token from an input channel *)
val read_tag : io_in -> tag
(** Read a tag token. *)
val read_this_tag : io_in -> tag -> unit
(** Read this particular tag. *)
val finish : io_in -> unit
(** Finish consuming the input. Actually, this matches the Stop_data tag. *)
val read_int : io_in -> int
(** Read an integer. *)
val read_int64 : io_in -> int64
(** Read a 64-bit integer. *)
val read_float : io_in -> float
(** Read a floating-point number. *)
val read_bool : io_in -> bool
(** Read a boolean. *)
val read_char : io_in -> char
(** Read a character. *)
val read_field : io_in -> string
(** Read a field label. *)
val read_constructor : io_in -> string
(** Read a constructor name. *)
val read_string : io_in -> string
(** Read a string. *)
val loss : io_in -> unit
(** Signal that some data has been lost. This will be called, for instance, if the reader sees an unknown record
field name. *)
val lost : io_in -> bool
(** Tells us if any data has been lost, e.g., if [loss] has ever been called on this channel. *)
val create_io_out : write_token:(token -> unit) -> ?flush:(unit -> unit) -> unit -> io_out
(** Create an output channel from the given functions. *)
val write_token : io_out -> token -> unit
(** Write a token. *)
val write_int : io_out -> int -> unit
(** Write an integer. *)
val write_int64 : io_out -> int64 -> unit
(** Write a 64-bit integer. *)
val write_char : io_out -> char -> unit
(** Write a char. *)
val write_string : io_out -> string -> unit
(** Write a string. *)
val write_bool : io_out -> bool -> unit
(** Write a boolean. *)
val write_float : io_out -> float -> unit
(** Write a floating-point number. *)
val write_tag : io_out -> tag -> unit
(** Write a tag. *)
val write_field : io_out -> string -> unit
(** Write a fiel label. *)
val write_constructor : io_out -> string -> unit
(** Write a constructor name. *)
dose2-1.4.2/io/generic_io.ml 0000664 0000000 0000000 00000012705 11231374124 0015601 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
exception Unknown_format
(*** file_format *)
type file_format =
| Bin
| Cbn
| Txt
| Asc
;;
(* ***)
(*** format_list *)
let format_list = (* MUST be 3 characters long *)
[ Bin, "bin";
Txt, "txt";
Asc, "asc";
Cbn, "cbn" ]
;;
(* ***)
(*** format_list_swapped *)
let format_list_swapped = List.map (fun (x,y) -> (y,x)) format_list;;
(* ***)
(*** format_to_id *)
let format_to_id fmt = List.assoc fmt format_list;;
(* ***)
(*** id_to_format *)
let id_to_format id =
try
List.assoc id format_list_swapped
with
| Not_found -> raise Unknown_format
;;
(* ***)
(*** wrap *)
let wrap x g f =
begin
try
let r = f x in
g x;
r
with
| z ->
g x;
raise z
end
;;
(* ***)
(*** write_file_format *)
let write_file_format oc fmt =
output_string oc (format_to_id fmt);
output_char oc ' '
;;
(* ***)
(*** decode_format *)
let decode_format u c =
if c <> ' ' && c <> '\n' && c <> '\t' then raise Unknown_format;
id_to_format u
;;
(* ***)
(*** read_file_format *)
let read_file_format ic =
let u = String.make 3 ' ' in
really_input ic u 0 3;
let c = input_char ic in
decode_format u c
;;
(* ***)
(*** with_file_out *)
let with_file_out fn f = wrap (open_out_bin fn) close_out f;;
(* ***)
(*** with_file_in *)
let with_file_in fn f = wrap (open_in_bin fn) close_in f;;
(* ***)
(*** in_from_channel *)
let in_from_channel ?(header=true) ?(fmt=Bin) in_channel =
let fmt =
if header then
read_file_format in_channel
else
fmt
in
match fmt with
| Asc -> Ascii_io.in_of_lexbuf ~lexbuf:(Lexing.from_channel in_channel) ()
| Txt -> Human_io.in_of_channel ~in_channel ()
| Bin -> Binary_io.in_of_channel ~in_channel ()
| Cbn -> Binary_io.in_of_channel ~in_channel ~compress:true ()
;;
(* ***)
(*** load_from_channel *)
let load_from_channel ?header ?fmt io in_channel =
let i = in_from_channel ?header ?fmt in_channel in
let x = read io i in
finish i;
x
(* ***)
(*** out_from_channel *)
let out_from_channel ?(header=true) ?(fmt=Asc) out_channel =
if header then write_file_format out_channel fmt;
match fmt with
| Asc -> Ascii_io.out_of_channel ~out_channel ()
| Txt -> Human_io.out_of_channel ~indent:true ~out_channel ()
| Bin -> Binary_io.out_of_channel ~out_channel ()
| Cbn -> Binary_io.out_of_channel ~out_channel ~compress:true ()
;;
(* ***)
(*** save_to_channel *)
let save_to_channel ?header ?fmt io x out_channel =
let o = out_from_channel ?header ?fmt out_channel in
write io x o;
flush o;
;;
(* ***)
(*** save_to_file *)
let save_to_file ?header ?fmt io x fn = with_file_out fn (save_to_channel ?header ?fmt io x);;
(* ***)
(*** load_from_file *)
let load_from_file io fn = with_file_in fn (load_from_channel io);;
(* ***)
(*** in_from_string *)
let in_from_string ?(header=true) ?(fmt=Bin) ?(offset=0) u =
let (fmt, offset) =
if header then
begin
if String.length u < offset + 4 then
raise Unknown_format
else
(decode_format (String.sub u offset 3) u.[offset + 3], offset + 4)
end
else
(fmt, offset)
in
match fmt with
| Bin -> Binary_io.in_of_string ~str:u ~offset ()
| Cbn -> Binary_io.in_of_string ~str:u ~offset ~compress:true ()
| Asc ->
let lexbuf = Lexing.from_string u in
if offset > 0 then
begin
lexbuf.Lexing.lex_abs_pos <- offset;
lexbuf.Lexing.lex_start_pos <- offset;
lexbuf.Lexing.lex_curr_pos <- offset;
lexbuf.Lexing.lex_last_pos <- offset;
end;
Ascii_io.in_of_lexbuf ~lexbuf ()
| Txt ->
let s = Stream.of_string u in
for i = 1 to 4 do Stream.junk s done;
Human_io.in_of_stream ~stream:s ()
;;
(* ***)
(*** from_string *)
let from_string ?header ?fmt ?offset io u =
let i = in_from_string ?header ?fmt ?offset u in
read io i
;;
(* ***)
(*** to_string *)
let to_string ?(header=true) ?(fmt=Asc) io =
let fmt_id = (format_to_id fmt)^" " in
let human () =
let b = Buffer.create 256 in
let fmt = Format.formatter_of_buffer b in
fun x ->
Format.fprintf fmt "@.";
Buffer.clear b;
if header then Buffer.add_string b fmt_id;
let o = Human_io.out_of_formatter ~formatter:fmt () in
write io x o;
flush o;
Buffer.contents b
in
let ascii () =
let buffer = Buffer.create 256 in
fun x ->
Buffer.clear buffer;
if header then Buffer.add_string buffer fmt_id;
let o = Ascii_io.out_of_buffer ~buffer () in
write io x o;
flush o;
Buffer.contents buffer
in
let bin compress x =
let (o,get) = Binary_io.out_to_string ~compress () in
write io x o;
flush o;
if header then fmt_id ^ (get ())
else get ()
in
match fmt with
| Bin -> bin false
| Cbn -> bin true
| Asc -> ascii ()
| Txt -> human ()
;;
(* ***)
dose2-1.4.2/io/generic_io.mli 0000664 0000000 0000000 00000003262 11231374124 0015750 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
type file_format =
| Bin
| Cbn
| Txt
| Asc
exception Unknown_format
val format_list : (file_format * string) list
val format_to_id : file_format -> string
val id_to_format : string -> file_format
val in_from_channel : ?header:bool -> ?fmt:file_format -> in_channel -> Fragments.io_in
val out_from_channel : ?header:bool -> ?fmt:file_format -> out_channel -> Fragments.io_out
val save_to_file : ?header:bool -> ?fmt:file_format -> 'a Io.literate -> 'a -> string -> unit
val save_to_channel : ?header:bool -> ?fmt:file_format -> 'a Io.literate -> 'a -> out_channel -> unit
val load_from_file : 'a Io.literate -> string -> 'a
val load_from_channel : ?header:bool -> ?fmt:file_format -> 'a Io.literate -> in_channel -> 'a
val to_string : ?header:bool -> ?fmt:file_format -> 'a Io.literate -> 'a -> string
val from_string : ?header:bool -> ?fmt:file_format -> ?offset:int -> 'a Io.literate -> string -> 'a
val in_from_string : ?header:bool -> ?fmt:file_format -> ?offset:int -> string -> Fragments.io_in
dose2-1.4.2/io/human_io.ml 0000664 0000000 0000000 00000007563 11231374124 0015303 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
open Fragments;;
let sf = Printf.sprintf;;
(*** G *)
module G =
struct
include Genlex
(*** string_of_token *)
let string_of_token = function
| Ident x -> sf "Ident(%S)" x
| Int d -> sf "Int(%d)" d
| Float f -> sf "Float(%f)" f
| Kwd x -> sf "Kwd(%S)" x
| String s -> sf "String(%S)" s
| Char c -> sf "Char(%C)" c
(* ***)
end
;;
(* ***)
(*** tag_list *)
let tag_list =
["true";"false";"nan"] @
(List.map string_of_tag tags)
;;
(* ***)
(*** in_of_stream *)
let in_of_stream ~stream () =
let g = G.make_lexer tag_list stream in
let next () =
try
Stream.next g
with
| Stream.Failure ->
Stream.empty g;
raise End_of_file
in
(*let peek () = Stream.peek g in
let junk () = Stream.junk g in*)
let convert = function
| G.Ident x ->
begin
match x.[0] with
| 'A'..'Z' ->
Constructor x
| _ ->
Field x
end
| G.Int x -> Int x
| G.Char x -> Char x
| G.Float x -> Float x
| G.String x -> String x
| G.Kwd "true" -> Bool true
| G.Kwd "false" -> Bool false
| G.Kwd x -> Tag(tag_of_string x)
in
create_io_in
~peek_token:
begin fun () ->
match
Stream.peek g
with
| None -> raise End_of_file
| Some t -> convert t
end
~read_token:
begin fun () -> convert (next ()) end
()
;;
(* ***)
(*** in_of_channel *)
let in_of_channel ~in_channel () =
in_of_stream ~stream:(Stream.of_channel in_channel) ()
;;
(* ***)
(*** out_of_formatter *)
let out_of_formatter ~formatter ?(indent=false) () =
let fp = Format.fprintf in
let fmt = formatter in
let space = ref false in
let string_of_tag = string_of_tag in
create_io_out
~write_token:
begin function
| Int x -> fp fmt "@ %d" x
| Int64 x -> fp fmt "@ %Ld" x
| Char x -> fp fmt "@ %C" x
| String x -> fp fmt "@ %S" x
| Float x -> fp fmt "@ %F" x
| Bool x -> fp fmt "@ %b" x
| Tag x ->
if indent && is_end_tag x then fp fmt "@]";
if !space then
fp fmt "@ %s" (string_of_tag x)
else
fp fmt "%s" (string_of_tag x);
space := true;
if indent && is_start_tag x then fp fmt "@["
| Constructor x ->
let y = String.copy x in
y.[0] <- Char.uppercase x.[0];
fp fmt "@ %s" y
| Field x -> fp fmt "@ %s" x
| EOF -> ()
end
~flush:
begin fun () ->
fp fmt "@."
end
()
;;
(* ***)
(*** condense_formatter *)
let condense_formatter fmt =
let (out, flush, newline, spaces) = Format.pp_get_all_formatter_output_functions fmt () in
let fmt' = Format.make_formatter out flush in
Format.pp_set_all_formatter_output_functions fmt'
~out
~flush
~newline:(fun _ -> ())
~spaces:(function 0 -> () | _ -> out " " 0 1);
fmt'
;;
(* ***)
(*** out_of_channel *)
let out_of_channel ?(condensed=false) ~out_channel =
let fmt = (Format.formatter_of_out_channel out_channel) in
let formatter =
if condensed then
condense_formatter fmt
else
fmt
in
out_of_formatter ~formatter
;;
(* ***)
dose2-1.4.2/io/human_io.mli 0000664 0000000 0000000 00000002440 11231374124 0015441 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** I/O functions for human-readable, pretty-printed data. *)
val in_of_stream : stream:char Stream.t -> unit -> Fragments.io_in
(** Create a reader from a character stream. *)
val in_of_channel : in_channel:in_channel -> unit -> Fragments.io_in
(** Create a reader from an Ocaml input channel. *)
val out_of_formatter : formatter:Format.formatter -> ?indent:bool -> unit -> Fragments.io_out
(** Create a writer from a formatter. *)
val out_of_channel : ?condensed:bool -> out_channel:out_channel -> ?indent:bool -> unit -> Fragments.io_out
(** Create a writer from an Ocaml output channel. *)
dose2-1.4.2/io/io.ml 0000664 0000000 0000000 00000030375 11231374124 0014110 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Fragments;;
exception Unknown_tag;;
exception Unknown_constructor;;
type io_in = Fragments.io_in
type io_out = Fragments.io_out
(*** r, w, literate, sum_io_spec, record_io_spec *)
type 'a r = io_in -> 'a
type 'a w = 'a -> io_out -> unit
type 'a literate = 'a r * 'a w
type 'a sum_io_spec = (string -> 'a r) * ('a -> string * (io_out -> unit));;
type 'a record_io_spec = (string * ('a -> io_in -> 'a) * ('a -> io_out -> unit)) list;;
type ('thing,'bag) iterator = 'bag -> ('thing -> unit) -> unit
type ('thing,'bag) builder = unit -> ('thing -> unit) * (unit -> 'bag)
type ('thing,'bag) collection_io_spec = 'thing literate * ('thing,'bag) iterator * ('thing,'bag) builder
(* ***)
(*** read, write, flush *)
let read : 'a literate -> io_in -> 'a = fun (r,_) i -> r i;;
let write : 'a literate -> 'a -> io_out -> unit = fun (_,w) x o -> w x o;;
let flush : io_out -> unit = fun o -> Fragments.flush o;;
let finish i = finish i;;
let write_and_flush io x o = write io x o; flush o;;
(* ***)
(*** convert *)
let convert ~(reader : io_in) ~(writer : io_out) () =
let rec loop () =
let t = read_token reader in
(*if t <> Tag T_Stop_data then
begin*)
write_token writer t;
loop ()
(*end
else
flush writer*)
in
loop ()
;;
(* ***)
(*** dump *)
let dump ~(reader : io_in) () =
try
let i = ref 0 in
while true do
let t = read_token reader in
Printf.printf "%d %s\n%!" !i (string_of_token t);
incr i
done
with
| End_of_file -> finish reader
;;
(* ***)
(*** io_{int,string,char,bool,float,unit,int64} *)
let io_int : int literate = (fun i -> read_int i), (fun x o -> write_int o x);;
let io_string : string literate = (fun i -> read_string i), (fun x o -> write_string o x);;
let io_char : char literate = (fun i -> read_char i), (fun x o -> write_char o x);;
let io_bool : bool literate = (fun i -> read_bool i), (fun x o -> write_bool o x);;
let io_float : float literate = (fun i -> read_float i), (fun x o -> write_float o x);;
let io_int64 : int64 literate = (fun i -> read_int64 i), (fun x o -> write_int64 o x);;
let io_unit : unit literate = (fun i -> ()), (fun x o -> ());;
(* ***)
(*** io_convert *)
let io_convert : ('a -> 'b) -> ('b -> 'a) -> 'a literate -> 'b literate =
fun f g io ->
(fun i -> f (read io i)),
(fun x o -> write io (g x) o)
;;
(* ***)
(*** assoc3 *)
let rec assoc3 key = function
| [] -> raise Not_found
| (x,y,z)::rest when x = key -> (y,z)
| _::rest -> assoc3 key rest
;;
(* ***)
(*** io_pair *)
let io_pair : 'a literate -> 'b literate -> ('a * 'b) literate = fun ((xr,xw) as xio) ((yr,yw) as yio) ->
begin fun i ->
read_this_tag i T_LParen;
let x = read xio i in
read_this_tag i T_Comma;
let y = read yio i in
read_this_tag i T_RParen;
(x, y)
end,
begin fun (x,y) o ->
write_tag o T_LParen;
write xio x o;
write_tag o T_Comma;
write yio y o;
write_tag o T_RParen
end
;;
(* ***)
(*** io_triple *)
let io_triple : 'a literate -> 'b literate -> 'c literate -> ('a * 'b * 'c) literate =
fun
((xr,xw) as xio)
((yr,yw) as yio)
((zr,zw) as zio)
->
begin fun i ->
read_this_tag i T_LParen;
let x = read xio i in
read_this_tag i T_Comma;
let y = read yio i in
read_this_tag i T_Comma;
let z = read zio i in
read_this_tag i T_RParen;
(x, y, z)
end,
begin fun (x,y,z) o ->
write_tag o T_LParen;
write xio x o;
write_tag o T_Comma;
write yio y o;
write_tag o T_Comma;
write zio z o;
write_tag o T_RParen
end
;;
(* ***)
(*** io_quadruple *)
let io_quadruple : 'a literate -> 'b literate -> 'c literate -> 'd literate -> ('a * 'b * 'c * 'd) literate =
fun
((xr,xw) as xio)
((yr,yw) as yio)
((zr,zw) as zio)
((tr,tw) as tio)
->
begin fun i ->
read_this_tag i T_LParen;
let x = read xio i in
read_this_tag i T_Comma;
let y = read yio i in
read_this_tag i T_Comma;
let z = read zio i in
read_this_tag i T_Comma;
let t = read tio i in
read_this_tag i T_RParen;
(x, y, z, t)
end,
begin fun (x,y,z,t) o ->
write_tag o T_LParen;
write xio x o;
write_tag o T_Comma;
write yio y o;
write_tag o T_Comma;
write zio z o;
write_tag o T_Comma;
write tio t o;
write_tag o T_RParen
end
;;
(* ***)
(*** discard *)
let rec discard i =
match read_token i with
| Tag T_LBrack -> discard_list i
| Tag T_LParen -> discard_tuple i
| Tag T_LBrace -> discard_record i
| Tag (T_Array|T_Hashtbl) ->
ignore (read_int i);
discard_list i
| Tag T_Set -> discard_list i
| Bool _ | Char _ | Int _ | Int64 _ | Float _ | String _ -> ()
| t -> raise (Error(sf "Unexpected %S in discard" (string_of_token t)))
and discard_record i =
match read_token i with
| Tag T_RBrace -> ()
| Field _ -> discard_record_field i
| t -> raise (Error(sf "Unexpected %S in discard_record" (string_of_token t)))
and discard_record_field i =
read_this_tag i T_Equal;
discard i;
begin
match read_token i with
| Tag T_RBrace -> ()
| Tag T_Semicolon ->
begin
match read_token i with
| Field _ -> discard_record_field i
| t -> raise (Error(sf "Unexpected %S in discard_record_field after semicolon" (string_of_token t)))
end
| t -> raise (Error(sf "Unexpected %S in discard_record_field" (string_of_token t)))
end
and discard_list i =
match read_token i with
| Tag T_RBrack -> ()
| Tag T_Semicolon ->
discard i;
discard_list i
| t -> raise (Error(sf "Unexpected %S in discard_list" (string_of_token t)))
and discard_tuple i =
match read_token i with
| Tag T_RParen -> ()
| Tag T_Comma ->
discard i;
discard_list i
| t -> raise (Error(sf "Unexpected %S in discard_tuple" (string_of_token t)))
(* ***)
(*** io_collection *)
let io_collection : ('thing,'bag) collection_io_spec -> 'bag literate =
fun (xio, iterator, builder) ->
begin fun i ->
(*read_this_tag i T_Collection;*)
let (add, get) = builder () in
let rec loop () =
match peek_token i with
| Tag T_RBrack ->
drop_token i;
get ()
| _ ->
let x = read xio i in
add x;
match read_token i with
| Tag T_RBrack -> get ()
| Tag T_Semicolon -> loop ()
| _ -> raise Unknown_tag
in
read_this_tag i T_Set;
read_this_tag i T_LBrack;
loop ()
end,
begin fun xb o ->
write_tag o T_Set;
write_tag o T_LBrack;
let first = ref true in
iterator xb
begin fun x ->
if !first then first := false else write_tag o T_Semicolon;
write xio x o;
end;
write_tag o T_RBrack
end
;;
(* ***)
(*** io_list *)
let io_list : 'a literate -> 'a list literate = fun ((xr,xw) as xio) ->
begin fun i ->
read_this_tag i T_LBrack;
let rec loop () =
match peek_token i with
| Tag T_RBrack ->
drop_token i;
[]
| _ ->
let x = read xio i in
match read_token i with
| Tag T_RBrack -> [x]
| Tag T_Semicolon -> x :: (loop ())
| _ -> raise Unknown_tag
in
loop ()
end,
begin fun xl o ->
write_tag o T_LBrack;
let rec loop semicolon = function
| [] -> write_tag o T_RBrack
| x :: rest ->
if semicolon then write_tag o T_Semicolon;
write xio x o;
loop true rest
in
loop false xl
end
;;
(* ***)
(*** io_array *)
let io_array : 'a literate -> 'a array literate = fun ((xr,xw) as xio) ->
begin fun i ->
read_this_tag i T_Array;
let m = read_int i in
read_this_tag i T_LBrack;
let x =
Array.init m
begin fun j ->
if j > 0 then read_this_tag i T_Semicolon;
read xio i
end
in
read_this_tag i T_RBrack;
x
end,
begin fun x o ->
write_tag o T_Array;
write_int o (Array.length x);
write_tag o T_LBrack;
Array.iteri
begin fun j x ->
if j > 0 then write_tag o T_Semicolon;
write xio x o
end
x;
write_tag o T_RBrack
end
;;
(* ***)
(*** io_hashtbl *)
let io_hashtbl : 'a literate -> 'b literate -> ('a,'b) Hashtbl.t literate = fun ((xr,xw) as xio) ((yr,yw) as yio) ->
begin fun i ->
read_this_tag i T_Hashtbl;
let m = read_int i in
let h = Hashtbl.create m in
read_this_tag i T_LBrack;
for j = 0 to m - 1 do
if j > 0 then read_this_tag i T_Semicolon;
read_this_tag i T_LParen;
let x = read xio i in
read_this_tag i T_Comma;
let y = read yio i in
read_this_tag i T_RParen;
Hashtbl.add h x y
done;
read_this_tag i T_RBrack;
h
end,
begin fun x o ->
write_tag o T_Hashtbl;
write_int o (Hashtbl.length x);
write_tag o T_LBrack;
let first = ref true in
Hashtbl.iter
begin fun x y ->
if !first then first := false else write_tag o T_Semicolon;
write_tag o T_LParen;
write xio x o;
write_tag o T_Comma;
write yio y o;
write_tag o T_RParen;
end
x;
write_tag o T_RBrack
end
;;
(* ***)
(*** io_record *)
let io_record : 'a record_io_spec -> 'a -> 'a literate =
fun rl initial ->
begin fun i ->
read_this_tag i T_LBrace;
let rec loop1 semicolon current =
match read_token i with
| Tag T_RBrace -> current
| Tag T_Semicolon when semicolon ->
begin
match read_token i with
| Field field ->
read_this_tag i T_Equal;
do_field current field rl
| t -> raise (Error(sf "Expecting field in record after semicolon, not %S" (string_of_token t)))
end
| Field field ->
read_this_tag i T_Equal;
do_field current field rl
| t -> raise (Error(sf "Expecting field in record, not %S" (string_of_token t)))
and do_field current field = function
| [] ->
loss i; (* We've just seen an unknown field *)
discard i; (* Magical discard *)
loop1 true current
| (field',input,_)::rest ->
if field = field' then
begin
let current = input current i in
loop1 true current
end
else
do_field current field rest
in
loop1 false initial
end,
begin fun x o ->
write_tag o T_LBrace;
let first = ref true in
List.iter
begin fun (field,_,output) ->
if !first then first := false else write_tag o T_Semicolon;
write_field o field;
write_tag o T_Equal;
output x o
end
rl;
write_tag o T_RBrace
end
;;
(* ***)
(*** io_sum *)
let io_sum : 'a sum_io_spec -> 'a literate =
fun (sr,sw) ->
begin fun i ->
match read_token i with
| Constructor name ->
begin
try
sr name i
with
| Unknown_constructor -> raise (Error(sf "Constructor %S unknown" name))
end
| t -> raise (Error(sf "Expecting constructor, not %S" (string_of_token t)))
end,
begin fun x o ->
let (name, f) = sw x in
write_token o (Constructor name);
f o
end
;;
(* ***)
(*** io_option *)
let io_option : 'a literate -> 'a option literate =
fun ((xr,xw) as xio) ->
io_sum
begin
begin function
| "none" -> fun i -> None
| "some" -> fun i -> Some(read xio i)
| _ -> raise Unknown_tag
end,
begin function
| None -> "none", write io_unit ()
| Some x -> "some", write xio x
end
end
;;
(* ***)
(*** io_not_implemented *)
let io_not_implemented =
(fun _ -> assert false),
(fun _ _ -> assert false)
;;
(* ***)
dose2-1.4.2/io/io.mli 0000664 0000000 0000000 00000020140 11231374124 0014246 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** General structured I/O module.
This module defines the base types and combinators that you can use to build literates for your data type.
A literate for a type ['a] is someone who can both read and write values of type ['a] over arbitrary
fragment channels (which are defined in the module [Fragments].)
Once you have defined a literate, you can use it to do I/O over any kind of fragment channel. Basic fragment
channels (pretty-printed, human-readable ASCII ; binary and XML) are defined in the modules Human_io, Binary_io and
XML_io. You can also mix channel kinds and for instance read from binary fragment channels and write to ASCII
fragment channels.
To do IO with a type
[type foo = (int * (float list) * (string option list)) option array]
you must :
- Define a literate for your data type, usually using the combinators [io_pair], [io_list], etc.:
[
let io_foo =
io_array (io_option
io_int
(io_list io_float)
(io_list (io_option io_string)))
;;
]
- If you want to save your data, get a channel to save.
[ ]
*)
type io_in = Fragments.io_in
type io_out = Fragments.io_out
exception Unknown_constructor
(** When reading sum types, raise this exception if you are given an unknown constructor name. *)
type 'a r = io_in -> 'a
(** The type of readers. A reader takes an input channel and returns a value. *)
type 'a w = 'a -> io_out -> unit
(** Type type of writers. A writer takes a value, an output channel and returns nothing. *)
type 'a literate = 'a r * 'a w
(** A literate is something that can both read and write. *)
type 'a sum_io_spec = (string -> 'a r) * ('a -> string * (io_out -> unit))
(** The description of a sum type, to be passed to [io_sum] to build a literate for the given type.
It is a pair [(reader,writer)] where [reader] is first given the name of the constructor
and has to return a reader that will read the arguments of the constructor and apply
the constructor to return a value of type ['a]. [writer] pattern-matches the sum
type and returns a pair [(name, writer')] where [name] is a string encoding the name
of the constructor, and [writer'] is a writer for the arguments (which therefore have
to be curryfied.
For instance, the specifier for the ['a option] type is defined as:
[ (function
| "none" -> fun i -> None
| "some" -> fun i -> Some(read xio i)
| _ -> raise Unknown_tag),
(function
| None -> "none", write io_unit ()
| Some x -> "some", write xio x)
] *)
type 'a record_io_spec =
(string * ('a -> io_in -> 'a) * ('a -> io_out -> unit)) list
(** The description of a record type, to be passed to [io_record] to build a literate for
that record type. This is a list of triplets
[[(field1,reader1,writer1); (field2,reader2,writer2); ...]]
where [fieldi] is an identifiers for the field,
[readeri] takes the current value of the record,
and updates it by reading a value for the field [fieldi],
and [writeri] takes a record and an output channel and writes its
field [fieldi]. *)
type ('thing,'bag) iterator = 'bag -> ('thing -> unit) -> unit
(** An iterator takes a bag, a function, and runs the function over the elements of the bag. *)
type ('thing,'bag) builder = unit -> ('thing -> unit) * (unit -> 'bag)
(** A builder takes unit and returns a pair [(add,get)] where [add] is a function that adds
one element to the bag and [get] returns the contents of the bag. *)
type ('thing,'bag) collection_io_spec = 'thing literate * ('thing,'bag) iterator * ('thing,'bag) builder
(** The specification type for an abstract collection of things of type ['thing] is made of a literate for the
type ['thing], an iterator and a builder. *)
val assoc3 : 'a -> ('a * 'b * 'c) list -> 'b * 'c
val read : 'a literate -> io_in -> 'a
(** [read lit ch] reads a value from the channel [ch] using the literate [lit]. For instance,
[read io_int ch] returns an integer. *)
val write : 'a literate -> 'a -> io_out -> unit
(** [write lit v ch] writes the value [v] to the channel [ch] using the literate [lit]. For example,
[write io_int 33 ch] writes the integer [33] to the channel [ch]. *)
val write_and_flush : 'a literate -> 'a -> io_out -> unit
val finish : io_in -> unit
(** [finish ch] finishes reading the input channel. Actually, it reads the Stop_data tag. *)
val flush : io_out -> unit
(** [flush ch] flushed the output channel. Actually, it emits the Stop_data tag and flushes the I/O buffers. *)
val io_int : int literate
(** The literate for integers. *)
val io_int64 : int64 literate
(** The literate for 64-bit integers. *)
val io_string : string literate
(** The literate for strings. *)
val io_char : char literate
(** The literate for characters. *)
val io_bool : bool literate
(** The literate for booleans. *)
val io_float : float literate
(** The literate for floats. *)
val io_unit : unit literate
(** The literate for values of type unit. Actually, this one does nothing. *)
val io_convert : ('a -> 'b) -> ('b -> 'a) -> 'a literate -> 'b literate
(** Given a function [f : 'a -> 'b] its inverse [g : 'b -> 'a] and a literate [io] for ['a]
creates a literate for ['b]. *)
val io_pair : 'a literate -> 'b literate -> ('a * 'b) literate
(** The literate constructor for pairs. [io_pair lit1 lit2] takes literates [lit1] and [lit2] for types
['a] and ['b] and returns a literate for the type ['a * 'b]. *)
val io_triple : 'a literate -> 'b literate -> 'c literate -> ('a * 'b * 'c) literate
(** The literate constructor for triples. *)
val io_quadruple : 'a literate -> 'b literate -> 'c literate -> 'd literate -> ('a * 'b * 'c * 'd) literate
(** The literate constructor for quadruples. *)
val io_list : 'a literate -> 'a list literate
(** The literate constructor for lists. For example, [io_list io_int] is a literate able to read and write
lists of integers. *)
val io_array : 'a literate -> 'a array literate
(** The literate constructor for arrays. *)
val io_hashtbl : 'a literate -> 'b literate -> ('a, 'b) Hashtbl.t literate
(** The literate constructor for hash tables from the module Hashtbl.t. *)
val io_record : 'a record_io_spec -> 'a -> 'a literate
(** The literate constructor for records. Due to the nature of the Ocaml language, you have to provide a
[record_io_spec] describing your record. *)
val io_collection : ('thing,'bag) collection_io_spec -> 'bag literate
(** The literate constructor for abstract collections. *)
val io_sum : 'a sum_io_spec -> 'a literate
(** The literate constructor for sum types. Due to the nature of the Ocaml language, you have to provide a
[record_io_spec] describing your sum type. *)
val io_option : 'a literate -> 'a option literate
(** The literate constructor for the ['a option] sum type. *)
val io_not_implemented : 'a literate
(** Use this when you need to declare a literate but don't want to implement one. *)
val convert : reader:io_in -> writer:io_out -> unit -> unit
(** This function will copy data from [reader] to [writer]. This can be used to convert data between different
formats (e.g., pretty-printed to XML, or XML to binary, etc.) Note that it is not necessary to have a literate
for the data to be converted. *)
val dump : reader:io_in -> unit -> unit
(** This debugging function will dump the tokens to [stdout]. *)
dose2-1.4.2/io/lexer.mli 0000664 0000000 0000000 00000001424 11231374124 0014762 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
exception Lexical_error of string
val token : Lexing.lexbuf -> Fragments.token
dose2-1.4.2/io/lexer.mll 0000664 0000000 0000000 00000005647 11231374124 0015000 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
{
open Fragments;;
exception Lexical_error of string;;
let hex c =
let x = Char.code c in
match c with
| 'a'..'f' -> x - 97 + 10
| 'A'..'F' -> x - 65 + 10
| '0'..'9' -> x land 16
| _ -> invalid_arg "Bad hexadecimal character"
;;
let dec c =
let x = Char.code c in
match c with
| '0'..'9' -> x land 15
| _ -> invalid_arg "Bad decimal character"
;;
let hex_char c1 c2 = Char.chr (((hex c1) lsl 4) lor (hex c2));;
let dec_char c1 c2 c3 = Char.chr ((dec c1) * 100 + (dec c2) * 10 + dec c3);;
}
let hexchar = ['0'-'9' 'a'-'f' 'A'-'F']
let alphanum = ['0'-'9' 'a'-'z' 'A'-'Z' '_']
let decimal = ['0'-'9']
let float_literal =
['0'-'9'] ['0'-'9']*
('.' ['0'-'9']* )?
(['e' 'E'] ['+' '-']? ['0'-'9'] ['0'-'9']*)?
rule token = parse
| "(" { Tag T_LParen }
| ")" { Tag T_RParen }
| "[" { Tag T_LBrack }
| "]" { Tag T_RBrack }
| "{" { Tag T_LBrace }
| "}" { Tag T_RBrace }
| "," { Tag T_Comma }
| ";" { Tag T_Semicolon }
| "=" { Tag T_Equal }
| "array" { Tag T_Array }
| "hash" { Tag T_Hashtbl }
| "set" { Tag T_Set }
| '_'(['a'-'z']alphanum* as w) { Field w }
| ['A'-'Z']alphanum* as w { Constructor w }
| ['a'-'z']alphanum* as w { Field w }
| "true" { Bool true }
| "false" { Bool false }
| '-'? decimal+ as w { Int(int_of_string w) }
| ('-'? decimal+ as w) 'L' { Int64(Int64.of_string w) }
| float_literal as f { Float(float_of_string f) }
| '"' {
let b = Buffer.create 32 in
readstr (Buffer.add_char b) lexbuf;
String(Buffer.contents b)
}
| "(*" { eat_comment lexbuf; token lexbuf }
| [' ' '\t' '\n' '\r']+ { token lexbuf }
| eof { EOF }
| _ as c { raise (Lexical_error(Printf.sprintf "Unexpected %C" c)) }
and eat_comment = parse
| "(*" { eat_comment lexbuf; eat_comment lexbuf }
| "*)" { }
| [^'(' '*']+ { eat_comment lexbuf }
| _ { eat_comment lexbuf }
and readstr f = parse
| "\\n" { f '\n'; readstr f lexbuf }
| "\\t" { f '\t'; readstr f lexbuf }
| "\\b" { f '\b'; readstr f lexbuf }
| "\\r" { f '\r'; readstr f lexbuf }
| "\\\"" { f '"'; readstr f lexbuf }
| "\\\\" { f '\\'; readstr f lexbuf }
| "\\x" (hexchar as c1) (hexchar as c2) { f (hex_char c1 c2); readstr f lexbuf }
| "\\" (decimal as d1) (decimal as d2) (decimal as d3) { f (dec_char d1 d2 d3); readstr f lexbuf }
| '"' { () }
| _ as c { f c; readstr f lexbuf }
{
(* Epilogue. *)
}
dose2-1.4.2/lifetime/ 0000775 0000000 0000000 00000000000 11231374124 0014326 5 ustar 00root root 0000000 0000000 dose2-1.4.2/lifetime/.depend 0000664 0000000 0000000 00000000107 11231374124 0015564 0 ustar 00root root 0000000 0000000 lifetime.cmo: lifetime.cmi
lifetime.cmx: lifetime.cmi
lifetime.cmi:
dose2-1.4.2/lifetime/Makefile 0000664 0000000 0000000 00000000211 11231374124 0015760 0 ustar 00root root 0000000 0000000 NAME= lifetime
SOURCES= lifetime.ml
MLIS= lifetime.mli
REQUIRES= io
PACKAGES= calendar
include ../Makefile.config
include .depend
dose2-1.4.2/lifetime/lifetime.ml 0000664 0000000 0000000 00000007033 11231374124 0016461 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open CalendarLib;;
open Io;;
module G = Generic_io;;
exception Empty;;
type day = int;;
type lifetime = (day * day) list;;
let io_day = io_int;;
let io_lifetime = io_list (io_pair io_day io_day);;
let day_of_ymd (y,m,d) = Date.to_mjd (Date.make y m d);;
let ymd_of_day j =
let d = Date.from_mjd j in
(Date.year d, Date.int_of_month (Date.month d), Date.day_of_month d)
;;
let empty = [];;
let singleton j = [(j,j)];;
let load fn = G.load_from_file io_lifetime fn;;
let save fn lf = G.save_to_file io_lifetime lf fn;;
let print_day oc j =
let (y,m,d) = ymd_of_day j in
Printf.fprintf oc "%04d-%02d-%02d" y m d
;;
let output oc lf =
let first = ref true in
Printf.fprintf oc "[";
List.iter
begin fun (x,y) ->
if !first then first := false else Printf.fprintf oc "; ";
Printf.fprintf oc "(%a,%a)" print_day x print_day y
end
lf;
Printf.fprintf oc "]"
;;
let inner_add_day lf j =
let rec loop = function
| [] -> [(j,j)]
| [(j1,j2)] as stuff ->
if j1 <= j && j <= j2 then
stuff
else
if j < j1 then
(j,j)::stuff
else
if j2 + 1 = j then
[(j1,j2+1)]
else
[(j1,j2);(j,j)]
| ((j1,j2)::(j3,j4)::rest) as stuff ->
if j < j1 then
(* Before the first interval *)
if j = j1 - 1 then
(* Just before, extend the first *)
(j,j2) :: (j3,j4) :: rest
else
(* Do not extend the first *)
(j,j)::stuff
else
if j <= j2 then
(* Absorbed by first interval *)
stuff
else
if j = j2 + 1 then
(* Extends the first interval by one day to the future *)
if j = j3 then
begin
(* The first two intervals merge *)
(j1,j4)::rest
end
else
(* The first two intervals remain disjoint *)
(j1,j2+1)::(j3,j4)::rest
else
(j1,j2)::(loop ((j3,j4)::rest))
in
loop lf
;;
let add_day lf j =
inner_add_day lf j
;;
let iterate_over_intervals f lf =
List.iter f lf
;;
let iterate_over_days f lf =
List.iter
begin fun (j1,j2) ->
for j = j1 to j2 do
f j
done
end
lf
;;
let is_empty = function
| [] -> true
| _ -> false
;;
let range = function
| [] -> raise Empty
| (j1, j2) :: rest ->
List.fold_left
begin fun (j1, j2) (j1', j2') ->
(min j1 j1', max j2 j2')
end
(j1,j2)
rest
;;
(*val add_interval : lifetime -> day * day -> lifetime (** [add_interval lf (a,b)] returns a lifetime with all the days in
[lf] and all the days in the set \{[a],[a+1],...,[b]\}. If [b < a] then no day is added. *) *)
dose2-1.4.2/lifetime/lifetime.mli 0000664 0000000 0000000 00000004514 11231374124 0016633 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** Datastructure for life timelines.
Provides a datastructure for representing sets of days as a list of intervals, suitable for
rLepresenting the lifetime of a package in an archive. *)
exception Empty (** Raised when a function expects a non-empty lifetime *)
type day = int (** Represented as calendar days from an unspecified origin. *)
type lifetime
val io_lifetime : lifetime Io.literate
val io_day : day Io.literate
val day_of_ymd : (int * int * int) -> day (** Convert a date in Gregorian [(year,month,day)] format to a calendar day. *)
val ymd_of_day : day -> (int * int * int) (** Inverse function of [day_of_date]. *)
val empty : lifetime (** A lifetime containing no days. *)
val load : string -> lifetime (** Load lifetime data from a file using [Io]. *)
val save : string -> lifetime -> unit (** Save lifetime data to a file using [Io]. *)
val output : out_channel -> lifetime -> unit (** Output lifetime data to a channel using [Io]. *)
val singleton : day -> lifetime (** Create a lifetime with the given single day. *)
val add_day : lifetime -> day -> lifetime (** Add a day to a lifetime. *)
val is_empty : lifetime -> bool (** Returns [true] if the lifetime contains no days. *)
val range : lifetime -> day * day
(** [range lf] returns a pair [(a,b)] where [a] is the first day and [b]
* is the last day in the lifetime. Raises [Empty] if [lf] is empty. *)
val iterate_over_intervals : (day * day -> unit) -> lifetime -> unit (** Iterate over the intervals in the lifetime. A
single day is represented by a pair [(d,d)]. *)
val iterate_over_days : (day -> unit) -> lifetime -> unit (** Iterate over every single day in the lifetime. *)
dose2-1.4.2/mmap/ 0000775 0000000 0000000 00000000000 11231374124 0013462 5 ustar 00root root 0000000 0000000 dose2-1.4.2/mmap/Makefile 0000664 0000000 0000000 00000000322 11231374124 0015117 0 ustar 00root root 0000000 0000000 # Makefile
SOURCES = mmap.mli mmap.ml map.c
NAME = mmap
REQUIRES = unix threads
OCAML_INCLUDE := $(shell ocamlc -where)
CFLAGS += -I$(OCAML_INCLUDE) -fPIC
extra2 = dllmmap.so
include Makefile.library
dose2-1.4.2/mmap/map.c 0000664 0000000 0000000 00000011441 11231374124 0014404 0 ustar 00root root 0000000 0000000 /* Memory mapped files */
#include
#include
#include
#include
#include
#include
#include
#include
typedef struct {
void *mmd_start;
size_t mmd_length;
off_t mmd_offset;
} mmd;
#define mmd_val(v) (*((mmd *) Data_custom_val(v)))
static void mmd_finalize(value mmdv)
{
if(munmap(mmd_val(mmdv).mmd_start, mmd_val(mmdv).mmd_length)) {
caml_failwith("munmap");
}
}
static struct custom_operations mmd_ops = {
"memory_mapped_string",
mmd_finalize,
custom_compare_default,
custom_hash_default,
custom_serialize_default,
custom_deserialize_default
};
value caml_mmap_unmap(value mmdv)
{
CAMLparam1(mmdv);
if(mmd_val(mmdv).mmd_start == MAP_FAILED) caml_failwith("not mapped");
mmd_finalize(mmdv);
CAMLreturn(Val_unit);
}
value caml_mmap_length(value mmdv)
{
CAMLparam1(mmdv);
CAMLlocal1(lengthv);
if(mmd_val(mmdv).mmd_start == MAP_FAILED) caml_failwith("not mapped");
lengthv = copy_int64(mmd_val(mmdv).mmd_length);
CAMLreturn(lengthv);
}
value caml_mmap_offset(value mmdv)
{
CAMLparam1(mmdv);
CAMLlocal1(offsetv);
if(mmd_val(mmdv).mmd_start == MAP_FAILED) caml_failwith("not mapped");
offsetv = copy_int64(mmd_val(mmdv).mmd_offset);
CAMLreturn(offsetv);
}
value caml_mmap_map(value writev, value copyv, value offsetv, value lengthv, value fdv)
{
CAMLparam5(writev,copyv,offsetv,lengthv,fdv);
CAMLlocal1(mmdv);
size_t length;
off_t offset;
void *start;
int write, copy;
int prot, flags;
int fd;
fd = Int_val(fdv);
write = Int_val(writev);
copy = Int_val(copyv);
length = Int64_val(lengthv);
offset = Int64_val(offsetv);
if(length < 0) caml_failwith("mmap: bad length");
if(offset < 0) caml_failwith("mmap: bad offset");
prot = PROT_READ;
if(write) prot |= PROT_WRITE;
flags = write ? MAP_PRIVATE : MAP_SHARED;
start = mmap(0, length, prot, flags, fd, offset);
if(start == MAP_FAILED) caml_failwith("mmap");
mmdv = alloc_custom(&mmd_ops, sizeof(mmd), length, 1048576);
mmd_val(mmdv).mmd_start = start;
mmd_val(mmdv).mmd_length = length;
mmd_val(mmdv).mmd_offset = offset;
CAMLreturn(mmdv);
}
value caml_mmap_sub(value mmdv, value offsetv, value lengthv)
{
CAMLparam3(mmdv, offsetv, lengthv);
off_t offset;
size_t length;
CAMLlocal1(uv);
if(mmd_val(mmdv).mmd_start == MAP_FAILED) caml_failwith("not mapped");
offset = Int64_val(offsetv);
length = Int_val(lengthv);
if(offset >= 0 &&
offset + length <= mmd_val(mmdv).mmd_length) {
uv = caml_alloc_string(length);
memcpy(String_val(uv), ((char *) mmd_val(mmdv).mmd_start) + offset, length);
} else {
caml_invalid_argument("bad offset or length");
}
CAMLreturn(uv);
}
value caml_mmap_blit(value mmdv, value targetv, value stringv, value offsetv, value lengthv)
{
CAMLparam5(mmdv, targetv, stringv, offsetv, lengthv);
off_t target;
int offset;
size_t length;
char *string;
if(mmd_val(mmdv).mmd_start == MAP_FAILED) caml_failwith("not mapped");
target = Int64_val(targetv);
string = String_val(stringv);
offset = Int_val(offsetv);
length = Int_val(lengthv);
if(target >= 0 &&
target + length <= mmd_val(mmdv).mmd_length &&
offset >= 0 &&
offset + length <= string_length(stringv)) {
memcpy(((char *) mmd_val(mmdv).mmd_start) + target, string + offset, length);
} else {
caml_invalid_argument("bad offset or length");
}
CAMLreturn(Val_unit);
}
#if 0
value caml_blit_mmd(value mmdv, value uv, value offsetv)
{
CAMLparam3(mmdv, uv, offsetv);
void *u;
size_t offset;
size_t length;
offset = Int_val(offsetv);
u = String_val(uv);
length = string_length(uv);
if(offset >= 0 &&
offset + length <= mmd_val(mmdv).mmd_length) {
memcpy(mmd_val(mmdv).mmd_start, u, length);
} else {
caml_invalid_argument("bad offset or length");
}
CAMLreturn(Val_unit);
}
typedef int (*iiti)(int, int);
typedef int (*sti)(char *, int);
value caml_exec_mmd_iiti(value mmdv, value offsetv, value xv, value yv)
{
CAMLparam4(mmdv, offsetv, xv, yv);
size_t offset;
int x, y;
int z;
x = Int_val(xv);
y = Int_val(yv);
offset = Int_val(offsetv);
if(offset >= 0 && offset < mmd_val(mmdv).mmd_length) {
iiti f;
f = (iiti)(mmd_val(mmdv).mmd_start + offset);
z = f(x,y);
} else {
caml_invalid_argument("bad offset or length");
}
CAMLreturn(Val_int(z));
}
value caml_exec_mmd_sti(value mmdv, value offsetv, value wordv)
{
CAMLparam3(mmdv, offsetv, wordv);
size_t offset;
int z;
offset = Int_val(offsetv);
if(offset >= 0 && offset < mmd_val(mmdv).mmd_length) {
sti f;
f = (sti)(mmd_val(mmdv).mmd_start + offset);
z = f(String_val(wordv), string_length(wordv));
} else {
caml_invalid_argument("bad offset or length");
}
CAMLreturn(Val_int(z));
}
#endif
dose2-1.4.2/mmap/mmap.ml 0000664 0000000 0000000 00000002725 11231374124 0014754 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
type t
external caml_map : bool -> bool -> int64 -> int64 -> Unix.file_descr -> t = "caml_mmap_map" "caml_mmap_map"
module UL = Unix.LargeFile;;
let map ?(write=false) ?(copy=false) ?(offset=0L) ?length fd =
let st = UL.fstat fd in
let length = Int64.sub st.UL.st_size offset in
caml_map write copy offset length fd
;;
external unmap : t -> unit = "caml_mmap_unmap" "caml_mmap_unmap"
external length : t -> int64 = "caml_mmap_length" "caml_mmap_length"
external offset : t -> int64 = "caml_mmap_offset" "caml_mmap_offset"
external sub : t -> int64 -> int -> string = "caml_mmap_sub" "caml_mmap_sub"
external blit : t -> int64 -> string -> int -> int -> unit = "caml_mmap_blit" "caml_mmap_blit"
let paste mp offset u =
let n = String.length u in
blit mp offset u 0 n
;;
dose2-1.4.2/mmap/mmap.mli 0000664 0000000 0000000 00000004746 11231374124 0015132 0 ustar 00root root 0000000 0000000 (* Copyright 2006 Berke DURAK and INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** Accessing memory-mapped files as strings.
This module allows one to map files into memory and access
them byte by byte, or by extracing or blitting substrings.
*)
type t (** A type representing a memory-mapped file *)
val map : ?write:bool -> ?copy:bool -> ?offset:int64 -> ?length:int64 -> Unix.file_descr -> t
(** [map fd copy offset length] maps the bytes [offset .. offset + length - 1] of file [fd];
if [copy] is true, the file is mapped in copy-on-write mode. *)
val unmap : t -> unit
(** [unmap mp] removes the mapping [mp] ; all subsequent calls with [mp] will raise an [Invalid_argument]
exception. *)
val sub : t -> int64 -> int -> string
(** [sub mp o n] copies the bytes from [offset + o] to [offset + o + n]
into a new string *)
val length : t -> int64
(** Returns the length of the mapped region *)
val offset : t -> int64
(** Returns the offset of the mapped region *)
val blit : t -> int64 -> string -> int -> int -> unit
(** [blit mp i u j n] copies the bytes
[j] to [j + n - 1] of the string [u]
into the bytes [offset + i] to [offset + i + n - 1] of the map. *)
val paste : t -> int64 -> string -> unit
(** [paste mp i u] copies the string [u] into the bytes [offset + i] to [offset + i + n - 1]
of the map, where [n] is the length of the string [u]. *)
(*
val get : t -> int64 -> char
(** [get mp i] returns the byte at [offset + i] of the mapped file t as a character *)
val get_byte : t -> int64 -> int
(** [get_byte mp i] returns the byte at [offset + i] of the mapped file t as an integer *)
val blit_from_string : t -> int64 -> int -> string -> int -> unit
(** [blit_from_string mp i n u j] copies the bytes
[j] to [j + n - 1] of the string [u]
into the bytes [offset + i] to [offset + i + n - 1] of the map. *)
*)
dose2-1.4.2/myocamlbuild.ml 0000664 0000000 0000000 00000006425 11231374124 0015552 0 ustar 00root root 0000000 0000000 open Ocamlbuild_plugin;;
open Ocamlbuild_pack;;
open Command;;
let ocamlducedep_command arg =
let tags = tags_of_pathname arg++"ocaml"++"ocamldep" in
if Tags.does_match tags (Tags.of_list ["use_ocamlduce"]) then
S[A "ocamlducefind"; A "ocamldep"; T tags; Ocaml_utils.ocaml_ppflags tags; Tools.flags_of_pathname arg; A "-modules"]
else
S[!Options.ocamldep; T tags; Ocaml_utils.ocaml_ppflags tags; Tools.flags_of_pathname arg; A "-modules"];;
let ocamlducedep_command arg out =
S[ocamlducedep_command arg; P arg; Sh ">"; Px out];;
dispatch begin function
| Before_options ->
begin
Options.ocamlc := S[A "ocamlfind"; A "ocamlc"];
Options.ocamlopt := S[A "ocamlfind"; A "ocamlopt"];
Options.ocamldep := S[A "ocamlfind"; A "ocamldep"];
Options.ocamlyacc := S[A "menhir" (* ; A "--trace" *)];
end
| After_rules ->
Ocamldep.depends "ocamlduce dependencies ml" ~insert:(`before "ocaml dependencies ml") ~ocamldep_command:ocamlducedep_command ~dep:"%.ml" ~prod:"%.ml.depends" ();
Ocamldep.depends "ocamlduce dependencies mli" ~insert:(`before "ocaml dependencies mli") ~ocamldep_command:ocamlducedep_command ~dep:"%.mli" ~prod:"%.mli.depends" ();
rule "ocamlduce: ml & cmi -> cmo" ~insert:(`before "ocaml: ml & cmi -> cmo") ~prod:"%.cmo" ~deps:["%.mli"; "%.ml"; "%.ml.depends"; "%.cmi"]
begin fun env build ->
let ml = env "%.ml"
and _cmo = env "%.cmo" in
let tags = (tags_of_pathname ml)++"compile"++"ocaml"++"byte" in
Ocaml_compiler.prepare_compile build ml;
if Tags.does_match tags (Tags.of_list ["use_ocamlduce"]) then
Cmd(S[A "ocamlducefind"; A "ocamlc"; A "-c"; Ocaml_utils.ocaml_include_flags ml; T tags; P ml])
else
Cmd(S[!Options.ocamlc; A "-c"; Ocaml_utils.ocaml_include_flags ml; T tags; P ml])
end;
rule "ocamlduce: ml -> cmo & cmi" ~insert:(`before "ocaml: ml -> cmo & cmi") ~prods:["%.cmo"; "%.cmi"] ~deps:["%.ml"; "%.ml.depends"]
begin fun env build ->
let ml = env "%.ml"
and cmo = env "%.cmo" in
let tags = (tags_of_pathname ml)++"compile"++"ocaml"++"byte" in
Ocaml_compiler.prepare_compile build ml;
if Tags.does_match tags (Tags.of_list ["use_ocamlduce"]) then
Cmd(S[A "ocamlducefind"; A "ocamlc"; A "-c"; Ocaml_utils.ocaml_include_flags ml; T tags; A "-o"; P cmo; P ml])
else
Cmd(S[!Options.ocamlc; A "-c"; Ocaml_utils.ocaml_include_flags ml; T tags; P ml])
end;
rule "ocamlduce: cmo* -> cma" ~insert:(`before "ocaml: cmo* -> cma") ~prod:"%.cma" ~dep:"%.cmo"
begin fun env _build ->
let cmo = env "%.cmo"
and cma = env "%.cma" in
let tags = (tags_of_pathname cmo)++"library"++"ocaml"++"byte" in
if Tags.does_match tags (Tags.of_list ["use_ocamlduce"]) then
Cmd(S[A "ocamlducefind"; A "ocamlc"; A "-a"; Ocaml_utils.ocaml_include_flags cmo; T tags; A "-o"; P cma; P cmo])
else
Cmd(S[!Options.ocamlc; A "-a"; T tags; Ocaml_utils.ocaml_include_flags cmo; A "-o"; P cma; P cmo])
end;
flag ["byte"; "camlp4o"] (S[A "-pp"; A "camlp4o.byte"]);
flag ["compile"; "use_calendar"] (S[A "-package"; A "calendar"]);
flag ["compile"; "use_pcre"] (S[A "-package"; A "pcre"]);
flag ["compile"; "use_ocsigen"] (S[A "-package"; A "ocsigen"]);
flag ["program"; "use_calendar"] (S[A "-linkpkg"; A "-package"; A "calendar"]);
flag ["program"; "use_pcre"] (S[A "-linkpkg"; A "-package"; A "pcre"]);
| _ -> ()
end;;
dose2-1.4.2/napkin/ 0000775 0000000 0000000 00000000000 11231374124 0014010 5 ustar 00root root 0000000 0000000 dose2-1.4.2/napkin/.depend 0000664 0000000 0000000 00000000075 11231374124 0015252 0 ustar 00root root 0000000 0000000 napkin.cmo: napkin.cmi
napkin.cmx: napkin.cmi
napkin.cmi:
dose2-1.4.2/napkin/Makefile 0000664 0000000 0000000 00000000164 11231374124 0015451 0 ustar 00root root 0000000 0000000 NAME = napkin
SOURCES = napkin.ml
MLIS = napkin.mli
REQUIRES = io
include ../Makefile.config
include .depend
dose2-1.4.2/napkin/gendoc.sh 0000775 0000000 0000000 00000000103 11231374124 0015600 0 ustar 00root root 0000000 0000000 #!/bin/sh
ocamlfind ocamldoc napkin.mli -d doc -html -package pcre
dose2-1.4.2/napkin/napkin.ml 0000664 0000000 0000000 00000017202 11231374124 0015624 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Io;;
(*** Types *)
type ('a) selector =
| Sel_LEQ of 'a
| Sel_GEQ of 'a
| Sel_LT of 'a
| Sel_GT of 'a
| Sel_EQ of 'a
| Sel_ANY;;
type ('unit, 'version, 'glob) versioned =
| Unit_version of ('unit * 'version selector)
| Glob_pattern of 'glob
type ('extra, 'unit, 'version, 'glob, 'architecture, 'source) package = {
pk_unit : 'unit;
pk_version : 'version;
pk_architecture : 'architecture;
pk_extra : 'extra;
pk_size : int64;
pk_installed_size : int64;
pk_source : 'source;
pk_provides : ('unit, 'version, 'glob) versioned list;
pk_conflicts : ('unit, 'version, 'glob) versioned list;
pk_breaks : ('unit, 'version, 'glob) versioned list;
pk_replaces : ('unit, 'version, 'glob) versioned list;
pk_depends : ('unit, 'version, 'glob) versioned list list;
pk_pre_depends : ('unit, 'version, 'glob) versioned list list;
pk_suggests : ('unit, 'version, 'glob) versioned list list;
pk_recommends : ('unit, 'version, 'glob) versioned list list;
pk_enhances : ('unit, 'version, 'glob) versioned list list;
pk_essential : bool;
pk_build_essential : bool
};;
type default_package = (unit, string, string, string, string, string * string) package;;
type package_with_files = ((string * string) list, string, string, string, string, string * string) package;;
(* ***)
(*** string_of_versioned *)
let string_of_versioned v =
match v with
| Unit_version (pn, vs) -> begin
match vs with
| Sel_ANY -> pn
| Sel_LEQ v -> pn^" (<= "^v^")"
| Sel_LT v -> pn^" (<< "^v^")"
| Sel_GEQ v -> pn^" (>= "^v^")"
| Sel_GT v -> pn^" (>> "^v^")"
| Sel_EQ v -> pn^" (== "^v^")"
end
| Glob_pattern g -> g
;;
(* ***)
(*** io_selector
let io_version_selector io_v =
io_sum
begin
begin function
| "ANY" -> fun i -> Sel_ANY
| "LT" -> fun i -> Sel_LT(read io_v i)
| "LEQ" -> fun i -> Sel_LEQ(read io_v i)
| "EQ" -> fun i -> Sel_EQ(read io_v i)
| "GEQ" -> fun i -> Sel_GEQ(read io_v i)
| "GT" -> fun i -> Sel_GT(read io_v i)
| _ -> fun i -> raise Unknown_constructor
end,
begin function
| Sel_ANY -> "ANY", write io_unit ()
| Sel_LT vn -> "LT", write io_v vn
| Sel_LEQ vn -> "LEQ", write io_v vn
| Sel_EQ vn -> "EQ", write io_v vn
| Sel_GEQ vn -> "GEQ", write io_v vn
| Sel_GT vn -> "GT", write io_v vn
end
end
;;
***)
(*** io_versioned
let io_versioned io_unit io_version io_glob =
io_sum
begin
begin function
| "UV" -> fun i -> Unit_version (read (io_pair io_unit io_version) i)
| "GLOB" -> fun i -> Glob_pattern(read io_glob i)
| _ -> fun i -> raise Unknown_constructor
end,
begin function
| Unit_version uv -> "UV", write (io_pair io_unit io_version) uv
| Glob_pattern g -> "GLOB", write io_glob g
end
end
;;
***)
(*** map_version_selector *)
let map_selector f = function
| Sel_LEQ v -> Sel_LEQ(f v)
| Sel_GEQ v -> Sel_GEQ(f v)
| Sel_LT v -> Sel_LT(f v)
| Sel_GT v -> Sel_GT(f v)
| Sel_EQ v -> Sel_EQ(f v)
| Sel_ANY -> Sel_ANY
;;
(* ***)
(*** map *)
let map ~extra ~unit ~version ~glob ~architecture ~source p =
let versioned v =
match v with
| Unit_version (u, vs) -> Unit_version (unit u, map_selector version vs)
| Glob_pattern g -> Glob_pattern (glob g)
in
{ pk_extra = extra p.pk_extra;
pk_unit = unit p.pk_unit;
pk_version = version p.pk_version;
pk_architecture = architecture p.pk_architecture;
pk_source = source p.pk_source;
pk_essential = p.pk_essential;
pk_build_essential = p.pk_build_essential;
pk_provides = List.map versioned p.pk_provides;
pk_size = p.pk_size;
pk_installed_size = p.pk_installed_size;
pk_conflicts = List.map versioned p.pk_conflicts;
pk_breaks = List.map versioned p.pk_breaks;
pk_replaces = List.map versioned p.pk_replaces;
pk_depends = List.map (List.map versioned) p.pk_depends;
pk_pre_depends = List.map (List.map versioned) p.pk_pre_depends;
pk_suggests = List.map (List.map versioned) p.pk_suggests;
pk_recommends = List.map (List.map versioned) p.pk_recommends;
pk_enhances = List.map (List.map versioned) p.pk_enhances }
;;
(* ***)
(*** io_package
let io_package
~io_extra
~io_unit
~io_version
~io_glob
~io_architecture
~io_source =
let io_versioned' = io_versioned io_unit io_version io_glob in
io_record
[
"extra",
(fun x i -> { x with pk_extra = read io_extra i }),
(fun x -> write io_extra x.pk_extra);
"unit",
(fun x i -> { x with pk_unit = read io_unit i }),
(fun x -> write io_unit x.pk_unit);
"version",
(fun x i -> { x with pk_version = read io_version i }),
(fun x -> write io_version x.pk_version);
"architecture",
(fun x i -> { x with pk_architecture = read io_architecture i }),
(fun x -> write io_architecture x.pk_architecture);
"source",
(fun x i -> { x with pk_source = read io_source i }),
(fun x -> write io_source x.pk_source);
"essential",
(fun x i -> { x with pk_essential = read io_bool i }),
(fun x -> write io_bool x.pk_essential);
"build_essential",
(fun x i -> { x with pk_build_essential = read io_bool i }),
(fun x -> write io_bool x.pk_build_essential);
"provides",
(fun x i -> { x with pk_provides = read (io_list io_versioned') i }),
(fun x -> write (io_list io_versioned') x.pk_provides);
"conflicts",
(fun x i -> { x with pk_conflicts = read (io_list io_versioned') i }),
(fun x -> write (io_list io_versioned') x.pk_conflicts);
"replaces",
(fun x i -> { x with pk_replaces = read (io_list io_versioned') i }),
(fun x -> write (io_list io_versioned') x.pk_replaces);
"depends",
(fun x i -> { x with pk_depends = read (io_list (io_list io_versioned')) i }),
(fun x -> write (io_list (io_list (io_versioned'))) x.pk_depends);
"pre_depends",
(fun x i -> { x with pk_pre_depends = read (io_list (io_list io_versioned')) i }),
(fun x -> write (io_list (io_list (io_versioned'))) x.pk_pre_depends);
"suggests",
(fun x i -> { x with pk_suggests = read (io_list (io_list io_versioned')) i }),
(fun x -> write (io_list (io_list (io_versioned'))) x.pk_suggests);
"recommends",
(fun x i -> { x with pk_recommends = read (io_list (io_list io_versioned')) i }),
(fun x -> write (io_list (io_list (io_versioned'))) x.pk_recommends);
"enhances",
(fun x i -> { x with pk_enhances = read (io_list (io_list io_versioned')) i }),
(fun x -> write (io_list (io_list (io_versioned'))) x.pk_enhances);
]
;;
***)
let name nk = (nk.pk_unit, nk.pk_version, nk.pk_architecture);;
type channel = default_package Stream.t;;
let to_default_package (p: ('a, string, string, string, string, string * string) package): default_package =
{ p with pk_extra = () };;
dose2-1.4.2/napkin/napkin.mli 0000664 0000000 0000000 00000012062 11231374124 0015774 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** Normalized Abstract PacKage INformation.
Provides a common datastructure for expressing package dependency information.
Readers for Debian or RPM-style metadata output a stream of [package] structures. *)
(** The type [('a, 'b) selector] represents a range of versions where type ['a] represents versions and ['b] represents glob patterns. *)
type ('a) selector =
| Sel_LEQ of 'a
| Sel_GEQ of 'a
| Sel_LT of 'a
| Sel_GT of 'a
| Sel_EQ of 'a
| Sel_ANY;;
(** Maps over selectors. *)
val map_selector: ('a -> 'b) -> ('a) selector -> ('b) selector
(** A range of versions for a unit such as ocaml (>> 3.04) is represented by ["ocaml", Sel_GT "3.04"]. *)
type ('name, 'version, 'glob) versioned =
| Unit_version of ('name * 'version selector)
| Glob_pattern of 'glob
(** The main datastructure used to represent packages. *)
type ('extra, 'unit, 'version, 'glob, 'architecture, 'source) package = {
pk_unit : 'unit; (** The name of the unit, e.g., ["libc6"] *)
pk_version : 'version; (** Its version ["2.3.6.ds1-8"] *)
pk_architecture : 'architecture; (** Its architecture ["i386"]; *)
pk_extra : 'extra; (** Extra user-specific information *)
pk_size : int64; (** Its packaged size, in bytes. *)
pk_installed_size : int64; (** Its installed size, in bytes. *)
pk_source : 'source; (** The source of this package. *)
pk_provides : ('unit, 'version, 'glob) versioned list; (** A list of units provided by this package. *)
pk_conflicts : ('unit, 'version, 'glob) versioned list; (** A list of versions with which this package conflicts. *)
pk_breaks : ('unit, 'version, 'glob) versioned list; (** A list of versions with which this package breaks. *)
pk_replaces : ('unit, 'version, 'glob) versioned list; (** A list of versions which this package replaces. *)
pk_depends : ('unit, 'version, 'glob) versioned list list; (** A list of disjunctions which this package needs to run. For instance,
pk_if [depends] is [[[a;b];[c];[d;e;f]]] then this package requires (a or b) and c and (d or e or f). *)
pk_pre_depends : ('unit, 'version, 'glob) versioned list list; (** A list of disjunctions which this package needs to be configured. *)
pk_suggests : ('unit, 'version, 'glob) versioned list list; (** A list of disjunctions which this package suggests. *)
pk_recommends : ('unit, 'version, 'glob) versioned list list; (** A list of disjunctions which this package recommends. *)
pk_enhances : ('unit, 'version, 'glob) versioned list list; (** A list of disjunctions which this package enhances. *)
pk_essential : bool; (** If true, this is an essential package. *)
pk_build_essential : bool (** If true, this is a build-essential package. *)
};;
type default_package = (unit, string, string, string, string, string * string) package;;
type package_with_files = ((string * string) list, string, string, string, string, string * string) package;;
val map :
extra:('extra1 -> 'extra2) ->
unit:('unit1 -> 'unit2) ->
version:('version1 -> 'version2) ->
glob:('glob1 -> 'glob2) ->
architecture:('architecture1 -> 'architecture2) ->
source:('source1 -> 'source2) ->
('extra1, 'unit1, 'version1, 'glob1, 'architecture1, 'source1) package ->
('extra2, 'unit2, 'version2, 'glob2, 'architecture2, 'source2) package
(** Returns a textual representation of a versioned range in Debian style. *)
val string_of_versioned : (string, string, string) versioned -> string
(** Package names must be unique *)
val name : ('extra, 'unit, 'version, 'glob, 'architecture, 'source) package -> 'unit * 'version * 'architecture
(* A literate constructor for packages
val io_package :
io_extra:'extra Io.literate ->
io_unit:'unit Io.literate ->
io_version:'version Io.literate ->
io_glob:'glob Io.literate ->
io_architecture:'architecture Io.literate ->
io_source:'source Io.literate ->
('extra, 'unit, 'version, 'glob, 'architecture, 'source) package ->
('extra, 'unit, 'version, 'glob, 'architecture, 'source) package Io.literate *)
(** Channels are streams of packages *)
type channel = default_package Stream.t;;
(** Convert a package with extras to a default package *)
val to_default_package: ('a, string, string, string, string, string * string) package -> default_package;;
dose2-1.4.2/ocamldeb/ 0000775 0000000 0000000 00000000000 11231374124 0014276 5 ustar 00root root 0000000 0000000 dose2-1.4.2/ocamldeb/.depend 0000664 0000000 0000000 00000000377 11231374124 0015545 0 ustar 00root root 0000000 0000000 pirate.cmo: pirate.cmi
pirate.cmx: pirate.cmi
ocamldeb.cmo: pirate.cmi ocamldeb.cmi
ocamldeb.cmx: pirate.cmx ocamldeb.cmi
ocamldebwriter.cmo: ocamldebwriter.cmi
ocamldebwriter.cmx: ocamldebwriter.cmi
pirate.cmi:
ocamldeb.cmi:
ocamldebwriter.cmi:
dose2-1.4.2/ocamldeb/Makefile.in 0000664 0000000 0000000 00000000370 11231374124 0016343 0 ustar 00root root 0000000 0000000 # Makefile
NAME= ocamldeb
SOURCES= pirate.ml ocamldeb.ml ocamldebwriter.ml
MLIS= pirate.mli ocamldeb.mli ocamldebwriter.mli
REQUIRES= util progress napkin
PACKAGES= pcre,@OCAMLZIP@,bz2,num
include ../Makefile.config
include .depend
dose2-1.4.2/ocamldeb/ocamldeb.ml 0000664 0000000 0000000 00000037202 11231374124 0016402 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(* version ::=
| epoch':'.upstream_version.'-'.debian_revision
| upstream_version_no_colon.'-'.debian_revision
| upstream_version_no_colon_no_dash
| epoch':'.upstream_version_no_dash
* epoch ::= [0-9]+
* upstream_version ::= [a-zA-Z0-9.+-:]+
* upstream_version_no_colon ::= [a-zA-Z0-9.+-]+
* upstream_version_no_dash ::= [a-zA-Z0-9.+:]+
* upstream_version_no_colon_no_dash ::= [a-zA-Z0-9.+]+
* debian_revision ::= [a-zA-Z0-9+.]+
*)
open Big_int
open Scanf
open Util
open Napkin
let comma_rex = Pcre.regexp ",";;
let bar_rex = Pcre.regexp "\\|";;
let buffer = ref "";;
let buffer_pos = ref 0;;
let bufsize = 8192;;
let sub_buffer = String.create bufsize;;
let extract_epoch x =
try
let ci = String.index x ':' in
if ci < String.length x - 1 then
let epoch = String.sub x 0 ci
and rest = String.sub x (ci + 1) (String.length x - ci - 1)
in
(epoch,rest)
else
("",x)
with
| Not_found -> ("",x)
;;
let extract_revision x =
try
let di = String.rindex x '-' in
if di < String.length x - 1 then
let upstream = String.sub x 0 di
and revision = String.sub x (di + 1) (String.length x - di - 1)
in
(upstream,revision)
else
(x,"")
with
| Not_found -> (x,"")
;;
let extract_chunks x =
let (epoch,rest) = extract_epoch x in
let (upstream,revision) = extract_revision rest in
(epoch,upstream,revision)
;;
let ( ** ) x y = if x = 0 then y else x;;
let ( *** ) x y = if x = 0 then y () else x;;
let ( ~~~ ) f x = not (f x)
let order = function
| `C '~' -> (0,'~')
| `C('0'..'9' as c) -> (1,c)
| `E -> (2,'\000')
| `C('a'..'z'|'A'..'Z' as c) -> (3,c)
| `C(c) -> (4,c)
;;
let compare_couples (x1,x2) (y1,y2) = (compare x1 y1) ** (compare x2 y2);;
let compare_special x y =
let m = String.length x
and n = String.length y
in
let rec loop i =
let cx = if i >= m then `E else `C(x.[i])
and cy = if i >= n then `E else `C(y.[i])
in
(compare_couples (order cx) (order cy)) ***
(fun () ->
if i > m or i > n then
0
else
loop (i + 1))
in
loop 0
;;
(* -1 : x < y *)
(** According to APT's behaviour, 5.002 and 5.2 are equivalent version numbers. This means that
* the Debian ordering is not a proper order on strings but a preorder. This means that it is
* not possible to use version string-indexed hashtables, as we may get duplicate entries.
*)
let compare_numeric_decimal x y =
let m = String.length x
and n = String.length y
in
let rec loop1 i j =
if i < m && x.[i] = '0' then
loop1 (i + 1) j
else
if j < n && y.[j] = '0' then
loop1 i (j + 1)
else
if i = m && j = n then
0
else
loop2 i j
and loop2 i j =
if i = m then
if j = n then
0
else
(* x is finished, but y is not *)
-1
else
if j = n then
(* x is not finished, but y is *)
1
else
if m - i < n - j then -1
else if m - i > n - j then 1
else
if x.[i] < y.[j] then -1
else if x.[i] > y.[j] then 1
else
loop2 (i + 1) (j + 1)
in
loop1 0 0
;;
(* ***)
let rec compare_chunks x y =
if x = y then 0
else
let x1,x2 = longest_matching_prefix (~~~ is_digit) x
and y1,y2 = longest_matching_prefix (~~~ is_digit) y
in
let c = compare_special x1 y1 in
if c <> 0 then
c
else
let (x21,x22) = longest_matching_prefix is_digit x2
and (y21,y22) = longest_matching_prefix is_digit y2
in
let c = compare_numeric_decimal x21 y21 in
if c <> 0 then
c
else
compare_chunks x22 y22
;;
let compare_versions x1 x2 =
let (e1,u1,r1) = extract_chunks x1
and (e2,u2,r2) = extract_chunks x2
in
(compare_numeric_decimal e1 e2) ***
(fun () -> (compare_chunks u1 u2) ***
(fun () -> compare_chunks r1 r2))
;;
let detect_pre_dependency_cycle (ps: default_package list): bool =
let pd_ht = Hashtbl.create (List.length ps) in
let rec detect_cycle pd_ht u =
begin
try
let (d, m) = Hashtbl.find pd_ht u in
match m with
| `Grey -> (Printf.eprintf "WARNING: pre_dependency cycle at package %s!\n%!" u; true)
| `White -> (Hashtbl.replace pd_ht u (d, `Grey);
let r = List.fold_left (fun x alt ->
(List.fold_left (fun y vs ->
match vs with
| Unit_version (v, _) -> (detect_cycle pd_ht v) || y
| Glob_pattern _ -> raise (Failure "Debian does not support glob patterns")
) false alt) || x
) false d in
Hashtbl.replace pd_ht u (d, `Black);
r)
| `Black -> false
with Not_found -> false (* ignore virtual packages *)
end in
let cycle = ref false in
begin
List.iter (fun p ->
Hashtbl.add pd_ht p.pk_unit (p.pk_pre_depends, `White)
) ps;
Hashtbl.iter (fun u _ ->
if (detect_cycle pd_ht u) then cycle := true
) pd_ht;
!cycle
end;;
(**
Read a character from a .deb file (buffer if necessary)
@param channel Channel to read from
@param input_char Function that reads a character from the input channel
@return the character read
*)
let read_deb_char (input: unit -> string): char =
begin
if (!buffer = "") || (!buffer_pos >= String.length !buffer) then
begin
buffer := input ();
buffer_pos := 0;
end;
let result = !buffer.[!buffer_pos] in
incr buffer_pos;
result
end;;
let next_deb_char (input: unit -> string): char =
begin
if (!buffer = "") || (!buffer_pos >= String.length !buffer) then
begin
buffer := input ();
buffer_pos := 0;
end;
!buffer.[!buffer_pos]
end;;
(**
Parse a debian name and version specification
Example: kde (>= 3.5)
@param spec The specification
@return a deb_dependency containing the specification
*)
let parse_deb_name_version (s: string): (string, string, string) versioned =
begin
let spec = remove_spaces s in
try
sscanf (remove_spaces spec) "%[^(] (%[^)])" (fun t v ->
let target = (remove_spaces t) in
Unit_version (target, try
sscanf v "= %s" (fun vn -> Sel_EQ vn)
with Scan_failure _ ->
try
sscanf v "<< %s" (fun vn -> Sel_LT vn)
with Scan_failure _ ->
try
sscanf v "<= %s" (fun vn -> Sel_LEQ vn)
with Scan_failure _ ->
try
sscanf v ">= %s" (fun vn -> Sel_GEQ vn)
with Scan_failure _ ->
try
sscanf v ">> %s" (fun vn -> Sel_GT vn)
with Scan_failure _ ->
try
sscanf v "> %s" (fun vn -> Sel_GT vn)
with Scan_failure _ ->
try
sscanf v "< %s" (fun vn -> Sel_LT vn)
with Scan_failure _ -> Sel_ANY)
)
with End_of_file -> Unit_version (spec, Sel_ANY)
end;;
let parse_deb_list (fields: (string, string) Hashtbl.t) (name: string): (string, string, string) versioned list =
begin
try
let line = Hashtbl.find fields name in
List.map parse_deb_name_version (List.map remove_spaces (Pcre.split ~rex:comma_rex line))
with Not_found -> []
end;;
(**
Parse a .deb dependency line (Depends: ...)
@param line The dependency line
@return a deb_dep_expression containing the line
*)
let parse_deb_disjunction (fields: (string, string) Hashtbl.t) (name: string): (string, string, string) versioned list list =
begin
try
let line = Hashtbl.find fields name in
let disjunctions = Pcre.split ~rex:comma_rex line in
List.map (fun disj ->
List.map parse_deb_name_version (List.map remove_spaces (Pcre.split ~rex:bar_rex disj))
) disjunctions
with
Not_found -> []
end;;
let parse_deb_boolean (fields: (string, string) Hashtbl.t) (name: string): bool =
begin
try
(Hashtbl.find fields name) = "yes"
with Not_found -> false
end;;
let parse_deb_int64 (fields: (string, string) Hashtbl.t) (name: string): int64 =
begin
try
Int64.of_string (Hashtbl.find fields name)
with Not_found -> 0L
end;;
(**
Read a field from a .deb file
@param channel Channel to read from
@param input_char Function to read a character from that channel
*)
let read_deb_field (input: unit -> string): string * string =
let my_char = ref ' '
and my_line = ref ""
and is_multiline = ref true
and my_name = ref ""
and my_contents = ref "" in
begin
while !is_multiline
do
my_char := read_deb_char input;
while !my_char <> '\n'
do
my_line := !my_line ^ (String.make 1 !my_char);
my_char := read_deb_char input;
done;
let next = next_deb_char input in
is_multiline := (next = ' ' || next = '\t');
if (!is_multiline) then my_line := !my_line ^ "\n"
done;
if !my_line = "" then raise End_of_file;
let colon_index = String.index !my_line ':' in
my_name := String.lowercase (String.sub !my_line 0 colon_index);
my_contents := remove_leading_spaces (String.sub !my_line (colon_index + 1) ((String.length !my_line) - colon_index - 1));
(!my_name, !my_contents)
end;;
let read_deb_fields (input: unit -> string): (string, string) Hashtbl.t =
let fields = Hashtbl.create 10 in
begin
try
while true
do
let (n, v) = read_deb_field input in
Hashtbl.add fields n v
done;
fields
with End_of_file -> fields
end;;
let strict_package_re = Pcre.regexp "^[a-z0-9][a-z0-9.+-]+$"
let package_re = Pcre.regexp "^[A-Za-z0-9][A-Za-z0-9._+-]+$"
let strict_architecture_re = Pcre.regexp "^[a-z0-9]+-?[a-z0-9]+$"
let architecture_re = Pcre.regexp "^[A-Za-z0-9][A-Za-z0-9._+-]+$"
let napkin_of_fields (fields: (string, string) Hashtbl.t): default_package =
begin
(* Package (unit and version *)
let (pk_unit, pk_version) =
try
let u = Hashtbl.find fields "package" in
try
let v = Hashtbl.find fields "version" in
(u, v)
with Not_found -> raise (Failure (Printf.sprintf "Package %S ignored because it has no version." u))
with Not_found -> raise (Failure "Warning: package ignored because it has no name") in
(* Source *)
let pk_source =
try
let sp = Hashtbl.find fields "source" in
try
Scanf.sscanf sp "%[^ \t] (%[^)])" (fun n v -> (n, v))
with
| End_of_file -> (sp, pk_version)
| Scan_failure _ ->
try
Scanf.sscanf sp "%[^ \t] %[^)]" (fun n v -> (n, v))
with
| End_of_file -> (sp, pk_version)
with Not_found -> (pk_unit, pk_version) in
(* Architecture *)
let pk_architecture =
try
Hashtbl.find fields "architecture"
with Not_found -> (Printf.eprintf "Warning: package %s doesn't have an architecture, using 'any'\n%!" pk_unit; "any") in
(* Give warnings in case packages and/or architectures are strange *)
if not (Pcre.pmatch ~rex:strict_package_re pk_unit) then
begin
Printf.eprintf "Warning: Bad package name: %s\n%!" pk_unit;
if not (Pcre.pmatch ~rex:package_re pk_unit) then
failwith (Format.sprintf "Error: Really bad package name: %s\n%!" pk_unit)
end;
if not (Pcre.pmatch ~rex:strict_architecture_re pk_architecture) then
begin
Printf.eprintf "Warning: Bad architecture name: %s\n%!" pk_architecture;
if not (Pcre.pmatch ~rex:architecture_re pk_architecture) then
failwith (Format.sprintf "Error: Really bad architecture name: %s\n%!" pk_architecture)
end;
{ pk_extra = ();
pk_unit = pk_unit;
pk_version = pk_version;
pk_architecture = pk_architecture;
pk_source = pk_source;
pk_essential = parse_deb_boolean fields "essential";
pk_build_essential = parse_deb_boolean fields "build-essential";
pk_size = parse_deb_int64 fields "size";
pk_installed_size = parse_deb_int64 fields "installed-size";
pk_provides = parse_deb_list fields "provides";
pk_conflicts = parse_deb_list fields "conflicts";
pk_breaks = parse_deb_list fields "breaks";
pk_replaces = parse_deb_list fields "replaces";
pk_depends = parse_deb_disjunction fields "depends";
pk_pre_depends = parse_deb_disjunction fields "pre-depends";
pk_suggests = parse_deb_disjunction fields "suggests";
pk_recommends = parse_deb_disjunction fields "recommends";
pk_enhances = parse_deb_disjunction fields "enhances"
}
end;;
(** Read MD5 sums from a .deb file
@param channel Channel to input from
@param input_char Function to read a character from that channel
@param size The size of the MD5 file in the .deb file
@return a list of tuples (name and MD5 sum)
*)
let read_deb_md5sums (channel: 'a) (input_char: 'a -> char) (size: big_int): (string * string) list =
let files = ref []
and my_char = ref (input_char channel)
and my_line = ref ""
and chars_read = ref unit_big_int in
begin
try
while (le_big_int !chars_read size)
do
while (!my_char <> '\n')
do
my_line := !my_line ^ (String.make 1 !my_char);
my_char := input_char channel;
chars_read := succ_big_int !chars_read;
done;
sscanf !my_line "%s %s" (fun s f ->
files := (f, s)::!files);
my_line := "";
my_char := input_char channel;
chars_read := succ_big_int !chars_read
done;
(* read up to 512 extra characters *)
let rest = 512 - (int_of_big_int (mod_big_int size (big_int_of_int 512))) in
if rest <> 0 then for i = 2 to rest do ignore (input_char channel) done;
!files
with
End_of_file -> !files
end;;
let bz2_input c () =
let r = Bz2.read c sub_buffer 0 bufsize in
if r = 0 then raise End_of_file else (String.sub sub_buffer 0 r);;
let gzip_input c () =
let r = Gzip.input c sub_buffer 0 bufsize in
if r = 0 then raise End_of_file else (String.sub sub_buffer 0 r);;
let normal_input c () =
let r = Pervasives.input c sub_buffer 0 bufsize in
if r = 0 then raise End_of_file else (String.sub sub_buffer 0 r);;
(**
Read a .deb file
@param filename File name
@return package metadata
*)
let read_deb_file (filename: string): package_with_files =
let ar_channel = Pirate.open_ar_file filename in
begin
ignore (Pirate.ar_seek_to_file ar_channel "control.tar.gz");
let gz_channel = Gzip.open_in_chan ar_channel in
let sums_size = Pirate.tar_seek_to_file gz_channel Gzip.input Gzip.input_char "./md5sums" in
let sums = read_deb_md5sums gz_channel Gzip.input_char sums_size in
ignore (Pirate.tar_seek_to_file gz_channel Gzip.input Gzip.input_char "./control");
{ (napkin_of_fields (read_deb_fields (gzip_input gz_channel))) with pk_extra = sums }
end;;
(**
Read a pool (cache) file
@param filename File name
@return a list package metadata
*)
let read_pool_file (filename: string) (progress: Progress.indicator): default_package list =
let ch = ref (open_in filename) in
let close_channel = ref (fun () -> ()) in
let input_buf = ref (fun () -> "") in
let packages = ref [] in
(*let icl = ref (in_channel_length !ch) in*)
begin
let first_package = try
let c = Bz2.open_in !ch in
input_buf := (bz2_input c);
close_channel := (fun () -> Bz2.close_in c);
napkin_of_fields (read_deb_fields !input_buf)
with Bz2.Data_error | Bz2.Unexpected_EOF ->
try
close_in !ch;
ch := open_in filename;
(*icl := in_channel_length !ch;*)
let c = Gzip.open_in_chan !ch in
input_buf := (gzip_input c);
close_channel := (fun () -> Gzip.close_in c);
napkin_of_fields (read_deb_fields !input_buf)
with Gzip.Error _ ->
close_in !ch;
ch := open_in filename;
(*icl := in_channel_length !ch;*)
input_buf := (normal_input !ch);
close_channel := (fun () -> ());
napkin_of_fields (read_deb_fields !input_buf) in
packages := [first_package];
try
while true
do
(*progress#display (pos_in !ch, !icl);*)
let fields = read_deb_fields !input_buf in
if Hashtbl.length fields = 0 then raise End_of_file;
packages := (napkin_of_fields fields)::!packages
done;
!packages
with End_of_file ->
begin
!close_channel ();
close_in !ch;
!packages
end
end;;
dose2-1.4.2/ocamldeb/ocamldeb.mli 0000664 0000000 0000000 00000001720 11231374124 0016547 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
val compare_versions: string -> string -> int
val detect_pre_dependency_cycle: Napkin.default_package list -> bool
val read_deb_file: string -> Napkin.package_with_files
val read_pool_file: string -> Progress.indicator -> Napkin.default_package list
dose2-1.4.2/ocamldeb/ocamldebwriter.ml 0000664 0000000 0000000 00000010446 11231374124 0017640 0 ustar 00root root 0000000 0000000 (****************************************************************************
Copyright 2009 Ralf Treinen
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
Dose2 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, see .
***************************************************************************)
open Napkin
let output_string_field out field value =
output_string out field;
output_string out ": ";
output_string out value;
output_char out '\n'
;;
let output_int64_field out field value =
output_string out field;
output_string out ": ";
output_string out (Int64.to_string value);
output_char out '\n'
;;
let output_bool_field out field value =
if value then begin
output_string out field;
output_string out ": ";
output_string out (if value then "yes" else "no");
output_char out '\n'
end
;;
let output_versionend out = function
| Glob_pattern _glob -> failwith "this cannot happen"
| Unit_version(unit,versionend) ->
output_string out unit;
match versionend with
Sel_ANY -> ()
| Sel_LEQ version ->
output_string out " (<= ";
output_string out version;
output_string out ")"
| Sel_GEQ version ->
output_string out " (>= ";
output_string out version;
output_string out ")"
| Sel_EQ version ->
output_string out " (= ";
output_string out version;
output_string out ")"
| Sel_LT version ->
output_string out " (<< ";
output_string out version;
output_string out ")"
| Sel_GT version ->
output_string out " (>> ";
output_string out version;
output_string out ")"
;;
let output_clause out clause =
(* a clause cannot be empty *)
assert (clause <> []);
output_versionend out (List.hd clause);
List.iter
(function versionend ->
output_string out "|";
output_versionend out versionend
)
(List.tl clause)
;;
let output_list_field out field vlist =
if vlist <> [] then begin
output_string out field;
output_string out ": ";
if vlist <> [] then begin
output_versionend out (List.hd vlist);
List.iter
(function versionend ->
output_string out ", ";
output_versionend out versionend
)
(List.tl vlist)
end;
output_char out '\n'
end
;;
let output_cnf_field out field cnf =
if cnf <> [] then begin
output_string out field;
output_string out ": ";
if cnf <> [] then begin
output_clause out (List.hd cnf);
List.iter
(function clause ->
output_string out ", ";
output_clause out clause
)
(List.tl cnf)
end;
output_char out '\n'
end
;;
let output_package out package =
output_string_field out "Package" package.pk_unit;
output_string_field out "Version" package.pk_version;
output_string_field out "Architecture" package.pk_architecture;
output_int64_field out "Size" package.pk_size;
output_int64_field out "Installed-Size" package.pk_installed_size;
output_bool_field out "Essential" package.pk_essential;
output_string_field out "Source" (fst package.pk_source);
output_list_field out "Provides" package.pk_provides;
output_list_field out "Conflicts" package.pk_conflicts;
output_list_field out "Breaks" package.pk_breaks;
output_list_field out "Replaces" package.pk_replaces;
output_cnf_field out "Depends" package.pk_depends;
output_cnf_field out "Pre-Depends" package.pk_pre_depends;
output_cnf_field out "Suggests" package.pk_suggests;
output_cnf_field out "Recommends" package.pk_recommends;
output_cnf_field out "Enhances" package.pk_enhances;
;;
let output_package_list out packages =
List.iter
(function package ->
output_package out package;
output_char out '\n'
)
packages
;;
dose2-1.4.2/ocamldeb/ocamldebwriter.mli 0000664 0000000 0000000 00000003704 11231374124 0020010 0 ustar 00root root 0000000 0000000 (****************************************************************************
Copyright 2009 Ralf Treinen
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
Dose2 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, see .
***************************************************************************)
(* Writing out in debian/control format napkin package descriptions *)
(* from debian data. Conforms to debian policy version 3.8.0.1 *)
(* See below for an exact listing of printed field. *)
(* write one package *)
val output_package: out_channel -> Napkin.default_package -> unit
(* write a list of packages, each of them terminated by \nl *)
val output_package_list: out_channel -> Napkin.default_package list -> unit
(* The following fields are written: *)
(* - Package *)
(* - Version *)
(* - Architecture *)
(* - Size *)
(* - Installed_Size *)
(* - Essential [only if true] *)
(* - Source *)
(* - Provides [only if nonempty] *)
(* - Conflicts [only if nonempty] *)
(* - Breaks [only if nonempty] *)
(* - Replaces [only if nonempty] *)
(* - Depends [only if nonempty] *)
(* - Pre-Depends [only if nonempty] *)
(* - Suggests [only if nonempty] *)
(* - Recommends [only if nonempty] *)
(* - Enhances [only if nonempty] *)
dose2-1.4.2/ocamldeb/pirate.ml 0000664 0000000 0000000 00000014656 11231374124 0016130 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Dose2 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 Dose2; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
open Big_int
open Util
type ar_header =
{
file_name: string;
file_time: big_int;
file_uid: int;
file_gid: int;
file_mode: int;
file_size: big_int
}
type tar_header =
{
ar_header: ar_header
}
(**
Arrrr! Deal with ar(1) files
@author Jaap Boender
*)
(**
Read the global header
@param ar_channel Channel to read from
@raise Failure if the header is not present
*)
let read_ar_global_header (ar_channel: in_channel): unit =
let magic = String.create 8 in
begin
ignore (input ar_channel (magic) 0 8);
if magic <> "!\n" then
raise (Failure "This is not an ar(1) archive")
end;;
(**
Read the header
@param ar_channel Channel to read from
@return a list of file name, date, uid, gid, mode, size
@raise End_of_file if end of archive is reached
*)
let read_ar_header (ar_channel: in_channel): ar_header =
let name = String.create 16
and date = String.create 12
and uid = String.create 6
and gid = String.create 6
and mode = String.create 8
and size = String.create 10
and magic = String.create 2 in
begin
if input ar_channel name 0 16 = 0 then
raise End_of_file;
ignore (input ar_channel date 0 12);
ignore (input ar_channel uid 0 6);
ignore (input ar_channel gid 0 6);
ignore (input ar_channel mode 0 8);
ignore (input ar_channel size 0 10);
ignore (input ar_channel magic 0 2);
if magic <> "`\n" then
raise (Failure "Error in magic number in ar(1) header");
{ file_name = name;
file_time = big_int_of_string date;
file_uid = int_of_string (remove_leading_spaces uid);
file_gid = int_of_string (remove_leading_spaces gid);
file_mode = int_of_string (remove_leading_spaces mode);
file_size = big_int_of_string size }
end;;
(**
Seek to a particular file
@param ar_channel The channel to read from
@param header Information from the header
@return size of file according to header
@raise Failure if file is not found in archive
*)
let ar_seek_to_file (ar_channel: in_channel) (filename: string): big_int =
let my_name = ref ""
and my_size = ref zero_big_int in
begin
while !my_name <> filename
do
let header =
try
read_ar_header ar_channel
with End_of_file -> raise (Failure "File was not found in archive") in
my_name := remove_leading_spaces header.file_name;
my_size := header.file_size;
if !my_name <> filename then
let isize = int_of_big_int header.file_size in
seek_in ar_channel ((pos_in ar_channel) + if isize mod 2 = 0 then isize else isize + 1)
done;
!my_size
end;;
(**
Open an AR file for reading and seek to the first file
@param filename File name
@return a channel
*)
let open_ar_file (filename: string): in_channel =
let ar_channel = open_in_bin filename in
begin
read_ar_global_header ar_channel;
ar_channel
end;;
(**
Read a tar header from a (binary) channel
@param channel Channel to read from
@param input_function Function that inputs from the channel
@return the tar header
*)
let read_tar_header (channel: 'a) (input_function: 'a -> string -> int -> int -> int): tar_header =
let file_name = String.create 100
and file_mode = String.create 8
and file_uid = String.create 8
and file_gid = String.create 8
and file_size = String.create 12
and file_time = String.create 12
and checksum = String.create 8
and link_indicator = String.create 1
and link_name = String.create 100
and ustar = String.create 6
and ustar_version = String.create 2
and user_name = String.create 32
and group_name = String.create 32
and dev_major = String.create 8
and dev_minor = String.create 8
and file_prefix = String.create 155
and padding = String.create 12 in
begin
ignore (input_function channel file_name 0 100);
ignore (input_function channel file_mode 0 8);
ignore (input_function channel file_uid 0 8);
ignore (input_function channel file_gid 0 8);
ignore (input_function channel file_size 0 12);
ignore (input_function channel file_time 0 12);
ignore (input_function channel checksum 0 8);
ignore (input_function channel link_indicator 0 1);
ignore (input_function channel link_name 0 100);
ignore (input_function channel ustar 0 6);
ignore (input_function channel ustar_version 0 2);
ignore (input_function channel user_name 0 32);
ignore (input_function channel group_name 0 32);
ignore (input_function channel dev_major 0 8);
ignore (input_function channel dev_minor 0 8);
ignore (input_function channel file_prefix 0 155);
ignore (input_function channel padding 0 12);
{ ar_header =
{ file_name = file_name;
file_time = big_int_of_string (remove_leading_spaces file_time);
file_uid = int_of_string (remove_leading_spaces file_uid);
file_gid = int_of_string (remove_leading_spaces file_gid);
file_mode = int_of_string (remove_leading_spaces file_mode);
(* XXX only works for ints! *)
file_size = big_int_of_int (int_of_string ("0o" ^ (remove_leading_spaces file_size)))
}
}
end;;
(**
Seek to a particular file in a TAR archive
@param channel Channel to read from
@param input_function Function that inputs from the channel
@param input_char_function Function that reads one character from the channel
@param filename File to seek to
@return the size of the file
*)
let tar_seek_to_file (channel: 'a) (input_function: 'a -> string -> int -> int -> int) (input_char_function: 'a -> char) (filename: string): big_int =
let my_name = ref ""
and my_size = ref zero_big_int in
begin
while !my_name <> filename
do
let header =
try
read_tar_header channel input_function
with End_of_file -> raise (Failure "File was not found in archive") in
my_name := remove_leading_spaces header.ar_header.file_name;
my_size := header.ar_header.file_size;
if !my_name <> filename then
let isize = int_of_big_int header.ar_header.file_size in
let iblocks = if isize = 0 then 0 else isize / 512 + 1 in
for i = 1 to 512 * iblocks do ignore (input_char_function channel) done
done;
!my_size
end;;
dose2-1.4.2/ocamldeb/pirate.mli 0000664 0000000 0000000 00000001673 11231374124 0016274 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Dose2 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 Dose2; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
open Big_int
val ar_seek_to_file: in_channel -> string -> big_int
val open_ar_file: string -> in_channel
val tar_seek_to_file: 'a -> ('a -> string -> int -> int -> int) -> ('a -> char) -> string -> big_int
dose2-1.4.2/ocamldeb/test/ 0000775 0000000 0000000 00000000000 11231374124 0015255 5 ustar 00root root 0000000 0000000 dose2-1.4.2/ocamldeb/test/Makefile 0000664 0000000 0000000 00000001161 11231374124 0016714 0 ustar 00root root 0000000 0000000 FLAVOUR=byte
MAIN=reader-writer
PKG=dose2.progress,dose2.ocamldeb
$(MAIN): $(MAIN).$(FLAVOUR)
ln -sf $(MAIN).$(FLAVOUR) $(MAIN)
$(MAIN).cmo: $(MAIN).ml
ocamlfind ocamlc -package dose2 -I .. -c $(MAIN).ml
$(MAIN).cmx: $(MAIN).ml
ocamlfind ocamlopt -package dose2 -c $(MAIN).ml
$(MAIN).byte: $(MAIN).cmo ../ocamldebwriter.cmo
ocamlfind ocamlc -package $(PKG) \
-linkpkg ../ocamldebwriter.cmo $(MAIN).cmo \
-o $(MAIN).byte
$(MAIN).native: $(MAIN).cmx
ocamlfind ocamlopt -package $(PKG) -linkpkg $(MAIN).cmx \
-o $(MAIN).native
clean:
-rm -f *.{cmo,cmi,cmx,o} $(MAIN).{byte,native} $(MAIN)
.phony: clean test
dose2-1.4.2/ocamldeb/test/reader-writer.ml 0000664 0000000 0000000 00000001020 11231374124 0020354 0 ustar 00root root 0000000 0000000 (* test for reading an writing debian package files *)
open Napkin;;
open Ocamldeb;;
open Arg;;
let inputfile = ref "";;
let options =
[ ( "-i",
Set_string(inputfile),
"path of the input Packages file"
)
]
in
parse
options
(function _ -> raise (Bad "Argument not allowed"))
"uplose -i ";;
if (!inputfile = "") then
raise (Bad "Missing input file");;
let
packages = read_pool_file !inputfile Progress.dummy
in
Ocamldebwriter.output_package_list stdout (List.rev packages);;
dose2-1.4.2/ocamlpkgsrc/ 0000775 0000000 0000000 00000000000 11231374124 0015035 5 ustar 00root root 0000000 0000000 dose2-1.4.2/ocamlpkgsrc/.depend 0000664 0000000 0000000 00000000171 11231374124 0016274 0 ustar 00root root 0000000 0000000 ocamlpkgsrc.cmo: ocamlpkgsrc.cmi
ocamlpkgsrc.cmx: ocamlpkgsrc.cmi
ocamlpkgsrc_stubs.o: ocamlpkgsrc_stubs.c ../config.h
dose2-1.4.2/ocamlpkgsrc/Makefile 0000664 0000000 0000000 00000000457 11231374124 0016503 0 ustar 00root root 0000000 0000000 # Makefile
NAME= ocamlpkgsrc
SOURCES= ocamlpkgsrc.ml
MLIS= ocamlpkgsrc.mli
C_SOURCES= ocamlpkgsrc_stubs.c
STUB_INSTALL= dllocamlpkgsrc.so
EXTRA_INSTALL= libocamlpkgsrc.a
REQUIRES= util napkin
PACKAGES= pcre
include ../Makefile.config
include .depend
CFLAGS+= -I.. -fPIC
dose2-1.4.2/ocamlpkgsrc/ocamlpkgsrc.ml 0000664 0000000 0000000 00000021506 11231374124 0017700 0 ustar 00root root 0000000 0000000 (* Copyright 2008 Jaap BOENDER and the MANCOOSI Project.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
let comma_rex = Pcre.regexp ",";;
let starts_with (haystack: string) (needle: string): bool =
if String.length needle > String.length haystack then false
else let len = String.length needle in
String.sub haystack 0 len = needle;;
let ends_with (haystack: string) (needle: string): bool =
if String.length needle > String.length haystack then false
else let len = String.length needle in
String.sub haystack (String.length haystack - len) len = needle;;
let rec split_version (v: string) (nb: int): int32 list * int =
let alphas = "abcdefghijklmnopqrstuvwxyz" in
let isdigit c = String.contains "0123456789" c in
let isalpha c = String.contains alphas c in
begin
let vl = String.lowercase v in
if vl = "" then
([], nb)
else
begin
(* digits *)
if isdigit vl.[0] then
Scanf.sscanf vl "%lu%s@\n" (fun i r ->
let (res, new_nb) = split_version r nb in (i::res, new_nb))
(* modifiers *)
else if starts_with vl "alpha" then
let (res, new_nb) = split_version (String.sub vl 5 (String.length vl - 5)) nb in
(-3l::res, new_nb)
else if starts_with vl "beta" then
let (res, new_nb) = split_version (String.sub vl 4 (String.length vl - 4)) nb in
(-2l::res, new_nb)
else if starts_with vl "pre" then
let (res, new_nb) = split_version (String.sub vl 3 (String.length vl - 3)) nb in
(-1l::res, new_nb)
else if starts_with vl "rc" then
let (res, new_nb) = split_version (String.sub vl 2 (String.length vl - 2)) nb in
(-1l::res, new_nb)
else if starts_with vl "pl" then
let (res, new_nb) = split_version (String.sub vl 2 (String.length vl - 2)) nb in
(0l::res, new_nb)
else if starts_with vl "_" then
let (res, new_nb) = split_version (String.sub vl 1 (String.length vl - 1)) nb in
(0l::res, new_nb)
else if starts_with vl "." then
let (res, new_nb) = split_version (String.sub vl 1 (String.length vl - 1)) nb in
(0l::res, new_nb)
(* "nb" *)
else if starts_with vl "nb" then
Scanf.sscanf vl "nb%d%s@\n" (fun new_nb r ->
let (res, newer_nb) = split_version r new_nb in
(res, newer_nb))
(* letter *)
else if isalpha v.[0] then
let (res, new_nb) = split_version (String.sub vl 1 (String.length vl -1)) nb in
(0l::(Int32.of_int (String.index alphas v.[0]))::res, new_nb)
else
raise (Failure (Printf.sprintf "Unparseable version string %s" v))
end
end;;
let rec compare_lists (l1: int32 list) (l2: int32 list): int =
begin
match l1, l2 with
| [], [] -> 0
| [], _ -> -1
| _, [] -> 1
| h1::t1, h2::t2 -> let res = compare h1 h2 in
if res = 0 then compare_lists t1 t2 else res
end;;
let compare_versions (v1: string) (v2: string): int =
begin
let (l1, nb1) = split_version v1 0
and (l2, nb2) = split_version v2 0 in
let res = compare_lists l1 l2 in
if res = 0 then compare nb1 nb2 else res
end;;
let read_summary_fields (channel: in_channel): (string, string) Hashtbl.t =
let fields = Hashtbl.create 10 in
let my_line = ref "" in
begin
my_line := input_line channel;
while !my_line <> ""
do
let equals = String.index !my_line '=' in
let name = String.sub !my_line 0 equals
and contents = String.sub !my_line (equals + 1) (String.length !my_line - equals - 1) in
begin
Hashtbl.add fields name contents;
my_line := input_line channel
end
done;
fields
end;;
let contains_one_of (s: string) (c: char list): bool =
let result = ref false in
begin
for i = 0 to (String.length s - 1)
do
if List.mem s.[i] c then result := true
done;
!result
end;;
let rec uniq (x: 'a list): 'a list =
begin
match x with
[] -> []
| y::ys ->
begin
match ys with
[] -> [y]
| z::zs -> if y = z then uniq ys else y::(uniq ys)
end
end;;
let rec get_dependency_list (pat: string): (string, string, string) versioned list list =
(* This does a textual substitution of the alternative and then runs a pkg_match. *)
let rec alternative_match (pat: string): string list =
begin
let sa = String.rindex pat '{' in
let ea = String.index_from pat sa '}' in
let to_sub = String.sub pat (sa+1) (ea-sa-1) in
let pre = String.sub pat 0 sa in
let post = String.sub pat (ea+1) (String.length pat - ea - 1) in
let alternatives = Pcre.split ~rex:comma_rex to_sub in
List.flatten (List.map (fun a ->
let new_pat = Printf.sprintf "%s%s%s" pre a post in
if String.contains new_pat '{' then
alternative_match new_pat
else
[new_pat]
) alternatives)
end in
let dewey_match (pat: string) =
begin
try
begin
let gtc = String.index pat '>' in
let unit_name = String.sub pat 0 gtc in
let v_str = if pat.[gtc+1] = '=' then String.sub pat (gtc+2) (String.length pat-gtc-2) else String.sub pat (gtc+1) (String.length pat-gtc-1) in
try
let ltc = String.index v_str '<' in
let g_spec = String.sub v_str 0 ltc in
[if v_str.[ltc+1] = '='
then Unit_version (unit_name, Sel_LEQ (String.sub v_str (ltc+2) (String.length v_str-ltc-2)))
else Unit_version (unit_name, Sel_LT (String.sub v_str (ltc+1) (String.length v_str-ltc-1)));
if pat.[gtc+1] = '='
then Unit_version (unit_name, Sel_GEQ g_spec)
else Unit_version (unit_name, Sel_GT g_spec)]
with Not_found -> if pat.[gtc+1] = '='
then [Unit_version (unit_name, Sel_GEQ v_str)]
else [Unit_version (unit_name, Sel_GT v_str)]
end
with Not_found ->
let ltc = String.index pat '<' in
let unit_name = String.sub pat 0 ltc in
if pat.[ltc+1] = '='
then [Unit_version (unit_name, Sel_LEQ (String.sub pat (ltc+2) (String.length pat-ltc-2)))]
else [Unit_version (unit_name, Sel_LT (String.sub pat (ltc+1) (String.length pat-ltc-1)))]
end in
let glob_match pat =
begin
[[Glob_pattern pat]]
end in
begin
if pat = "" then
[]
else if String.contains pat '{' then
List.flatten (List.map get_dependency_list (alternative_match pat))
else if contains_one_of pat ['<'; '>'] then
List.map (fun a -> [a]) (dewey_match pat)
else if contains_one_of pat ['*'; '?'; '['; ']'] then
glob_match pat
else
begin
let dash = String.rindex pat '-' in
[[Unit_version (String.sub pat 0 dash, Sel_EQ (String.sub pat (dash+1) (String.length pat-dash-1)))]]
end
end;;
let get_dewey_int64 (fields: (string, string) Hashtbl.t) (name: string): int64 =
begin
try
Int64.of_string (Hashtbl.find fields name)
with Not_found -> 0L
end
let napkin_of_fields (fields: (string, string) Hashtbl.t): default_package =
begin
let (pk_unit, pk_version) =
try
let pkgname = Hashtbl.find fields "PKGNAME" in
let dash = String.rindex pkgname '-' in
(String.sub pkgname 0 dash,
String.sub pkgname (dash + 1) (String.length pkgname - dash - 1))
with Not_found -> raise (Failure "Warning: package ignored because it has no name") in
let pk_source = (pk_unit, pk_version) in
let pk_architecture =
try
Hashtbl.find fields "MACHINE_ARCH"
with Not_found -> (Printf.eprintf "Warning: package %s doesn't have an architecture, using 'any'\n%!" pk_unit; "any") in
{ pk_extra = ();
pk_unit = pk_unit;
pk_version = pk_version;
pk_source = pk_source;
pk_architecture = pk_architecture;
pk_essential = false;
pk_build_essential = false;
pk_size = get_dewey_int64 fields "FILE_SIZE";
pk_installed_size = get_dewey_int64 fields "SIZE_PKG";
pk_provides = [];
pk_conflicts = List.flatten (List.flatten (List.map get_dependency_list (Hashtbl.find_all fields "CONFLICTS")));
pk_breaks = List.flatten (List.flatten (List.map get_dependency_list (Hashtbl.find_all fields "BREAKS")));
pk_replaces = [];
pk_depends = List.flatten (List.map get_dependency_list (Hashtbl.find_all fields "DEPENDS"));
pk_pre_depends = [];
pk_suggests = [];
pk_recommends = [];
pk_enhances = []
}
end;;
(**
Read a pool (cache) file
@param filename File name
@return a list package metadata
*)
let read_summary_file (filename: string): default_package list =
let channel = open_in filename in
let packages = ref [] in
begin
try
while true
do
let fields = read_summary_fields channel in
if Hashtbl.length fields = 0 then
begin
raise End_of_file
end;
packages := (napkin_of_fields fields)::!packages
done;
!packages
with End_of_file -> !packages
end;;
type fnmatch_options =
FNM_NOESCAPE
| FNM_PATHNAME
| FNM_PERIOD
external fnmatch: string -> string -> fnmatch_options list -> bool =
"ocamlpkgsrc_fnmatch";;
dose2-1.4.2/ocamlpkgsrc/ocamlpkgsrc.mli 0000664 0000000 0000000 00000001727 11231374124 0020054 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER and the
EDOS Project.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
val compare_versions: string -> string -> int
val read_summary_file: string -> Napkin.default_package list
type fnmatch_options =
FNM_NOESCAPE
| FNM_PATHNAME
| FNM_PERIOD
val fnmatch: string -> string -> fnmatch_options list -> bool
dose2-1.4.2/ocamlpkgsrc/ocamlpkgsrc_stubs.c 0000664 0000000 0000000 00000001702 11231374124 0020726 0 ustar 00root root 0000000 0000000 #include
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_FNMATCH_H
#include
#endif
#ifdef HAVE_CAML_MLVALUES_H
#include
#endif
#ifdef HAVE_CAML_MEMORY_H
#include
#endif
#ifdef HAVE_CAML_ALLOC_H
#include
#endif
#ifdef HAVE_CAML_CUSTOM_H
#include
#endif
value ocamlpkgsrc_fnmatch (value pattern, value string, value options)
{
CAMLparam3 (pattern, string, options);
CAMLlocal1 (optptr);
int flags = 0;
optptr = options;
while (Is_block (optptr))
{
switch (Int_val (Field (optptr, 0)))
{
case 0: flags |= FNM_NOESCAPE; break;
case 1: flags |= FNM_PATHNAME; break;
case 2: flags |= FNM_PERIOD; break;
default: fprintf (stderr, "Unknown %d\n", Int_val (Field (optptr, 0)));
}
optptr = Field (optptr, 1);
}
if (fnmatch (String_val (pattern), String_val (string), flags) == 0)
CAMLreturn (Val_true);
else
CAMLreturn (Val_false);
}
dose2-1.4.2/ocamlrpm/ 0000775 0000000 0000000 00000000000 11231374124 0014342 5 ustar 00root root 0000000 0000000 dose2-1.4.2/ocamlrpm/.depend 0000664 0000000 0000000 00000000147 11231374124 0015604 0 ustar 00root root 0000000 0000000 ocamlrpm.cmo: ocamlrpm.cmi
ocamlrpm.cmx: ocamlrpm.cmi
ocamlrpm_stubs.o: ocamlrpm_stubs.c ../config.h
dose2-1.4.2/ocamlrpm/Makefile 0000664 0000000 0000000 00000000452 11231374124 0016003 0 ustar 00root root 0000000 0000000 # Makefile
NAME= ocamlrpm
SOURCES= ocamlrpm.ml
MLIS= ocamlrpm.mli
C_SOURCES= ocamlrpm_stubs.c
STUB_INSTALL= dllocamlrpm.so
EXTRA_INSTALL= libocamlrpm.a
REQUIRES= napkin progress
PACKAGES= pcre
include ../Makefile.config
include .depend
CFLAGS+= -I.. -fPIC
dose2-1.4.2/ocamlrpm/ocamlrpm.ml 0000664 0000000 0000000 00000023573 11231374124 0016520 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Dose2 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 Dose2; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
open Napkin
let compare_versions (v1: string) (v2: string): int =
let split_version (v: string): string * string * string =
let split_epoch (v: string): string * string =
begin
try
let colon_index = String.index v ':' in
(String.sub v 0 colon_index, String.sub v (colon_index+1) ((String.length v)-colon_index-1))
with
Not_found -> ("0", v)
end
and split_release (v: string): string * string =
begin
try
let hyphen_index = String.rindex v '-' in
(String.sub v 0 hyphen_index, String.sub v (hyphen_index+1) ((String.length v)-hyphen_index-1))
with
Not_found -> (v, "")
end in
begin
let (epoch, rest) = split_epoch v in
let (upstream, release) = split_release rest in
(epoch, upstream, release)
end in
let rec get_chunk (s: string): string * string =
let chunk = ref ""
and rest = ref "" in
begin
Scanf.sscanf s "%_[^0-9a-zA-Z]%[0-9]%s%!" (fun x y -> chunk := x; rest := y);
if !chunk = "" then (* no numeric chunk *)
Scanf.sscanf s "%_[^0-9a-zA-Z]%[a-zA-Z]%s%!" (fun x y -> chunk := x; rest := y);
(!chunk, !rest)
end in
let compare_ztrange (s1: string) (s2: string): int =
begin
if String.contains "0123456789" s1.[0] then (* s1 is numeric *)
1 (* s2 cannot be numeric *)
else (* s1 is NOT numeric *)
begin
if String.contains "0123456789" s2.[0] then (* s2 is numeric *)
-1
else
compare s1 s2
end
end in
let rec compare_chunky (s1: string) (s2: string): int =
let (c1, r1) = get_chunk s1
and (c2, r2) = get_chunk s2 in
begin
if c1 = "" && r1 = "" && c2 = "" && r2 = "" then 0
else if c1 = "" && c2 <> "" then -1
else if c1 <> "" && c2 = "" then 1
else if c1 = c2 then compare_chunky r1 r2
else
let res = try
compare (int_of_string c1) (int_of_string c2)
with Failure _ -> compare_ztrange c1 c2 in
if res = 0 then compare_chunky r1 r2
else res
end in
let (e1, u1, r1) = split_version v1
and (e2, u2, r2) = split_version v2 in
begin
let epochs = compare (int_of_string e1) (int_of_string e2) in
if epochs = 0 then
begin
let upstreams = compare_chunky u1 u2 in
if upstreams = 0 then
begin
if r1 = "" then 0
else if r2 = "" then 0
else compare_chunky r1 r2
end
else upstreams
end
else
epochs
end;;
let add_file_provides (progress: Progress.indicator) (pkgs: package_with_files list): package_with_files list =
let is_file_dependency p = p.[0] = '/' in
let i = ref 0
and n = 2 * (List.length pkgs) in
begin
progress#set_label "Adding file provides...";
let filedep_ht = Hashtbl.create (List.length pkgs) in
(* Scour packages for file dependencies *)
List.iter (fun pkg ->
progress#display (!i, n);
List.iter (fun disj ->
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) disj
) pkg.pk_depends;
List.iter (fun disj ->
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) disj
) pkg.pk_pre_depends;
List.iter (fun disj ->
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) disj
) pkg.pk_recommends;
List.iter (fun disj ->
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) disj
) pkg.pk_suggests;
List.iter (fun disj ->
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) disj
) pkg.pk_enhances;
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) pkg.pk_replaces;
List.iter (fun dep ->
match dep with
| Unit_version (target, _) -> if is_file_dependency target then
Hashtbl.add filedep_ht target (pkg.pk_unit, pkg.pk_version)
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
) pkg.pk_conflicts;
incr i;
) pkgs;
(* Now add explicit file provides, but only for files that are needed *)
List.map (fun pkg ->
progress#display (!i, n);
let extra_provides = List.flatten (List.map (fun (fn, _) ->
let providers = Hashtbl.find_all filedep_ht fn in
match providers with
| [] -> []
| _ -> [Unit_version (fn, Sel_ANY)]
) pkg.pk_extra) in
(incr i; { pkg with pk_provides = pkg.pk_provides @ extra_provides })
) pkgs
end;;
let add_file_conflicts (progress: Progress.indicator) (pkgs: package_with_files list): package_with_files list
=
let f_ht = Hashtbl.create (List.length pkgs * 12) in
let i = ref 0
and n = List.length pkgs in
begin
progress#set_label "Adding file conflicts...";
List.map (fun pkg ->
progress#display (!i, n);
let cfl = ref [] in
List.iter (fun (fn, _) ->
if fn.[String.length fn - 1] <> '/' then
begin
match Hashtbl.find_all f_ht fn with
| [] -> Hashtbl.add f_ht fn pkg
| l ->
begin
cfl := List.map (fun pkg' ->
(* Printf.eprintf "[RPM] Adding file conflict for %s between %s and %s\n%!" fn pkg.pk_unit pkg'.pk_unit; *)
Unit_version (pkg'.pk_unit, Sel_EQ pkg'.pk_version)
) l;
Hashtbl.add f_ht fn pkg
end
end
) pkg.pk_extra;
(incr i; { pkg with pk_conflicts = !cfl @ pkg.pk_conflicts })
) pkgs;
end;;
external read_package: string -> string -> package_with_files =
"ocamlrpm_read_package"
external read_hdlist: string -> string -> package_with_files list =
"ocamlrpm_read_hdlist"
let read_synthesis_hdlist (file: string): package_with_files list =
let fc = open_in file in
let res = ref [] in
let at_regex = Pcre.regexp "@" in
let get_package () =
let fields = Hashtbl.create 10 in
let treat_dependency s =
begin
try
let ln = Pcre.split ~rex:at_regex (Hashtbl.find fields s) in
List.map (fun d ->
try
Scanf.sscanf d "%[^[][%[^]]]" (fun n sel ->
Unit_version (n,
if sel = "*" then Sel_ANY
else Scanf.sscanf sel "%s %s" (fun op req ->
if op = "==" then Sel_EQ req
else if op = "<" then Sel_LT req
else if op = ">" then Sel_GT req
else if op = "<=" then Sel_LEQ req
else if op = ">=" then Sel_GEQ req
else failwith (Printf.sprintf "Unknown version operator %s" op))
)
)
with End_of_file -> Unit_version (d, Sel_ANY)
) ln;
with Not_found -> []
end in
let line = ref (input_line fc) in
let field = ref "" in
let data = ref "" in
begin
let first_at = String.index_from !line 1 '@' in
field := String.sub !line 1 (first_at-1);
data := String.sub !line (first_at+1) (String.length !line-first_at-1);
while !field <> "info"
do
Hashtbl.add fields !field !data;
line := input_line fc;
let first_at = String.index_from !line 1 '@' in
field := String.sub !line 1 (first_at-1);
data := String.sub !line (first_at+1) (String.length !line-first_at-1);
done;
Scanf.sscanf !data "%s@@%d@@%Ld%s"
(fun nvra epoch size _ ->
let ra = String.rindex nvra '.' in
let vr = String.rindex_from nvra (ra-1) '-' in
let nv = String.rindex_from nvra (vr-1) '-' in
let name = String.sub nvra 0 nv
and version = String.sub nvra (nv+1) (vr-nv-1)
and release = String.sub nvra (vr+1) (ra-vr-1)
and arch = String.sub nvra (ra+1) (String.length nvra-ra-1) in
{ pk_unit = name;
pk_version =
(if epoch <> 0 then Printf.sprintf "%d:%s-%s" epoch version release
else Printf.sprintf "%s-%s" version release);
pk_architecture = arch;
pk_source = (name, "");
pk_size =
(try
Int64.of_string (Hashtbl.find fields "filesize")
with Not_found -> 0L);
pk_installed_size = size;
pk_provides = treat_dependency "provides";
pk_depends =
List.map (fun x -> [x]) (treat_dependency "requires");
pk_pre_depends = [];
pk_conflicts = treat_dependency "conflicts";
pk_breaks = [];
pk_replaces = treat_dependency "obsoletes";
pk_suggests =
List.map (fun x -> [x]) (treat_dependency "suggests");
pk_recommends = [];
pk_enhances = [];
pk_essential = false;
pk_build_essential = false;
pk_extra = []
}
)
end in
begin
try
while true
do
res := (get_package ())::!res
done;
!res
with End_of_file -> !res
end;;
dose2-1.4.2/ocamlrpm/ocamlrpm.mli 0000664 0000000 0000000 00000002235 11231374124 0016661 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Jaap Boender.
This file is part of Dose2.
Dose2 is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Dose2 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 Dose2; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
open Napkin
val compare_versions: string -> string -> int
val add_file_provides: Progress.indicator -> package_with_files list -> package_with_files list
val add_file_conflicts: Progress.indicator -> package_with_files list -> package_with_files list
val read_package: string -> string -> package_with_files
val read_hdlist: string -> string -> package_with_files list
val read_synthesis_hdlist: string -> package_with_files list
dose2-1.4.2/ocamlrpm/ocamlrpm_stubs.c 0000664 0000000 0000000 00000071620 11231374124 0017546 0 ustar 00root root 0000000 0000000 /* Copyright 2005-2008 Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . */
#include
#include
#include
#include
#include
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_RPM_RPMIO_H
#include
#endif
#ifdef HAVE_RPM_RPMLIB_H
#include
#endif
#ifdef HAVE_CAML_MLVALUES_H
#include
#endif
#ifdef HAVE_CAML_MEMORY_H
#include
#endif
#ifdef HAVE_CAML_ALLOC_H
#include
#endif
#ifdef HAVE_CAML_CUSTOM_H
#include
#endif
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* #define DEBUG */
#define NAPKIN_PK_UNIT 0
#define NAPKIN_PK_VERSION 1
#define NAPKIN_PK_ARCHITECTURE 2
#define NAPKIN_PK_EXTRA 3
#define NAPKIN_PK_SIZE 4
#define NAPKIN_PK_INSTALLED_SIZE 5
#define NAPKIN_PK_SOURCE 6
#define NAPKIN_PK_PROVIDES 7
#define NAPKIN_PK_CONFLICTS 8
#define NAPKIN_PK_BREAKS 9
#define NAPKIN_PK_REPLACES 10
#define NAPKIN_PK_DEPENDS 11
#define NAPKIN_PK_PRE_DEPENDS 12
#define NAPKIN_PK_SUGGESTS 13
#define NAPKIN_PK_RECOMMENDS 14
#define NAPKIN_PK_ENHANCES 15
#define NAPKIN_PK_ESSENTIAL 16
#define NAPKIN_PK_BUILD_ESSENTIAL 17
#define NAPKIN_NR_FIELDS 18
/* Selectors */
#define SEL_LEQ 0
#define SEL_GEQ 1
#define SEL_LT 2
#define SEL_GT 3
#define SEL_EQ 4
#define SEL_ANY (Val_int(0))
#define NAME_VERSION 0
const char *ocamlize_string (int32_t my_locale, int32_t nr_locales, int32_t type, const char *data)
{
int32_t i;
const char *ptr;
switch (type)
{
case RPM_STRING_TYPE:
return data;
case RPM_I18NSTRING_TYPE:
for (i = 0, ptr = data + (nr_locales * 4); i < my_locale; i++, ptr += strlen (ptr) + 1);
#ifdef DEBUG
fprintf (stderr, "I18N string (locale %d): %s\n", my_locale, ptr);
#endif
return ptr;
default:
fprintf (stderr, "ocamlize_string called for something that is not a string.\n");
exit (EXIT_FAILURE);
}
}
value ocamlize_rpm_dependency_list (char *pkgname, char *type, int length, char **names, char **versions, uint32_t *flags)
{
int i;
CAMLparam0 ();
CAMLlocal5 (hd, tl, v0, v1, v2);
tl = Val_int (0);
for (i = 0; i < length; i++)
{
#ifdef DEBUG
fprintf (stderr, "%s: %s[%d] is %s %s\n", pkgname, type, i, names[i], versions[i]);
#endif
if (versions [i][0] == '%')
fprintf (stderr, "[%s] Erroneous version found in %s: %s'%s\n", pkgname, type, names [i], versions [i]);
if (strncmp (names [i], "rpmlib", 6) == 0)
continue;
switch (flags [i] % 16)
{
case 2: // < x
v2 = caml_alloc (1, SEL_LT);
Store_field (v2, 0, caml_copy_string (versions [i]));
break;
case 4: // > x
v2 = caml_alloc (1, SEL_GT);
Store_field (v2, 0, caml_copy_string (versions [i]));
break;
case 8: // = x
v2 = caml_alloc (1, SEL_EQ);
Store_field (v2, 0, caml_copy_string (versions [i]));
break;
case 10: // <= x
v2 = caml_alloc (1, SEL_LEQ);
Store_field (v2, 0, caml_copy_string (versions [i]));
break;
case 12: // >= x
v2 = caml_alloc (1, SEL_GEQ);
Store_field (v2, 0, caml_copy_string (versions [i]));
break;
default: // any
v2 = SEL_ANY;
}
v1 = caml_alloc_tuple (2); // (name, versioned)
Store_field (v1, 0, caml_copy_string (names [i]));
Store_field (v1, 1, v2);
v0 = caml_alloc (1, NAME_VERSION);
Store_field (v0, 0, v1);
hd = caml_alloc (2, 0); // selector list
Store_field (hd, 0, v0);
Store_field (hd, 1, tl);
tl = hd;
}
CAMLreturn (tl);
}
/* Returns a pkg_metadata value */
value ocamlize_header (Header header, char *locale)
{
HeaderIterator hi;
#if RPM_FORMAT_VERSION >= 5
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
#else
uint32_t tag, type, count;
void *data;
#endif
uint32_t epoch = 0, *dirindexes = NULL, nr_di = 0, nr_bn = 0, nr_dn = 0, nr_md5s = 0, nr_modes = 0, nr_p = 0, nr_d = 0, nr_c = 0, nr_o = 0, nr_s = 0, i;
uint32_t *p_flags = NULL, *d_flags = NULL, *c_flags = NULL, *o_flags = NULL, *s_flags = NULL, nr_locales = 0, my_locale = 0;
uint32_t installed_size, archive_size, date = 0;
char *version = NULL, *release = NULL, **basenames = NULL, **dirnames = NULL, *version_string;
char **p_names = NULL, **p_versions = NULL;
char **d_names = NULL, **d_versions = NULL;
char **c_names = NULL, **c_versions = NULL;
char **o_names = NULL, **o_versions = NULL;
char **s_names = NULL, **s_versions = NULL;
char **locales = NULL, *name = NULL, *pkgname = NULL, **md5s = NULL, *arch = NULL, *maintainer = NULL, *category = NULL, *source_package = NULL, *homepage = NULL, *summary = NULL, *description = NULL, *license = NULL, *distribution = NULL, *vendor = NULL, *os = NULL;
uint16_t *modes = NULL;
CAMLparam0 ();
CAMLlocal5 (napkin, v0, v1, v2, v3);
CAMLlocal2 (hd, tl);
CAMLlocal4 (depends_hd, depends_tl, pre_depends_hd, pre_depends_tl);
CAMLlocal2 (suggests_hd, suggests_tl);
napkin = caml_alloc (NAPKIN_NR_FIELDS, 0);
#if RPM_FORMAT_VERSION >= 5
# define TAG (he -> tag)
# define COUNT (he -> c)
# define TYPE (he -> t)
# define DATA(i) (he -> p.argv[i])
# define DATA_STR (he -> p.str)
# define UINT16(i) (he -> p.ui16p [i])
# define UINT32(i) (he -> p.ui32p [i])
#else
# define TAG (tag)
# define COUNT (count)
# define TYPE (type)
# define DATA(i) (((char **) data) [i])
# define DATA_STR ((char *) data)
# define RPM_UINT16_TYPE RPM_INT16_TYPE
# define RPM_UINT32_TYPE RPM_INT32_TYPE
# define UINT16(i) (((uint16_t *) data) [i])
# define UINT32(i) (((int32 *) data) [i])
#endif
#if RPM_FORMAT_VERSION >= 5
hi = headerInit (header);
while (headerNext (hi, he, 0))
#else
hi = headerInitIterator (header);
while (headerNextIterator (hi, &tag, &type, &data, &count))
#endif
{
#ifdef DEBUG
fprintf (stderr, "- tag number: %d\n", TAG);
#endif
switch (TAG)
{
case HEADER_I18NTABLE:
locales = (char **) malloc (COUNT * sizeof (char *));
for (i = 0; i < COUNT; i++)
{
locales [i] = strdup (DATA (i));
if (strcmp (locales [i], locale) == 0)
my_locale = i;
}
nr_locales = COUNT;
break;
case RPMTAG_NAME: /* string type */
#ifdef DEBUG
fprintf (stderr, "- Name: %s\n", DATA_STR);
#endif /* DEBUG */
if (TYPE == RPM_STRING_TYPE)
name = strdup (DATA_STR);
else
caml_failwith ("NAME tag without string type");
break;
case RPMTAG_EPOCH:
if (TYPE == RPM_UINT32_TYPE)
epoch = UINT32(0);
else
caml_failwith ("EPOCH tag without int32 type");
break;
case RPMTAG_VERSION:
if (TYPE == RPM_STRING_TYPE)
version = strdup (DATA_STR);
else
caml_failwith ("VERSION tag without string type");
break;
case RPMTAG_RELEASE:
if (TYPE == RPM_STRING_TYPE)
release = strdup (DATA_STR);
else
caml_failwith ("RELEASE tag without string type");
break;
case RPMTAG_REQUIRENAME:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
nr_d = COUNT;
d_names = (char **) malloc (nr_d * sizeof (char *));
for (i = 0; i < nr_d; i++)
d_names [i] = strdup (DATA(i));
}
else
caml_failwith ("REQUIRENAME tag without string type");
break;
case RPMTAG_REQUIREVERSION:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
if (nr_d == 0)
nr_d = COUNT;
else if (COUNT != nr_d)
caml_failwith ("The number of REQUIREVERSIONS is not consistent");
d_versions = (char **) malloc (nr_d * sizeof (char *));
for (i = 0; i < nr_d; i++)
d_versions [i] = strdup (DATA(i));
}
else
caml_failwith ("REQUIREVERSION tag without string type");
break;
case RPMTAG_REQUIREFLAGS:
if (TYPE == RPM_UINT32_TYPE)
{
if (nr_d == 0)
nr_d = COUNT;
else if (COUNT != nr_d)
caml_failwith ("The number of REQUIREFLAGS is not consistent");
d_flags = (int32_t *) malloc (nr_d * sizeof (int32_t));
for (i = 0; i < nr_d; i++)
d_flags [i] = UINT32(i);
}
else
caml_failwith ("REQUIREFLAGS tag without string type");
break;
case RPMTAG_PROVIDENAME:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
nr_p = COUNT;
p_names = (char **) malloc (nr_p * sizeof (char *));
for (i = 0; i < nr_p; i++)
p_names [i] = strdup (DATA(i));
}
else
caml_failwith ("PROVIDENAME tag without string type");
break;
case RPMTAG_PROVIDEVERSION:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
if (nr_p == 0)
nr_p = COUNT;
else if (COUNT != nr_p)
caml_failwith ("The number of PROVIDEVERSIONS is not consistent");
p_versions = (char **) malloc (nr_p * sizeof (char *));
for (i = 0; i < nr_p; i++)
p_versions [i] = strdup (DATA(i));
}
else
caml_failwith ("PROVIDEVERSION tag without string type");
break;
case RPMTAG_PROVIDEFLAGS:
if (TYPE == RPM_UINT32_TYPE)
{
if (nr_p == 0)
nr_p = COUNT;
else if (COUNT != nr_p)
caml_failwith ("The number of PROVIDEFLAGS is not consistent");
p_flags = (int32_t *) malloc (nr_p * sizeof (int32_t));
for (i = 0; i < nr_p; i++)
p_flags [i] = UINT32(i);
}
else
caml_failwith ("PROVIDEFLAGS tag without string type");
break;
case RPMTAG_CONFLICTNAME:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
nr_c = COUNT;
c_names = (char **) malloc (nr_c * sizeof (char *));
for (i = 0; i < nr_c; i++)
c_names [i] = strdup (DATA(i));
}
else
caml_failwith ("CONFLICTNAME tag without string type");
break;
case RPMTAG_CONFLICTVERSION:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
if (nr_c == 0)
nr_c = COUNT;
else if (COUNT != nr_c)
caml_failwith ("The number of CONFLICTVERSIONS is not consistent");
c_versions = (char **) malloc (nr_c * sizeof (char *));
for (i = 0; i < nr_c; i++)
c_versions [i] = strdup (DATA(i));
}
else
caml_failwith ("CONFLICTVERSION tag without string type");
break;
case RPMTAG_CONFLICTFLAGS:
if (TYPE == RPM_UINT32_TYPE)
{
if (nr_c == 0)
nr_c = COUNT;
else if (COUNT != nr_c)
caml_failwith ("The number of CONFLICTFLAGS is not consistent");
c_flags = (int32_t *) malloc (nr_c * sizeof (int32_t));
for (i = 0; i < nr_c; i++)
c_flags [i] = UINT32(i);
}
else
caml_failwith ("CONFLICTFLAGS tag without string type");
break;
case RPMTAG_OBSOLETENAME:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
nr_o = COUNT;
o_names = (char **) malloc (nr_o * sizeof (char *));
for (i = 0; i < nr_o; i++)
o_names [i] = strdup (DATA(i));
}
else
caml_failwith ("OBSOLETENAME tag without string type");
break;
case RPMTAG_OBSOLETEVERSION:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
if (nr_o == 0)
nr_o = COUNT;
else if (COUNT != nr_o)
caml_failwith ("The number of OBSOLETEVERSIONS is not consistent");
o_versions = (char **) malloc (nr_o * sizeof (char *));
for (i = 0; i < nr_o; i++)
o_versions [i] = strdup (DATA(i));
}
else
caml_failwith ("OBSOLETEVERSION tag without string type");
break;
case RPMTAG_OBSOLETEFLAGS:
if (TYPE == RPM_UINT32_TYPE)
{
if (nr_o == 0)
nr_o = COUNT;
else if (COUNT != nr_o)
caml_failwith ("The number of OBSOLETEFLAGS is not consistent");
o_flags = (int32_t *) malloc (nr_o * sizeof (int32_t));
for (i = 0; i < nr_o; i++)
o_flags [i] = UINT32(i);
}
else
caml_failwith ("OBSOLETEFLAGS tag without string type");
break;
case RPMTAG_SUGGESTSNAME:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
nr_s = COUNT;
s_names = (char **) malloc (nr_s * sizeof (char *));
for (i = 0; i < nr_s; i++)
s_names [i] = strdup (DATA(i));
}
else
caml_failwith ("SUGGESTSNAME tag without string type");
break;
case RPMTAG_SUGGESTSVERSION:
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
if (nr_s == 0)
nr_s = COUNT;
else if (COUNT != nr_s)
caml_failwith ("The number of SUGGESTSVERSIONS is not consistent");
s_versions = (char **) malloc (nr_s * sizeof (char *));
for (i = 0; i < nr_s; i++)
s_versions [i] = strdup (DATA(i));
}
else
caml_failwith ("SUGGESTSVERSION tag without string type");
break;
case RPMTAG_SUGGESTSFLAGS:
if (TYPE == RPM_UINT32_TYPE)
{
if (nr_s == 0)
nr_s = COUNT;
else if (COUNT != nr_s)
caml_failwith ("The number of SUGGESTSFLAGS is not consistent");
s_flags = (int32_t *) malloc (nr_s * sizeof (int32_t));
for (i = 0; i < nr_s; i++)
s_flags [i] = UINT32(i);
}
else
caml_failwith ("SUGGESTSFLAGS tag without string type");
break;
case RPMTAG_ARCH: /* string type */
if (TYPE == RPM_STRING_TYPE)
arch = strdup (DATA_STR);
else
caml_failwith ("ARCHITECTURE tag without string type");
break;
case RPMTAG_DIRINDEXES:
nr_di = COUNT;
if (TYPE == RPM_UINT32_TYPE)
{
dirindexes = (int32_t *) malloc (nr_di * sizeof (int32_t *));
for (i = 0; i < nr_di; i++)
dirindexes [i] = UINT32(i);
}
else
caml_failwith ("DIRINDEXES tag without int32 type");
break;
case RPMTAG_BASENAMES:
nr_bn = COUNT;
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
basenames = (char **) malloc (nr_bn * sizeof (char *));
for (i = 0; i < nr_bn; i++)
basenames [i] = strdup (DATA(i));
}
else
caml_failwith ("BASENAMES tag without string array type");
break;
case RPMTAG_DIRNAMES:
nr_dn = COUNT;
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
dirnames = (char **) malloc (nr_dn * sizeof (char *));
for (i = 0; i < nr_dn; i++)
dirnames [i] = strdup (DATA(i));
}
else
caml_failwith ("BASENAMES tag without string array type");
break;
case RPMTAG_FILEMODES:
nr_modes = COUNT;
if (TYPE == RPM_UINT16_TYPE)
{
modes = (uint16_t *) malloc (nr_modes * sizeof (uint16_t));
for (i = 0; i < nr_modes; i++)
modes [i] = UINT16(i);
}
else
caml_failwith ("MODES tag without uint16 type");
break;
case RPMTAG_FILEMD5S:
nr_md5s = COUNT;
if (TYPE == RPM_STRING_ARRAY_TYPE)
{
md5s = (char **) malloc (nr_md5s * sizeof (char *));
for (i = 0; i < nr_md5s; i++)
md5s [i] = strdup (DATA(i));
}
else
caml_failwith ("FILEMD5S tag without string array tyoe");
break;
/* case RPMTAG_PACKAGER: // string type
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
maintainer = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("PACKAGER tag without (i18n) string type");
break;
case RPMTAG_GROUP: // string type
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
category = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("GROUP tag without (i18n) string type");
break; */
case RPMTAG_ARCHIVESIZE: /* int32 type */
if (TYPE == RPM_UINT32_TYPE)
archive_size = UINT32(0);
else
caml_failwith ("ARCHIVE_SIZE tag without int32 type");
break;
case RPMTAG_SIZE: /* int32 type */
if (TYPE == RPM_UINT32_TYPE)
installed_size = UINT32(0);
else
caml_failwith ("SIZE tag without int32 type");
break;
case RPMTAG_SOURCERPM: /* string type */
#ifdef DEBUG
fprintf (stderr, "- Source RPM: %s\n", DATA_STR);
#endif
if (TYPE == RPM_STRING_TYPE)
source_package = strdup (DATA_STR);
else
caml_failwith ("SOURCERPM tag without string type");
break;
/* case RPMTAG_URL: // string type
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
homepage = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("URL tag without (i18n) string type");
break;
case RPMTAG_SUMMARY: // string type
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
summary = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("SUMMARY tag without (i18n) string type");
break;
case RPMTAG_DESCRIPTION: // string type
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
description = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("DESCRIPTION tag without (i18n) string type");
break;
case RPMTAG_LICENSE:
#ifdef DEBUG
fprintf (stderr, "- License: %s\n", DATA_STR);
#endif
if (TYPE == RPM_STRING_TYPE)
license = strdup (DATA_STR);
else
caml_failwith ("LICENSE tag without string type");
break;
case RPMTAG_DISTRIBUTION:
#ifdef DEBUG
fprintf (stderr, "- Distribution: %s\n", DATA_STR);
#endif
if (TYPE == RPM_STRING_TYPE)
distribution = strdup (DATA_STR);
else
caml_failwith ("DISTRIBUTION tag without string type");
break;
case RPMTAG_VENDOR:
if ((TYPE == RPM_STRING_TYPE) || (TYPE == RPM_I18NSTRING_TYPE))
vendor = strdup (ocamlize_string (my_locale, nr_locales, TYPE, DATA_STR));
else
caml_failwith ("VENDOR tag without (i18n) string type");
break;
case RPMTAG_OS:
if (TYPE == RPM_STRING_TYPE)
os = strdup (DATA_STR);
else
caml_failwith ("OS tag without string type");
break;
case RPMTAG_BUILDTIME:
if (TYPE == RPM_UINT32_TYPE)
date = UINT32(0);
else
caml_failwith ("BUILDTIME tag without int32 type");
break; */
}
#if RPM_FORMAT_VERSION >= 5
free (he -> p.ptr);
#endif
}
#if RPM_FORMAT_VERSION >= 5
headerFini(hi);
#else
headerFreeIterator (hi);
#endif
for (i = 0; i < nr_locales; i++)
free (locales [i]);
free (locales);
#ifdef DEBUG
fprintf (stderr, "- finished with header.\n");
#endif
/* name (pk_unit) */
if (name == NULL)
caml_failwith ("No NAME tag found");
else
Store_field (napkin, NAPKIN_PK_UNIT, caml_copy_string (name));
/* version */
if (epoch == 0)
version_string = strdup ("");
else
asprintf (&version_string, "%d:", epoch);
if (version != NULL)
{
version_string = (char *) realloc (version_string, strlen (version_string) + strlen (version) + 1);
strcat (version_string, version);
}
if (release != NULL)
{
version_string = (char *) realloc (version_string, strlen (version_string) + strlen (release) + 2);
strcat (version_string, "-");
strcat (version_string, release);
}
Store_field (napkin, NAPKIN_PK_VERSION, caml_copy_string (version_string));
free (version); free (release);
asprintf (&pkgname, "%s'%s", name, version_string);
/* architecture */
if (arch == NULL)
Store_field (napkin, NAPKIN_PK_ARCHITECTURE, caml_copy_string (""));
else
Store_field (napkin, NAPKIN_PK_ARCHITECTURE, caml_copy_string (arch));
free (arch);
/* extra */
Store_field (napkin, NAPKIN_PK_EXTRA, Val_unit);
/* size */
Store_field (napkin, NAPKIN_PK_SIZE, caml_copy_int64 (archive_size));
/* installed_size */
Store_field (napkin, NAPKIN_PK_INSTALLED_SIZE, caml_copy_int64 (installed_size));
/* source */
v0 = caml_alloc_tuple (2);
if (source_package == NULL)
{
Store_field (v0, 0, caml_copy_string (name));
Store_field (v0, 1, caml_copy_string (version_string));
}
else
{
char *last_dash = strrchr (source_package, '-'), *sep, *dot;
if (last_dash != NULL)
{
dot = strchr (last_dash + 1, '.');
if (dot != NULL)
*dot = '\0';
*last_dash = '\0';
sep = strrchr (source_package, '-');
if (sep != NULL)
{
*last_dash = '-';
*sep = '\0';
Store_field (v0, 0, caml_copy_string (source_package));
Store_field (v0, 1, caml_copy_string (sep + 1));
}
else
{
Store_field (v0, 0, caml_copy_string (source_package));
Store_field (v0, 1, caml_copy_string (last_dash + 1));
}
}
else
{
Store_field (v0, 0, caml_copy_string (source_package));
Store_field (v0, 1, caml_copy_string (version_string));
}
}
Store_field (napkin, NAPKIN_PK_SOURCE, v0);
free (source_package); free (version_string); free (name);
/* provides */
v0 = ocamlize_rpm_dependency_list (pkgname, "provides", nr_p, p_names, p_versions, p_flags);
Store_field (napkin, NAPKIN_PK_PROVIDES, v0);
for (i = 0; i < nr_p; i++)
{
free (p_names [i]); free (p_versions [i]);
}
free (p_names); free (p_versions); free (p_flags);
/* conflicts */
v0 = ocamlize_rpm_dependency_list (pkgname, "conflicts", nr_c, c_names, c_versions, c_flags);
Store_field (napkin, NAPKIN_PK_CONFLICTS, v0);
for (i = 0; i < nr_c; i++)
{
free (c_names [i]); free (c_versions [i]);
}
if (c_names != NULL)
{
free (c_names); free (c_versions); free (c_flags);
}
/* replaces */
v0 = ocamlize_rpm_dependency_list (pkgname, "obsoletes", nr_o, o_names, o_versions, o_flags);
Store_field (napkin, NAPKIN_PK_REPLACES, v0);
for (i = 0; i < nr_o; i++)
{
free (o_names [i]); free (o_versions [i]);
}
if (o_names != NULL)
{
free (o_names); free (o_versions); free (o_flags);
}
/* depends */
/* special case: both flags-wise and list-creation-wise */
depends_tl = Val_int (0);
pre_depends_tl = Val_int (0);
for (i = 0; i < nr_d; i++)
{
if (d_versions [i][0] == '%')
fprintf (stderr, "Warning: [%s] depends on erroneous version: %s'%s\n", pkgname, d_names [i], d_versions [i]);
if (strncmp (d_names [i], "rpmlib", 6) == 0)
continue;
switch (d_flags [i] % 16)
{
case 2: // < x
v3 = caml_alloc (1, SEL_LT);
Store_field (v3, 0, caml_copy_string (d_versions [i]));
break;
case 4: // > x
v3 = caml_alloc (1, SEL_GT);
Store_field (v3, 0, caml_copy_string (d_versions [i]));
break;
case 8: // = x
v3 = caml_alloc (1, SEL_EQ);
Store_field (v3, 0, caml_copy_string (d_versions [i]));
break;
case 10: // <= x
v3 = caml_alloc (1, SEL_LEQ);
Store_field (v3, 0, caml_copy_string (d_versions [i]));
break;
case 12: // >= x
v3 = caml_alloc (1, SEL_GEQ);
Store_field (v3, 0, caml_copy_string (d_versions [i]));
break;
default: // any
v3 = SEL_ANY;
}
v2 = caml_alloc_tuple (2); // (name, versioned)
Store_field (v2, 0, caml_copy_string (d_names [i]));
Store_field (v2, 1, v3);
v1 = caml_alloc (1, NAME_VERSION); // instead of glob_pattern
Store_field (v1, 0, v2);
v0 = caml_alloc (2, 0);
Store_field (v0, 0, v1);
Store_field (v0, 1, Val_int (0));
if (d_flags [i] & (1<<9)) // it's a pre_dependency
{
pre_depends_hd = caml_alloc (2, 0); // versioned list
Store_field (pre_depends_hd, 0, v0);
Store_field (pre_depends_hd, 1, pre_depends_tl);
pre_depends_tl = pre_depends_hd;
}
else
{
depends_hd = caml_alloc (2, 0); // versioned list
Store_field (depends_hd, 0, v0);
Store_field (depends_hd, 1, depends_tl);
depends_tl = depends_hd;
}
}
Store_field (napkin, NAPKIN_PK_DEPENDS, depends_tl);
Store_field (napkin, NAPKIN_PK_PRE_DEPENDS, pre_depends_tl);
for (i = 0; i < nr_d; i++)
{
free (d_names [i]); free (d_versions [i]);
}
free (d_names); free (d_versions); free (d_flags);
/* suggests, like depends */
suggests_tl = Val_int (0);
for (i = 0; i < nr_s; i++)
{
if (s_versions [i][0] == '%')
fprintf (stderr, "Warning: [%s] suggests erroneous version: %s'%s\n", pkgname, s_names [i], s_versions [i]);
if (strncmp (s_names [i], "rpmlib", 6) == 0)
continue;
switch (s_flags [i] % 16)
{
case 2: // < x
v3 = caml_alloc (1, SEL_LT);
Store_field (v3, 0, caml_copy_string (s_versions [i]));
break;
case 4: // > x
v3 = caml_alloc (1, SEL_GT);
Store_field (v3, 0, caml_copy_string (s_versions [i]));
break;
case 8: // = x
v3 = caml_alloc (1, SEL_EQ);
Store_field (v3, 0, caml_copy_string (s_versions [i]));
break;
case 10: // <= x
v3 = caml_alloc (1, SEL_LEQ);
Store_field (v3, 0, caml_copy_string (s_versions [i]));
break;
case 12: // >= x
v3 = caml_alloc (1, SEL_GEQ);
Store_field (v3, 0, caml_copy_string (s_versions [i]));
break;
default: // any
v3 = SEL_ANY;
}
v2 = caml_alloc_tuple (2); // (name, versioned)
Store_field (v2, 0, caml_copy_string (s_names [i]));
Store_field (v2, 1, v3);
v1 = caml_alloc (1, NAME_VERSION); // instead of glob_pattern
Store_field (v1, 0, v2);
v0 = caml_alloc (2, 0);
Store_field (v0, 0, v1);
Store_field (v0, 1, Val_int (0));
suggests_hd = caml_alloc (2, 0); // versioned list
Store_field (suggests_hd, 0, v0);
Store_field (suggests_hd, 1, suggests_tl);
suggests_tl = suggests_hd;
}
Store_field (napkin, NAPKIN_PK_SUGGESTS, suggests_tl);
for (i = 0; i < nr_s; i++)
{
free (s_names [i]); free (s_versions [i]);
}
free (s_names); free (s_versions); free (s_flags);
/* RPM doesn't know suggests, recommends, enhances, essential and/or
* build-essential */
Store_field (napkin, NAPKIN_PK_BREAKS, Val_int (0));
Store_field (napkin, NAPKIN_PK_RECOMMENDS, Val_int (0));
Store_field (napkin, NAPKIN_PK_ENHANCES, Val_int (0));
Store_field (napkin, NAPKIN_PK_ESSENTIAL, Val_int (0));
Store_field (napkin, NAPKIN_PK_BUILD_ESSENTIAL, Val_int (0));
/* files */
if ((nr_bn != nr_md5s) && (nr_md5s > 0))
{
caml_failwith ("The number of basenames is not equal to the number of MD5 keys");
}
if ((nr_bn != nr_modes) && (nr_modes > 0))
{
caml_failwith ("The number of basenames is not equal to the number of file mode entries");
}
tl = Val_int (0);
for (i = 0; i < nr_bn; i++)
{
char *t;
if (modes [i] & 040000 == 040000)
asprintf (&t, "%s%s/", dirnames [dirindexes [i]], basenames [i]);
else
asprintf (&t, "%s%s", dirnames [dirindexes [i]], basenames [i]);
#ifdef DEBUG
fprintf (stderr, "file[%d]: %s\n", i, t);
#endif
v0 = caml_alloc (2, 0);
Store_field (v0, 0, caml_copy_string (t));
Store_field (v0, 1, caml_copy_string (nr_md5s == 0 ? "" : md5s [i]));
hd = caml_alloc (2, 0);
Store_field (hd, 0, v0);
Store_field (hd, 1, tl);
free (t);
tl = hd;
}
Store_field (napkin, NAPKIN_PK_EXTRA, tl);
for (i = 0; i < nr_bn; i++)
free (basenames [i]);
for (i = 0; i < nr_dn; i++)
free (dirnames [i]);
for (i = 0; i < nr_md5s; i++)
free (md5s [i]);
if (basenames != NULL)
free (basenames);
if (dirnames != NULL)
free (dirnames);
if (dirindexes != NULL)
free (dirindexes);
if (md5s != NULL)
free (md5s);
free (pkgname);
CAMLreturn (napkin);
}
value ocamlrpm_read_package (value locale, value file_name)
{
FD_t fd;
Header header;
#if RPM_FORMAT_VERSION < 5 && defined(HAVE_RPMLEAD)
struct rpmlead lead;
#endif
CAMLparam2 (locale, file_name);
CAMLlocal1 (retval);
fd = Fopen (String_val (file_name), "r");
if (!fd)
caml_failwith (strerror (errno));
#if RPM_FORMAT_VERSION < 5 && defined(HAVE_RPMLEAD)
readLead (fd, &lead);
rpmReadSignature (fd, NULL, lead.signature_type);
header = headerRead (fd, lead.major >= 3 ? HEADER_MAGIC_YES : HEADER_MAGIC_NO);
#endif
retval = ocamlize_header (header, String_val (locale));
Fclose (fd);
CAMLreturn (retval);
}
value ocamlrpm_read_hdlist (value locale, value file_name)
{
uint32_t block[4], il, dl, *ei, nb;
ssize_t x;
FD_t fd;
Header header;
CAMLparam2 (locale, file_name);
CAMLlocal2 (hd, tl);
fd = Fopen (String_val (file_name), "r");
if (!fd)
caml_failwith (strerror (errno));
#if RPM_FORMAT_VERSION >= 5
x = ufdio->read (fd, (char *) block, sizeof (block));
if (x == 0)
CAMLreturn (Val_int (0));
else if (x != sizeof (block))
{
char *s;
asprintf (&s, "Read %u bytes (%u expected)", x, sizeof (block));
caml_failwith (s);
}
il = ntohl (block [2]);
dl = ntohl (block [3]);
nb = (il * 16) + dl;
ei = (uint32_t *) malloc (sizeof (il) + sizeof (dl) + nb);
if ((x = ufdio->read (fd, (char *) &ei [2], nb)) != nb)
{
char *s;
asprintf (&s, "Read %u bytes (%u expected)", x, nb);
caml_failwith (s);
}
ei [0] = block [2];
ei [1] = block [3];
header = headerLoad (ei);
#else
header = headerRead (fd, HEADER_MAGIC_YES);
#endif /* RPM_FORMAT_VERSION */
tl = Val_int (0);
while (header != NULL)
{
hd = caml_alloc (2, 0);
Store_field (hd, 0, ocamlize_header (header, String_val (locale)));
Store_field (hd, 1, tl);
headerFree (header);
header = NULL;
#if RPM_FORMAT_VERSION >= 5
free (ei);
ei = NULL;
x = ufdio->read (fd, (char *) block, sizeof (block));
if (x == 0)
break;
else if (x != sizeof (block))
{
char *s;
asprintf (&s, "Read %u bytes (%u expected)", x, sizeof (block));
caml_failwith (s);
}
il = ntohl (block [2]);
dl = ntohl (block [3]);
nb = (il * 16) + dl;
ei = (uint32_t *) xmalloc (sizeof (il) + sizeof (dl) + nb);
if ((x = ufdio->read (fd, (char *) &ei [2], nb)) != nb)
{
char *s;
asprintf (&s, "Read %u bytes (%u expected)", x, nb);
caml_failwith (s);
}
ei [0] = block [2];
ei [1] = block [3];
header = headerLoad (ei);
#else
header = headerRead (fd, HEADER_MAGIC_YES);
#endif /* RPM_FORMAT_VERSION */
tl = hd;
}
if (header != NULL)
headerFree (header);
#if RPM_FORMAT_VERSION >= 5
free (ei);
#endif /* RPM_FORMAT_VERSION */
Fclose (fd);
CAMLreturn (tl);
}
dose2-1.4.2/packetology/ 0000775 0000000 0000000 00000000000 11231374124 0015051 5 ustar 00root root 0000000 0000000 dose2-1.4.2/packetology/.depend 0000664 0000000 0000000 00000000373 11231374124 0016314 0 ustar 00root root 0000000 0000000 factorize.cmo:
factorize.cmx:
diagnosis.cmo: diagnosis.cmi
diagnosis.cmx: diagnosis.cmi
installability.cmo: diagnosis.cmi installability.cmi
installability.cmx: diagnosis.cmx installability.cmi
diagnosis.cmi:
installability.cmi: diagnosis.cmi
dose2-1.4.2/packetology/Makefile 0000664 0000000 0000000 00000000401 11231374124 0016504 0 ustar 00root root 0000000 0000000 # Makefile
NAME = packetology
SOURCES = factorize.ml diagnosis.ml installability.ml
MLIS= diagnosis.mli installability.mli
REQUIRES= util napkin rapids io progress satsolver
EXTRA_CLEAN= factorize.cmi
include ../Makefile.config
include .depend
dose2-1.4.2/packetology/diagnosis.ml 0000664 0000000 0000000 00000006441 11231374124 0017370 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
open Io
;;
type ('package_id, 'versioned) reason =
| Not_available of 'package_id
| Requested of 'package_id
| Dependency of 'package_id * 'package_id list
| Empty_disjunction of 'package_id * 'versioned list
| Conflict of 'package_id * 'package_id
;;
type ('not_installable_id, 'package_id, 'versioned) diagnosis = {
dg_closure_size : int;
dg_conflicts : int;
dg_disjunctions : int;
dg_dependencies : int;
dg_failures : ('not_installable_id * ('package_id, 'versioned) reason list) array
}
;;
(*** io_reason *)
let io_reason io_id io_range =
io_sum
begin
begin function
| "Not_available" -> fun i -> Not_available(read io_id i)
| "Requested" -> fun i -> Requested(read io_id i)
| "Dependency" -> fun i -> let (x,y) = read (io_pair io_id (io_list io_id)) i in Dependency(x,y)
| "Conflict" -> fun i -> let (x,y) = read (io_pair io_id io_id) i in Conflict(x,y)
| "Empty_disjunction" -> fun i -> let (x,y) = read (io_pair io_id (io_list io_range)) i in Empty_disjunction(x,y)
| _ -> fun i -> raise Unknown_constructor
end,
begin function
| Not_available x -> "Not_available", write io_id x
| Requested x -> "Requested", write io_id x
| Dependency(x,xl) -> "Dependency", write (io_pair io_id (io_list io_id)) (x,xl)
| Empty_disjunction(x,xl) -> "Empty_disjunction", write (io_pair io_id (io_list io_range)) (x,xl)
| Conflict(x,y) -> "Conflict", write (io_pair io_id io_id) (x,y)
end
end
;;
(* ***)
(*** empty_diagnosis *)
let empty_diagnosis = {
dg_closure_size = 0;
dg_conflicts = 0;
dg_disjunctions = 0;
dg_dependencies = 0;
dg_failures = [||]
};;
(* ***)
(*** io_diagnosis *)
let io_diagnosis io_ni io_id io_range =
io_record
[
"closure_size",
(fun x i -> { x with dg_closure_size = read io_int i }),
(fun x -> write io_int x.dg_closure_size );
"conflicts",
(fun x i -> { x with dg_conflicts = read io_int i }),
(fun x -> write io_int x.dg_conflicts);
"disjunctions",
(fun x i -> { x with dg_disjunctions = read io_int i }),
(fun x -> write io_int x.dg_disjunctions);
"dependencies",
(fun x i -> { x with dg_dependencies = read io_int i }),
(fun x -> write io_int x.dg_dependencies);
let io = io_array (io_pair io_ni (io_list (io_reason io_id io_range))) in
"failures",
(fun x i -> { x with dg_failures = read io i }),
(fun x -> write io x.dg_failures)
]
empty_diagnosis
;;
(* ***)
dose2-1.4.2/packetology/diagnosis.mli 0000664 0000000 0000000 00000002710 11231374124 0017534 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
type ('package_id, 'versioned) reason =
| Not_available of 'package_id
| Requested of 'package_id
| Dependency of 'package_id * 'package_id list
| Empty_disjunction of 'package_id * 'versioned list
| Conflict of 'package_id * 'package_id
type ('not_installable_id, 'package_id, 'versioned) diagnosis = {
dg_closure_size : int;
dg_conflicts : int;
dg_disjunctions : int;
dg_dependencies : int;
dg_failures : ('not_installable_id * ('package_id, 'versioned) reason list) array
}
val empty_diagnosis : ('a, 'b, 'c) diagnosis;;
val io_reason : 'a Io.literate -> 'b Io.literate -> ('a, 'b) reason Io.literate
val io_diagnosis : 'a Io.literate -> 'b Io.literate -> 'c Io.literate -> ('a, 'b, 'c) diagnosis Io.literate
dose2-1.4.2/packetology/diagnosis_store.ml 0000664 0000000 0000000 00000004451 11231374124 0020603 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
open Io;;
module G = Generic_io;;
(*** key_of_archives *)
let key_of_archives archives =
let al =
List.fold_left
begin fun key archive ->
[archive.flavor; archive.architecture; archive.distribution; archive.component] :: key
end
[]
archives
in
let pl = Factorize.factorize al in
Factorize.encode_product_list (fun b x -> Printf.bprintf b "%s" x) pl
;;
(* ***)
(*** store *)
class store db =
let io_range =
io_convert
(fun (u_name, str_sel) ->
let u_id = id_of_unit db u_name in
(u_id,
map_selector
(fun v -> version_of_name db u_id v)
str_sel))
(fun (u_id, num_sel) ->
(name_of_unit db u_id,
map_selector (name_of_version db u_id) num_sel))
(io_pair
io_string
(io_selector io_string))
in
let io_diagnosis =
Diagnosis.io_diagnosis
(io_convert
(fun (u,v) -> find_package_id db u v)
(fun p_id -> unit_and_version_of_package db (get_package db p_id))
(io_pair io_string io_string))
io_range
in
object(self)
method load fn = G.load_from_file io_diagnosis fn
method save fn dg = G.save_to_file ~header:true ~fmt:G.Asc io_diagnosis dg fn
(*** make_filename *)
method make_filename path key date =
Filename.concat
path
(Util.sanitize_filename
~is_safe:
(function
|'A'..'Z'|'a'..'z'|'0'..'9'|'_'|'-'|'('|')'|'+'|','|'.' -> true
| _ -> false)
(sf "diagnosis.%s.%s" key (Util.string_of_iso_8601 date)))
(* ***)
end
(* ***)
dose2-1.4.2/packetology/factorize.ml 0000664 0000000 0000000 00000005131 11231374124 0017371 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
type 'a product = P of 'a * 'a product list;;
(*** factorize *)
let rec factorize : 'a list list -> 'a product list =
fun l ->
let l = List.sort compare l in
let (result,state) =
List.fold_left
begin fun (result,state) term ->
match term with
| head :: rest ->
begin
match state with
| None -> (result,Some(head,[rest]))
| Some(head', rests) ->
if head = head' then
(result,Some(head', rest :: rests))
else
(P(head', factorize rests) :: result, Some(head, [rest]))
end
| _ -> (result,state)
end
([],None)
l
in
match state with
| None -> result
| Some(head, rests) -> P(head, factorize rests) :: result
;;
(* ***)
(*** print_product, print_product_list *)
let rec print_product print_element oc = function
| P(x,[]) -> print_element oc x
| P(x,[p]) ->
Printf.fprintf oc "%a" print_element x;
print_product print_element oc p
| P(x,l) ->
Printf.fprintf oc "%a(" print_element x;
print_product_list print_element oc l;
Printf.fprintf oc ")"
and print_product_list print_element oc l =
let first = ref true in
List.iter
begin fun y ->
if !first then first := false else Printf.fprintf oc " + ";
print_product print_element oc y
end
l
;;
(* ***)
(*** encode_product_list *)
let encode_product_list element pl =
let b = Buffer.create 256 in
let rec product = function
| P(x,[]) -> element b x
| P(x,[p]) ->
Printf.bprintf b "%a." element x;
product p
| P(x,l) ->
Printf.bprintf b "%a(" element x;
product_list l;
Printf.bprintf b ")"
and product_list l =
let first = ref true in
List.iter
begin fun y ->
if !first then first := false else Printf.bprintf b "+";
product y
end
l
in
product_list pl;
Buffer.contents b
;;
(* ***)
dose2-1.4.2/packetology/installability.ml 0000664 0000000 0000000 00000025453 11231374124 0020440 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
open Diagnosis
module N =
struct
type t = (package_id, (unit_id, (version_number * release_number), glob) versioned) reason
type reason = t
end;;
module S = Solver.M(N);;
module PS = Package_set;;
let sf = Printf.sprintf;;
type solver =
SAT (* Jerome Vouillon's SAT-based solver *)
| Direct (* Direct solver *);;
let current_solver = ref SAT;;
let current_verifier = ref None;;
let set_solver s =
current_solver := s;;
let get_solver () =
!current_solver;;
let set_verifier v =
current_verifier := v;;
let get_verifier () =
!current_verifier;;
let list_diagnosis_of (pl: package_id list) r: (package_id list, package_id, (unit_id, version_number * release_number, glob) versioned) diagnosis =
{ dg_closure_size = 0;
dg_conflicts = 0;
dg_disjunctions = 0;
dg_dependencies = 0;
dg_failures =
(match r with
| [] -> [| |]
| r' -> [| (pl, r') |])
};;
(*** renumber_set *)
let renumber_set set =
let set_size = PS.cardinal set in
let backward = Hashtbl.create (2 * set_size) in
let forward = Hashtbl.create (2 * set_size) in
let i = ref 0 in
PS.iter (fun p_id ->
Hashtbl.add backward !i p_id;
Hashtbl.add forward p_id !i;
incr i) set;
(backward, forward)
;;
let prepare db ?(log=ignore) ~(indicator: Progress.indicator) ?targets ~available () =
let problem_set = match targets with
| None -> available
| Some t ->
(* Compute the dependency closure of the set *)
log "Computing closure";
PS.union t (PS.inter available (Functions.dependency_closure db t)) in
(* Number packages *)
let problem_size = PS.cardinal problem_set in (* Number of affected packages *)
let (backward, forward) = renumber_set problem_set in
let f = Hashtbl.find forward
and g = Hashtbl.find backward
in
(* Generate the boolean problem *)
log (sf "Converting to boolean problem");
let pb = S.initialize_problem problem_size in
let num_conflicts = ref 0
and num_disjunctions = ref 0
and num_dependencies = ref 0
in
let encoding_size = ref 0 in
let charge x = encoding_size := !encoding_size + 2 in
let j = ref 0 in
(*** add conflicts and dependencies *)
indicator#start;
indicator#set_label "Conflicts and dependencies...";
PS.iter
begin fun p_id ->
indicator#display (!j,problem_size);
incr j;
let p = Functions.get_package_from_id db p_id in
let pn = Unit_index.find (get_unit_index db) p.pk_unit in
(*** Add conflicts *)
(* log (sf "Adding conflicts (%s)..." pn);*)
(*let conflicts = PS.inter (get_conflicts db p_id) set_closure in*)
let conflicts = PS.inter (Functions.conflicts db (PS.singleton p_id)) problem_set in
PS.iter
begin fun p_id' ->
if p_id <> p_id' then
begin
let x = S.lit_of_var (f p_id) false
and y = S.lit_of_var (f p_id') false
in
charge 2;
S.add_bin_rule pb x y [Conflict(p_id, p_id')];
incr num_conflicts
end
end
conflicts;
(* ***)
(*** Add dependencies *)
(* log (sf "Adding dependencies (%s)..." pn); *)
let process conjunction =
List.iter
begin fun disjunction ->
incr num_disjunctions;
if disjunction = [] then
() (* XXX : ignore empty disjunctions *)
else
begin
let ps =
List.fold_left
begin fun ps versioned ->
incr num_dependencies;
(* let (uid, sel) = versioned in *)
(* log (sf "Selecting for unit %s" (Unit_index.find (get_unit_index db) uid)); *)
PS.union ps
(PS.inter available (Functions.select db versioned))
end
PS.empty
disjunction
in
(* let ps = PS.inter set ps in *)
let o = PS.cardinal ps in
if o = 0 then
begin
S.add_un_rule pb (S.lit_of_var (f p_id) false)
[Empty_disjunction(p_id, disjunction)]
end
else
begin
let pl = PS.elements ps in
let vl = List.map f pl in
let l = List.map (fun v -> S.lit_of_var v true) vl in
charge (1 + o);
S.add_rule pb (Array.of_list ((S.lit_of_var (f p_id) false)::l))
[Dependency(p_id, pl)];
if l <> [] then S.associate_vars pb (S.lit_of_var (f p_id) true) vl
end
end
end
conjunction
in
process p.pk_depends;
process p.pk_pre_depends;
(* ***)
end
problem_set;
indicator#finish;
(* PS.iter
begin fun p_id ->
let v = S.lit_of_var (f p_id) false in
S.add_un_rule pb v [Not_available p_id]
end
(PS.diff set_closure available); *)
(* ***)
(*let vars = List.map f (PS.elements set) in*)
let failures = ref [] in
log (sf "Done, formula of size %d" !encoding_size);
(problem_size, f, g, problem_set, pb, failures, num_conflicts, num_disjunctions, num_dependencies);;
let check
db
?(log=ignore)
?preparation
~(indicator : Progress.indicator)
~targets
~available
()
=
let (closure_size, f, g, set, pb, failures, num_conflicts, num_disjunctions, num_dependencies) =
match preparation with
| None -> prepare db ~log ~indicator ~targets ~available ()
| Some (cs, f, g, set, pb, fl, nc, nd, ndp) ->
(cs, f, g, set, S.copy pb, fl, nc, nd, ndp) in
S.reset pb;
indicator#set_label "Solving";
let unknown = Array.make closure_size true in
for i = 0 to closure_size - 1 do
indicator#display (i,closure_size);
if PS.mem (g i) targets && unknown.(i) then
begin
if S.solve pb i or (S.reset pb; S.solve pb i) then
(* This package is OK *)
begin
let a = S.assignment pb in
for j = 0 to closure_size - 1 do
if a.(j) = S.True then unknown.(j) <- false
done
end
else
begin
S.reset pb;
ignore (S.solve pb i);
let reasons = S.collect_reasons pb i in
failures := (g i, reasons) :: !failures;
S.reset pb;
end
end
done;
indicator#finish;
(* Sort failures *)
let a = Array.of_list !failures in
Array.sort
begin fun (p_id,_) (p_id',_) ->
let f p_id =
let p = Functions.get_package_from_id db p_id in
(Unit_index.find (get_unit_index db) p.pk_unit, p.pk_version)
in
compare (f p_id) (f p_id')
end
a;
(* Create diagnosis *)
{ dg_closure_size = closure_size;
dg_conflicts = !num_conflicts;
dg_disjunctions = !num_disjunctions;
dg_dependencies = !num_dependencies;
dg_failures = a }
;;
let check_together
db
?(log=ignore)
?preparation
~(indicator : Progress.indicator)
~targets
~available
()
=
begin
let (closure_size, f, g, set, pb, failures, num_conflicts, num_disjunctions, num_dependencies) =
match preparation with
| None -> prepare db ~indicator ~targets ~available ()
| Some (cs, f, g, set, pb, fl, nc, nd, ndp) ->
(cs, f, g, set, S.copy pb, fl, nc, nd, ndp) in
S.reset pb;
indicator#set_label "Solving";
let pkgs = ref PS.empty in
(* let unknown = Array.make closure_size true in *)
let tg_list = List.map f (PS.elements targets) in
log (sf "Target list size %d" (List.length tg_list));
if not (S.solve_lst pb tg_list) then
begin
let reasons = S.collect_reasons_lst pb tg_list in
failures := (List.map g tg_list, reasons) :: !failures;
log (sf "Not successful, %d failures" (List.length !failures))
end
else
log (sf "Successful.");
indicator#finish;
{ dg_closure_size = closure_size;
dg_conflicts = !num_conflicts;
dg_disjunctions = !num_disjunctions;
dg_dependencies = !num_dependencies;
dg_failures = Array.of_list !failures }
end;;
let install
db
?(log=ignore)
?preparation
~(indicator : Progress.indicator)
~targets
~available
?(known=PS.empty)
()
=
let (closure_size, f, g, set, pb, failures, num_conflicts, num_disjunctions, num_dependencies) =
match preparation with
| None -> prepare db ~log ~indicator ~targets ~available ()
| Some (cs, f, g, set, pb, fl, nc, nd, ndp) ->
(cs, f, g, set, S.copy pb, fl, nc, nd, ndp) in
S.reset pb;
indicator#set_label "Solving";
let pkgs = ref PS.empty in
(* let unknown = Array.make closure_size true in *)
let tg_list = List.map f (PS.elements targets) in
log (sf "Target list size %d" (List.length tg_list));
if S.solve_lst pb tg_list then
begin
let a = S.assignment pb in
for i = 0 to closure_size - 1 do
if a.(i) = S.True then
pkgs := PS.add (g i) !pkgs;
done;
end;
indicator#finish;
!pkgs
;;
let abundance db ps =
begin
let package_id = ref None in
PS.iter (fun p_id ->
let p = Functions.get_package_from_id db p_id in
List.iter (fun disj ->
if !package_id = None then
let d_ok = List.exists
(fun v -> let range = Functions.select db v in
not (PS.is_empty (PS.inter ps range))
) disj in
if not d_ok then
package_id := Some p_id
) (p.pk_depends @ p.pk_pre_depends);
) ps;
!package_id
end;;
(* ***)
let strong_dep db ?is ?preparation available p1 p2 =
begin
let (closure_size, f, g, set, pb, failures, num_conflicts, num_disjunctions, num_dependencies) =
match preparation with
| None -> prepare db ~indicator:Progress.dummy ~available ()
| Some (cs, f, g, set, pb, fl, nc, nd, ndp) ->
(cs, f, g, set, S.copy pb, fl, nc, nd, ndp) in
let v2 = S.lit_of_var (f p2) false in
S.add_un_rule pb v2 [];
not (S.solve pb (f p1))
end;;
let trim db ps =
begin
let res_ps = ref ps in
let d = check db ~indicator:Progress.dummy ~targets:ps ~available:ps () in
Array.iter (fun (p_id, _) ->
res_ps := Package_set.remove p_id !res_ps
) d.dg_failures;
!res_ps
end;;
dose2-1.4.2/packetology/installability.mli 0000664 0000000 0000000 00000006451 11231374124 0020606 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
open Diagnosis
module N:
sig
type t = (package_id, (unit_id, version_number * release_number, glob) versioned) reason
type reason = t
end;;
(* This doesn't do anything, but is preserved for upwards compatibility with
* unstable versions *)
type solver =
SAT (* Jerome Vouillon's SAT-based solver *)
| Direct (* Direct solver *)
val set_solver: solver -> unit
val get_solver: unit -> solver
val set_verifier: solver option -> unit
val get_verifier: unit -> solver option
val prepare :
db ->
?log:(string -> unit) ->
indicator:Progress.indicator ->
?targets:Package_set.t ->
available:Package_set.t ->
unit ->
int * (Package_set.elt -> Solver.M(N).var) * (Solver.M(N).var -> Package_set.elt) * Package_set.t * Solver.M(N).state * 'a list ref * int ref * int ref * int ref
val check :
db ->
?log:(string -> unit) ->
?preparation:(int * (Package_set.elt -> Solver.M(N).var) * (Solver.M(N).var -> Package_set.elt) * Package_set.t * Solver.M(N).state * (Package_set.elt * N.reason list) list ref * int ref * int ref * int ref) ->
indicator:Progress.indicator ->
targets:Package_set.t ->
available:Package_set.t ->
unit ->
(Package_set.elt, Package_set.elt, (Rapids.unit_id, (Rapids.version_number * Rapids.release_number), glob) Napkin.versioned) Diagnosis.diagnosis
val check_together :
db ->
?log:(string -> unit) ->
?preparation:int * (Package_set.elt -> Solver.M(N).var) * (Solver.M(N).var -> Package_set.elt) * Package_set.t * Solver.M(N).state * (Package_set.elt list * N.reason list) list ref * int ref * int ref * int ref ->
indicator:Progress.indicator ->
targets:Package_set.t ->
available:Package_set.t ->
unit ->
(Package_set.elt list, Package_set.elt, (Rapids.unit_id, (Rapids.version_number * Rapids.release_number), glob) Napkin.versioned) Diagnosis.diagnosis
val install :
db ->
?log:(string -> unit) ->
?preparation:(int * (Package_set.elt -> Solver.M(N).var) *
(Solver.M(N).var -> Package_set.elt) * Package_set.t * Solver.M(N).state *
'a list ref * int ref * int ref * int ref) ->
indicator:Progress.indicator ->
targets:Package_set.t ->
available:Package_set.t ->
?known:Package_set.t ->
unit ->
Package_set.t
val abundance : db -> Package_set.t -> package_id option
val strong_dep:
db -> ?is:Package_set.t ->
?preparation:int * (Package_set.elt -> Solver.M(N).var) * (Solver.M(N).var -> Package_set.elt) * Package_set.t * Solver.M(N).state * 'a list ref * int ref * int ref * int ref ->
Package_set.t -> package_id -> package_id -> bool
val trim:
db ->
Package_set.t ->
Package_set.t
dose2-1.4.2/progress/ 0000775 0000000 0000000 00000000000 11231374124 0014374 5 ustar 00root root 0000000 0000000 dose2-1.4.2/progress/.depend 0000664 0000000 0000000 00000000107 11231374124 0015632 0 ustar 00root root 0000000 0000000 progress.cmo: progress.cmi
progress.cmx: progress.cmi
progress.cmi:
dose2-1.4.2/progress/Makefile 0000664 0000000 0000000 00000000207 11231374124 0016033 0 ustar 00root root 0000000 0000000 # Makefile
NAME = progress
SOURCES = progress.ml
MLIS = progress.mli
REQUIRES= util
include ../Makefile.config
include .depend
dose2-1.4.2/progress/depend 0000664 0000000 0000000 00000000070 11231374124 0015553 0 ustar 00root root 0000000 0000000 progress.cmo: progress.cmi
progress.cmx: progress.cmi
dose2-1.4.2/progress/progress.ml 0000664 0000000 0000000 00000007511 11231374124 0016576 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** A progress indicator module *)
class type progress_indicator =
object
method set_label : string -> unit
method set_decimation : int -> unit
method display : ?force:bool -> int * int -> unit
method start : unit
method finish : unit
method warn : string -> unit
end
;;
let dummy =
object(self)
method set_label _ = ()
method set_decimation _ = ()
method display ?force (_,_) = ()
method start = ()
method finish = ()
method warn msg = ()
end
;;
class virtual generic_indicator ~decimation ~label:initial_label () =
let delay = 0.100 in (* 100 ms *)
let full = "* 100.0%" in
(*let unspecified = " " in*)
let reserved = String.length full in
let rotate = "|/-\\" in
let columns = 75 in
object(self)
val mutable last = (-1,-1)
val mutable stamp = 0.0
val mutable label = ""
val mutable count = 0
val mutable rotation = 0
val mutable decimation = decimation
val b = Buffer.create columns
initializer
self#set_label initial_label
method private virtual output : unit
method set_label l =
let w = Util.limit (columns - reserved) l in
label <- w^(String.make (columns - reserved - (String.length w)) ' ')
method set_decimation d =
decimation <- d;
count <- 0
method display ?(force=false) (x,y) =
Buffer.clear b;
if decimation > 0 then
begin
count <- count + 1;
if count = decimation then
count <- 0;
end;
if force or ((decimation = 0 or count = 1 or y = 0) (* && (x,y) <> last *)) then
begin
let t = Unix.gettimeofday () in
if force or stamp +. delay < t then
begin
stamp <- t;
last <- (x,y);
Buffer.add_char b '\r';
Buffer.add_string b label;
if y = 0 then
Printf.bprintf b " %-7d" x
else
begin
let f = floor (1000.0 *. (float x) /. (float y)) in
let f = f /. 10.0 in
if f = 100.0 then
Buffer.add_string b full
else
begin
rotation <- (1 + rotation) land 3;
Printf.bprintf b "%c %%%4.1f" rotate.[rotation] f
end
end;
self#output
end
end
method start =
self#display ~force:true (0,0);
self#output
method finish =
self#display ~force:true (100,100);
Buffer.add_char b '\n';
self#output
method warn msg =
Printf.printf "\n%s\n" msg;
self#display ~force:true last
end
;;
class indicator ~decimation ~label ~channel () =
object(self)
inherit generic_indicator ~decimation ~label () as super
method private output =
Buffer.output_buffer channel b;
flush channel
end
;;
class formatter_indicator ~decimation ~label ~fmt () =
object(self)
inherit generic_indicator ~decimation ~label () as super
method private output =
let x = Buffer.contents b in
Format.fprintf fmt "%s@?" x;
end
;;
dose2-1.4.2/progress/progress.mli 0000664 0000000 0000000 00000002350 11231374124 0016743 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2007 Berke DURAK, INRIA Rocquencourt.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** A progress indicator module *)
class type progress_indicator =
object
method set_label : string -> unit
method set_decimation : int -> unit
method display : ?force:bool -> int * int -> unit
method start : unit
method finish : unit
method warn : string -> unit
end
;;
class indicator : decimation:int -> label:string -> channel:out_channel -> unit -> progress_indicator
class formatter_indicator : decimation:int -> label:string -> fmt:Format.formatter -> unit -> progress_indicator
val dummy : progress_indicator
dose2-1.4.2/rapids/ 0000775 0000000 0000000 00000000000 11231374124 0014012 5 ustar 00root root 0000000 0000000 dose2-1.4.2/rapids/.depend 0000664 0000000 0000000 00000000245 11231374124 0015253 0 ustar 00root root 0000000 0000000 rapids.cmo: rapids.cmi
rapids.cmx: rapids.cmi
waterway.cmo: rapids.cmi waterway.cmi
waterway.cmx: rapids.cmx waterway.cmi
rapids.cmi:
waterway.cmi: rapids.cmi
dose2-1.4.2/rapids/Makefile 0000664 0000000 0000000 00000000407 11231374124 0015453 0 ustar 00root root 0000000 0000000 NAME = rapids
SOURCES = rapids.ml waterway.ml
MLIS = rapids.mli waterway.mli
REQUIRES= lifetime napkin conduit io dosebase util progress ocamldeb ocamlrpm \
ocamlpkgsrc
OCAML_CFLAGS+= -I +ocamlbuild
include ../Makefile.config
include .depend
dose2-1.4.2/rapids/rapids.ml 0000664 0000000 0000000 00000122312 11231374124 0015627 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Conduit
open Napkin
open Io
open Ocamlpkgsrc
module G = Generic_io
module DBI = Dosebase.In
;;
exception Conflicting_information of string
let sf = Printf.sprintf;;
type liquid = RPM | Debian | Pkgsrc
type glob = string
(*** ORDERED_LITERATE *)
module type ORDERED_LITERATE =
sig
type t
val compare : t -> t -> int
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : t literate
end
;;
(* ***)
(*** Version_order *)
module Version_order =
struct
type t = string
let comparator = ref String.compare
let compare u v = !comparator u v
let set_comparator f = comparator := f
let scribe cd oc u = cd.cd_print oc "%s" u
let io = io_string
end
;;
(* ***)
(*** Release *)
module Release_order =
struct
type t = string option
let comparator = ref
(fun a b ->
match a, b with
| None , None -> 0
| None , (Some _) -> (-1)
| (Some _), None -> 1
| (Some x), (Some y) -> String.compare x y
)
let compare u v = !comparator u v
let set_comparator f = comparator := f
let scribe cd oc u = cd.cd_print oc "%s" (match u with None -> "" | Some x -> x)
let io = io_option io_string
end
;;
(*** STRING_ORDERED_LITERATE *)
module type STRING_ORDERED_LITERATE =
sig
type t = string
val compare : t -> t -> int
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : string literate
end
;;
(* ***)
(*** SET *)
module type SET =
sig
include Set.S
val io : t literate
end
;;
(* ***)
(*** ID *)
module type ID =
sig
type id
val to_int : id -> int
val from_int : int -> id
val compare : id -> id -> int
val succ : id -> id
val scribe : 'a Conduit.conduit -> 'a -> id -> unit
val zero : id
val sweep : id -> (id -> unit) -> unit
val io : id literate
end
;;
(* ***)
(*** INDEXED *)
module type INDEXED =
sig
type id
val compare_id : id -> id -> int
val io_id : id literate
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
end
;;
(* ***)
(*** INDEX *)
module type INDEX =
sig
type elt
type id
type t
val create : unit -> t
val register : t -> elt -> id
val search : t -> elt -> id
val find : t -> id -> elt
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id literate
val iter : t -> (id -> elt -> unit) -> unit
val set_watcher : t -> (id -> elt -> unit) -> unit
end
;;
(* ***)
(*** type *)
module type DATA =
sig
type t
end
;;
(* ***)
(*** LABELED_INDEX *)
module type LABELED_INDEX =
sig
type data
type elt
type id
type t
val create : unit -> t
val register : t -> elt -> (unit -> data) -> id
val search : t -> elt -> id
val find : t -> id -> elt
val data : t -> id -> data
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id literate
val iter : t -> (id -> elt -> data -> unit) -> unit
val set_watcher : t -> (id -> elt -> data -> unit) -> unit
end
;;
(* ***)
(*** Labeled_index *)
module Labeled_index(D : DATA)(I : ORDERED_LITERATE) :
LABELED_INDEX with type elt = I.t and type data = D.t
=
struct
type elt = I.t
type data = D.t
type id = int
type t = {
idx_to_id : (elt, id) Hashtbl.t;
idx_from_id : (id, elt * data) Hashtbl.t;
mutable idx_count : int;
mutable idx_watcher : id -> elt -> data -> unit
};;
let create () = {
idx_to_id = Hashtbl.create 1009;
idx_from_id = Hashtbl.create 1009;
idx_count = 0;
idx_watcher = (fun _ _ _ -> ())
};;
let register idx e d =
try
Hashtbl.find idx.idx_to_id e
with
| Not_found ->
let i = idx.idx_count in
idx.idx_count <- 1 + i;
Hashtbl.add idx.idx_to_id e i;
let data = d () in
Hashtbl.add idx.idx_from_id i (e, data);
idx.idx_watcher i e data;
i
;;
let set_watcher idx f = idx.idx_watcher <- f;;
let search idx e = Hashtbl.find idx.idx_to_id e;;
let find idx id =
let (e, _) = Hashtbl.find idx.idx_from_id id in e
;;
let data idx id =
let (_, d) = Hashtbl.find idx.idx_from_id id in d
;;
let compare_id (id1 : id) (id2 : id) = compare id1 id2;;
let scribe_id cd oc id = cd.cd_print oc "<%d>" id;;
let io_id = io_int;;
let iter idx f =
for i = 0 to idx.idx_count - 1 do
let (e, d) = Hashtbl.find idx.idx_from_id i in
f i e d
done
;;
end
;;
(* ***)
(*** Index *)
module Index(I : ORDERED_LITERATE) :
INDEX with type elt = I.t
=
struct
module LI = Labeled_index(struct type t = unit end)(I)
include LI
let register idx e = register idx e ignore;;
let iter idx f = LI.iter idx (fun id e _ -> f id e);;
let set_watcher idx f = set_watcher idx (fun id e _ -> f id e);;
end
;;
(* ***)
(*** DOUBLE_INDEX *)
module type DOUBLE_INDEX =
sig
type e1
type e2
type elt = e1 * e2
type id
type t
val create : unit -> t
val register : t -> elt -> id
val replace : t -> elt -> unit
val find : t -> id -> elt
val search1 : t -> e1 -> id
val search2 : t -> e2 -> id
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val iter : t -> (id -> elt -> unit) -> unit
val set_watcher : t -> (id -> elt -> unit) -> unit
end
;;
(* ***)
(*** Double_index *)
module Double_index(ID : ID)(I1 : ORDERED_LITERATE)(I2 : ORDERED_LITERATE) :
DOUBLE_INDEX with type e1 = I1.t and type e2 = I2.t and type id = ID.id
=
struct
type e1 = I1.t
type e2 = I2.t
type elt = e1 * e2
type id = ID.id
type t = {
idx_i1_to_id : (I1.t, id) Hashtbl.t;
idx_i2_to_id : (I2.t, id) Hashtbl.t;
idx_from_id : (id, elt) Hashtbl.t;
mutable idx_count : id;
mutable idx_watcher : (id -> elt -> unit);
};;
let create () = {
idx_i1_to_id = Hashtbl.create 1009;
idx_i2_to_id = Hashtbl.create 1009;
idx_from_id = Hashtbl.create 1009;
idx_count = ID.zero;
idx_watcher = (fun _ _ -> ())
};;
let register idx (e1,e2) =
try
Hashtbl.find idx.idx_i1_to_id e1
with
| Not_found ->
let id = idx.idx_count in
idx.idx_count <- ID.succ id;
Hashtbl.add idx.idx_i1_to_id e1 id;
Hashtbl.add idx.idx_i2_to_id e2 id;
Hashtbl.add idx.idx_from_id id (e1,e2);
idx.idx_watcher id (e1,e2);
id
;;
let replace idx (e1,e2) =
try
let id = Hashtbl.find idx.idx_i1_to_id e1 in
Hashtbl.replace idx.idx_i1_to_id e1 id;
Hashtbl.replace idx.idx_i2_to_id e2 id;
Hashtbl.replace idx.idx_from_id id (e1,e2);
idx.idx_watcher id (e1,e2)
with
| Not_found -> ignore (register idx (e1, e2))
;;
let set_watcher idx f = idx.idx_watcher <- f;;
let find idx id = Hashtbl.find idx.idx_from_id id;;
let search1 idx e1 = Hashtbl.find idx.idx_i1_to_id e1;;
let search2 idx e2 = Hashtbl.find idx.idx_i2_to_id e2;;
let compare_id = ID.compare
let scribe_id = ID.scribe
let iter idx f =
ID.sweep idx.idx_count
begin fun id ->
let e = Hashtbl.find idx.idx_from_id id in
f id e;
end
;;
end
;;
(* ***)
(*** VERSION_POOL *)
module type VERSION_POOL =
sig
type version
type handle
type id
type t
val create : unit -> t
val register : t -> version -> handle
val search : t -> version -> handle
val compare_versions : t -> handle -> handle -> int
val find : t -> id -> handle
val get_version : handle -> version
val get_id : handle -> id
val iter : t -> (handle -> unit) -> unit
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id literate
end
;;
(* ***)
(*** Version_pool *)
module Version_pool(V : ORDERED_LITERATE) :
VERSION_POOL with type version = V.t
=
struct
type version = V.t
type id = int
type handle = {
mutable h_order : int;
h_id : int;
h_version : version
}
module VM = Map.Make(V)
type t = {
mutable vp_map : handle VM.t;
mutable vp_count : int;
mutable vp_disorder : bool;
vp_from_id : (id, handle) Hashtbl.t
};;
let create () = {
vp_map = VM.empty;
vp_count = 0; (* Number of distinct versions known to the system; also next ID *)
vp_disorder = false;
vp_from_id = Hashtbl.create 1009
};;
let get_version h = h.h_version;;
let get_id h = h.h_id;;
let find vp id = Hashtbl.find vp.vp_from_id id;;
let reorder vp =
let x = ref 0 in
VM.iter
begin fun _ h ->
h.h_order <- !x;
incr x
end
vp.vp_map;
vp.vp_disorder <- false
;;
let iter vp f =
VM.iter
begin fun _ h ->
f h
end
vp.vp_map
;;
let compare_versions vp h1 h2 =
if vp.vp_disorder then reorder vp;
compare h1.h_order h2.h_order
;;
let register vp v =
try
VM.find v vp.vp_map
with
| Not_found ->
vp.vp_disorder <- true;
let id = vp.vp_count in
vp.vp_count <- 1 + id;
let h =
{ h_order = 0;
h_id = id;
h_version = v }
in
vp.vp_map <- VM.add v h vp.vp_map;
Hashtbl.add vp.vp_from_id id h;
h
;;
let search vp v = VM.find v vp.vp_map;;
let scribe_id cd oc id = cd.cd_print oc "<%d>" id;;
let io_id = io_int;;
end
;;
(* ***)
(*** Perishable *)
module Perishable =
struct
type 'a t = {
p_time : int ref;
p_contents : 'a option;
mutable p_build_date : int
}
let create time = {
p_time = time;
p_contents = None;
p_build_date = min_int
};;
end
;;
(* ***)
(*** CHRONOLOGICAL_PARAMETER *)
module type CHRONOLOGICAL_PARAMETER =
sig
val n : int
end
;;
(* ***)
(*** Set *)
module Set(O : ORDERED_LITERATE) : SET with type elt = O.t =
struct
module S = Set.Make(O)
let io = io_collection
begin
O.io,
(fun ps f -> S.iter f ps),
begin fun () ->
let ps = ref S.empty in
(fun i -> ps := S.add i !ps),
(fun () -> !ps)
end
end
include S
end
;;
(* ***)
(*** CHRONOLOGICAL_MAP *)
module type CHRONOLOGICAL_MAP =
sig
type t
type set
type elt
type day = int
val io : t Io.literate
val create : unit -> t
val iter : (day -> set -> unit) -> t -> unit
val range : t -> day * day
val get : t -> day -> set
val add : t -> day -> day -> set -> unit
end
;;
(* ***)
(*** Chronological_Map *)
module Chronological_Map(IS : SET)(P : CHRONOLOGICAL_PARAMETER) :
CHRONOLOGICAL_MAP with type elt = IS.elt and type set = IS.t
=
struct
open P;;
type elt = IS.elt
type set = IS.t
type day = int
;;
module WM = Map.Make(struct type t = int let compare = compare end);;
type week = {
mutable wk_base : IS.t;
wk_deltas : IS.t option array;
}
type t = {
mutable cm_weeks : week WM.t; (** Maps Julian week number to [week]. *)
}
let io_deltas = io_array (io_option IS.io);;
let io_wm xio = io_collection
begin
io_pair io_int xio,
(fun wm f -> WM.iter (fun k v -> f (k,v)) wm),
begin fun () ->
let wm = ref WM.empty in
(fun (i,x) -> wm := WM.add i x !wm),
(fun () -> !wm)
end
end
;;
let io_week =
io_record
[
"base",
(fun x i -> { x with wk_base = read IS.io i }),
(fun x -> write IS.io x.wk_base);
"deltas",
(fun x i -> { x with wk_deltas = read io_deltas i }),
(fun x -> write io_deltas x.wk_deltas)
]
{ wk_base = IS.empty;
wk_deltas = [||] }
;;
let io =
io_convert
(fun wks -> { cm_weeks = wks })
(fun cm -> cm.cm_weeks)
(io_wm io_week)
;;
(*** create *)
(** Creates a new chronological map. *)
let create () = { cm_weeks = WM.empty };;
(* ***)
let week_of_julian j = j / n;;
let next_week_of_julian j = (week_of_julian j) + 1;;
let day_of_julian j =
if j < 0 then
n - ((- j) mod n)
else
j mod n
;;
let julian_of_week w = w * n;;
(*** iter *)
let iter f cm =
WM.iter
begin fun w wk ->
let jw = julian_of_week w in
let current = ref wk.wk_base in
for i = 0 to n - 1 do
let j = jw + i in
current := (match wk.wk_deltas.(i) with
None -> IS.empty
| Some x -> IS.union !current x);
f j !current
done
end
cm.cm_weeks
;;
(* ***)
(*** get_week *)
let get_week cm w =
try
WM.find w cm.cm_weeks
with
| Not_found ->
let wk =
{ wk_base = IS.empty;
wk_deltas = Array.make n None }
in
cm.cm_weeks <- WM.add w wk cm.cm_weeks;
wk
;;
(* ***)
(*** add_to_week_base *)
let add_to_week_base cm w ps =
let wk = get_week cm w in
wk.wk_base <- IS.union ps wk.wk_base
;;
(* ***)
(*** unempty_delta *)
let unempty_delta cm w d =
let wk = get_week cm w in
wk.wk_deltas.(d) <- (match wk.wk_deltas.(d) with
| None -> Some IS.empty
| Some x -> Some x)
;;
(* ***)
(*** add_to_delta *)
let add_to_delta wk d ps =
wk.wk_deltas.(d) <- (match wk.wk_deltas.(d) with
None -> Some ps
| Some x -> Some (IS.union ps x))
;;
(* ***)
(*** range *)
let range cm =
let w0 = ref max_int
and w1 = ref min_int
in
(* We should have MAP.min_key, MAP.max_key *)
WM.iter
begin fun w _ ->
w0 := min w !w0;
w1 := max w !w1
end
cm.cm_weeks;
let w0 = !w0
and w1 = !w1
in
let wk0 = get_week cm w0
and wk1 = get_week cm w1
in
let j0 = julian_of_week w0
and j1 = julian_of_week w1
in
let j0 =
if IS.is_empty wk0.wk_base then
begin
let rec loop d =
assert (d < n);
match wk0.wk_deltas.(d) with
None -> loop (d + 1)
| Some _ -> j0 + d
in
loop 0
end
else
j0
and j1 =
if IS.is_empty wk1.wk_base then
begin
let rec loop d =
assert (d >= 0);
match wk1.wk_deltas.(d) with
None -> loop (d - 1)
| Some _ -> j1 + d
in
loop (n - 1)
end
else
j1 + n - 1
in
(j0,j1)
;;
(* ***)
(*** get *)
let get cm j =
let w = week_of_julian j in
let wk = get_week cm w in
let d = day_of_julian j in
match wk.wk_deltas.(d) with
None -> IS.empty
| Some x -> IS.union wk.wk_base x
;;
(* ***)
(*** add *)
let add cm j0 j1 p =
if j0 > j1 then
(* Empty range *)
()
else
begin
let w0 = week_of_julian j0
and w1 = week_of_julian j1
in
let d0 = day_of_julian j0
and d1 = day_of_julian j1
in
let wk0 = get_week cm w0 in
if w0 = w1 then
(* Single week *)
if d0 = 0 && d1 = n - 1 then
begin
(* Full week *)
add_to_week_base cm w0 p;
for d = d0 to d1 do
unempty_delta cm w0 d
done
end
else
(* Less than a week *)
for d = d0 to d1 do
add_to_delta wk0 d p
done
else
begin
(* Multi-weeks *)
(* Suffix of first week *)
if d0 = 0 then
begin
(* Present all this week: add to the week base. *)
add_to_week_base cm w0 p;
for d = 0 to 6 do
unempty_delta cm w0 d
done
end
else
(* Starts in the middle of the first week. Add to deltas. *)
for d = d0 to n - 1 do
(* Add to the deltas *)
add_to_delta wk0 d p
done;
(* Add to the base of intermediary weeks where it's present all the week *)
for w = w0 + 1 to w1 - 1 do
add_to_week_base cm w p;
for d = 0 to 6 do
unempty_delta cm w d
done
done;
(* Do last week *)
if d1 = n - 1 then
begin
(* Whole week *)
add_to_week_base cm w1 p;
for d = 0 to d1 do
unempty_delta cm w1 d
done
end
else
(* Ends in the middle of last week. *)
begin
let wk1 = get_week cm w1 in
for d = 0 to d1 do
add_to_delta wk1 d p
done
end
end
end
(* ***)
end
;;
(* ***)
(*** V *)
module V = Version_order;;
(* ***)
(*** Version_index *)
module Version_index = Version_pool(V);;
(* ***)
(*** R *)
module R = Release_order;;
(* ***)
(*** Release_index *)
module Release_index = Version_pool(R);;
(* ***)
(*** archive_name, ... *)
type archive_name = string;;
type architecture_name = string;;
type unit_name = string;;
type version_name = Version_index.version;;
type source_name = unit_name * version_name
type source_version_name = version_name;;
type version_number = Version_index.handle;;
type release_number = Release_index.handle;;
type version_id = Version_index.id;;
type release_id = Release_index.id;;
(* ***)
(*** Set_of_index(I *)
module Set_of_index(I : INDEXED) :
SET with type elt = I.id
=
struct
module S =
Set(struct
type t = I.id
let compare = I.compare_id
let io = I.io_id
let scribe = I.scribe_id
end)
include S
end
;;
(* ***)
(*** Archive_name *)
module Archive_name =
struct
type t = archive_name
let compare = compare
let scribe = scribe_string
let io = io_string
end
;;
(* ***)
(*** Architecture_name *)
module Architecture_name =
struct
type t = architecture_name
let compare = compare
let scribe = scribe_string
let io = io_string
end
;;
(* ***)
(*** Architecture_index *)
module Architecture_index = Index(Architecture_name);;
(* ***)
(*** Unit_name *)
module Unit_name =
struct
type t = unit_name
let compare = compare
let scribe = scribe_string
let io = io_string
end
;;
(* ***)
(*** Package_ID *)
module Package_ID :
ID
=
struct
type id = int;;
let to_int id = id;;
let from_int id = id;;
let compare (id1 : id) (id2 : id) = compare id1 id2;;
let succ id = id + 1;;
let zero = 0;;
let scribe cd oc id = cd.cd_print oc "<%d>" id;;
let io = io_int;;
let sweep id f =
for i = 0 to id - 1 do
f i
done
;;
end
;;
(* ***)
(*** Package_set *)
module Package_set =
Set(struct
include Package_ID
type t = Package_ID.id
end)
;;
(* ***)
type package_id = Package_ID.id;;
type package_set = Package_set.t;;
(*** Unit_data *)
module Unit_data =
struct
type t = {
mutable ud_packages : package_set; (* Package who have exactly this unit *)
mutable ud_providers : (package_id, version_number * release_number, glob) versioned list; (* Packages who potentially provide this unit *)
}
end
;;
(* ***)
(*** Unit_index *)
module Unit_index = Labeled_index(Unit_data)(Unit_name);;
(* ***)
(*** Unit_set *)
module Unit_set = Set_of_index(Unit_index);;
(* ***)
type unit_id = Unit_index.id;;
type unit_set = Unit_set.t;;
(*** Source_name *)
module Source_name =
struct
type t = unit_name * version_name
let compare = compare
let scribe cd oc (u,v) = cd.cd_print oc "%s`%s" u v
let io = io_pair io_string io_string
end
;;
(* ***)
(*** Source_index *)
module Source_index = Index(Source_name);;
(* ***)
(*** Source_set *)
module Source_set = Set_of_index(Source_index);;
(* ***)
type source_id = Source_index.id;;
type source_set = Source_set.t;;
type architecture_id = Architecture_index.id;;
type package_name = unit_id * version_id * release_id * architecture_id;;
(*** Chronology *)
module Chronology =
Chronological_Map(Package_set)(struct let n = 7 end);;
(* ***)
(* ***)
(*** Archives *)
type archive = {
ar_key : archive_name;
ar_contents : Chronology.t;
}
module Archive_index =
Labeled_index
(struct type t = archive end)
(Archive_name)
module Archive_set = Set_of_index(Archive_index);;
type archive_id = Archive_index.id
type archive_set = Archive_set.t
(* ***)
(*** package_extra *)
type package_extra =
{
px_conflict_cache : package_set Perishable.t; (** Packages that conflict with this one *)
}
;;
(* ***)
(*** package *)
type package =
(package_extra,
unit_id,
version_number * release_number,
glob,
architecture_id,
source_id)
Napkin.package
;;
(* ***)
(*** Package_index *)
module Package_index =
Double_index
(Package_ID)
(struct
type t = package_name
let compare = compare
let scribe cd oc _p = cd.cd_print oc ">"
let io = io_quadruple Unit_index.io_id Version_index.io_id Release_index.io_id Architecture_index.io_id
end)
(struct
type t = package
let compare = compare
let scribe cd oc _ = cd.cd_print oc ">"
let io = io_not_implemented
end)
;;
(* ***)
(*** db *)
type db = {
db_liquid : liquid option ref;
(* Main indexes *)
db_unit_index : Unit_index.t;
db_package_index : Package_index.t;
db_architecture_index : Architecture_index.t;
db_source_index : Source_index.t;
db_version_index : Version_index.t;
db_release_index : Release_index.t;
db_archive_index : Archive_index.t;
(* Universes *)
mutable db_packages : package_set;
mutable db_units : unit_set;
mutable db_sources : source_set;
mutable db_archives : archive_set;
(* Timestamp for perishable goods *)
db_time : int ref;
};;
(* ***)
let get_liquid db = !(db.db_liquid);;
let get_package_index db = db.db_package_index;;
let get_unit_index db = db.db_unit_index;;
let get_architecture_index db = db.db_architecture_index;;
let get_version_index db = db.db_version_index;;
let get_release_index db = db.db_release_index;;
let get_archive_index db = db.db_archive_index;;
let get_source_index db = db.db_source_index;;
let set_liquid db l = db.db_liquid := Some l;;
(*** split_version *)
let split_version (x: string): string * string option =
begin
try let hyphen_index = String.rindex x '-' in
let vstr = String.sub x 0 hyphen_index
and rstr = String.sub x (hyphen_index+1) ((String.length x)-hyphen_index-1) in
(vstr, if rstr = "" then None else Some rstr)
with Not_found -> try
Scanf.sscanf x "%s@nb%s" (fun v r -> (v, if r = "" then None else Some r))
with _ -> (x, None)
end;;
(* ***)
(*** register_version *)
let register_version db x =
let (v, r) = split_version x in
(Release_index.register db.db_release_index r,
Version_index.register db.db_version_index v)
;;
(* ***)
(*** register_unit *)
let register_unit db u =
Unit_index.register
db.db_unit_index
u
(fun () ->
{ Unit_data.ud_packages = Package_set.empty;
Unit_data.ud_providers = [] })
;;
(* ***)
(*** archive_index_watcher *)
let archive_index_watcher db u_id _ _ = db.db_archives <- Archive_set.add u_id db.db_archives;;
(* ***)
(*** unit_index_watcher *)
let unit_index_watcher db u_id _ _ = db.db_units <- Unit_set.add u_id db.db_units;;
(* ***)
(*** source_index_watcher *)
let source_index_watcher db s_id (u,v) =
ignore (register_unit db u);
ignore (register_version db v);
db.db_sources <- Source_set.add s_id db.db_sources;
;;
(* ***)
(*** package_index_watcher *)
let package_index_watcher db p_id _ = db.db_packages <- Package_set.add p_id db.db_packages;;
(* ***)
(*** create_database *)
let create_database () =
let db =
{ db_liquid = ref None;
db_unit_index = Unit_index.create ();
db_package_index = Package_index.create ();
db_architecture_index = Architecture_index.create ();
db_source_index = Source_index.create ();
db_version_index = Version_index.create ();
db_release_index = Release_index.create ();
db_archive_index = Archive_index.create ();
db_packages = Package_set.empty;
db_sources = Source_set.empty;
db_units = Unit_set.empty;
db_archives = Archive_set.empty;
db_time = ref 0 }
in
Unit_index.set_watcher db.db_unit_index (unit_index_watcher db);
Source_index.set_watcher db.db_source_index (source_index_watcher db);
Package_index.set_watcher db.db_package_index (package_index_watcher db);
Archive_index.set_watcher db.db_archive_index (archive_index_watcher db);
db
;;
(* ***)
(*** archive_range *)
let archive_range db ar = Chronology.range ar.ar_contents;;
(* ***)
(*** get_archive *)
let get_archive db archive_id = Archive_index.data db.db_archive_index archive_id;;
(* ***)
(*** get_archive_contents *)
let get_archive_contents ar day = Chronology.get ar.ar_contents day;;
(* ***)
(*** iterate_over_archive *)
let iterate_over_archive f ar = Chronology.iter f ar.ar_contents;;
(* ***)
(*** add_archive *)
let add_archive db archive_name =
Archive_index.register
db.db_archive_index
archive_name
begin fun () ->
{ ar_key = archive_name;
ar_contents = Chronology.create ();
}
end
(* ***)
(*** add_packages_to_archive *)
let add_packages_to_archive db ar set lf =
Lifetime.iterate_over_intervals
begin fun (j0,j1) ->
Chronology.add ar.ar_contents j0 j1 set
end
lf
;;
(* ***)
(*** name_of_package *)
let name_of_package db p =
(p.pk_unit, Version_index.get_id (fst p.pk_version), Release_index.get_id (snd p.pk_version), p.pk_architecture)
;;
(* ***)
(*** add_package *)
let add_package db (nk : Napkin.default_package) =
let px = {
px_conflict_cache = Perishable.create db.db_time;
}
in
let p =
Napkin.map
~extra:(fun _ -> px)
~unit:(register_unit db)
~version:(fun x ->
let (v, r) = split_version x in
Version_index.register db.db_version_index v,
Release_index.register db.db_release_index r)
~glob:(fun g -> g)
~architecture:(Architecture_index.register db.db_architecture_index)
~source:(Source_index.register db.db_source_index)
nk
in
let package_id =
Package_index.register
db.db_package_index
(name_of_package db p, p)
in
let ud = Unit_index.data db.db_unit_index p.pk_unit in
ud.Unit_data.ud_packages <- Package_set.add package_id ud.Unit_data.ud_packages;
List.iter
begin fun prv ->
match prv with
| Unit_version (unit_id', sel) -> let ud' = Unit_index.data db.db_unit_index unit_id' in
ud'.Unit_data.ud_providers <- Unit_version (package_id, sel) :: (ud'.Unit_data.ud_providers)
| Glob_pattern p -> raise (Invalid_argument "Glob_pattern in providers, bailing out")
end
(if !(db.db_liquid) = Some RPM then
p.pk_provides
else
((Unit_version (p.pk_unit, Sel_ANY)) :: p.pk_provides));
package_id
;;
(* ***)
(*** replace_package *)
let replace_package db p (* (nk : Napkin.default_package) *) =
let px = {
px_conflict_cache = Perishable.create db.db_time;
}
in
Package_index.replace
db.db_package_index
(name_of_package db p, p);
let package_id = Package_index.search1 db.db_package_index (name_of_package db p) in
List.iter
begin fun prv ->
match prv with
| Unit_version (unit_id', sel) -> let ud' = Unit_index.data db.db_unit_index unit_id' in
ud'.Unit_data.ud_providers <- Unit_version (package_id, sel) :: (ud'.Unit_data.ud_providers)
| Glob_pattern p -> raise (Invalid_argument "Glob_pattern in providers, bailing out")
end
(if !(db.db_liquid) = Some RPM then
p.pk_provides
else
((Unit_version (p.pk_unit, Sel_ANY)) :: p.pk_provides))
;;
(* ***)
(*** Functions *)
module Functions =
struct
(*** scribe_version_from_number *)
let scribe_version_from_number _db cd oc (v_n, r_n) =
let version_name = Version_index.get_version v_n
and release_name = Release_index.get_version r_n in
match release_name with
None -> cd.cd_print oc "'%s" version_name
| Some r -> cd.cd_print oc "'%s-%s" version_name r
;;
(* ***)
(*** scribe_archive_from_id *)
let scribe_archive_from_id db cd oc a_id =
let archive_name = Archive_index.find db.db_archive_index a_id in
cd.cd_print oc "%%%s" archive_name
;;
(* ***)
(*** scribe_unit_from_id *)
let scribe_unit_from_id db cd oc u_id =
let unit_name = Unit_index.find db.db_unit_index u_id in
cd.cd_print oc "%s" unit_name
;;
(* ***)
(*** scribe_source_from_id *)
let scribe_source_from_id db cd oc s_id =
let (unit_name, version_name) = Source_index.find db.db_source_index s_id in
cd.cd_print oc "%s`%s" unit_name version_name
;;
(* ***)
(*** scribe_package *)
let scribe_package db cd oc ?default_architecture p =
let scribe_rel r = match r with None -> "" | Some x -> ("-" ^ x) in
let unit_name = Unit_index.find db.db_unit_index p.pk_unit
and architecture = Architecture_index.find db.db_architecture_index p.pk_architecture
and version = Version_index.get_version (fst p.pk_version)
and release = Release_index.get_version (snd p.pk_version) in
match default_architecture with
| None -> cd.cd_print oc "%s'%s%s@%s" unit_name version (scribe_rel release) architecture
| Some a_id ->
if a_id = p.pk_architecture then
cd.cd_print oc "%s'%s%s" unit_name version (scribe_rel release)
else
cd.cd_print oc "%s'%s%s@%s" unit_name version (scribe_rel release) architecture
;;
(* ***)
(*** get_package_from_id *)
let get_package_from_id db p_id =
let (_,p) = Package_index.find db.db_package_index p_id in
p
;;
(* ***)
(*** scribe_package_from_id *)
let scribe_package_from_id db cd oc ?default_architecture p_id =
scribe_package db cd oc ?default_architecture (get_package_from_id db p_id);;
(* ***)
(*** unit_id_to_package_set *)
let unit_id_to_package_set db unit_id =
let ud = Unit_index.data db.db_unit_index unit_id in
ud.Unit_data.ud_packages
;;
(* ***)
(*** unit_id_to_providers *)
let unit_id_to_providers db unit_id =
let ud = Unit_index.data db.db_unit_index unit_id in
ud.Unit_data.ud_providers
;;
(* ***)
module PS = Package_set;;
(*** packages, units, sources *)
let packages db = db.db_packages;;
let units db = db.db_units;;
let sources db = db.db_sources;;
let archives db = db.db_archives;;
(* ***)
(*** select *)
let select db depspec =
begin
let vcmp = Version_index.compare_versions db.db_version_index
and rcmp = Release_index.compare_versions db.db_release_index in
let rpmcmp v1 r1 v2 r2 =
begin
if vcmp v1 v2 < 0 then -1
else if vcmp v1 v2 > 0 then 1
else (* vcmp v1 v2 = 0 *)
let rs1 = Release_index.get_version r1
and rs2 = Release_index.get_version r2 in
begin
if (rs1 = None) || (rs2 = None) then 0
else if rcmp r1 r2 < 0 then -1
else if rcmp r1 r2 > 0 then 1
else (* rcmp r1 r2 = 0 *) 0
end
end in
let rpmcheck asel gsel =
begin
match asel with
| Sel_ANY -> true
| Sel_LT (av, ar) ->
begin
match gsel with
| Sel_ANY | Sel_LT _ | Sel_LEQ _ -> true
| Sel_EQ (gv, gr) -> rpmcmp av ar gv gr > 0
| Sel_GEQ (gv, gr) -> rpmcmp av ar gv gr > 0
| Sel_GT (gv, gr) -> rpmcmp av ar gv gr > 0
end
| Sel_LEQ (av, ar) ->
begin
match gsel with
| Sel_ANY | Sel_LT _ | Sel_LEQ _ -> true
| Sel_EQ (gv, gr) -> rpmcmp av ar gv gr >= 0
| Sel_GEQ (gv, gr) -> rpmcmp av ar gv gr >= 0
| Sel_GT (gv, gr) -> rpmcmp av ar gv gr > 0
end
| Sel_EQ (av, ar) ->
begin
match gsel with
| Sel_ANY -> true
| Sel_LT (gv, gr) -> rpmcmp av ar gv gr < 0
| Sel_LEQ (gv, gr) -> rpmcmp av ar gv gr <= 0
| Sel_EQ (gv, gr) -> rpmcmp av ar gv gr = 0
| Sel_GEQ (gv, gr) -> rpmcmp av ar gv gr >= 0
| Sel_GT (gv, gr) -> rpmcmp av ar gv gr > 0
end
| Sel_GEQ (av, ar) ->
begin
match gsel with
| Sel_ANY | Sel_GEQ _ | Sel_GT _ -> true
| Sel_LT (gv, gr) -> rpmcmp av ar gv gr < 0
| Sel_LEQ (gv, gr) -> rpmcmp av ar gv gr <= 0
| Sel_EQ (gv, gr) -> rpmcmp av ar gv gr <= 0
end
| Sel_GT (av, ar) ->
begin
match gsel with
| Sel_ANY | Sel_GEQ _ | Sel_GT _ -> true
| Sel_LT (gv, gr) -> rpmcmp av ar gv gr < 0
| Sel_LEQ (gv, gr) -> rpmcmp av ar gv gr < 0
| Sel_EQ (gv, gr) -> rpmcmp av ar gv gr < 0
end
end in
let debcmp v1 r1 v2 r2 =
begin
if vcmp v1 v2 < 0 then -1
else if vcmp v1 v2 > 0 then 1
else (* vcmp v1 v2 = 0 *)
let rs1 = Release_index.get_version r1
and rs2 = Release_index.get_version r2 in
begin
if (rs1 = None) && (rs2 = None) then 0
else if rs1 = None then -1
else if rs2 = None then 1
else rcmp r1 r2
end
end in
let debcheck sel (gv, gr) =
begin
match sel with
| Sel_ANY -> true
| Sel_LT (av, ar) -> debcmp gv gr av ar < 0
| Sel_LEQ (av, ar) -> debcmp gv gr av ar <= 0
| Sel_EQ (av, ar) -> debcmp gv gr av ar = 0
| Sel_GEQ (av, ar) -> debcmp gv gr av ar >= 0
| Sel_GT (av, ar) -> debcmp gv gr av ar > 0
end in
let pscheck sel (gv, gr) =
begin
match sel with
| Sel_ANY -> true
| Sel_LT (av, ar) -> debcmp gv gr av ar < 0
| Sel_LEQ (av, ar) -> debcmp gv gr av ar <= 0
| Sel_EQ (av, ar) -> debcmp gv gr av ar = 0
| Sel_GEQ (av, ar) -> debcmp gv gr av ar >= 0
| Sel_GT (av, ar) -> debcmp gv gr av ar > 0
end in
if !(db.db_liquid) = (Some RPM) then
begin
match depspec with
| Unit_version (unit_id, selector) ->
let udata = Unit_index.data db.db_unit_index unit_id in
let pkgs = ref PS.empty in
List.iter
(fun d -> match d with
| Unit_version (p, ps) -> if rpmcheck selector ps then
pkgs := PS.add p !pkgs
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
)
udata.Unit_data.ud_providers;
!pkgs
| Glob_pattern _ -> raise (Failure "RPM does not support glob patterns")
end
else if !(db.db_liquid) = (Some Pkgsrc) then
begin
match depspec with
| Unit_version (unit_id, selector) ->
let udata = Unit_index.data db.db_unit_index unit_id in
let pkgs = ref PS.empty in
PS.iter
(fun p_id ->
let p = get_package_from_id db p_id in
if pscheck selector p.pk_version then
pkgs := PS.add p_id !pkgs
)
udata.Unit_data.ud_packages;
!pkgs
| Glob_pattern g ->
let vos u v rq =
match rq with
| None -> Printf.sprintf "%s-%s" u v
| Some r -> Printf.sprintf "%s-%snb%s" u v r in
let pkgs = ref PS.empty in
PS.iter
(fun p_id ->
let p = get_package_from_id db p_id in
let un = Unit_index.find db.db_unit_index p.pk_unit in
let vn = Version_index.get_version (fst p.pk_version) in
let rn = Release_index.get_version (snd p.pk_version) in
if fnmatch g (vos un vn rn) [FNM_PERIOD] then
pkgs := PS.add p_id !pkgs
)
db.db_packages;
!pkgs
end
else
begin
match depspec with
| Unit_version (unit_id, selector) ->
let udata = Unit_index.data db.db_unit_index unit_id in
begin
match selector with
| Sel_ANY ->
let pkgs = ref PS.empty in
List.iter
(fun d -> match d with
| Unit_version (p, _) -> pkgs := PS.add p !pkgs
| Glob_pattern _ -> raise (Failure "Only Pkgsrc supports glob patterns"))
udata.Unit_data.ud_providers;
!pkgs
| _ ->
let pkgs = ref PS.empty in
PS.iter
(fun p_id ->
let p = get_package_from_id db p_id in
if debcheck selector p.pk_version then
pkgs := PS.add p_id !pkgs)
udata.Unit_data.ud_packages;
!pkgs
end
| Glob_pattern _ -> raise (Failure "Only Pkgsrc supports glob patterns")
end
end;;
(* ***)
(*** conflicts *)
let conflicts db ps =
(* val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a *)
PS.fold
begin fun p_id set ->
let p = get_package_from_id db p_id in
List.fold_left
begin fun set versioned ->
PS.union set (select db versioned)
end
set
(p.pk_conflicts @ p.pk_breaks)
end
ps
PS.empty
;;
(* ***)
(*** dependency_closure *)
let dependency_closure db ?(relations=[`Pre;`Dep]) s =
let queue = ref s in
let visited = ref PS.empty in
while not (PS.is_empty !queue) do
let p_id = PS.choose !queue in
queue := PS.remove p_id !queue;
visited := PS.add p_id !visited;
let p = get_package_from_id db p_id in
let process =
List.iter
begin fun disjunction ->
List.iter
begin fun versioned ->
let ps = select db versioned in
PS.iter (fun p_id' ->
if not (PS.mem p_id' !visited) then
queue := PS.add p_id' !queue) ps
end
disjunction
end
in
List.iter
begin function
| `Pre -> process p.pk_pre_depends
| `Dep -> process p.pk_depends;
end
relations
done;
!visited
;;
(* ***)
(* ***)
let dependency_path ?(conjunctive=false) db ps p1 p2 =
let visited = ref Package_set.empty in
let rec visit todo preds =
begin
if Package_set.is_empty todo then None
else if Package_set.mem p2 todo then Some (List.rev (p2::preds))
else
begin
Package_set.fold (fun p acc ->
if Package_set.mem p !visited then acc
else
begin
visited := Package_set.add p !visited;
let pkg = get_package_from_id db p in
match acc with
| None ->
begin
let deps = List.fold_left (fun acc d ->
List.fold_left (fun acc' a ->
let pkgs = Package_set.inter (select db a) ps in
if conjunctive && Package_set.cardinal pkgs > 1
then acc'
else Package_set.union acc' pkgs
) acc d
) Package_set.empty (pkg.pk_depends @ pkg.pk_pre_depends) in
visit deps (p::preds)
end
| Some a -> Some a
end
) todo None
end
end in
begin
visit (Package_set.singleton p1) []
end;;
end;;
(*** self_test *)
let self_test db =
let cd = stdoutcd in
let oc = cd.cd_out_channel in
let vp = db.db_version_index in
Printf.printf "Versions:\n";
Version_index.iter vp
begin fun vh ->
let v = Version_index.get_version vh
and id = Version_index.get_id vh
in
cd.cd_print oc " %s %a\n" v (Version_index.scribe_id cd) id
end;
Printf.printf "Units:\n";
Unit_index.iter db.db_unit_index
begin fun id u _ ->
cd.cd_print oc " %s %a\n" u (Unit_index.scribe_id cd) id
end;
Printf.printf "Architectures:\n";
Architecture_index.iter db.db_architecture_index
begin fun id a ->
cd.cd_print oc " %s %a\n" a (Architecture_index.scribe_id cd) id
end;
Printf.printf "Packages:\n";
Package_index.iter db.db_package_index
begin fun id ((unit_id, version_id, release_id, architecture_id), p) ->
let unit_name = Unit_index.find db.db_unit_index unit_id
and architecture_name = Architecture_index.find db.db_architecture_index architecture_id
and version = Version_index.get_version (Version_index.find db.db_version_index version_id)
and release = Release_index.get_version (Release_index.find db.db_release_index release_id) in
cd.cd_print oc " %s'%s%s on %s\n" unit_name version (match release with None -> "" | Some x -> ("-" ^ x)) architecture_name;
let unit_id' = Unit_index.search db.db_unit_index unit_name in
let architecture_id' = Architecture_index.search db.db_architecture_index architecture_name in
let version_id' = Version_index.get_id (Version_index.search db.db_version_index version) in
let release_id' = Release_index.get_id (Release_index.search db.db_release_index release) in
let id' = Package_index.search1 db.db_package_index (unit_id', version_id', release_id', architecture_id') in
cd.cd_print oc " id=%a id'=%a\n" (Package_index.scribe_id cd) id (Package_index.scribe_id cd) id';
cd.cd_print oc "%!";
end;
;;
(* ***)
dose2-1.4.2/rapids/rapids.mli 0000664 0000000 0000000 00000032050 11231374124 0015777 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** Random Access Package Information Data Structure.
Provides a fast, indexed archive for working on historical metadata archives expressed in the NAPKIN format.
*)
open Lifetime
open Napkin
(** This exception is raised if the database gets non-unifiable, conflicting pieces
of information. *)
exception Conflicting_information of string
type liquid = RPM | Debian | Pkgsrc
module type ORDERED_LITERATE =
sig
type t
val compare : t -> t -> int
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : t Io.literate
end
module type STRING_ORDERED_LITERATE =
sig
type t = string
val compare : t -> t -> int
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : string Io.literate
end
module Version_order :
sig
type t = string
val compare : t -> t -> int
val set_comparator : (t -> t -> int) -> unit
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : string Io.literate
end
module Release_order :
sig
type t = string option
val compare : t -> t -> int
val set_comparator : (t -> t -> int) -> unit
val scribe : 'a Conduit.conduit -> 'a -> t -> unit
val io : string option Io.literate
end
module type SET =
sig
include Set.S
val io : t Io.literate
end
module type ID =
sig
type id
val to_int : id -> int
val from_int : int -> id
val compare : id -> id -> int
val succ : id -> id
val scribe : 'a Conduit.conduit -> 'a -> id -> unit
val zero : id
val sweep : id -> (id -> unit) -> unit
val io : id Io.literate
end
module type INDEX =
sig
type elt
type id
type t
val create : unit -> t
val register : t -> elt -> id
val search : t -> elt -> id
val find : t -> id -> elt
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id Io.literate
val iter : t -> (id -> elt -> unit) -> unit
val set_watcher : t -> (id -> elt -> unit) -> unit
end
module type DOUBLE_INDEX =
sig
type e1
type e2
type elt = e1 * e2
type id
type t
val create : unit -> t
val register : t -> elt -> id
val replace : t -> elt -> unit
val find : t -> id -> elt
val search1 : t -> e1 -> id
val search2 : t -> e2 -> id
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val iter : t -> (id -> elt -> unit) -> unit
val set_watcher : t -> (id -> elt -> unit) -> unit
end
module type VERSION_POOL =
sig
type version
type handle
type id
type t
val create : unit -> t
val register : t -> version -> handle
val search : t -> version -> handle
val compare_versions : t -> handle -> handle -> int
val find : t -> id -> handle
val get_version : handle -> version
val get_id : handle -> id
val iter : t -> (handle -> unit) -> unit
(*val set_watcher : t -> (handle -> unit) -> unit*)
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id Io.literate
end
module type LABELED_INDEX =
sig
type data
type elt
type id
type t
val create : unit -> t
val register : t -> elt -> (unit -> data) -> id
val search : t -> elt -> id
val find : t -> id -> elt
val data : t -> id -> data
val compare_id : id -> id -> int
val scribe_id : 'a Conduit.conduit -> 'a -> id -> unit
val io_id : id Io.literate
val iter : t -> (id -> elt -> data -> unit) -> unit
val set_watcher : t -> (id -> elt -> data -> unit) -> unit
end
module type CHRONOLOGICAL_MAP =
sig
type t
type set
type elt
type day = int
val io : t Io.literate
val create : unit -> t
val iter : (day -> set -> unit) -> t -> unit
val range : t -> day * day
val get : t -> day -> set
val add : t -> day -> day -> set -> unit
end
(** An archive name is a list of strings intended to identify
* a component such as debian/stable/main/i386 by a list like
* [["debian";"stable";"main";"i386"]]. However it is up to the user to enforce
* constraints such as homogeneity of a given archive with respect to architecture. *)
type archive_name = string
type architecture_name = string
type unit_name = string
type version_name = string
type source_name = unit_name * version_name
type source_version_name = version_name
(** A comparable version number *)
type version_number
type release_number
(** The following are opaque, but unique IDs *)
type version_id
type release_id
type unit_id
type source_id
type architecture_id
type package_id
type archive_id
(* Globs are stored as strings for the moment *)
type glob = string
(** An archive is a map from dates to sets of packages. *)
type archive
(** Architectures, units and versions are indexed for reducing memory usage and allowing
* for fast set operations. These modules contain [Set] modules, scribeers and [Io] literates. *)
module Architecture_name : ORDERED_LITERATE with type t = architecture_name
module Architecture_index : INDEX with type elt = architecture_name and type id = architecture_id
module Unit_name : ORDERED_LITERATE with type t = unit_name
module Package_ID : ID with type id = package_id
module Package_set : SET with type elt = package_id
module Unit_index : LABELED_INDEX with type elt = unit_name and type id = unit_id
module Unit_set : SET with type elt = unit_id
module Source_name : ORDERED_LITERATE with type t = source_name
module Source_index : INDEX with type elt = source_name and type id = source_id
module Source_set : SET with type elt = source_id
module Version_index : VERSION_POOL with type version = string and type id = version_id and type handle = version_number
module Release_index : VERSION_POOL with type version = string option and type id = release_id and type handle = release_number
module Archive_index : LABELED_INDEX with type elt = archive_name and type data = archive and type id = archive_id
module Archive_set : SET with type elt = archive_id
(** A package is uniquely identified by its unit, version and architecture.
We use IDs for speed. *)
type package_name = unit_id * version_id * release_id * architecture_id;;
(** Extra private information (cached results and other things) *)
type package_extra
(** A package is essentially a Napkin with strings replaced by IDs for efficiency. *)
type package =
(package_extra,
unit_id,
version_number * release_number,
glob,
architecture_id,
source_id)
Napkin.package
;;
(** The database contains a ``double index'' for packages, the first is for
mapping package names to package IDs. *)
module Package_index : DOUBLE_INDEX with
type e1 = package_name and
type e2 = package and
type id = package_id
(** Handy aliases. *)
type package_set = Package_set.t
type unit_set = Unit_set.t
type source_set = Source_set.t
type archive_set = Archive_set.t
(** The [Chronology] module efficiently maps days to sets of packages. *)
module Chronology : CHRONOLOGICAL_MAP with type elt = Package_ID.id and type set = Package_set.t
(** A RAPIDS database. *)
type db
(** Create a fresh database. *)
val create_database : unit -> db
(** Add the given napkin into the database and return its ID. This operation is
idempotent -- if the napkin is already interned, it does no harm and returns the correct package ID with an
efficient lookup, provided the information in the given and stored napkins coincide. If not, a
[Conflicting_information] exception is raised. If the package had only its name interned, this will fill the
package's napkin. *)
val add_package : db -> Napkin.default_package -> package_id
(** Replace a package in the database. If the package did not already exist,
it will be added. *)
val replace_package: db -> package -> unit
(** Run a series of self-tests on the database, which must have been previously filled. *)
val self_test : db -> unit
(** The following functions return the various indexes from the database. *)
val get_liquid : db -> liquid option
val get_package_index : db -> Package_index.t
val get_unit_index : db -> Unit_index.t
val get_version_index : db -> Version_index.t
val get_release_index : db -> Release_index.t
val get_architecture_index : db -> Architecture_index.t
val get_archive_index : db -> Archive_index.t
val get_source_index : db -> Source_index.t
val set_liquid : db -> liquid -> unit
val split_version: string -> string * string option
(** Register an archive. Efficient and idempotent. *)
val add_archive : db -> archive_name -> archive_id
(** Get an archive *)
val get_archive : db -> archive_id -> archive
(** Get the contents of an archive on a given day *)
val get_archive_contents : archive -> day -> package_set
(** Iterate over the days of an archive *)
val iterate_over_archive : (day -> package_set -> unit) -> archive -> unit
(** Get the first and last days for which this archive contains packages. *)
val archive_range : db -> archive -> day * day
(** Add the given packages to the archive for the given days. *)
val add_packages_to_archive : db -> archive -> package_set -> lifetime -> unit
(*
(** Create a copy of the database *)
val copy : db -> db
(** Create a copy of the database limited to the given date range. *)
val limit_to_dates : db -> day -> day -> db
(** Create a copy of the database limited to the given archives. *)
val limit_to_archives : db -> archive_name list -> db
(** Intern the given package into the database and return its ID. This function is idempotent
and is also used as an efficient way to look up a package's ID. *)
val intern_package_name : db -> unit_name:string -> version_name:string -> architecture_name:string -> package_id
(** Intern a unit name. *)
val intern_unit : db -> string -> unit_id
*)
module Functions :
sig
val packages : db -> package_set (** Return the set of all packages *)
val units : db -> unit_set (** Return the set of all units *)
val sources : db -> source_set (** Return the set of all sources *)
val archives : db -> archive_set (** Return the set of all archives *)
val unit_id_to_package_set : db -> unit_id -> package_set (** Return the set of packages matching a unit *)
val unit_id_to_providers : db -> unit_id -> (package_id, version_number * release_number, glob) versioned list (** Return the set of packages providing a unit *)
(** Return the set of packages matching a selector *)
val select : db -> (Unit_index.id, Version_index.handle * Release_index.handle, string) Napkin.versioned -> package_set
(** Compute the forward dependencies closure of a given set of packages on the relation
in the list relations: [`Pre] is for the pre-dependency relation,
[`Dep] is for the dependency relation. *)
val dependency_closure : db -> ?relations:[`Pre|`Dep] list -> package_set -> package_set
(** Compute a dependency path in package_set from a to b (if it does not
exist, raise Not_found *)
val dependency_path: ?conjunctive:bool -> db -> package_set -> package_id -> package_id -> package_id list option
(** Compute the set of packages that conflict with a given set. *)
val conflicts : db -> package_set -> package_set
(** Return a package from its ID. *)
val get_package_from_id : db -> package_id -> package
(** Scribes *)
(** Scribe the name of a package, omitting the architecture if it
is the default one. *)
val scribe_package :
db -> 'a Conduit.conduit -> 'a -> ?default_architecture:architecture_id -> package -> unit
(** Scribe the name of a package from its ID, omitting the architecture if it
is the default one. *)
val scribe_package_from_id :
db -> 'a Conduit.conduit -> 'a -> ?default_architecture:architecture_id -> package_id-> unit
val scribe_unit_from_id :
db -> 'a Conduit.conduit -> 'a -> unit_id -> unit (** Scribe the name of a unit from its ID *)
val scribe_archive_from_id :
db -> 'a Conduit.conduit -> 'a -> archive_id -> unit (** Scribe the name of a archive from its ID *)
val scribe_source_from_id :
db -> 'a Conduit.conduit -> 'a -> source_id -> unit (** Scribe the name of a source from its ID *)
val scribe_version_from_number :
db -> 'a Conduit.conduit -> 'a -> version_number * release_number -> unit (** Scribe the name of a version from its number *)
end
dose2-1.4.2/rapids/waterway.ml 0000664 0000000 0000000 00000024667 11231374124 0016226 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Napkin
open Rapids
module R = Rapids
module DBI = Dosebase.In
;;
type waterway = File of string | Directory of string | Dose of string
type specification = (liquid * waterway) list
;;
(*** specification_of_string *)
let specification_of_string u =
let sl = Util.split_at ',' u in
List.map
begin fun v ->
let (lq,fn) = Util.split_once_at ((=) ':') v in
match lq with
| "dose" -> let tp = DBI.get_type (DBI.open_in fn) in
(match tp with
"debian" -> (Debian, Dose fn)
| "rpm" -> (RPM, Dose fn)
| "pkgsrc" -> (Pkgsrc, Dose fn)
| f -> invalid_arg (Printf.sprintf "Unknown dosebase type %s\n" f))
| "deb" -> (Debian, File fn)
| "rpm" -> (RPM, File fn)
| "ps" -> (Pkgsrc, File fn)
| _ -> invalid_arg (Printf.sprintf "Bad waterway specification %S" lq)
end
sl
;;
(* ***)
(*** mode_of_specification *)
let mode_of_specification sl =
let mode = ref None in
List.iter
begin fun (lq, _) ->
match (lq, !mode) with
| (Debian, (None|Some Debian)) -> mode := Some Debian
| (RPM, (None|Some RPM)) -> mode := Some RPM
| (Pkgsrc, (None|Some Pkgsrc)) -> mode := Some Pkgsrc
| (_,_) -> invalid_arg "Different package types do not mix"
end
sl;
!mode
;;
(* ***)
(*** load_from_dosebase *)
(* load_from_dosebase ignores overlay, because packages are in archives
* anyway *)
let load_from_dosebase db (progress : Progress.indicator) ~(overlay: bool) base =
let dbi = DBI.open_in base in
let lifetimes = ref [] in
let pop = DBI.count_population dbi in
let count = ref 0 in
DBI.iter
~package:
begin fun ~unit_name ~version ~architecture package ->
incr count;
progress#display (!count,pop);
let nk = Dosebase.napkin_of_fields (DBI.get_field_first dbi package) in
ignore (add_package db nk)
end
~lifetime:
begin fun ~archive ~unit_name ~version ~architecture lifetime ->
lifetimes := (unit_name, version, architecture, archive, lifetime) :: !lifetimes
end
dbi;
let unit_index = get_unit_index db in
let architecture_index = get_architecture_index db in
let version_index = get_version_index db in
let release_index = get_release_index db in
let package_index = get_package_index db in
List.iter
begin fun (unit_name, version, architecture, archive_name, lifetime) ->
let unit_id = Unit_index.search unit_index unit_name in
let architecture_id = Architecture_index.search architecture_index architecture in
let v, r = Rapids.split_version version in
let version_id = Version_index.get_id (Version_index.search version_index v) in
let release_id = Release_index.get_id (Release_index.search release_index r) in
let package_id = Package_index.search1 package_index (unit_id, version_id, release_id, architecture_id) in
let archive_id = add_archive db archive_name in
let archive = get_archive db archive_id in
add_packages_to_archive
db
archive
(Package_set.singleton package_id)
lifetime
end
!lifetimes;
DBI.close_in dbi
;;
(* ***)
(*** load_from_debian *)
let load_from_debian db (progress : Progress.indicator) ~(overlay: bool) fn =
let ps = Ocamldeb.read_pool_file fn progress in
if not (Ocamldeb.detect_pre_dependency_cycle ps) then
let n = ref 1 in
let nr_pkgs = List.length ps in
begin
progress#set_label "Adding...";
List.iter (fun (p: Napkin.default_package) ->
progress#display (!n, nr_pkgs);
if overlay then
begin
let ps = Functions.unit_id_to_package_set db (Unit_index.search (get_unit_index db) p.pk_unit) in
Package_set.iter (fun p' ->
let pkg' = Functions.get_package_from_id db p' in
let (v', r') = pkg'.pk_version in
Printf.printf "Should replace %s%s by %s.\n" (Version_index.get_version v')
(match Release_index.get_version r' with None -> "" | Some x -> "-"^x) p.pk_version
) ps
end ;
ignore (add_package db p);
incr n
) ps
end
else
prerr_endline "There is a pre-dependency cycle."
;;
(* ***)
(*** load_from_rpm *)
let load_from_rpm db (progress : Progress.indicator) ?(add_file_conflicts=true) ~(overlay:bool) fn =
begin
let ps =
if Util.string_contains fn "synthesis" then
Ocamlrpm.read_synthesis_hdlist fn
else
begin
let hl = Ocamlrpm.add_file_provides progress (Ocamlrpm.read_hdlist "" fn) in
if add_file_conflicts then Ocamlrpm.add_file_conflicts progress hl else hl
end in
List.iter (fun p -> try
(* if overlay then
begin
let u_id = Unit_index.search (get_unit_index db) p.pk_unit in
let ps = Functions.unit_id_to_package_set db u_id in
Package_set.iter (fun p' ->
let pkg' = Functions.get_package_from_id db p' in
let (v', r') = pkg'.pk_version in
Printf.printf "Replacing %s: %s%s -> %s.\n" p.pk_unit (Version_index.get_version v')
(match Release_index.get_version r' with None -> "" | Some x -> "-"^x) p.pk_version;
let new_p = Napkin.map
~extra:(fun _ -> pkg'.pk_extra)
~unit:(fun _ -> u_id)
~version:(fun x -> let (v, r) = split_version x in
Version_index.register (get_version_index db) v,
Release_index.register (get_release_index db) r)
~glob:(fun g -> g)
~architecture:(Architecture_index.register (get_architecture_index db))
~source:(Source_index.register (get_source_index db))
p in
replace_package db new_p
) ps
end; *)
ignore (add_package db (to_default_package p))
with Failure s ->
Printf.eprintf "Error while adding package %s: %s\n%!" p.pk_unit s) ps;
end;;
(* ***)
(*** load_from_pkgsrc *)
let load_from_pkgsrc db (progress : Progress.indicator) ~(overlay:bool) fn =
let ps = Ocamlpkgsrc.read_summary_file fn in
List.iter (fun p -> try
ignore (add_package db (to_default_package p))
with Failure s ->
Printf.eprintf "Error while adding package %s: %s\n%!" p.pk_unit s) ps
;;
(* ***)
(*** adjust_comparator *)
let adjust_comparator db sl =
match mode_of_specification sl with
| None -> ()
| Some Debian ->
begin
match get_liquid db with
None -> (set_liquid db Debian;
Version_order.set_comparator Ocamldeb.compare_versions;
Release_order.set_comparator (fun c1 c2 ->
match (c1, c2) with
| (None, None) -> 0
| (None, _) -> 1
| (_, None) -> -1
| (Some x1, Some x2) -> Ocamldeb.compare_versions x1 x2
))
| Some Debian -> ()
| Some RPM -> invalid_arg "Debian and RPM do not match"
| Some Pkgsrc -> invalid_arg "Debian and pkgsrc do not match"
end
| Some RPM ->
begin
match get_liquid db with
None -> (set_liquid db RPM;
Version_order.set_comparator Ocamlrpm.compare_versions;
Release_order.set_comparator (fun c1 c2 ->
match (c1, c2) with
| (None, None) -> 0
| (None, _) -> 1
| (_, None) -> -1
| (Some x1, Some x2) -> Ocamlrpm.compare_versions x1 x2
))
| Some RPM -> ()
| Some Debian -> invalid_arg "RPM and Debian do not match"
| Some Pkgsrc -> invalid_arg "RPM and pkgsrc do not match"
end
| Some Pkgsrc ->
begin
match get_liquid db with
None -> (set_liquid db Pkgsrc;
Version_order.set_comparator Ocamlpkgsrc.compare_versions;
Release_order.set_comparator (fun c1 c2 ->
match (c1, c2) with
| (None, None) -> 0
| (None, _) -> 1
| (_, None) -> -1
| (Some x1, Some x2) -> Ocamlpkgsrc.compare_versions x1 x2
))
| Some Pkgsrc -> ()
| Some Debian -> invalid_arg "Pkgsrc and Debian do not match"
| Some RPM -> invalid_arg "Pkgsrc and RPM do not match"
end
;;
(*** complete conflicts *)
let complete_conflicts db (progress: Progress.indicator) =
let pkgs = Functions.packages db in
let i = ref 0 in
let n = Package_set.cardinal pkgs in
begin
progress#set_label "Completing conflicts...";
Package_set.iter (fun p ->
let pkg = Functions.get_package_from_id db p in
progress#display (!i, n);
List.iter (fun c ->
Package_set.iter (fun p' ->
let pkg' = Functions.get_package_from_id db p' in
if not (Package_set.mem p
(List.fold_left Package_set.union Package_set.empty (List.map (Functions.select db) pkg'.pk_conflicts))) then
let new_pkg' = { pkg' with pk_conflicts = (Unit_version (pkg.pk_unit, Sel_EQ pkg.pk_version))::pkg'.pk_conflicts } in
replace_package db new_pkg'
) (Functions.select db c)
) pkg.pk_conflicts;
incr i
) (Functions.packages db)
end;;
(* ***)
(*** merge *)
let merge db ?progress ?(add_file_conflicts=true) ?(overlay=false) sl =
let p = match progress with
| None -> new Progress.indicator ~decimation:1000 ~label:"Merging..." ~channel:stderr ()
| Some pr -> pr in
adjust_comparator db sl;
p#start;
List.iter
begin function
| (_, Dose base) -> load_from_dosebase db p ~overlay base
| (Debian, File fn) -> load_from_debian db p ~overlay fn
| (RPM, File fn) -> load_from_rpm db p ~add_file_conflicts ~overlay fn
| (Pkgsrc, File fn) -> load_from_pkgsrc db p ~overlay fn
| (_, _) -> invalid_arg "Unsupported waterway"
end
sl;
complete_conflicts db p;
p#finish
;;
(* ***)
(*** perform *)
let perform sl handle =
let db = create_database () in
let progress = new Progress.indicator ~decimation:1000 ~label:"Loading" ~channel:stderr () in
progress#start;
List.iter
begin function
| (_, Dose base) -> load_from_dosebase db progress ~overlay:false base
(* | (Debian, File fn) -> load_from_debian db progress fn *)
| (_, _) -> invalid_arg "Unsupported waterway"
end
sl;
progress#finish;
handle db
;;
(* ***)
(*** with_database *)
(* let with_database sl handle =
adjust_comparator sl;
perform sl handle
;; *)
(* ***)
dose2-1.4.2/rapids/waterway.mli 0000664 0000000 0000000 00000004166 11231374124 0016367 0 ustar 00root root 0000000 0000000 (* Copyright 2005-2008 Berke DURAK, INRIA Rocquencourt, Jaap BOENDER.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
(** Glues RAPIDS and various parser modules to provide a convenient way of loading
a RAPIDS database. *)
(** A waterway is a way to get the liquid we are interested in. This can be in
a DOSEbase(TM), a file (which will be a Debian APT list or an hdlist), or a
structured collection of such files. *)
type waterway = File of string | Directory of string | Dose of string
(** It is possible to load multiple waterways at once, provided they have the same liquid.
This is given as a list, whose components must all have the same [liquid]. Yes, this
could have been factored but it is not very important and simpler that way. *)
type specification = (Rapids.liquid * waterway) list
(** The textual representation of a specifications is a comma-separated list as below:
(deb|dose|rpm|doserpm):filename(,(deb|dose|rpm|doserpm):filename)*
For example:
dose:/tmp/dose,deb:/var/lib/apt/lists/ftp.fr.debian.org_debian_dists_testing_main_binary-i386_Packages
is a valid specification. *)
val specification_of_string : string -> specification
(** Merge a waterway into the given database. *)
val merge : Rapids.db -> ?progress:Progress.indicator ->
?add_file_conflicts:bool -> ?overlay:bool -> specification -> unit
(** Call [with_database sl handler] where [sl]
is a waterstream specification and [handler] is your function. *)
(* val with_database : specification -> (Rapids.db -> unit) -> unit *)
dose2-1.4.2/satsolver/ 0000775 0000000 0000000 00000000000 11231374124 0014552 5 ustar 00root root 0000000 0000000 dose2-1.4.2/satsolver/.depend 0000664 0000000 0000000 00000000075 11231374124 0016014 0 ustar 00root root 0000000 0000000 solver.cmo: solver.cmi
solver.cmx: solver.cmi
solver.cmi:
dose2-1.4.2/satsolver/Makefile 0000664 0000000 0000000 00000000162 11231374124 0016211 0 ustar 00root root 0000000 0000000 # Makefile
NAME= satsolver
SOURCES= solver.ml
MLIS= solver.mli
include ../Makefile.config
include .depend
dose2-1.4.2/satsolver/README 0000664 0000000 0000000 00000000263 11231374124 0015433 0 ustar 00root root 0000000 0000000 Credits
=======
This SAT solver was written by Jerome Vouillon
(Jerome.Vouillon@pps.jussieu.fr).
and extracted from his program "debcheck".
The API was improved by Berke Durak.
dose2-1.4.2/satsolver/depend 0000664 0000000 0000000 00000000060 11231374124 0015730 0 ustar 00root root 0000000 0000000 solver.cmo: solver.cmi
solver.cmx: solver.cmi
dose2-1.4.2/satsolver/solver.ml 0000664 0000000 0000000 00000036543 11231374124 0016431 0 ustar 00root root 0000000 0000000 (* Copyright (C) 2005 Jerome Vouillon.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
let debug = ref false
module type S = sig
type reason
end
module M (X : S) = struct
(* Variables *)
type var = int
(* Literals *)
type lit = int
(* A clause is an array of literals *)
type clause =
{ lits : lit array;
reasons : X.reason list }
type value = True | False | Unknown
type state =
{ (* Indexed by var *)
st_assign : value array;
st_reason : clause option array;
st_level : int array;
st_seen_var : int array;
st_refs : int array;
st_pinned : bool array;
(* Indexed by lit *)
st_simpl_prop : (lit * clause) list array;
st_watched : clause list array;
st_associated_vars : var list array;
(* Queues *)
mutable st_trail : lit list;
mutable st_trail_lim : lit list list;
st_prop_queue : lit Queue.t;
(* Misc *)
mutable st_cur_level : int;
mutable st_min_level : int;
mutable st_seen : int;
mutable st_var_queue_head : var list;
st_var_queue : var Queue.t;
mutable st_cost : int; (* Total computational cost so far *)
st_print_var : Format.formatter -> int -> unit;
mutable st_coherent : bool }
let copy_clause p =
let n = Array.length p in
let a = Array.make n None in
Array.iteri (fun i c ->
let copy = function
|None -> None
|Some cl -> Some ({ cl with lits = Array.copy cl.lits })
in
Array.set a i (copy c)
) p
;
a
let copy_simpl_prop p =
let n = Array.length p in
let a = Array.make n [] in
Array.iteri (fun i l ->
let copy cl = { cl with lits = Array.copy cl.lits } in
let l' = List.map (fun (lit,clause) -> (lit,copy clause)) l in
Array.set a i l'
) p
;
a
let copy_watched p =
let n = Array.length p in
let a = Array.make n [] in
Array.iteri (fun i l ->
let copy cl = { cl with lits = Array.copy cl.lits } in
let l' = List.map (fun clause -> copy clause) l in
Array.set a i l'
) p
;
a
let copy st =
{ st_assign = Array.copy st.st_assign;
st_reason = copy_clause st.st_reason;
st_level = Array.copy st.st_level;
st_seen_var = Array.copy st.st_seen_var;
st_refs = Array.copy st.st_refs;
st_pinned = Array.copy st.st_pinned;
st_simpl_prop = copy_simpl_prop st.st_simpl_prop;
st_watched = copy_watched st.st_watched;
st_associated_vars = Array.copy st.st_associated_vars;
st_trail = st.st_trail;
st_trail_lim = st.st_trail_lim;
st_prop_queue = Queue.copy st.st_prop_queue;
st_cur_level = st.st_cur_level;
st_min_level = st.st_min_level;
st_seen = st.st_seen;
st_var_queue_head = st.st_var_queue_head;
st_var_queue = Queue.copy st.st_var_queue;
st_cost = st.st_cost;
st_print_var = st.st_print_var;
st_coherent = st.st_coherent }
(****)
let charge st x = st.st_cost <- st.st_cost + x
let get_bill st = st.st_cost
(****)
let pin_var st x = st.st_pinned.(x) <- true
let unpin_var st x = st.st_pinned.(x) <- false
let enqueue_var st x =
charge st 1;
pin_var st x;
Queue.push x st.st_var_queue
let requeue_var st x =
pin_var st x;
st.st_var_queue_head <- x :: st.st_var_queue_head
(* Returns -1 if no variable remains *)
let rec dequeue_var st =
let x =
match st.st_var_queue_head with
x :: r -> st.st_var_queue_head <- r; x
| [] -> try Queue.take st.st_var_queue with Queue.Empty -> -1
in
if x = -1 then x else begin
unpin_var st x;
if st.st_refs.(x) = 0 || st.st_assign.(x) <> Unknown then
dequeue_var st
else
x
end
(****)
let var_of_lit p = p lsr 1
let pol_of_lit p = p land 1 = 0
let lit_of_var v s = if s then v + v else v + v + 1
let lit_neg p = p lxor 1
let val_neg v =
match v with
True -> False
| False -> True
| Unknown -> Unknown
let val_of_bool b = if b then True else False
let val_of_lit st p =
let v = st.st_assign.(var_of_lit p) in
if pol_of_lit p then v else val_neg v
(****)
let print_val ch v =
Format.fprintf ch "%s"
(match v with True -> "True" | False -> "False" | Unknown -> "Unknown")
let print_lits st ch lits =
Format.fprintf ch "{";
Array.iter
(fun p ->
if pol_of_lit p then
Format.fprintf ch " +%a" st.st_print_var (var_of_lit p)
else
Format.fprintf ch " -%a" st.st_print_var (var_of_lit p))
lits;
Format.fprintf ch " }"
let print_rule st ch r = print_lits st ch r.lits
(****)
exception Conflict of clause option
let enqueue st p reason =
charge st 1;
if !debug then begin
match reason with
Some r -> Format.eprintf "Applying rule %a@." (print_rule st) r
| _ -> ()
end;
match val_of_lit st p with
False ->
if !debug then begin
if pol_of_lit p then
Format.eprintf "Cannot install %a@." st.st_print_var (var_of_lit p)
else
Format.eprintf "Already installed %a@."
st.st_print_var (var_of_lit p)
end;
raise (Conflict reason)
| True ->
()
| Unknown ->
if !debug then begin
if pol_of_lit p then
Format.eprintf "Installing %a@." st.st_print_var (var_of_lit p)
else
Format.eprintf "Should not install %a@."
st.st_print_var (var_of_lit p);
end;
let x = var_of_lit p in
st.st_assign.(x) <- val_of_bool (pol_of_lit p);
st.st_reason.(x) <- reason;
st.st_level.(x) <- st.st_cur_level;
st.st_trail <- p :: st.st_trail;
List.iter
(fun x ->
charge st 1;
let refs = st.st_refs.(x) in
if refs = 0 then enqueue_var st x;
st.st_refs.(x) <- st.st_refs.(x) + 1)
st.st_associated_vars.(p);
Queue.push p st.st_prop_queue
let rec find_not_false st lits i l =
if i = l then -1 else
if val_of_lit st lits.(i) <> False then i else
find_not_false st lits (i + 1) l
let propagate_in_clause st r p =
charge st 1;
let p' = lit_neg p in
if r.lits.(0) = p' then begin
r.lits.(0) <- r.lits.(1);
r.lits.(1) <- p'
end;
if val_of_lit st r.lits.(0) = True then
st.st_watched.(p) <- r :: st.st_watched.(p)
else begin
let i = find_not_false st r.lits 2 (Array.length r.lits) in
if i = -1 then begin
st.st_watched.(p) <- r :: st.st_watched.(p);
enqueue st r.lits.(0) (Some r)
end else begin
r.lits.(1) <- r.lits.(i);
r.lits.(i) <- p';
let p = lit_neg r.lits.(1) in
st.st_watched.(p) <- r :: st.st_watched.(p)
end
end
let propagate st =
try
while not (Queue.is_empty st.st_prop_queue) do
charge st 1;
let p = Queue.take st.st_prop_queue in
List.iter (fun (p, r) -> enqueue st p (Some r)) st.st_simpl_prop.(p);
let l = ref (st.st_watched.(p)) in
st.st_watched.(p) <- [];
begin try
while
match !l with
r :: rem ->
l := rem;
propagate_in_clause st r p;
true
| [] ->
false
do () done
with Conflict _ as e ->
st.st_watched.(p) <- !l @ st.st_watched.(p);
raise e
end
done
with Conflict _ as e ->
Queue.clear st.st_prop_queue;
raise e
(****)
let raise_level st =
st.st_cur_level <- st.st_cur_level + 1;
st.st_trail_lim <- st.st_trail :: st.st_trail_lim;
st.st_trail <- []
let assume st p =
raise_level st;
enqueue st p None
let protect st =
propagate st;
raise_level st;
st.st_min_level <- st.st_cur_level
let undo_one st p =
let x = var_of_lit p in
if !debug then Format.eprintf "Cancelling %a@." st.st_print_var x;
st.st_assign.(x) <- Unknown;
st.st_reason.(x) <- None;
st.st_level.(x) <- -1;
List.iter
(fun x -> charge st 1; st.st_refs.(x) <- st.st_refs.(x) - 1)
st.st_associated_vars.(p);
if st.st_refs.(x) > 0 && not st.st_pinned.(x) then enqueue_var st x
let cancel st =
st.st_cur_level <- st.st_cur_level - 1;
List.iter (fun p -> undo_one st p) st.st_trail;
match st.st_trail_lim with
[] -> assert false
| l :: r -> st.st_trail <- l; st.st_trail_lim <- r
let reset st =
if !debug then Format.eprintf "Reset@.";
while st.st_trail_lim <> [] do cancel st done;
for i = 0 to Array.length st.st_refs - 1 do
st.st_refs.(i) <- 0;
st.st_pinned.(i) <- false
done;
st.st_var_queue_head <- [];
st.st_min_level <- 0;
Queue.clear st.st_var_queue;
st.st_coherent <- true
(****)
let rec find_next_lit st =
match st.st_trail with
[] ->
assert false
| p :: rem ->
st.st_trail <- rem;
if st.st_seen_var.(var_of_lit p) = st.st_seen then
let reason = st.st_reason.(var_of_lit p) in
undo_one st p;
(p, reason)
else begin
undo_one st p;
find_next_lit st
end
let analyze st conflict =
st.st_seen <- st.st_seen + 1;
let counter = ref 0 in
let learnt = ref [] in
let bt_level = ref 0 in
let reasons = ref [] in
let r = ref conflict in
while
if !debug then begin
Array.iter
(fun p ->
Format.eprintf "%d:%a (%b/%d) "
p print_val (val_of_lit st p)
(st.st_reason.(var_of_lit p) <> None)
st.st_level.(var_of_lit p))
!r.lits;
Format.eprintf "@."
end;
reasons := !r.reasons @ !reasons;
for i = 0 to Array.length !r.lits - 1 do
let p = !r.lits.(i) in
let x = var_of_lit p in
if st.st_seen_var.(x) <> st.st_seen then begin
assert (val_of_lit st p = False);
st.st_seen_var.(x) <- st.st_seen;
let level = st.st_level.(x) in
if level = st.st_cur_level then begin
incr counter
end else (* if level > 0 then*) begin
learnt := p :: !learnt;
bt_level := max level !bt_level
end
end
done;
let (p, reason) = find_next_lit st in
decr counter;
if !counter = 0 then
learnt := lit_neg p :: !learnt
else
begin match reason with
Some r' -> r := r'
| None -> assert false
end;
!counter > 0
do () done;
if !debug then begin
List.iter
(fun p ->
Format.eprintf "%d:%a/%d "
p print_val (val_of_lit st p) st.st_level.(var_of_lit p))
!learnt;
Format.eprintf "@."
end;
(Array.of_list !learnt, !reasons, !bt_level)
let find_highest_level st lits =
let level = ref (-1) in
let i = ref 0 in
Array.iteri
(fun j p ->
if st.st_level.(var_of_lit p) > !level then begin
level := st.st_level.(var_of_lit p);
i := j
end)
lits;
!i
let rec solve_rec st =
match try propagate st; None with Conflict r -> Some r with
None ->
let x = dequeue_var st in
x < 0 ||
begin
assume st (lit_of_var x false);
solve_rec st
end
| Some r ->
let r =
match r with
None -> assert false
| Some r -> r
in
let (learnt, reasons, level) = analyze st r in
let level = max st.st_min_level level in
while st.st_cur_level > level do cancel st done;
assert (val_of_lit st learnt.(0) = Unknown);
let rule = { lits = learnt; reasons = reasons } in
if !debug then Format.eprintf "Learning %a@." (print_rule st) rule;
if Array.length learnt > 1 then begin
let i = find_highest_level st learnt in
assert (i > 0);
let p' = learnt.(i) in
learnt.(i) <- learnt.(1);
learnt.(1) <- p';
let p = lit_neg learnt.(0) in
let p' = lit_neg p' in
st.st_watched.(p) <- rule :: st.st_watched.(p);
st.st_watched.(p') <- rule :: st.st_watched.(p')
end;
enqueue st learnt.(0) (Some rule);
st.st_cur_level > st.st_min_level &&
solve_rec st
let rec solve st x =
assert (st.st_cur_level = st.st_min_level);
propagate st;
try
let p = lit_of_var x true in
assume st p;
assert (st.st_cur_level = st.st_min_level + 1);
if solve_rec st then begin
protect st;
true
end else
solve st x
with Conflict _ ->
st.st_coherent <- false;
false
let rec solve_lst_rec st l0 l =
match l with
[] ->
true
| x :: r ->
protect st;
List.iter (fun x -> enqueue st (lit_of_var x true) None) l0;
propagate st;
if solve st x then begin
if r <> [] then reset st;
solve_lst_rec st (x :: l0) r
end else
false
let solve_lst st l = solve_lst_rec st [] l
let initialize_problem ?(print_var = (fun fmt -> Format.fprintf fmt "%d")) n =
{ st_assign = Array.make n Unknown;
st_reason = Array.make n None;
st_level = Array.make n (-1);
st_seen_var = Array.make n (-1);
st_refs = Array.make n 0;
st_pinned = Array.make n false;
st_simpl_prop = Array.make (2 * n) [];
st_watched = Array.make (2 * n) [];
st_associated_vars = Array.make (2 * n) [];
st_trail = [];
st_trail_lim = [];
st_prop_queue = Queue.create ();
st_cur_level = 0;
st_min_level = 0;
st_seen = 0;
st_var_queue_head = [];
st_var_queue = Queue.create ();
st_cost = 0;
st_print_var = print_var;
st_coherent = true }
let insert_simpl_prop st r p p' =
let p = lit_neg p in
if not (List.mem_assoc p' st.st_simpl_prop.(p)) then
st.st_simpl_prop.(p) <- (p', r) :: st.st_simpl_prop.(p)
let add_bin_rule st p p' reasons =
let r = { lits = [|p; p'|]; reasons = reasons } in
insert_simpl_prop st r p p';
insert_simpl_prop st r p' p
let add_un_rule st p reasons =
let r = { lits = [|p|]; reasons = reasons } in
enqueue st p (Some r)
let add_rule st lits reasons =
let is_true = ref false in
let j = ref 0 in
for i = 0 to Array.length lits - 1 do
match val_of_lit st lits.(i) with
True -> is_true := true
| False -> ()
| Unknown -> lits.(!j) <- lits.(i); incr j
done;
let lits = Array.sub lits 0 !j in
if not !is_true then
match Array.length lits with
0 -> assert false
| 1 -> add_un_rule st lits.(0) reasons
| 2 -> add_bin_rule st lits.(0) lits.(1) reasons
| _ -> let rule = { lits = lits; reasons = reasons } in
let p = lit_neg rule.lits.(0) in let p' = lit_neg rule.lits.(1) in
assert (val_of_lit st p <> False);
assert (val_of_lit st p' <> False);
st.st_watched.(p) <- rule :: st.st_watched.(p);
st.st_watched.(p') <- rule :: st.st_watched.(p')
let associate_vars st lit l =
st.st_associated_vars.(lit) <- l @ st.st_associated_vars.(lit)
let rec collect_rec st x l =
if st.st_seen_var.(x) = st.st_seen then l else begin
st.st_seen_var.(x) <- st.st_seen;
match st.st_reason.(x) with
None ->
l
| Some r ->
r.reasons @
Array.fold_left (fun l p -> collect_rec st (var_of_lit p) l) l r.lits
end
let collect_reasons st x =
st.st_seen <- st.st_seen + 1;
collect_rec st x []
let collect_reasons_lst st l =
st.st_seen <- st.st_seen + 1;
let x = List.find (fun x -> st.st_assign.(x) = False) l in
collect_rec st x []
let assignment st = st.st_assign
end
dose2-1.4.2/satsolver/solver.mli 0000664 0000000 0000000 00000005713 11231374124 0016575 0 ustar 00root root 0000000 0000000 (* Copyright (C) 2005 Jerome Vouillon
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
module type S = sig
type reason (** *)
end
module M (X : S) : sig
type state
type var = int
type lit
(* [lit_of_var] given a variable and its value, it returns a literal.
The solver assumes that variables are integers numbered between 1 and n.
By default the assigment of all variables is Unknown. *)
val lit_of_var : var -> bool -> lit
(** initialize the solver *)
val initialize_problem :
?print_var:(Format.formatter -> int -> unit) -> int -> state
(** provide a deep copy of the current state of the solver *)
val copy : state -> state
val propagate : state -> unit
val protect : state -> unit
(** [reset] reset the state of the solver and, in particular, it
resets the variable assignment array *)
val reset : state -> unit
(** the value of a variable at any give time *)
type value = True | False | Unknown
(* [assignment] return the array of values associated to every variable *)
val assignment : state -> value array
(** [add_un_rule] gets that state of the solver, a literal and
reasons to return in case this clause was involved in a clash.
*)
val add_un_rule : state -> lit -> X.reason list -> unit
(** [add_bin_rule] gets that state of the solver, two literals [a,b] and a
list reasons to return in case this clause was involved in a clash.
Updates the internal state of the solver with ( a \lor b ) *)
val add_bin_rule : state -> lit -> lit -> X.reason list -> unit
(** [add_bin_rule] gets that state of the solver, a list of literals [l] and a
list reasons to return in case this clause was involved in a clash.
Updates the internal state of the solver with ( \Bigvee l ) *)
val add_rule : state -> lit array -> X.reason list -> unit
(** [associate_vars] associate a variable to a list of variables. The solver
* will use this information to guide the search heuristic *)
val associate_vars : state -> lit -> var list -> unit
(** [solve st v] finds a variable assignment that makes [v] true *)
val solve : state -> var -> bool
(** [solve st l] finds a variable assignment that makes true all variables in [l]*)
val solve_lst : state -> var list -> bool
val collect_reasons : state -> var -> X.reason list
val collect_reasons_lst : state -> var list -> X.reason list
end
dose2-1.4.2/util/ 0000775 0000000 0000000 00000000000 11231374124 0013505 5 ustar 00root root 0000000 0000000 dose2-1.4.2/util/.depend 0000664 0000000 0000000 00000000063 11231374124 0014744 0 ustar 00root root 0000000 0000000 util.cmo: util.cmi
util.cmx: util.cmi
util.cmi:
dose2-1.4.2/util/Makefile 0000664 0000000 0000000 00000000173 11231374124 0015146 0 ustar 00root root 0000000 0000000 # Makefile
NAME= util
SOURCES= util.ml
MLIS= util.mli
PACKAGES= unix
include ../Makefile.config
include .depend
dose2-1.4.2/util/README 0000664 0000000 0000000 00000000135 11231374124 0014364 0 ustar 00root root 0000000 0000000 Stuff.
Credits
=======
* Makefiles et al originally ripped from Gerd Stolpmann's netclient.
dose2-1.4.2/util/util.ml 0000664 0000000 0000000 00000045176 11231374124 0015031 0 ustar 00root root 0000000 0000000 (* Copyright 2004-2007 Berke DURAK.
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
open Unix;;
let sf = Printf.sprintf;;
exception At of string * exn;;
(*** first_line *)
let first_line =
let b = Buffer.create 256 in
fun w ->
Buffer.clear b;
let rec loop i =
if i = String.length w or w.[i] = '\n' then
Buffer.contents b
else
begin
Buffer.add_char b w.[i];
loop (i + 1)
end
in
loop 0
;;
(* ***)
(*** limit *)
let limit m w =
let n = String.length w in
if n <= m then
w
else
if m < 3 then
String.make m '.'
else
(String.sub w 0 (min (m - 3) n))^"..."
;;
(* ***)
(*** limit_left *)
let limit_left m w =
let n = String.length w in
if n <= m then
w
else
if m < 3 then
String.make m '.'
else
let m' = min (m - 3) n in
"..."^(String.sub w (m - m') m')
;;
(* ***)
(*** for_all_chars *)
let for_all_chars f w =
let m = String.length w in
let rec loop i =
if i = m then
true
else
f w.[i] && loop (i + 1)
in
loop 0
;;
(* ***)
(*** split_once_at *)
let split_once_at f s =
let m = String.length s in
let rec loop1 i =
if i = m then
raise Not_found
else
if f s.[i] then
loop2 i (i + 1)
else
loop1 (i + 1)
and loop2 i j =
if j = m or not (f s.[j]) then
(i,j)
else
loop2 i (j + 1)
in
try
let (i,j) = loop1 0 in
(String.sub s 0 i,
String.sub s j (m - j))
with
| Not_found -> (s, "")
;;
(* ***)
(*** is_alpha *)
let is_alpha = function
| 'a'..'z' -> true
| 'A'..'Z' -> true
| _ -> false
;;
(* ***)
(*** is_digit *)
let is_digit = function
| '0'..'9' -> true
| _ -> false
;;
(* ***)
(*** is_space *)
let is_space = function
| ' '|'\t'|'\n' -> true
| _ -> false
;;
(* ***)
(*** parse_strings *)
let parse_strings u =
let m = String.length u in
let b = Buffer.create m in
let rec loop0 r i =
if i >= m then
List.rev r
else
match u.[i] with
| ' '|'\t'|'\n' -> loop0 r (i + 1)
| '"' ->
Buffer.clear b;
loop2 r (i + 1)
| _ -> loop1 r i
and loop1 r i =
if i = m or is_space u.[i] or u.[i] = '"' then
begin
let x = Buffer.contents b in
Buffer.clear b;
loop0 (x::r) i
end
else
begin
Buffer.add_char b u.[i];
loop1 r (i + 1)
end
and loop2 r i =
if i = m then
invalid_arg "Unterminated double quote"
else
if u.[i] = '"' then
begin
let x = Buffer.contents b in
Buffer.clear b;
loop0 (x::r) (i + 1)
end
else
if u.[i] = '\\' then
if i + 1 < m then
match u.[i + 1] with
| '\\' -> Buffer.add_char b '\\'; loop2 r (i + 2)
| 'n' -> Buffer.add_char b '\n'; loop2 r (i + 2)
| 'r' -> Buffer.add_char b 'r'; loop2 r (i + 2)
| '"' -> Buffer.add_char b '"'; loop2 r (i + 2)
| 't' -> Buffer.add_char b 't'; loop2 r (i + 2)
| '0'..'9' ->
if i + 3 < m then
let x = int_of_string (String.sub u (i + 1) 3) in
if 0 < x && x < 256 then
begin
Buffer.add_char b (Char.chr x);
loop2 r (i + 4)
end
else
invalid_arg "Bad or null character code in backslash code"
else
invalid_arg "Unterminated decimal backslash code"
| _ -> invalid_arg "Unknown backslash code"
else
invalid_arg "Unterminated backslash sequence"
else
begin
Buffer.add_char b u.[i];
loop2 r (i + 1)
end
in
loop0 [] 0
;;
(* ***)
(*** split_at *)
let split_at c u =
let m = String.length u in
let b = Buffer.create m in
let rec loop0 r i =
if i >= m then
List.rev r
else
if u.[i] = c then
loop0 r (i + 1)
else
loop1 r i
and loop1 r i =
if i = m or u.[i] = c then
begin
let x = Buffer.contents b in
Buffer.clear b;
loop0 (x::r) (i + 1)
end
else
begin
Buffer.add_char b u.[i];
loop1 r (i + 1)
end
in
loop0 [] 0
;;
(* ***)
(*** list_intersect *)
let list_intersect l1 l2 =
let rec loop r = function
| [] -> r
| x::y -> loop (if List.mem x l2 then x::r else r) y
in
loop [] l1
;;
(* ***)
(*** once *)
let once f =
let x = ref true in
fun () ->
if !x then
begin
x := false;
f ()
end
else
()
;;
(* ***)
(*** list_has_more_than_one_element *)
let list_has_more_than_one_element = function
| []|[_] -> false
| _ -> true
;;
(* ***)
(*** count_lines *)
let count_lines w =
let m = String.length w in
let rec loop x i =
if i = m then
x
else
loop (if w.[i] = '\n' then x + 1 else x) (i + 1)
in
loop 1 0
;;
(* ***)
let first_matching_char_from i f w =
let m = String.length w in
let rec loop i =
if i = m then
raise Not_found
else
if f w.[i] then
i
else
loop (i + 1)
in
loop i
;;
let first_matching_char = first_matching_char_from 0;;
let first_matching_char_rev_from i f w =
let rec loop i =
if i = -1 then
raise Not_found
else
if f w.[i] then
i
else
loop (i - 1)
in
loop i
;;
let first_matching_char_rev f w =
first_matching_char_rev_from (String.length w - 1) f w
;;
(*** remove_leading_spaces *)
let remove_leading_spaces w =
try
let i = first_matching_char (fun c -> not (is_space c)) w in
String.sub w i (String.length w - i)
with
| Not_found -> w
;;
(* ***)
(*** remove_spaces *)
let remove_spaces w =
try
let i = first_matching_char (fun c -> not (is_space c)) w in
let j = first_matching_char_rev (fun c -> not (is_space c)) w in
String.sub w i (j - i + 1)
with
| Not_found -> w
;;
(* ***)
(*** delete_first_chars *)
let delete_first_chars n w =
let m = String.length w in
if m > n then
String.sub w n (m - n)
else
""
;;
(* ***)
let longest_matching_prefix f w =
try
let i = first_matching_char (fun c -> not (f c)) w in
String.sub w 0 i, String.sub w i (String.length w - i)
with
| Not_found -> (w,"")
;;
(*** hierarchical *)
let hierarchical x y =
let m = String.length x
and n = String.length y
in
if m < n then
-1
else if m > n then
1
else
compare x y
;;
(* ***)
(*** wind *)
let wind f x g y =
begin
try
let r = f x in
g y;
r
with
| z ->
g y;
raise z
end
;;
(* ***)
(*** list_change_nth *)
let rec list_change_nth l n z =
match l,n with
| [],_ -> raise Not_found
| x::y,0 -> z::y
| x::y,_ -> x::(list_change_nth y (n - 1) z)
;;
(* ***)
(*** list_remove_nth *)
let rec list_remove_nth l n =
match l,n with
| [],_ -> raise Not_found
| x::y,0 -> y
| x::y,_ -> x::(list_remove_nth y (n - 1))
;;
(* ***)
(*** word_wrap *)
let word_wrap oc ?(columns=75) u =
let m = String.length u in
let f c = output_char oc c
and g u i m = output oc u i m
in
(* beginning of line space *)
(* i: current index *)
(* j: pending beginning-of-line spaces (i.e., indent) *)
let rec loop0 i j =
if i = m then
if j > 0 then
f '\n'
else
()
else match u.[i] with
| ' ' -> loop0 (i + 1) (j + 1)
| '\t' -> loop0 (i + 1) (j + (4 - j land 3))
| '\n' ->
f '\n';
loop0 (i + 1) 0
| _ ->
if j < columns then
loop2 i i 0 j
else
begin
f '\n';
loop2 i i 0 0
end
(* inter-word space *)
(* i: current index *)
(* j: actual column *)
and loop1 i j =
if i = m then
if j > 0 then
f '\n'
else
()
else match u.[i] with
| ' '|'\t' -> loop1 (i + 1) j
| '\n' ->
f '\n';
loop0 (i + 1) 0
| _ -> loop2 i i j 1
(* word *)
(* i0: index of beginning of word *)
(* i: current index *)
(* j: actual cursor column *)
(* k: number of pending spaces *)
and loop2 i0 i j k =
if i = m or u.[i] = ' ' or u.[i] = '\t' or u.[i] = '\n' then
let l = i - i0 in
if j + k + l >= columns then
begin
f '\n';
g u i0 l;
if i < m & u.[i] = '\n' then
begin
f '\n';
loop0 (i + 1) 0
end
else
if l >= columns then
begin
f '\n';
loop1 (i + 1) 0
end
else
loop1 (i + 1) l
end
else
begin
for h = 1 to k do
f ' '
done;
g u i0 l;
if u.[i] = '\n' then
begin
f '\n';
loop0 (i + 1) 0
end
else
loop1 (i + 1) (j + k + l)
end
else
loop2 i0 (i + 1) j k
in
loop0 0 0
;;
(* ***)
(*** reg_of_string *)
let reg_of_string w =
let m = String.length w in
let b = Buffer.create m in
for i = 0 to m - 1 do
match w.[i] with
| ('.'|'+'|'?'|'['|']'|'^'|'$'|'('|')'|'{'|'}'|'\\') as c -> Buffer.add_char b '\\'; Buffer.add_char b c
| '*' -> Buffer.add_string b ".*"
| c -> Buffer.add_char b c
done;
Buffer.contents b
;;
(* ***)
(*** flip_array *)
let flip_array a =
let m = Array.length a in
for i = 0 to m / 2 - 1 do
let t = a.(i) in
a.(i) <- a.(m - 1 - i);
a.(m - 1 - i) <- t
done
;;
(* ***)
(*** proc_get_free_mem *)
let proc_get_free_mem () =
let ic = open_in "/proc/meminfo" in
wind (fun () ->
let tot = ref 0 in
try
while true do
let l = input_line ic in
match split_at ' ' l with
| [("MemFree:"|"Cached:");x;"kB"] -> tot := (int_of_string x) + !tot
| _ -> ()
done;
assert false
with
| End_of_file -> !tot
| _ -> 16384 (* assumption *)) ()
(fun () -> close_in ic) ()
;;
(* ***)
(*** proc_get_rsz_vsz *)
let proc_get_rsz_vsz () =
let ic = open_in (sf "/proc/%d/statm" (getpid ())) in
wind (fun () ->
Scanf.fscanf ic "%d %d %d %d %d %d %d"
(fun size resident share trs drs lrs dt ->
(resident,share))) () (fun () -> close_in ic) ()
;;
(* ***)
(*** substitute_variables *)
let substitute_variables env w =
let b = Buffer.create (String.length w) in
Buffer.add_substitute b (fun v -> List.assoc v env) w;
Buffer.contents b
;;
(* ***)
(*** string_of_process_status *)
let string_of_process_status thing = function
| WEXITED(rc) -> if rc <> 0 then Some(sf "%s failed with code %d" thing rc) else None
| WSIGNALED(sg) -> Some(sf "%s exited with signal %d" thing sg)
| WSTOPPED(sg) -> Some(sf "%s stopped with signal %d" thing sg)
;;
(* ***)
(*** list_sub_rev *)
let list_sub_rev l start length =
let rec loop r j = function
| [] -> r (* shall we raise an exception ? *)
| x::y -> loop (if j < start or j >= start + length then r else x::r) (j + 1) y
in
loop [] 0 l
;;
(* ***)
(*** unix_really_read *)
let rec unix_really_read fd u o m =
let l = read fd u o m in
if l < m then
if l = 0 then raise End_of_file
else
unix_really_read fd u (o + l) (m - l)
else
()
;;
(* ***)
(*** is_prefix *)
let is_prefix u v =
let m = String.length u
and n = String.length v
in
m <= n &&
let rec loop i = i = m or u.[i] = v.[i] && loop (i + 1) in
loop 0
;;
(* ***)
(*** string_of_sockaddr *)
let string_of_sockaddr =
function
| ADDR_UNIX x -> sf "UNIX(%S)" x
| ADDR_INET (a, p) -> sf "%s:%d" (string_of_inet_addr a) p
;;
(* ***)
(*** sockaddr_of_string *)
let sockaddr_of_string u =
let m = String.length u in
if is_prefix "UNIX(" u then
ADDR_UNIX(String.sub u 5 (m - 6))
else
let (a,p) = split_once_at ((=) ':') u in
ADDR_INET(inet_addr_of_string a, int_of_string p)
;;
(* ***)
(*** int64_of_inet_addr *)
let int64_of_inet_addr ip =
let w = string_of_inet_addr ip in
match List.map int_of_string (split_at '.' w) with
| [a;b;c;d] ->
Int64.logor
(Int64.shift_left (Int64.of_int a) 24)
(Int64.logor
(Int64.shift_left (Int64.of_int b) 16)
(Int64.logor
(Int64.shift_left (Int64.of_int c) 8)
(Int64.of_int d)))
| _ -> assert false
;;
(* ***)
(*** lowercase_compare *)
let lowercase_compare u v =
let m = String.length u
and n = String.length v
in
if m <> n then
false
else
let rec loop i = i = m || (Char.lowercase u.[i] = Char.lowercase v.[i] && loop (i + 1)) in
loop 0
;;
(* ***)
(*** call_if *)
let call_if f x =
match f with
| None -> ()
| Some g -> g x
(* ***)
(*** wrap *)
let wrap x g f =
begin
try
let r = f x in
g x;
r
with
| z ->
g x;
raise z
end
;;
(* ***)
(*** string_of_iso_8601 *)
let string_of_iso_8601 (y,m,d) = sf "%04d-%02d-%02d" y m d;;
(* ***)
(*** seconds_of_iso_8601 *)
let seconds_of_iso_8601 (y,m,d) =
let tm = {
tm_sec = 0;
tm_min = 0;
tm_hour = 0;
tm_mon = m + 1;
tm_wday = 0;
tm_yday = 0;
tm_year = y - 1900;
tm_mday = d;
tm_isdst = false
}
in
let (t,_) = mktime tm in
t
;;
(* ***)
(*** iso_8601_of_string *)
let iso_8601_of_string date =
match List.map int_of_string (split_at '-' date) with
| [y;m;d] -> (y,m,d)
| _ -> invalid_arg "bad date"
;;
(* ***)
(*** binary_search *)
let binary_search compare a x =
let m = Array.length a in
let rec loop i0 m =
if m = 0 then
raise Not_found
else
begin
if m < 8 then
if compare a.(i0) x = 0 then
i0
else
loop (i0 + 1) (m - 1)
else
let i = i0 + m / 2 in
let y = a.(i) in
let c = compare x y in
if c = 0 then
i
else
if c < 0 then
loop i0 (m / 2)
else
loop (i + 1) (m - m / 2 - 1)
end
in
loop 0 m
;;
(* ***)
(*** randomize *)
let randomize a =
let m = Array.length a in
let swap i j =
let x = a.(i) in
a.(i) <- a.(j);
a.(j) <- x
in
for i = 0 to m - 2 do
let j = i + 1 + Random.int (m - i - 1) in
swap i j
done
;;
(* ***)
(*** array_mem_assoc *)
let array_mem_assoc x a =
let m = Array.length a in
let rec loop i =
if i = m then false
else
let (y,_) = a.(i) in
x = y or loop (i + 1)
in
loop 0
;;
(* ***)
(*** array_assoc *)
let array_assoc x a =
let m = Array.length a in
let rec loop i =
if i = m then raise Not_found
else
let (y,z) = a.(i) in
if x = y then
z
else
loop (i + 1)
in
loop 0
;;
(* ***)
(*** today *)
let today () =
let tm = Unix.gmtime (Unix.gettimeofday ()) in
(tm.Unix.tm_year + 1900, tm.Unix.tm_mon + 1, tm.Unix.tm_mday)
;;
(* ***)
(*** mkdirhier *)
let mkdirhier path =
let exists fn =
try
let st = stat fn in
st.st_kind = S_DIR
with
| Unix_error(ENOENT,_,_) -> false
in
let l = split_at '/' path in
let rec loop dir = function
| [] -> ()
| x::y ->
let path = Filename.concat dir x in
if not (exists path) then mkdir path 0o755;
loop path y
in
let base = if String.length path > 1 && path.[0] = '/' then "/" else "" in
loop base l
;;
(* ***)
(*** inside *)
let inside msg f x =
try
f x
with
| x -> raise (At(msg, x))
;;
(* ***)
(*** display_exception *)
let rec display_exception = function
| At(location, x) ->
Printf.eprintf " At %s:\n" location;
display_exception x
| x -> Printf.eprintf " %s.\n" (Printexc.to_string x)
;;
(* ***)
(*** catch *)
let catch f =
try
f ()
with
| x ->
Printf.eprintf "Caught exception:\n";
display_exception x;
Printf.eprintf "%!";
exit 1;
;;
(* ***)
(*** sanitize_filename *)
let sanitize_filename
?(is_safe=
(function
| ('a'..'z'|'A'..'Z'|'0'..'9'|'-'|'_') -> true
| _ -> false))
?(buffer=Buffer.create 256)
?(prefix="") fn =
let b = buffer in
Buffer.clear b;
let m = String.length fn in
Buffer.add_string b prefix;
for i = 0 to m - 1 do
let c = fn.[i] in
if is_safe c then
Buffer.add_char b c
else
Printf.bprintf b "%%%02x" (Char.code c)
done;
Buffer.contents b
;;
(* ***)
(*** unsanitize_filename *)
let unsanitize_filename ?(buffer=Buffer.create 256) ?(prefix="") fn =
if not (is_prefix prefix fn) then invalid_arg "unsanitize_filename: no prefix";
let b = buffer in
Buffer.clear b;
let m = String.length fn in
let rec loop i =
if i = m then
Buffer.contents b
else
begin
match fn.[i] with
| ('a'..'z'|'A'..'Z'|'0'..'9'|'-'|'_') as c ->
Buffer.add_char b c;
loop (i + 1)
| '%' ->
if i + 2 >= m then invalid_arg (sf "unsanitize_filename: short hex escape at %d" i);
let f c =
let x = Char.code c in
match c with
| 'a'..'f' -> x - 87
| 'A'..'F' -> x - 55
| '0'..'9' -> x - 48
| _ -> invalid_arg (sf "unsanitize_filename: bad hex char %C" c)
in
let x = ((f fn.[i+1]) lsl 4) lor (f fn.[i+2]) in
Buffer.add_char b (Char.chr x);
loop (i + 3)
| c -> invalid_arg (sf "unsanitize_filename: bad char %C" c)
end
in
loop (String.length prefix)
;;
(* ***)
(*
(*** under_lock *)
let under_lock mutex f x =
Mutex.lock mutex;
try
let y = f x in
Mutex.unlock mutex;
y
with
| x ->
Mutex.unlock mutex;
raise x
;;
(* ***)
*)
(*** with_output_to_file *)
let with_output_to_file fn f =
let oc = open_out fn in
try
f oc
with
| x ->
close_out oc;
raise x
;;
(* ***)
let rec uniq2 l r =
match l with
| [] -> r
| [a] -> a::r
| h::(h'::t) -> if h = h' then uniq2 (h'::t) r else uniq2 (h'::t) (h::r);;
let uniq l =
uniq2 l [];;
let string_contains haystack needle =
let rec string_contains_from i k h n =
begin
if i - k + String.length needle > String.length haystack then
false
else if k == String.length needle then
true
else if h.[i] <> n.[k] then
string_contains_from (i+1) 0 h n
else
string_contains_from (i+1) (k+1) h n
end in
if String.length needle > String.length haystack then
false
else
string_contains_from 0 0 haystack needle;;
dose2-1.4.2/util/util.mli 0000664 0000000 0000000 00000007123 11231374124 0015170 0 ustar 00root root 0000000 0000000 (* Copyright 2004-2007 Berke DURAK
This file is part of Dose2.
Dose2 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dose2 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, see . *)
val sf : ('a, unit, string) format -> 'a
val first_line : string -> string
val limit : int -> string -> string
val limit_left : int -> string -> string
val for_all_chars : (char -> bool) -> string -> bool
val split_once_at : (char -> bool) -> string -> string * string
val is_alpha : char -> bool
val is_digit : char -> bool
val is_space : char -> bool
val parse_strings : string -> string list
val split_at : char -> string -> string list
val list_intersect : 'a list -> 'a list -> 'a list
val once : (unit -> unit) -> unit -> unit
val list_has_more_than_one_element : 'a list -> bool
val count_lines : string -> int
val first_matching_char_from : int -> (char -> bool) -> string -> int
val first_matching_char : (char -> bool) -> string -> int
val first_matching_char_rev_from : int -> (char -> bool) -> string -> int
val first_matching_char_rev : (char -> bool) -> string -> int
val remove_leading_spaces : string -> string
val remove_spaces : string -> string
val delete_first_chars : int -> string -> string
val longest_matching_prefix : (char -> bool) -> string -> string * string
val hierarchical : string -> string -> int
val wind : ('a -> 'b) -> 'a -> ('c -> 'd) -> 'c -> 'b
val list_change_nth : 'a list -> int -> 'a -> 'a list
val list_remove_nth : 'a list -> int -> 'a list
val word_wrap : out_channel -> ?columns:int -> string -> unit
val reg_of_string : string -> string
val flip_array : 'a array -> unit
val proc_get_rsz_vsz : unit -> int * int
val proc_get_free_mem : unit -> int
val substitute_variables : (string * string) list -> string -> string
val string_of_process_status : string -> Unix.process_status -> string option
val list_sub_rev : 'a list -> int -> int -> 'a list
val unix_really_read : Unix.file_descr -> string -> int -> int -> unit
val is_prefix : string -> string -> bool
val string_of_sockaddr : Unix.sockaddr -> string
val sockaddr_of_string : string -> Unix.sockaddr
val int64_of_inet_addr : Unix.inet_addr -> int64
val lowercase_compare : string -> string -> bool
val call_if : ('a -> unit) option -> 'a -> unit
val wrap : 'a -> ('a -> 'b) -> ('a -> 'c) -> 'c
val string_of_iso_8601 : (int * int * int) -> string
val seconds_of_iso_8601 : (int * int * int) -> float
val iso_8601_of_string : string -> (int * int * int)
val binary_search : ('a -> 'a -> int) -> 'a array -> 'a -> int
val randomize : 'a array -> unit
val array_mem_assoc : 'a -> ('a * 'b) array -> bool
val array_assoc : 'a -> ('a * 'b) array -> 'b
val today : unit -> (int * int * int)
val mkdirhier : string -> unit
val inside : string -> ('a -> 'b) -> 'a -> 'b
val catch : (unit -> 'a) -> 'a
val sanitize_filename : ?is_safe:(char -> bool) -> ?buffer:Buffer.t -> ?prefix:string -> string -> string
val unsanitize_filename : ?buffer:Buffer.t -> ?prefix:string -> string -> string
(*val under_lock : Mutex.t -> ('a -> 'b) -> 'a -> 'b*)
val with_output_to_file : string -> (out_channel -> 'a) -> 'a
val uniq: 'a list -> 'a list
val string_contains: string -> string -> bool