* vendor dependencies
wch-ch32v003
Matt Knight 2 years ago committed by Matt Knight
parent 1c676cbcfb
commit d10482c9bd

@ -1 +1,2 @@
*.zig text eol=lf
.gyro/** linguist-vendored

@ -1,2 +1,3 @@
zig-cache
zig-out
.gyro/redirects

@ -1,6 +0,0 @@
[submodule "libs/zig-clap"]
path = libs/zig-clap
url = https://github.com/Hejsil/zig-clap.git
[submodule "libs/zig-libxml2"]
path = libs/zig-libxml2
url = https://github.com/mitchellh/zig-libxml2.git

@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "11:00"
open-pull-requests-limit: 10

@ -0,0 +1,29 @@
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1.3.0
with:
version: master
- run: zig build
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: goto-bus-stop/setup-zig@v1.3.0
with:
version: master
- run: zig fmt --check .

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Jimmi Holst Christensen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,271 @@
<!---
README.md is autogenerated. Please edit example/README.md.template instead.
-->
# zig-clap
A simple and easy to use command line argument parser library for Zig.
## Features
* Short arguments `-a`
* Chaining `-abc` where `a` and `b` does not take values.
* Long arguments `--long`
* Supports both passing values using spacing and `=` (`-a 100`, `-a=100`)
* Short args also support passing values with no spacing or `=` (`-a100`)
* This all works with chaining (`-ba 100`, `-ba=100`, `-ba100`)
* Supports options that can be specified multiple times (`-e 1 -e 2 -e 3`)
* Print help message from parameter specification.
* Parse help message to parameter specification.
## Examples
### `clap.parse`
The simplest way to use this library is to just call the `clap.parse` function.
```zig
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
pub fn main() !void {
// First we specify what parameters our program can take.
// We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-n, --number <usize> An option parameter, which takes a value.
\\-s, --string <str>... An option parameter which can be specified multiple times.
\\<str>...
\\
);
// Initalize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also pass `.{}` to `clap.parse` if you don't
// care about the extra information `Diagnostics` provides.
var diag = clap.Diagnostic{};
var res = clap.parse(clap.Help, &params, clap.parsers.default, .{
.diagnostic = &diag,
}) catch |err| {
// Report useful error and exit
diag.report(io.getStdErr().writer(), err) catch {};
return err;
};
defer res.deinit();
if (res.args.help)
debug.print("--help\n", .{});
if (res.args.number) |n|
debug.print("--number = {}\n", .{n});
for (res.args.string) |s|
debug.print("--string = {s}\n", .{s});
for (res.positionals) |pos|
debug.print("{s}\n", .{pos});
}
```
The result will contain an `args` field and a `positionals` field. `args` will have one field
for each none positional parameter of your program. The name of the field will be the longest
name of the parameter.
The fields in `args` are typed. The type is based on the name of the value the parameter takes.
Since `--number` takes a `usize` the field `res.args.number` has the type `usize`.
Note that this is only the case because `clap.parsers.default` has a field called `usize` which
contains a parser that returns `usize`. You can pass in something other than
`clap.parsers.default` if you want some other mapping.
```zig
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
const process = std.process;
pub fn main() !void {
// First we specify what parameters our program can take.
// We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-n, --number <INT> An option parameter, which takes a value.
\\-s, --string <STR>... An option parameter which can be specified multiple times.
\\<FILE>...
\\
);
// Declare our own parsers which are used to map the argument strings to other
// types.
const parsers = comptime .{
.STR = clap.parsers.string,
.FILE = clap.parsers.string,
.INT = clap.parsers.int(usize, 10),
};
var diag = clap.Diagnostic{};
var res = clap.parse(clap.Help, &params, parsers, .{
.diagnostic = &diag,
}) catch |err| {
diag.report(io.getStdErr().writer(), err) catch {};
return err;
};
defer res.deinit();
if (res.args.help)
debug.print("--help\n", .{});
if (res.args.number) |n|
debug.print("--number = {}\n", .{n});
for (res.args.string) |s|
debug.print("--string = {s}\n", .{s});
for (res.positionals) |pos|
debug.print("{s}\n", .{pos});
}
```
### `streaming.Clap`
The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an
`args.Iterator` to provide it with arguments lazily.
```zig
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
const process = std.process;
pub fn main() !void {
const allocator = std.heap.page_allocator;
// First we specify what parameters our program can take.
const params = [_]clap.Param(u8){
.{
.id = 'h',
.names = .{ .short = 'h', .long = "help" },
},
.{
.id = 'n',
.names = .{ .short = 'n', .long = "number" },
.takes_value = .one,
},
.{ .id = 'f', .takes_value = .one },
};
var iter = try process.ArgIterator.initWithAllocator(allocator);
defer iter.deinit();
// Skip exe argument
_ = iter.next();
// Initalize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also leave the `diagnostic` field unset if you
// don't care about the extra information `Diagnostic` provides.
var diag = clap.Diagnostic{};
var parser = clap.streaming.Clap(u8, process.ArgIterator){
.params = &params,
.iter = &iter,
.diagnostic = &diag,
};
// Because we use a streaming parser, we have to consume each argument parsed individually.
while (parser.next() catch |err| {
// Report useful error and exit
diag.report(io.getStdErr().writer(), err) catch {};
return err;
}) |arg| {
// arg.param will point to the parameter which matched the argument.
switch (arg.param.id) {
'h' => debug.print("Help!\n", .{}),
'n' => debug.print("--number = {s}\n", .{arg.value.?}),
// arg.value == null, if arg.param.takes_value == .none.
// Otherwise, arg.value is the value passed with the argument, such as "-a=10"
// or "-a 10".
'f' => debug.print("{s}\n", .{arg.value.?}),
else => unreachable,
}
}
}
```
Currently, this parser is the only parser that allows an array of `Param` that
is generated at runtime.
### `help`
The `help` prints a simple list of all parameters the program can take. It expects the
`Id` to have a `description` method and an `value` method so that it can provide that
in the output. `HelpOptions` is passed to `help` to control how the help message is
printed.
```zig
const clap = @import("clap");
const std = @import("std");
pub fn main() !void {
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-v, --version Output version information and exit.
\\
);
var res = try clap.parse(clap.Help, &params, clap.parsers.default, .{});
defer res.deinit();
// `clap.help` is a function that can print a simple help message. It can print any `Param`
// where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter).
// The last argument contains options as to how `help` should print those parameters. Using
// `.{}` means the default options.
if (res.args.help)
return clap.help(std.io.getStdErr().writer(), clap.Help, &params, .{});
}
```
```
$ zig-out/bin/help --help
-h, --help
Display this help and exit.
-v, --version
Output version information and exit.
```
### `usage`
The `usage` prints a small abbreviated version of the help message. It expects the `Id`
to have a `value` method so it can provide that in the output.
```zig
const clap = @import("clap");
const std = @import("std");
pub fn main() !void {
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-v, --version Output version information and exit.
\\ --value <str> An option parameter, which takes a value.
\\
);
var res = try clap.parse(clap.Help, &params, clap.parsers.default, .{});
defer res.deinit();
// `clap.usage` is a function that can print a simple help message. It can print any `Param`
// where `Id` has a `value` method (`Param(Help)` is one such parameter).
if (res.args.help)
return clap.usage(std.io.getStdErr().writer(), clap.Help, &params);
}
```
```
$ zig-out/bin/usage --help
[-hv] [--value <str>]
```

@ -0,0 +1,71 @@
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const test_all_step = b.step("test", "Run all tests in all modes.");
inline for (@typeInfo(std.builtin.Mode).Enum.fields) |field| {
const test_mode = @field(std.builtin.Mode, field.name);
const mode_str = @tagName(test_mode);
const tests = b.addTest("clap.zig");
tests.setBuildMode(test_mode);
tests.setTarget(target);
const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ ".");
test_step.dependOn(&tests.step);
test_all_step.dependOn(test_step);
}
const example_step = b.step("examples", "Build examples");
inline for (.{
"simple",
"simple-ex",
//"simple-error",
"streaming-clap",
"help",
"usage",
}) |example_name| {
const example = b.addExecutable(example_name, "example/" ++ example_name ++ ".zig");
example.addPackagePath("clap", "clap.zig");
example.setBuildMode(mode);
example.setTarget(target);
example.install();
example_step.dependOn(&example.step);
}
const readme_step = b.step("readme", "Remake README.");
const readme = readMeStep(b);
readme.dependOn(example_step);
readme_step.dependOn(readme);
const all_step = b.step("all", "Build everything and runs all tests");
all_step.dependOn(test_all_step);
all_step.dependOn(example_step);
all_step.dependOn(readme_step);
b.default_step.dependOn(all_step);
}
fn readMeStep(b: *Builder) *std.build.Step {
const s = b.allocator.create(std.build.Step) catch unreachable;
s.* = std.build.Step.init(.custom, "ReadMeStep", b.allocator, struct {
fn make(step: *std.build.Step) anyerror!void {
@setEvalBranchQuota(10000);
_ = step;
const file = try std.fs.cwd().createFile("README.md", .{});
const stream = file.writer();
try stream.print(@embedFile("example/README.md.template"), .{
@embedFile("example/simple.zig"),
@embedFile("example/simple-ex.zig"),
@embedFile("example/streaming-clap.zig"),
@embedFile("example/help.zig"),
@embedFile("example/usage.zig"),
});
}
}.make);
return s;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,41 @@
const builtin = @import("builtin");
const std = @import("std");
const debug = std.debug;
const heap = std.heap;
const mem = std.mem;
const process = std.process;
const testing = std.testing;
/// An example of what methods should be implemented on an arg iterator.
pub const ExampleArgIterator = struct {
pub fn next(iter: *ExampleArgIterator) ?[]const u8 {
_ = iter;
return "2";
}
};
/// An argument iterator which iterates over a slice of arguments.
/// This implementation does not allocate.
pub const SliceIterator = struct {
args: []const []const u8,
index: usize = 0,
pub fn next(iter: *SliceIterator) ?[]const u8 {
if (iter.args.len <= iter.index)
return null;
defer iter.index += 1;
return iter.args[iter.index];
}
};
test "SliceIterator" {
const args = [_][]const u8{ "A", "BB", "CCC" };
var iter = SliceIterator{ .args = &args };
for (args) |a|
try testing.expectEqualStrings(a, iter.next().?);
try testing.expectEqual(@as(?[]const u8, null), iter.next());
}

@ -0,0 +1,48 @@
const std = @import("std");
const fmt = std.fmt;
pub const default = .{
.string = string,
.str = string,
.u8 = int(u8, 0),
.u16 = int(u16, 0),
.u32 = int(u32, 0),
.u64 = int(u64, 0),
.usize = int(usize, 0),
.i8 = int(i8, 0),
.i16 = int(i16, 0),
.i32 = int(i32, 0),
.i64 = int(i64, 0),
.isize = int(isize, 0),
.f32 = float(f32),
.f64 = float(f64),
};
pub fn string(in: []const u8) error{}![]const u8 {
return in;
}
pub fn int(comptime T: type, comptime radix: u8) fn ([]const u8) fmt.ParseIntError!T {
return struct {
fn parse(in: []const u8) fmt.ParseIntError!T {
return fmt.parseInt(T, in, radix);
}
}.parse;
}
pub fn float(comptime T: type) fn ([]const u8) fmt.ParseFloatError!T {
return struct {
fn parse(in: []const u8) fmt.ParseFloatError!T {
return fmt.parseFloat(T, in);
}
}.parse;
}
fn ReturnType(comptime P: type) type {
return @typeInfo(P).Fn.return_type.?;
}
pub fn Result(comptime P: type) type {
return @typeInfo(ReturnType(P)).ErrorUnion.payload;
}

@ -0,0 +1,444 @@
const builtin = @import("builtin");
const clap = @import("../clap.zig");
const std = @import("std");
const args = clap.args;
const debug = std.debug;
const heap = std.heap;
const io = std.io;
const mem = std.mem;
const os = std.os;
const testing = std.testing;
/// The result returned from Clap.next
pub fn Arg(comptime Id: type) type {
return struct {
const Self = @This();
param: *const clap.Param(Id),
value: ?[]const u8 = null,
};
}
pub const Error = error{
MissingValue,
InvalidArgument,
DoesntTakeValue,
};
/// A command line argument parser which, given an ArgIterator, will parse arguments according
/// to the params. Clap parses in an iterating manner, so you have to use a loop together with
/// Clap.next to parse all the arguments of your program.
///
/// This parser is the building block for all the more complicated parsers.
pub fn Clap(comptime Id: type, comptime ArgIterator: type) type {
return struct {
const State = union(enum) {
normal,
chaining: Chaining,
rest_are_positional,
const Chaining = struct {
arg: []const u8,
index: usize,
};
};
params: []const clap.Param(Id),
iter: *ArgIterator,
state: State = .normal,
positional: ?*const clap.Param(Id) = null,
diagnostic: ?*clap.Diagnostic = null,
/// Get the next Arg that matches a Param.
pub fn next(parser: *@This()) !?Arg(Id) {
switch (parser.state) {
.normal => return try parser.normal(),
.chaining => |state| return try parser.chaining(state),
.rest_are_positional => {
const param = parser.positionalParam() orelse unreachable;
const value = parser.iter.next() orelse return null;
return Arg(Id){ .param = param, .value = value };
},
}
}
fn normal(parser: *@This()) !?Arg(Id) {
const arg_info = (try parser.parseNextArg()) orelse return null;
const arg = arg_info.arg;
switch (arg_info.kind) {
.long => {
const eql_index = mem.indexOfScalar(u8, arg, '=');
const name = if (eql_index) |i| arg[0..i] else arg;
const maybe_value = if (eql_index) |i| arg[i + 1 ..] else null;
for (parser.params) |*param| {
const match = param.names.long orelse continue;
if (!mem.eql(u8, name, match))
continue;
if (param.takes_value == .none) {
if (maybe_value != null)
return parser.err(arg, .{ .long = name }, Error.DoesntTakeValue);
return Arg(Id){ .param = param };
}
const value = blk: {
if (maybe_value) |v|
break :blk v;
break :blk parser.iter.next() orelse
return parser.err(arg, .{ .long = name }, Error.MissingValue);
};
return Arg(Id){ .param = param, .value = value };
}
return parser.err(arg, .{ .long = name }, Error.InvalidArgument);
},
.short => return try parser.chaining(.{
.arg = arg,
.index = 0,
}),
.positional => if (parser.positionalParam()) |param| {
// If we find a positional with the value `--` then we
// interpret the rest of the arguments as positional
// arguments.
if (mem.eql(u8, arg, "--")) {
parser.state = .rest_are_positional;
const value = parser.iter.next() orelse return null;
return Arg(Id){ .param = param, .value = value };
}
return Arg(Id){ .param = param, .value = arg };
} else {
return parser.err(arg, .{}, Error.InvalidArgument);
},
}
}
fn chaining(parser: *@This(), state: State.Chaining) !?Arg(Id) {
const arg = state.arg;
const index = state.index;
const next_index = index + 1;
for (parser.params) |*param| {
const short = param.names.short orelse continue;
if (short != arg[index])
continue;
// Before we return, we have to set the new state of the clap
defer {
if (arg.len <= next_index or param.takes_value != .none) {
parser.state = .normal;
} else {
parser.state = .{
.chaining = .{
.arg = arg,
.index = next_index,
},
};
}
}
const next_is_eql = if (next_index < arg.len) arg[next_index] == '=' else false;
if (param.takes_value == .none) {
if (next_is_eql)
return parser.err(arg, .{ .short = short }, Error.DoesntTakeValue);
return Arg(Id){ .param = param };
}
if (arg.len <= next_index) {
const value = parser.iter.next() orelse
return parser.err(arg, .{ .short = short }, Error.MissingValue);
return Arg(Id){ .param = param, .value = value };
}
if (next_is_eql)
return Arg(Id){ .param = param, .value = arg[next_index + 1 ..] };
return Arg(Id){ .param = param, .value = arg[next_index..] };
}
return parser.err(arg, .{ .short = arg[index] }, Error.InvalidArgument);
}
fn positionalParam(parser: *@This()) ?*const clap.Param(Id) {
if (parser.positional) |p|
return p;
for (parser.params) |*param| {
if (param.names.long) |_|
continue;
if (param.names.short) |_|
continue;
parser.positional = param;
return param;
}
return null;
}
const ArgInfo = struct {
arg: []const u8,
kind: enum {
long,
short,
positional,
},
};
fn parseNextArg(parser: *@This()) !?ArgInfo {
const full_arg = parser.iter.next() orelse return null;
if (mem.eql(u8, full_arg, "--") or mem.eql(u8, full_arg, "-"))
return ArgInfo{ .arg = full_arg, .kind = .positional };
if (mem.startsWith(u8, full_arg, "--"))
return ArgInfo{ .arg = full_arg[2..], .kind = .long };
if (mem.startsWith(u8, full_arg, "-"))
return ArgInfo{ .arg = full_arg[1..], .kind = .short };
return ArgInfo{ .arg = full_arg, .kind = .positional };
}
fn err(parser: @This(), arg: []const u8, names: clap.Names, _err: anytype) @TypeOf(_err) {
if (parser.diagnostic) |d|
d.* = .{ .arg = arg, .name = names };
return _err;
}
};
}
fn testNoErr(
params: []const clap.Param(u8),
args_strings: []const []const u8,
results: []const Arg(u8),
) !void {
var iter = args.SliceIterator{ .args = args_strings };
var c = Clap(u8, args.SliceIterator){
.params = params,
.iter = &iter,
};
for (results) |res| {
const arg = (try c.next()) orelse return error.TestFailed;
try testing.expectEqual(res.param, arg.param);
const expected_value = res.value orelse {
try testing.expectEqual(@as(@TypeOf(arg.value), null), arg.value);
continue;
};
const actual_value = arg.value orelse return error.TestFailed;
try testing.expectEqualSlices(u8, expected_value, actual_value);
}
if (try c.next()) |_|
return error.TestFailed;
}
fn testErr(
params: []const clap.Param(u8),
args_strings: []const []const u8,
expected: []const u8,
) !void {
var diag: clap.Diagnostic = undefined;
var iter = args.SliceIterator{ .args = args_strings };
var c = Clap(u8, args.SliceIterator){
.params = params,
.iter = &iter,
.diagnostic = &diag,
};
while (c.next() catch |err| {
var buf: [1024]u8 = undefined;
var fbs = io.fixedBufferStream(&buf);
diag.report(fbs.writer(), err) catch return error.TestFailed;
try testing.expectEqualStrings(expected, fbs.getWritten());
return;
}) |_| {}
try testing.expect(false);
}
test "short params" {
const params = [_]clap.Param(u8){
.{ .id = 0, .names = .{ .short = 'a' } },
.{ .id = 1, .names = .{ .short = 'b' } },
.{
.id = 2,
.names = .{ .short = 'c' },
.takes_value = .one,
},
.{
.id = 3,
.names = .{ .short = 'd' },
.takes_value = .many,
},
};
const a = &params[0];
const b = &params[1];
const c = &params[2];
const d = &params[3];
try testNoErr(
&params,
&.{
"-a", "-b", "-ab", "-ba",
"-c", "0", "-c=0", "-ac",
"0", "-ac=0", "-d=0",
},
&.{
.{ .param = a },
.{ .param = b },
.{ .param = a },
.{ .param = b },
.{ .param = b },
.{ .param = a },
.{ .param = c, .value = "0" },
.{ .param = c, .value = "0" },
.{ .param = a },
.{ .param = c, .value = "0" },
.{ .param = a },
.{ .param = c, .value = "0" },
.{ .param = d, .value = "0" },
},
);
}
test "long params" {
const params = [_]clap.Param(u8){
.{ .id = 0, .names = .{ .long = "aa" } },
.{ .id = 1, .names = .{ .long = "bb" } },
.{
.id = 2,
.names = .{ .long = "cc" },
.takes_value = .one,
},
.{
.id = 3,
.names = .{ .long = "dd" },
.takes_value = .many,
},
};
const aa = &params[0];
const bb = &params[1];
const cc = &params[2];
const dd = &params[3];
try testNoErr(
&params,
&.{
"--aa", "--bb",
"--cc", "0",
"--cc=0", "--dd=0",
},
&.{
.{ .param = aa },
.{ .param = bb },
.{ .param = cc, .value = "0" },
.{ .param = cc, .value = "0" },
.{ .param = dd, .value = "0" },
},
);
}
test "positional params" {
const params = [_]clap.Param(u8){.{
.id = 0,
.takes_value = .one,
}};
try testNoErr(
&params,
&.{ "aa", "bb" },
&.{
.{ .param = &params[0], .value = "aa" },
.{ .param = &params[0], .value = "bb" },
},
);
}
test "all params" {
const params = [_]clap.Param(u8){
.{
.id = 0,
.names = .{ .short = 'a', .long = "aa" },
},
.{
.id = 1,
.names = .{ .short = 'b', .long = "bb" },
},
.{
.id = 2,
.names = .{ .short = 'c', .long = "cc" },
.takes_value = .one,
},
.{ .id = 3, .takes_value = .one },
};
const aa = &params[0];
const bb = &params[1];
const cc = &params[2];
const positional = &params[3];
try testNoErr(
&params,
&.{
"-a", "-b", "-ab", "-ba",
"-c", "0", "-c=0", "-ac",
"0", "-ac=0", "--aa", "--bb",
"--cc", "0", "--cc=0", "something",
"-", "--", "--cc=0", "-a",
},
&.{
.{ .param = aa },
.{ .param = bb },
.{ .param = aa },
.{ .param = bb },
.{ .param = bb },
.{ .param = aa },
.{ .param = cc, .value = "0" },
.{ .param = cc, .value = "0" },
.{ .param = aa },
.{ .param = cc, .value = "0" },
.{ .param = aa },
.{ .param = cc, .value = "0" },
.{ .param = aa },
.{ .param = bb },
.{ .param = cc, .value = "0" },
.{ .param = cc, .value = "0" },
.{ .param = positional, .value = "something" },
.{ .param = positional, .value = "-" },
.{ .param = positional, .value = "--cc=0" },
.{ .param = positional, .value = "-a" },
},
);
}
test "errors" {
const params = [_]clap.Param(u8){
.{
.id = 0,
.names = .{ .short = 'a', .long = "aa" },
},
.{
.id = 1,
.names = .{ .short = 'c', .long = "cc" },
.takes_value = .one,
},
};
try testErr(&params, &.{"q"}, "Invalid argument 'q'\n");
try testErr(&params, &.{"-q"}, "Invalid argument '-q'\n");
try testErr(&params, &.{"--q"}, "Invalid argument '--q'\n");
try testErr(&params, &.{"--q=1"}, "Invalid argument '--q'\n");
try testErr(&params, &.{"-a=1"}, "The argument '-a' does not take a value\n");
try testErr(&params, &.{"--aa=1"}, "The argument '--aa' does not take a value\n");
try testErr(&params, &.{"-c"}, "The argument '-c' requires a value but none was supplied\n");
try testErr(
&params,
&.{"--cc"},
"The argument '--cc' requires a value but none was supplied\n",
);
}

@ -0,0 +1,90 @@
<!---
README.md is autogenerated. Please edit example/README.md.template instead.
-->
# zig-clap
A simple and easy to use command line argument parser library for Zig.
## Features
* Short arguments `-a`
* Chaining `-abc` where `a` and `b` does not take values.
* Long arguments `--long`
* Supports both passing values using spacing and `=` (`-a 100`, `-a=100`)
* Short args also support passing values with no spacing or `=` (`-a100`)
* This all works with chaining (`-ba 100`, `-ba=100`, `-ba100`)
* Supports options that can be specified multiple times (`-e 1 -e 2 -e 3`)
* Print help message from parameter specification.
* Parse help message to parameter specification.
## Examples
### `clap.parse`
The simplest way to use this library is to just call the `clap.parse` function.
```zig
{s}
```
The result will contain an `args` field and a `positionals` field. `args` will have one field
for each none positional parameter of your program. The name of the field will be the longest
name of the parameter.
The fields in `args` are typed. The type is based on the name of the value the parameter takes.
Since `--number` takes a `usize` the field `res.args.number` has the type `usize`.
Note that this is only the case because `clap.parsers.default` has a field called `usize` which
contains a parser that returns `usize`. You can pass in something other than
`clap.parsers.default` if you want some other mapping.
```zig
{s}
```
### `streaming.Clap`
The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an
`args.Iterator` to provide it with arguments lazily.
```zig
{s}
```
Currently, this parser is the only parser that allows an array of `Param` that
is generated at runtime.
### `help`
The `help` prints a simple list of all parameters the program can take. It expects the
`Id` to have a `description` method and an `value` method so that it can provide that
in the output. `HelpOptions` is passed to `help` to control how the help message is
printed.
```zig
{s}
```
```
$ zig-out/bin/help --help
-h, --help
Display this help and exit.
-v, --version
Output version information and exit.
```
### `usage`
The `usage` prints a small abbreviated version of the help message. It expects the `Id`
to have a `value` method so it can provide that in the output.
```zig
{s}
```
```
$ zig-out/bin/usage --help
[-hv] [--value <str>]
```

@ -0,0 +1,20 @@
const clap = @import("clap");
const std = @import("std");
pub fn main() !void {
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-v, --version Output version information and exit.
\\
);
var res = try clap.parse(clap.Help, &params, clap.parsers.default, .{});
defer res.deinit();
// `clap.help` is a function that can print a simple help message. It can print any `Param`
// where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter).
// The last argument contains options as to how `help` should print those parameters. Using
// `.{}` means the default options.
if (res.args.help)
return clap.help(std.io.getStdErr().writer(), clap.Help, &params, .{});
}

@ -0,0 +1,44 @@
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
const process = std.process;
pub fn main() !void {
// First we specify what parameters our program can take.
// We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-n, --number <INT> An option parameter, which takes a value.
\\-s, --string <STR>... An option parameter which can be specified multiple times.
\\<FILE>...
\\
);
// Declare our own parsers which are used to map the argument strings to other
// types.
const parsers = comptime .{
.STR = clap.parsers.string,
.FILE = clap.parsers.string,
.INT = clap.parsers.int(usize, 10),
};
var diag = clap.Diagnostic{};
var res = clap.parse(clap.Help, &params, parsers, .{
.diagnostic = &diag,
}) catch |err| {
diag.report(io.getStdErr().writer(), err) catch {};
return err;
};
defer res.deinit();
if (res.args.help)
debug.print("--help\n", .{});
if (res.args.number) |n|
debug.print("--number = {}\n", .{n});
for (res.args.string) |s|
debug.print("--string = {s}\n", .{s});
for (res.positionals) |pos|
debug.print("{s}\n", .{pos});
}

@ -0,0 +1,39 @@
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
pub fn main() !void {
// First we specify what parameters our program can take.
// We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-n, --number <usize> An option parameter, which takes a value.
\\-s, --string <str>... An option parameter which can be specified multiple times.
\\<str>...
\\
);
// Initalize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also pass `.{}` to `clap.parse` if you don't
// care about the extra information `Diagnostics` provides.
var diag = clap.Diagnostic{};
var res = clap.parse(clap.Help, &params, clap.parsers.default, .{
.diagnostic = &diag,
}) catch |err| {
// Report useful error and exit
diag.report(io.getStdErr().writer(), err) catch {};
return err;
};
defer res.deinit();
if (res.args.help)
debug.print("--help\n", .{});
if (res.args.number) |n|
debug.print("--number = {}\n", .{n});
for (res.args.string) |s|
debug.print("--string = {s}\n", .{s});
for (res.positionals) |pos|
debug.print("{s}\n", .{pos});
}

@ -0,0 +1,59 @@
const clap = @import("clap");
const std = @import("std");
const debug = std.debug;
const io = std.io;
const process = std.process;
pub fn main() !void {
const allocator = std.heap.page_allocator;
// First we specify what parameters our program can take.
const params = [_]clap.Param(u8){
.{
.id = 'h',
.names = .{ .short = 'h', .long = "help" },
},
.{
.id = 'n',
.names = .{ .short = 'n', .long = "number" },
.takes_value = .one,
},
.{ .id = 'f', .takes_value = .one },
};
var iter = try process.ArgIterator.initWithAllocator(allocator);
defer iter.deinit();
// Skip exe argument
_ = iter.next();
// Initalize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also leave the `diagnostic` field unset if you
// don't care about the extra information `Diagnostic` provides.
var diag = clap.Diagnostic{};
var parser = clap.streaming.Clap(u8, process.ArgIterator){
.params = &params,
.iter = &iter,
.diagnostic = &diag,
};
// Because we use a streaming parser, we have to consume each argument parsed individually.
while (parser.next() catch |err| {
// Report useful error and exit
diag.report(io.getStdErr().writer(), err) catch {};
return err;
}) |arg| {
// arg.param will point to the parameter which matched the argument.
switch (arg.param.id) {
'h' => debug.print("Help!\n", .{}),
'n' => debug.print("--number = {s}\n", .{arg.value.?}),
// arg.value == null, if arg.param.takes_value == .none.
// Otherwise, arg.value is the value passed with the argument, such as "-a=10"
// or "-a 10".
'f' => debug.print("{s}\n", .{arg.value.?}),
else => unreachable,
}
}
}

@ -0,0 +1,19 @@
const clap = @import("clap");
const std = @import("std");
pub fn main() !void {
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-v, --version Output version information and exit.
\\ --value <str> An option parameter, which takes a value.
\\
);
var res = try clap.parse(clap.Help, &params, clap.parsers.default, .{});
defer res.deinit();
// `clap.usage` is a function that can print a simple help message. It can print any `Param`
// where `Id` has a `value` method (`Param(Help)` is one such parameter).
if (res.args.help)
return clap.usage(std.io.getStdErr().writer(), clap.Help, &params);
}

@ -0,0 +1,14 @@
pkgs:
clap:
version: 0.5.0
license: MIT
description: Simple command line argument parsing library
source_url: "https://github.com/Hejsil/zig-clap"
root: clap.zig
files:
README.md
LICENSE
build.zig
clap/*.zig
example/*.zig

@ -0,0 +1,5 @@
id: aoe2l16htluewam6bfwvv0khsbbno8g8jd7suonifg74u7kd
name: clap
main: clap.zig
license: MIT
dependencies:

@ -0,0 +1,5 @@
# If we are a computer with nix-shell available, then use that to setup
# the build environment with exactly what we need.
if has nix-shell; then
use nix
fi

@ -0,0 +1,66 @@
on: [push, pull_request]
name: Test
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
target: [
aarch64-linux-gnu,
aarch64-linux-musl,
aarch64-macos,
i386-linux-gnu,
i386-linux-musl,
i386-windows,
x86_64-linux-gnu,
x86_64-linux-musl,
x86_64-macos,
x86_64-windows-gnu,
]
runs-on: ${{ matrix.os }}
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
# Install Nix and use that to run our tests so our environment matches exactly.
- uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable
# Run our checks to catch quick issues
- run: nix flake check
# Run our go tests within the context of the dev shell from the flake. This
# will ensure we have all our dependencies.
- name: test
run: nix develop -c zig build -Dtarget=${{ matrix.target }}
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
# Install Nix and use that to run our tests so our environment matches exactly.
- uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable
# Run our checks to catch quick issues
- run: nix flake check
# Run our go tests within the context of the dev shell from the flake. This
# will ensure we have all our dependencies.
- name: test
run: nix develop -c zig build test

@ -0,0 +1,6 @@
[submodule "libxml2"]
path = libxml2
url = https://github.com/GNOME/libxml2.git
[submodule "test/zig-zlib"]
path = test/zig-zlib
url = https://github.com/mattnite/zig-zlib

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Mitchell Hashimoto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,65 @@
# libxml2 Built with Zig
This repository contains Zig code for building libxml2 using Zig.
This allows other projects that use the Zig build system to easily
consume this library, cross-compile it, etc.
**Why?** Using the Zig build system makes it much easier to cross-compile
a library, even if you aren't using the Zig programming language. See
[Maintain it with Zig](https://kristoff.it/blog/maintain-it-with-zig/)
for some more information.
This library currently hardcodes the libxml2 version (latest as of writing
this but unlikely to remain that way for long). In the future, I'd like to
allow users to pass in a custom libxml2 directory, and it'd be really cool to
setup some sort of Github Action to check for new versions and try to pull
it in. Maybe one day.
## Usage
While we all eagerly await the [Zig Package Manager](https://github.com/ziglang/zig/issues/943),
the recommended way to use this is via git submodules or just embedding
this into your repository.
```zig
const libxml2 = @import("path/to/libxml2.zig");
pub fn build(b: *std.build.Builder) !void {
// ...
const lib = try libxml2.create(b, target, mode, .{
// These are the minimal options to NOT depend on any other libraries.
// If you ave these libraries, just set these to true.
.iconv = false,
.lzma = false,
.zlib = false,
});
const exe = b.addExecutable("my-program", "src/main.zig");
lib.link(exe);
}
```
This package does not provide any Zig-native APIs to access the underlying
C library. This is by design, the focus of this repository is only to enable
building the underlying library using the Zig build system. Therefore, to
use the library, import the headers and use the C API:
```zig
const c = @cImport({
@cInclude("libxml/xmlreader.h");
});
// ... do stuff with `c`
```
### Other Dependencies
Some features require other libraries. In the example above, we disabled
those features. For example, if you set `.zlib = true`, then zlib must
be available.
In this scenario, you can find and use a zlib build such as
[zig-zlib](https://github.com/mattnite/zig-zlib) as normal. When that
library is also added to the project, it adds its include paths and
linking information to the build, so libxml2 can be built with zlib support.

@ -0,0 +1,36 @@
const std = @import("std");
const libxml2 = @import("libxml2.zig");
const zlib = @import("test/zig-zlib/zlib.zig");
pub fn build(b: *std.build.Builder) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const xml2 = try libxml2.create(b, target, mode, .{
// We don't have the required libs so don't build these
.iconv = false,
.lzma = false,
.zlib = false,
});
xml2.step.install();
// Tests that we can depend on other libraries like zlib
const xml2_with_libs = try libxml2.create(b, target, mode, .{
// We don't have the required libs so don't build these
.iconv = false,
.lzma = false,
// Testing this
.zlib = true,
});
const z = zlib.create(b, target, mode);
z.link(xml2_with_libs.step, .{});
const static_binding_test = b.addTest("test/basic.zig");
static_binding_test.setBuildMode(mode);
xml2.link(static_binding_test);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&xml2_with_libs.step.step);
test_step.dependOn(&static_binding_test.step);
}

@ -0,0 +1,94 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1629481132,
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "997f7efcb746a9c140ce1f13c72263189225f482",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1641939011,
"narHash": "sha256-a0z5+KgAFkqrDSFI9dl80GpnvtCgWnEHMewASkGrSE0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1b29f6fdb8ca9389f5000f479cdec42ceb67e161",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1631288242,
"narHash": "sha256-sXm4KiKs7qSIf5oTAmrlsEvBW193sFj+tKYVirBaXz0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0e24c87754430cb6ad2f8c8c8021b29834a8845e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"zig": "zig"
}
},
"zig": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1641947361,
"narHash": "sha256-EQa8TYWFPmdKxT/7GFf6FvCUcuBFCJgKXX1/eI4P1TM=",
"owner": "arqv",
"repo": "zig-overlay",
"rev": "287a88af76af7e80fad707656f87921678f2a7e4",
"type": "github"
},
"original": {
"owner": "arqv",
"repo": "zig-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

@ -0,0 +1,30 @@
{
description = "libflightplan";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig.url = "github:arqv/zig-overlay";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
let
overlays = [
# Our repo overlay
(import ./nix/overlay.nix)
# Zig overlay
(final: prev: {
zigpkgs = inputs.zig.packages.${prev.system};
})
];
# Our supported systems are the same supported systems as the Zig binaries
systems = builtins.attrNames inputs.zig.packages;
in flake-utils.lib.eachSystem systems (system:
let pkgs = import nixpkgs { inherit overlays system; };
in rec {
devShell = pkgs.devShell;
}
);
}

@ -0,0 +1,248 @@
const std = @import("std");
/// The version information for this library. This is hardcoded for now but
/// in the future we will parse this from configure.ac.
pub const Version = struct {
pub const major = "2";
pub const minor = "9";
pub const micro = "12";
pub fn number() []const u8 {
comptime {
return major ++ "0" ++ minor ++ "0" ++ micro;
}
}
pub fn string() []const u8 {
comptime {
return "\"" ++ number() ++ "\"";
}
}
pub fn dottedString() []const u8 {
comptime {
return "\"" ++ major ++ "." ++ minor ++ "." ++ micro ++ "\"";
}
}
};
/// This is the type returned by create.
pub const Library = struct {
step: *std.build.LibExeObjStep,
/// statically link this library into the given step
pub fn link(self: Library, other: *std.build.LibExeObjStep) void {
self.addIncludeDirs(other);
other.linkLibrary(self.step);
}
/// only add the include dirs to the given step. This is useful if building
/// a static library that you don't want to fully link in the code of this
/// library.
pub fn addIncludeDirs(self: Library, other: *std.build.LibExeObjStep) void {
_ = self;
other.addIncludeDir(include_dir);
other.addIncludeDir(override_include_dir);
}
};
/// Compile-time options for the library. These mostly correspond to
/// options exposed by the native build system used by the library.
pub const Options = struct {
// These options are all defined in libxml2's configure.c and correspond
// to `--with-X` options for `./configure`. Their defaults are properly set.
c14n: bool = true,
catalog: bool = true,
debug: bool = true,
docb: bool = true, // docbook
ftp: bool = true,
history: bool = true,
html: bool = true,
iconv: bool = true,
icu: bool = false,
iso8859x: bool = true,
mem_debug: bool = false,
minimum: bool = true,
output: bool = true,
pattern: bool = true,
push: bool = true,
reader: bool = true,
regexp: bool = true,
run_debug: bool = false,
sax1: bool = true,
schemas: bool = true,
schematron: bool = true,
thread: bool = true,
thread_alloc: bool = false,
tree: bool = true,
valid: bool = true,
writer: bool = true,
xinclude: bool = true,
xpath: bool = true,
xptr: bool = true,
modules: bool = true,
lzma: bool = true,
zlib: bool = true,
};
/// Create this library. This is the primary API users of build.zig should
/// use to link this library to their application. On the resulting Library,
/// call the link function and given your own application step.
pub fn create(
b: *std.build.Builder,
target: std.zig.CrossTarget,
mode: std.builtin.Mode,
opts: Options,
) !Library {
const ret = b.addStaticLibrary("xml2", null);
ret.setTarget(target);
ret.setBuildMode(mode);
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
try flags.appendSlice(&.{
// Version info, hardcoded
"-DLIBXML_VERSION=" ++ Version.number(),
"-DLIBXML_VERSION_STRING=" ++ Version.string(),
"-DLIBXML_VERSION_EXTRA=\"\"",
"-DLIBXML_DOTTED_VERSION=" ++ Version.dottedString(),
// These might now always be true (particularly Windows) but for
// now we just set them all. We should do some detection later.
"-DSEND_ARG2_CAST=",
"-DGETHOSTBYNAME_ARG_CAST=",
"-DGETHOSTBYNAME_ARG_CAST_CONST=",
// Always on
"-DLIBXML_STATIC=1",
"-DLIBXML_AUTOMATA_ENABLED=1",
"-DWITHOUT_TRIO=1",
});
if (!target.isWindows()) {
try flags.appendSlice(&.{
"-DHAVE_ARPA_INET_H=1",
"-DHAVE_ARPA_NAMESER_H=1",
"-DHAVE_DL_H=1",
"-DHAVE_NETDB_H=1",
"-DHAVE_NETINET_IN_H=1",
"-DHAVE_PTHREAD_H=1",
"-DHAVE_SHLLOAD=1",
"-DHAVE_SYS_DIR_H=1",
"-DHAVE_SYS_MMAN_H=1",
"-DHAVE_SYS_NDIR_H=1",
"-DHAVE_SYS_SELECT_H=1",
"-DHAVE_SYS_SOCKET_H=1",
"-DHAVE_SYS_TIMEB_H=1",
"-DHAVE_SYS_TIME_H=1",
"-DHAVE_SYS_TYPES_H=1",
});
}
// Option-specific changes
if (opts.history) {
try flags.appendSlice(&.{
"-DHAVE_LIBHISTORY=1",
"-DHAVE_LIBREADLINE=1",
});
}
if (opts.mem_debug) {
try flags.append("-DDEBUG_MEMORY_LOCATION=1");
}
if (opts.regexp) {
try flags.append("-DLIBXML_UNICODE_ENABLED=1");
}
if (opts.run_debug) {
try flags.append("-DLIBXML_DEBUG_RUNTIME=1");
}
if (opts.thread) {
try flags.append("-DHAVE_LIBPTHREAD=1");
}
// Enable our `./configure` options. For bool-type fields we translate
// it to the `LIBXML_{field}_ENABLED` C define where field is uppercased.
inline for (std.meta.fields(@TypeOf(opts))) |field| {
if (field.field_type == bool and @field(opts, field.name)) {
var nameBuf: [32]u8 = undefined;
const name = std.ascii.upperString(&nameBuf, field.name);
const define = try std.fmt.allocPrint(b.allocator, "-DLIBXML_{s}_ENABLED=1", .{name});
try flags.append(define);
}
}
// C files
ret.addCSourceFiles(srcs, flags.items);
if (opts.sax1) {
ret.addCSourceFile(root() ++ "libxml2/DOCBparser.c", flags.items);
}
ret.addIncludeDir(include_dir);
ret.addIncludeDir(override_include_dir);
if (target.isWindows()) {
ret.addIncludeDir(win32_include_dir);
ret.linkSystemLibrary("ws2_32");
} else {
ret.addIncludeDir(posix_include_dir);
}
ret.linkLibC();
return Library{ .step = ret };
}
fn root() []const u8 {
return (std.fs.path.dirname(@src().file) orelse unreachable) ++ "/";
}
/// Directories with our includes.
const include_dir = root() ++ "libxml2/include";
const override_include_dir = root() ++ "override/include";
const posix_include_dir = root() ++ "override/config/posix";
const win32_include_dir = root() ++ "override/config/win32";
const srcs = &.{
root() ++ "libxml2/buf.c",
root() ++ "libxml2/c14n.c",
root() ++ "libxml2/catalog.c",
root() ++ "libxml2/chvalid.c",
root() ++ "libxml2/debugXML.c",
root() ++ "libxml2/dict.c",
root() ++ "libxml2/encoding.c",
root() ++ "libxml2/entities.c",
root() ++ "libxml2/error.c",
root() ++ "libxml2/globals.c",
root() ++ "libxml2/hash.c",
root() ++ "libxml2/HTMLparser.c",
root() ++ "libxml2/HTMLtree.c",
root() ++ "libxml2/legacy.c",
root() ++ "libxml2/list.c",
root() ++ "libxml2/nanoftp.c",
root() ++ "libxml2/nanohttp.c",
root() ++ "libxml2/parser.c",
root() ++ "libxml2/parserInternals.c",
root() ++ "libxml2/pattern.c",
root() ++ "libxml2/relaxng.c",
root() ++ "libxml2/SAX.c",
root() ++ "libxml2/SAX2.c",
root() ++ "libxml2/schematron.c",
root() ++ "libxml2/threads.c",
root() ++ "libxml2/tree.c",
root() ++ "libxml2/uri.c",
root() ++ "libxml2/valid.c",
root() ++ "libxml2/xinclude.c",
root() ++ "libxml2/xlink.c",
root() ++ "libxml2/xmlIO.c",
root() ++ "libxml2/xmlmemory.c",
root() ++ "libxml2/xmlmodule.c",
root() ++ "libxml2/xmlreader.c",
root() ++ "libxml2/xmlregexp.c",
root() ++ "libxml2/xmlsave.c",
root() ++ "libxml2/xmlschemas.c",
root() ++ "libxml2/xmlschemastypes.c",
root() ++ "libxml2/xmlstring.c",
root() ++ "libxml2/xmlunicode.c",
root() ++ "libxml2/xmlwriter.c",
root() ++ "libxml2/xpath.c",
root() ++ "libxml2/xpointer.c",
root() ++ "libxml2/xzlib.c",
};

@ -0,0 +1,127 @@
*.exe
*.o
*.lo
*.log
*.pyc
*.patch
.deps
.libs
.memdump
COPYING
CVE-*
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache
bissect*
compile
config.guess
config.h
config.h.in
config.h.in~
config.log
config.status
config.sub
configure
dba100000.xml
depcomp
doc/Makefile
doc/Makefile.in
doc/devhelp/Makefile
doc/devhelp/Makefile.in
doc/examples/.deps
doc/examples/Makefile
doc/examples/Makefile.in
doc/examples/io1
doc/examples/io2
doc/examples/parse1
doc/examples/parse2
doc/examples/parse3
doc/examples/parse4
doc/examples/reader1
doc/examples/reader2
doc/examples/reader3
doc/examples/reader4
doc/examples/testWriter
doc/examples/tree1
doc/examples/tree2
doc/examples/xpath1
doc/examples/xpath2
example/.deps
example/Makefile
example/Makefile.in
example/gjobread
include/Makefile
include/Makefile.in
include/libxml/Makefile
include/libxml/Makefile.in
include/libxml/xmlversion.h
install-sh
libtool
libxml-2.0-uninstalled.pc
libxml-2.0.pc
libxml2-config.cmake
libxml2.la
libxml2.spec
list
ltmain.sh
log
missing
missing.lst
m4
python/.deps
python/.libs
python/Makefile
python/Makefile.in
python/gen_prog
python/libxml2-export.c
python/libxml2-py.c
python/libxml2-py.h
python/libxml2.py
python/libxml2class.py
python/libxml2class.txt
python/libxml2mod.la
python/setup.py
python/tests/Makefile
python/tests/Makefile.in
python/tests/tmp.xml
runsuite
runtest
runxmlconf
runxmlconf.log
stamp-h1
tags
test.out
testAutomata
testC14N
testHTML
testModule
testReader
testRegexp
testRelax
testSAX
testSchemas
testThreads
testURI
testXPath
testapi
testapi.c.new
testchar
testdict
testdso.la
testlimits
testrecurse
tmp
tst.c
tst
xml2-config
xml2Conf.sh
xmlcatalog
xmlconf
xmllint
xstc/*-test.py
xstc/Makefile
xstc/Makefile.in
xstc/Tests
xstc/xsts-*.tar.gz

@ -0,0 +1,277 @@
.test:
# The image was generated with the following Dockerfile. It is also used
# for libxslt, that's why we need git and libgcrypt-dev.
#
# FROM ubuntu:20.04
# ENV DEBIAN_FRONTEND=noninteractive
# RUN apt-get update && \
# apt-get upgrade -y && \
# apt-get install -y --no-install-recommends \
# curl git ca-certificates \
# autoconf automake libtool pkg-config \
# make gcc clang llvm \
# zlib1g-dev liblzma-dev libgcrypt-dev \
# python-dev python3-dev \
# cmake
# WORKDIR /tests
# RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
image: registry.gitlab.gnome.org/gnome/libxml2
script:
- |
ln -s /tests/xmlconf
sh autogen.sh $CONFIG
make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
make check
gcc:
extends: .test
variables:
CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=700"
gcc:python3:
extends: .test
only:
- schedules
variables:
CONFIG: "--with-python=/usr/bin/python3"
CFLAGS: "-O2"
clang:asan:
extends: .test
variables:
CONFIG: "--without-python"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,unsigned-integer-overflow -fno-sanitize-recover=all -Wno-error=cast-align"
# LeakSanitizer requires SYS_CAP_PTRACE
ASAN_OPTIONS: "detect_leaks=0"
UBSAN_OPTIONS: "print_stacktrace=1"
clang:msan:
extends: .test
only:
- schedules
variables:
CONFIG: "--without-python --without-zlib --without-lzma"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align"
.cmake:linux:
image: registry.gitlab.gnome.org/gnome/libxml2
script:
- cmake -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBXML2_XMLCONF_WORKING_DIR=/tests -S . -B libxml2-build
- cmake --build libxml2-build --target install
- mkdir -p libxml2-install/share/libxml2
- cp Copyright libxml2-install/share/libxml2
- cd libxml2-build
- ctest -VV
after_script:
- cd libxml2-install
- tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$CC-$SUFFIX.tar.gz *
artifacts:
paths:
- libxml2-$CI_COMMIT_SHORT_SHA-$CC-$SUFFIX.tar.gz
expire_in: 1 day
cmake:linux:gcc:shared:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
CC: gcc
SUFFIX: shared
cmake:linux:gcc:static:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
CC: gcc
SUFFIX: static
cmake:linux:clang:shared:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
CC: clang
SUFFIX: shared
cmake:linux:clang:static:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
CC: clang
SUFFIX: static
.cmake:mingw:
tags:
- win32-ps
before_script:
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
- $Env:Path="C:\msys64\$Env:MINGW_PATH\bin;C:\msys64\usr\bin;$Env:Path"
- pacman --noconfirm -Syu
- pacman --noconfirm -S
$Env:MINGW_PACKAGE_PREFIX-cmake
$Env:MINGW_PACKAGE_PREFIX-libiconv
$Env:MINGW_PACKAGE_PREFIX-ninja
$Env:MINGW_PACKAGE_PREFIX-python
$Env:MINGW_PACKAGE_PREFIX-python2
$Env:MINGW_PACKAGE_PREFIX-xz
$Env:MINGW_PACKAGE_PREFIX-zlib
- if (-not (Test-Path 7za.exe)) {
Invoke-WebRequest -Uri https://www.7-zip.org/a/7z1900-extra.7z -OutFile 7z1900-extra.7z ;
cmake -E tar xf 7z1900-extra.7z 7za.exe
}
- if (-not (Test-Path libxml2-build/xmlconf)) {
Invoke-WebRequest -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz -OutFile xmlts20080827.tar.gz ;
.\7za.exe x xmlts20080827.tar.gz -olibxml2-build
}
script:
- cmake -G Ninja -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B libxml2-build
- cmake --build libxml2-build --target install
- New-Item -ItemType Directory libxml2-install\share\libxml2
- Copy-Item Copyright libxml2-install\share\libxml2
- cd libxml2-build
- ctest -VV
after_script:
- .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:MINGW_PACKAGE_PREFIX-$Env:SUFFIX.7z .\libxml2-install\*
cache:
key: "$MINGW_PACKAGE_PREFIX"
paths:
- libxml2-build/xmlconf/
- 7za.exe
artifacts:
paths:
- libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:MINGW_PACKAGE_PREFIX-$Env:SUFFIX.7z
expire_in: 1 day
cmake:mingw:w64-i686:shared:
extends: .cmake:mingw
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
MINGW_PACKAGE_PREFIX: mingw-w64-i686
MINGW_PATH: mingw32
SUFFIX: shared
cmake:mingw:w64-i686:static:
extends: .cmake:mingw
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
MINGW_PACKAGE_PREFIX: mingw-w64-i686
MINGW_PATH: mingw32
SUFFIX: static
cmake:mingw:w64-x86_64:shared:
extends: .cmake:mingw
variables:
BUILD_SHARED_LIBS: "ON"
MINGW_PACKAGE_PREFIX: mingw-w64-x86_64
MINGW_PATH: mingw64
SUFFIX: shared
cmake:mingw:w64-x86_64:static:
extends: .cmake:mingw
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
MINGW_PACKAGE_PREFIX: mingw-w64-x86_64
MINGW_PATH: mingw64
SUFFIX: static
.cmake:msvc:
tags:
- win32-ps
variables:
CMAKE_VERSION: 3.19.4
before_script:
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
- if (-not (Test-Path cmake-$Env:CMAKE_VERSION-win64-x64)) {
Invoke-WebRequest -Uri http://github.com/Kitware/CMake/releases/download/v$Env:CMAKE_VERSION/cmake-$Env:CMAKE_VERSION-win64-x64.zip -OutFile cmake-$Env:CMAKE_VERSION-win64-x64.zip ;
Expand-Archive cmake-$Env:CMAKE_VERSION-win64-x64.zip -DestinationPath .
}
- $Env:Path="$Env:CI_PROJECT_DIR\cmake-$Env:CMAKE_VERSION-win64-x64\bin;$Env:Path"
- if (-not (Test-Path 7za.exe)) {
Invoke-WebRequest -Uri https://www.7-zip.org/a/7z1900-extra.7z -OutFile 7z1900-extra.7z ;
cmake -E tar xf 7z1900-extra.7z 7za.exe
}
- if (-not (Test-Path libxml2-build/xmlconf)) {
Invoke-WebRequest -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz -OutFile xmlts20080827.tar.gz ;
.\7za.exe x xmlts20080827.tar.gz -olibxml2-build
}
script:
- cmake -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=OFF -S . -B libxml2-build
- cmake --build libxml2-build --config Debug --target install
- cmake --build libxml2-build --config Release --target install
- New-Item -ItemType Directory libxml2-install\share\libxml2
- Copy-Item Copyright libxml2-install\share\libxml2
- cd libxml2-build
- ctest -C Debug -VV
- ctest -C Release -VV
after_script:
- .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
cache:
key: "msvc"
paths:
- cmake-$Env:CMAKE_VERSION-win64-x64/
- libxml2-build/xmlconf/
- 7za.exe
artifacts:
paths:
- libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z
expire_in: 1 day
.cmake:msvc:v141:
extends: .cmake:msvc
variables:
CMAKE_GENERATOR: Visual Studio 15 2017
CMAKE_GENERATOR_TOOLSET: v141
.cmake:msvc:v141:x64:
extends: .cmake:msvc:v141
variables:
CMAKE_GENERATOR_PLATFORM: x64
cmake:msvc:v141:x64:shared:
extends: .cmake:msvc:v141:x64
variables:
BUILD_SHARED_LIBS: "ON"
SUFFIX: shared
cmake:msvc:v141:x64:static:
extends: .cmake:msvc:v141:x64
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
SUFFIX: static
.cmake:msvc:v141:x86:
extends: .cmake:msvc:v141
only:
- schedules
variables:
CMAKE_GENERATOR_PLATFORM: Win32
cmake:msvc:v141:x86:shared:
extends: .cmake:msvc:v141:x86
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
SUFFIX: shared
cmake:msvc:v141:x86:static:
extends: .cmake:msvc:v141:x86
variables:
BUILD_SHARED_LIBS: "OFF"
SUFFIX: static

@ -0,0 +1,23 @@
language: c
sudo: false
addons:
apt:
packages:
# Some tests require the DTDs.
w3c-sgml-lib
matrix:
include:
# Try to emulate a C89 compiler on a POSIX system by disabling as many
# GNU extensions as possible.
- compiler: gcc
env: CFLAGS="-O2 -std=c89 -D_XOPEN_SOURCE=700 -Werror -Wno-error=array-bounds"
# clang with AddressSanitizer and UndefinedBehaviorSanitizer.
- compiler: clang
sudo: required
dist: trusty
env: CONFIG="--without-python"
CFLAGS="-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,unsigned-integer-overflow -fno-sanitize-recover=all -Werror -Wno-error=cast-align"
UBSAN_OPTIONS=print_stacktrace=1
script: sh autogen.sh $CONFIG && make -j2 V=1 && make check
git:
depth: 10

@ -0,0 +1,5 @@
Daniel Veillard <daniel@veillard.com>
Bjorn Reese <breese@users.sourceforge.net>
William Brack <wbrack@mmm.com.hk>
Igor Zlatkovic <igor@zlatkovic.com> for the Windows port
Aleksey Sanin <aleksey@aleksey.com>

@ -0,0 +1,765 @@
cmake_minimum_required(VERSION 3.15)
project(libxml2 VERSION 2.9.10 LANGUAGES C)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(LIBXML2_WITH_AUTOMATA ON)
option(LIBXML2_WITH_C14N "Add the Canonicalization support" ON)
option(LIBXML2_WITH_CATALOG "Add the Catalog support" ON)
option(LIBXML2_WITH_DEBUG "Add the debugging module" ON)
option(LIBXML2_WITH_DOCB "Add Docbook SGML support" ON)
set(LIBXML2_WITH_EXPR ON)
option(LIBXML2_WITH_FTP "Add the FTP support" ON)
option(LIBXML2_WITH_HTML "Add the HTML support" ON)
option(LIBXML2_WITH_HTTP "Add the HTTP support" ON)
option(LIBXML2_WITH_ICONV "Add ICONV support" ON)
option(LIBXML2_WITH_ICU "Add ICU support" OFF)
option(LIBXML2_WITH_ISO8859X "Add ISO8859X support if no iconv" ON)
option(LIBXML2_WITH_LEGACY "Add deprecated APIs for compatibility" ON)
option(LIBXML2_WITH_LZMA "Use liblzma" ON)
option(LIBXML2_WITH_MEM_DEBUG "Add the memory debugging module" OFF)
option(LIBXML2_WITH_MODULES "Add the dynamic modules support" ON)
option(LIBXML2_WITH_OUTPUT "Add the serialization support" ON)
option(LIBXML2_WITH_PATTERN "Add the xmlPattern selection interface" ON)
option(LIBXML2_WITH_PROGRAMS "Build programs" ON)
option(LIBXML2_WITH_PUSH "Add the PUSH parser interfaces" ON)
option(LIBXML2_WITH_PYTHON "Build Python bindings" ON)
option(LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON)
option(LIBXML2_WITH_REGEXPS "Add Regular Expressions support" ON)
option(LIBXML2_WITH_RUN_DEBUG "Add the runtime debugging module" OFF)
option(LIBXML2_WITH_SAX1 "Add the older SAX1 interface" ON)
option(LIBXML2_WITH_SCHEMAS "Add Relax-NG and Schemas support" ON)
option(LIBXML2_WITH_SCHEMATRON "Add Schematron support" ON)
option(LIBXML2_WITH_TESTS "Build tests" ON)
option(LIBXML2_WITH_THREADS "Add multithread support" ON)
option(LIBXML2_WITH_THREAD_ALLOC "Add per-thread memory" OFF)
option(LIBXML2_WITH_TREE "Add the DOM like tree manipulation APIs" ON)
set(LIBXML2_WITH_TRIO OFF)
set(LIBXML2_WITH_UNICODE ON)
option(LIBXML2_WITH_VALID "Add the DTD validation support" ON)
option(LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON)
option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON)
option(LIBXML2_WITH_XPATH "Add the XPATH support" ON)
option(LIBXML2_WITH_XPTR "Add the XPointer support" ON)
option(LIBXML2_WITH_ZLIB "Use libz" ON)
set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
if(LIBXML2_WITH_ICONV)
find_package(Iconv REQUIRED)
endif()
if(LIBXML2_WITH_ICU)
find_package(ICU REQUIRED COMPONENTS data i18n uc)
endif()
if(LIBXML2_WITH_LZMA)
find_package(LibLZMA REQUIRED)
endif()
if(LIBXML2_WITH_PYTHON)
check_include_files(unistd.h HAVE_UNISTD_H)
check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
if(HAVE_UNISTD_H AND HAVE_F_GETFL)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
else()
find_package(Python2 COMPONENTS Interpreter Development REQUIRED)
add_library(Python::Python ALIAS Python2::Python)
set(Python_EXECUTABLE ${Python2_EXECUTABLE})
set(Python_SITEARCH ${Python2_SITEARCH})
endif()
set(LIBXML2_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
endif()
if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
endif()
if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif()
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_DOCB WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
else()
set(${VARIABLE} 0)
endif()
endforeach()
set(LIBXML_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set(LIBXML_MINOR_VERSION ${PROJECT_VERSION_MINOR})
set(LIBXML_MICRO_VERSION ${PROJECT_VERSION_PATCH})
set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
set(LIBXML_VERSION ${LIBXML_MAJOR_VERSION}0${LIBXML_MINOR_VERSION}0${LIBXML_MICRO_VERSION})
set(LIBXML_VERSION_STRING "${LIBXML_VERSION}")
set(LIBXML_VERSION_EXTRA "")
set(LIBXML_VERSION_NUMBER ${LIBXML_VERSION})
set(MODULE_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(PACKAGE "libxml2")
set(PACKAGE_BUGREPORT "xml@gnome.org")
set(PACKAGE_NAME "libxml2")
set(PACKAGE_STRING "libxml2 ${VERSION}")
set(PACKAGE_TARNAME "libxml2")
set(PACKAGE_URL "http://www.xmlsoft.org/")
set(PACKAGE_VERSION ${VERSION})
if(LIBLZMA_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES LibLZMA::LibLZMA)
endif()
if(Threads_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
endif()
if(ZLIB_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
endif()
if(MSVC)
configure_file(include/win32config.h config.h COPYONLY)
else()
check_c_source_compiles("
void __attribute__((destructor))
f(void) {}
int main(void) { return 0; }
" ATTRIBUTE_DESTRUCTOR)
check_c_source_compiles("
#include <netdb.h>
int main() { (void) gethostbyname((const char*) \"\"); return 0; }
" GETHOSTBYNAME_ARG_CAST_CONST)
if(NOT GETHOSTBYNAME_ARG_CAST_CONST)
set(GETHOSTBYNAME_ARG_CAST "(char *)")
else()
set(GETHOSTBYNAME_ARG_CAST "/**/")
endif()
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
check_include_files(arpa/nameser.h HAVE_ARPA_NAMESER_H)
check_struct_has_member("struct sockaddr_storage" ss_family "sys/socket.h;sys/types.h" HAVE_SS_FAMILY)
check_struct_has_member("struct sockaddr_storage" __ss_family "sys/socket.h;sys/types.h" HAVE_BROKEN_SS_FAMILY)
if(HAVE_BROKEN_SS_FAMILY)
set(ss_family __ss_family)
endif()
check_function_exists(class HAVE_CLASS)
check_include_files(ctype.h HAVE_CTYPE_H)
check_include_files(dirent.h HAVE_DIRENT_H)
check_include_files(dlfcn.h HAVE_DLFCN_H)
check_library_exists(dl dlopen "" HAVE_DLOPEN)
check_include_files(dl.h HAVE_DL_H)
check_include_files(errno.h HAVE_ERRNO_H)
check_include_files(fcntl.h HAVE_FCNTL_H)
check_function_exists(finite HAVE_FINITE)
check_include_files(float.h HAVE_FLOAT_H)
check_function_exists(fpclass HAVE_FPCLASS)
check_function_exists(fprintf HAVE_FPRINTF)
check_function_exists(fp_class HAVE_FP_CLASS)
check_function_exists(ftime HAVE_FTIME)
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_function_exists(isascii HAVE_ISASCII)
check_function_exists(isinf HAVE_ISINF)
check_function_exists(isnan HAVE_ISNAN)
check_function_exists(isnand HAVE_ISNAND)
check_library_exists(history append_history "" HAVE_LIBHISTORY)
check_library_exists(lzma lzma_code "" HAVE_LIBLZMA)
check_library_exists(pthread pthread_join "" HAVE_LIBPTHREAD)
check_library_exists(readline readline "" HAVE_LIBREADLINE)
check_library_exists(z gzread "" HAVE_LIBZ)
check_include_files(limits.h HAVE_LIMITS_H)
check_function_exists(localtime HAVE_LOCALTIME)
check_include_files(lzma.h HAVE_LZMA_H)
check_include_files(malloc.h HAVE_MALLOC_H)
check_include_files(math.h HAVE_MATH_H)
check_include_files(memory.h HAVE_MEMORY_H)
check_function_exists(mmap HAVE_MMAP)
check_function_exists(munmap HAVE_MUNMAP)
check_symbol_exists(DIR ndir.h HAVE_NDIR_H)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
check_include_files(poll.h HAVE_POLL_H)
check_function_exists(printf HAVE_PRINTF)
check_include_files(pthread.h HAVE_PTHREAD_H)
check_function_exists(putenv HAVE_PUTENV)
check_function_exists(rand HAVE_RAND)
check_function_exists(rand_r HAVE_RAND_R)
check_include_files(resolv.h HAVE_RESOLV_H)
check_library_exists(dld shl_load "" HAVE_SHLLOAD)
check_function_exists(signal HAVE_SIGNAL)
check_include_files(signal.h HAVE_SIGNAL_H)
check_function_exists(snprintf HAVE_SNPRINTF)
check_function_exists(sprintf HAVE_SPRINTF)
check_function_exists(srand HAVE_SRAND)
check_function_exists(sscanf HAVE_SSCANF)
check_function_exists(stat HAVE_STAT)
check_include_files(stdarg.h HAVE_STDARG_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_function_exists(strftime HAVE_STRFTIME)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(string.h HAVE_STRING_H)
check_symbol_exists(DIR sys/dir.h HAVE_SYS_DIR_H)
check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
check_symbol_exists(DIR sys/ndir.h HAVE_SYS_NDIR_H)
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_function_exists(time HAVE_TIME)
check_include_files(time.h HAVE_TIME_H)
check_include_files(unistd.h HAVE_UNISTD_H)
check_function_exists(va_copy HAVE_VA_COPY)
check_function_exists(vfprintf HAVE_VFPRINTF)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(vsprintf HAVE_VSPRINTF)
check_function_exists(__va_copy HAVE___VA_COPY)
check_c_source_compiles("
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
\"C\"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv(iconv_t cd, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft);
#else
size_t iconv();
#endif
int main() { return 0; }
" ICONV_CONST_TEST)
if(NOT ICONV_CONST_TEST)
set(ICONV_CONST "const")
endif()
set(LT_OBJDIR ".libs/")
check_c_source_compiles("
#include <sys/socket.h>
#include <sys/types.h>
int main() { (void) send(1, (const char*) \"\", 1, 1); return 0; }
" SEND_ARG2_CAST_CONST)
if(NOT SEND_ARG2_CAST_CONST)
set(SEND_ARG2_CAST "(char *)")
else()
set(SEND_ARG2_CAST "/**/")
endif()
check_include_files("float.h;stdarg.h;stdlib.h;string.h" STDC_HEADERS)
check_c_source_compiles("
#include <stdarg.h>
void a(va_list* ap) {};
int main() { va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1; return 0; }
" VA_LIST_IS_ARRAY_TEST)
if(VA_LIST_IS_ARRAY_TEST)
set(VA_LIST_IS_ARRAY FALSE)
else()
set(VA_LIST_IS_ARRAY TRUE)
endif()
check_c_source_compiles("
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
int main() { (void) getsockopt(1, 1, 1, NULL, (socklen_t*) NULL); return 0; }
" XML_SOCKLEN_T_SOCKLEN_T)
if(XML_SOCKLEN_T_SOCKLEN_T)
set(XML_SOCKLEN_T socklen_t)
else()
check_c_source_compiles("
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
int main() { (void) getsockopt(1, 1, 1, NULL, (size_t*) NULL); return 0; }
" XML_SOCKLEN_T_SIZE_T)
if(XML_SOCKLEN_T_SIZE_T)
set(XML_SOCKLEN_T size_t)
else()
check_c_source_compiles("
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
int main() { (void) getsockopt (1, 1, 1, NULL, (int*) NULL); return 0; }
" XML_SOCKLEN_T_INT)
set(XML_SOCKLEN_T int)
endif()
endif()
configure_file(config.h.cmake.in config.h)
endif()
set(
LIBXML2_HDRS
include/libxml/c14n.h
include/libxml/catalog.h
include/libxml/chvalid.h
include/libxml/debugXML.h
include/libxml/dict.h
include/libxml/DOCBparser.h
include/libxml/encoding.h
include/libxml/entities.h
include/libxml/globals.h
include/libxml/hash.h
include/libxml/HTMLparser.h
include/libxml/HTMLtree.h
include/libxml/list.h
include/libxml/nanoftp.h
include/libxml/nanohttp.h
include/libxml/parser.h
include/libxml/parserInternals.h
include/libxml/pattern.h
include/libxml/relaxng.h
include/libxml/SAX.h
include/libxml/SAX2.h
include/libxml/schemasInternals.h
include/libxml/schematron.h
include/libxml/threads.h
include/libxml/tree.h
include/libxml/uri.h
include/libxml/valid.h
include/libxml/xinclude.h
include/libxml/xlink.h
include/libxml/xmlIO.h
include/libxml/xmlautomata.h
include/libxml/xmlerror.h
include/libxml/xmlexports.h
include/libxml/xmlmemory.h
include/libxml/xmlmodule.h
include/libxml/xmlreader.h
include/libxml/xmlregexp.h
include/libxml/xmlsave.h
include/libxml/xmlschemas.h
include/libxml/xmlschemastypes.h
include/libxml/xmlstring.h
include/libxml/xmlunicode.h
include/libxml/xmlwriter.h
include/libxml/xpath.h
include/libxml/xpathInternals.h
include/libxml/xpointer.h
)
set(
LIBXML2_SRCS
buf.c
c14n.c
catalog.c
chvalid.c
debugXML.c
dict.c
encoding.c
entities.c
error.c
globals.c
hash.c
HTMLparser.c
HTMLtree.c
legacy.c
list.c
nanoftp.c
nanohttp.c
parser.c
parserInternals.c
pattern.c
relaxng.c
SAX.c
SAX2.c
schematron.c
threads.c
tree.c
uri.c
valid.c
xinclude.c
xlink.c
xmlIO.c
xmlmemory.c
xmlmodule.c
xmlreader.c
xmlregexp.c
xmlsave.c
xmlschemas.c
xmlschemastypes.c
xmlstring.c
xmlunicode.c
xmlwriter.c
xpath.c
xpointer.c
xzlib.c
)
if(WIN32)
list(APPEND LIBXML2_SRCS win32/libxml2.rc)
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/rcVersion.h
"#define LIBXML_MAJOR_VERSION ${LIBXML_MAJOR_VERSION}\n"
"#define LIBXML_MINOR_VERSION ${LIBXML_MINOR_VERSION}\n"
"#define LIBXML_MICRO_VERSION ${LIBXML_MICRO_VERSION}\n"
"#define LIBXML_DOTTED_VERSION \"${VERSION}\"\n"
)
endif()
if(LIBXML2_WITH_SAX1)
list(APPEND LIBXML2_SRCS DOCBparser.c)
endif()
if(LIBXML2_WITH_TRIO)
list(APPEND LIBXML2_SRCS trio.c triostr.c)
endif()
add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS})
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC)
set(XML_CFLAGS "-DLIBXML_STATIC")
endif()
if(LIBXML2_WITH_THREADS)
target_compile_definitions(LibXml2 PRIVATE _REENTRANT)
if(WIN32)
target_compile_definitions(LibXml2 PRIVATE HAVE_WIN32_THREADS)
endif()
endif()
target_include_directories(
LibXml2
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/libxml2>
)
if(HAVE_DLOPEN)
target_link_libraries(LibXml2 PRIVATE dl)
set(MODULE_PLATFORM_LIBS "-ldl")
endif()
if(HAVE_SHLLOAD)
target_link_libraries(LibXml2 PRIVATE dld)
set(MODULE_PLATFORM_LIBS "-ldld")
endif()
if(UNIX)
target_link_libraries(LibXml2 PRIVATE m)
set(M_LIBS "-lm")
endif()
if(WIN32)
target_link_libraries(LibXml2 PRIVATE ws2_32)
set(WIN32_EXTRA_LIBADD "-lws2_32")
endif()
if(LIBXML2_WITH_ICONV)
target_link_libraries(LibXml2 PUBLIC Iconv::Iconv)
if(NOT Iconv_IS_BUILT_IN)
set(ICONV_LIBS "-liconv")
endif()
endif()
if(LIBXML2_WITH_ICU)
target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
if(WIN32)
set(ICU_LIBS "-licudt -licuin -licuuc")
else()
set(ICU_LIBS "-licudata -licui18n -licuuc")
endif()
endif()
if(LIBXML2_WITH_LZMA)
target_link_libraries(LibXml2 PRIVATE LibLZMA::LibLZMA)
set(LZMA_LIBS "-llzma")
endif()
if(LIBXML2_WITH_THREADS)
target_link_libraries(LibXml2 PRIVATE Threads::Threads)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif()
if(LIBXML2_WITH_ZLIB)
target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
set(Z_LIBS "-lz")
endif()
set_target_properties(
LibXml2
PROPERTIES
IMPORT_PREFIX lib
OUTPUT_NAME xml2
POSITION_INDEPENDENT_CODE ON
PREFIX lib
VERSION ${PROJECT_VERSION}
)
if(MSVC)
if(BUILD_SHARED_LIBS)
set_target_properties(
LibXml2
PROPERTIES
DEBUG_POSTFIX d
)
else()
set_target_properties(
LibXml2
PROPERTIES
DEBUG_POSTFIX sd
MINSIZEREL_POSTFIX s
RELEASE_POSTFIX s
RELWITHDEBINFO_POSTFIX s
)
endif()
endif()
install(FILES ${LIBXML2_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
install(
TARGETS LibXml2
EXPORT LibXml2
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
if(MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:LibXml2> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
endif()
if(LIBXML2_WITH_PROGRAMS)
set(
PROGRAMS
xmlcatalog
xmllint
)
foreach(PROGRAM ${PROGRAMS})
add_executable(${PROGRAM} ${PROGRAM}.c)
target_link_libraries(${PROGRAM} LibXml2)
if(HAVE_LIBHISTORY)
target_link_libraries(${PROGRAM} history)
endif()
if(HAVE_LIBREADLINE)
target_link_libraries(${PROGRAM} readline)
endif()
install(TARGETS ${PROGRAM} EXPORT LibXml2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
endforeach()
endif()
if(LIBXML2_WITH_TESTS)
enable_testing()
set(
TESTS
runxmlconf
runsuite
testapi
testAutomata
testC14N
testchar
testdict
testHTML
testModule
testlimits
testReader
testrecurse
testRegexp
testRelax
testSAX
testSchemas
testURI
testXPath
)
foreach(TEST ${TESTS})
add_executable(${TEST} ${TEST}.c)
target_link_libraries(${TEST} LibXml2)
endforeach()
if(EXISTS ${LIBXML2_XMLCONF_WORKING_DIR}/xmlconf/xmlconf.xml)
add_test(NAME runxmlconf COMMAND runxmlconf WORKING_DIRECTORY ${LIBXML2_XMLCONF_WORKING_DIR})
endif()
if(NOT WIN32)
add_test(NAME testapi COMMAND testapi)
endif()
add_test(NAME testchar COMMAND testchar)
add_test(NAME testdict COMMAND testdict)
add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(Threads_FOUND)
set(
TESTS_THREADS
runtest
testThreads
)
foreach(TEST ${TESTS_THREADS})
add_executable(${TEST} ${TEST}.c)
if(WIN32)
target_compile_definitions(${TEST} PRIVATE HAVE_WIN32_THREADS)
endif()
target_link_libraries(${TEST} LibXml2 Threads::Threads)
endforeach()
add_test(NAME runtest COMMAND runtest --out ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME testThreads COMMAND testThreads WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endif()
if(LIBXML2_WITH_PYTHON)
execute_process(
COMMAND
${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/python/generator.py
${CMAKE_CURRENT_SOURCE_DIR}/doc/libxml2-api.xml
${CMAKE_CURRENT_SOURCE_DIR}/python/libxml2-python-api.xml
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
)
file(READ python/libxml.py LIBXML_PY)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in "${LIBXML_PY}")
file(READ ${CMAKE_CURRENT_BINARY_DIR}/libxml2class.py LIBXML2CLASS_PY)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in "${LIBXML2CLASS_PY}")
configure_file(${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in libxml2.py COPYONLY)
add_library(
LibXml2Mod
libxml2-py.c
libxml2-py.h
python/libxml.c
python/libxml_wrap.h
python/types.c
)
target_include_directories(
LibXml2Mod
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/python>
)
target_link_libraries(LibXml2Mod LibXml2 Python::Python)
set_target_properties(
LibXml2Mod
PROPERTIES
IMPORT_PREFIX lib
OUTPUT_NAME xml2mod
PREFIX lib
VERSION ${PROJECT_VERSION}
)
install(
TARGETS LibXml2Mod
ARCHIVE DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT development
LIBRARY DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime NAMELINK_COMPONENT development
RUNTIME DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime
)
if(MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:LibXml2Mod> DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
endif()
install(FILES python/drv_libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
endif()
install(FILES libxml.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 COMPONENT documentation)
install(FILES doc/xmlcatalog.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
install(FILES doc/xmllint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2 COMPONENT documentation PATTERN Makefile.* EXCLUDE)
configure_package_config_file(
libxml2-config.cmake.cmake.in libxml2-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
COMPONENT development
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
COMPONENT development
)
install(
EXPORT LibXml2
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
NAMESPACE LibXml2::
FILE libxml2-export.cmake
COMPONENT development
)
configure_file(include/libxml/xmlversion.h.in libxml/xmlversion.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
if(MSVC)
configure_file(include/libxml/xmlwin32version.h.in libxml/xmlwin32version.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlwin32version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
endif()
if(LIBXML2_WITH_PYTHON)
set(prefix "${CMAKE_INSTALL_PREFIX}")
configure_file(python/setup.py.in setup.py @ONLY)
endif()
set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
set(XML_LIBDIR "-L\${libdir}")
set(XML_LIBS "-lxml2")
set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${M_LIBS}")
file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
set(prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}")
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development)
set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..")
configure_file(xml2-config.in xml2-config @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xml2-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development)
set(XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2")
set(XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}")
configure_file(xml2Conf.sh.in xml2Conf.sh @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml2Conf.sh DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development)
set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime)
set(CPACK_COMPONENT_PROGRAMS_DEPENDS runtime)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${PACKAGE_TARNAME}-dev")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PACKAGE_URL})
set(CPACK_DEBIAN_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_NAME "${PACKAGE_TARNAME}-utils")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "${PACKAGE_TARNAME}-utils")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs")
set(CPACK_NSIS_PACKAGE_NAME ${PACKAGE_STRING})
set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_URL})
set(CPACK_PACKAGE_CONTACT ${PACKAGE_BUGREPORT})
set(CPACK_PACKAGE_DISPLAY_NAME ${PACKAGE_STRING})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_TARNAME}-${PACKAGE_VERSION}")
set(CPACK_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBXML_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LIBXML_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LIBXML_MICRO_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/Copyright)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_development_PACKAGE_NAME "${PACKAGE_NAME}-devel")
set(CPACK_RPM_development_PACKAGE_REQUIRES "${PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_RPM_PACKAGE_URL ${PACKAGE_URL})
set(CPACK_RPM_programs_PACKAGE_NAME "${PACKAGE_NAME}-utils")
set(CPACK_RPM_programs_PACKAGE_REQUIRES "${PACKAGE_NAME}")
set(CPACK_RPM_runtime_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_RPM_runtime_PACKAGE_SUGGESTS "${PACKAGE_NAME}-utils")
include(CPack)

@ -0,0 +1,20 @@
The current version of the code can be found in the GNOME Git Repository:
https://gitlab.gnome.org/GNOME/libxml2
There's mirror on GitHub:
https://github.com/GNOME/libxml2
Start discussions and send patches to the mailing list, or file a bug and
add a patch as attachment.
https://mail.gnome.org/mailman/listinfo/xml
https://gitlab.gnome.org/GNOME/libxml2/issues
Format patches with git-format-patch and use plain text attachments
if possible.
All code must conform to C89 and pass the "make check" tests. Avoid
compiler warnings and add regression tests if possible.

@ -0,0 +1,23 @@
Except where otherwise noted in the source code (e.g. the files hash.c,
list.c and the trio files, which are covered by a similar licence but
with different Copyright notices) all the files are:
Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is fur-
nished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@ -0,0 +1,305 @@
/*
* DOCBparser.c : an attempt to parse SGML Docbook documents
*
* This is deprecated !!!
* Code removed with release 2.6.0 it was broken.
* The doc are expect to be migrated to XML DocBook
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#define IN_LIBXML
#include "libxml.h"
#ifdef LIBXML_DOCB_ENABLED
#include <libxml/xmlerror.h>
#include <libxml/DOCBparser.h>
/**
* docbEncodeEntities:
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of UTF-8 chars
* @inlen: the length of @in
* @quoteChar: the quote character to escape (' or ") or zero.
*
* Take a block of UTF-8 chars in and try to convert it to an ASCII
* plus SGML entities block of chars out.
*
* Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
* The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed.
*/
int
docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
int *outlen ATTRIBUTE_UNUSED,
const unsigned char *in ATTRIBUTE_UNUSED,
int *inlen ATTRIBUTE_UNUSED,
int quoteChar ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbEncodeEntities() deprecated function reached\n");
deprecated = 1;
}
return(-1);
}
/**
* docbParseDocument:
* @ctxt: an SGML parser context
*
* parse an SGML document (and build a tree if using the standard SAX
* interface).
*
* Returns 0, -1 in case of error. the parser context is augmented
* as a result of the parsing.
*/
int
docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseDocument() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseDocument(ctxt));
}
/**
* docbFreeParserCtxt:
* @ctxt: an SGML parser context
*
* Free all the memory used by a parser context. However the parsed
* document in ctxt->myDoc is not freed.
*/
void
docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbFreeParserCtxt() deprecated function reached\n");
deprecated = 1;
}
xmlFreeParserCtxt(ctxt);
}
/**
* docbParseChunk:
* @ctxt: an XML parser context
* @chunk: an char array
* @size: the size in byte of the chunk
* @terminate: last chunk indicator
*
* Parse a Chunk of memory
*
* Returns zero if no error, the xmlParserErrors otherwise.
*/
int
docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
const char *chunk ATTRIBUTE_UNUSED,
int size ATTRIBUTE_UNUSED,
int terminate ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseChunk(ctxt, chunk, size, terminate));
}
/**
* docbCreatePushParserCtxt:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
* @chunk: a pointer to an array of chars
* @size: number of chars in the array
* @filename: an optional file name or URI
* @enc: an optional encoding
*
* Create a parser context for using the DocBook SGML parser in push mode
* To allow content encoding detection, @size should be >= 4
* The value of @filename is used for fetching external entities
* and error/warning reports.
*
* Returns the new parser context or NULL
*/
docbParserCtxtPtr
docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *user_data ATTRIBUTE_UNUSED,
const char *chunk ATTRIBUTE_UNUSED,
int size ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
xmlCharEncoding enc ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));
}
/**
* docbSAXParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
docbDocPtr
docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED,
docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *userData ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlSAXParseMemoryWithData(sax, (const char *)cur,
xmlStrlen((const xmlChar *) cur), 0, userData));
}
/**
* docbParseDoc:
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the SGML document encoding, or NULL
*
* parse an SGML in-memory document and build a tree.
*
* Returns the resulting document tree
*/
docbDocPtr
docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseChunk() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseDoc(cur));
}
/**
* docbCreateFileParserCtxt:
* @filename: the filename
* @encoding: the SGML document encoding, or NULL
*
* Create a parser context for a file content.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
*
* Returns the new parser context or NULL
*/
docbParserCtxtPtr
docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbCreateFileParserCtxt() deprecated function reached\n");
deprecated = 1;
}
return (xmlCreateFileParserCtxt(filename));
}
/**
* docbSAXParseFile:
* @filename: the filename
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
* @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
*
* Returns the resulting document tree
*/
docbDocPtr
docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED,
docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
void *userData ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbSAXParseFile() deprecated function reached\n");
deprecated = 1;
}
return (xmlSAXParseFileWithData(sax, filename, 0, userData));
}
/**
* docbParseFile:
* @filename: the filename
* @encoding: a free form C string describing document encoding, or NULL
*
* parse a Docbook SGML file and build a tree. Automatic support for
* ZLIB/Compress compressed document is provided by default if found
* at compile-time.
*
* Returns the resulting document tree
*/
docbDocPtr
docbParseFile(const char *filename ATTRIBUTE_UNUSED,
const char *encoding ATTRIBUTE_UNUSED)
{
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"docbParseFile() deprecated function reached\n");
deprecated = 1;
}
return (xmlParseFile(filename));
}
#define bottom_DOCBparser
#include "elfgcchack.h"
#endif /* LIBXML_DOCB_ENABLED */

@ -0,0 +1,51 @@
See also the generic INSTALL file for configure options
Compilation
1. What is the process to compile libxml?
As most UNIX libraries libxml follows the "standard":
gunzip -c xxx.tar.gz | tar xvf -
cd libxml-xxxx
./configure --help
to see the options, then the compilation/installation proper
./configure [possible options]
make
make install
At that point you may have to rerun ldconfig or similar utility to
update your list of installed shared libs.
At this point you can check that the library is properly functioning
by running
make check
Please report test failures to the mailing list or bug tracker.
2. What other libraries are needed to compile/install libxml?
Libxml does not require any other libraries. A platform with somewhat
recent POSIX support should be sufficient (please report any violation
to this rule you may find).
However if found at configuration time, libxml will detect and use
the following libs:
libz: a highly portable and widely available compression library
https://zlib.net/
liblzma: another compression library
https://tukaani.org/xz/
iconv: a powerful character encoding conversion library. It's
part of POSIX.1-2001, so it doesn't need to be installed
on modern UNIX-like systems, specifically on Linux.
https://www.gnu.org/software/libiconv/
ICU: Mainly used by Chromium on Windows. Unnecessary on most
systems.
Daniel
veillard@redhat.com

@ -0,0 +1,9 @@
See first http://xmlsoft.org/bugs.html and use the list please.
Daniel Veillard
E-mail: veillard@redhat.com
Userid: veillard
Co-maintainer: William Brack <wbrack@mmm.com.hk>
Windows port: Igor Zlatkovic <igor@zlatkovic.com>
Rob Richards <rrichards@ctindustries.net>

@ -0,0 +1,41 @@
#
# You may have to adjust to call the right compiler, or other options
# for compiling and linking
#
CFLAGS=`xml2-config --cflags`
LIBS=`xml2-config --libs`
THREADLIB= -lpthread
EXEEXT=
all: runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT) testchar$(EXEEXT)
clean:
$(RM) runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT)
check: do_runtest do_testchar do_testapi do_runsuite
runtest$(EXEEXT): runtest.c
$(CC) -o runtest$(EXEEXT) $(CFLAGS) runtest.c $(LIBS) $(THREADLIB)
do_runtest: runtest$(EXEEXT)
./runtest
runsuite$(EXEEXT): runsuite.c
$(CC) -o runsuite$(EXEEXT) $(CFLAGS) runsuite.c $(LIBS)
do_runsuite: runsuite$(EXEEXT)
./runsuite
testapi$(EXEEXT): testapi.c
$(CC) -o testapi$(EXEEXT) $(CFLAGS) testapi.c $(LIBS)
do_testapi: testapi$(EXEEXT)
./testapi
testchar$(EXEEXT): testchar.c
$(CC) -o testchar$(EXEEXT) $(CFLAGS) testchar.c $(LIBS)
do_testchar: testchar$(EXEEXT)
./testchar

@ -0,0 +1,34 @@
# This is a makefile for win32 systems (VC 5.0).
# Christopher Blizzard
# http://odin.appliedtheory.com/
CC = cl
CFLAGS = /c /GB /Gi /nologo /I. /DWIN32 /MT /Zi
LD = link
LDFLAGS = /DEBUG /NODEFAULTLIB:libc
AR = lib
all: xml.lib
test: tester.exe
SHARED_OBJS = entities.obj parser.obj tree.obj SAX.obj
xml.lib: $(SHARED_OBJS)
$(AR) /out:xml.lib $(SHARED_OBJS)
tester.obj: $(SHARED_OBJS)
$(CC) $(CFLAGS) tester.c /out:tester.obj
tester.exe: tester.obj xml.lib
$(LD) $(LDFLAGS) /out:tester.exe tester.obj xml.lib
clean:
-del /f $(SHARED_OBJS) tester.obj
-del /f tester.exe
-del /f xml.lib
-del /f *.pdb
-del /f *.idb
-del /f *.ilk

@ -0,0 +1,40 @@
XML toolkit from the GNOME project
Full documentation is available on-line at
http://xmlsoft.org/
This code is released under the MIT Licence see the Copyright file.
To build on an Unixised setup:
./configure ; make ; make install
if the ./configure file does not exist, run ./autogen.sh instead.
To build on Windows:
see instructions on win32/Readme.txt
To assert build quality:
on an Unixised setup:
run make tests
otherwise:
There is 3 standalone tools runtest.c runsuite.c testapi.c, which
should compile as part of the build or as any application would.
Launch them from this directory to get results, runtest checks
the proper functioning of libxml2 main APIs while testapi does
a full coverage check. Report failures to the list.
To report bugs, follow the instructions at:
http://xmlsoft.org/bugs.html
A mailing-list xml@gnome.org is available, to subscribe:
http://mail.gnome.org/mailman/listinfo/xml
The list archive is at:
http://mail.gnome.org/archives/xml/
All technical answers asked privately will be automatically answered on
the list and archived for public access unless privacy is explicitly
required and justified.
Daniel Veillard
$Id$

@ -0,0 +1,5 @@
Please read the CONTRIBUTING file for instructions
Daniel
$Id$

@ -0,0 +1,39 @@
README.tests
Instructions for standalone test regressions of libxml2
libxml2-tests-$version.tar.gz contains 3 standalone C programs as well
as a large amount of tests and results coming from libxml2 itself and
from W3C, NIST, Sun Microsystems, Microsoft and James Clark. Each C
program has a different testing purpose:
runtest.c : runs libxml2 basic internal regression tests
runsuite.c: runs libxml2 against external regression tests
testapi.c : exercises the library public entry points
testchar.c: exercise the check of character ranges and UTF-8 validation
The command:
make check
or
make -f Makefile.tests check
should be sufficient on an Unix system to build and exercise the tests
for the version of the library installed on the system. Note however
that there isn't backward compatibility provided so if the installed
version is older than the testsuite one, failing to compile or run the tests
is likely. In any event this won't work with an installed libxml2 older
than 2.6.20.
Building on other platforms should be a matter of compiling the C files
like any other program using libxml2, running the test should be done
simply by launching the resulting executables.
Also note the availability of a "make valgrind" target which will run the
above tests under valgrind to check for memory errors (but this relies
on the availability of the valgrind command and take far more time to
complete).
Daniel Veillard
Mon May 7 2012

@ -0,0 +1,212 @@
Notes for compiling on zOS:
- since testapi.c file is huge (over 52000 lines), it's compilation
fails: I skipped the problem by removing all references to testapi in the
Makefile.in, but it would be neater if one can build without test files
(I didn't find an option in configure...)
- since the name of files (or qualifier) in PDS are limited to 8 I had to
rename xmlschemas.c and xmlschemastypes.c in (resp.) xmlsche.c xmlschet.c
(and I had to modify all occurrences of these files accordingly in the
rest of the Makefile !!!).
- in order to copy objects to PDS, I had the cp command at line 860
of Makefile.in
libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES)
$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
# Copy objects to PDS
@list='$(libxml2_OBJECTS)' ; for p in $$list; do \
cp -ACMv $$p "//'<PDS NAME>'"; \
done
with <PDS NAME> stands for the name of my PDS and
libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
xmlsche.o xmlschet.o xmlunicode.o \
xmlreader.o relaxng.o dict.o SAX2.o \
xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
xmlmodule.o schematron.o xzlib.o
In order to handle the support of zOS without breaking the existing
Makefile maybe a new option/flag zOs would copy xmlschemas.c and
xmlschemastypes.c files and use specifics targets rather than existing
ones with the longer names... A variable to handle the PDS name has to
be provided also...
See patch below for set of changes to Makefile.in
Stéphane Michaut <smichaut@axway.com>
July 2017
--- Makefile.in 2017-08-01 08:17:15.000000000 +0200
+++ Makefile-new.in 2017-08-01 08:07:26.000000000 +0200
@@ -41,7 +41,7 @@
testSAX$(EXEEXT) testHTML$(EXEEXT) testXPath$(EXEEXT) \
testURI$(EXEEXT) testThreads$(EXEEXT) testC14N$(EXEEXT) \
testAutomata$(EXEEXT) testRegexp$(EXEEXT) testReader$(EXEEXT) \
- testapi$(EXEEXT) testModule$(EXEEXT) runtest$(EXEEXT) \
+ testModule$(EXEEXT) runtest$(EXEEXT) \
runsuite$(EXEEXT) testchar$(EXEEXT) testdict$(EXEEXT) \
runxmlconf$(EXEEXT) testrecurse$(EXEEXT) testlimits$(EXEEXT)
bin_PROGRAMS = xmllint$(EXEEXT) xmlcatalog$(EXEEXT)
@@ -106,6 +106,7 @@
debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c \
DOCBparser.c catalog.c globals.c threads.c c14n.c xmlstring.c \
buf.c xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
+ xmlsche.c xmlschet.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c xmlmodule.c \
schematron.c xzlib.c
@@ -118,10 +119,24 @@
nanohttp.lo nanoftp.lo $(am__objects_1) catalog.lo globals.lo \
threads.lo c14n.lo xmlstring.lo buf.lo xmlregexp.lo \
xmlschemas.lo xmlschemastypes.lo xmlunicode.lo \
+ xmlsche.lo xmlschet.lo \
$(am__objects_2) xmlreader.lo relaxng.lo dict.lo SAX2.lo \
xmlwriter.lo legacy.lo chvalid.lo pattern.lo xmlsave.lo \
xmlmodule.lo schematron.lo xzlib.lo
libxml2_la_OBJECTS = $(am_libxml2_la_OBJECTS)
+
+libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
+ parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
+ xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
+ HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
+ nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
+ threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
+ xmlschemas.o xmlschemastypes.o xmlunicode.o \
+ xmlsche.o xmlschemast.o \
+ xmlreader.o relaxng.o dict.o SAX2.o \
+ xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
+ xmlmodule.o schematron.o xzlib.o
+
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
@@ -216,11 +231,6 @@
testXPath_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(testXPath_LDFLAGS) $(LDFLAGS) -o $@
-am_testapi_OBJECTS = testapi.$(OBJEXT)
-testapi_OBJECTS = $(am_testapi_OBJECTS)
-testapi_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(testapi_LDFLAGS) $(LDFLAGS) -o $@
am_testchar_OBJECTS = testchar.$(OBJEXT)
testchar_OBJECTS = $(am_testchar_OBJECTS)
testchar_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -285,7 +295,7 @@
$(testReader_SOURCES) $(testRegexp_SOURCES) \
$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
$(testThreads_SOURCES) $(testURI_SOURCES) $(testXPath_SOURCES) \
- $(testapi_SOURCES) $(testchar_SOURCES) $(testdict_SOURCES) \
+ $(testchar_SOURCES) $(testdict_SOURCES) \
$(testlimits_SOURCES) $(testrecurse_SOURCES) \
$(xmlcatalog_SOURCES) $(xmllint_SOURCES)
DIST_SOURCES = $(am__libxml2_la_SOURCES_DIST) $(testdso_la_SOURCES) \
@@ -295,7 +305,7 @@
$(testReader_SOURCES) $(testRegexp_SOURCES) \
$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
$(am__testThreads_SOURCES_DIST) $(testURI_SOURCES) \
- $(testXPath_SOURCES) $(testapi_SOURCES) $(testchar_SOURCES) \
+ $(testXPath_SOURCES) $(testchar_SOURCES) \
$(testdict_SOURCES) $(testlimits_SOURCES) \
$(testrecurse_SOURCES) $(xmlcatalog_SOURCES) \
$(xmllint_SOURCES)
@@ -700,11 +710,6 @@
noinst_LTLIBRARIES = testdso.la
testdso_la_SOURCES = testdso.c
testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir)
-BUILT_SOURCES = testapi.c
-testapi_SOURCES = testapi.c
-testapi_LDFLAGS =
-testapi_DEPENDENCIES = $(DEPS)
-testapi_LDADD = $(LDADDS)
runxmlconf_SOURCES = runxmlconf.c
runxmlconf_LDFLAGS =
runxmlconf_DEPENDENCIES = $(DEPS)
@@ -854,6 +859,12 @@
done
libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES)
$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
+ # Copie des obj
+ @list='$(libxml2_OBJECTS)' ; for p in $$list; do \
+ echo "copy to PDS: $$p"; \
+ cp -ACMv $$p "//'A009153.XRDEV230.FIC.OBJLIB.LIBXML'"; \
+ done
+
testdso.la: $(testdso_la_OBJECTS) $(testdso_la_DEPENDENCIES)
$(AM_V_CCLD)$(testdso_la_LINK) $(testdso_la_OBJECTS) $(testdso_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@@ -953,9 +964,6 @@
testXPath$(EXEEXT): $(testXPath_OBJECTS) $(testXPath_DEPENDENCIES)
@rm -f testXPath$(EXEEXT)
$(AM_V_CCLD)$(testXPath_LINK) $(testXPath_OBJECTS) $(testXPath_LDADD) $(LIBS)
-testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES)
- @rm -f testapi$(EXEEXT)
- $(AM_V_CCLD)$(testapi_LINK) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS)
testchar$(EXEEXT): $(testchar_OBJECTS) $(testchar_DEPENDENCIES)
@rm -f testchar$(EXEEXT)
$(AM_V_CCLD)$(testchar_LINK) $(testchar_OBJECTS) $(testchar_LDADD) $(LIBS)
@@ -1056,7 +1064,6 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testThreadsWin32.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testURI.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testXPath.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testchar.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdict.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdso.Plo@am__quote@
@@ -1755,18 +1762,6 @@
uninstall-local uninstall-m4dataDATA uninstall-man \
uninstall-man1 uninstall-man3 uninstall-pkgconfigDATA
-
-# that one forces the rebuild when "make rebuild" is run on doc/
-rebuild_testapi:
- -@(if [ "$(PYTHON)" != "" ] ; then \
- $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
-
-# that one is just to make sure it is rebuilt if missing
-# but adding the dependances generate mess
-testapi.c: $(srcdir)/gentest.py
- -@(if [ "$(PYTHON)" != "" ] ; then \
- $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
-
#testOOM_SOURCES=testOOM.c testOOMlib.h testOOMlib.c
#testOOM_LDFLAGS =
#testOOM_DEPENDENCIES = $(DEPS)
@@ -1775,7 +1770,7 @@
runtests:
[ -d test ] || $(LN_S) $(srcdir)/test .
[ -d result ] || $(LN_S) $(srcdir)/result .
- $(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
+ $(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
$(MAKE) tests ; fi)
@@ -1797,10 +1792,6 @@
$(MAKE) tests ; fi)
@(cd doc/examples ; $(MAKE) tests)
-APItests: testapi$(EXEEXT)
- @echo "## Running the API regression tests this may take a little while"
- -@($(CHECKER) $(top_builddir)/testapi -q)
-
HTMLtests : testHTML$(EXEEXT)
@(echo > .memdump)
@echo "## HTML regression tests"
@@ -2746,7 +2737,7 @@
dist-test: distdir
(mkdir -p $(distdir))
(cd $(srcdir) ; tar -cf - --exclude CVS --exclude .svn --exclude .git xstc/Tests) | (cd $(distdir); tar xf -)
- tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/testapi.c $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
+ tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
@(rm -rf $(distdir)/xstc/Test)
cleantar:

@ -0,0 +1,180 @@
/*
* SAX.c : Old SAX v1 handlers to build a tree.
* Deprecated except for compatibility
*
* See Copyright for the status of this software.
*
* Daniel Veillard <daniel@veillard.com>
*/
#define IN_LIBXML
#include "libxml.h"
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/SAX.h>
#include <libxml/uri.h>
#include <libxml/valid.h>
#include <libxml/HTMLtree.h>
#include <libxml/globals.h>
#include <libxml/SAX2.h>
#ifdef LIBXML_LEGACY_ENABLED
#ifdef LIBXML_SAX1_ENABLED
/**
* initxmlDefaultSAXHandler:
* @hdlr: the SAX handler
* @warning: flag if non-zero sets the handler warning procedure
*
* Initialize the default XML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
*/
void
initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = xmlSAX2ExternalSubset;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = xmlSAX2AttributeDecl;
hdlr->elementDecl = xmlSAX2ElementDecl;
hdlr->notationDecl = xmlSAX2NotationDecl;
hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2Characters;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
if (warning == 0)
hdlr->warning = NULL;
else
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#ifdef LIBXML_HTML_ENABLED
/**
* inithtmlDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default HTML SAX version 1 handler
* DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
*/
void
inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = NULL;
hdlr->hasInternalSubset = NULL;
hdlr->hasExternalSubset = NULL;
hdlr->resolveEntity = NULL;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = NULL;
hdlr->attributeDecl = NULL;
hdlr->elementDecl = NULL;
hdlr->notationDecl = NULL;
hdlr->unparsedEntityDecl = NULL;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = NULL;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = xmlSAX2CDataBlock;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#endif /* LIBXML_HTML_ENABLED */
#ifdef LIBXML_DOCB_ENABLED
/**
* initdocbDefaultSAXHandler:
* @hdlr: the SAX handler
*
* Initialize the default DocBook SAX version 1 handler
* DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
*/
void
initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
{
if(hdlr->initialized == 1)
return;
hdlr->internalSubset = xmlSAX2InternalSubset;
hdlr->externalSubset = NULL;
hdlr->isStandalone = xmlSAX2IsStandalone;
hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
hdlr->resolveEntity = xmlSAX2ResolveEntity;
hdlr->getEntity = xmlSAX2GetEntity;
hdlr->getParameterEntity = NULL;
hdlr->entityDecl = xmlSAX2EntityDecl;
hdlr->attributeDecl = NULL;
hdlr->elementDecl = NULL;
hdlr->notationDecl = NULL;
hdlr->unparsedEntityDecl = NULL;
hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
hdlr->startDocument = xmlSAX2StartDocument;
hdlr->endDocument = xmlSAX2EndDocument;
hdlr->startElement = xmlSAX2StartElement;
hdlr->endElement = xmlSAX2EndElement;
hdlr->reference = xmlSAX2Reference;
hdlr->characters = xmlSAX2Characters;
hdlr->cdataBlock = NULL;
hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
hdlr->processingInstruction = NULL;
hdlr->comment = xmlSAX2Comment;
hdlr->warning = xmlParserWarning;
hdlr->error = xmlParserError;
hdlr->fatalError = xmlParserError;
hdlr->initialized = 1;
}
#endif /* LIBXML_DOCB_ENABLED */
#endif /* LIBXML_SAX1_ENABLED */
#define bottom_SAX
#include "elfgcchack.h"
#endif /* LIBXML_LEGACY_ENABLED */

@ -0,0 +1,278 @@
124907 HTML parse buffer problem when parsing larse in-memory docs
124110 DTD validation && wrong namespace
123564 xmllint --html --format
TODO for the XML parser and stuff:
==================================
$Id$
this tend to be outdated :-\ ...
DOCS:
=====
- use case of using XInclude to load for example a description.
order document + product base -(XSLT)-> quote with XIncludes
|
HTML output with description of parts <---(XSLT)--
TODO:
=====
- XInclude at the SAX level (libSRVG)
- fix the C code prototype to bring back doc/libxml-undocumented.txt
to a reasonable level
- Computation of base when HTTP redirect occurs, might affect HTTP
interfaces.
- Computation of base in XInclude. Relativization of URIs.
- listing all attributes in a node.
- Better checking of external parsed entities TAG 1234
- Go through erratas and do the cleanup.
http://www.w3.org/XML/xml-19980210-errata ... started ...
- jamesh suggestion: SAX like functions to save a document ie. call a
function to open a new element with given attributes, write character
data, close last element, etc
+ inversted SAX, initial patch in April 2002 archives.
- htmlParseDoc has parameter encoding which is not used.
Function htmlCreateDocParserCtxt ignore it.
- fix realloc() usage.
- Stricten the UTF8 conformance (Martin Duerst):
http://www.w3.org/2001/06/utf-8-test/.
The bad files are in http://www.w3.org/2001/06/utf-8-wrong/.
- xml:id normalized value
TODO:
=====
- move all string manipulation functions (xmlStrdup, xmlStrlen, etc.) to
global.c. Bjorn noted that the following files depends on parser.o solely
because of these string functions: entities.o, global.o, hash.o, tree.o,
xmlIO.o, and xpath.o.
- Optimization of tag strings allocation ?
- maintain coherency of namespace when doing cut'n paste operations
=> the functions are coded, but need testing
- function to rebuild the ID table
- functions to rebuild the DTD hash tables (after DTD changes).
EXTENSIONS:
===========
- Tools to produce man pages from the SGML docs.
- Add Xpointer recognition/API
- Add Xlink recognition/API
=> started adding an xlink.[ch] with a unified API for XML and HTML.
it's crap :-(
- Implement XSchemas
=> Really need to be done <grin/>
- datatype are complete, but structure support is very limited.
- extend the shell with:
- edit
- load/save
- mv (yum, yum, but it's harder because directories are ordered in
our case, mvup and mvdown would be required)
Done:
=====
- Add HTML validation using the XHTML DTD
- problem: do we want to keep and maintain the code for handling
DTD/System ID cache directly in libxml ?
=> not really done that way, but there are new APIs to check elements
or attributes. Otherwise XHTML validation directly ...
- XML Schemas datatypes except Base64 and BinHex
- Relax NG validation
- XmlTextReader streaming API + validation
- Add a DTD cache prefilled with xhtml DTDs and entities and a program to
manage them -> like the /usr/bin/install-catalog from SGML
right place seems $datadir/xmldtds
Maybe this is better left to user apps
=> use a catalog instead , and xhtml1-dtd package
- Add output to XHTML
=> XML serializer automatically recognize the DTd and apply the specific
rules.
- Fix output of <tst val="x&#xA;y"/>
- compliance to XML-Namespace checking, see section 6 of
http://www.w3.org/TR/REC-xml-names/
- Correct standalone checking/emitting (hard)
2.9 Standalone Document Declaration
- Implement OASIS XML Catalog support
http://www.oasis-open.org/committees/entity/
- Get OASIS testsuite to a more friendly result, check all the results
once stable. the check-xml-test-suite.py script does this
- Implement XSLT
=> libxslt
- Finish XPath
=> attributes addressing troubles
=> defaulted attributes handling
=> namespace axis ?
done as XSLT got debugged
- bug reported by Michael Meallin on validation problems
=> Actually means I need to add support (and warn) for non-deterministic
content model.
- Handle undefined namespaces in entity contents better ... at least
issue a warning
- DOM needs
int xmlPruneProp(xmlNodePtr node, xmlAtttrPtr attr);
=> done it's actually xmlRemoveProp xmlUnsetProp xmlUnsetNsProp
- HTML: handling of Script and style data elements, need special code in
the parser and saving functions (handling of < > " ' ...):
http://www.w3.org/TR/html4/types.html#type-script
Attributes are no problems since entities are accepted.
- DOM needs
xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value)
- problem when parsing hrefs with & with the HTML parser (IRC ac)
- If the internal encoding is not UTF8 saving to a given encoding doesn't
work => fix to force UTF8 encoding ...
done, added documentation too
- Add an ASCII I/O encoder (asciiToUTF8 and UTF8Toascii)
- Issue warning when using non-absolute namespaces URI.
- the html parser should add <head> and <body> if they don't exist
started, not finished.
Done, the automatic closing is added and 3 testcases were inserted
- Command to force the parser to stop parsing and ignore the rest of the file.
xmlStopParser() should allow this, mostly untested
- support for HTML empty attributes like <hr noshade>
- plugged iconv() in for support of a large set of encodings.
- xmlSwitchToEncoding() rewrite done
- URI checkings (no fragments) rfc2396.txt
- Added a clean mechanism for overload or added input methods:
xmlRegisterInputCallbacks()
- dynamically adapt the alloc entry point to use g_alloc()/g_free()
if the programmer wants it:
- use xmlMemSetup() to reset the routines used.
- Check attribute normalization especially xmlGetProp()
- Validity checking problems for NOTATIONS attributes
- Validity checking problems for ENTITY ENTITIES attributes
- Parsing of a well balanced chunk xmlParseBalancedChunkMemory()
- URI module: validation, base, etc ... see uri.[ch]
- turn tester into a generic program xmllint installed with libxml
- extend validity checks to go through entities content instead of
just labelling them PCDATA
- Save Dtds using the children list instead of dumping the tables,
order is preserved as well as comments and PIs
- Wrote a notice of changes requires to go from 1.x to 2.x
- make sure that all SAX callbacks are disabled if a WF error is detected
- checking/handling of newline normalization
http://localhost/www.xml.com/axml/target.html#sec-line-ends
- correct checking of '&' '%' on entities content.
- checking of PE/Nesting on entities declaration
- checking/handling of xml:space
- checking done.
- handling done, not well tested
- Language identification code, productions [33] to [38]
=> done, the check has been added and report WFness errors
- Conditional sections in DTDs [61] to [65]
=> should this crap be really implemented ???
=> Yep OASIS testsuite uses them
- Allow parsed entities defined in the internal subset to override
the ones defined in the external subset (DtD customization).
=> This mean that the entity content should be computed only at
use time, i.e. keep the orig string only at parse time and expand
only when referenced from the external subset :-(
Needed for complete use of most DTD from Eve Maler
- Add regression tests for all WFC errors
=> did some in test/WFC
=> added OASIS testsuite routines
http://xmlsoft.org/conf/result.html
- I18N: http://wap.trondheim.com/vaer/index.phtml is not XML and accepted
by the XML parser, UTF-8 should be checked when there is no "encoding"
declared !
- Support for UTF-8 and UTF-16 encoding
=> added some conversion routines provided by Martin Durst
patched them, got fixes from @@@
I plan to keep everything internally as UTF-8 (or ISO-Latin-X)
this is slightly more costly but more compact, and recent processors
efficiency is cache related. The key for good performances is keeping
the data set small, so will I.
=> the new progressive reading routines call the detection code
is enabled, tested the ISO->UTF-8 stuff
- External entities loading:
- allow override by client code
- make sure it is called for all external entities referenced
Done, client code should use xmlSetExternalEntityLoader() to set
the default loading routine. It will be called each time an external
entity entity resolution is triggered.
- maintain ID coherency when removing/changing attributes
The function used to deallocate attributes now check for it being an
ID and removes it from the table.
- push mode parsing i.e. non-blocking state based parser
done, both for XML and HTML parsers. Use xmlCreatePushParserCtxt()
and xmlParseChunk() and html counterparts.
The tester program now has a --push option to select that parser
front-end. Douplicated tests to use both and check results are similar.
- Most of XPath, still see some troubles and occasionnal memleaks.
- an XML shell, allowing to traverse/manipulate an XML document with
a shell like interface, and using XPath for the anming syntax
- use of readline and history added when available
- the shell interface has been cleanly separated and moved to debugXML.c
- HTML parser, should be fairly stable now
- API to search the lang of an attribute
- Collect IDs at parsing and maintain a table.
PBM: maintain the table coherency
PBM: how to detect ID types in absence of DtD !
- Use it for XPath ID support
- Add validity checking
Should be finished now !
- Add regression tests with entity substitutions
- External Parsed entities, either XML or external Subset [78] and [79]
parsing the xmllang DtD now works, so it should be sufficient for
most cases !
- progressive reading. The entity support is a first step toward
abstraction of an input stream. A large part of the context is still
located on the stack, moving to a state machine and putting everything
in the parsing context should provide an adequate solution.
=> Rather than progressive parsing, give more power to the SAX-like
interface. Currently the DOM-like representation is built but
=> it should be possible to define that only as a set of SAX callbacks
and remove the tree creation from the parser code.
DONE
- DOM support, instead of using a proprietary in memory
format for the document representation, the parser should
call a DOM API to actually build the resulting document.
Then the parser becomes independent of the in-memory
representation of the document. Even better using RPC's
the parser can actually build the document in another
program.
=> Work started, now the internal representation is by default
very near a direct DOM implementation. The DOM glue is implemented
as a separate module. See the GNOME gdome module.
- C++ support : John Ehresman <jehresma@dsg.harvard.edu>
- Updated code to follow more recent specs, added compatibility flag
- Better error handling, use a dedicated, overridable error
handling function.
- Support for CDATA.
- Keep track of line numbers for better error reporting.
- Support for PI (SAX one).
- Support for Comments (bad, should be in ASAP, they are parsed
but not stored), should be configurable.
- Improve the support of entities on save (+SAX).

@ -0,0 +1,31 @@
- implement counted transitions at the automata level
- Unicode:
+ upgrade to 3.2
+ improve the python script to generate better test
expressions to check the list of ranges.
- Implement the interface at the SAX level
- Implement the missing parts in the Structure part
+ all content model
+ enumerations
+ countless others c.f. the TODO scattered in the code
- Complete the Built-In datatype collections and Facets implementations
- Regression tests based on
+ the primer:
http://www.w3.org/TR/xmlschema-0/
+ the Schemas Test Collection:
http://www.w3.org/2001/05/xmlschema-test-collection/
+ archives of the schemas-dev list
- Integrity constraints:
+ what's that ? How need to read about it
- "formal" checking, i.e. go through the full Structure spec and
bind code and associated parts of the Schemas spec
- go though the erratas
http://www.w3.org/2001/05/xmlschema-errata

@ -0,0 +1,86 @@
libxml2 on VxWorks 6.4+
Here are my instructions for building on VxWorks.... I am very ashamed of
how I did this because it is a complete hack, but it works great, so I
can't complain too much.
General Information
1. The only way to build for VxWorks is to cross compile from a windows or
linux system. We use a RedHat 5.1 workstation system as our build
environment.
2. VxWorks 6.X has two main types of executable, DKMs (dynamic kernel
modules), and RTPs (real-time processes). Kernel modules are the bread
and butter of VxWorks, but they look nothing like processes/threads in
normal UNIX/Windows systems. RTPs are more like processes that have
memory protection, threads, etc. VxWorks 6.X also introduces some level
of POSIX conformance to their environment. The POSIX conformance was the
key for us to be able to port libxml2. We support accessing libxml2 from
both DKMs and RTPs.
3. There are 2 compilers for VxWorks, the WindRiver compiler, and a port
of the GNU toolchain, we have only tested and built with the GNU
toolchain.
How To Build
1. Run the configure on your native linux system (this is the cheesy
hack). Since the VxWorks GNU toolchain is very close in version to the
one in red hat, it generates a good config.h file. We configured libxml2
with the following to keep the size down, (but we have done basic testing
with everything compiled in).
./configure --with-minimum --with-reader --with-writer --with-regexps
--with-threads --with-thread-alloc
2. Rename the libxml2 folder to "src". This step is required for our
replacement makefile to work.
3. Run the replacement makefile. I wrote a new makefile that sets all the
proper vxworks defines and uses the correct compilers. The two defines on
the make command line are to tell it which VxWorks Target (SH3.2 little
endian), and the executable type. We have tested this code on PENTIUM2gnu
and SH32gnule.
This makefile creates a shared library that runs on VxWorks: (libxml2.so)
make -f Makefile.vxworks clean all VXCPU=SH32gnule VXTYPE=RTP
This makefile creates a kernel module that runs on VxWorks: (xml2.out)
make -f Makefile.vxworks clean all VXCPU=SH32gnule VXTYPE=DKM
Important Notes
1. There are several ways that this process could be improved, but at the
end of the day, we make products, not port libraries, so we did a meets
minimum for our needs.
2. VxWorks is the devil, give me embedded linux every day.
3. No matter what I tried, I couldn't get the configure to pick up the
VxWorks toolchain, and in my investigation, it has something to do with
automake/autoconf, not any individual package. VxWorks doesn't play by
the normal rules for building toolchains.
4. The PIC flag in VxWorks (especially for SH processors) is very
important, and very troublesome. On linux, you can liberally use the PIC
flag when compiling and the compiler/linker will ignore it as needed, on
VxWorks if must always be on for shared libraries, and always be off for
static libraries and executables.
5. If anyone wants to work on a better way to do the build of libxml2 for
VxWorks, I'm happy to help as much as I can, but I'm not looking to
support it myself.
Attached Files
1. To use my Makefile for vxworks, you should enter the vxworks
environment (/opt/windriver/wrenv.linux -p vxworks-6.4 for me).
2. Run: build.sh libxml2-2.6.32 SH32gnule RTP (where you have
libxml2-2.6.32.tar.gz and the Makefile in the same directory as the script
file).
Thanks,
Jim Wert Jr.
JWert@ILSTechnology.com

@ -0,0 +1,85 @@
LIBXML2=$1
TARGETCPU=$2
TARGETTYPE=$3
if [ -z "$2" ]; then
TARGETCPU=SIMPENTIUMgnu
fi
if [ -z "$3" ]; then
TARGETTYPE=RTP
fi
echo "LIBXML2 Version: ${LIBXML2}"
echo "LIBXML2 Target CPU: ${TARGETCPU}"
echo "LIBXML2 Target Type: ${TARGETTYPE}"
rm -fR src
tar xvzf ${LIBXML2}.tar.gz
mv ${LIBXML2} src
cd src
./configure --with-minimum --with-reader --with-writer --with-regexps --with-threads --with-thread-alloc
find . -name '*.in' -exec rm -fR {} +
find . -name '*.am' -exec rm -fR {} +
rm -fR *.m4
rm -fR *.pc
rm -fR *.pl
rm -fR *.py
rm -fR *.spec
rm -fR .deps
rm -fR AUTHORS
rm -fR bakefile
rm -fR ChangeLog
rm -fR config.guess
rm -fR config.log
rm -fR config.status
rm -fR config.stub
rm -fR config.sub
rm -fR configure
rm -fR COPYING
rm -fR Copyright
rm -fR depcomp
rm -fR doc
rm -fR example
rm -fR INSTALL
rm -fR install-sh
rm -fR libxml.3
rm -fR ltmain.sh
rm -fR Makefile
rm -fR Makefile.tests
rm -fR macos
rm -fR mkinstalldirs
rm -fR missing
rm -fR nanoftp.c
rm -fR nanohttp.c
rm -fR NEWS
rm -fR python
rm -fR README
rm -fR README.tests
rm -fR regressions.xml
rm -fR result
rm -fR runsuite.c
rm -fR runtest.c
rm -fR test
rm -fR test*.c
rm -fR TODO*
rm -fR trio*
rm -fR vms
rm -fR win32
rm -fR xml2*
rm -fR xmllint.c
rm -fR xstc
cd ..
make clean all VXCPU=${TARGETCPU} VXTYPE=${TARGETTYPE}
if [ "${TARGETTYPE}" = "RTP" ]; then
cp libxml2.so ../../lib/.
else
cp xml2.out ../../bin/.
fi
cp -R src/include/libxml ../../include/.

@ -0,0 +1,28 @@
dnl Like AC_TRY_EVAL but also errors out if the compiler generates
dnl _any_ output. Some compilers might issue warnings which we want
dnl to catch.
AC_DEFUN([AC_TRY_EVAL2],
[{ (eval echo configure:__oline__: \"[$]$1\") 1>&AS_MESSAGE_LOG_FD; dnl
(eval [$]$1) 2>&AS_MESSAGE_LOG_FD; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }])
dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL
AC_DEFUN([AC_TRY_COMPILE2],
[cat > conftest.$ac_ext <<EOF
[#]line __oline__ "configure"
#include "confdefs.h"
[$1]
int main(void) {
[$2]
; return 0; }
EOF
if AC_TRY_EVAL2(ac_compile); then
ifelse([$3], , :, [rm -rf conftest*
$3])
else
echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
ifelse([$4], , , [ rm -rf conftest*
$4
])dnl
fi
rm -f conftest*])

@ -0,0 +1,95 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
THEDIR=`pwd`
cd $srcdir
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/autoconf"
DIE=1
}
(libtoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have libtool installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/libtool"
DIE=1
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
DIE=1
echo "You must have automake installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/automake"
}
if test "$DIE" -eq 1; then
exit 1
fi
test -f entities.c || {
echo "You must run this script in the top-level libxml directory"
exit 1
}
EXTRA_ARGS=
if test "x$1" = "x--system"; then
shift
prefix=/usr
libdir=$prefix/lib
sysconfdir=/etc
localstatedir=/var
if [ -d /usr/lib64 ]; then
libdir=$prefix/lib64
fi
EXTRA_ARGS="--prefix=$prefix --sysconfdir=$sysconfdir --localstatedir=$localstatedir --libdir=$libdir"
echo "Running ./configure with $EXTRA_ARGS $@"
else
if test -z "$NOCONFIGURE" && test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
fi
if [ ! -d $srcdir/m4 ]; then
mkdir $srcdir/m4
fi
# Replaced by autoreconf below
autoreconf -if -Wall
if ! grep -q pkg.m4 aclocal.m4; then
cat <<EOF
Couldn't find pkg.m4 from pkg-config. Install the appropriate package for
your distribution or set ACLOCAL_PATH to the directory containing pkg.m4.
EOF
exit 1
fi
cd $THEDIR
if test x$OBJ_DIR != x; then
mkdir -p "$OBJ_DIR"
cd "$OBJ_DIR"
fi
if test -z "$NOCONFIGURE"; then
$srcdir/configure $EXTRA_ARGS "$@"
if test "$?" -ne 0; then
echo
echo "Configure script failed, check config.log for more info."
else
echo
echo "Now type 'make' to compile libxml2."
fi
fi

@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<!-- $Id$ -->
<bakefile-gen>
<disable-formats>gnu,dmars,cbx_unix,cbuilderx</disable-formats>
<input>libxml2.bkl</input>
<!-- List of output formats to generate: -->
<add-formats>
borland,dmars,mingw,msvc,msvc6prj,watcom,cbuilderx,cbx_unix,gnu
</add-formats>
</bakefile-gen>

@ -0,0 +1,92 @@
LIBXML2 build system for Win32 README
-------------------------------------
In this folder are stored all the files required to compile LIBXML2 with win32 compilers.
Bakefile (http://bakefile.sourceforge.net) is used as makefile generator.
Supported makefiles:
- makefile.vc for Microsoft NMAKE
- makefile.bcc for Borland MAKE
- makefile.wat for OpenWatcom MAKE
- makefile.gcc for MinGW MINGW32-MAKE
- all DSP & DSW for Microsoft VisualC++ 6.0 (can be used also with VS.NET AFAIK)
This readme is organized as:
1.0 HOWTO compile LIBXML2 using makefiles <-- for users who want to build the library using *command-line*
1.1 HOWTO compile LIBXML2 using an IDE <-- for users who want to build the library using an *IDE*
1.2 HOWTO regenerate makefiles for LIBXML2 <-- for libxml2 mantainers/developers/advanced users
If you just want to compile the library (and the test programs) you should definitely avoid the
section 1.1 and focus on the 1.0.
1.0 HOWTO compile LIBXML2 using makefiles
-----------------------------------------
Choose your preferred compiler among those actually supported (see above) and then run
mycompilermake -fmakefile.makefileext [options]
for a full list of the available options you should open with a notepad (or something like that)
the makefile you want to use; at the beginning you should see a section which starts as:
# -------------------------------------------------------------------------
# These are configurable options:
# -------------------------------------------------------------------------
here you can find all the options actually used by that makefile.
They can be customized when running the makefile writing something like:
nmake -fmakefile.vc BUILD=release
mingw32-make -fmakefile.gcc BUILD=debug ICONV_DIR=c:\myiconv
or they can be permanently changed modifying the makefile.
That's all: for any problem/compile-error/suggestion, write to
frm@users.sourceforge.net with the word "libxml2" in the subject.
1.1 HOWTO compile LIBXML2 using an IDE
--------------------------------------
Actually only the Microsoft VisualC++ 6.0 project files are generated.
In future other Integrated Development Environments (IDEs) will be supported as well.
With MSVC++ 6.0, you should open the DSW file and then set as the active project the
"libxml2" project, if you want to build the library or one of the test projects if you
want to run them.
Using the command "Build->Set Active Configuration" you can choose one of the predefined
configuration.
1.2 HOWTO regenerate makefiles for LIBXML2
------------------------------------------
Be sure to have installed Bakefile (http://bakefile.sourceforge.net).
Just run the "bakefile_gen" command inside the folder containing the "libxml2.bkl" file.
NOTE: if you want to remove all the makefiles, you can use the "bakefile_gen -c" command.
The template files used to generate all makefiles are only two:
- libxml2.bkl (the main one)
- Bakefiles.bkgen
All the other files can be dynamically regenerated.
If you have problems with the compilation of LIBXML2 under windows (using one of the supported compiler)
please write to:
Francesco Montorsi <frm@users.sourceforge.net>

@ -0,0 +1,745 @@
<?xml version="1.0" ?>
<!-- Author: Francesco Montorsi <frm@users.sourceforge.net> -->
<!-- Date: 30/8/2004 -->
<!-- Last revision: 26/1/2005 -->
<!-- LIBXML2 BAKEFILE -->
<!-- -->
<!-- The bakefile used to build the library and the test -->
<!-- programs. The makefiles output is put: -->
<!-- -->
<!-- - in the ..\LIB folder -->
<!-- - in the ..\BIN folder -->
<!-- -->
<makefile>
<using module="datafiles"/>
<requires version="0.1.5"/>
<!-- This is a bakefile, that is, a generic template used to -->
<!-- generate makefiles ALL supported compilers. -->
<!-- To use this project file you need Bakefile installed. -->
<!-- With the command "bakefile_gen" you can regen all the -->
<!-- makefiles and project files. -->
<!-- See http://bakefile.sourceforge.net for more info. -->
<!--
This file is divided in:
- generic options
- generic variables
- libxml2 options
- libxml2 variables
- about config.h creation
- templates
- libxml2 library target
- libxml2 test program targets
-->
<!-- -->
<!-- GENERIC OPTIONS -->
<!-- -->
<!-- This is a standard option that determines -->
<!-- whether the user wants to build this library as -->
<!-- a dll or as a static library. -->
<option name="SHARED">
<values>0,1</values>
<values-description>,DLL</values-description>
<default-value>0</default-value>
<description>If set to zero a STATIC libxml library will be built</description>
</option>
<!-- Configuration for building the bakefile with -->
<!-- unicode strings or not (unicode or ansi). -->
<option name="UNICODE">
<values>0,1</values>
<values-description>,Unicode</values-description>
<default-value>0</default-value>
<description>Compile Unicode build?</description>
</option>
<!-- There are several options that deal with build -->
<!-- types. First, there's this one, BUILD. -->
<!-- -->
<!-- BUILD determines whether or not we want to build -->
<!-- in release or debug mode. Note that in practice -->
<!-- this means modifying the optimize tag, which by -->
<!-- default is set to off. In this case debug means -->
<!-- off (no optimizations), and release means speed -->
<!-- (fast with inlining). There is also a size option -->
<!-- that is not addressed in this example bakefile. -->
<option name="BUILD">
<values>debug,release</values>
<values-description>Debug,Release</values-description>
<default-value>release</default-value>
<description>
Type of compiled binaries
</description>
</option>
<!-- -->
<!-- GENERIC VARIABLES -->
<!-- -->
<!-- Set the ISDLL variable, so that we can use it -->
<!-- inside an if statement later on (options not -->
<!-- allowed in if statements). -->
<set var="ISDLL" cond="SHARED=='1'">1</set>
<set var="ISDLL" cond="SHARED=='0'">0</set>
<!-- The unicode define we want. By default bakefile -->
<!-- makes variables an empty string, so if unicode -->
<!-- is not defined $(UNICODE_DEFINE) would expand -->
<!-- to nothing (literally). -->
<set var="UNICODE_DEFINE">
<if cond="FORMAT!='autoconf' and UNICODE=='1'">_UNICODE</if>
</set>
<!-- The debug define we need with win32 compilers -->
<!-- (on Linux, the wx-config program is used). -->
<set var="DEBUG_DEFINE">
<if cond="FORMAT!='autoconf' and BUILD=='debug'">
__WXDEBUG__
</if>
</set>
<!-- Value we will use later on for the debug-info -->
<!-- tag inside our templates. -->
<set var="DEBUGINFO">
<if cond="BUILD=='debug'">on</if>
<if cond="BUILD=='release'">off</if>
</set>
<!-- Value we will use later on for the debug-runtime -->
<!-- tag inside our templates. -->
<set var="DEBUGRUNTIME">
<if cond="BUILD=='debug'">on</if>
<if cond="BUILD=='release'">off</if>
</set>
<!-- Value for optimize tag. -->
<set var="OPTIMIZEFLAG">
<if cond="BUILD=='debug'">off</if>
<if cond="BUILD=='release'">speed</if>
</set>
<!-- Level of warnings. Here we max it out in debug -->
<!-- mode, and turn them off in release mode. -->
<set var="WARNINGS">
<if cond="BUILD=='debug'">max</if>
<if cond="BUILD=='release'">no</if>
</set>
<!-- Set MYCPPFLAGS as empty; maybe it will be filled later... -->
<set var="MYCPPFLAGS"></set>
<if cond="FORMAT=='mingw' or FORMAT=='autoconf'">
<!-- With GCC, settings warnings to MAX would force -->
<!-- Bakefile to call GCC with "-W -Wall" which generates -->
<!-- a *lot* of warnings about wxWidgets headers... -->
<!-- this is why "-W -Wall" is here replaced by "-Wall". -->
<set var="WARNINGS">default</set>
<set var="MYCPPFLAGS">-Wall</set>
</if>
<!-- -->
<!-- LIBXML2 OPTIONS -->
<!-- -->
<!-- Note #1: not all of them are used by win32 makefiles -->
<!-- -->
<!-- Note #2: since all combinations of non-path options are -->
<!-- translated into different 'configurations' by -->
<!-- Bakefile when using the MSVC6PRJ output, we must -->
<!-- avoid to create a 10 MB libxml2.dsp file forcing -->
<!-- some options to their default values... this -->
<!-- behaviour can be overridden by the -->
<!-- FULL_OPTIONS_SUPPORT -->
<!-- variable defined below... -->
<set var="FULL_OPTIONS_SUPPORT">
<if cond="FORMAT=='msvc6prj'">0</if>
<if cond="FORMAT!='msvc6prj'">1</if>
</set>
<option name="ICONV_DIR" category="path">
<default-value>c:\iconv</default-value>
<description>The iconv library main folder</description>
</option>
<option name="WITH_TRIO">
<values>0,1</values>
<default-value>0</default-value>
<description>Enable TRIO string manipulator</description>
</option>
<!-- see the note #2 -->
<if cond="FULL_OPTIONS_SUPPORT=='0'">
<set var="WITH_THREADS">native</set>
</if>
<if cond="FULL_OPTIONS_SUPPORT=='1'">
<option name="WITH_THREADS">
<values>no,ctls,native,posix</values>
<default-value>native</default-value>
<description>Enable thread safety</description>
</option>
</if>
<option name="WITH_FTP">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable FTP client</description>
</option>
<option name="WITH_HTTP">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable HTTP client</description>
</option>
<option name="WITH_C14N">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable C14N support</description>
</option>
<option name="WITH_CATALOG">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable catalog support</description>
</option>
<option name="WITH_DOCB">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable DocBook support</description>
</option>
<option name="WITH_XPATH">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable XPath support</description>
</option>
<option name="WITH_XPTR">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable XPointer support</description>
</option>
<option name="WITH_XINCLUDE">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable XInclude support</description>
</option>
<!-- see the note #2 -->
<if cond="FULL_OPTIONS_SUPPORT=='0'">
<set var="WITH_ICONV">1</set>
</if>
<if cond="FULL_OPTIONS_SUPPORT=='1'">
<option name="WITH_ICONV">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable iconv support</description>
</option>
</if>
<option name="WITH_ISO8859X">
<values>0,1</values>
<default-value>0</default-value>
<description>Enable iso8859x support</description>
</option>
<!-- see the note #2 -->
<if cond="FULL_OPTIONS_SUPPORT=='0'">
<set var="WITH_ZLIB">0</set>
</if>
<if cond="FULL_OPTIONS_SUPPORT=='1'">
<option name="WITH_ZLIB">
<values>0,1</values>
<default-value>0</default-value>
<description>Enable ZLIB support</description>
</option>
</if>
<option name="WITH_REGEXPS">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable regular expressions</description>
</option>
<option name="WITH_TREE">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable tree api</description>
</option>
<option name="WITH_READER">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable xmlReader api</description>
</option>
<option name="WITH_WRITER">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable xmlWriter api</description>
</option>
<option name="WITH_WALKER">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable xmlDocWalker api</description>
</option>
<option name="WITH_PATTERN">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable xmlPattern api</description>
</option>
<option name="WITH_PUSH">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable push api</description>
</option>
<option name="WITH_VALID">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable DTD validation support</description>
</option>
<option name="WITH_SAX1">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable SAX1 api</description>
</option>
<option name="WITH_SCHEMAS">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable XML Schema support</description>
</option>
<option name="WITH_LEGACY">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable deprecated APIs</description>
</option>
<option name="WITH_OUTPUT">
<values>0,1</values>
<default-value>1</default-value>
<description>Enable serialization support</description>
</option>
<option name="WITH_PYTHON">
<values>0,1</values>
<default-value>0</default-value>
<description>Build Python bindings</description>
</option>
<!-- -->
<!-- LIBXML2 VARIABLES -->
<!-- -->
<!-- Put all the objects files generated by -->
<!-- the compilation in a subfolder of BUILD -->
<set var="BUILDDIR">$(FORMAT)</set>
<!-- This variable is set to 1 when the current output writer supports -->
<!-- the __DEFINE_ARG variable. Otherwise it's set to zero. -->
<set var="HAS_DEFINE_ARG">
<if cond="FORMAT!='msvc6prj'">1</if>
<if cond="FORMAT=='msvc6prj'">0</if>
</set>
<!-- The root directory of libxml2 -->
<set var="XMLBASEDIR">..</set>
<!-- The directory where libxml2' tests will be put -->
<set var="XMLTESTDIR">$(XMLBASEDIR)$(DIRSEP)bin</set>
<set var="LIBXML_MAJOR_VERSION">2</set>
<set var="LIBXML_MINOR_VERSION">6</set>
<set var="LIBXML_MICRO_VERSION">16</set>
<!-- some defines related to threads -->
<set var="THREADS_DEF">
<if cond="HAS_DEFINE_ARG=='1' and WITH_THREADS=='native'">
$(__DEFINE_ARG)_REENTRANT $(__DEFINE_ARG)HAVE_WIN32_THREADS
</if>
<if cond="HAS_DEFINE_ARG=='1' and WITH_THREADS=='ctls'">
$(__DEFINE_ARG)_REENTRANT $(__DEFINE_ARG)HAVE_WIN32_THREADS $(__DEFINE_ARG)HAVE_COMPILER_TLS
</if>
<if cond="HAS_DEFINE_ARG=='1' and WITH_THREADS=='posix'">
$(__DEFINE_ARG)_REENTRANT $(__DEFINE_ARG)HAVE_PTHREAD_H
</if>
</set>
<if cond="FORMAT=='borland'">
<set var="THREADS_DEF">
<if cond="WITH_THREADS=='native'">$(THREADS_DEF) $(__DEFINE_ARG)__MT__</if>
<if cond="WITH_THREADS=='ctls'">$(THREADS_DEF) $(__DEFINE_ARG)__MT__</if>
<if cond="WITH_THREADS=='posix'">$(THREADS_DEF) $(__DEFINE_ARG)__MT__</if>
</set>
</if>
<!-- some other conditional defines -->
<set var="DEBUG_DEF"><if cond="BUILD=='debug'">_DEBUG</if></set>
<set var="DEBUG_DEF"><if cond="BUILD=='release'">NDEBUG</if></set>
<!-- this is very very important when compiling with MINGW: without this line,
the test programs (and all the programs built with libxml2 which use xmlFree)
won't build because of "undefined references to __xmlFree" -->
<set var="STATIC_DEF"><if cond="SHARED=='0'">LIBXML_STATIC</if></set>
<!-- some conditional libraries dependencies -->
<set var="ICONV_LIB"><if cond="WITH_ICONV=='1'">iconv</if></set>
<set var="WSOCK32_LIB"><if cond="WITH_THREADS=='native'">wsock32</if></set>
<set var="ZLIB_LIB"><if cond="WITH_ZLIB=='1'">zdll</if></set>
<set var="POSIX_LIB"><if cond="WITH_THREADS=='posix'">pthreadVC</if></set>
<set var="XMLINCLUDEDIR">$(XMLBASEDIR)$(DIRSEP)include$(DIRSEP)libxml$(DIRSEP)</set>
<!-- -->
<!-- ABOUT CONFIG.H HEADER CREATION -->
<!-- -->
<set var="CONFIG_SRCNAME">win32config.h</set>
<set var="CONFIG_DSTNAME">config.h</set>
<if cond="FORMAT!='msvc6prj' and FORMAT!='autoconf' and FORMAT!='gnu'">
<copy-file-to-file id="setup">
<!-- On win32 we need to manually copy a default config.h file -->
<!-- from the include/mc/msw folder to include/mc -->
<src>../include/$(CONFIG_SRCNAME)</src>
<dst>../$(CONFIG_DSTNAME)</dst>
<dependency-of>all</dependency-of>
<!-- With autoconf, we will use the configure script to translate -->
<!-- include/mc/config.h.in to include/mc/config.h and thus we do -->
<!-- not need to do anything here... -->
</copy-file-to-file>
</if>
<if cond="FORMAT!='msvc6prj'">
<mkdir id="setuplibdir"><dir>$(XMLBASEDIR)$(DIRSEP)lib</dir></mkdir>
<mkdir id="setupbindir"><dir>$(XMLBASEDIR)$(DIRSEP)bin</dir></mkdir>
<!-- Creates all output folders -->
<phony id="setupdirs">
<dependency-of>all</dependency-of>
<depends>setuplibdir</depends>
<depends>setupbindir</depends>
</phony>
</if>
<!-- This defines a tag which includes headers on MSVC -->
<!-- Note that $(value) is stuck in there by bakefile, -->
<!-- and is the value between the beginning and end tag. -->
<define-tag name="headers" rules="dll,lib,exe">
<if cond="FORMAT=='msvc6prj'">
<msvc-project-files>
$(value)
</msvc-project-files>
</if>
</define-tag>
<!-- Creates the following custom build rule for MSVC6PRJ file:
copies ..\include\win32config.h into ..\config.h
NOTE: this tag must be used before the <sources> tag if you want that the configuration
file will be created before any other source file is compiled... -->
<define-tag name="msvc-copy-setup-h" rules="dll,lib,action">
<if cond="FORMAT=='msvc6prj'">
<headers>$(XMLBASEDIR)\include\$(CONFIG_SRCNAME)</headers>
<set var="__subdir">$(value)</set>
<set var="_custom_build_files" append="1">$(XMLBASEDIR)\include\$(CONFIG_SRCNAME)</set>
<set var="_custom_build____include_win32config_h">
Creating the configuration file ..\$(CONFIG_DSTNAME) from ..\include\$(CONFIG_SRCNAME)
InputPath=..\include\$(CONFIG_SRCNAME)
"..\$(CONFIG_DSTNAME)" : $(DOLLAR)(SOURCE) "$(DOLLAR)(INTDIR)" "$(DOLLAR)(OUTDIR)"
$(TAB)copy "$(DOLLAR)(InputPath)" ..\$(CONFIG_DSTNAME)
</set>
</if>
</define-tag>
<!-- -->
<!-- TEMPLATES -->
<!-- -->
<!-- The basic template: used by all the targets -->
<template id="base">
<if cond="FORMAT=='mingw'">
<define>HAVE_W32API_H</define>
<ldflags>-mthreads</ldflags>
</if>
<cxxflags>$(MYCPPFLAGS)</cxxflags>
<warnings>$(WARNINGS)</warnings>
<define>$(UNICODE_DEFINE)</define>
<optimize>$(OPTIMIZEFLAG)</optimize>
<debug-info>$(DEBUGINFO)</debug-info>
<debug-runtime-libs>$(DEBUGRUNTIME)</debug-runtime-libs>
</template>
<!-- The template used both by the library and by the test programs -->
<template id="xml2" template="base">
<!-- -I & -L equivalents -->
<include>$(XMLBASEDIR)$(DIRSEP)include</include>
<include>$(ICONV_DIR)$(DIRSEP)include</include>
<lib-path>$(ICONV_DIR)$(DIRSEP)lib</lib-path>
<!-- some conditional define flags -->
<cflags>$(THREADS_DEF)</cflags>
<define>$(ZLIB_DEF)</define>
<define>$(DEBUG_DEF)</define>
<define>$(STATIC_DEF)</define>
<if cond="HAS_DEFINE_ARG=='0'">
<!-- we are probably using an IDE output: defaults to WITH_THREADS=='native' -->
<define>_REENTRANT</define>
<define>HAVE_WIN32_THREADS</define>
</if>
<!-- these must always be defined on win32 -->
<define>WIN32</define>
<define>_WINDOWS</define>
<define>_MBCS</define>
<if cond="FORMAT=='borland'">
<define>_NO_VCL</define>
<define>EILSEQ=2</define>
</if>
</template>
<!-- The template used by libxml2 test programs -->
<template id="xml2test" template="xml2">
<dirname>$(XMLTESTDIR)</dirname>
<app-type>console</app-type>
<library>libxml2</library>
<sys-lib>$(ICONV_LIB)</sys-lib>
<sys-lib>$(WSOCK32_LIB)</sys-lib>
<sys-lib>$(ZLIB_LIB)</sys-lib>
<sys-lib>$(POSIX_LIB)</sys-lib>
</template>
<!-- -->
<!-- LIBXML2 LIBRARY TARGET -->
<!-- -->
<lib id="libxml2" template="xml2">
<!-- this is useful only when using MSVC6PRJ -->
<if cond="FORMAT=='msvc6prj'">
<msvc-copy-setup-h/>
<msvc-file-group>Config headers:*config.h</msvc-file-group>
</if>
<if cond="FORMAT!='msvc6prj'">
<depends>setup</depends>
<depends>setuplibdir</depends>
</if>
<!-- output folder -->
<dirname>$(XMLBASEDIR)$(DIRSEP)lib</dirname>
<!-- The output name must be "libxml2.lib" with all compilers.
Since mingw format autoadds the "lib" prefix to the library
name, we must intercept that case to avoid to get "liblibxml2.a" -->
<if cond="FORMAT!='mingw'">
<libname>libxml2</libname>
</if>
<if cond="FORMAT=='mingw'">
<libname>xml2</libname>
</if>
<!-- the list of source files to compile -->
<sources>
$(XMLBASEDIR)$(DIRSEP)c14n.c
$(XMLBASEDIR)$(DIRSEP)catalog.c
$(XMLBASEDIR)$(DIRSEP)chvalid.c
$(XMLBASEDIR)$(DIRSEP)debugXML.c
$(XMLBASEDIR)$(DIRSEP)dict.c
$(XMLBASEDIR)$(DIRSEP)DOCBparser.c
$(XMLBASEDIR)$(DIRSEP)encoding.c
$(XMLBASEDIR)$(DIRSEP)entities.c
$(XMLBASEDIR)$(DIRSEP)error.c
$(XMLBASEDIR)$(DIRSEP)globals.c
$(XMLBASEDIR)$(DIRSEP)hash.c
$(XMLBASEDIR)$(DIRSEP)HTMLparser.c
$(XMLBASEDIR)$(DIRSEP)HTMLtree.c
$(XMLBASEDIR)$(DIRSEP)legacy.c
$(XMLBASEDIR)$(DIRSEP)list.c
$(XMLBASEDIR)$(DIRSEP)nanoftp.c
$(XMLBASEDIR)$(DIRSEP)nanohttp.c
$(XMLBASEDIR)$(DIRSEP)parser.c
$(XMLBASEDIR)$(DIRSEP)parserInternals.c
$(XMLBASEDIR)$(DIRSEP)pattern.c
$(XMLBASEDIR)$(DIRSEP)relaxng.c
$(XMLBASEDIR)$(DIRSEP)SAX2.c
$(XMLBASEDIR)$(DIRSEP)SAX.c
$(XMLBASEDIR)$(DIRSEP)threads.c
$(XMLBASEDIR)$(DIRSEP)tree.c
$(XMLBASEDIR)$(DIRSEP)uri.c
$(XMLBASEDIR)$(DIRSEP)valid.c
$(XMLBASEDIR)$(DIRSEP)xinclude.c
$(XMLBASEDIR)$(DIRSEP)xlink.c
$(XMLBASEDIR)$(DIRSEP)xmlIO.c
$(XMLBASEDIR)$(DIRSEP)xmlmemory.c
$(XMLBASEDIR)$(DIRSEP)xmlreader.c
$(XMLBASEDIR)$(DIRSEP)xmlregexp.c
$(XMLBASEDIR)$(DIRSEP)xmlsave.c
$(XMLBASEDIR)$(DIRSEP)xmlschemas.c
$(XMLBASEDIR)$(DIRSEP)xmlschemastypes.c
$(XMLBASEDIR)$(DIRSEP)xmlunicode.c
$(XMLBASEDIR)$(DIRSEP)xmlwriter.c
$(XMLBASEDIR)$(DIRSEP)xpath.c
$(XMLBASEDIR)$(DIRSEP)xpointer.c
$(XMLBASEDIR)$(DIRSEP)xmlstring.c
</sources>
<!-- the list of header files (for IDE projects) -->
<headers>
$(XMLINCLUDEDIR)c14n.h
$(XMLINCLUDEDIR)catalog.h
$(XMLINCLUDEDIR)chvalid.h
$(XMLINCLUDEDIR)debugXML.h
$(XMLINCLUDEDIR)dict.h
$(XMLINCLUDEDIR)DOCBparser.h
$(XMLINCLUDEDIR)encoding.h
$(XMLINCLUDEDIR)entities.h
$(XMLINCLUDEDIR)globals.h
$(XMLINCLUDEDIR)hash.h
$(XMLINCLUDEDIR)HTMLparser.h
$(XMLINCLUDEDIR)HTMLtree.h
$(XMLINCLUDEDIR)list.h
$(XMLINCLUDEDIR)nanoftp.h
$(XMLINCLUDEDIR)nanohttp.h
$(XMLINCLUDEDIR)parser.h
$(XMLINCLUDEDIR)parserInternals.h
$(XMLINCLUDEDIR)pattern.h
$(XMLINCLUDEDIR)relaxng.h
$(XMLINCLUDEDIR)SAX.h
$(XMLINCLUDEDIR)SAX2.h
$(XMLINCLUDEDIR)schemasInternals.h
$(XMLINCLUDEDIR)threads.h
$(XMLINCLUDEDIR)tree.h
$(XMLINCLUDEDIR)uri.h
$(XMLINCLUDEDIR)valid.h
$(XMLINCLUDEDIR)xinclude.h
$(XMLINCLUDEDIR)xlink.h
$(XMLINCLUDEDIR)xmlautomata.h
$(XMLINCLUDEDIR)xmlerror.h
$(XMLINCLUDEDIR)xmlexports.h
$(XMLINCLUDEDIR)xmlIO.h
$(XMLINCLUDEDIR)xmlmemory.h
$(XMLINCLUDEDIR)xmlmodule.h
$(XMLINCLUDEDIR)xmlreader.h
$(XMLINCLUDEDIR)xmlregexp.h
$(XMLINCLUDEDIR)xmlsave.h
$(XMLINCLUDEDIR)xmlschemas.h
$(XMLINCLUDEDIR)xmlschemastypes.h
$(XMLINCLUDEDIR)xmlstring.h
$(XMLINCLUDEDIR)xmlunicode.h
$(XMLINCLUDEDIR)xmlversion.h
$(XMLINCLUDEDIR)xmlwriter.h
$(XMLINCLUDEDIR)xpath.h
$(XMLINCLUDEDIR)xpathInternals.h
$(XMLINCLUDEDIR)xpointer.h
</headers>
<!-- these ones are not inside the include/libxml folder -->
<headers>
$(XMLBASEDIR)$(DIRSEP)libxml.h
$(XMLBASEDIR)$(DIRSEP)triodef.h
$(XMLBASEDIR)$(DIRSEP)trionan.h
$(XMLBASEDIR)$(DIRSEP)include$(DIRSEP)wsockcompat.h
</headers>
</lib>
<!-- -->
<!-- LIBXML2 test programs -->
<!-- -->
<set var="BUILD_ALL_TESTS">
<!-- when using full options support with MSVC6PRJ we should
avoid to create all the DSP files required for the test
programs: they would take a _lot_ of space !! -->
<if cond="FORMAT=='msvc6prj' and FULL_OPTIONS_SUPPORT=='1'">0</if>
<!-- when creating a makefile or using MSVC6PRJ with limited
options support, then we can build all the tests safely -->
<if cond="FORMAT!='msvc6prj' or FULL_OPTIONS_SUPPORT=='0'">1</if>
</set>
<if cond="BUILD_ALL_TESTS=='1'">
<exe id="testAutomata" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testAutomata.c</sources></exe>
<exe id="testC14N" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testC14N.c</sources></exe>
<exe id="testHTML" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testHTML.c</sources></exe>
<exe id="testReader" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testReader.c</sources></exe>
<exe id="testRegexp" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testRegexp.c</sources></exe>
<exe id="testRelax" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testRelax.c</sources></exe>
<exe id="testSax" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testSax.c</sources></exe>
<exe id="testSchemas" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testSchemas.c</sources></exe>
<exe id="testURI" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testURI.c</sources></exe>
<exe id="testXPath" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testXPath.c</sources></exe>
<exe id="xmllint" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)xmllint.c</sources></exe>
<if cond="FORMAT=='autoconf'">
<exe id="testdso" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testdso.c</sources></exe>
</if>
<!-- FIXME:
<exe id="testModule" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testModule.c</sources></exe>
<if cond="WITH_THREADS!='no'">
<exe id="testThreads" template="xml2test"><sources>$(XMLBASEDIR)$(DIRSEP)testThreads.c</sources></exe>
</if>
-->
</if>
</makefile>

@ -0,0 +1,72 @@
/*
* Summary: Internal Interfaces for memory buffers in libxml2
* Description: this module describes most of the new xmlBuf buffer
* entry points, those are private routines, with a
* few exceptions exported in tree.h. This was added
* in 2.9.0.
*
* Copy: See Copyright for the status of this software.
*
* Author: Daniel Veillard
*/
#ifndef __XML_BUF_H__
#define __XML_BUF_H__
#include <libxml/tree.h>
#ifdef __cplusplus
extern "C" {
#endif
xmlBufPtr xmlBufCreate(void);
xmlBufPtr xmlBufCreateSize(size_t size);
xmlBufPtr xmlBufCreateStatic(void *mem, size_t size);
int xmlBufSetAllocationScheme(xmlBufPtr buf,
xmlBufferAllocationScheme scheme);
int xmlBufGetAllocationScheme(xmlBufPtr buf);
void xmlBufFree(xmlBufPtr buf);
void xmlBufEmpty(xmlBufPtr buf);
/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
int xmlBufGrow(xmlBufPtr buf, int len);
int xmlBufInflate(xmlBufPtr buf, size_t len);
int xmlBufResize(xmlBufPtr buf, size_t len);
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
int xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len);
int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
int xmlBufCCat(xmlBufPtr buf, const char *str);
int xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string);
int xmlBufWriteChar(xmlBufPtr buf, const char *string);
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
size_t xmlBufAvail(const xmlBufPtr buf);
size_t xmlBufLength(const xmlBufPtr buf);
/* size_t xmlBufUse(const xmlBufPtr buf); */
int xmlBufIsEmpty(const xmlBufPtr buf);
int xmlBufAddLen(xmlBufPtr buf, size_t len);
int xmlBufErase(xmlBufPtr buf, size_t len);
/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
xmlChar * xmlBufDetach(xmlBufPtr buf);
size_t xmlBufDump(FILE *file, xmlBufPtr buf);
xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer);
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf);
int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
size_t base, size_t cur);
#ifdef __cplusplus
}
#endif
#endif /* __XML_BUF_H__ */

@ -0,0 +1,122 @@
#! /usr/bin/env python
###
#
# build_glob.py : Build the global_functions.h and global_functions.c
# files which are required to implement the user
# interface to global variables now that thread specific
# data (TSD) is used to emulate global state.
#
# See Copyright for the status of this software.
# Gary.Pennington@sun.com
###
import os, string
class globvar:
def __init__(self, type, name):
self.type=type
self.name=name
def striplinesep(line):
while line and line[-1] in ('\r','\n'):
line = line[:-1]
return line
def writeline(file, line=None):
if line:
file.write(line)
file.write("\n")
if __name__ == "__main__":
globals={}
global_data=open("global.data").readlines()
global_code=open("globals.c").readlines()
global_hdr=open("include/libxml/globals.h").readlines()
global_functions_hdr=open("include/libxml/globals.h", "w+")
global_functions_impl=open("globals.c", "w+")
#
# Rebuild the beginning of the file up to the
# Automatically generated string
#
for line in global_hdr:
line = striplinesep(line)
if line == " * Automatically generated by build_glob.py.":
break
writeline(global_functions_hdr, line)
writeline(global_functions_hdr, " * Automatically generated by build_glob.py.")
writeline(global_functions_hdr, " * Do not modify the previous line.")
writeline(global_functions_hdr, " */")
writeline(global_functions_hdr)
for line in global_code:
line = striplinesep(line)
if line == " * Automatically generated by build_glob.py.":
break
writeline(global_functions_impl, line)
writeline(global_functions_impl, " * Automatically generated by build_glob.py.")
writeline(global_functions_impl, " * Do not modify the previous line.")
writeline(global_functions_impl, " */")
writeline(global_functions_impl)
# Now process the data and write it to the appropriate output file
for line in global_data:
if line[0]=='#':
continue
line = striplinesep(line)
fields = string.split(line, ",")
# Update the header file
writeline(global_functions_hdr)
global_functions_hdr.write("extern "+fields[0]+" *")
if fields[2]:
global_functions_hdr.write("(*")
global_functions_hdr.write("__"+fields[1]+"(void)")
if fields[2]:
global_functions_hdr.write(")"+fields[2])
writeline(global_functions_hdr,";")
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
writeline(global_functions_hdr,"#define "+fields[1]+" \\")
writeline(global_functions_hdr,"(*(__"+fields[1]+"()))")
writeline(global_functions_hdr,"#else")
if fields[2]:
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+fields[2]+";")
else:
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+";")
writeline(global_functions_hdr,"#endif")
# set/get for per-thread global defaults
if fields[3]:
writeline(global_functions_hdr,fields[0]+" "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v);")
# Update the implementation file
writeline(global_functions_impl)
# writeline(global_functions_impl, "extern "+fields[0]+" "+fields[1]+";")
writeline(global_functions_impl, "#undef\t"+fields[1])
writeline(global_functions_impl, fields[0]+" *")
if fields[2]:
global_functions_impl.write("(*")
global_functions_impl.write("__"+fields[1]+"(void)")
if fields[2]:
writeline(global_functions_impl, ")[]")
writeline(global_functions_impl, " {")
writeline(global_functions_impl, " if (IS_MAIN_THREAD)")
writeline(global_functions_impl, "\treturn (&"+fields[1]+");")
writeline(global_functions_impl, " else")
writeline(global_functions_impl, "\treturn (&xmlGetGlobalState()->"+fields[1]+");")
writeline(global_functions_impl, "}")
# set/get for per-thread global defaults
if fields[3]:
writeline(global_functions_impl,fields[0]+" "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v) {")
writeline(global_functions_impl," "+fields[0]+" ret;");
writeline(global_functions_impl," xmlMutexLock(xmlThrDefMutex);")
writeline(global_functions_impl," ret = "+fields[1][:3]+fields[1][3:]+"ThrDef;")
writeline(global_functions_impl," "+fields[1][:3]+fields[1][3:]+"ThrDef = v;")
writeline(global_functions_impl," xmlMutexUnlock(xmlThrDefMutex);")
writeline(global_functions_impl," return ret;")
writeline(global_functions_impl,"}")
# Terminate the header file with appropriate boilerplate
writeline(global_functions_hdr)
writeline(global_functions_hdr, "#ifdef __cplusplus")
writeline(global_functions_hdr, "}")
writeline(global_functions_hdr, "#endif")
writeline(global_functions_hdr)
writeline(global_functions_hdr, "#endif /* __XML_GLOBALS_H */")

@ -0,0 +1,394 @@
#!/usr/bin/python
import sys
import time
import os
import string
import StringIO
sys.path.insert(0, "python")
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
debug = 0
verbose = 0
quiet = 1
#
# the testsuite description
#
CONF=os.path.join(os.path.dirname(__file__), "test/relaxng/OASIS/spectest.xml")
LOG="check-relaxng-test-suite.log"
RES="relaxng-test-results.xml"
log = open(LOG, "w")
nb_schemas_tests = 0
nb_schemas_success = 0
nb_schemas_failed = 0
nb_instances_tests = 0
nb_instances_success = 0
nb_instances_failed = 0
libxml2.lineNumbersDefault(1)
#
# Error and warnng callbacks
#
def callback(ctx, str):
global log
log.write("%s%s" % (ctx, str))
libxml2.registerErrorHandler(callback, "")
#
# Resolver callback
#
resources = {}
def resolver(URL, ID, ctxt):
global resources
if string.find(URL, '#') != -1:
URL = URL[0:string.find(URL, '#')]
if resources.has_key(URL):
return(StringIO.StringIO(resources[URL]))
log.write("Resolver failure: asked %s\n" % (URL))
log.write("resources: %s\n" % (resources))
return None
#
# Load the previous results
#
#results = {}
#previous = {}
#
#try:
# res = libxml2.parseFile(RES)
#except:
# log.write("Could not parse %s" % (RES))
#
# handle a valid instance
#
def handle_valid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nFailed to parse correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
return
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
except:
ret = -1
if ret != 0:
log.write("\nFailed to validate correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
doc.freeDoc()
#
# handle an invalid instance
#
def handle_invalid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
return
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
except:
ret = -1
if ret == 0:
log.write("\nFailed to detect validation problem in instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
doc.freeDoc()
#
# handle an incorrect test
#
def handle_correct(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs == None:
log.write("\nFailed to compile correct schema:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
nb_schemas_success = nb_schemas_success + 1
return rngs
def handle_incorrect(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs != None:
log.write("\nFailed to detect schema error in:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
# log.write("\nSuccess detecting schema error in:\n-----\n")
# log.write(schema)
# log.write("\n-----\n")
nb_schemas_success = nb_schemas_success + 1
return None
#
# resource handling: keep a dictionary of URL->string mappings
#
def handle_resource(node, dir):
global resources
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
res = ""
child = node.children
while child != None:
if child.type != 'text':
res = res + child.serialize()
child = child.next
resources[name] = res
#
# dir handling: pseudo directory resources
#
def handle_dir(node, dir):
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, name)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, name)
#
# handle a testCase element
#
def handle_testCase(node):
global nb_schemas_tests
global nb_instances_tests
global resources
sections = node.xpathEval('string(section)')
log.write("\n ======== test %d line %d section %s ==========\n" % (
nb_schemas_tests, node.lineNo(), sections))
resources = {}
if debug:
print "test %d line %d" % (nb_schemas_tests, node.lineNo())
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, None)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, None)
tsts = node.xpathEval('incorrect')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
schema = handle_incorrect(tsts[0])
else:
tsts = node.xpathEval('correct')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <correct> example"% (node.lineNo())
schema = handle_correct(tsts[0])
else:
print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
nb_schemas_tests = nb_schemas_tests + 1;
valids = node.xpathEval('valid')
invalids = node.xpathEval('invalid')
nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
if schema != None:
for valid in valids:
handle_valid(valid, schema)
for invalid in invalids:
handle_invalid(invalid, schema)
#
# handle a testSuite element
#
def handle_testSuite(node, level = 0):
global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
global nb_instances_tests, nb_instances_success, nb_instances_failed
global quiet
if level >= 1:
old_schemas_tests = nb_schemas_tests
old_schemas_success = nb_schemas_success
old_schemas_failed = nb_schemas_failed
old_instances_tests = nb_instances_tests
old_instances_success = nb_instances_success
old_instances_failed = nb_instances_failed
docs = node.xpathEval('documentation')
authors = node.xpathEval('author')
if docs != []:
msg = ""
for doc in docs:
msg = msg + doc.content + " "
if authors != []:
msg = msg + "written by "
for author in authors:
msg = msg + author.content + " "
if quiet == 0:
print msg
sections = node.xpathEval('section')
if sections != [] and level <= 0:
msg = ""
for section in sections:
msg = msg + section.content + " "
if quiet == 0:
print "Tests for section %s" % (msg)
for test in node.xpathEval('testCase'):
handle_testCase(test)
for test in node.xpathEval('testSuite'):
handle_testSuite(test, level + 1)
if verbose and level >= 1 and sections != []:
msg = ""
for section in sections:
msg = msg + section.content + " "
print "Result of tests for section %s" % (msg)
if nb_schemas_tests != old_schemas_tests:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests - old_schemas_tests,
nb_schemas_success - old_schemas_success,
nb_schemas_failed - old_schemas_failed)
if nb_instances_tests != old_instances_tests:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests - old_instances_tests,
nb_instances_success - old_instances_success,
nb_instances_failed - old_instances_failed)
#
# Parse the conf file
#
libxml2.substituteEntitiesDefault(1);
testsuite = libxml2.parseFile(CONF)
libxml2.setEntityLoader(resolver)
root = testsuite.getRootElement()
if root.name != 'testSuite':
print "%s doesn't start with a testSuite element, aborting" % (CONF)
sys.exit(1)
if quiet == 0:
print "Running Relax NG testsuite"
handle_testSuite(root)
if quiet == 0:
print "\nTOTAL:\n"
if quiet == 0 or nb_schemas_failed != 0:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
if quiet == 0 or nb_instances_failed != 0:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests, nb_instances_success, nb_instances_failed)
testsuite.freeDoc()
# Memory debug specific
libxml2.relaxNGCleanupTypes()
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
if quiet == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()

@ -0,0 +1,418 @@
#!/usr/bin/python
import sys
import time
import os
import string
import StringIO
sys.path.insert(0, "python")
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
debug = 0
quiet = 1
#
# the testsuite description
#
CONF=os.path.join(os.path.dirname(__file__), "test/relaxng/testsuite.xml")
LOG="check-relaxng-test-suite2.log"
log = open(LOG, "w")
nb_schemas_tests = 0
nb_schemas_success = 0
nb_schemas_failed = 0
nb_instances_tests = 0
nb_instances_success = 0
nb_instances_failed = 0
libxml2.lineNumbersDefault(1)
#
# Resolver callback
#
resources = {}
def resolver(URL, ID, ctxt):
global resources
if resources.has_key(URL):
return(StringIO.StringIO(resources[URL]))
log.write("Resolver failure: asked %s\n" % (URL))
log.write("resources: %s\n" % (resources))
return None
#
# Load the previous results
#
#results = {}
#previous = {}
#
#try:
# res = libxml2.parseFile(RES)
#except:
# log.write("Could not parse %s" % (RES))
#
# handle a valid instance
#
def handle_valid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = node.prop("dtd")
if instance == None:
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
# mem = libxml2.debugMemory(1);
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nFailed to parse correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
return
if debug:
print "instance line %d" % (node.lineNo())
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
del ctxt
except:
ret = -1
doc.freeDoc()
# if mem != libxml2.debugMemory(1):
# print "validating instance %d line %d leaks" % (
# nb_instances_tests, node.lineNo())
if ret != 0:
log.write("\nFailed to validate correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
#
# handle an invalid instance
#
def handle_invalid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = node.prop("dtd")
if instance == None:
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
# mem = libxml2.debugMemory(1);
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
return
if debug:
print "instance line %d" % (node.lineNo())
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
del ctxt
except:
ret = -1
doc.freeDoc()
# mem2 = libxml2.debugMemory(1)
# if mem != mem2:
# print "validating instance %d line %d leaks %d bytes" % (
# nb_instances_tests, node.lineNo(), mem2 - mem)
if ret == 0:
log.write("\nFailed to detect validation problem in instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
#
# handle an incorrect test
#
def handle_correct(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs == None:
log.write("\nFailed to compile correct schema:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
nb_schemas_success = nb_schemas_success + 1
return rngs
def handle_incorrect(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs != None:
log.write("\nFailed to detect schema error in:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
# log.write("\nSuccess detecting schema error in:\n-----\n")
# log.write(schema)
# log.write("\n-----\n")
nb_schemas_success = nb_schemas_success + 1
return None
#
# resource handling: keep a dictionary of URL->string mappings
#
def handle_resource(node, dir):
global resources
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
res = ""
child = node.children
while child != None:
if child.type != 'text':
res = res + child.serialize()
child = child.next
resources[name] = res
#
# dir handling: pseudo directory resources
#
def handle_dir(node, dir):
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, name)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, name)
#
# handle a testCase element
#
def handle_testCase(node):
global nb_schemas_tests
global nb_instances_tests
global resources
sections = node.xpathEval('string(section)')
log.write("\n ======== test %d line %d section %s ==========\n" % (
nb_schemas_tests, node.lineNo(), sections))
resources = {}
if debug:
print "test %d line %d" % (nb_schemas_tests, node.lineNo())
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, None)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, None)
tsts = node.xpathEval('incorrect')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
schema = handle_incorrect(tsts[0])
else:
tsts = node.xpathEval('correct')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <correct> example"% (node.lineNo())
schema = handle_correct(tsts[0])
else:
print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
nb_schemas_tests = nb_schemas_tests + 1;
valids = node.xpathEval('valid')
invalids = node.xpathEval('invalid')
nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
if schema != None:
for valid in valids:
handle_valid(valid, schema)
for invalid in invalids:
handle_invalid(invalid, schema)
#
# handle a testSuite element
#
def handle_testSuite(node, level = 0):
global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
global nb_instances_tests, nb_instances_success, nb_instances_failed
if level >= 1:
old_schemas_tests = nb_schemas_tests
old_schemas_success = nb_schemas_success
old_schemas_failed = nb_schemas_failed
old_instances_tests = nb_instances_tests
old_instances_success = nb_instances_success
old_instances_failed = nb_instances_failed
docs = node.xpathEval('documentation')
authors = node.xpathEval('author')
if docs != []:
msg = ""
for doc in docs:
msg = msg + doc.content + " "
if authors != []:
msg = msg + "written by "
for author in authors:
msg = msg + author.content + " "
if quiet == 0:
print msg
sections = node.xpathEval('section')
if sections != [] and level <= 0:
msg = ""
for section in sections:
msg = msg + section.content + " "
if quiet == 0:
print "Tests for section %s" % (msg)
for test in node.xpathEval('testCase'):
handle_testCase(test)
for test in node.xpathEval('testSuite'):
handle_testSuite(test, level + 1)
if level >= 1 and sections != []:
msg = ""
for section in sections:
msg = msg + section.content + " "
print "Result of tests for section %s" % (msg)
if nb_schemas_tests != old_schemas_tests:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests - old_schemas_tests,
nb_schemas_success - old_schemas_success,
nb_schemas_failed - old_schemas_failed)
if nb_instances_tests != old_instances_tests:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests - old_instances_tests,
nb_instances_success - old_instances_success,
nb_instances_failed - old_instances_failed)
#
# Parse the conf file
#
libxml2.substituteEntitiesDefault(1);
testsuite = libxml2.parseFile(CONF)
#
# Error and warnng callbacks
#
def callback(ctx, str):
global log
log.write("%s%s" % (ctx, str))
libxml2.registerErrorHandler(callback, "")
libxml2.setEntityLoader(resolver)
root = testsuite.getRootElement()
if root.name != 'testSuite':
print "%s doesn't start with a testSuite element, aborting" % (CONF)
sys.exit(1)
if quiet == 0:
print "Running Relax NG testsuite"
handle_testSuite(root)
if quiet == 0:
print "\nTOTAL:\n"
if quiet == 0 or nb_schemas_failed != 0:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
if quiet == 0 or nb_instances_failed != 0:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests, nb_instances_success, nb_instances_failed)
testsuite.freeDoc()
# Memory debug specific
libxml2.relaxNGCleanupTypes()
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
if quiet == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()

@ -0,0 +1,221 @@
#!/usr/bin/python
import sys
import time
import os
import string
sys.path.insert(0, "python")
import libxml2
#
# the testsuite description
#
DIR="xinclude-test-suite"
CONF="testdescr.xml"
LOG="check-xinclude-test-suite.log"
log = open(LOG, "w")
os.chdir(DIR)
test_nr = 0
test_succeed = 0
test_failed = 0
test_error = 0
#
# Error and warning handlers
#
error_nr = 0
error_msg = ''
def errorHandler(ctx, str):
global error_nr
global error_msg
if string.find(str, "error:") >= 0:
error_nr = error_nr + 1
if len(error_msg) < 300:
if len(error_msg) == 0 or error_msg[-1] == '\n':
error_msg = error_msg + " >>" + str
else:
error_msg = error_msg + str
libxml2.registerErrorHandler(errorHandler, None)
def testXInclude(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
print "testXInclude(%s, %s)" % (filename, id)
return 1
def runTest(test, basedir):
global test_nr
global test_failed
global test_error
global test_succeed
global error_msg
global log
fatal_error = 0
uri = test.prop('href')
id = test.prop('id')
type = test.prop('type')
if uri == None:
print "Test without ID:", uri
return -1
if id == None:
print "Test without URI:", id
return -1
if type == None:
print "Test without URI:", id
return -1
if basedir != None:
URI = basedir + "/" + uri
else:
URI = uri
if os.access(URI, os.R_OK) == 0:
print "Test %s missing: base %s uri %s" % (URI, basedir, uri)
return -1
expected = None
outputfile = None
diff = None
if type != 'error':
output = test.xpathEval('string(output)')
if output == 'No output file.':
output = None
if output == '':
output = None
if output != None:
if basedir != None:
output = basedir + "/" + output
if os.access(output, os.R_OK) == 0:
print "Result for %s missing: %s" % (id, output)
output = None
else:
try:
f = open(output)
expected = f.read()
outputfile = output
except:
print "Result for %s unreadable: %s" % (id, output)
try:
# print "testing %s" % (URI)
doc = libxml2.parseFile(URI)
except:
doc = None
if doc != None:
res = doc.xincludeProcess()
if res >= 0 and expected != None:
result = doc.serialize()
if result != expected:
print "Result for %s differs" % (id)
open("xinclude.res", "w").write(result)
diff = os.popen("diff %s xinclude.res" % outputfile).read()
doc.freeDoc()
else:
print "Failed to parse %s" % (URI)
res = -1
test_nr = test_nr + 1
if type == 'success':
if res > 0:
test_succeed = test_succeed + 1
elif res == 0:
test_failed = test_failed + 1
print "Test %s: no substitution done ???" % (id)
elif res < 0:
test_error = test_error + 1
print "Test %s: failed valid XInclude processing" % (id)
elif type == 'error':
if res > 0:
test_error = test_error + 1
print "Test %s: failed to detect invalid XInclude processing" % (id)
elif res == 0:
test_failed = test_failed + 1
print "Test %s: Invalid but no substitution done" % (id)
elif res < 0:
test_succeed = test_succeed + 1
elif type == 'optional':
if res > 0:
test_succeed = test_succeed + 1
else:
print "Test %s: failed optional test" % (id)
# Log the ontext
if res != 1:
log.write("Test ID %s\n" % (id))
log.write(" File: %s\n" % (URI))
content = string.strip(test.content)
while content[-1] == '\n':
content = content[0:-1]
log.write(" %s:%s\n\n" % (type, content))
if error_msg != '':
log.write(" ----\n%s ----\n" % (error_msg))
error_msg = ''
log.write("\n")
if diff != None:
log.write("diff from test %s:\n" %(id))
log.write(" -----------\n%s\n -----------\n" % (diff));
return 0
def runTestCases(case):
creator = case.prop('creator')
if creator != None:
print "=>", creator
base = case.getBase(None)
basedir = case.prop('basedir')
if basedir != None:
base = libxml2.buildURI(basedir, base)
test = case.children
while test != None:
if test.name == 'testcase':
runTest(test, base)
if test.name == 'testcases':
runTestCases(test)
test = test.next
conf = libxml2.parseFile(CONF)
if conf == None:
print "Unable to load %s" % CONF
sys.exit(1)
testsuite = conf.getRootElement()
if testsuite.name != 'testsuite':
print "Expecting TESTSUITE root element: aborting"
sys.exit(1)
profile = testsuite.prop('PROFILE')
if profile != None:
print profile
start = time.time()
case = testsuite.children
while case != None:
if case.name == 'testcases':
old_test_nr = test_nr
old_test_succeed = test_succeed
old_test_failed = test_failed
old_test_error = test_error
runTestCases(case)
print " Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
test_nr - old_test_nr, test_succeed - old_test_succeed,
test_failed - old_test_failed, test_error - old_test_error)
case = case.next
conf.freeDoc()
log.close()
print "Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
test_nr, test_succeed, test_failed, test_error, time.time() - start)

@ -0,0 +1,409 @@
#!/usr/bin/python
import sys
import time
import os
import string
sys.path.insert(0, "python")
import libxml2
test_nr = 0
test_succeed = 0
test_failed = 0
test_error = 0
#
# the testsuite description
#
CONF="xml-test-suite/xmlconf/xmlconf.xml"
LOG="check-xml-test-suite.log"
log = open(LOG, "w")
#
# Error and warning handlers
#
error_nr = 0
error_msg = ''
def errorHandler(ctx, str):
global error_nr
global error_msg
error_nr = error_nr + 1
if len(error_msg) < 300:
if len(error_msg) == 0 or error_msg[-1] == '\n':
error_msg = error_msg + " >>" + str
else:
error_msg = error_msg + str
libxml2.registerErrorHandler(errorHandler, None)
#warning_nr = 0
#warning = ''
#def warningHandler(ctx, str):
# global warning_nr
# global warning
#
# warning_nr = warning_nr + 1
# warning = warning + str
#
#libxml2.registerWarningHandler(warningHandler, None)
#
# Used to load the XML testsuite description
#
def loadNoentDoc(filename):
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return None
ctxt.replaceEntities(1)
ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if ctxt.wellFormed() != 1:
doc.freeDoc()
return None
return doc
#
# The conformance testing routines
#
def testNotWf(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if doc != None:
doc.freeDoc()
if ret == 0 or ctxt.wellFormed() != 0:
print "%s: error: Well Formedness error not detected" % (id)
log.write("%s: error: Well Formedness error not detected\n" % (id))
return 0
return 1
def testNotWfEnt(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.replaceEntities(1)
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if doc != None:
doc.freeDoc()
if ret == 0 or ctxt.wellFormed() != 0:
print "%s: error: Well Formedness error not detected" % (id)
log.write("%s: error: Well Formedness error not detected\n" % (id))
return 0
return 1
def testNotWfEntDtd(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.replaceEntities(1)
ctxt.loadSubset(1)
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if doc != None:
doc.freeDoc()
if ret == 0 or ctxt.wellFormed() != 0:
print "%s: error: Well Formedness error not detected" % (id)
log.write("%s: error: Well Formedness error not detected\n" % (id))
return 0
return 1
def testWfEntDtd(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.replaceEntities(1)
ctxt.loadSubset(1)
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if doc == None or ret != 0 or ctxt.wellFormed() == 0:
print "%s: error: wrongly failed to parse the document" % (id)
log.write("%s: error: wrongly failed to parse the document\n" % (id))
if doc != None:
doc.freeDoc()
return 0
if error_nr != 0:
print "%s: warning: WF document generated an error msg" % (id)
log.write("%s: error: WF document generated an error msg\n" % (id))
doc.freeDoc()
return 2
doc.freeDoc()
return 1
def testError(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.replaceEntities(1)
ctxt.loadSubset(1)
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
if doc != None:
doc.freeDoc()
if ctxt.wellFormed() == 0:
print "%s: warning: failed to parse the document but accepted" % (id)
log.write("%s: warning: failed to parse the document but accepte\n" % (id))
return 2
if error_nr != 0:
print "%s: warning: WF document generated an error msg" % (id)
log.write("%s: error: WF document generated an error msg\n" % (id))
return 2
return 1
def testInvalid(filename, id):
global error_nr
global error_msg
global log
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.validate(1)
ret = ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
valid = ctxt.isValid()
if doc == None:
print "%s: error: wrongly failed to parse the document" % (id)
log.write("%s: error: wrongly failed to parse the document\n" % (id))
return 0
if valid == 1:
print "%s: error: Validity error not detected" % (id)
log.write("%s: error: Validity error not detected\n" % (id))
doc.freeDoc()
return 0
if error_nr == 0:
print "%s: warning: Validity error not reported" % (id)
log.write("%s: warning: Validity error not reported\n" % (id))
doc.freeDoc()
return 2
doc.freeDoc()
return 1
def testValid(filename, id):
global error_nr
global error_msg
error_nr = 0
error_msg = ''
ctxt = libxml2.createFileParserCtxt(filename)
if ctxt == None:
return -1
ctxt.validate(1)
ctxt.parseDocument()
try:
doc = ctxt.doc()
except:
doc = None
valid = ctxt.isValid()
if doc == None:
print "%s: error: wrongly failed to parse the document" % (id)
log.write("%s: error: wrongly failed to parse the document\n" % (id))
return 0
if valid != 1:
print "%s: error: Validity check failed" % (id)
log.write("%s: error: Validity check failed\n" % (id))
doc.freeDoc()
return 0
if error_nr != 0 or valid != 1:
print "%s: warning: valid document reported an error" % (id)
log.write("%s: warning: valid document reported an error\n" % (id))
doc.freeDoc()
return 2
doc.freeDoc()
return 1
def runTest(test):
global test_nr
global test_succeed
global test_failed
global error_msg
global log
uri = test.prop('URI')
id = test.prop('ID')
if uri == None:
print "Test without ID:", uri
return -1
if id == None:
print "Test without URI:", id
return -1
base = test.getBase(None)
URI = libxml2.buildURI(uri, base)
if os.access(URI, os.R_OK) == 0:
print "Test %s missing: base %s uri %s" % (URI, base, uri)
return -1
type = test.prop('TYPE')
if type == None:
print "Test %s missing TYPE" % (id)
return -1
extra = None
if type == "invalid":
res = testInvalid(URI, id)
elif type == "valid":
res = testValid(URI, id)
elif type == "not-wf":
extra = test.prop('ENTITIES')
# print URI
#if extra == None:
# res = testNotWfEntDtd(URI, id)
#elif extra == 'none':
# res = testNotWf(URI, id)
#elif extra == 'general':
# res = testNotWfEnt(URI, id)
#elif extra == 'both' or extra == 'parameter':
res = testNotWfEntDtd(URI, id)
#else:
# print "Unknown value %s for an ENTITIES test value" % (extra)
# return -1
elif type == "error":
res = testError(URI, id)
else:
# TODO skipped for now
return -1
test_nr = test_nr + 1
if res > 0:
test_succeed = test_succeed + 1
elif res == 0:
test_failed = test_failed + 1
elif res < 0:
test_error = test_error + 1
# Log the ontext
if res != 1:
log.write(" File: %s\n" % (URI))
content = string.strip(test.content)
while content[-1] == '\n':
content = content[0:-1]
if extra != None:
log.write(" %s:%s:%s\n" % (type, extra, content))
else:
log.write(" %s:%s\n\n" % (type, content))
if error_msg != '':
log.write(" ----\n%s ----\n" % (error_msg))
error_msg = ''
log.write("\n")
return 0
def runTestCases(case):
profile = case.prop('PROFILE')
if profile != None and \
string.find(profile, "IBM XML Conformance Test Suite - Production") < 0:
print "=>", profile
test = case.children
while test != None:
if test.name == 'TEST':
runTest(test)
if test.name == 'TESTCASES':
runTestCases(test)
test = test.next
conf = loadNoentDoc(CONF)
if conf == None:
print "Unable to load %s" % CONF
sys.exit(1)
testsuite = conf.getRootElement()
if testsuite.name != 'TESTSUITE':
print "Expecting TESTSUITE root element: aborting"
sys.exit(1)
profile = testsuite.prop('PROFILE')
if profile != None:
print profile
start = time.time()
case = testsuite.children
while case != None:
if case.name == 'TESTCASES':
old_test_nr = test_nr
old_test_succeed = test_succeed
old_test_failed = test_failed
old_test_error = test_error
runTestCases(case)
print " Ran %d tests: %d succeeded, %d failed and %d generated an error" % (
test_nr - old_test_nr, test_succeed - old_test_succeed,
test_failed - old_test_failed, test_error - old_test_error)
case = case.next
conf.freeDoc()
log.close()
print "Ran %d tests: %d succeeded, %d failed and %d generated an error in %.2f s." % (
test_nr, test_succeed, test_failed, test_error, time.time() - start)

@ -0,0 +1,420 @@
#!/usr/bin/python
import sys
import time
import os
import string
import StringIO
sys.path.insert(0, "python")
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
debug = 0
verbose = 0
quiet = 1
#
# the testsuite description
#
CONF=os.path.join(os.path.dirname(__file__), "test/xsdtest/xsdtestsuite.xml")
LOG="check-xsddata-test-suite.log"
log = open(LOG, "w")
nb_schemas_tests = 0
nb_schemas_success = 0
nb_schemas_failed = 0
nb_instances_tests = 0
nb_instances_success = 0
nb_instances_failed = 0
libxml2.lineNumbersDefault(1)
#
# Error and warnng callbacks
#
def callback(ctx, str):
global log
log.write("%s%s" % (ctx, str))
libxml2.registerErrorHandler(callback, "")
#
# Resolver callback
#
resources = {}
def resolver(URL, ID, ctxt):
global resources
if resources.has_key(URL):
return(StringIO.StringIO(resources[URL]))
log.write("Resolver failure: asked %s\n" % (URL))
log.write("resources: %s\n" % (resources))
return None
#
# handle a valid instance
#
def handle_valid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = node.prop("dtd")
if instance == None:
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
mem = libxml2.debugMemory(1);
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nFailed to parse correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
return
if debug:
print "instance line %d" % (node.lineNo())
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
del ctxt
except:
ret = -1
doc.freeDoc()
if mem != libxml2.debugMemory(1):
print "validating instance %d line %d leaks" % (
nb_instances_tests, node.lineNo())
if ret != 0:
log.write("\nFailed to validate correct instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
#
# handle an invalid instance
#
def handle_invalid(node, schema):
global log
global nb_instances_success
global nb_instances_failed
instance = node.prop("dtd")
if instance == None:
instance = ""
child = node.children
while child != None:
if child.type != 'text':
instance = instance + child.serialize()
child = child.next
# mem = libxml2.debugMemory(1);
try:
doc = libxml2.parseDoc(instance)
except:
doc = None
if doc == None:
log.write("\nStrange: failed to parse incorrect instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
return
if debug:
print "instance line %d" % (node.lineNo())
try:
ctxt = schema.relaxNGNewValidCtxt()
ret = doc.relaxNGValidateDoc(ctxt)
del ctxt
except:
ret = -1
doc.freeDoc()
# if mem != libxml2.debugMemory(1):
# print "validating instance %d line %d leaks" % (
# nb_instances_tests, node.lineNo())
if ret == 0:
log.write("\nFailed to detect validation problem in instance:\n-----\n")
log.write(instance)
log.write("\n-----\n")
nb_instances_failed = nb_instances_failed + 1
else:
nb_instances_success = nb_instances_success + 1
#
# handle an incorrect test
#
def handle_correct(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs == None:
log.write("\nFailed to compile correct schema:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
nb_schemas_success = nb_schemas_success + 1
return rngs
def handle_incorrect(node):
global log
global nb_schemas_success
global nb_schemas_failed
schema = ""
child = node.children
while child != None:
if child.type != 'text':
schema = schema + child.serialize()
child = child.next
try:
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
rngs = rngp.relaxNGParse()
except:
rngs = None
if rngs != None:
log.write("\nFailed to detect schema error in:\n-----\n")
log.write(schema)
log.write("\n-----\n")
nb_schemas_failed = nb_schemas_failed + 1
else:
# log.write("\nSuccess detecting schema error in:\n-----\n")
# log.write(schema)
# log.write("\n-----\n")
nb_schemas_success = nb_schemas_success + 1
return None
#
# resource handling: keep a dictionary of URL->string mappings
#
def handle_resource(node, dir):
global resources
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
res = ""
child = node.children
while child != None:
if child.type != 'text':
res = res + child.serialize()
child = child.next
resources[name] = res
#
# dir handling: pseudo directory resources
#
def handle_dir(node, dir):
try:
name = node.prop('name')
except:
name = None
if name == None or name == '':
log.write("resource has no name")
return;
if dir != None:
# name = libxml2.buildURI(name, dir)
name = dir + '/' + name
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, name)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, name)
#
# handle a testCase element
#
def handle_testCase(node):
global nb_schemas_tests
global nb_instances_tests
global resources
sections = node.xpathEval('string(section)')
log.write("\n ======== test %d line %d section %s ==========\n" % (
nb_schemas_tests, node.lineNo(), sections))
resources = {}
if debug:
print "test %d line %d" % (nb_schemas_tests, node.lineNo())
dirs = node.xpathEval('dir')
for dir in dirs:
handle_dir(dir, None)
res = node.xpathEval('resource')
for r in res:
handle_resource(r, None)
tsts = node.xpathEval('incorrect')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <incorrect> example" %(node.lineNo())
schema = handle_incorrect(tsts[0])
else:
tsts = node.xpathEval('correct')
if tsts != []:
if len(tsts) != 1:
print "warning test line %d has more than one <correct> example"% (node.lineNo())
schema = handle_correct(tsts[0])
else:
print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo())
nb_schemas_tests = nb_schemas_tests + 1;
valids = node.xpathEval('valid')
invalids = node.xpathEval('invalid')
nb_instances_tests = nb_instances_tests + len(valids) + len(invalids)
if schema != None:
for valid in valids:
handle_valid(valid, schema)
for invalid in invalids:
handle_invalid(invalid, schema)
#
# handle a testSuite element
#
def handle_testSuite(node, level = 0):
global nb_schemas_tests, nb_schemas_success, nb_schemas_failed
global nb_instances_tests, nb_instances_success, nb_instances_failed
if verbose and level >= 0:
old_schemas_tests = nb_schemas_tests
old_schemas_success = nb_schemas_success
old_schemas_failed = nb_schemas_failed
old_instances_tests = nb_instances_tests
old_instances_success = nb_instances_success
old_instances_failed = nb_instances_failed
docs = node.xpathEval('documentation')
authors = node.xpathEval('author')
if docs != []:
msg = ""
for doc in docs:
msg = msg + doc.content + " "
if authors != []:
msg = msg + "written by "
for author in authors:
msg = msg + author.content + " "
if quiet == 0:
print msg
sections = node.xpathEval('section')
if verbose and sections != [] and level <= 0:
msg = ""
for section in sections:
msg = msg + section.content + " "
if quiet == 0:
print "Tests for section %s" % (msg)
for test in node.xpathEval('testCase'):
handle_testCase(test)
for test in node.xpathEval('testSuite'):
handle_testSuite(test, level + 1)
if verbose and level >= 0 :
if sections != []:
msg = ""
for section in sections:
msg = msg + section.content + " "
print "Result of tests for section %s" % (msg)
elif docs != []:
msg = ""
for doc in docs:
msg = msg + doc.content + " "
print "Result of tests for %s" % (msg)
if nb_schemas_tests != old_schemas_tests:
print "found %d test schemas: %d success %d failures" % (
nb_schemas_tests - old_schemas_tests,
nb_schemas_success - old_schemas_success,
nb_schemas_failed - old_schemas_failed)
if nb_instances_tests != old_instances_tests:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests - old_instances_tests,
nb_instances_success - old_instances_success,
nb_instances_failed - old_instances_failed)
#
# Parse the conf file
#
libxml2.substituteEntitiesDefault(1);
testsuite = libxml2.parseFile(CONF)
#
# Error and warnng callbacks
#
def callback(ctx, str):
global log
log.write("%s%s" % (ctx, str))
libxml2.registerErrorHandler(callback, "")
libxml2.setEntityLoader(resolver)
root = testsuite.getRootElement()
if root.name != 'testSuite':
print "%s doesn't start with a testSuite element, aborting" % (CONF)
sys.exit(1)
if quiet == 0:
print "Running Relax NG testsuite"
handle_testSuite(root)
if quiet == 0 or nb_schemas_failed != 0:
print "\nTOTAL:\nfound %d test schemas: %d success %d failures" % (
nb_schemas_tests, nb_schemas_success, nb_schemas_failed)
if quiet == 0 or nb_instances_failed != 0:
print "found %d test instances: %d success %d failures" % (
nb_instances_tests, nb_instances_success, nb_instances_failed)
testsuite.freeDoc()
# Memory debug specific
libxml2.relaxNGCleanupTypes()
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
if quiet == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()

@ -0,0 +1,336 @@
/*
* chvalid.c: this module implements the character range
* validation APIs
*
* This file is automatically generated from the cvs source
* definition files using the genChRanges.py Python script
*
* Generation date: Mon Mar 27 11:09:48 2006
* Sources: chvalid.def
* William Brack <wbrack@mmm.com.hk>
*/
#define IN_LIBXML
#include "libxml.h"
#include <libxml/chvalid.h>
/*
* The initial tables ({func_name}_tab) are used to validate whether a
* single-byte character is within the specified group. Each table
* contains 256 bytes, with each byte representing one of the 256
* possible characters. If the table byte is set, the character is
* allowed.
*
*/
const unsigned char xmlIsPubidChar_tab[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01,
0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
static const xmlChSRange xmlIsBaseChar_srng[] = { {0x100, 0x131},
{0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e}, {0x180, 0x1c3},
{0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217}, {0x250, 0x2a8},
{0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c},
{0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6}, {0x3da, 0x3da},
{0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3f3},
{0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c}, {0x45e, 0x481},
{0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc}, {0x4d0, 0x4eb},
{0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556}, {0x559, 0x559},
{0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
{0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be}, {0x6c0, 0x6ce},
{0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x905, 0x939},
{0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990},
{0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9},
{0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
{0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
{0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
{0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d}, {0xa8f, 0xa91},
{0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9},
{0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
{0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb36, 0xb39},
{0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb85, 0xb8a},
{0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
{0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
{0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
{0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
{0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
{0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10},
{0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xe01, 0xe2e},
{0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45}, {0xe81, 0xe82},
{0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d},
{0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5},
{0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae}, {0xeb0, 0xeb0},
{0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xf40, 0xf47},
{0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1100},
{0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109}, {0x110b, 0x110c},
{0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e}, {0x1140, 0x1140},
{0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150}, {0x1154, 0x1155},
{0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163}, {0x1165, 0x1165},
{0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e}, {0x1172, 0x1173},
{0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8}, {0x11ab, 0x11ab},
{0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba}, {0x11bc, 0x11c2},
{0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9}, {0x1e00, 0x1e9b},
{0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45},
{0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b},
{0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc},
{0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3},
{0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc},
{0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e}, {0x2180, 0x2182},
{0x3041, 0x3094}, {0x30a1, 0x30fa}, {0x3105, 0x312c}, {0xac00, 0xd7a3}};
const xmlChRangeGroup xmlIsBaseCharGroup =
{197, 0, xmlIsBaseChar_srng, (xmlChLRangePtr)0};
static const xmlChSRange xmlIsChar_srng[] = { {0x100, 0xd7ff},
{0xe000, 0xfffd}};
static const xmlChLRange xmlIsChar_lrng[] = { {0x10000, 0x10ffff}};
const xmlChRangeGroup xmlIsCharGroup =
{2, 1, xmlIsChar_srng, xmlIsChar_lrng};
static const xmlChSRange xmlIsCombining_srng[] = { {0x300, 0x345},
{0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
{0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
{0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df},
{0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903},
{0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954},
{0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be},
{0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
{0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c},
{0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48},
{0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc},
{0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03},
{0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d},
{0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8},
{0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44},
{0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83},
{0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
{0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
{0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e},
{0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd},
{0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39},
{0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b},
{0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7},
{0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f},
{0x3099, 0x3099}, {0x309a, 0x309a}};
const xmlChRangeGroup xmlIsCombiningGroup =
{95, 0, xmlIsCombining_srng, (xmlChLRangePtr)0};
static const xmlChSRange xmlIsDigit_srng[] = { {0x660, 0x669},
{0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
{0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
{0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
{0xf20, 0xf29}};
const xmlChRangeGroup xmlIsDigitGroup =
{14, 0, xmlIsDigit_srng, (xmlChLRangePtr)0};
static const xmlChSRange xmlIsExtender_srng[] = { {0x2d0, 0x2d0},
{0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640}, {0xe46, 0xe46},
{0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035}, {0x309d, 0x309e},
{0x30fc, 0x30fe}};
const xmlChRangeGroup xmlIsExtenderGroup =
{10, 0, xmlIsExtender_srng, (xmlChLRangePtr)0};
static const xmlChSRange xmlIsIdeographic_srng[] = { {0x3007, 0x3007},
{0x3021, 0x3029}, {0x4e00, 0x9fa5}};
const xmlChRangeGroup xmlIsIdeographicGroup =
{3, 0, xmlIsIdeographic_srng, (xmlChLRangePtr)0};
/**
* xmlCharInRange:
* @val: character to be validated
* @rptr: pointer to range to be used to validate
*
* Does a binary search of the range table to determine if char
* is valid
*
* Returns: true if character valid, false otherwise
*/
int
xmlCharInRange (unsigned int val, const xmlChRangeGroup *rptr) {
int low, high, mid;
const xmlChSRange *sptr;
const xmlChLRange *lptr;
if (rptr == NULL) return(0);
if (val < 0x10000) { /* is val in 'short' or 'long' array? */
if (rptr->nbShortRange == 0)
return 0;
low = 0;
high = rptr->nbShortRange - 1;
sptr = rptr->shortRange;
while (low <= high) {
mid = (low + high) / 2;
if ((unsigned short) val < sptr[mid].low) {
high = mid - 1;
} else {
if ((unsigned short) val > sptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
} else {
if (rptr->nbLongRange == 0) {
return 0;
}
low = 0;
high = rptr->nbLongRange - 1;
lptr = rptr->longRange;
while (low <= high) {
mid = (low + high) / 2;
if (val < lptr[mid].low) {
high = mid - 1;
} else {
if (val > lptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
}
return 0;
}
/**
* xmlIsBaseChar:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsBaseChar_ch or xmlIsBaseCharQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsBaseChar(unsigned int ch) {
return(xmlIsBaseCharQ(ch));
}
/**
* xmlIsBlank:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsBlank_ch or xmlIsBlankQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsBlank(unsigned int ch) {
return(xmlIsBlankQ(ch));
}
/**
* xmlIsChar:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsChar_ch or xmlIsCharQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsChar(unsigned int ch) {
return(xmlIsCharQ(ch));
}
/**
* xmlIsCombining:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsCombiningQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsCombining(unsigned int ch) {
return(xmlIsCombiningQ(ch));
}
/**
* xmlIsDigit:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsDigit_ch or xmlIsDigitQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsDigit(unsigned int ch) {
return(xmlIsDigitQ(ch));
}
/**
* xmlIsExtender:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsExtender_ch or xmlIsExtenderQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsExtender(unsigned int ch) {
return(xmlIsExtenderQ(ch));
}
/**
* xmlIsIdeographic:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsIdeographicQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsIdeographic(unsigned int ch) {
return(xmlIsIdeographicQ(ch));
}
/**
* xmlIsPubidChar:
* @ch: character to validate
*
* This function is DEPRECATED.
* Use xmlIsPubidChar_ch or xmlIsPubidCharQ instead
*
* Returns true if argument valid, false otherwise
*/
int
xmlIsPubidChar(unsigned int ch) {
return(xmlIsPubidCharQ(ch));
}
#define bottom_chvalid
#include "elfgcchack.h"

@ -0,0 +1,361 @@
name xmlIsChar
ur 0x9
ur 0xA
ur 0xD
ur 0x20..0xFF
ur 0x0100..0xD7FF
ur 0xE000..0xFFFD
ur 0x10000..0x10FFFF
end xmlIsChar
name xmlIsPubidChar
ur 0x20 0x0d 0x0a 'a'..'z' 'A'..'Z' '0'..'9'
ur '-' 0x27 '(' ')' '+' ',' '.' '/'
ur ':' '=' '?' ';' '!' '*' '#' '@'
ur '$' '_' '%'
end
name xmlIsBlank
ur 0x09 0x0a 0x0d 0x20
end xmlIsBlank
name xmlIsBaseChar
ur 0x0041..0x005A
ur 0x0061..0x007A
ur 0x00C0..0x00D6
ur 0x00D8..0x00F6
ur 0x00F8..0x00FF
ur 0x0100..0x0131
ur 0x0134..0x013E
ur 0x0141..0x0148
ur 0x014A..0x017E
ur 0x0180..0x01C3
ur 0x01CD..0x01F0
ur 0x01F4..0x01F5
ur 0x01FA..0x0217
ur 0x0250..0x02A8
ur 0x02BB..0x02C1
ur 0x0386
ur 0x0388..0x038A
ur 0x038C
ur 0x038E..0x03A1
ur 0x03A3..0x03CE
ur 0x03D0..0x03D6
ur 0x03DA
ur 0x03DC
ur 0x03DE
ur 0x03E0
ur 0x03E2..0x03F3
ur 0x0401..0x040C
ur 0x040E..0x044F
ur 0x0451..0x045C
ur 0x045E..0x0481
ur 0x0490..0x04C4
ur 0x04C7..0x04C8
ur 0x04CB..0x04CC
ur 0x04D0..0x04EB
ur 0x04EE..0x04F5
ur 0x04F8..0x04F9
ur 0x0531..0x0556
ur 0x0559
ur 0x0561..0x0586
ur 0x05D0..0x05EA
ur 0x05F0..0x05F2
ur 0x0621..0x063A
ur 0x0641..0x064A
ur 0x0671..0x06B7
ur 0x06BA..0x06BE
ur 0x06C0..0x06CE
ur 0x06D0..0x06D3
ur 0x06D5
ur 0x06E5..0x06E6
ur 0x0905..0x0939
ur 0x093D
ur 0x0958..0x0961
ur 0x0985..0x098C
ur 0x098F..0x0990
ur 0x0993..0x09A8
ur 0x09AA..0x09B0
ur 0x09B2
ur 0x09B6..0x09B9
ur 0x09DC..0x09DD
ur 0x09DF..0x09E1
ur 0x09F0..0x09F1
ur 0x0A05..0x0A0A
ur 0x0A0F..0x0A10
ur 0x0A13..0x0A28
ur 0x0A2A..0x0A30
ur 0x0A32..0x0A33
ur 0x0A35..0x0A36
ur 0x0A38..0x0A39
ur 0x0A59..0x0A5C
ur 0x0A5E
ur 0x0A72..0x0A74
ur 0x0A85..0x0A8B
ur 0x0A8D
ur 0x0A8F..0x0A91
ur 0x0A93..0x0AA8
ur 0x0AAA..0x0AB0
ur 0x0AB2..0x0AB3
ur 0x0AB5..0x0AB9
ur 0x0ABD
ur 0x0AE0
ur 0x0B05..0x0B0C
ur 0x0B0F..0x0B10
ur 0x0B13..0x0B28
ur 0x0B2A..0x0B30
ur 0x0B32..0x0B33
ur 0x0B36..0x0B39
ur 0x0B3D
ur 0x0B5C..0x0B5D
ur 0x0B5F..0x0B61
ur 0x0B85..0x0B8A
ur 0x0B8E..0x0B90
ur 0x0B92..0x0B95
ur 0x0B99..0x0B9A
ur 0x0B9C
ur 0x0B9E..0x0B9F
ur 0x0BA3..0x0BA4
ur 0x0BA8..0x0BAA
ur 0x0BAE..0x0BB5
ur 0x0BB7..0x0BB9
ur 0x0C05..0x0C0C
ur 0x0C0E..0x0C10
ur 0x0C12..0x0C28
ur 0x0C2A..0x0C33
ur 0x0C35..0x0C39
ur 0x0C60..0x0C61
ur 0x0C85..0x0C8C
ur 0x0C8E..0x0C90
ur 0x0C92..0x0CA8
ur 0x0CAA..0x0CB3
ur 0x0CB5..0x0CB9
ur 0x0CDE
ur 0x0CE0..0x0CE1
ur 0x0D05..0x0D0C
ur 0x0D0E..0x0D10
ur 0x0D12..0x0D28
ur 0x0D2A..0x0D39
ur 0x0D60..0x0D61
ur 0x0E01..0x0E2E
ur 0x0E30
ur 0x0E32..0x0E33
ur 0x0E40..0x0E45
ur 0x0E81..0x0E82
ur 0x0E84
ur 0x0E87..0x0E88
ur 0x0E8A
ur 0x0E8D
ur 0x0E94..0x0E97
ur 0x0E99..0x0E9F
ur 0x0EA1..0x0EA3
ur 0x0EA5
ur 0x0EA7
ur 0x0EAA..0x0EAB
ur 0x0EAD..0x0EAE
ur 0x0EB0
ur 0x0EB2..0x0EB3
ur 0x0EBD
ur 0x0EC0..0x0EC4
ur 0x0F40..0x0F47
ur 0x0F49..0x0F69
ur 0x10A0..0x10C5
ur 0x10D0..0x10F6
ur 0x1100
ur 0x1102..0x1103
ur 0x1105..0x1107
ur 0x1109
ur 0x110B..0x110C
ur 0x110E..0x1112
ur 0x113C
ur 0x113E
ur 0x1140
ur 0x114C
ur 0x114E
ur 0x1150
ur 0x1154..0x1155
ur 0x1159
ur 0x115F..0x1161
ur 0x1163
ur 0x1165
ur 0x1167
ur 0x1169
ur 0x116D..0x116E
ur 0x1172..0x1173
ur 0x1175
ur 0x119E
ur 0x11A8
ur 0x11AB
ur 0x11AE..0x11AF
ur 0x11B7..0x11B8
ur 0x11BA
ur 0x11BC..0x11C2
ur 0x11EB
ur 0x11F0
ur 0x11F9
ur 0x1E00..0x1E9B
ur 0x1EA0..0x1EF9
ur 0x1F00..0x1F15
ur 0x1F18..0x1F1D
ur 0x1F20..0x1F45
ur 0x1F48..0x1F4D
ur 0x1F50..0x1F57
ur 0x1F59
ur 0x1F5B
ur 0x1F5D
ur 0x1F5F..0x1F7D
ur 0x1F80..0x1FB4
ur 0x1FB6..0x1FBC
ur 0x1FBE
ur 0x1FC2..0x1FC4
ur 0x1FC6..0x1FCC
ur 0x1FD0..0x1FD3
ur 0x1FD6..0x1FDB
ur 0x1FE0..0x1FEC
ur 0x1FF2..0x1FF4
ur 0x1FF6..0x1FFC
ur 0x2126
ur 0x212A..0x212B
ur 0x212E
ur 0x2180..0x2182
ur 0x3041..0x3094
ur 0x30A1..0x30FA
ur 0x3105..0x312C
ur 0xAC00..0xD7A3
end xmlIsBaseChar
name xmlIsIdeographic
ur 0x4E00..0x9FA5
ur 0x3007
ur 0x3021..0x3029
end xmlIsIdeographic
name xmlIsCombining
ur 0x0300..0x0345
ur 0x0360..0x0361
ur 0x0483..0x0486
ur 0x0591..0x05A1
ur 0x05A3..0x05B9
ur 0x05BB..0x05BD
ur 0x05BF
ur 0x05C1..0x05C2
ur 0x05C4
ur 0x064B..0x0652
ur 0x0670
ur 0x06D6..0x06DC
ur 0x06DD..0x06DF
ur 0x06E0..0x06E4
ur 0x06E7..0x06E8
ur 0x06EA..0x06ED
ur 0x0901..0x0903
ur 0x093C
ur 0x093E..0x094C
ur 0x094D
ur 0x0951..0x0954
ur 0x0962..0x0963
ur 0x0981..0x0983
ur 0x09BC
ur 0x09BE
ur 0x09BF
ur 0x09C0..0x09C4
ur 0x09C7..0x09C8
ur 0x09CB..0x09CD
ur 0x09D7
ur 0x09E2..0x09E3
ur 0x0A02
ur 0x0A3C
ur 0x0A3E
ur 0x0A3F
ur 0x0A40..0x0A42
ur 0x0A47..0x0A48
ur 0x0A4B..0x0A4D
ur 0x0A70..0x0A71
ur 0x0A81..0x0A83
ur 0x0ABC
ur 0x0ABE..0x0AC5
ur 0x0AC7..0x0AC9
ur 0x0ACB..0x0ACD
ur 0x0B01..0x0B03
ur 0x0B3C
ur 0x0B3E..0x0B43
ur 0x0B47..0x0B48
ur 0x0B4B..0x0B4D
ur 0x0B56..0x0B57
ur 0x0B82..0x0B83
ur 0x0BBE..0x0BC2
ur 0x0BC6..0x0BC8
ur 0x0BCA..0x0BCD
ur 0x0BD7
ur 0x0C01..0x0C03
ur 0x0C3E..0x0C44
ur 0x0C46..0x0C48
ur 0x0C4A..0x0C4D
ur 0x0C55..0x0C56
ur 0x0C82..0x0C83
ur 0x0CBE..0x0CC4
ur 0x0CC6..0x0CC8
ur 0x0CCA..0x0CCD
ur 0x0CD5..0x0CD6
ur 0x0D02..0x0D03
ur 0x0D3E..0x0D43
ur 0x0D46..0x0D48
ur 0x0D4A..0x0D4D
ur 0x0D57
ur 0x0E31
ur 0x0E34..0x0E3A
ur 0x0E47..0x0E4E
ur 0x0EB1
ur 0x0EB4..0x0EB9
ur 0x0EBB..0x0EBC
ur 0x0EC8..0x0ECD
ur 0x0F18..0x0F19
ur 0x0F35
ur 0x0F37
ur 0x0F39
ur 0x0F3E
ur 0x0F3F
ur 0x0F71..0x0F84
ur 0x0F86..0x0F8B
ur 0x0F90..0x0F95
ur 0x0F97
ur 0x0F99..0x0FAD
ur 0x0FB1..0x0FB7
ur 0x0FB9
ur 0x20D0..0x20DC
ur 0x20E1
ur 0x302A..0x302F
ur 0x3099
ur 0x309A
end xmlIsCombining
name xmlIsDigit
ur 0x0030..0x0039
ur 0x0660..0x0669
ur 0x06F0..0x06F9
ur 0x0966..0x096F
ur 0x09E6..0x09EF
ur 0x0A66..0x0A6F
ur 0x0AE6..0x0AEF
ur 0x0B66..0x0B6F
ur 0x0BE7..0x0BEF
ur 0x0C66..0x0C6F
ur 0x0CE6..0x0CEF
ur 0x0D66..0x0D6F
ur 0x0E50..0x0E59
ur 0x0ED0..0x0ED9
ur 0x0F20..0x0F29
end xmlIsDigit
name xmlIsExtender
ur 0x00B7
ur 0x02D0
ur 0x02D1
ur 0x0387
ur 0x0640
ur 0x0E46
ur 0x0EC6
ur 0x3005
ur 0x3031..0x3035
ur 0x309D..0x309E
ur 0x30FC..0x30FE
end xmlIsExtender

@ -0,0 +1,288 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if __attribute__((destructor)) is accepted */
#cmakedefine ATTRIBUTE_DESTRUCTOR 1
/* Type cast for the gethostbyname() argument */
#cmakedefine GETHOSTBYNAME_ARG_CAST @GETHOSTBYNAME_ARG_CAST@
/* Define to 1 if you have the <arpa/inet.h> header file. */
#cmakedefine HAVE_ARPA_INET_H 1
/* Define to 1 if you have the <arpa/nameser.h> header file. */
#cmakedefine HAVE_ARPA_NAMESER_H 1
/* Whether struct sockaddr::__ss_family exists */
#cmakedefine HAVE_BROKEN_SS_FAMILY 1
/* Define to 1 if you have the <ctype.h> header file. */
#cmakedefine HAVE_CTYPE_H 1
/* Define to 1 if you have the <dirent.h> header file. */
#cmakedefine HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H 1
/* Have dlopen based dso */
#cmakedefine HAVE_DLOPEN 1
/* Define to 1 if you have the <dl.h> header file. */
#cmakedefine HAVE_DL_H 1
/* Define to 1 if you have the <errno.h> header file. */
#cmakedefine HAVE_ERRNO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H 1
/* Define to 1 if you have the <float.h> header file. */
#cmakedefine HAVE_FLOAT_H 1
/* Define to 1 if you have the `fprintf' function. */
#cmakedefine HAVE_FPRINTF 1
/* Define to 1 if you have the `ftime' function. */
#cmakedefine HAVE_FTIME 1
/* Define if getaddrinfo is there */
#cmakedefine HAVE_GETADDRINFO 1
/* Define to 1 if you have the `gettimeofday' function. */
#cmakedefine HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define to 1 if you have the `isascii' function. */
#cmakedefine HAVE_ISASCII 1
/* Define if isinf is there */
#cmakedefine HAVE_ISINF 1
/* Define if isnan is there */
#cmakedefine HAVE_ISNAN 1
/* Define if history library is there (-lhistory) */
#cmakedefine HAVE_LIBHISTORY 1
/* Define if pthread library is there (-lpthread) */
#cmakedefine HAVE_LIBPTHREAD 1
/* Define if readline library is there (-lreadline) */
#cmakedefine HAVE_LIBREADLINE 1
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H 1
/* Define to 1 if you have the `localtime' function. */
#cmakedefine HAVE_LOCALTIME 1
/* Define to 1 if you have the <lzma.h> header file. */
#cmakedefine HAVE_LZMA_H 1
/* Define to 1 if you have the <malloc.h> header file. */
#cmakedefine HAVE_MALLOC_H 1
/* Define to 1 if you have the <math.h> header file. */
#cmakedefine HAVE_MATH_H 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
#cmakedefine HAVE_MMAP 1
/* Define to 1 if you have the `munmap' function. */
#cmakedefine HAVE_MUNMAP 1
/* mmap() is no good without munmap() */
#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
# undef /**/ HAVE_MMAP
#endif
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_NDIR_H 1
/* Define to 1 if you have the <netdb.h> header file. */
#cmakedefine HAVE_NETDB_H 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#cmakedefine HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <poll.h> header file. */
#cmakedefine HAVE_POLL_H 1
/* Define to 1 if you have the `printf' function. */
#cmakedefine HAVE_PRINTF 1
/* Define if <pthread.h> is there */
#cmakedefine HAVE_PTHREAD_H 1
/* Define to 1 if you have the `putenv' function. */
#cmakedefine HAVE_PUTENV 1
/* Define to 1 if you have the `rand' function. */
#cmakedefine HAVE_RAND 1
/* Define to 1 if you have the `rand_r' function. */
#cmakedefine HAVE_RAND_R 1
/* Define to 1 if you have the <resolv.h> header file. */
#cmakedefine HAVE_RESOLV_H 1
/* Have shl_load based dso */
#cmakedefine HAVE_SHLLOAD 1
/* Define to 1 if you have the `signal' function. */
#cmakedefine HAVE_SIGNAL 1
/* Define to 1 if you have the <signal.h> header file. */
#cmakedefine HAVE_SIGNAL_H 1
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1
/* Define to 1 if you have the `sprintf' function. */
#cmakedefine HAVE_SPRINTF 1
/* Define to 1 if you have the `srand' function. */
#cmakedefine HAVE_SRAND 1
/* Define to 1 if you have the `sscanf' function. */
#cmakedefine HAVE_SSCANF 1
/* Define to 1 if you have the `stat' function. */
#cmakedefine HAVE_STAT 1
/* Define to 1 if you have the <stdarg.h> header file. */
#cmakedefine HAVE_STDARG_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define to 1 if you have the `strftime' function. */
#cmakedefine HAVE_STRFTIME 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#cmakedefine HAVE_SYS_DIR_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#cmakedefine HAVE_SYS_NDIR_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#cmakedefine HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#cmakedefine HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/timeb.h> header file. */
#cmakedefine HAVE_SYS_TIMEB_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the `time' function. */
#cmakedefine HAVE_TIME 1
/* Define to 1 if you have the <time.h> header file. */
#cmakedefine HAVE_TIME_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Whether va_copy() is available */
#cmakedefine HAVE_VA_COPY 1
/* Define to 1 if you have the `vfprintf' function. */
#cmakedefine HAVE_VFPRINTF 1
/* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine HAVE_VSNPRINTF 1
/* Define to 1 if you have the `vsprintf' function. */
#cmakedefine HAVE_VSPRINTF 1
/* Define to 1 if you have the <zlib.h> header file. */
#cmakedefine HAVE_ZLIB_H 1
/* Whether __va_copy() is available */
#cmakedefine HAVE___VA_COPY 1
/* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST @ICONV_CONST@
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#cmakedefine LT_OBJDIR "@LT_OBJDIR@"
/* Name of package */
#define PACKAGE "@PACKAGE@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@PACKAGE_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
/* Type cast for the send() function 2nd arg */
#cmakedefine SEND_ARG2_CAST @SEND_ARG2_CAST@
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS 1
/* Support for IPv6 */
#cmakedefine SUPPORT_IP6 1
/* Define if va_list is an array type */
#cmakedefine VA_LIST_IS_ARRAY 1
/* Version number of package */
#cmakedefine VERSION "@VERSION@"
/* Determine what socket length (socklen_t) data type is */
#cmakedefine XML_SOCKLEN_T @XML_SOCKLEN_T@
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#cmakedefine _UINT32_T @_UINT32_T@
/* ss_family is not defined here, use __ss_family instead */
#cmakedefine ss_family @ss_family@
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#cmakedefine uint32_t @uint32_t@

@ -0,0 +1,43 @@
#!/usr/bin/perl
$size = shift;
if ($size eq "")
{
die "usage: dbgen.pl [size]\n";
}
@firstnames = ("Al", "Bob", "Charles", "David", "Egon", "Farbood",
"George", "Hank", "Inki", "James");
@lastnames = ("Aranow", "Barker", "Corsetti", "Dershowitz", "Engleman",
"Franklin", "Grice", "Haverford", "Ilvedson", "Jones");
@states = ("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
print "<?xml version=\"1.0\"?>\n";
print "\n";
print "<table>\n";
for ($i=0; $i<$size; $i++)
{
$first = $firstnames [$i % 10];
$last = $lastnames [($i / 10) % 10];
$state = $states [($i / 100) % 50];
$zip = 22000 + $i / 5000;
printf " <row>\n";
printf " <id>%04d</id>\n", $i;
printf " <firstname>$first</firstname>\n", $i;
printf " <lastname>$last</lastname>\n", $i;
printf " <street>%d Any St.</street>\n", ($i % 100) + 1;
printf " <city>Anytown</city>\n";
printf " <state>$state</state>\n";
printf " <zip>%d</zip>\n", $zip;
printf " </row>\n";
}
print "</table>\n";

@ -0,0 +1,42 @@
#!/usr/bin/perl
$size = shift;
if ($size eq "")
{
die "usage: dbgen.pl [size]\n";
}
@firstnames = ("Al", "Bob", "Charles", "David", "Egon", "Farbood",
"George", "Hank", "Inki", "James");
@lastnames = ("Aranow", "Barker", "Corsetti", "Dershowitz", "Engleman",
"Franklin", "Grice", "Haverford", "Ilvedson", "Jones");
@states = ("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
print "<?xml version=\"1.0\"?>\n";
print "\n";
print "<table>\n";
for ($i=0; $i<$size; $i++)
{
$first = $firstnames [$i % 10];
$last = $lastnames [($i / 10) % 10];
$state = $states [($i / 100) % 50];
$zip = 22000 + $i / 5000;
printf " <row\n";
printf " id='%04d'\n", $i;
printf " firstname='$first'\n", $i;
printf " lastname='$last'\n", $i;
printf " street='%d Any St.'\n", ($i % 100) + 1;
printf " city='Anytown'\n";
printf " state='$state'\n";
printf " zip='%d'/>\n", $zip;
}
print "</table>\n";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save