Skip to content

Commit

Permalink
Merge pull request #27 from jonludlam/stdext-pack
Browse files Browse the repository at this point in the history
Use packed stdext
  • Loading branch information
Jon Ludlam authored Jun 23, 2016
2 parents fba3588 + 31de0ab commit e064560
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 30 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
language: c
install: wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh
sudo: required
dist: trusty
branches:
only: master
install:
- wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
sudo: true
env:
- OCAML_VERSION=4.02 PACKAGE=xen-api-libs-transitional FORK_USER=xapi-project EXTRA_REMOTES=git://github.com/xapi-project/opam-repo-dev
global:
- PACKAGE=xapi-libs-transitional
- TESTS=true
matrix:
- OCAML_VERSION=4.02
notifications:
slack: citrix:BHYQZbI8m036ELU21gZil75Y
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.0.0 (22-Jun-2016):
* Use secure cypher suites in stunnel
* Fix wsproxy in http-svr

0.9.9 (20-Oct-2015):
* Remove cpuid
* Remove xen-utils
Expand Down
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.3
Name: xen-api-libs-transitional
Version: 0.9.9
Version: 1.0.0
Synopsis: Temporary set of to-be-deprecated libraries
License: LGPL-2.1 with OCaml linking exception
Authors: various
Expand Down
1 change: 1 addition & 0 deletions gzip/gzip.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* GNU Lesser General Public License for more details.
*)

open Stdext
open Pervasiveext

(** Path to the gzip binary *)
Expand Down
1 change: 1 addition & 0 deletions http-svr/http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

(* A very very simple HTTP server! *)

open Stdext
open Xstringext
open Pervasiveext
open Fun
Expand Down
1 change: 1 addition & 0 deletions http-svr/http_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*)
(* A very simple HTTP client *)

open Stdext
open Xstringext

module D = Debug.Make(struct let name="http" end)
Expand Down
1 change: 1 addition & 0 deletions http-svr/http_proxy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module D=Debug.Make(struct let name="http_proxy" end)
open D

open Xmlrpc_client
open Stdext
open Threadext
open Pervasiveext

Expand Down
1 change: 1 addition & 0 deletions http-svr/http_svr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*
*)

open Stdext
open Http
open Xstringext
open Pervasiveext
Expand Down
4 changes: 2 additions & 2 deletions http-svr/mime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*)
(* MIME handling for HTTP responses *)

open Xstringext
open Stdext.Xstringext
open Printf

(** Map extension to MIME type *)
Expand All @@ -22,7 +22,7 @@ type t = (string, string) Hashtbl.t
(** Parse an Apache-format mime.types file and return mime_t *)
let mime_of_file file =
let h = Hashtbl.create 1024 in
Unixext.readfile_line (fun line ->
Stdext.Unixext.readfile_line (fun line ->
if not (String.startswith "#" line) then begin
match String.split_f String.isspace line with
|[] |[_] -> ()
Expand Down
2 changes: 1 addition & 1 deletion http-svr/radix_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ let fold f acc t =
let rec inner p acc = function
| Node (p', v, ns) ->
let pp = p ^ p' in
let acc = Opt.default acc (Opt.map (fun v -> f pp v acc) v) in
let acc = Stdext.Opt.default acc (Stdext.Opt.map (fun v -> f pp v acc) v) in
List.fold_left (fun acc n -> inner pp acc n) acc ns in
inner "" acc t
1 change: 1 addition & 0 deletions http-svr/server_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*)

open Unix
open Stdext
open Pervasiveext
open Threadext

Expand Down
6 changes: 3 additions & 3 deletions http-svr/ws_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17
*)

open Xstringext
open Stdext.Xstringext

type protocol = | Hixie76 | Hybi10

Expand Down Expand Up @@ -201,7 +201,7 @@ let v10_upgrade req s =
let key = find_header headers "sec-websocket-key" in
(*let vsn = find_header headers "sec-websocket-version" in*)
let result = sha_1 (key ^ ws_uuid) in
let key = Base64.encode result in
let key = Stdext.Base64.encode result in
let headers = http_101_websocket_upgrade_15 key in
Http.output_http s headers

Expand All @@ -219,7 +219,7 @@ let hixie_v76_upgrade req s =
let s1 = marshal_int32 v1 in
let s2 = marshal_int32 v2 in
let s3 = String.make 8 '\000' in
Unixext.really_read s s3 0 8;
Stdext.Unixext.really_read s s3 0 8;
let string = Printf.sprintf "%s%s%s" s1 s2 s3 in
let digest = Digest.string string in

Expand Down
4 changes: 2 additions & 2 deletions http-svr/xMLRPC.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module To = struct

let boolean b = value (box "boolean" [pcdata (if b then "1" else "0")])

let datetime s = value (box "dateTime.iso8601" [pcdata (Date.to_string s)])
let datetime s = value (box "dateTime.iso8601" [pcdata (Stdext.Date.to_string s)])

let double x =
let txt = match classify_float x with
Expand Down Expand Up @@ -156,7 +156,7 @@ module From = struct

let boolean = value (singleton ["boolean"] ((<>) (Xml.PCData "0")))

let datetime x = Date.of_string (value (singleton ["dateTime.iso8601"] (pcdata id)) x)
let datetime x = Stdext.Date.of_string (value (singleton ["dateTime.iso8601"] (pcdata id)) x)

let double = value (singleton ["double"] (pcdata float_of_string))

Expand Down
4 changes: 2 additions & 2 deletions http-svr/xMLRPC.mli
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module To : sig
val boolean : bool -> xmlrpc

(** Marshal a date-time. *)
val datetime : Date.iso8601 -> xmlrpc
val datetime : Stdext.Date.iso8601 -> xmlrpc

(** Marshal a double. *)
val double : float -> xmlrpc
Expand Down Expand Up @@ -93,7 +93,7 @@ module From : sig
val boolean : xmlrpc -> bool

(** Parse a date-time. *)
val datetime : xmlrpc -> Date.iso8601
val datetime : xmlrpc -> Stdext.Date.iso8601

(** Parse a double. *)
val double : xmlrpc -> float
Expand Down
1 change: 1 addition & 0 deletions http-svr/xmlrpc_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
open Stdext
open Xstringext
open Pervasiveext
open Threadext
Expand Down
13 changes: 10 additions & 3 deletions opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
opam-version: "1"
opam-version: "1.2"
maintainer: "[email protected]"
authors: "[email protected]"
homepage: "https://xapi-project.github.io/"
bug-reports: "https://github.com/xapi-project/xen-api-libs-transitional.git"
dev-repo: "https://github.com/xapi-project/xen-api-libs-transitional.git"
build: [
[make]
]
install: [
[make "install" "BINDIR=%{bin}%"]
]
remove: [
Expand All @@ -17,16 +23,17 @@ remove: [
["ocamlfind" "remove" "xenstore-compat"]
["ocamlfind" "remove" "xml-light2"]
]
os: ["linux"]
available: [ os = "linux" ]
depends: [
"ocamlfind"
"xapi-stdext" {>= "0.13.0"}
"xapi-stdext" {>= "2.0.0"}
"xmlm"
"xapi-forkexecd"
"rpc"
"xenctrl"
"xenstore"
"xenstore_transport"
"oasis" {build}
]
depexts: [
[["debian"] ["libxen-dev"]]
Expand Down
6 changes: 2 additions & 4 deletions pciutil/pciutil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* Util to parse pciids
*)

open Xstringext

(* defaults, if we can't find better information: *)
let unknown_vendor vendor = Some (Printf.sprintf "Unknown vendor %s" vendor)
let unknown_device device = Some (Printf.sprintf "Unknown device %s" device)
Expand All @@ -27,7 +25,7 @@ let parse_from file vendor device =
When we find a device match we only accept it if it's from the right vendor; it doesn't make
sense to pair vendor 2's device with vendor 1. *)
let current_xvendor = ref "" in
Unixext.readfile_line (fun line ->
Stdext.Unixext.readfile_line (fun line ->
if line = "" || line.[0] = '#' ||
(line.[0] = '\t' && line.[1] = '\t') then
(* ignore subvendors/subdevices, blank lines and comments *)
Expand All @@ -41,7 +39,7 @@ let parse_from file vendor device =
if xdevice = device then (
device_str := Some (String.sub line 7 (String.length line - 7));
(* abort reading, we found what we want *)
raise Unixext.Break
raise Stdext.Unixext.Break
)
)
) else (
Expand Down
2 changes: 1 addition & 1 deletion sexpr/sExpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type t =
| String of string
| WeirdString of string * string

open Xstringext
open Stdext.Xstringext

let unescape_buf buf s =
let aux esc = function
Expand Down
3 changes: 1 addition & 2 deletions sexpr/sExpr_TS.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
open Threadext

let lock = Mutex.create ()

let of_string s =
Mutex.execute lock
Stdext.Threadext.Mutex.execute lock
(fun () -> SExprParser.expr SExprLexer.token (Lexing.from_string s))

let string_of = SExpr.string_of
1 change: 1 addition & 0 deletions sha1/sha1sum.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(** Path to the sha1sum binary (used in the new import/export code to append checksums *)
let sha1sum = "/usr/bin/sha1sum"

open Stdext
open Pervasiveext
open Xstringext

Expand Down
1 change: 1 addition & 0 deletions stunnel/stunnel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module D=Debug.Make(struct let name="stunnel" end)
open D
let trim = String.trim

open Stdext
open Printf
open Pervasiveext
open Xstringext
Expand Down
1 change: 1 addition & 0 deletions stunnel/stunnel_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ let times : (int, float) Hashtbl.t ref = ref (Hashtbl.create capacity)
(** A mapping of stunnel unique ID to Stunnel.t *)
let stunnels : (int, Stunnel.t) Hashtbl.t ref = ref (Hashtbl.create capacity)

open Stdext
open Pervasiveext
open Threadext
open Listext
Expand Down
2 changes: 1 addition & 1 deletion xenstore/watch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let has_fired ~xs x =
let wait_for ~xs ?(timeout=300.) (x: 'a t) =
let task = Xs.wait x.evaluate in
let (p1,p2) = Unix.pipe () in
Pervasiveext.finally (fun () ->
Stdext.Pervasiveext.finally (fun () ->
let thread = Thread.create (fun () ->
let r,_,_ = Unix.select [p1] [] [] timeout in
if List.length r > 0 then () else begin
Expand Down
6 changes: 3 additions & 3 deletions xml-light2/xml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let parse_bigbuffer b =
let n = ref Int64.zero in
let aux () =
try
let c = Bigbuffer.get b !n in
let c = Stdext.Bigbuffer.get b !n in
n := Int64.add !n Int64.one;
int_of_char c
with _ -> raise End_of_file in
Expand Down Expand Up @@ -186,8 +186,8 @@ let to_string_fmt xml =
let s = Buffer.contents buffer in Buffer.reset buffer; s

let to_bigbuffer xml =
let buffer = Bigbuffer.make () in
to_fct xml (fun s -> Bigbuffer.append_substring buffer s 0 (String.length s));
let buffer = Stdext.Bigbuffer.make () in
to_fct xml (fun s -> Stdext.Bigbuffer.append_substring buffer s 0 (String.length s));
buffer

(* helpers functions *)
Expand Down
4 changes: 2 additions & 2 deletions xml-light2/xml.mli
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ 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
val parse_bigbuffer : Stdext.Bigbuffer.t -> xml

(** output functions *)
val to_fct : xml -> (string -> unit) -> unit
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
val to_bigbuffer : xml -> Stdext.Bigbuffer.t

(** helper functions *)
exception Not_pcdata of string
Expand Down

0 comments on commit e064560

Please sign in to comment.