]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
Initial import of hg.uk.xensource.com/carbon/trunk/api-libs.hg c/s 255:b95c318ded7c...
authorXen hg user <hg@uk.xensource.com>
Thu, 28 May 2009 11:05:33 +0000 (12:05 +0100)
committerXen hg user <hg@uk.xensource.com>
Thu, 28 May 2009 11:05:33 +0000 (12:05 +0100)
For reference here is the output of 'hg export 255':
...
# Node ID b95c318ded7ca1eb3ff556c472f51ff0bd6c649f
# Parent  44307a5cffbf4d78042683602596d6a4a8421417
...

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
121 files changed:
.hgignore
CREDITS
Makefile [new file with mode: 0644]
camldm/META.in
camldm/Makefile
camldm/camldm.ml
camldm/camldm.mli
camldm/camldm_stubs.c
camldm/testcamldm.ml
cdrom/META.in
cdrom/Makefile
cdrom/cdrom.ml
cdrom/cdrom.mli
cdrom/cdrom_stubs.c
eventchn/META.in
eventchn/Makefile
eventchn/eventchn.ml
eventchn/eventchn.mli
eventchn/eventchn_injection.c
eventchn/eventchn_stubs.c
fake/marshall.h
fake/using.h
log/META.in
log/Makefile
log/log.ml
log/log.mli
log/logs.ml
log/syslog.ml
log/syslog_stubs.c
mmap/Makefile
mmap/mmap.ml
mmap/mmap.mli
mmap/mmap_stubs.c
mmap/mmap_stubs.h
rebuild
sha1/META.in [new file with mode: 0644]
sha1/Makefile [new file with mode: 0644]
sha1/sha1.ml [new file with mode: 0644]
sha1/sha1_stubs.c [new file with mode: 0644]
sha1/sha1sum.ml [new file with mode: 0644]
stdext/META.in
stdext/Makefile
stdext/arrayext.ml
stdext/arrayext.mli
stdext/bigbuffer.ml
stdext/bigbuffer.mli
stdext/filenameext.ml
stdext/filenameext.mli
stdext/fring.ml
stdext/fring.mli
stdext/hashtblext.ml
stdext/hashtblext.mli
stdext/listext.ml
stdext/listext.mli
stdext/opt.ml
stdext/opt.mli
stdext/pervasiveext.ml
stdext/pervasiveext.mli
stdext/qring.ml
stdext/qring.mli
stdext/range.ml
stdext/range.mli
stdext/ring.ml
stdext/ring.mli
stdext/stringext.ml
stdext/stringext.mli
stdext/threadext.ml
stdext/threadext.mli
stdext/trie.ml
stdext/trie.mli
stdext/unixext.ml
stdext/unixext.mli
stdext/unixext_stubs.c
stdext/vIO.ml
stdext/vIO.mli
tests/close_all_fds_except.ml
tests/copy_file.ml
tests/dotdot.ml
tests/unlink.ml
tests/watch_bug.ml
uuid/Makefile
uuid/uuid.ml
uuid/uuid.mli
xb/META.in
xb/Makefile
xb/op.ml
xb/packet.ml
xb/partial.ml
xb/xb.ml
xb/xb.mli
xb/xb_stubs.c
xb/xs_ring.ml
xb/xs_ring_stubs.c
xc/META.in
xc/Makefile
xc/xc.h
xc/xc.ml
xc/xc.mli
xc/xc_cpufeature.h
xc/xc_cpuid.h
xc/xc_e820.h
xc/xc_lib.c
xc/xc_lib_injection.c
xc/xc_stubs.c
xml-light2/META.in
xml-light2/Makefile
xml-light2/xml.ml
xml-light2/xml.mli
xs/META.in
xs/Makefile
xs/queueop.ml
xs/xs.ml
xs/xs.mli
xs/xsraw.ml
xs/xsraw.mli
xs/xst.ml
xs/xst.mli
xsrpc/META.in
xsrpc/Makefile
xsrpc/xsrpc.ml
xsrpc/xsrpc.mli

index 02927deee48748af5d0247d12c6ce0d7e92bde22..e3e9388f57961a7cc0e2bfe37987ad93edb10a88 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -8,13 +8,3 @@
 \.a$
 \.annot$
 \/META$
-autom4te\.cache/
-\.swp$
-^stdext/config\.h$
-^config\.log$
-^config\.status$
-^configure$
-doc/*
-~$
-\.rej$
-\.orig$
diff --git a/CREDITS b/CREDITS
index 64d0073e9a8fed3864d71bffb54c284a3b05bc6a..3f5674b48fa03de6ccfcb13a7f033ed3aaeee2c6 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -10,7 +10,6 @@ Jonathan Davies <jonathan.davies@citrix.com>
 Jonathan Knowles <jonathan.knowles@citrix.com>
 Jonathan Ludlam <Jonathan.Ludlam@eu.citrix.com>
 Magnus Therning <magnus.therning@eu.citrix.com>
-Prashanth Mundkur <prashanth.mundkur@gmail.com>
 Richard Sharp <richard.sharp@eu.citrix.com>
 Thomas Gazagnaire <thomas.gazagnaire@citrix.com>
 Tim Deegan <Tim.Deegan@citrix.com>
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..268be67
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,114 @@
+NO_DEFAULT_BUILD := yes
+ifdef B_BASE
+include $(B_BASE)/common.mk
+else
+MY_OUTPUT_DIR ?= $(CURDIR)/output
+MY_OBJ_DIR ?= $(CURDIR)/obj
+
+%/.dirstamp:
+       @mkdir -p $*
+       @touch $@
+endif
+
+all:
+       $(MAKE) -C uuid
+       $(MAKE) -C camldm
+       $(MAKE) -C stdext
+       $(MAKE) -C cdrom
+       $(MAKE) -C log
+       $(MAKE) -C sha1
+       $(MAKE) -C xml-light2
+allxen:
+       $(MAKE) -C mmap
+       $(MAKE) -C xc
+       $(MAKE) -C xb
+       $(MAKE) -C xs
+       $(MAKE) -C xsrpc
+       $(MAKE) -C eventchn
+
+install:
+       $(MAKE) -C uuid install
+       $(MAKE) -C camldm install
+       $(MAKE) -C stdext install
+       $(MAKE) -C cdrom install
+       $(MAKE) -C log install
+       $(MAKE) -C sha1 install
+       $(MAKE) -C xml-light2 install
+
+installxen:
+       $(MAKE) -C mmap install
+       $(MAKE) -C xc install
+       $(MAKE) -C xb install
+       $(MAKE) -C xs install
+       $(MAKE) -C xsrpc install
+       $(MAKE) -C eventchn install
+
+uninstall:
+       $(MAKE) -C uuid uninstall
+       $(MAKE) -C camldm uninstall
+       $(MAKE) -C stdext uninstall
+       $(MAKE) -C cdrom uninstall
+       $(MAKE) -C log uninstall
+       $(MAKE) -C sha1 uninstall
+       $(MAKE) -C xml-light2 uninstall
+
+uninstallxen:
+       $(MAKE) -C eventchn uninstall
+       $(MAKE) -C xsrpc uninstall
+       $(MAKE) -C xs uninstall
+       $(MAKE) -C xb uninstall
+       $(MAKE) -C xc uninstall
+       $(MAKE) -C mmap uninstall
+
+OUTPUT_API_PKG := $(MY_OUTPUT_DIR)/api-libs.tar.gz
+
+$(OUTPUT_API_PKG): DESTDIR=$(MY_OBJ_DIR)/staging/
+$(OUTPUT_API_PKG): PREFIX=$(shell ocamlfind printconf path)
+$(OUTPUT_API_PKG): $(MY_OBJ_DIR)/.dirstamp $(MY_OUTPUT_DIR)/.dirstamp
+       rm -rf $(DESTDIR)
+       mkdir -p $(DESTDIR)$(PREFIX)
+       $(MAKE) clean
+       $(MAKE) all
+       $(MAKE) DESTDIR=$(MY_OBJ_DIR)/staging install
+       tar -C $(DESTDIR) -zcf $@ .
+
+OUTPUT_XAPI_PKG := $(MY_OUTPUT_DIR)/xapi-libs.tar.gz
+
+$(OUTPUT_XAPI_PKG): DESTDIR=$(MY_OBJ_DIR)/staging/
+$(OUTPUT_XAPI_PKG): PREFIX=$(shell ocamlfind printconf path)
+$(OUTPUT_XAPI_PKG): $(MY_OBJ_DIR)/.dirstamp $(MY_OUTPUT_DIR)/.dirstamp
+       rm -rf $(DESTDIR)
+       mkdir -p $(DESTDIR)$(PREFIX)
+       $(MAKE) cleanxen
+       $(MAKE) allxen
+       $(MAKE) DESTDIR=$(MY_OBJ_DIR)/staging installxen
+       tar -C $(DESTDIR) -zcf $@ .
+
+.PHONY: api-libs
+api-libs: $(OUTPUT_API_PKG)
+       @ :
+
+.PHONY: xapi-libs
+xapi-libs: $(OUTPUT_XAPI_PKG)
+       @ :
+
+.PHONY: clean
+clean:
+       make -C uuid clean
+       make -C camldm clean
+       make -C stdext clean
+       make -C cdrom clean
+       make -C log clean
+       make -C sha1 clean
+       make -C xml-light2 clean
+       rm -f $(OUTPUT_API_PKG)
+
+cleanxen:
+       $(MAKE) -C mmap clean
+       $(MAKE) -C xc clean
+       $(MAKE) -C xb clean
+       $(MAKE) -C xs clean
+       $(MAKE) -C xsrpc clean
+       $(MAKE) -C eventchn clean
+       rm -f $(OUTPUT_XAPI_PKG)
index 9774760d8d1c5cead155d0af50976043e477bac0..e1b3895bf654741bf82fe9ed8892730dee934bd6 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "device-mapper ocaml interface"
-requires = "unix,rpc-light.json"
 archive(byte) = "camldm.cma"
 archive(native) = "camldm.cmxa"
index 725f250c536464bf0125f071ef5f9bb2dcd05efc..762e414917d2fed5639bafcfe9c657cc0eee5219 100644 (file)
@@ -1,12 +1,12 @@
+
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g
 OCAMLOPT = ocamlopt
 
-FEPP = camlp4o -I ../rpc-light -I $(shell ocamlfind query type-conv) pa_type_conv.cmo pa_rpc.cma
-
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -18,11 +18,6 @@ OBJS = camldm
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = camldm.cma camldm.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
-OCAMLFLAGS = -pp '${FEPP}' -I ../rpc-light
-
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -30,10 +25,10 @@ bins: $(PROGRAMS)
 libs: $(LIBS)
 
 camldm.cmxa: libcamldm_stubs.a $(foreach obj,$(OBJS),$(obj).cmx)
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) $(OCAMLFLAGS) -a -o $@ -cclib -lcamldm_stubs -cclib -ldevmapper $(foreach obj,$(OBJS),$(obj).cmx)
+       $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $@ -cclib -lcamldm_stubs -cclib -ldevmapper $(foreach obj,$(OBJS),$(obj).cmx)
 
 camldm.cma: $(foreach obj,$(OBJS),$(obj).cmo)
-       $(OCAMLC) $(OCAMLOPTFLAGS) $(OCAMLFLAGS) -a -dllib dllcamldm_stubs.so -cclib -lcamldm_stubs -cclib -ldevmapper -o $@ $(foreach obj,$(OBJS),$(obj).cmo)
+       $(OCAMLC) -a -dllib dllcamldm_stubs.so -cclib -lcamldm_stubs -cclib -ldevmapper -o $@ $(foreach obj,$(OBJS),$(obj).cmo)
 
 camldm_stubs.a: camldm_stubs.o
        ocamlmklib -o camldm_stubs -ldevmapper $+
@@ -43,13 +38,13 @@ libcamldm_stubs.a: camldm_stubs.o
        ocamlmklib -o camldm_stubs -ldevmapper $+
 
 %.cmo: %.ml
-       $(OCAMLC) $(OCAMLFLAGS) -c -o $@ $<
+       $(OCAMLC) -c -o $@ $<
 
 %.cmi: %.mli
-       $(OCAMLC) $(OCAMLFLAGS) -c -o $@ $<
+       $(OCAMLC) -c -o $@ $<
 
 %.cmx: %.ml
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) $(OCAMLFLAGS) -c -o $@ $<
+       $(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $<
 
 %.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<
@@ -58,18 +53,12 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore camldm META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore camldm META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove camldm
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "camldm" "package" "$(OBJS)" "." "" ""
-
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
index 8914966e92ff24ba1dd48ff0a3a7960cc7f80bc8..d2c254a93488a54ec183b4dfe2c31269c0a7aa17 100644 (file)
@@ -1,42 +1,24 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-
-type devty = 
-    | Dereferenced of string (* e.g. PV id *)
-    | Real of string (* device *)
-       
-and dev = {
-  device : devty;
+type dev = {
+  device : string;
   offset : int64;
 }
-    
-and stripety = {
-  chunk_size : int64;  (* In sectors - must be a power of 2 and at least as large as the system's PAGE_SIZE *)
+
+type stripety = {
+  chunk_size : int64;
   dests : dev array;
 }
 
-and mapty = 
+type mapty = 
     | Linear of dev (* Device, offset *)
     | Striped of stripety
 
-and mapping = {
+type mapping = {
   start : int64;
-  len : int64; 
+  len : int64;
   map : mapty;
 }
 
-and status = {
+type status = {
   exists : bool;
   suspended : bool;
   live_table : bool;
@@ -47,99 +29,36 @@ and status = {
   minor : int32;
   read_only : bool;
   targets : (int64 * int64 * string * string) list
-} 
-
-and mapping_array = {
-  m : mapping array 
-} 
-
-and create_error_t = {
-  c : (int64 * int64 * string * string) array
 }
-with rpc
-
-
 
 external _create : string -> (int64 * int64 * string * string) array -> unit = "camldm_create"
-external _reload : string -> (int64 * int64 * string * string) array -> unit = "camldm_reload"
 external _table : string -> status = "camldm_table"
 external _mknods : string -> unit = "camldm_mknods"
 external _remove : string -> unit = "camldm_remove"
-external _suspend : string -> unit = "camldm_suspend"
-external _resume : string -> unit = "camldm_resume"
 external _mknod : string -> int -> int -> int -> unit = "camldm_mknod"
-external _ls : unit -> (string list) option = "camldm_ls"
 
 (* Helper to convert from our type to the string*string 
  * type expected by libdevmapper *)
-let resolve_device dev deref_table =
-  match dev with
-    | Real d -> d
-    | Dereferenced d -> List.assoc d deref_table
-
-let convert_mapty m deref_table =
+let convert_mapty m =
   let array_concat sep a = String.concat sep (Array.to_list a) in
   match m with
     | Linear dev -> 
-       "linear",Printf.sprintf "%s %Ld" (resolve_device dev.device deref_table) dev.offset
+       "linear",Printf.sprintf "%s %Ld" dev.device dev.offset
     | Striped st ->
        "striped",
        Printf.sprintf "%d %Ld %s" (Array.length st.dests) st.chunk_size 
          (array_concat " " 
              (Array.map (fun dev -> 
-               Printf.sprintf "%s %Ld" (resolve_device dev.device deref_table) dev.offset) st.dests))
+               Printf.sprintf "%s %Ld" dev.device dev.offset) st.dests))
 
-exception CreateError of string
-exception ReloadError of string
+let create dev map =
+  let newmap = Array.map (fun m ->
+    let (ty,params) = convert_mapty m.map in
+    (m.start, m.len, ty, params)) map in
+  _create dev newmap
 
-let to_string m = Jsonrpc.to_string (rpc_of_mapping_array {m=m})
-let of_string s = (mapping_array_of_rpc (Jsonrpc.of_string s)).m
-let _writemap dev map =
-  let oc = open_out (Printf.sprintf "/tmp/%s.map" dev) in
-  Printf.fprintf oc "%s" (String.concat " " (Array.to_list (Array.map (fun (start,len,ty,params) -> Printf.sprintf "(start: %Ld len: %Ld ty: %s params: %s)" start len ty params) map)));
-  close_out oc
-    
-let _getmap map dereference_table =  
-  Array.map (fun m ->
-    let (ty,params) = convert_mapty m.map dereference_table in
-    (m.start, m.len, ty, params)) map 
-    
-let create dev map dereference_table =
-  let newmap = _getmap map dereference_table in
-  try 
-    _writemap dev newmap;
-    _create dev newmap
-  with Failure x ->
-    raise (CreateError x)
-      
-let reload dev map dereference_table =
-  let newmap = _getmap map dereference_table in
-  try 
-    _writemap dev newmap;
-    _reload dev newmap
-  with Failure x ->
-    raise (ReloadError x)
-
-let get_sector_pos_of map sector dereference_table =
-  match map.map with 
-    | Linear l -> (resolve_device l.device dereference_table, Int64.add l.offset sector)
-    | Striped s ->
-       (* Untested *)
-       let ndevs = Int64.of_int (Array.length s.dests) in
-       let chunk_num = Int64.div sector s.chunk_size in
-       let offset_in_chunk = Int64.rem sector s.chunk_size in
-       let dev_num = Int64.to_int (Int64.rem chunk_num ndevs) in
-       let dev_off = Int64.div chunk_num ndevs in
-       let device = s.dests.(dev_num) in
-       let offset_from_start = Int64.add (Int64.mul dev_off s.chunk_size) offset_in_chunk in   
-       let total_offset = Int64.add offset_from_start device.offset in
-       (resolve_device device.device dereference_table, total_offset)
-      
 let remove = _remove
 let table = _table
 let mknods = _mknods
 let mknod = _mknod
-let suspend = _suspend
-let resume = _resume 
-let ls = _ls
index 26ae79b687d535f647b6738b459970b11bcee0d3..43b4d10406a621ac02a9a75629eb99f550168574 100644 (file)
@@ -1,25 +1,7 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-
-type devty = | Dereferenced of string | Real of string
-type dev = { device : devty; offset : int64; }
+type dev = { device : string; offset : int64; }
 type stripety = { chunk_size : int64; dests : dev array; }
 type mapty = Linear of dev | Striped of stripety
 type mapping = { start : int64; len : int64; map : mapty; }
-type mapping_array = {
-  m : mapping array 
-} 
 type status = {
   exists : bool;
   suspended : bool;
@@ -32,24 +14,9 @@ type status = {
   read_only : bool;
   targets : (int64 * int64 * string * string) list;
 }
-
-exception CreateError of string
-exception ReloadError of string
-
-val rpc_of_mapping_array : mapping_array -> Rpc.t
-val mapping_array_of_rpc : Rpc.t -> mapping_array
-val convert_mapty : mapty -> (string * string) list -> string * string
-val create : string -> mapping array -> (string * string) list -> unit
-val reload : string -> mapping array -> (string * string) list -> unit
-val suspend : string -> unit
-val resume : string -> unit
+val convert_mapty : mapty -> string * string
+val create : string -> mapping array -> unit
 val remove : string -> unit
 val table : string -> status
 val mknods : string -> unit
 val mknod : string -> int -> int -> int -> unit
-val get_sector_pos_of : mapping -> int64 -> (string * string) list -> string * int64
-val to_string : mapping array -> string
-val of_string : string -> mapping array
-
-val rpc_of_status : status -> Rpc.t
-val ls : unit -> (string list) option
index 8d9921796da628721f44fc6c8c0d28e24023d56e..b02e74efed04c606d4b6a719bcd3c798d362e7e1 100644 (file)
@@ -1,16 +1,3 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 #include <libdevmapper.h>
 #include <caml/mlvalues.h>
 #include <caml/memory.h>
@@ -39,46 +26,6 @@ void camldm_create(value name, value map)
   if(!(dmt = dm_task_create(DM_DEVICE_CREATE)))
     caml_failwith("Failed to create task!");
 
-  if(!dm_task_set_name(dmt, String_val(name))) {
-    dm_task_destroy(dmt);
-    caml_failwith("Failed to set name");
-  }
-
-  for(i=0; i<Wosize_val(map); i++) {
-    start=Int64_val(Field(Field(map,i),0));
-    size=Int64_val(Field(Field(map,i),1));
-    ty=String_val(Field(Field(map,i),2));
-    params=String_val(Field(Field(map,i),3));
-
-    printf("%" PRIu64 " %" PRIu64 " %s %s\n", start, size, ty, params);
-
-    if(!dm_task_add_target(dmt, start, size, ty, params)) {
-      dm_task_destroy(dmt);
-      caml_failwith("Failed to add target");
-    }
-  }
-  
-  if(!dm_task_run(dmt)) {
-    dm_task_destroy(dmt);
-    caml_failwith("Failed to run task");
-  }
-  
- win:
-  CAMLreturn0;  
-}
-
-void camldm_reload(value name, value map) 
-{
-  CAMLparam2(name,map);
-
-  struct dm_task *dmt;
-  int i;
-  uint64_t start, size;
-  char *ty,*params;
-
-  if(!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
-    caml_failwith("Failed to create task!");
-
   if(!dm_task_set_name(dmt, String_val(name))) 
     goto out;
 
@@ -166,13 +113,8 @@ value camldm_table(value dev)
 
   tmp=Val_int(0);
 
-  do {
+  do { 
     next = dm_get_next_target(dmt, next, &start, &length, &target_type, &params);
-
-    /* This is how dmsetup.c checks for an empty table: */
-    if (!target_type)
-      continue;
-
     dm_task_get_info(dmt, &info);
 
     tuple=caml_alloc_tuple(4);
@@ -186,6 +128,8 @@ value camldm_table(value dev)
     Store_field(r, 1, tmp);
 
     tmp=r;
+
+    printf("params=%s\n",params);
   } while(next);
 
   Store_field(result,9,tmp);
@@ -220,100 +164,9 @@ void camldm_remove(value device)
   CAMLreturn0;
 }
 
-void camldm_suspend(value device)
-{
-  CAMLparam1(device);
-  _simple(DM_DEVICE_SUSPEND,String_val(device));
-  CAMLreturn0;
-}
-
-void camldm_resume(value device)
-{
-  CAMLparam1(device);
-  _simple(DM_DEVICE_RESUME,String_val(device));
-  CAMLreturn0;
-}
-
 void camldm_mknod(value path, value mode, value major, value minor)
 {
   CAMLparam4(path, mode, major, minor);
   mknod(String_val(path),S_IFBLK | Int_val(mode), makedev(Int_val(major),Int_val(minor)));
   CAMLreturn0;
 }
-
-
-/* Helper functions for camldm_ls */
-
-#define none Val_int(0)
-#define Tag_some Val_int(0)
-
-value some (value content) {
-  CAMLparam1 (content);
-  CAMLlocal1 (result);
-  result = caml_alloc (1, Tag_some);
-  Store_field (result, 0, content);
-  CAMLreturn (result);
-};
-value cons (value car_value, value cdr_value) {
-  CAMLparam2 (car_value, cdr_value);
-  CAMLlocal1 (cell);
-  
-  const int car = 0;
-  const int cdr = 1;
-  cell = caml_alloc (2, Tag_cons);
-  Store_field (cell, car, car_value);
-  Store_field (cell, cdr, cdr_value);
-  
-  CAMLreturn (cell);
-};
-/*
-  camldm_ls may leak memory.  Who knows?  (Does the c function (_process_all)
-  where I copied this from (dmsetup.c) care about memory?  dmsetup
-  exits shortly after executing it, anyway.
-  
-  After testing: It does _not_ seem to leak.  Probably
-  "dm_task_destroy(dmt);" is doing some cleaning up.
-*/
-value camldm_ls()
-{
-  CAMLparam0 ();
-  CAMLlocal1 (list);
-  
-  struct dm_names *names;
-  struct dm_task *dmt;
-
-  if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
-    CAMLreturn(none);
-  
-  if (!dm_task_run(dmt)) {
-    dm_task_destroy(dmt);
-    CAMLreturn(none);
-  }
-  
-  if (!(names = dm_task_get_names(dmt))) {
-    dm_task_destroy(dmt);
-    CAMLreturn(none);
-  }
-  
-  list = Val_emptylist;
-  if (!names->dev) {
-    dm_task_destroy(dmt);
-    CAMLreturn(some(list));
-  }
-
-  unsigned int next = 0;
-
-  do {
-    names = (void *) names + next;
-    //    printf("%s\t(%d, %d)\n", names->name,
-    //    (int) MAJOR(names->dev), (int) MINOR(names->dev));
-    
-    list = cons (caml_copy_string(names->name), list);
-    
-    // printf("%s\t(:Debug only)\n", names->name);
-    next = names->next;
-  } while (next);
-
-  dm_task_destroy(dmt);
-  CAMLreturn(some(list));
-}
index b856c0eb971c92a24ce1423bd2e238cd4d142d82..d4be8533a54b7948df8d7db1c7732c3dc972d35a 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 open Camldm
 
 let _ =
index c85094aff6a347cd309a76abfcc4f351670297a2..0b9383791bec25542a74afa6349f05fceebc4516 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "Cdrom extension"
-requires = "unix"
 archive(byte) = "cdrom.cma"
 archive(native) = "cdrom.cmxa"
index 63d5a4d2c18f169ea04944b2b1822fc0f3b7bd90..17f4cfe581d9d0b8dbe485d5729c0bdde674b55f 100644 (file)
@@ -1,10 +1,11 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g
 OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -16,8 +17,6 @@ OBJS = cdrom
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = cdrom.cma cdrom.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -53,19 +52,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore cdrom META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore cdrom META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove cdrom
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "cdrom" "package" "$(OBJS)" "." "" ""
-       
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index 46b14e4f92120421d11c6cebe4bea4b5121b79a6..897e09cbf7875e87464113a5e07f4a2a9a932b4c 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 type cdrom_drive_status =
        | NO_INFO
index 20129b7a457e1707990f51e3691acc2d6118c3c1..7fc59a2fca57eccad50489c899bca7be6cee11c0 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type cdrom_drive_status =
        | NO_INFO
        | NO_DISC
index f6e24c086ec9920ba3e7c18875cc4ce7e3c72a48..532ee2ff7152b0bb91a89b6794e09966ebca0828 100644 (file)
@@ -1,16 +1,3 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 /* Query CDROM info */
 #include <string.h>
 #include <errno.h>
index 0da7372b41ecd060bbba1f487c9ff84317e1a516..f3e01aa37447a9639781a0fbb0270e4fbe2f78e7 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "Eventchn interface extension"
-requires = "unix"
 archive(byte) = "eventchn.cma"
 archive(native) = "eventchn.cmxa"
index 4e2aeb09ebf1e6824c08271b2a49bbbb596564bf..59002a9d54552d75d027d7979f4c50867f3bdb59 100644 (file)
@@ -1,10 +1,11 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml -I$(XEN_ROOT)/usr/include
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(XEN_ROOT)/usr/include
 OCAMLC = ocamlc -g
 OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -16,8 +17,6 @@ OBJS = eventchn
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = eventchn.cma eventchn.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -53,19 +52,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove eventchn
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "eventchn" "package" "$(OBJS)" "." "" ""
-       
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index a2f9a1679708a0985bf72bd4fca3fdce89997771..6ce754beccae5b5e4e8c42acc4389a6be5a1a733 100644 (file)
@@ -1,16 +1,10 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006-2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
+
 exception Error of string
 
 external init: unit -> Unix.file_descr = "stub_eventchn_init"
index 90add23ff33d348d9857d4995ea056e96767b876..649bc31ff35279475cb0201cff946a0c4f8fff72 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 exception Error of string
 external init : unit -> Unix.file_descr = "stub_eventchn_init"
 external notify : Unix.file_descr -> int -> unit = "stub_eventchn_notify"
index cd7e76f5e66bc18a669944514295b6346c32777f..f64edba20298371a07b1330d92987d2841a6a40a 100644 (file)
@@ -1,16 +1,10 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006-2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
+
 #ifdef WITH_INJECTION_CAPABILITY
 #include "../fake/marshall.h"
 #include "../fake/using.h"
index 1e2c354706896d71cd3a8bba02071e697f76a410..36252578cad64d688287cbb0f3e70f92f0fb88c3 100644 (file)
@@ -1,16 +1,10 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006-2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -41,7 +35,9 @@
 #include <caml/callback.h>
 #include <caml/fail.h>
 
-#define EVENTCHN_PATH "/dev/xen/evtchn"
+#define EVENTCHN_PATH "/dev/xen/eventchn"
+#define EVENTCHN_MAJOR 10
+#define EVENTCHN_MINOR 63
 
 #define WITH_INJECTION_CAPABILITY
 #include "eventchn_injection.c"
@@ -71,7 +67,11 @@ int eventchn_do_open(void)
        pre_eventchn_open();
 
        fd = open(EVENTCHN_PATH, O_RDWR);
-
+       if (fd == -1 && errno == ENOENT) {
+               mkdir("/dev/xen", 0640);
+               mknod(EVENTCHN_PATH, S_IFCHR | 0640, makedev(10, 63));
+               fd = open(EVENTCHN_PATH, O_RDWR);
+       }
        return fd;
 }
 
index ab15391bc1ab76ba2ed4141f70f3b5d9286b0094..58b2b793277f66cbc233267f61193cdd36134758 100644 (file)
@@ -1,15 +1,6 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (c) 2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  */
 
 #ifndef FAKE_MARSHALL_H
index de6097d169e234f789771a6b61fa3279efbc083d..8300f779c3efc267c25843b07a577cf491b13644 100644 (file)
@@ -1,15 +1,8 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
 #ifndef FAKE_USING_H
 #define FAKE_USING_H
index 98f0c4c501491170f38bc6d6f10a1230bb2b5ba8..5c3646a62169bbc311e6b94a4b6d02379f19b9e3 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "Log - logging library"
-requires = "unix,stdext"
 archive(byte) = "log.cma"
 archive(native) = "log.cmxa"
index aa3f6084df0285231fd3fd59c5a7d699f34e6ede..be0719a085752e1e5fde801439d72fe88c21ef98 100644 (file)
@@ -1,11 +1,11 @@
 CC = gcc
-OCAMLLOC := $(shell ocamlc -where)
-CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(OCAMLLOC)
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc
 OCAMLOPT = ocamlopt 
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLCFLAGS = -g -dtypes -thread -I ../stdext
 OCAMLOPTFLAGS = -g -dtypes -thread -I ../stdext
@@ -15,12 +15,10 @@ OCAMLABI := $(shell ocamlc -version)
 OCAMLLIBDIR := $(shell ocamlc -where)
 OCAMLDESTDIR ?= $(OCAMLLIBDIR)
 
-OBJS = syslog log logs debug
-INTF = log.cmi logs.cmi syslog.cmi debug.cmi
+OBJS = syslog log logs
+INTF = log.cmi logs.cmi syslog.cmi
 LIBS = log.cma log.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -40,39 +38,40 @@ libsyslog_stubs.a: syslog_stubs.o
        ar rcs $@ $+
        ocamlmklib -o syslog_stubs $+
 
-%.cmi: %.mli
+%.cmo: %.ml
        $(OCAMLC) -c $(OCAMLCFLAGS) -o $@ $<
 
-%.cmo: %.ml %.cmi
-       $(OCAMLC) -c $(OCAMLCFLAGS) -thread -o $@ $<
+%.cmi: %.mli
+       $(OCAMLC) -c $(OCAMLCFLAGS) -o $@ $<
 
-%.cmx: %.ml %.cmi
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -c -o $@ $<
+%.cmx: %.ml
+       $(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $<
 
 %.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<
 
+logs.mli : logs.ml
+       $(OCAMLC) -i $(OCAMLCFLAGS) $< > $@
+
+syslog.mli : syslog.ml
+       $(OCAMLC) -i $< > $@
+
 META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 #dependency:
-log.cmi: syslog.cmi
-logs.cmi: log.cmi
-debug.cmi: logs.cmi
+log.cmo: syslog.cmo log.cmi 
+log.cmx: syslog.cmx log.cmi 
+logs.cmo: log.cmi 
+logs.cmx: log.cmx 
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove log
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "log" "package" "$(OBJS)" "." "stdext" ""
-       
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
index 8987b5193d615994c84ece926fa5d576ea119039..599da964ffae15fb83a21179092b2d65f4225c22 100644 (file)
@@ -1,27 +1,10 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006 XenSource LTD
+ * Author: Vincent Hanquez <vincent@xensource.com>
  *)
 
 open Printf
-
-module Mutex = struct
-    include Mutex
-    let execute lock f =
-       Mutex.lock lock;
-       let r = begin try f () with exn -> Mutex.unlock lock; raise exn end; in
-       Mutex.unlock lock;
-       r
-end
+open Threadext
 
 exception Unknown_level of string
 
@@ -72,12 +55,6 @@ let mkdir_rec dir perm =
 
 type t = { output: output; mutable level: level; }
 
-let get_strings t = match t.output with
-       | String s -> !s
-       | _ -> []
-
-let get_level t = t.level
-
 let make output level = { output = output; level = level; }
 
 let make_stream ty channel = 
@@ -148,7 +125,7 @@ let close t =
        | String _      -> ()
 
 (** create a string representating the parameters of the logger *)
-let to_string t =
+let string_of_logger t =
        match t.output with
        | Nil           -> "nil"
        | Syslog k      -> sprintf "syslog:%s" k
@@ -162,7 +139,7 @@ let to_string t =
            end
 
 (** parse a string to a logger *)
-let of_string s : t =
+let logger_of_string s : t =
        match s with
        | "nil"    -> opennil ()
        | "stderr" -> openerr Debug
@@ -216,9 +193,9 @@ let set t level = t.level <- level
 
 let gettimestring () =
        let time = Unix.gettimeofday () in
-       let tm = Unix.gmtime time in
+       let tm = Unix.localtime time in
         let msec = time -. (floor time) in
-       sprintf "%d%.2d%.2dT%.2d:%.2d:%.2d.%.3dZ|" (1900 + tm.Unix.tm_year)
+       sprintf "%d%.2d%.2d %.2d:%.2d:%.2d.%.3d|" (1900 + tm.Unix.tm_year)
                (tm.Unix.tm_mon + 1) tm.Unix.tm_mday
                tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec
                (int_of_float (1000.0 *. msec))
@@ -228,8 +205,7 @@ let gettimestring () =
 let filesize = ref 0 
 let mutex = Mutex.create ()
 
-let output_common t ?(raw=false) ?(syslog_time=false) ?(key="") ?(extra="") priority (message: string) =
-  let result_string = ref "" in
+let output t ?(key="") ?(extra="") priority (message: string) =
   let construct_string withtime =
                (*let key = if key = "" then [] else [ key ] in
                let extra = if extra = "" then [] else [ extra ] in
@@ -238,14 +214,8 @@ let output_common t ?(raw=false) ?(syslog_time=false) ?(key="") ?(extra="") prio
                  @ [ sprintf "%5s" (string_of_level priority) ] @ extra @ key @ [ message ] in
 (*             let items = !extra_hook items in*)
                String.concat " " items*)
-               result_string := (
-                       if raw
-                       then Printf.sprintf "%s" message
-                       else
     Printf.sprintf "[%s%.5s|%s] %s" 
       (if withtime then gettimestring () else "") (string_of_level priority) extra message
-    );
-    !result_string
        in
        (* Keep track of how much we write out to streams, so that we can *)
        (* log-rotate at appropriate times *)
@@ -257,15 +227,14 @@ let output_common t ?(raw=false) ?(syslog_time=false) ?(key="") ?(extra="") prio
         in
 
        if String.length message > 0 then
-       (match t.output with
+       match t.output with
        | Syslog k      ->
                let sys_prio = match priority with
                | Debug -> Syslog.Debug
                | Info  -> Syslog.Info
                | Warn  -> Syslog.Warning
                | Error -> Syslog.Err in
-               let facility = try Syslog.facility_of_string k with _->Syslog.Daemon in
-               Syslog.log facility sys_prio ((construct_string syslog_time) ^ "\n")
+               Syslog.log Syslog.Daemon sys_prio ((construct_string false) ^ "\n")
        | Stream s -> Mutex.execute s.mutex 
            (fun () -> 
              match !(s.channel) with
@@ -273,14 +242,6 @@ let output_common t ?(raw=false) ?(syslog_time=false) ?(key="") ?(extra="") prio
                | None -> ())
        | Nil           -> ()
        | String s      -> (s := (construct_string true)::!s)
-       );
-       !result_string
-
-let output t ?(key="") ?(extra="") priority (message: string) =
-       ignore(output_common t ~key ~extra priority message)
-
-let output_and_return t ?(raw=false) ~syslog_time ?(key="") ?(extra="") priority (message: string) =
-       output_common t ~raw ~syslog_time ~key ~extra priority message
 
 let log t level (fmt: ('a, unit, string, unit) format4): 'a =
        let b = (int_of_level t.level) <= (int_of_level level) in
index fa9ab2f9ea08cf92c6f4de3f3c99b4f7db65fc01..a76e8b2124dc2a843ab07accc59bd368b54c216d 100644 (file)
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-
-(** Logging utilities *)
-
-type t
-
-(** create a string representating the parameters of the logger *)
-val to_string : t -> string
-
-(** parse a string to a logger *)
-val of_string : string -> t
-
-(** try to reopen a logger *)
-val reopen : t -> t
-
-(** close a logger *)
-val close : t -> unit
-
-val gettimestring : unit -> string
-
-(** {2 Builders} *)
-
+exception Unknown_level of string
 type level = Debug | Info | Warn | Error
-val get_level : t -> level
 
-exception Unknown_level of string
-val level_of_string : string -> level
+type stream_type = Stderr | Stdout | File of string
+type stream_log = {
+  ty : stream_type;
+  channel : out_channel option ref;
+  mutex : Mutex.t;
+}
+type output =
+    Stream of stream_log
+  | String of string list ref
+  | Syslog of string
+  | Nil
+val int_of_level : level -> int
 val string_of_level : level -> string
-
-(** open a syslog logger *)
+val level_of_string : string -> level
+val mkdir_safe : string -> Unix.file_perm -> unit
+val mkdir_rec : string -> Unix.file_perm -> unit
+type t = { output : output; mutable level : level; }
+val make : output -> level -> t
 val opensyslog : string -> level -> t
-
-(** open a stderr logger *)
 val openerr : level -> t
-
-(** open a stdout logger *)
 val openout : level -> t
-
-(** open a stream logger - returning the output type *)
 val openfile : string -> level -> t
-
-(** open a nil logger *)
 val opennil : unit -> t
-
-(** open a string logger *)
 val openstring : level -> t
-val get_strings : t -> string list
-
-(** {2 Raw output functions} *)
-
+val reopen : t -> t
+val close : t -> unit
+val string_of_logger : t -> string
+val logger_of_string : string -> t
+val validate : string -> unit
+val set : t -> level -> unit
+val gettimestring : unit -> string
+val filesize : int ref
+val mutex : Mutex.t
 val output : t -> ?key:string -> ?extra:string -> level -> string -> unit
-val output_and_return : t -> ?raw:bool -> syslog_time:bool -> ?key:string -> ?extra:string -> level -> string -> string
-
-(** {2 Pretty output functions} *)
-
+val log : t -> level -> ('a, unit, string, unit) format4 -> 'a
 val debug : t -> ('a, unit, string, unit) format4 -> 'a
 val info : t -> ('a, unit, string, unit) format4 -> 'a
 val warn : t -> ('a, unit, string, unit) format4 -> 'a
 val error : t -> ('a, unit, string, unit) format4 -> 'a
-val log : t -> level -> ('a, unit, string, unit) format4 -> 'a
-
-(** {2 Output validation} *)
-
-val validate : string -> unit
-
-(** {2 Concurrency} *)
-
-(** TODO: It would be very nice to have a thread-free log module (ie. put the control outside that module).
-       This mutex protects all the recorded outputs. *)
-val mutex : Mutex.t
-
-(** TODO: remove the global state (what happens if multiple log files are opened???) ! *)
-val filesize : int ref
-
-(*
-type stream_type = Stderr | Stdout | File of string
-type stream_log = {
-  ty : stream_type;
-  channel : out_channel option ref;
-  mutex : Mutex.t;
-}
-
-val int_of_level : level -> int
-val mkdir_safe : string -> Unix.file_perm -> unit
-val mkdir_rec : string -> Unix.file_perm -> unit
-val set : t -> level -> unit
-val mutex : Mutex.t
-*)
index cc8937f0cd28e32fed568e9621529a76149a4a6a..f4af4410f2f9dfbad976e1b42a3ab0b03c6930f1 100644 (file)
@@ -1,15 +1,6 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006-2007 XenSource LTD
+ * Author: Vincent Hanquez <vincent@xensource.com>
  *)
 
 type keylogger =
@@ -41,7 +32,7 @@ let get_or_open logstring =
        if Hashtbl.mem __all_loggers logstring then
                Hashtbl.find __all_loggers logstring
        else
-               let t = Log.of_string logstring in
+               let t = Log.logger_of_string logstring in
                Hashtbl.add __all_loggers logstring t;
                t
 
@@ -158,7 +149,7 @@ let reset_all logger =
 (** log a fmt message to the key|level logger specified in the log mapping.
  * if the logger doesn't exist, assume nil logger.
  *)
-let log_common key level ?(extra="") ~ret_fn1 ~ret_fn2 (fmt: ('a, unit, string, 'b) format4): 'a =
+let log key level ?(extra="") (fmt: ('a, unit, string, unit) format4): 'a =
        let keylog =
                if Hashtbl.mem __log_mapping key then
                        let keylog = Hashtbl.find __log_mapping key in
@@ -171,32 +162,18 @@ let log_common key level ?(extra="") ~ret_fn1 ~ret_fn2 (fmt: ('a, unit, string,
                        __default_logger in
        let loggers = get_by_level keylog level in
        match loggers with
-       | [] -> Printf.kprintf ret_fn1 fmt
+       | [] -> Printf.kprintf ignore fmt
        | _  ->
                let l = List.fold_left (fun acc logger ->       
                        try get_or_open logger :: acc
                        with _ -> acc
                ) [] loggers in
                let l = List.rev l in
-               ret_fn2 l
-
-let log key level ?(extra="") (fmt: ('a, unit, string, unit) format4): 'a =
-       log_common key level ~extra ~ret_fn1:(ignore) fmt
-               ~ret_fn2:(fun l ->
-    (* ksprintf is the preferred name for kprintf, but the former                                   
-     * is not available in OCaml 3.08.3 *)                                                          
-    Printf.kprintf (fun s ->
-      List.iter (fun t -> Log.output t ~key ~extra level s) l) fmt
-               )
-
-let log_and_return key level ?(raw=false) ~syslog_time ?(extra="") (fmt: ('a, unit, string, string) format4): 'a =
-       log_common key level ~extra ~ret_fn1:(fun s->s) fmt
-    ~ret_fn2:(fun l ->
-               let ret_str = ref "" in
-    Printf.kprintf (fun s ->
-      List.iter (fun t -> ret_str := Log.output_and_return t ~raw ~syslog_time ~key ~extra level s) l; !ret_str) fmt
-               )
 
+               (* ksprintf is the preferred name for kprintf, but the former
+                * is not available in OCaml 3.08.3 *)
+               Printf.kprintf (fun s ->
+                       List.iter (fun t -> Log.output t ~key ~extra level s) l) fmt
 
 (* define some convenience functions *)
 let debug t ?extra (fmt: ('a , unit, string, unit) format4) =
@@ -207,5 +184,3 @@ let warn t ?extra (fmt: ('a , unit, string, unit) format4) =
        log t Log.Warn ?extra fmt
 let error t ?extra (fmt: ('a , unit, string, unit) format4) =
        log t Log.Error ?extra fmt
-let audit t ?raw ?extra (fmt: ('a , unit, string, string) format4) =
-  log_and_return t Log.Info ?raw ~syslog_time:true ?extra fmt
index ee99da9ba0e3ee4a31ff1c95ecfdcd540d5590af..e328feb36f797d55ea10bd87037f803d1701274c 100644 (file)
@@ -1,15 +1,6 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *)
 
 type level = Emerg | Alert | Crit | Err | Warning | Notice | Info | Debug
@@ -22,28 +13,3 @@ type facility = Auth | Authpriv | Cron | Daemon | Ftp | Kern
 (* external init : string -> options list -> facility -> unit = "stub_openlog" *)
 external log : facility -> level -> string -> unit = "stub_syslog"
 external close : unit -> unit = "stub_closelog"
-
-exception Unknown_facility of string
-let facility_of_string s =
-       match s with
-    |"auth"->Auth
-    |"authpriv"->Authpriv
-    |"cron"->Cron
-    |"daemon"->Daemon
-    |"ftp"->Ftp
-    |"kern"->Kern
-    |"local0"->Local0
-    |"local1"->Local1
-    |"local2"->Local2
-    |"local3"->Local3
-    |"local4"->Local4
-    |"local5"->Local5
-    |"local6"->Local6
-    |"local7"->Local7
-    |"lpr"->Lpr
-    |"mail"->Mail
-    |"news"->News
-    |"syslog"->Syslog
-    |"user"->User
-    |"uucp"->Uucp
-               |_-> raise (Unknown_facility s)
index 408ecefe320eac2c7a23a12e5d8e019fefd5d1cc..e0386932bc5904f2011debf8e7952c8ee312cfd4 100644 (file)
@@ -1,24 +1,13 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  */
 
 #include <syslog.h>
-#include <string.h>
 #include <caml/mlvalues.h>
 #include <caml/memory.h>
 #include <caml/alloc.h>
 #include <caml/custom.h>
-#include <caml/signals.h>
 
 static int __syslog_level_table[] = {
        LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
@@ -57,15 +46,11 @@ value stub_openlog(value ident, value option, value facility)
 value stub_syslog(value facility, value level, value msg)
 {
        CAMLparam3(facility, level, msg);
-       const char *c_msg = strdup(String_val(msg));
-       int c_facility = __syslog_facility_table[Int_val(facility)]
-                      | __syslog_level_table[Int_val(level)];
+       int c_facility;
 
-       caml_enter_blocking_section();
-       syslog(c_facility, "%s", c_msg);
-       caml_leave_blocking_section();
-       
-       free(c_msg);
+       c_facility = __syslog_facility_table[Int_val(facility)]
+                  | __syslog_level_table[Int_val(level)];
+       syslog(c_facility, "%s", String_val(msg));
        CAMLreturn(Val_unit);
 }
 
index 6f305871cf2f58d2b9c051cbfdd3a0ca85e52a32..960ef1986bc92bb4249eaa93b72e6e4d52070624 100644 (file)
@@ -1,10 +1,11 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g
 OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -16,8 +17,6 @@ OBJS = mmap
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = mmap.cma mmap.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -53,19 +52,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove mmap
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "mmap" "package" "$(OBJS)" "." "" ""
-
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index 30c180de741742bdd70fa388d7d0f8e81ec851b1..a0647d75c5ec23858f60e6cca3ca6914a247a3ac 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 type mmap_interface
index 457a5bf20092aefcace94231dc36e209bc9bf1ce..458c4970699c445932df9d312868b48ca123e663 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type mmap_interface
 type mmap_prot_flag = RDONLY | WRONLY | RDWR
 type mmap_map_flag = SHARED | PRIVATE
index 1d2a39fddcf7f4d016ec1c25ec30e1a5ea34aca6..0270970a31deb24e3e1569b7901236463c5ece74 100644 (file)
@@ -1,15 +1,8 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+/**
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
 
 #include <unistd.h>
index 2b18bcd40053032e56757a761163a7270226adf0..dbc3a8e08a56e7160ef64b6b94ff2444c45f7eda 100644 (file)
@@ -1,15 +1,8 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+/**
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
 
 #ifndef C_MMAP_H
diff --git a/rebuild b/rebuild
index 55d075fdcffd7e40912ec86792a6b1f4be34f1d5..ccd8934c92af1d526293ddc7f0e5d7aab11827ca 100755 (executable)
--- a/rebuild
+++ b/rebuild
@@ -1,8 +1,6 @@
 #!/bin/sh
 
-export REPO=/myrepos/xen-api-libs.hg
-
 set -e 
 make clean; make cleanxen;
-make uninstall; make uninstallxen; make binuninstall
-make all && make bins && make install && make allxen && make installxen && make bininstall
+make uninstall; make uninstallxen;
+make all && make install && make allxen && make installxen
diff --git a/sha1/META.in b/sha1/META.in
new file mode 100644 (file)
index 0000000..a48e46e
--- /dev/null
@@ -0,0 +1,4 @@
+version = "@VERSION@"
+description = "Sha1 hash functions"
+archive(byte) = "sha1.cma"
+archive(native) = "sha1.cmxa"
diff --git a/sha1/Makefile b/sha1/Makefile
new file mode 100644 (file)
index 0000000..9732c48
--- /dev/null
@@ -0,0 +1,69 @@
+CC = gcc
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(XEN_ROOT)/usr/include -I../mmap -I./
+OCAMLC = ocamlc -g
+OCAMLOPT = ocamlopt
+OCAMLOPTFLAGS = -g -dtypes -I ./
+
+LDFLAGS = -cclib -L./
+
+DESTDIR ?= /
+VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
+
+OCAMLABI := $(shell ocamlc -version)
+OCAMLLIBDIR := $(shell ocamlc -where)
+OCAMLDESTDIR ?= $(OCAMLLIBDIR)
+
+OBJS = sha1
+INTF = sha1.cmi
+LIBS = sha1.cma sha1.cmxa
+
+PROGRAMS =
+
+all: $(INTF) $(LIBS) $(PROGRAMS)
+
+bins: $(PROGRAMS)
+
+libs: $(LIBS)
+
+sha1.cmxa: libsha1_stubs.a $(foreach obj,$(OBJS),$(obj).cmx)
+       $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $@ -cclib -lsha1_stubs $(foreach obj,$(OBJS),$(obj).cmx)
+
+sha1.cma: $(foreach obj,$(OBJS),$(obj).cmo)
+       $(OCAMLC) -a -dllib dllsha1_stubs.so -cclib -lsha1_stubs -o $@ $(foreach obj,$(OBJS),$(obj).cmo)
+
+sha1_stubs.a: sha1_stubs.o
+       ocamlmklib -o sha1_stubs $+
+
+libsha1_stubs.a: sha1_stubs.o
+       ar rcs $@ $+
+       ocamlmklib -o sha1_stubs $+
+
+%.cmo: %.ml
+       $(OCAMLC) -c -o $@ $<
+
+%.cmi: %.mli
+       $(OCAMLC) -c -o $@ $<
+
+%.mli: %.ml
+       $(OCAMLC) -i $< > $@
+
+%.cmx: %.ml
+       $(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $<
+
+%.o: %.c
+       $(CC) $(CFLAGS) -c -o $@ $<
+
+META: META.in
+       sed 's/@VERSION@/$(VERSION)/g' < $< > $@
+
+.PHONY: install
+install: $(LIBS) META
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore sha1 META $(INTF) $(LIBS) *.a *.so *.cmx
+
+.PHONY: uninstall
+uninstall:
+       ocamlfind remove sha1
+
+clean:
+       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS) $(INTF)
+
diff --git a/sha1/sha1.ml b/sha1/sha1.ml
new file mode 100644 (file)
index 0000000..d2c5224
--- /dev/null
@@ -0,0 +1,12 @@
+(*
+ * Copyright (C) 2007 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
+ *)
+
+type ctx
+type t
+
+external init: unit -> ctx = "stub_sha1_init"
+external update: ctx -> string -> int -> int -> unit = "stub_sha1_update"
+external finalize: ctx -> t = "stub_sha1_finalize"
+external to_hex: t -> string = "stub_sha1_to_hex"
diff --git a/sha1/sha1_stubs.c b/sha1/sha1_stubs.c
new file mode 100644 (file)
index 0000000..8025bd1
--- /dev/null
@@ -0,0 +1,210 @@
+/* Copyright (c) 2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com> */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <byteswap.h>
+
+#ifdef WORDS_BIGENDIAN
+#define be16_to_cpu(x) (x)
+#define be32_to_cpu(x) (x)
+#define be64_to_cpu(x) (x)
+#define le16_to_cpu(x) bswap_16(x)
+#define le32_to_cpu(x) bswap_32(x)
+#define le64_to_cpu(x) bswap_64(x)
+#else
+#define be16_to_cpu(x) bswap_16(x)
+#define be32_to_cpu(x) bswap_32(x)
+#define be64_to_cpu(x) bswap_64(x)
+#define le16_to_cpu(x) (x)
+#define le32_to_cpu(x) (x)
+#define le64_to_cpu(x) (x)
+#endif
+
+struct sha1_ctx
+{
+       unsigned int state[5];
+       unsigned char buf[64];
+       unsigned long long count;
+};
+
+typedef struct { unsigned int digest[5]; } sha1_digest;
+
+static void sha1_init(struct sha1_ctx *ctx)
+{
+       memset(ctx, 0, sizeof(*ctx));
+
+       /* initialize H */
+       ctx->state[0] = 0x67452301;
+       ctx->state[1] = 0xEFCDAB89;
+       ctx->state[2] = 0x98BADCFE;
+       ctx->state[3] = 0x10325476;
+       ctx->state[4] = 0xC3D2E1F0;
+}
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define blk0(i) (block[i] = be32_to_cpu(((unsigned int*)buffer)[i]))
+#define blk(i) (block[i] = rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1))
+
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)    +blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)    +blk (i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=( w^x     ^y)    +blk (i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk (i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=( w^x     ^y)    +blk (i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+static void sha1_transform(unsigned int state[5], unsigned char buffer[64])
+{
+       unsigned int block[80];
+       unsigned int i, a, b, c, d, e;
+
+       a = state[0];
+       b = state[1];
+       c = state[2];
+       d = state[3];
+       e = state[4];
+
+       for (i = 0; i < 15; i += 5) {
+               R0(a, b, c, d, e, 0 + i);
+               R0(e, a, b, c, d, 1 + i);
+               R0(d, e, a, b, c, 2 + i);
+               R0(c, d, e, a, b, 3 + i);
+               R0(b, c, d, e, a, 4 + i);
+       }
+
+       R0(a, b, c, d, e, 15);
+       R1(e, a, b, c, d, 16);
+       R1(d, e, a, b, c, 17);
+       R1(c, d, e, a, b, 18);
+       R1(b, c, d, e, a, 19);
+
+       for (i = 20; i < 40; i += 5) {
+               R2(a, b, c, d, e, 0 + i);
+               R2(e, a, b, c, d, 1 + i);
+               R2(d, e, a, b, c, 2 + i);
+               R2(c, d, e, a, b, 3 + i);
+               R2(b, c, d, e, a, 4 + i);
+       }
+       for (; i < 60; i += 5) {
+               R3(a, b, c, d, e, 0 + i);
+               R3(e, a, b, c, d, 1 + i);
+               R3(d, e, a, b, c, 2 + i);
+               R3(c, d, e, a, b, 3 + i);
+               R3(b, c, d, e, a, 4 + i);
+       }
+       for (; i < 80; i += 5) {
+               R4(a, b, c, d, e, 0 + i);
+               R4(e, a, b, c, d, 1 + i);
+               R4(d, e, a, b, c, 2 + i);
+               R4(c, d, e, a, b, 3 + i);
+               R4(b, c, d, e, a, 4 + i);
+       }
+
+       state[0] += a;
+       state[1] += b;
+       state[2] += c;
+       state[3] += d;
+       state[4] += e;
+}
+
+static void sha1_update(struct sha1_ctx *ctx, unsigned char *data, int len)
+{
+       unsigned int i, j;
+       j = ctx->count & 63;
+       ctx->count += len;
+
+       if ((j + len) > 63) {
+               i = 64 - j;
+               memcpy(&ctx->buf[j], data, i);
+               sha1_transform(ctx->state, ctx->buf);
+               for ( ; i + 63 < len; i += 64) {
+                       sha1_transform(ctx->state, &data[i]);
+               }
+               j = 0;
+       } else
+               i = 0;
+       memcpy(&ctx->buf[j], &data[i], len - i);
+}
+
+static void sha1_finalize(struct sha1_ctx *ctx, sha1_digest *digest)
+{
+       int i;
+       unsigned long long finalcount = be64_to_cpu(ctx->count << 3);
+
+       sha1_update(ctx, (unsigned char *)"\200", 1);
+       while ((ctx->count & 63) != 56)
+               sha1_update(ctx, (unsigned char *) "", 1);
+
+       sha1_update(ctx, (unsigned char *) &finalcount, 8);
+       for (i = 0; i < 5; i++)
+               digest->digest[i] = be32_to_cpu(ctx->state[i]);
+}
+
+static inline void sha1_to_hex(sha1_digest *digest, char *out)
+{
+       char *p;
+       int i;
+       for (p = out, i = 0; i < 20; i++, p += 2)
+               snprintf(p, 3, "%02x", ((unsigned char *) digest->digest)[i]);
+}
+
+#define CAML_NAME_SPACE
+#include <caml/alloc.h>
+#include <caml/memory.h>
+#include <caml/signals.h>
+#include <caml/fail.h>
+
+#define GET_CTX_STRUCT(a) ((struct sha1_ctx *) a)
+
+CAMLprim value stub_sha1_init(value unit)
+{
+       CAMLparam1(unit);
+       CAMLlocal1(result);
+
+        result = caml_alloc(sizeof(struct sha1_ctx), Abstract_tag);
+       sha1_init(GET_CTX_STRUCT(result));
+
+       CAMLreturn(result);
+}
+
+CAMLprim value stub_sha1_update(value ctx, value data, value ofs, value len)
+{
+       CAMLparam4(ctx, data, ofs, len);
+       sha1_update(GET_CTX_STRUCT(ctx), (unsigned char *) data + Int_val(ofs),
+                   Int_val(len));
+       CAMLreturn(Val_unit);
+}
+
+CAMLprim value stub_sha1_finalize(value ctx)
+{
+       CAMLparam1(ctx);
+       CAMLlocal1(t);
+
+       t = caml_alloc(sizeof(sha1_digest), Abstract_tag);
+       sha1_finalize(GET_CTX_STRUCT(ctx), (sha1_digest *) t);
+
+       CAMLreturn(t);
+}
+
+CAMLprim value stub_sha1_to_hex(value t)
+{
+       CAMLparam1(t);
+       CAMLlocal1(result);
+
+       result = caml_alloc_string(40);
+       sha1_to_hex((sha1_digest *) t, String_val(result));
+
+       CAMLreturn(result);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: t
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
diff --git a/sha1/sha1sum.ml b/sha1/sha1sum.ml
new file mode 100644 (file)
index 0000000..d242810
--- /dev/null
@@ -0,0 +1,29 @@
+(* Copyright (C) 2007 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
+ *)
+let channel chan len =
+       let ctx = Sha1.init ()
+       and buf = String.create 4096 in
+
+       let left = ref len and eof = ref false in
+       while (!left == -1 || !left > 0) && not !eof
+       do
+               let len = if !left < 0 then 4096 else (min !left 4096) in
+               let readed = Pervasives.input chan buf 0 len in
+               if readed = 0 then
+                       eof := true
+               else (
+                       Sha1.update ctx buf 0 readed;
+                       if !left <> -1 then left := !left - readed
+               )
+       done;
+       if !left > 0 && !eof then
+               raise End_of_file;
+       Sha1.finalize ctx
+
+let _ =
+       let name = Sys.argv.(1) in
+       let chan = open_in_bin name in
+       let digest = channel chan (-1) in
+       close_in chan;
+       Printf.printf "%s\n" (Sha1.to_hex digest)
index 67b7e0d8504326393ee7f1455cea4e04ec189aa5..bc67d1e2000a824303d05a74d4b090de55c86521 100644 (file)
@@ -1,5 +1,5 @@
 version = "@VERSION@"
 description = "Stdext - Common stdlib extensions"
-requires = "unix,uuid,bigarray,rpc-light.json"
+requires = "unix,uuid"
 archive(byte) = "stdext.cma"
 archive(native) = "stdext.cmxa"
index 444bd1942452f6df8c4e41f402d16d23563e5000..ce277859ddaa718e910f7fe00875d79b782f7b6f 100644 (file)
@@ -1,98 +1,41 @@
-IPROG=install -m 755 -o root -g root
 CC = gcc
-OCAMLLOC := $(shell ocamlc -where)
-CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(OCAMLLOC)
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g
 OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
-LIBEXEC = "/opt/xensource/libexec/"
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
-OCAMLABI := $(OCAMLLOC)
-OCAMLLIBDIR := $(OCAMLLOC)
+OCAMLABI := $(shell ocamlc -version)
+OCAMLLIBDIR := $(shell ocamlc -where)
 OCAMLDESTDIR ?= $(OCAMLLIBDIR)
 
-FEPP = camlp4o -I ../rpc-light -I $(shell ocamlfind query type-conv) pa_type_conv.cmo pa_rpc.cma
-
 OCAML_TEST_INC = -I $(shell ocamlfind query oUnit)
 OCAML_TEST_LIB = $(shell ocamlfind query oUnit)/oUnit.cmxa
 
-STDEXT_OBJS = \
-       fun \
-       opt \
-       listext \
-       filenameext \
-       stringext \
-       arrayext \
-       hashtblext \
-       pervasiveext \
-       threadext \
-       int64ext \
-       ring \
-       qring \
-       fring \
-       bigbuffer \
-       unixext \
-       range \
-       vIO \
-       trie \
-       config \
-       date \
-       encodings \
-       fe \
-       fecomms \
-       forkhelpers \
-       gzip \
-       sha1sum \
-       zerocheck \
-       base64 \
-       backtrace \
-       tar \
-       mapext \
-       os \
-       either \
-       lazyList \
-       extentlistSet \
-       set_test
-
+STDEXT_OBJS = filenameext stringext arrayext hashtblext listext pervasiveext threadext ring qring fring opt unixext range bigbuffer vIO trie
 INTF = $(foreach obj, $(STDEXT_OBJS),$(obj).cmi)
 LIBS = stdext.cma stdext.cmxa
 
-PROGRAMS = base64pp fe_cli fe_test extentlistset_test
-
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
-all: $(INTF) $(LIBS)
+all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
 
 libs: $(LIBS)
 
-base64pp: base64_main.ml all libstdext_stubs.a
-       ocamlfind $(OCAMLOPT) $(OCAMLOPTFLAGS) stdext.cmxa -linkpkg -o $@ $< -ccopt -L.
-
-fe_cli: fe_cli.ml all libstdext_stubs.a
-       ocamlfind $(OCAMLOPT) $(OCAMLOPTFLAGS) unix.cmxa ../uuid/uuid.cmxa ../rpc-light/rpc.cmx ../rpc-light/jsonrpc.cmx stdext.cmxa -linkpkg -o $@ $< -ccopt -L.
-
-fe_test: fe_test.ml all libstdext_stubs.a
-       ocamlfind $(OCAMLOPT) $(OCAMLOPTFLAGS) unix.cmxa ../uuid/uuid.cmxa ../rpc-light/rpc.cmx ../rpc-light/jsonrpc.cmx stdext.cmxa -linkpkg -I ../uuid -o $@ $< -ccopt -L.
-
-extentlistset_test: extentlistset_test.ml all libstdext_stubs.a
-       ocamlfind $(OCAMLOPT) $(OCAMLOPTFLAGS) unix.cmxa stdext.cmxa -linkpkg -o $@ $< -ccopt -L.
-
 stdext.cmxa: libstdext_stubs.a $(foreach obj,$(STDEXT_OBJS),$(obj).cmx)
        $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $@ -cclib -lstdext_stubs $(foreach obj,$(STDEXT_OBJS),$(obj).cmx)
 
 stdext.cma: $(foreach obj,$(STDEXT_OBJS),$(obj).cmo)
        $(OCAMLC) -a -dllib dllstdext_stubs.so -cclib -lstdext_stubs -o $@ $(foreach obj,$(STDEXT_OBJS),$(obj).cmo)
 
-stdext_stubs.a: unixext_stubs.o zerocheck_stub.o 
+stdext_stubs.a: unixext_stubs.o
        ocamlmklib -o stdext_stubs $+
 
-libstdext_stubs.a: unixext_stubs.o zerocheck_stub.o 
+libstdext_stubs.a: unixext_stubs.o
        ar rcs $@ $+
        ocamlmklib -o stdext_stubs $+
 
@@ -101,55 +44,22 @@ querycd: querycd.cmo
 #camlc unix.cma stdext.cma querycd.cmo -o querycd
 
 ## OBJS
-threadext.cmo: threadext.ml threadext.cmi
+threadext.cmo: threadext.ml
        $(OCAMLC) -thread -c -o $@ $<
 
-fecomms.cmo : fecomms.ml
-       $(OCAMLC) -I ../rpc-light -c -o $@ $<
-
-fe.cmo: fe.ml 
-       $(OCAMLC) -pp '$(FEPP)' -I ../jsonrpc -I ../rpc-light -c -o $@ $<
-
-forkhelpers.cmo: forkhelpers.ml forkhelpers.cmi
-       $(OCAMLC) -thread -I ../uuid -c -o $@ $<
-
-filenameext.cmo: filenameext.ml filenameext.cmi
+%.cmo: %.ml
        $(OCAMLC) -c -I ../uuid -o $@ $<
 
-%.cmo: %.ml %.cmi
-       $(OCAMLC) -c -o $@ $<
-
 threadext.cmi: threadext.mli
        $(OCAMLC) -thread -c -o $@ $<
 
-forkhelpers.cmi: forkhelpers.mli
-       $(OCAMLC) -thread -c -o $@ $<
-
-filenameext.cmi: filenameext.mli
-       $(OCAMLC) -c -I ../uuid -o $@ $<
-
-fe.cmi: fe.cmo
-       $(OCAMLC) -pp '$(FEPP)' -c -o $@ $<
-
 %.cmi: %.mli
-       $(OCAMLC) -c -o $@ $<
-
-fe.cmx: fe.ml 
-       $(OCAMLOPT) -pp '$(FEPP)' -I ../rpc-light -c -o $@ $<
+       $(OCAMLC) -c -I ../uuid -o $@ $<
 
-threadext.cmx: threadext.ml threadext.cmi
+threadext.cmx: threadext.ml
        $(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -c -o $@ $<
 
-fecomms.cmx : fecomms.ml
-       $(OCAMLOPT) -I ../rpc-light -c -o $@ $<
-
-forkhelpers.cmx: forkhelpers.ml forkhelpers.cmi
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../uuid -thread -c -o $@ $<
-
-filenameext.cmx: filenameext.ml filenameext.cmi
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -c -I ../uuid -o $@ $<
-
-%.cmx: %.ml %.cmi
+%.cmx: %.ml
        $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../uuid -c -o $@ $<
 
 %.o: %.c
@@ -159,35 +69,17 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore stdext META $(INTF) $(LIBS) *.a *.so *.cmx
-
-.PHONY: bininstall
-bininstall: path = $(DESTDIR)$(LIBEXEC)
-bininstall: all
-       mkdir -p $(path)
-       $(IPROG) $(PROGRAMS) $(path)
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore stdext META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove stdext
 
-.PHONY: binuninstall
-binuninstall:
-       rm -f $(DESTDIR)$(LIBEXEC)$(PROGRAMS)
-
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "stdext" "package" "$(STDEXT_OBJS)" "." "threads,uuid,unix" ""
-
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
 #dependency:
 
-unixext.cmi: filenameext.cmi
-gzip.cmi: forkhelpers.cmi
-sha1sum.cmi: forkhelpers.cmi
-tar.cmi: bigbuffer.cmi
+unixext.cmo : filenameext.ml
+unixext.cmx : filenameext.ml
index 00b50948c6e228014ceb8bff2a2c925a655ea103..ab3d8a395726ecaa7effe64ba2e57b3e6b1ac07f 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Array = struct include Array
 
 (* Useful for vector addition. *)
index 3f10861b8e91c42e1da3b19ef89685497963e249..b2f9d08669fb526e9d872cc290169f5cac1f5ba5 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Array :
   sig
     external length : 'a array -> int = "%array_length"
index fec2e92abf18f264f42c6fcf03637c55cccb987b..0de8bf8f9a231e317d44b5c2049068e89013dffc 100644 (file)
@@ -1,15 +1,6 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2007 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *)
 
 type t = {
@@ -24,13 +15,6 @@ let make () = { cells = Array.make default_array_len None; index = 0L }
 
 let length bigbuf = bigbuf.index
 
-let get bigbuf n =
-       let array_offset = Int64.to_int (Int64.div n (Int64.of_int cell_size)) in
-       let cell_offset = Int64.to_int (Int64.rem n (Int64.of_int cell_size)) in
-       match bigbuf.cells.(array_offset) with
-       | None -> "".[0]
-       | Some buf -> buf.[cell_offset]
-
 let rec append_substring bigbuf s offset len =
        let array_offset = Int64.to_int (Int64.div bigbuf.index (Int64.of_int cell_size)) in
        let cell_offset = Int64.to_int (Int64.rem bigbuf.index (Int64.of_int cell_size)) in
@@ -59,8 +43,6 @@ let rec append_substring bigbuf s offset len =
        );
        ()
 
-let append_string b s = append_substring b s 0 (String.length s)
-
 let to_fct bigbuf f =
        let array_offset = Int64.to_int (Int64.div bigbuf.index (Int64.of_int cell_size)) in
        let cell_offset = Int64.to_int (Int64.rem bigbuf.index (Int64.of_int cell_size)) in
@@ -69,17 +51,16 @@ let to_fct bigbuf f =
        for i = 0 to array_offset - 1
        do
                match bigbuf.cells.(i) with
-               | None      -> (* should never happen *) ()
+               | None      -> (* ?!?!? *) ()
                | Some cell -> f cell
        done;
 
-       if(cell_offset > 0) then
-         (* copy last cell *)
-         begin match bigbuf.cells.(array_offset) with
-           | None      -> (* Should never happen (any more) *) ()
-           | Some cell -> f (String.sub cell 0 cell_offset)
-         end
-
+       (* copy last cell *)
+       begin match bigbuf.cells.(array_offset) with
+       | None      -> (* ?!?!?! *) ()
+       | Some cell -> f (String.sub cell 0 cell_offset)
+       end;
+       ()
 
 let to_string bigbuf =
        if bigbuf.index > (Int64.of_int Sys.max_string_length) then
@@ -94,18 +75,5 @@ let to_string bigbuf =
        );
        dest
 
-
-let test max =
-  let rec inner n =
-    if n>max then () else begin
-      let bb = make () in
-      let s = String.create n in
-      append_substring bb s 0 n;
-      assert ((to_string bb)=s);
-      inner (n+1)
-    end
-  in 
-  inner 0
-
 let to_stream bigbuf outchan =
        to_fct bigbuf (fun s -> output_string outchan s)
index b56764e0c58b191ae0e9ed755f2696e0cbead39c..fe734589c0f8e321150198b61a379d3d1ede37ac 100644 (file)
@@ -1,25 +1,7 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type t
 val make : unit -> t
 val length : t -> int64
-val get : t -> int64 -> char
 val append_substring : t -> string -> int -> int -> unit
-
-(** [append_string b s] appends the string [x] to the big buffer [b] *)
-val append_string : t -> string -> unit
-
 val to_fct : t -> (string -> unit) -> unit
 val to_string : t -> string
 val to_stream : t -> out_channel -> unit
index 11f8c9f1e7fca0c9d93f503f0e27201e4b7f8b2c..9eddbefaaa10638810f5a1bb6888da03e67dd5b1 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 (** Makes a new file in the same directory as 'otherfile' *)
 let temp_file_in_dir otherfile =
index 5529c3959a96bb22ce9fe9721774b44a78b439b9..b4e2a469cc025f4834bdf0d4eec8fda85045c884 100644 (file)
@@ -1,14 +1 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 val temp_file_in_dir : string -> string
index 4b64ebf3de66c55a27a8ac40ad94915de171a602..fb4e2c2e029cfc74f2af855ea6696d7c2a70a4c2 100644 (file)
@@ -1,19 +1,13 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (c) 2006-2008 Citrix Systems Ltd.
+ * Authors Vincent Hanquez   <vincent@xensource.com>
+ *         Thomas Gazagnaire <thomas.gazagnaire@citrix.com>
+ * All rights reserved.
  *)
 
 type t = { size: int; mutable current: int; data: (float,Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Array1.t ; }
 
+(** create a ring structure with @size record. records inited to @initval *)
 let make size init =
        let ring = 
                { size = size; current = size - 1; data = Bigarray.Array1.create Bigarray.float32 Bigarray.c_layout size; }
@@ -23,14 +17,17 @@ let make size init =
        done;
        ring
 
+(** length of the ring *)
 let length ring = ring.size
 
+(** push into the ring one element *)
 let push ring e =
        ring.current <- ring.current + 1;
        if ring.current = ring.size then
                ring.current <- 0;
        Bigarray.Array1.set ring.data ring.current e
 
+(** get the @ith old element from the ring *)
 let peek ring i =
        if i >= ring.size then
                raise (Invalid_argument "peek: index");
@@ -39,8 +36,10 @@ let peek ring i =
                if offset >= 0 then offset else ring.size + offset in
        Bigarray.Array1.get ring.data index
 
+(** get the top element of the ring *)
 let top ring = Bigarray.Array1.get ring.data ring.current
 
+(** iterate over nb element of the ring, starting from the top *)
 let iter_nb ring f nb =
        if nb > ring.size then
                raise (Invalid_argument "iter_nb: nb");
@@ -50,7 +49,7 @@ let iter_nb ring f nb =
                f (peek ring i)
        done
 
-(* iter directly on all element without using the index *)
+(** iter directly on all element without using the index *)
 let iter f a = 
        for i=0 to Bigarray.Array1.dim a - 1 do
                f (Bigarray.Array1.get a i)
@@ -59,8 +58,10 @@ let iter f a =
 let raw_iter ring f =
        iter f ring.data
 
+(** iterate over all element of the ring, starting from the top *)
 let iter ring f = iter_nb ring f (ring.size)
 
+(** get array of latest #nb value *)
 let get_nb ring nb =
        if nb > ring.size then
                raise (Invalid_argument "get_nb: nb");
@@ -73,4 +74,3 @@ let get_nb ring nb =
        a
 
 let get ring = get_nb ring (ring.size)
-
index 38a60d1a99019e60a56d3329264a68073c51f000..1c87585138f42e83b1b42500750983ac1270ef88 100644 (file)
@@ -1,48 +1,15 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-(** Ring structures *)
 type t = {
   size : int;
   mutable current : int;
   data : (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Array1.t;
 }
-
-(** create a ring structure with [size] record; records initialised to [init] *)
 val make : int -> float -> t
-
-(** length of the ring *)
 val length : t -> int
-
-(** push into the ring one element *)
 val push : t -> float -> unit
-
-(** get the i{^th} old element from the ring *)
 val peek : t -> int -> float
-
-(** get the top element of the ring *)
 val top : t -> float
-
-(** iterate over nb element of the ring, starting from the top *)
 val iter_nb : t -> (float -> 'a) -> int -> unit
-
 val raw_iter : t -> (float -> 'a) -> unit
-
-(** iterate over all elements of the ring, starting from the top *)
 val iter : t -> (float -> 'a) -> unit
-
-(** get array of latest [nb] value *)
 val get_nb : t -> int -> float array
-
 val get : t -> float array
index bd156f9d2f6c235e7c073126b6ce5bf508d9db16..8d4ec746900db15dba9cd6fa0f56a027944b02d0 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Hashtbl = struct include Hashtbl
 
 let to_list tbl =
index dae1d8ac58df6342695d4e17763a282fca857770..d628745fe737ab6124f993f74e4e442826f278e3 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Hashtbl :
   sig
     type ('a, 'b) t = ('a, 'b) Hashtbl.t
index ffb31a2f638adef85bee022409a47e141b0d431e..3c21b25536f3c1de6aa560cb59b43e1b2ee8116b 100644 (file)
@@ -1,17 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-open Fun
 module List = struct include List
 
 (** Turn a list into a set *)
@@ -23,7 +9,6 @@ let subset s1 s2 = List.fold_left (&&) true (List.map (fun s->List.mem s s2) s1)
 let set_equiv s1 s2 = (subset s1 s2) && (subset s2 s1)
 
 let iteri f list = ignore (fold_left (fun i x -> f i x; i+1) 0 list)
-let iteri_right f list = ignore (fold_right (fun x i -> f i x; i+1) list 0)
 
 let rec inv_assoc k = function
        | [] -> raise Not_found
@@ -147,9 +132,18 @@ let unrle l =
 let inner fold_left2 base f l1 l2 g =
        fold_left2 (fun accu e1 e2 -> g accu (f e1 e2)) base l1 l2
 
-let rec is_sorted compare list =
+let filter_map f list =
+       List.fold_right
+               begin
+                       fun element list -> match (f element) with
+                               | Some x -> x :: list
+                               | None -> list
+               end
+               list []
+
+let rec is_sorted compare list = 
        match list with
-               | x :: y :: list ->
+               | x :: y :: list -> 
                        if compare x y <= 0
                                then is_sorted compare (y :: list)
                                else false
@@ -162,51 +156,4 @@ let set_difference a b = List.filter (fun x -> not(List.mem x b)) a
 
 let assoc_default k l d =
   if List.mem_assoc k l then List.assoc k l else d
-
-let map_assoc_with_key op al =
-       List.map (fun (k, v1) -> (k, op k v1)) al
-
-(* Like the Lisp cons *)
-let cons a b = a :: b
-
-(* Could use fold_left to get the same value, but that would necessarily go through the whole list everytime, instead of the first n items, only. *)
-(* ToDo: This is complicated enough to warrant a test. *)
-(* Is it wise to fail silently on negative values?  (They are treated as zero, here.)
-   Pro: Would mask fewer bugs.
-   Con: Less robust.
-*)
-let take n list =
-       let rec helper i acc list =
-       if i <= 0 || list = []
-       then acc
-       else helper (i-1)  (List.hd list :: acc) (List.tl list)
-       in List.rev $ helper n [] list
-
-(* Thanks to sharing we only use linear space. (Roughly double the space needed for the spine of the original list) *)
-let rec tails = function
-       | [] -> [[]]
-       | (_::xs) as l -> l :: tails xs
-
-let safe_hd = function
-       | a::_ -> Some a
-       | [] -> None
-
-let rec replace_assoc key new_value = function
-       | [] -> []
-       | (k, _) as p :: tl ->
-               if k = key then
-                       (key, new_value) :: tl
-               else
-                       p :: replace_assoc key new_value tl
-
-let make_assoc op l = map (fun key -> key, op key) l
-
-let unbox_list a = List.map Opt.unbox (List.filter Opt.is_boxed a)
-
-let filter_map f list =
-       (unbox_list +++ map) f list
-
-let restrict_with_default default keys al =
-       make_assoc (fun k -> assoc_default k al default) keys
-
 end
index 2f4fee4f563f787eb14917fe029d572a73e5479f..1004fa92fc28bf3e91ae772e8a420cd91776e297 100644 (file)
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module List :
-sig
-       val setify : 'a list -> 'a list
-       val subset : 'a list -> 'a list -> bool
-       val set_equiv : 'a list -> 'a list -> bool
-       val length : 'a list -> int
-       val hd : 'a list -> 'a
-       val tl : 'a list -> 'a list
-       val nth : 'a list -> int -> 'a
-       val rev : 'a list -> 'a list
-       val append : 'a list -> 'a list -> 'a list
-       val rev_append : 'a list -> 'a list -> 'a list
-       val concat : 'a list list -> 'a list
-       val flatten : 'a list list -> 'a list
-       val iter : ('a -> unit) -> 'a list -> unit
-       val map : ('a -> 'b) -> 'a list -> 'b list
-       val rev_map : ('a -> 'b) -> 'a list -> 'b list
-       val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
-       val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
-       val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
-       val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
-       val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
-       val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
-       val fold_right2 :
-               ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
-       val for_all : ('a -> bool) -> 'a list -> bool
-       val exists : ('a -> bool) -> 'a list -> bool
-       val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
-       val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
-       val mem : 'a -> 'a list -> bool
-       val memq : 'a -> 'a list -> bool
-       val find : ('a -> bool) -> 'a list -> 'a
-       val filter : ('a -> bool) -> 'a list -> 'a list
-       val find_all : ('a -> bool) -> 'a list -> 'a list
-       val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
-       val assoc : 'a -> ('a * 'b) list -> 'b
-       val assq : 'a -> ('a * 'b) list -> 'b
-       val mem_assoc : 'a -> ('a * 'b) list -> bool
-       val mem_assq : 'a -> ('a * 'b) list -> bool
-       val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
-       val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
-       val split : ('a * 'b) list -> 'a list * 'b list
-       val combine : 'a list -> 'b list -> ('a * 'b) list
-       val sort : ('a -> 'a -> int) -> 'a list -> 'a list
-       val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
-       val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
-       val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
-
-       (** Perform a lookup on an association list of (value, key) pairs. *)
-       val inv_assoc : 'a -> ('b * 'a) list -> 'b
-
-       (** A tail-recursive map. *)
-       val map_tr : ('a -> 'b) -> 'a list -> 'b list
-
-       (** Count the number of list elements matching the given predicate. *)
-       val count : ('a -> bool) -> 'a list -> int
-
-       (** Find the indices of all elements matching the given predicate. *)
-       val position : ('a -> bool) -> 'a list -> int list
-
-       (** Map the given function over a list, supplying the integer
-           index as well as the element value. *)
-       val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
-
-       val iteri : (int -> 'a -> unit) -> 'a list -> unit
-
-       val iteri_right : (int -> 'a -> unit) -> 'a list -> unit
-
-       (** Map the given function over a list in reverse order. *)
-       val rev_mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
-
-       (** Tail-recursive [mapi]. *)
-       val mapi_tr : (int -> 'a -> 'b) -> 'a list -> 'b list
-
-       (** Split a list at the given index to give a pair of lists. *)
-       val chop : int -> 'a list -> 'a list * 'a list
-
-       (** Split a list at the given index to give a pair of lists, the first in
-                 reverse order. *)
-       val rev_chop : int -> 'a list -> 'a list * 'a list
-
-       (** Tail-recursive [chop]. *)
-       val chop_tr : int -> 'a list -> 'a list * 'a list
-
-       (** Split a list into lists with the given number of elements. *)
-       val dice : int -> 'a list -> 'a list list
-
-       (** Extract the sub-list between the given indices. *)
-       val sub : int -> int -> 'a list -> 'a list
-
-       (** Remove the element at the given index. *)
-       val remove : int -> 'a list -> 'a list
-
-       (** Extract the element at the given index, returning the element and the
-               list without that element. *)
-       val extract : int -> 'a list -> 'a * 'a list
-
-       (** Insert the given element at the given index. *)
-       val insert : int -> 'a -> 'a list -> 'a list
-
-       (** Replace the element at the given index with the given value. *)
-       val replace : int -> 'a -> 'a list -> 'a list
-
-       (** Apply the given function to the element at the given index. *)
-       val morph : int -> ('a -> 'a) -> 'a list -> 'a list
-
-       (** Insert the element [e] between every pair of adjacent elements in the
-           given list. *)
-       val between : 'a -> 'a list -> 'a list
-
-       (** Tail-recursive [between]. *)
-       val between_tr : 'a -> 'a list -> 'a list
-
-       (** Generate a random permutation of the given list. *)
-       val randomize : 'a list -> 'a list
-
-       (** Distribute the given element over the given list, returning a list of
-           lists with the new element in each position. *)
-       val distribute : 'a -> 'a list -> 'a list list
-
-       (** Generate all permutations of the given list. *)
-       val permute : 'a list -> 'a list list
-
-       (** Run-length encode the given list using the given equality function. *)
-       val rle_eq : ('a -> 'a -> bool) -> 'a list -> ('a * int) list
+  sig
+    val setify : 'a list -> 'a list
+    val subset : 'a list -> 'a list -> bool
+    val set_equiv : 'a list -> 'a list -> bool
+    val length : 'a list -> int
+    val hd : 'a list -> 'a
+    val tl : 'a list -> 'a list
+    val nth : 'a list -> int -> 'a
+    val rev : 'a list -> 'a list
+    val append : 'a list -> 'a list -> 'a list
+    val rev_append : 'a list -> 'a list -> 'a list
+    val concat : 'a list list -> 'a list
+    val flatten : 'a list list -> 'a list
+    val iter : ('a -> unit) -> 'a list -> unit
+    val map : ('a -> 'b) -> 'a list -> 'b list
+    val rev_map : ('a -> 'b) -> 'a list -> 'b list
+    val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
+    val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
+    val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
+    val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
+    val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
+    val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
+    val fold_right2 :
+      ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
+    val for_all : ('a -> bool) -> 'a list -> bool
+    val exists : ('a -> bool) -> 'a list -> bool
+    val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
+    val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
+    val mem : 'a -> 'a list -> bool
+    val memq : 'a -> 'a list -> bool
+    val find : ('a -> bool) -> 'a list -> 'a
+    val filter : ('a -> bool) -> 'a list -> 'a list
+    val find_all : ('a -> bool) -> 'a list -> 'a list
+    val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
+    val assoc : 'a -> ('a * 'b) list -> 'b
+    val assq : 'a -> ('a * 'b) list -> 'b
+    val mem_assoc : 'a -> ('a * 'b) list -> bool
+    val mem_assq : 'a -> ('a * 'b) list -> bool
+    val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
+    val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
+    val split : ('a * 'b) list -> 'a list * 'b list
+    val combine : 'a list -> 'b list -> ('a * 'b) list
+    val sort : ('a -> 'a -> int) -> 'a list -> 'a list
+    val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
+    val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
+    val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
+
+    (** Perform a lookup on an association list of (value, key) pairs. *)
+    val inv_assoc : 'a -> ('b * 'a) list -> 'b
+
+    (** A tail-recursive map. *)
+    val map_tr : ('a -> 'b) -> 'a list -> 'b list
+
+    (** Count the number of list elements matching the given predicate. *)
+    val count : ('a -> bool) -> 'a list -> int
+
+    (** Find the indices of all elements matching the given predicate. *)
+    val position : ('a -> bool) -> 'a list -> int list
+
+    (** Map the given function over a list, supplying the integer index as well
+       as the element value. *)
+    val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
+
+    val iteri : (int -> 'a -> unit) -> 'a list -> unit
+
+    (** Map the given function over a list in reverse order. *)
+    val rev_mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
+
+    (** Tail-recursive [mapi]. *)
+    val mapi_tr : (int -> 'a -> 'b) -> 'a list -> 'b list
+
+    (** Split a list at the given index to give a pair of lists. *)
+    val chop : int -> 'a list -> 'a list * 'a list
+
+    (** Split a list at the given index to give a pair of lists, the first in
+       reverse order. *)
+    val rev_chop : int -> 'a list -> 'a list * 'a list
+
+    (** Tail-recursive [chop]. *)
+    val chop_tr : int -> 'a list -> 'a list * 'a list
+
+    (** Split a list into lists with the given number of elements. *)
+    val dice : int -> 'a list -> 'a list list
+
+    (** Extract the sub-list between the given indices. *)
+    val sub : int -> int -> 'a list -> 'a list
+
+    (** Remove the element at the given index. *)
+    val remove : int -> 'a list -> 'a list
+
+    (** Extract the element at the given index, returning the element and the
+       list without that element. *)
+    val extract : int -> 'a list -> 'a * 'a list
+
+    (** Insert the given element at the given index. *)
+    val insert : int -> 'a -> 'a list -> 'a list
+
+    (** Replace the element at the given index with the given value. *)
+    val replace : int -> 'a -> 'a list -> 'a list
+
+    (** Apply the given function to the element at the given index. *)
+    val morph : int -> ('a -> 'a) -> 'a list -> 'a list
+
+    (** Insert the element [e] between every pair of adjacent elements in the
+       given list. *)
+    val between : 'a -> 'a list -> 'a list
+
+    (** Tail-recursive [between]. *)
+    val between_tr : 'a -> 'a list -> 'a list
+
+    (** Generate a random permutation of the given list. *)
+    val randomize : 'a list -> 'a list
+
+    (** Distribute the given element over the given list, returning a list of
+       lists with the new element in each position. *)
+    val distribute : 'a -> 'a list -> 'a list list
+
+    (** Generate all permutations of the given list. *)
+    val permute : 'a list -> 'a list list
+
+    (** Run-length encode the given list using the given equality function. *)
+    val rle_eq : ('a -> 'a -> bool) -> 'a list -> ('a * int) list
+
+    (** Run-length encode the given list using built-in equality. *)
+    val rle : 'a list -> ('a * int) list
+
+    (** Decode a run-length encoded list. *)
+    val unrle : (int * 'a) list -> 'a list
 
-       (** Run-length encode the given list using built-in equality. *)
-       val rle : 'a list -> ('a * int) list
-
-       (** Decode a run-length encoded list. *)
-       val unrle : (int * 'a) list -> 'a list
-
-       (** Compute the inner product of two lists. *)
-       val inner :
-               (('a -> 'b -> 'c -> 'd) -> 'e -> 'f -> 'g -> 'h) ->
-               'e -> ('b -> 'c -> 'i) -> 'f -> 'g -> ('a -> 'i -> 'd) -> 'h
-
-       (** Applies a function f that generates optional values, to each
-           of the items in a list A [a1; ...; am], generating a new list of
-           non-optional values B [b1; ...; bn], with m >= n. For each value
-           a in list A, list B contains a corresponding value b if and only
-           if the application of (f a) results in Some b.  *)
+    (** Compute the inner product of two lists. *)
+    val inner :
+      (('a -> 'b -> 'c -> 'd) -> 'e -> 'f -> 'g -> 'h) ->
+      'e -> ('b -> 'c -> 'i) -> 'f -> 'g -> ('a -> 'i -> 'd) -> 'h
+       
+       (** Applies a function f that generates optional values, to each 
+           of the items in a list A [a1; ...; am], generating a new list
+           of non-optional values B [b1; ...; bn], with m >= n. For each
+           value a in list A, list B contains a corresponding value b if
+           and only if the application of (f a) results in Some b.      *)
        val filter_map : ('a -> 'b option) -> 'a list -> 'b list
 
        (** Returns true if and only if the given list is in sorted order
-           according to the given comparison function.  *)
+           according to the given comparison function.                  *)
        val is_sorted : ('a -> 'a -> int) -> 'a list -> bool
 
        (** Returns the intersection of two lists. *)
@@ -165,34 +150,8 @@ sig
        (** Returns the set difference of two lists *)
        val set_difference : 'a list -> 'a list -> 'a list
 
-       (** Act as List.assoc, but return the given default value if the
-           key is not in the list. *)
-       val assoc_default : 'a -> ('a * 'b) list -> 'b -> 'b
-
-       (** [map_assoc_with_key op al] transforms every value in [al] based on the
-           key and the value using [op]. *)
-       val map_assoc_with_key : ('k -> 'v1 -> 'v2) -> ('k * 'v1) list -> ('k * 'v2) list
-
-       (* Like Lisp cons*)
-       val cons : 'a -> 'a list -> 'a list
-
-       (** [take n list] returns the first [n] elements of [list] (or less if list
-           is shorter).*)
-       val take : int -> 'a list -> 'a list
-
-       val tails : 'a list -> ('a list) list
-       val safe_hd : 'a list -> 'a option
-
-       (** Replace the value belonging to a key in an association list. *)
-       val replace_assoc : 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
-
-       val make_assoc : ('a -> 'b) -> 'a list -> ('a * 'b) list
-
-       (** Unbox all values from the option list. *)
-       val unbox_list : 'a option list -> 'a list
+    (** Act as List.assoc, but return the given default value if the key
+        is not in the list. *)
+    val assoc_default : 'a -> ('a * 'b) list -> 'b -> 'b
 
-       (** [restrict_with_default default keys al] makes a new association map
-           from [keys] to previous values for [keys] in [al]. If a key is not found
-           in [al], the [default] is used. *)
-       val restrict_with_default : 'v -> 'k list -> ('k * 'v) list -> ('k * 'v) list
-end
+  end
index 9f43b36cef92b55a18eaf2d84106365e197c1a7b..be2f5ca0c058cdbadbf09cbc976b42e7acfd49bd 100644 (file)
@@ -1,25 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-
-(* Perhaps it's better to use `option' from the ocaml-extlib extension
- * to the standard library instead?  (Although it would not suffice,
- * since it's not a super-set of our `opt'.)
- * (http://code.google.com/p/ocaml-extlib/)
- *)
-
-open Pervasiveext
-
 let iter f = function
        | Some x -> f x
        | None -> ()
@@ -52,8 +30,3 @@ let fold_right f opt accu =
        match opt with
        | Some x -> f x accu
        | None -> accu
-
-let join = function
-    | Some (Some a) -> Some a
-    | _ -> None
-
index 9e9ff3a106719708b66c0c1a7149ab4a80467d7b..17403b61dd00255eca51453457ed71f7aeecb204 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 val iter : ('a -> unit) -> 'a option -> unit
 val map : ('a -> 'b) -> 'a option -> 'b option
 val default : 'a -> 'a option -> 'a
@@ -19,4 +6,3 @@ val is_boxed : 'a option -> bool
 val to_list : 'a option -> 'a list
 val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b option -> 'a
 val fold_right : ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
-val join : ('a option) option -> 'a option
index 4c1dadf3660e8ca6efc04360c1844c3a7b61afeb..d8d6fac1bd6b6b092bd7f9acfa7ceb17d1cd1a2b 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (** apply the clean_f function after fct function has been called.
  * Even if fct raises an exception, clean_f is applied
  *)
@@ -27,8 +14,6 @@ let finally fct clean_f =
        clean_f ();
        result
 
-(* Those should go into the Opt module: *)
-
 let maybe_with_default d f v =
        match v with None -> d | Some x -> f x
 
@@ -55,10 +40,3 @@ let ignore_int32 v = let (_: int32) = v in ()
 let ignore_string v = let (_: string) = v in ()
 let ignore_float v = let (_: float) = v in ()
 let ignore_bool v = let (_: bool) = v in ()
-
-(* To avoid some parens: *)
-(* composition of functions: *)
-let (++) f g x = Fun.comp f g x
-
-(* and application *)
-let ($) f a = f a
index 49a734e7766c9fa5463e30e67f97fdd89229fc44..e10b51b5074176c4e3e14c04b40b74547da57a34 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 val exnhook : (exn -> unit) option ref
 val finally : (unit -> 'a) -> (unit -> 'b) -> 'a
 val maybe_with_default : 'b -> ('a -> 'b) -> 'a option -> 'b
@@ -25,6 +12,3 @@ val ignore_int64 : int64 -> unit
 val ignore_string : string -> unit
 val ignore_float : float -> unit
 val ignore_bool : bool -> unit
-
-val (++) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
-val ($) : ('a -> 'b) -> 'a -> 'b
index 84c55b909fe342160a48a83fb2889ff041aa2406..19b20d6510aadb436a3c299f66024a4f65e5901d 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright 2008 Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * efficient circular string queue
  *)
 type t = {
        sz: int;
index 7708d85b05657bede8c028d322283b238fc0dd92..a372eff2f3e03bf5e5614b7e01f5662108e46203 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type t = {
        sz: int;
        data: string;
index 5b362951b22cd25a8a7557830d139b86390237ab..5c0eace67e472dcb7208c76a6d67ddfb2cdab3fd 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type t = { l : int; u : int }
 
 let make l u =
index 0b78d6444eba8e009f56a54c69b75955f6e25119..2e542018d80f74afada26bf84eda76dcb1abd9ba 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type t
 
 (** Make a range. *)
index 3fb032c56a901ea4099a28b7297ca6dd159c8ee4..5d60939e40dd1bd42e58c73dac7cdb038c037017 100644 (file)
@@ -1,20 +1,13 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 type 'a t = { size: int; mutable current: int; data: 'a array; }
 
-(** create a ring structure with size record. records inited to initval *)
+(** create a ring structure with @size record. records inited to @initval *)
 let make size initval =
        { size = size; current = size - 1; data = Array.create size initval; }
 
@@ -28,7 +21,7 @@ let push ring e =
                ring.current <- 0;
        ring.data.(ring.current) <- e
 
-(** get the ith old element from the ring *)
+(** get the @ith old element from the ring *)
 let peek ring i =
        if i >= ring.size then
                raise (Invalid_argument "peek: index");
@@ -57,7 +50,7 @@ let raw_iter ring f =
 (** iterate over all element of the ring, starting from the top *)
 let iter ring f = iter_nb ring f (ring.size)
 
-(** get array of latest nb value *)
+(** get array of latest #nb value *)
 let get_nb ring nb =
        if nb > ring.size then
                raise (Invalid_argument "get_nb: nb");
index 95afdd1a04837a0c12a2d8d24fedd1030cc298db..64f5a7d09ec4ba6b00ca6876b6115cc774e01ad0 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type 'a t = { size : int; mutable current : int; data : 'a array; }
 val make : int -> 'a -> 'a t
 val length : 'a t -> int
index 5304a616f282a98ae414bf61a7ed9ebb53dce96b..8540acbde3b5e5a2105d2802d40193fe285097e3 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module String = struct include String
 
 let of_char c = String.make 1 c
@@ -89,7 +76,7 @@ let escaped ?rules string = match rules with
                concat "" (fold_right aux string [])
 
 (** Take a predicate and a string, return a list of strings separated by
-runs of characters where the predicate was true (excluding those characters from the result) *)
+runs of characters where the predicate was true *)
 let split_f p str =
        let not_p = fun x -> not (p x) in
        let rec split_one p acc = function
index 3cbe245b27ab8402b2b7d786b4ff02a0a4353efb..22a2d545fe6d39b2ce81ed6dabde703115cbe84f 100644 (file)
@@ -1,20 +1,6 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module String :
   sig
     external length : string -> int = "%string_length"
-    (** blabla *)
     external get : string -> int -> char = "%string_safe_get"
     external set : string -> int -> char -> unit = "%string_safe_set"
     external create : int -> string = "caml_create_string"
@@ -109,7 +95,7 @@ module String :
 (** find all occurences of needle in haystack and return all their respective index *)
     val find_all : string -> string -> int list
 
-    (** replace all [f] substring in [s] by [t] *)
+    (** replace all @f substring in @s by @t *)
     val replace : string -> string -> string -> string
 
     (** filter chars from a string *)
index 16cc396144462b76be6b1777a02c0b22920fd26e..127588209b1e4c37271566a9b572e49c783ec117 100644 (file)
@@ -1,15 +1,7 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006 XenSource Ltd.
+ * Author: Vincent Hanquez <vincent@xensource.com>
+ * Author: Anil Madhavapeddy <anil@xensource.com>
  *)
 
 module Mutex = struct
@@ -162,9 +154,3 @@ module Delay = struct
         | None -> x.signalled <- true   (* If the wait hasn't happened yet then store up the signal *)
       )
 end
-
-let keep_alive () =
-       while true do
-               Thread.delay 20000.
-       done
-       
index 1aa8e93f679e3ba083677ed83394af12b8cfe5cc..4caec98c72a988ea8576d70e955c32f1860c1b54 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Mutex :
   sig
     type t = Mutex.t
@@ -42,7 +29,3 @@ module Delay :
     (** Sends a signal to a waiting thread. See 'wait' *)
     val signal : t -> unit
   end
-  
-(** Keeps a thread alive without doing anything. Used e.g. in XML/RPC daemons. *)
-val keep_alive: unit -> unit
-
index d0d26e5f9c5c032b7adfd17f0945ca5f0419bd9a..3423cbe15ec7687ab5c64392feb5288aafe4907c 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Node =
 struct
        type ('a,'b) t =  {
index efc179715122e94fb9604cb4504679c573486573..fd6140b6095a3eddf72d3ffd13834cce7ccfe638 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (** Basic Implementation of polymorphic tries (ie. prefix trees) *)
 
 type ('a, 'b) t
index 1e6c2744ec922f09473103679e808d9277c06a88..9183cf042e131d4a5d6d8454abeb1c2e47dee1ba 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 open Pervasiveext
 
 exception Unix_error of int
@@ -85,31 +72,18 @@ let daemonize () =
                end
        | _ -> exit 0
 
-let file_lines_fold f start file_path =
-       let input = open_in file_path in
-       let rec fold accumulator =
-               let line =
-                       try Some (input_line input)
-                       with End_of_file -> None in
-               match line with
-                       | Some line -> fold (f accumulator line)
-                       | None -> accumulator in
-       finally
-               (fun () -> fold start)
-               (fun () -> close_in input)
-
-let file_lines_iter f file_path =
-       let input = open_in file_path in
+(** Run a function over every line in a file *)
+let readfile_line fn fname =
+       let fin = open_in fname in
        try
                while true do
-                       let line = input_line input in
-                       f line
-               done
+                       let line = input_line fin in
+                       fn line
+               done;
+               close_in fin;
        with
-               | End_of_file -> close_in input
-               | exn -> close_in input; raise exn
-
-let readfile_line = file_lines_iter
+       | End_of_file -> close_in fin
+       | exn -> close_in fin; raise exn
 
 (** open a file, and make sure the close is always done *)
 let with_file file mode perms f =
@@ -151,12 +125,11 @@ let read_whole_file_to_string fname =
 
 (** Opens a temp file, applies the fd to the function, when the function completes, renames the file
     as required. *)
-let atomic_write_to_file fname perms f =
+let atomic_write_to_file fname f =
   let tmp = Filenameext.temp_file_in_dir fname in
-  Unix.chmod tmp perms;
   Pervasiveext.finally
     (fun () ->
-      let fd = Unix.openfile tmp [Unix.O_WRONLY; Unix.O_CREAT] perms (* ignored since the file exists *) in
+      let fd = Unix.openfile tmp [Unix.O_WRONLY; Unix.O_CREAT] 0o644 in
       let result = Pervasiveext.finally
        (fun () -> f fd)
        (fun () -> Unix.close fd) in
@@ -167,7 +140,7 @@ let atomic_write_to_file fname perms f =
 
 (** Atomically write a string to a file *)
 let write_string_to_file fname s =
-  atomic_write_to_file fname 0o644 (fun fd ->
+  atomic_write_to_file fname (fun fd ->
     let len = String.length s in
     let written = Unix.write fd s 0 len in
     if written <> len then (failwith "Short write occured!"))
@@ -201,7 +174,7 @@ let copy_file ?limit ifd ofd =
                let num64 = Int64.of_int num in
 
                limit := Opt.map (fun x -> Int64.sub x num64) !limit;
-               ignore_int (Unix.write ofd buffer 0 num);
+               Unix.write ofd buffer 0 num;
                total_bytes := Int64.add !total_bytes num64;
                finished := num = 0 || !limit = Some 0L;
        done;
@@ -347,18 +320,6 @@ let really_read_string fd length =
   really_read fd buf 0 length;
   buf
 
-let really_read_bigbuffer fd bigbuf n =
-       let chunk = 4096 in
-       let s = String.make chunk '\000' in
-       let written = ref 0L in
-       while !written < n do
-               let remaining = Int64.sub n !written in
-               let to_write = min remaining (Int64.of_int chunk) in
-               really_read fd s 0 (Int64.to_int to_write);
-               Bigbuffer.append_substring bigbuf s 0 (Int64.to_int to_write);
-               written := Int64.add !written to_write;
-       done
-
 let really_write fd string off n =
        let written = ref 0 in
        while !written < n
@@ -460,7 +421,6 @@ let double_fork f =
 external set_tcp_nodelay : Unix.file_descr -> bool -> unit = "stub_unixext_set_tcp_nodelay"
 
 external fsync : Unix.file_descr -> unit = "stub_unixext_fsync"
-external blkgetsize64 : Unix.file_descr -> int64 = "stub_unixext_blkgetsize64"
 
 external get_max_fd : unit -> int = "stub_unixext_get_max_fd"
 
@@ -486,6 +446,27 @@ let close_all_fds_except (fds: Unix.file_descr list) =
     if not(List.mem i fds') then close' i
   done
 
+exception Process_output_error of string
+let get_process_output ?(handler) cmd : string =
+       let inchan = Unix.open_process_in cmd in
+
+       let buffer = Buffer.create 1024
+       and buf = String.make 1024 '\000' in
+       
+       let rec read_until_eof () =
+               let rd = input inchan buf 0 1024 in
+               if rd = 0 then
+                       ()
+               else (
+                       Buffer.add_substring buffer buf 0 rd;
+                       read_until_eof ()
+               ) in
+       (* Make sure an exception doesn't prevent us from waiting for the child process *)
+       (try read_until_eof () with _ -> ());
+       match (Unix.close_process_in inchan), handler with
+       | Unix.WEXITED 0, _ -> Buffer.contents buffer
+       | Unix.WEXITED n, Some handler -> handler cmd n
+       | _ -> raise (Process_output_error cmd)
 
 (** Remove "." and ".." from paths (NB doesn't attempt to resolve symlinks) *)
 let resolve_dot_and_dotdot (path: string) : string = 
@@ -526,6 +507,19 @@ let current_cursor_pos fd =
   (* 'seek' to the current position, exploiting the return value from Unix.lseek as the new cursor position *)
   Unix.lseek fd 0 Unix.SEEK_CUR 
 
+type statfs_t = {
+       statfs_type: int64;
+       statfs_bsize: int;
+       statfs_blocks: int64;
+       statfs_bfree: int64;
+       statfs_bavail: int64;
+       statfs_files: int64;
+       statfs_ffree: int64;
+       statfs_namelen: int;
+}
+
+external statfs: string -> statfs_t = "stub_unixext_statfs"
+
 module Fdset = struct
        type t
        external of_list : Unix.file_descr list -> t = "stub_fdset_of_list"
@@ -542,18 +536,6 @@ module Fdset = struct
        let select_wo w t = _select_wo w t
 end
 
-let wait_for_path path delay timeout =
-  let rec inner ttl =
-    if ttl=0 then failwith "No path!";
-    try 
-      ignore(Unix.stat path)
-    with _ ->
-      delay 0.5;
-      inner (ttl - 1)
-  in
-  inner (timeout * 2)
-       
-
 let _ = Callback.register_exception "unixext.unix_error" (Unix_error (0))
 
 (* HTTP helpers *)
@@ -668,6 +650,3 @@ end
 
 let http_get = Http.get
 let http_put = Http.put
-
-external send_fd : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> Unix.file_descr -> int = "stub_unix_send_fd_bytecode" "stub_unix_send_fd"
-external recv_fd : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddr * Unix.file_descr = "stub_unix_recv_fd"
index a07aff67df8f1bbf59a3bce6ff369af3ba825e7d..2b7beeac051363a95f5ce06074fe80f6cbca6642 100644 (file)
@@ -1,18 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-(** A collection of extensions to the [Unix] module. *)
-
 external _exit : int -> unit = "unix_exit"
 val unlink_safe : string -> unit
 val mkdir_safe : string -> Unix.file_perm -> unit
@@ -22,19 +7,10 @@ val pidfile_read : string -> int option
 val daemonize : unit -> unit
 val with_file : string -> Unix.open_flag list -> Unix.file_perm -> (Unix.file_descr -> 'a) -> 'a
 val with_directory : string -> (Unix.dir_handle -> 'a) -> 'a
-
-(** Folds function [f] over every line in the file at [file_path] using the
-starting value [start]. *)
-val file_lines_fold : ('a -> string -> 'a) -> 'a -> string -> 'a
-
-(** Applies function [f] to every line in the file at [file_path]. *)
-val file_lines_iter : (string -> unit) -> string -> unit
-
-(** Alias for function [file_lines_iter]. *)
 val readfile_line : (string -> 'a) -> string -> unit
 val read_whole_file : int -> int -> Unix.file_descr -> string
 val read_whole_file_to_string : string -> string
-val atomic_write_to_file : string -> Unix.file_perm -> (Unix.file_descr -> 'a) -> 'a
+val atomic_write_to_file : string -> (Unix.file_descr -> 'a) -> 'a
 val write_string_to_file : string -> string -> unit
 val execv_get_output : string -> string array -> int * Unix.file_descr
 val copy_file : ?limit:int64 -> Unix.file_descr -> Unix.file_descr -> int64
@@ -68,7 +44,6 @@ val make_endpoint : Unix.file_descr -> endpoint
 val proxy : Unix.file_descr -> Unix.file_descr -> unit
 val really_read : Unix.file_descr -> string -> int -> int -> unit
 val really_read_string : Unix.file_descr -> int -> string
-val really_read_bigbuffer : Unix.file_descr -> Bigbuffer.t -> int64 -> unit
 val really_write : Unix.file_descr -> string -> int -> int -> unit
 val really_write_string : Unix.file_descr -> string -> unit
 exception Timeout
@@ -83,17 +58,29 @@ external set_tcp_nodelay : Unix.file_descr -> bool -> unit
   = "stub_unixext_set_tcp_nodelay"
 external fsync : Unix.file_descr -> unit = "stub_unixext_fsync"
 external get_max_fd : unit -> int = "stub_unixext_get_max_fd"
-external blkgetsize64 : Unix.file_descr -> int64 = "stub_unixext_blkgetsize64"
-
 val int_of_file_descr : Unix.file_descr -> int
 val file_descr_of_int : int -> Unix.file_descr
 val close_all_fds_except : Unix.file_descr list -> unit
+val get_process_output : ?handler:(string -> int -> string) -> string -> string
 val resolve_dot_and_dotdot : string -> string
 
 val seek_to : Unix.file_descr -> int -> int
 val seek_rel : Unix.file_descr -> int -> int
 val current_cursor_pos : Unix.file_descr -> int
 
+type statfs_t = {
+       statfs_type: int64;
+       statfs_bsize: int;
+       statfs_blocks: int64;
+       statfs_bfree: int64;
+       statfs_bavail: int64;
+       statfs_files: int64;
+       statfs_ffree: int64;
+       statfs_namelen: int;
+}
+
+val statfs: string -> statfs_t
+
 module Fdset : sig
        type t
        external of_list : Unix.file_descr list -> t = "stub_fdset_of_list"
@@ -108,12 +95,7 @@ module Fdset : sig
        val select_wo : t -> float -> t
 end
 
-val wait_for_path : string -> (float -> unit) -> int -> unit
-
 (** Download a file via an HTTP GET *)
 val http_get: open_tcp:(server:string -> (in_channel * out_channel)) -> uri:string -> filename:string -> server:string -> unit
 (** Upload a file via an HTTP PUT *)
 val http_put: open_tcp:(server:string -> (in_channel * out_channel)) -> uri:string -> filename:string -> server:string -> unit
-
-external send_fd : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> Unix.file_descr -> int = "stub_unix_send_fd_bytecode" "stub_unix_send_fd"
-external recv_fd : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddr * Unix.file_descr = "stub_unix_recv_fd"
index b3e0905b73103bc4bbb8918fb03b978891dbeca1..ada4d0bb025c46d2bd5272ae913f6c078bd876ae 100644 (file)
@@ -1,27 +1,11 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <errno.h>
 #include <netinet/tcp.h>
 #include <netinet/in.h>
-#include <sys/un.h>
 #include <string.h>
 #include <unistd.h> /* needed for _SC_OPEN_MAX */
 #include <stdio.h> /* snprintf */
-#include <sys/ioctl.h>
-#include <linux/fs.h> 
 
 #include <caml/mlvalues.h>
 #include <caml/memory.h>
 #include <caml/custom.h>
 #include <caml/fail.h>
 #include <caml/callback.h>
-#include <caml/unixsupport.h>
+
+static void failwith_errno(void)
+{
+        char buf[256];
+       char buf2[280];
+       memset(buf, '\0', sizeof(buf));
+       strerror_r(errno, buf, sizeof(buf));
+       snprintf(buf2, sizeof(buf2), "errno: %d msg: %s", errno, buf);
+       caml_failwith(buf2);
+}
 
 /* Set the TCP_NODELAY flag on a Unix.file_descr */
 CAMLprim value stub_unixext_set_tcp_nodelay (value fd, value bool)
@@ -39,7 +32,7 @@ CAMLprim value stub_unixext_set_tcp_nodelay (value fd, value bool)
        int c_fd = Int_val(fd);
        int opt = (Bool_val(bool)) ? 1 : 0;
        if (setsockopt(c_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) != 0){
-               uerror("setsockopt", Nothing);
+               failwith_errno();
        }
        CAMLreturn(Val_unit);
 }
@@ -48,20 +41,10 @@ CAMLprim value stub_unixext_fsync (value fd)
 {
        CAMLparam1(fd);
        int c_fd = Int_val(fd);
-       if (fsync(c_fd) != 0) uerror("fsync", Nothing);
+       if (fsync(c_fd) != 0) failwith_errno();
        CAMLreturn(Val_unit);
 }
        
-CAMLprim value stub_unixext_blkgetsize64(value fd)
-{
-  CAMLparam1(fd);
-  uint64_t size;
-  int c_fd = Int_val(fd);
-  if(ioctl(c_fd,BLKGETSIZE64,&size)) {
-    uerror("ioctl(BLKGETSIZE64)", Nothing);
-  }
-  CAMLreturn(caml_copy_int64(size));
-}
 
 CAMLprim value stub_unixext_get_max_fd (value unit)
 {
@@ -71,6 +54,30 @@ CAMLprim value stub_unixext_get_max_fd (value unit)
        CAMLreturn(Val_int(maxfd));
 }
 
+#include <sys/vfs.h>
+
+CAMLprim value stub_unixext_statfs(value path)
+{
+       CAMLparam1(path);
+       CAMLlocal1(statinfo);
+       struct statfs info;
+
+       if (statfs(String_val(path), &info))
+               failwith_errno();
+
+       statinfo = caml_alloc_tuple(8);
+       Store_field(statinfo, 0, caml_copy_int64(info.f_type));
+       Store_field(statinfo, 1, Val_int(info.f_bsize));
+       Store_field(statinfo, 2, caml_copy_int64(info.f_blocks));
+       Store_field(statinfo, 3, caml_copy_int64(info.f_bfree));
+       Store_field(statinfo, 4, caml_copy_int64(info.f_bavail));
+       Store_field(statinfo, 5, caml_copy_int64(info.f_files));
+       Store_field(statinfo, 6, caml_copy_int64(info.f_ffree));
+       Store_field(statinfo, 7, Val_int(info.f_namelen));
+
+       CAMLreturn(statinfo);
+}
+
 #define FDSET_OF_VALUE(v) (&(((struct fdset_t *) v)->fds))
 #define MAXFD_OF_VALUE(v) (((struct fdset_t *) v)->max)
 struct fdset_t { fd_set fds; int max; };
@@ -271,137 +278,3 @@ CAMLprim value stub_fdset_is_empty(value set)
        
        CAMLreturn(Bool_val(ret == 0));
 }
-
-static int msg_flag_table[] = {
-  MSG_OOB, MSG_DONTROUTE, MSG_PEEK
-};
-
-#define UNIX_BUFFER_SIZE 16384
-
-CAMLprim value stub_unix_send_fd(value sock, value buff, value ofs, value len, value flags, value fd)
-{
-  CAMLparam5(sock,buff,ofs,len,flags);
-  CAMLxparam1(fd);
-  int ret,  cv_flags, cfd;
-  long numbytes;
-  char iobuf[UNIX_BUFFER_SIZE];
-  char buf[CMSG_SPACE(sizeof(cfd))];
-
-  cfd = Int_val(fd);
-
-  cv_flags = convert_flag_list(flags,msg_flag_table);
-
-  numbytes = Long_val(len);
-  if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
-  memmove(iobuf, &Byte(buff, Long_val(ofs)), numbytes);
-
-  /* Set up sockaddr */
-
-  struct msghdr msg;
-  struct iovec vec;
-  struct cmsghdr *cmsg;
-  
-  msg.msg_name = NULL;
-  msg.msg_namelen = 0; 
-  vec.iov_base=iobuf;
-  vec.iov_len=numbytes;
-  msg.msg_iov=&vec;
-  msg.msg_iovlen=1;
-
-  msg.msg_control = buf;
-  msg.msg_controllen = sizeof(buf);
-  cmsg = CMSG_FIRSTHDR(&msg);
-  cmsg->cmsg_level = SOL_SOCKET;
-  cmsg->cmsg_type = SCM_RIGHTS;
-  cmsg->cmsg_len = CMSG_LEN(sizeof(cfd));
-  *(int*)CMSG_DATA(cmsg) = cfd;
-  msg.msg_controllen = cmsg->cmsg_len;
-
-  msg.msg_flags = 0;
-
-  caml_enter_blocking_section();  
-  ret=sendmsg(Int_val(sock), &msg, cv_flags);
-  caml_leave_blocking_section();
-
-  if(ret == -1)
-    unixext_error(errno);
-
-  CAMLreturn(Val_int(ret));
-}
-
-CAMLprim value stub_unix_send_fd_bytecode(value *argv, int argn) 
-{
-  return stub_unix_send_fd(argv[0],argv[1],argv[2],argv[3],
-                        argv[4], argv[5]);
-}
-
-CAMLprim value stub_unix_recv_fd(value sock, value buff, value ofs, value len, value flags) 
-{
-  CAMLparam5(sock,buff,ofs,len,flags);
-  CAMLlocal2(res,addr);
-  int ret,  cv_flags, fd;
-  long numbytes;
-  char iobuf[UNIX_BUFFER_SIZE];
-  char buf[CMSG_SPACE(sizeof(fd))];
-  struct sockaddr_un unix_socket_name;
-
-  cv_flags = convert_flag_list(flags,msg_flag_table);
-
-  struct msghdr msg;
-  struct iovec vec;
-  struct cmsghdr *cmsg;
-
-  numbytes = Long_val(len);
-  if(numbytes > UNIX_BUFFER_SIZE)
-    numbytes = UNIX_BUFFER_SIZE;
-
-  msg.msg_name=&unix_socket_name;
-  msg.msg_namelen=sizeof(unix_socket_name);
-  vec.iov_base=iobuf;
-  vec.iov_len=numbytes;
-  msg.msg_iov=&vec;
-
-  msg.msg_iovlen=1;
-
-  msg.msg_control = buf;
-  msg.msg_controllen = sizeof(buf);
-
-  caml_enter_blocking_section();  
-  ret=recvmsg(Int_val(sock), &msg, cv_flags);
-  caml_leave_blocking_section();
-
-  if(ret == -1) 
-    unixext_error(errno);
-
-  if(ret>0 && msg.msg_controllen>0) {
-    cmsg = CMSG_FIRSTHDR(&msg);
-    if(cmsg->cmsg_level == SOL_SOCKET && (cmsg->cmsg_type == SCM_RIGHTS)) {
-      fd=Val_int(*(int*)CMSG_DATA(cmsg));
-    } else {
-      failwith("Failed to receive an fd!");
-    }
-  } else {
-    fd=Val_int(-1);
-  }
-  
-  if(ret<numbytes)
-    numbytes = ret;
-
-  memmove(&Byte(buff, Long_val(ofs)), iobuf, numbytes);
-
-  addr=alloc_small(1,0); /* Unix.sockaddr; must be an ADDR_UNIX of string */
-  Field(addr, 0) = Val_unit; /* must set all fields before next allocation */
-
-  if(ret>0) {
-    Field(addr,0) = copy_string(unix_socket_name.sun_path);
-  } else {
-    Field(addr,0) = copy_string("nothing");
-  }
-
-  res=alloc_small(3,0);
-  Field(res,0) = Val_int(ret);
-  Field(res,1) = addr;
-  Field(res,2) = fd;
-
-  CAMLreturn(res);
-}
index 6e512285f58eb30f748d8a26e032d8a67489280a..d305ee7c92c39918cc93907d43ac035ad61895e9 100644 (file)
@@ -1,15 +1,6 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2008 Citrix Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *)
 
 exception End_of_file
index a313b0074e7efad334c54dbfdbccef35e8aaf969..cbb42fc45bcbcd66fb4c20aaa8ce6482c72457c0 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 exception End_of_file
 exception Timeout
 
index 1de876ab899c38c4eace90dd0ce13a0029d6d01e..00b16016e0cbd2418fd537cfefbd46cce6d0e4bf 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 (** Test the close_all_fds_except *)
 
index 0bb6d95ba04b670f1d73ba037c2b3999ba96f2f8..311300404027ec631ef50b8beaf1f2c04eceb000 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 (** Test the copy_file function *)
 
index 3a33f1f6caa82ff5ca94a887fadeec32ea848442..9679176af2e730b8876e713b7b43513aa78ac9aa 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (* test the "." and ".." removal code *)
 
 let table = [ 
index 6006ced112430ec42039c2b4bbe6cd5c7e00d42e..706901d20c063151a75e0c1eb32f521bfdff3f7f 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 (** Test the Unixext.safe_unlink function *)
 
index 582085b8f0ee73f5c2a342a35629c4f1f2dfdaba..e07f67544092568ab31d8cdcd070edf8bec2ea0f 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 
 
 
index d7eb4f9921acf3f22f8451a86eb8a2a52797bfd0..0f4e749a3d76976a10730de205f5c908b9b2c776 100644 (file)
@@ -5,6 +5,7 @@ OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -16,8 +17,6 @@ OBJS = uuid
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = uuid.cma uuid.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -46,19 +45,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove uuid
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "uuid" "package" "$(OBJS)" "." "" ""
-
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index 83c84f48ad5fe1af7d6c8601f82b89236d74cac6..365c70968db341cc1697a689bd85389e3f50a44b 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (** Type-safe UUIDs. *)
 
 (** Internally, a UUID is simply a string. *)
@@ -85,10 +72,3 @@ let int_array_of_uuid s =
              a10; a11; a12; a13; a14; a15; ]);
     Array.of_list !l
   with _ -> invalid_arg "Uuid.int_array_of_uuid"
-
-let is_uuid str =
-       try
-               Scanf.sscanf str
-                       "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
-                       (fun _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -> true)
-       with _ -> false
index 7199a85a9e047b996df3825e8e3dd1260d2b0dd3..fd640303dcae4e7fbc5c3f2dfcb802a28c83fcbd 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (** Type-safe UUIDs.
     Probably need to refactor this; UUIDs are used in two places:
     1. to uniquely name things across the cluster
@@ -50,6 +37,3 @@ val string_of_cookie : cookie -> string
 val uuid_of_int_array : int array -> 'a t
 
 val int_array_of_uuid : 'a t -> int array
-
-(* check if a string is a uuid *)
-val is_uuid : string -> bool
index 1f3ca385534c2369c477fdc28a70457a16adbb1c..c041010c44a037cd968a42359470fbc6ee38a6c0 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "XenBus Interface"
-requires = "unix,mmap"
 archive(byte) = "xb.cma"
 archive(native) = "xb.cmxa"
index e9a14c12982f0e4b6e98dc91bab52030e1203580..16d5236bca2d0e41092d6fb1bda5cb728d5f2a1f 100644 (file)
@@ -1,11 +1,12 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml -I$(XEN_ROOT)/usr/include -I../mmap
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(XEN_ROOT)/usr/include -I../mmap
 OCAMLC = ocamlc -g -I ../mmap
 OCAMLOPT = ocamlopt
 OCAMLOPTFLAGS = -g -dtypes -I ../mmap
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 
 OCAMLABI := $(shell ocamlc -version)
@@ -19,8 +20,6 @@ OBJS = op partial packet xs_ring xb
 INTF = op.cmi packet.cmi xb.cmi
 LIBS = xb.cma xb.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(PREINTF) $(PRELIBS) $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -59,19 +58,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove xb
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "xb" "package" "$(OBJS)" "." "mmap" ""
-       
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index ad9f2f748efd8beaa78fd31dbb8a6c9285bc1574..392af579a6f31226da71f779e8009a6ae8097e98 100644 (file)
--- a/xb/op.ml
+++ b/xb/op.ml
@@ -1,16 +1,9 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
  *)
+
 type operation = Debug | Directory | Read | Getperms |
                  Watch | Unwatch | Transaction_start |
                  Transaction_end | Introduce | Release |
index 2af6d967939db27e71e6273c4c9e9ac1f80a3711..b03028349c74724f450fd118e9fc4d1666745609 100644 (file)
@@ -1,16 +1,10 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
+
 type t =
 {
        tid: int;
@@ -44,4 +38,4 @@ let get_data pkt =
                String.sub pkt.data 0 (l - 1)
        else
                pkt.data
-let get_rid pkt = pkt.rid
+let get_rid pkt = pkt.rid
\ No newline at end of file
index 90644a0d597f81fcc1d8df548fc397a111369180..1a40ca884ba85c393101c3d9c1483e14867a62ce 100644 (file)
@@ -1,16 +1,10 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
+
 type pkt =
 {
        tid: int;
index e414c6d582a7d17a647fc8600e221950d9b53523..49a775ccad9ac9741c002638ae45ee238caee36e 100644 (file)
--- a/xb/xb.ml
+++ b/xb/xb.ml
@@ -1,16 +1,10 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
+
 module Op = struct include Op end
 module Packet = struct include Packet end
 
index 537135759097acfb013ab929c165b44e989480a4..6cbf0a84fe0da912e3829f317632a9dd76753b4b 100644 (file)
--- a/xb/xb.mli
+++ b/xb/xb.mli
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 module Op:
 sig
        type operation = Op.operation =
index bdacbaf1d28e311653c136886617cccc3910b1be..9ab432589d9e0bc56f75e687e69fe06adac78769 100644 (file)
@@ -1,16 +1,10 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/mman.h>
 #define u32 uint32_t
 #include <xen/io/xs_wire.h>
 
-/* XS_RESTRICT is defined in 
-   http://xenbits.xen.org/xapi/xen-3.4.pq.hg?file/c01d38e7092a/restrict_xenstored */
-#include "../include/config.h"
-#if !HAVE_DECL_XS_RESTRICT
-#define XS_RESTRICT 128
-#endif
-
 CAMLprim value stub_get_internal_offset(void)
 {
        CAMLparam0();
index d0e6fa231aaed6d8dffbb0c1462a3daface6a81d..6b8ba214075c2b56f07a7880fb4fe205b4d7713e 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 external read: Mmap.mmap_interface -> string -> int -> int = "ml_interface_read"
index d5ec99a66c06bdc0e608c0ba1972963a81a0bbee..3cccf36a6c77b15ad4671862f3780227b78a31ed 100644 (file)
@@ -1,16 +1,10 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
index 61fe61a8d4ca0b75f638f4a81ccba1d33208b11a..e46d7dd112f763c05d27c2280708fd05542eda1e 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "Xen Control Interface"
-requires = "mmap,uuid"
 archive(byte) = "xc.cma"
 archive(native) = "xc.cmxa"
index e138a6a895fbdddb4b5d1e05c23761d3e200f3ff..2d4301cfeba1882b8fa8908b23203ccd220b6c41 100644 (file)
@@ -1,11 +1,12 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml -I$(XEN_ROOT)/usr/include -I../mmap -I./
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml -I$(XEN_ROOT)/usr/include -I../mmap -I./
 OCAMLC = ocamlc -g -I ../mmap -I ../uuid
 OCAMLOPT = ocamlopt
 OCAMLOPTFLAGS = -g -dtypes -I ../mmap -I ../uuid
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 
 OCAMLABI := $(shell ocamlc -version)
@@ -16,8 +17,6 @@ OBJS = xc
 INTF = xc.cmi
 LIBS = xc.cma xc.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -53,19 +52,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove xc
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "xc" "package" "$(OBJS)" "." "mmap,uuid" ""
-       
 clean:
-       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS) $(INTF) *~ *.rej *.orig
+       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS) $(INTF)
 
diff --git a/xc/xc.h b/xc/xc.h
index dd3a01c99e257924c089baa589c6fe65d9dc5e45..d7cc2f6aed9259b9c7d124c132cf7f4f48a9268e 100644 (file)
--- a/xc/xc.h
+++ b/xc/xc.h
@@ -1,15 +1,6 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  */
 
 #define __XEN_TOOLS__
@@ -19,7 +10,7 @@
 #include <xen/sysctl.h>
 #include <xen/domctl.h>
 #include <xen/sched.h>
-#include <xen/platform.h>
+#include <xen/sysctl.h>
 #if XEN_SYSCTL_INTERFACE_VERSION < 4
 #include <xen/linux/privcmd.h>
 #else
@@ -177,18 +168,9 @@ int xc_domain_cpuid_set(int xc, unsigned int domid, int hvm,
 int xc_domain_cpuid_apply(int xc, unsigned int domid, int hvm);
 int xc_cpuid_check(uint32_t input, uint32_t optsubinput,
                    char *config[4], char *config_out[4]);
-int xc_domain_suppress_spurious_page_faults(int xc, uint32_t domid);
-
 int xc_domain_send_s3resume(int handle, unsigned int domid);
-int xc_domain_set_vpt_align(int handle, unsigned int domid, int vpt_align);
-int xc_domain_set_hpet(int handle, unsigned int domid, int hpet);
-int xc_domain_set_timer_mode(int handle, unsigned int domid, int mode);
-int xc_domain_get_acpi_s_state(int handle, unsigned int domid);
-int xc_domain_trigger_power(int handle, unsigned int domid);
-int xc_domain_trigger_sleep(int handle, unsigned int domid);
-
-int xc_get_boot_cpufeatures(int handle, uint32_t *, uint32_t *, uint32_t *,
-       uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
+
+int xc_domain_suppress_spurious_page_faults(int xc, uint32_t domid);
 
 #if XEN_SYSCTL_INTERFACE_VERSION >= 6
 #define SAFEDIV(a, b)                                  (((b) >= 0) ? (a) / (b) : (a))
index af4c0de981f7232fcf9eb1dc4a6cd32d72736ab6..1ed9d5964aec93e2fb5ad6400c43e491947e8366 100644 (file)
--- a/xc/xc.ml
+++ b/xc/xc.ml
@@ -1,15 +1,6 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (C) 2006-2007 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *)
 
 (** *)
@@ -64,10 +55,6 @@ type sched_control =
        cap    : int;
 }
 
-type physinfo_cap_flag =
-       | CAP_HVM
-       | CAP_DirectIO
-
 type physinfo =
 {
        nr_cpus          : int;
@@ -80,7 +67,6 @@ type physinfo =
        free_pages       : nativeint;
        scrub_pages      : nativeint;
        (* XXX hw_cap *)
-       capabilities     : physinfo_cap_flag list;
 }
 
 type version =
@@ -156,7 +142,7 @@ external _domain_getinfolist: handle -> domid -> int -> domaininfo list
        = "stub_xc_domain_getinfolist"
 
 let domain_getinfolist handle first_domain =
-       let nb = 100 in
+       let nb = 2 in
        let last_domid l = (List.hd l).domid + 1 in
        let rec __getlist from =
                let l = _domain_getinfolist handle from nb in
@@ -246,15 +232,9 @@ external domain_test_assign_device: handle -> domid -> (int * int * int * int) -
 external domain_suppress_spurious_page_faults: handle -> domid -> unit
        = "stub_xc_domain_suppress_spurious_page_faults"
 
-external domain_set_timer_mode: handle -> domid -> int -> unit = "stub_xc_domain_set_timer_mode"
-external domain_set_hpet: handle -> domid -> int -> unit = "stub_xc_domain_set_hpet"
-external domain_set_vpt_align: handle -> domid -> int -> unit = "stub_xc_domain_set_vpt_align"
-
-external domain_send_s3resume: handle -> domid -> unit = "stub_xc_domain_send_s3resume"
 external domain_get_acpi_s_state: handle -> domid -> int = "stub_xc_domain_get_acpi_s_state"
 
-external domain_trigger_power: handle -> domid -> unit = "stub_xc_domain_trigger_power"
-external domain_trigger_sleep: handle -> domid -> unit = "stub_xc_domain_trigger_sleep"
+external domain_send_s3resume: handle -> domid -> unit = "stub_xc_domain_send_s3resume"
 
 (** check if some hvm domain got pv driver or not *)
 external hvm_check_pvdriver: handle -> domid -> bool
@@ -270,9 +250,6 @@ external version_capabilities: handle -> string =
 external watchdog : handle -> int -> int32 -> int
   = "stub_xc_watchdog"
 
-external get_boot_cpufeatures: handle ->
-       (int32 * int32 * int32 * int32 * int32 * int32 * int32 * int32) = "stub_xc_get_boot_cpufeatures"
-
 (* core dump structure *)
 type core_magic = Magic_hvm | Magic_pv
 
index f7ca795907d48922e825a4b74818ff3fc5657d5c..0a2723bf6ef97bca53bc6309a88c88d551c0067e 100644 (file)
--- a/xc/xc.mli
+++ b/xc/xc.mli
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type domid = int
 type vcpuinfo = {
   online : bool;
@@ -49,7 +36,6 @@ type domaininfo = {
   handle : int array;
 }
 type sched_control = { weight : int; cap : int; }
-type physinfo_cap_flag = CAP_HVM | CAP_DirectIO
 type physinfo = {
   nr_cpus : int;
   threads_per_core : int;
@@ -60,7 +46,6 @@ type physinfo = {
   total_pages : nativeint;
   free_pages : nativeint;
   scrub_pages : nativeint;
-  capabilities : physinfo_cap_flag list;
 }
 type version = { major : int; minor : int; extra : string; }
 type compile_info = {
@@ -158,18 +143,9 @@ external domain_deassign_device: handle -> domid -> (int * int * int * int) -> u
 external domain_test_assign_device: handle -> domid -> (int * int * int * int) -> bool
        = "stub_xc_domain_test_assign_device"
 
-external domain_set_timer_mode: handle -> domid -> int -> unit = "stub_xc_domain_set_timer_mode"
-external domain_set_hpet: handle -> domid -> int -> unit = "stub_xc_domain_set_hpet"
-external domain_set_vpt_align: handle -> domid -> int -> unit = "stub_xc_domain_set_vpt_align"
-
+external domain_get_acpi_s_state: handle -> domid -> int = "stub_xc_domain_get_acpi_s_state"
 external domain_send_s3resume: handle -> domid -> unit
   = "stub_xc_domain_send_s3resume"
-external domain_get_acpi_s_state: handle -> domid -> int = "stub_xc_domain_get_acpi_s_state"
-
-external domain_trigger_power: handle -> domid -> unit
-  = "stub_xc_domain_trigger_power"
-external domain_trigger_sleep: handle -> domid -> unit
-  = "stub_xc_domain_trigger_sleep"
 
 external hvm_check_pvdriver : handle -> domid -> bool
   = "stub_xc_hvm_check_pvdriver"
@@ -213,6 +189,3 @@ external domain_cpuid_apply: handle -> domid -> bool -> unit
 external cpuid_check: (int64 * (int64 option)) -> string option array -> (bool * string option array)
        = "stub_xc_cpuid_check"
 
-external get_boot_cpufeatures: handle ->
-       (int32 * int32 * int32 * int32 * int32 * int32 * int32 * int32) = "stub_xc_get_boot_cpufeatures"
-
index 485db9aa4fe58f26db2bac6eb3ad011fd9a6b335..6cd442cfe697c43a3dd9abec5d51a0eb12384cc9 100644 (file)
@@ -1,16 +1,3 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 #ifndef __LIBXC_CPUFEATURE_H
 #define __LIBXC_CPUFEATURE_H
 
index 1cad4622f4d65dead9aa62af69aaf3b5fab10327..68a5dc87fba502915cb14f5bc93cfa2ab17f0804 100644 (file)
@@ -1,16 +1,3 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 #ifndef XC_CPUID_H
 #define XC_CPUID_H
 
index 7f22a49aa1ec1d021cf6be2efca177441b5099a9..52bbb0f6516317a44d34be59ce321d38cc831ff9 100644 (file)
@@ -1,16 +1,3 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
 #ifndef __XC_E820_H__
 #define __XC_E820_H__
 
index cbb3f34b68bf371b539bf9e641b00c954e5963a2..2cb04a315dccbaa391e65dba9862217118edf46e 100644 (file)
@@ -1,15 +1,6 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (c) 2006-2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  */
 
 #include <stdint.h>
                .interface_version = XEN_SYSCTL_INTERFACE_VERSION, \
        }
 
-#define DECLARE_PLATFORM(_cmd)         \
-       struct xen_platform_op platform = { \
-               .cmd = _cmd,            \
-               .interface_version = XENPF_INTERFACE_VERSION, \
-       }
-
 #define DECLARE_HYPERCALL2(_cmd, _arg0, _arg1) \
        privcmd_hypercall_t hypercall = {       \
                .op = _cmd,                     \
@@ -212,24 +197,6 @@ static int do_sysctl(int handle, struct xen_sysctl *sysctl)
        return ret;
 }
 
-static int do_platform(int handle, struct xen_platform_op *platform)
-{
-       int ret;
-       DECLARE_HYPERCALL1(__HYPERVISOR_platform_op, platform);
-
-       if (mlock(platform, sizeof(*platform)) != 0) {
-               xc_error_set("mlock failed: %s", strerror(errno));
-               return -1;
-       }
-
-       ret = do_xen_hypercall(handle, &hypercall);
-       if (ret < 0)
-               xc_error_hypercall(hypercall, ret);
-
-       munlock(platform, sizeof(*platform));
-       return ret;
-}
-
 static int do_evtchnctl(int handle, int cmd, void *arg, size_t arg_size)
 {
        DECLARE_HYPERCALL2(__HYPERVISOR_event_channel_op, cmd, arg);
@@ -329,7 +296,7 @@ static int xc_set_hvm_param(int handle, unsigned int domid,
        };
        DECLARE_HYPERCALL2(__HYPERVISOR_hvm_op, HVMOP_set_param, (unsigned long) &arg);
        int ret;
-
+       
        if (mlock(&arg, sizeof(arg)) == -1) {
                xc_error_set("mlock failed: %s", strerror(errno));
                return -1;
@@ -1515,40 +1482,12 @@ out:
        return ret;
 }
 
-#ifndef HVM_PARAM_HPET_ENABLED
-#define HVM_PARAM_HPET_ENABLED 11
-#endif
-
-#ifndef HVM_PARAM_ACPI_S_STATE
-#define HVM_PARAM_ACPI_S_STATE 14
-#endif
-
-#ifndef HVM_PARAM_VPT_ALIGN
-#define HVM_PARAM_VPT_ALIGN 16
-#endif
-
 int xc_domain_send_s3resume(int handle, unsigned int domid)
 {
        #define HVM_PARAM_ACPI_S_STATE 14
        return xc_set_hvm_param(handle, domid, HVM_PARAM_ACPI_S_STATE, 0);
 }
 
-int xc_domain_set_timer_mode(int handle, unsigned int domid, int mode)
-{
-       return xc_set_hvm_param(handle, domid,
-                               HVM_PARAM_TIMER_MODE, (unsigned long) mode);
-}
-
-int xc_domain_set_hpet(int handle, unsigned int domid, int hpet)
-{
-       return xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) hpet);
-}
-
-int xc_domain_set_vpt_align(int handle, unsigned int domid, int vpt_align)
-{
-       return xc_set_hvm_param(handle, domid, HVM_PARAM_HPET_ENABLED, (unsigned long) vpt_align);
-}
-
 int xc_domain_get_acpi_s_state(int handle, unsigned int domid)
 {
        int ret;
@@ -1573,61 +1512,6 @@ int xc_domain_suppress_spurious_page_faults(int xc, uint32_t domid)
        return rc;
 }
 
-int xc_domain_trigger_power(int handle, unsigned int domid)
-{
-    int ret;
-
-    DECLARE_DOMCTL(XEN_DOMCTL_sendtrigger, domid);
-    domctl.u.sendtrigger.trigger = XEN_DOMCTL_SENDTRIGGER_POWER;
-
-       ret = do_domctl(handle, &domctl);
-       if (ret != 0)
-               xc_error_set("power button failed: %s", xc_error_get());
-    return ret;
-}
-
-int xc_domain_trigger_sleep(int handle, unsigned int domid)
-{
-    int ret;
-
-    DECLARE_DOMCTL(XEN_DOMCTL_sendtrigger, domid);
-    domctl.u.sendtrigger.trigger = XEN_DOMCTL_SENDTRIGGER_SLEEP;
-
-       ret = do_domctl(handle, &domctl);
-       if (ret != 0)
-               xc_error_set("sleep button failed: %s", xc_error_get());
-    return ret;
-}
-
-int xc_get_boot_cpufeatures(int handle,
-                            uint32_t *base_ecx, uint32_t *base_edx,
-                            uint32_t *ext_ecx, uint32_t *ext_edx,
-                            uint32_t *masked_base_ecx, 
-                            uint32_t *masked_base_edx,
-                            uint32_t *masked_ext_ecx, 
-                            uint32_t *masked_ext_edx)
-{
-       int ret = -EINVAL;
-#ifdef XENPF_get_cpu_features 
-       DECLARE_PLATFORM(XENPF_get_cpu_features);
-
-       ret = do_platform(handle, &platform);
-       if (ret != 0)
-               xc_error_set("getting boot cpu features failed: %s", xc_error_get());
-       else {
-               *base_ecx = platform.u.cpu_features.base_ecx;
-               *base_edx = platform.u.cpu_features.base_edx;
-               *ext_ecx = platform.u.cpu_features.ext_ecx;
-               *ext_edx = platform.u.cpu_features.ext_edx;
-               *masked_base_ecx = platform.u.cpu_features.masked_base_ecx;
-               *masked_base_edx = platform.u.cpu_features.masked_base_edx;
-               *masked_ext_ecx = platform.u.cpu_features.masked_ext_ecx;
-               *masked_ext_edx = platform.u.cpu_features.masked_ext_edx;
-       }
-#endif
-       return ret;
-}
-
 /*
  * Local variables:
  *  indent-tabs-mode: t
index beefb503f5621dfae332884dc59cc4ce115c5fd4..9847e604d346aad1e1156ba7ef31b52658f59d33 100644 (file)
@@ -1,15 +1,6 @@
 /*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Copyright (c) 2007 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  */
 
 #ifdef WITH_INJECTION_CAPABILITY
@@ -20,8 +11,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#define HYPCALLcmd "hypcall"
-
 static int fake_interface_open(void)
 {
        struct sockaddr_un remote;
@@ -73,10 +62,9 @@ static int fake_xen_domctl(int handle, struct xen_domctl *domctl)
                marshall_command(handle, "%s,%d,%d\n", DOMCTLcmd, domctl->cmd, domctl->domain);
                return unmarshall_return(handle);
        case XEN_DOMCTL_createdomain: /* W ssidref */
-               marshall_command(handle, "%s,%d,%d,%d," DOMAINHANDLE "\n", DOMCTLcmd,
+               marshall_command(handle, "%s,%d,%d," DOMAINHANDLE "\n", DOMCTLcmd,
                                 domctl->cmd,
-                                (domctl->u.createdomain.flags|XEN_DOMCTL_CDF_hvm_guest)?1:0,
-                                (domctl->u.createdomain.flags|XEN_DOMCTL_CDF_hap)?1:0,
+                                domctl->u.createdomain.flags,
                                 domctl->u.createdomain.handle[0],
                                 domctl->u.createdomain.handle[1],
                                 domctl->u.createdomain.handle[2],
@@ -332,11 +320,7 @@ static int fake_xen_schedop(int handle, unsigned long cmd, sched_remote_shutdown
 {
        switch (cmd) {
        case SCHEDOP_remote_shutdown:
-               marshall_command(handle, "%s,%d,%d,%d\n", HYPCALLcmd,
-                                                1, 
-                                arg->domain_id,
-                                                arg->reason);
-               return unmarshall_return(handle);
+               return 0;
        default:
                return -EINVAL;
        }
index 3da39ce1b192d74752741f104aeac19cc62eeb6b..64a4457b1e6f747988dc631dd6face36b13ca2d0 100644 (file)
@@ -1,16 +1,4 @@
-/*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- */
+/* Copyright (c) 2005-2006 XenSource Inc. */
 
 #define _XOPEN_SOURCE 600
 #include <stdlib.h>
@@ -546,7 +534,7 @@ CAMLprim value stub_xc_send_debug_keys(value xc_handle, value keys)
 CAMLprim value stub_xc_physinfo(value xc_handle)
 {
        CAMLparam1(xc_handle);
-       CAMLlocal3(physinfo, cap_list, tmp);
+       CAMLlocal1(physinfo);
        xc_physinfo_t c_physinfo;
        int r;
 
@@ -557,17 +545,7 @@ CAMLprim value stub_xc_physinfo(value xc_handle)
        if (r)
                failwith_xc();
 
-       tmp = cap_list = Val_emptylist;
-       for (r = 0; r < 2; r++) {
-               if ((c_physinfo.capabilities >> r) & 1) {
-                       tmp = caml_alloc_small(2, Tag_cons);
-                       Field(tmp, 0) = Val_int(r);
-                       Field(tmp, 1) = cap_list;
-                       cap_list = tmp;
-               }
-       }
-
-       physinfo = caml_alloc_tuple(10);
+       physinfo = caml_alloc_tuple(9);
        Store_field(physinfo, 0, Val_int(COMPAT_FIELD_physinfo_get_nr_cpus(c_physinfo)));
        Store_field(physinfo, 1, Val_int(c_physinfo.threads_per_core));
        Store_field(physinfo, 2, Val_int(c_physinfo.cores_per_socket));
@@ -577,7 +555,6 @@ CAMLprim value stub_xc_physinfo(value xc_handle)
        Store_field(physinfo, 6, caml_copy_nativeint(c_physinfo.total_pages));
        Store_field(physinfo, 7, caml_copy_nativeint(c_physinfo.free_pages));
        Store_field(physinfo, 8, caml_copy_nativeint(c_physinfo.scrub_pages));
-       Store_field(physinfo, 9, cap_list);
 
        CAMLreturn(physinfo);
 }
@@ -1143,13 +1120,13 @@ CAMLprim value stub_xc_domain_deassign_device(value xc_handle, value domid, valu
        CAMLreturn(Val_unit);
 }
 
-CAMLprim value stub_xc_watchdog(value handle, value domid, value timeout)
+CAMLprim value stub_xc_watchdog(value handle, value id, value timeout)
 {
-       CAMLparam3(handle, domid, timeout);
+       CAMLparam3(handle, id, timeout);
        int ret;
        unsigned int c_timeout = Int32_val(timeout);
 
-       ret = xc_domain_watchdog(_H(handle), _D(domid), c_timeout);
+       ret = xc_domain_watchdog(_H(handle), Int_val(id), c_timeout);
        if (ret < 0)
                failwith_xc();
 
@@ -1175,78 +1152,6 @@ CAMLprim value stub_xc_domain_send_s3resume(value handle, value domid)
        CAMLreturn(Val_unit);
 }
 
-
-CAMLprim value stub_xc_domain_set_timer_mode(value handle, value id, value mode)
-{
-       CAMLparam3(handle, id, mode);
-       int ret;
-
-       ret = xc_domain_set_timer_mode(_H(handle), _D(id), Int_val(mode));
-       if (ret < 0)
-               failwith_xc();
-       CAMLreturn(Val_unit);
-}
-
-CAMLprim value stub_xc_domain_set_hpet(value handle, value id, value mode)
-{
-       CAMLparam3(handle, id, mode);
-       int ret;
-
-       ret = xc_domain_set_hpet(_H(handle), _D(id), Int_val(mode));
-       if (ret < 0)
-               failwith_xc();
-       CAMLreturn(Val_unit);
-}
-
-CAMLprim value stub_xc_domain_set_vpt_align(value handle, value id, value mode)
-{
-       CAMLparam3(handle, id, mode);
-       int ret;
-
-       ret = xc_domain_set_vpt_align(_H(handle), _D(id), Int_val(mode));
-       if (ret < 0)
-               failwith_xc();
-       CAMLreturn(Val_unit);
-}
-
-CAMLprim value stub_xc_domain_trigger_power(value handle, value domid)
-{
-       CAMLparam2(handle, domid);
-       xc_domain_trigger_power(_H(handle), _D(domid));
-       CAMLreturn(Val_unit);
-}
-
-CAMLprim value stub_xc_domain_trigger_sleep(value handle, value domid)
-{
-       CAMLparam2(handle, domid);
-       xc_domain_trigger_sleep(_H(handle), _D(domid));
-       CAMLreturn(Val_unit);
-}
-
-CAMLprim value stub_xc_get_boot_cpufeatures(value handle)
-{
-       CAMLparam1(handle);
-       CAMLlocal1(v);
-       uint32_t a, b, c, d, e, f, g, h;
-       int ret;
-
-       ret = xc_get_boot_cpufeatures(_H(handle), &a, &b, &c, &d, &e, &f, &g, &h);
-       if (ret < 0)
-               failwith_xc();
-       
-       v = caml_alloc_tuple(8);
-       Store_field(v, 0, caml_copy_int32(a));
-       Store_field(v, 1, caml_copy_int32(b));
-       Store_field(v, 2, caml_copy_int32(c));
-       Store_field(v, 3, caml_copy_int32(d));
-       Store_field(v, 4, caml_copy_int32(e));
-       Store_field(v, 5, caml_copy_int32(f));
-       Store_field(v, 6, caml_copy_int32(g));
-       Store_field(v, 7, caml_copy_int32(h));
-
-       CAMLreturn(v);
-}
-
 /*
  * Local variables:
  *  indent-tabs-mode: t
index 9000f04590320469f77e2561e6ef0b994ae998b7..2c63767aa18363dac20c3a00abe26c0a5e52aa47 100644 (file)
@@ -1,5 +1,5 @@
 version = "@VERSION@"
 description = "Xml-light2 - Xml-light replacement"
-requires = "stdext,xmlm"
+requires = "stdext"
 archive(byte) = "xml-light2.cma"
 archive(native) = "xml-light2.cmxa"
index ee4464683e7b7d16a0e5e857a2560e8deb6a41cc..a7531e352dd60547310df5a4d86c0aca9e262a30 100644 (file)
@@ -1,4 +1,3 @@
-IPROG=install -m 755 -o root -g root
 OCAMLPACKS = xmlm
 
 CC = gcc
@@ -12,7 +11,7 @@ OCAMLOPT = $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS)
 
 LDFLAGS = -cclib -L./
 
-LIBEXEC  = "/opt/xensource/libexec"
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -23,19 +22,13 @@ OCAMLDESTDIR ?= $(OCAMLLIBDIR)
 OBJS = xml
 INTF = xml.cmi
 LIBS = xml-light2.cma xml-light2.cmxa
-PROGRAMS = xmlpp
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
-all: $(INTF) $(LIBS)
+all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
 
 libs: $(LIBS)
 
-xmlpp: xmlpp.ml all
-       $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../stdext stdext.cmxa xml-light2.cmxa -linkpkg -o $@ $<
-
 xml-light2.cmxa: $(foreach obj,$(OBJS),$(obj).cmx)
        $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $@ $(foreach obj,$(OBJS),$(obj).cmx)
 
@@ -58,29 +51,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore xml-light2 META $(INTF) $(LIBS) *.a *.cmx
-
-.PHONY: bininstall
-bininstall: path = $(DESTDIR)$(LIBEXEC)
-bininstall: all
-       mkdir -p $(path)
-       $(IPROG) $(PROGRAMS) $(path)
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xml-light2 META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove xml-light2
 
-.PHONY: binuninstall
-binuninstall:
-       rm -f $(DESTDIR)$(LIBEXEC)$(PROGRAMS)
-
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "xml-light2" "package" "$(OBJS)" "." "stdext,xmlm" ""
-       
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index 8df191853fea6ab06ae700b9073e4a7f4b67cd0f..e4c480ba1641ff23ec3c524e3da759ba83ed9da5 100644 (file)
@@ -1,17 +1,7 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2007 XenSource Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
-(*
  * This is a replacement interface for xml-light that use the superior xmlm
  * engine to parse stuff. Also the output functions SKIP characters that are
  * not allowed in XML.
@@ -31,29 +21,45 @@ let error (msg,pos) =
        Printf.sprintf "%s line %d" msg pos.eline
 
 (* internal parse function *)
-let is_empty xml =
-       let is_empty_string s = 
-               let is_empty = ref true in
-               for i = 0 to (String.length s - 1)
-               do
-                       if s.[i] <> '\n' && s.[i] <> ' ' && s.[i] <> '\t' then
-                               is_empty := false
-               done;
-               !is_empty in
-       match xml with
-       | PCData data when is_empty_string data -> true
-       | _ -> false
-
 let _parse i =
-       let el (tag: Xmlm.tag) (children: xml list) : xml =
-               let name_local = snd (fst tag) in
-               let attrs' = List.map (fun (nameattr, str) -> (snd nameattr, str)) (snd tag) in
-               Element (name_local, attrs', List.filter (fun xml -> not (is_empty xml)) children)
+       let filter_empty_pcdata l =
+               let is_empty_string s =
+                       let is_empty = ref true in
+                       for i = 0 to (String.length s - 1)
+                       do
+                               if s.[i] <> '\n' && s.[i] <> ' ' && s.[i] <> '\t' then
+                                       is_empty := false
+                       done;
+                       not (!is_empty)
+                       in
+               List.filter (fun node ->
+                       match node with Element _ -> true | PCData data -> is_empty_string data
+               ) l
+               in
+       let d data acc =
+               match acc with
+               | childs :: path -> ((PCData data) :: childs) :: path
+               | [] -> assert false
+               in
+       let s tag acc = [] :: acc in
+       let e tag acc =
+               match acc with
+               | childs :: path ->
+                       (* xml light doesn't handle namespace in node *)
+                       let (_, name), attrs = tag in
+                       (* xml light doesn't have namespace in attributes *)
+                       let realattrs = List.map (fun ((_, n), v) -> n, v) attrs in
+                       let childs = filter_empty_pcdata childs in
+                       let el = Element (name, realattrs, List.rev childs) in
+                       begin match path with
+                       | parent :: path' -> (el :: parent) :: path'
+                       | [] -> [ [ el ] ]
+                       end
+               | [] -> assert false
                in
-       let data s = PCData s in
-       match Xmlm.peek i with
-       | `Dtd _ -> snd (Xmlm.input_doc_tree ~el ~data i)
-       | _      -> Xmlm.input_tree ~el ~data i
+       match Xmlm.input ~d ~s ~e [] i with
+       | [ [ r ] ] -> r
+       | _         -> assert false
 
 let parse i =
        try _parse i
@@ -70,7 +76,7 @@ let parse i =
 let parse_file file =
        let chan = open_in file in
        try
-               let i = Xmlm.make_input (`Channel chan) in
+               let i = Xmlm.input_of_channel chan in
                let ret = parse i in
                close_in chan;
                ret
@@ -78,22 +84,11 @@ let parse_file file =
                close_in_noerr chan; raise exn
 
 let parse_in chan =
-       let i = Xmlm.make_input (`Channel chan) in
+       let i = Xmlm.input_of_channel chan in
        parse i
 
 let parse_string s =
-       let i = Xmlm.make_input (`String (0, s)) in
-       parse i
-
-let parse_bigbuffer b =
-       let n = ref Int64.zero in
-       let aux () =
-               try 
-                       let c = Bigbuffer.get b !n in
-                       n := Int64.add !n Int64.one;
-                       int_of_char c
-               with _ -> raise End_of_file in
-       let i = Xmlm.make_input (`Fun aux) in
+       let i = Xmlm.input_of_string s in
        parse i
 
 (* common output function *)
@@ -121,7 +116,7 @@ let esc_pcdata data =
 let str_of_attrs attrs =
        let fmt s = Printf.sprintf s in
        if List.length attrs > 0 then
-               " " ^ (String.concat " " (List.map (fun (k, v) -> fmt "%s=\"%s\"" k (esc_pcdata v)) attrs))
+         " "^(String.concat " " (List.map (fun (k, v) -> fmt "%s=\"%s\"" k (esc_pcdata v)) attrs))
        else
                ""
 
@@ -189,19 +184,3 @@ let to_bigbuffer xml =
        let buffer = Bigbuffer.make () in
        to_fct xml (fun s -> Bigbuffer.append_substring buffer s 0 (String.length s));
        buffer
-
-(* helpers functions *)
-exception Not_pcdata of string
-exception Not_element of string
-
-let pcdata = function
-       | PCData x -> x
-       | e -> raise (Not_pcdata (to_string e))
-
-let children = function
-       | Element (_,_,c) -> c
-       | e -> raise (Not_element (to_string e))
-
-let tag = function
-       | Element (x,_,_) -> x
-       | e -> raise (Not_element (to_string e))
index 46bfb0e96ced84b10d7f055e5b29d7981c300864..f969579264408dd45fa882e4c0eab79f81507195 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 (** tree representation *)
 type xml =
        | Element of (string * (string * string) list * xml list)
@@ -27,7 +14,6 @@ val error : error -> string
 val parse_file : string -> xml
 val parse_in : in_channel -> xml
 val parse_string : string -> xml
-val parse_bigbuffer : Bigbuffer.t -> xml
 
 (** output functions *)
 val to_fct : xml -> (string -> unit) -> unit
@@ -35,10 +21,3 @@ val to_fct_fmt : xml -> (string -> unit) -> unit
 val to_string : xml -> string
 val to_string_fmt : xml -> string
 val to_bigbuffer : xml -> Bigbuffer.t
-
-(** helper functions *)
-exception Not_pcdata of string
-exception Not_element of string
-val pcdata : xml -> string
-val children : xml -> xml list
-val tag : xml -> string
index b0b721433bddebd2b9095ede3ae04cebafd5fcd7..77d93b5969d36fa13766356e374c0a6284ead034 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "XenStore Interface"
-requires = "unix,xb"
 archive(byte) = "xs.cma"
 archive(native) = "xs.cmxa"
index be0904c406b1331a18b4b246817dfca60783bd00..a5efd14393de54aaefa12ef7ab4042661bfbb79e 100644 (file)
@@ -1,10 +1,11 @@
 CC = gcc
-CFLAGS = -Wall -fPIC -O2 -I/usr/lib/ocaml
+CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g -I ../xb/
 OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes -I ../xb/
 
@@ -19,8 +20,6 @@ OBJS = queueop xsraw xst xs
 INTF = xsraw.cmi xst.cmi xs.cmi
 LIBS = xs.cma xs.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(PREINTF) $(PRELIBS) $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -49,19 +48,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove xs
 
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "xs" "package" "$(OBJS)" "." "xb" ""
-
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS)
 
index c2d9a7666f0e2f5bc5632b59665544717779afea..b45da1d93ce09de8afe4013843a0ece214a4ad77 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 let data_concat ls = (String.concat "\000" ls) ^ "\000"
index 3c4534a0db1c36f8a5e283a0d0ddae99e4aca2f8..2dcfd99dd89e1769e31dd67546d106ad540acd3a 100644 (file)
--- a/xs/xs.ml
+++ b/xs/xs.ml
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 type perms = Xsraw.perms
index f35939edcb94aa40a6636f804f932f32a53d8d51..5a98b5dc483b6f1d78d12ee62436ff3d82c247aa 100644 (file)
--- a/xs/xs.mli
+++ b/xs/xs.mli
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 exception Timeout
index a1cccbe859fa943f8b9481334b8c62e651917ba7..184d6f6d68ecacf09d7c617c46dc123b070e8d67 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 exception Partial_not_empty
 exception Unexpected_packet of string
index 9a112bd56192c45f482550e810654cc537d33994..00b090a93ae1c0a12b505882c467e4b12cdff24a 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 exception Partial_not_empty
 exception Unexpected_packet of string
 exception Invalid_path of string
index 3f5b5dce3f9c652697e27ee78a5f4c33b2d2b513..719b308e554d6c8640bdfebb1ab2b8bcecdff843 100644 (file)
--- a/xs/xst.ml
+++ b/xs/xst.ml
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (c) 2006 XenSource Inc.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * All rights reserved.
  *)
 
 type ops =
index f252be087bb1a88aa7f5f36cf620d1469e7cf2c2..6bf57b5a791afefb65c01c6abdcf2ae52c21f666 100644 (file)
@@ -1,16 +1,3 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
- *)
 type ops = {
        directory : string -> string list;
        read : string -> string;
index 1c88161f9fad86e5f4272cc7d8d680a4fc80a362..1b909aeae30297716bc0b818c3842a796917d47a 100644 (file)
@@ -1,5 +1,4 @@
 version = "@VERSION@"
 description = "XenStore RPC"
-requires = "xs"
 archive(byte) = "xsrpc.cma"
 archive(native) = "xsrpc.cmxa"
index 3800b82fd56166e2482cba454007284d0d5f7206..cf0173f91bd6c633b9e5e04bbb4da7093366a486 100644 (file)
@@ -5,6 +5,7 @@ OCAMLOPT = ocamlopt
 
 LDFLAGS = -cclib -L./
 
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes -I ../xb/ -I ../xs/
 
@@ -16,8 +17,6 @@ OBJS = xsrpc
 INTF = xsrpc.cmi
 LIBS = xsrpc.cma xsrpc.cmxa
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
 bins: $(PROGRAMS)
@@ -46,19 +45,13 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore xsrpc META $(INTF) $(LIBS) *.a *.cmx
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xsrpc META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove xsrpc
-       
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "xsrpc" "package" "$(OBJS)" "." "xb,xs" ""
-       
+
 clean:
        rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot META $(LIBS) $(PROGRAMS)
 
index f29a794fcac23e4e78e49f4b1679b64250453381..9ca9a5b5b3dae75d2ce019150d8853a850acb3b3 100644 (file)
@@ -1,15 +1,8 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (C) 2008 Citrix Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
+ * Xenstore RPC
  *)
 
 (*
index 72c8279a82bbf91472e2c34fbb84512c85ef1fe3..f1ad4acdc250966490dc0ef8ab5449c2fff6c20a 100644 (file)
@@ -1,15 +1,7 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (C) 2008 Citrix Ltd.
+ * Author Vincent Hanquez <vincent@xensource.com>
  *
- * 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; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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.
  *)
 
 type t