http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/include/proton/url.h ---------------------------------------------------------------------- diff --git a/proton-c/include/proton/url.h b/proton-c/include/proton/url.h deleted file mode 100644 index e898aba..0000000 --- a/proton-c/include/proton/url.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef PROTON_URL_H -#define PROTON_URL_H 1 - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <proton/import_export.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * - * @copybrief url - * @deprecated - * - * @addtogroup url - * @{ - */ - -/** - * A parsed URL - */ -typedef struct pn_url_t pn_url_t; - -/** - * Create an empty URL - */ -PNX_EXTERN pn_url_t *pn_url(void); - -/** - * Parse a string URL as a pn_url_t. - * - * URL syntax: - * - * [ <scheme> :// ] [ <user> [ : <password> ] @ ] <host> [ : <port> ] [ / <path> ] - * - * `scheme`, `user`, `password`, `port` cannot contain any of '@', ':', '/' - * - * If the first character of `host` is '[' then it can contain any character up - * to ']' (this is to allow IPv6 literal syntax). Otherwise it also cannot - * contain '@', ':', '/' - * - * `path` can contain any character - * - * @param[in] url A URL string. - * @return The parsed pn_url_t or NULL if url is not a valid URL string. - */ -PNX_EXTERN pn_url_t *pn_url_parse(const char *url); - -/** - * Free a URL */ -PNX_EXTERN void pn_url_free(pn_url_t *url); - -/** - * Clear the contents of the URL. - */ -PNX_EXTERN void pn_url_clear(pn_url_t *url); - -/** - * Return the string form of a URL. - * - * The returned string is owned by the pn_url_t and will become - * invalid if it is modified. - */ -PNX_EXTERN const char *pn_url_str(pn_url_t *url); - -/** - * @name Getters for parts of the URL. - * - * Values belong to the URL. May return NULL if the value is not set. - * - * @{ - */ -PNX_EXTERN const char *pn_url_get_scheme(pn_url_t *url); -PNX_EXTERN const char *pn_url_get_username(pn_url_t *url); -PNX_EXTERN const char *pn_url_get_password(pn_url_t *url); -PNX_EXTERN const char *pn_url_get_host(pn_url_t *url); -PNX_EXTERN const char *pn_url_get_port(pn_url_t *url); -PNX_EXTERN const char *pn_url_get_path(pn_url_t *url); -/** - * @} - */ - -/** - * @name Setters for parts of the URL. - * - * Values are copied. Value can be NULL to indicate the part is not - * set. - * - * @{ - */ -PNX_EXTERN void pn_url_set_scheme(pn_url_t *url, const char *scheme); -PNX_EXTERN void pn_url_set_username(pn_url_t *url, const char *username); -PNX_EXTERN void pn_url_set_password(pn_url_t *url, const char *password); -PNX_EXTERN void pn_url_set_host(pn_url_t *url, const char *host); -PNX_EXTERN void pn_url_set_port(pn_url_t *url, const char *port); -PNX_EXTERN void pn_url_set_path(pn_url_t *url, const char *path); -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* url.h */
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/include/proton/version.h.in ---------------------------------------------------------------------- diff --git a/proton-c/include/proton/version.h.in b/proton-c/include/proton/version.h.in deleted file mode 100644 index 133b0bb..0000000 --- a/proton-c/include/proton/version.h.in +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _PROTON_VERSION_H -#define _PROTON_VERSION_H 1 - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#define PN_VERSION_MAJOR @PN_VERSION_MAJOR@ -#define PN_VERSION_MINOR @PN_VERSION_MINOR@ -#define PN_VERSION_POINT @PN_VERSION_POINT@ - -#endif /* version.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/mllib/__init__.py ---------------------------------------------------------------------- diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py deleted file mode 100644 index c0362cd..0000000 --- a/proton-c/mllib/__init__.py +++ /dev/null @@ -1,85 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -""" -This module provides document parsing and transformation utilities for XML. -""" - -from __future__ import absolute_import - -import os, sys -import xml.sax, types -from xml.sax.handler import ErrorHandler -from xml.sax.xmlreader import InputSource - -try: - from io import StringIO -except ImportError: - from cStringIO import StringIO - -if sys.version_info[0] == 2: - import types - CLASS_TYPES = (type, types.ClassType) -else: - CLASS_TYPES = (type,) - -from . import dom -from . import transforms -from . import parsers - -def transform(node, *args): - result = node - for t in args: - if isinstance(t, CLASS_TYPES): - t = t() - result = result.dispatch(t) - return result - -class Resolver: - - def __init__(self, path): - self.path = path - - def resolveEntity(self, publicId, systemId): - for p in self.path: - fname = os.path.join(p, systemId) - if os.path.exists(fname): - source = InputSource(systemId) - source.setByteStream(open(fname)) - return source - return InputSource(systemId) - -def xml_parse(filename, path=()): - if sys.version_info[0:2] == (2,3): - # XXX: this is for older versions of python - source = "file://%s" % os.path.abspath(filename) - else: - source = filename - h = parsers.XMLParser() - p = xml.sax.make_parser() - p.setContentHandler(h) - p.setErrorHandler(ErrorHandler()) - p.setEntityResolver(Resolver(path)) - p.parse(source) - return h.parser.tree - -def sexp(node): - s = transforms.Sexp() - node.dispatch(s) - return s.out http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/mllib/dom.py ---------------------------------------------------------------------- diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py deleted file mode 100644 index 9421504..0000000 --- a/proton-c/mllib/dom.py +++ /dev/null @@ -1,316 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -""" -Simple DOM for both SGML and XML documents. -""" - -from __future__ import division -from __future__ import generators -from __future__ import nested_scopes -from __future__ import absolute_import - -import sys -if sys.version_info[0] == 2: - STRING_TYPES = (basestring,) -else: - STRING_TYPES = (str,) - -class Container: - - def __init__(self): - self.children = [] - - def add(self, child): - child.parent = self - self.children.append(child) - - def extend(self, children): - for child in children: - child.parent = self - self.children.append(child) - -class Component: - - def __init__(self): - self.parent = None - - def index(self): - if self.parent: - return self.parent.children.index(self) - else: - return 0 - - def _line(self, file, line, column): - self.file = file - self.line = line - self.column = column - -class DispatchError(Exception): - - def __init__(self, scope, f): - msg = "no such attribtue" - -class Dispatcher: - - def is_type(self, type): - cls = self - while cls != None: - if cls.type == type: - return True - cls = cls.base - return False - - def dispatch(self, f, attrs = ""): - cls = self - while cls != None: - if hasattr(f, cls.type): - return getattr(f, cls.type)(self) - else: - cls = cls.base - - cls = self - while cls != None: - if attrs: - sep = ", " - if cls.base == None: - sep += "or " - else: - sep = "" - attrs += "%s'%s'" % (sep, cls.type) - cls = cls.base - - raise AttributeError("'%s' object has no attribute %s" % - (f.__class__.__name__, attrs)) - -class Node(Container, Component, Dispatcher): - - type = "node" - base = None - - def __init__(self): - Container.__init__(self) - Component.__init__(self) - self.query = Query([self]) - - def __getitem__(self, name): - for nd in self.query[name]: - return nd - - def text(self): - from . import transforms - return self.dispatch(transforms.Text()) - - def tag(self, name, *attrs, **kwargs): - t = Tag(name, *attrs, **kwargs) - self.add(t) - return t - - def data(self, s): - d = Data(s) - self.add(d) - return d - - def entity(self, s): - e = Entity(s) - self.add(e) - return e - -class Tree(Node): - - type = "tree" - base = Node - -class Tag(Node): - - type = "tag" - base = Node - - def __init__(self, _name, *attrs, **kwargs): - Node.__init__(self) - self.name = _name - self.attrs = list(attrs) - self.attrs.extend(kwargs.items()) - self.singleton = False - - def get_attr(self, name): - for k, v in self.attrs: - if name == k: - return v - - def _idx(self, attr): - idx = 0 - for k, v in self.attrs: - if k == attr: - return idx - idx += 1 - return None - - def set_attr(self, name, value): - idx = self._idx(name) - if idx is None: - self.attrs.append((name, value)) - else: - self.attrs[idx] = (name, value) - - def dispatch(self, f): - try: - attr = "do_" + self.name - method = getattr(f, attr) - except AttributeError: - return Dispatcher.dispatch(self, f, "'%s'" % attr) - return method(self) - -class Leaf(Component, Dispatcher): - - type = "leaf" - base = None - - def __init__(self, data): - assert isinstance(data, STRING_TYPES) - self.data = data - -class Data(Leaf): - type = "data" - base = Leaf - -class Entity(Leaf): - type = "entity" - base = Leaf - -class Character(Leaf): - type = "character" - base = Leaf - -class Comment(Leaf): - type = "comment" - base = Leaf - -################### -## Query Classes ## -########################################################################### - -class Adder: - - def __add__(self, other): - return Sum(self, other) - -class Sum(Adder): - - def __init__(self, left, right): - self.left = left - self.right = right - - def __iter__(self): - for x in self.left: - yield x - for x in self.right: - yield x - -class View(Adder): - - def __init__(self, source): - self.source = source - -class Filter(View): - - def __init__(self, predicate, source): - View.__init__(self, source) - self.predicate = predicate - - def __iter__(self): - for nd in self.source: - if self.predicate(nd): yield nd - -class Flatten(View): - - def __iter__(self): - sources = [iter(self.source)] - while sources: - try: - nd = next(sources[-1]) - if isinstance(nd, Tree): - sources.append(iter(nd.children)) - else: - yield nd - except StopIteration: - sources.pop() - -class Children(View): - - def __iter__(self): - for nd in self.source: - for child in nd.children: - yield child - -class Attributes(View): - - def __iter__(self): - for nd in self.source: - for a in nd.attrs: - yield a - -class Values(View): - - def __iter__(self): - for name, value in self.source: - yield value - -def flatten_path(path): - if isinstance(path, STRING_TYPES): - for part in path.split("/"): - yield part - elif callable(path): - yield path - else: - for p in path: - for fp in flatten_path(p): - yield fp - -class Query(View): - - def __iter__(self): - for nd in self.source: - yield nd - - def __getitem__(self, path): - query = self.source - for p in flatten_path(path): - if callable(p): - select = Query - pred = p - source = query - elif isinstance(p, STRING_TYPES): - if p[0] == "@": - select = Values - pred = lambda x, n=p[1:]: x[0] == n - source = Attributes(query) - elif p[0] == "#": - select = Query - pred = lambda x, t=p[1:]: x.is_type(t) - source = Children(query) - else: - select = Query - pred = lambda x, n=p: isinstance(x, Tag) and x.name == n - source = Flatten(Children(query)) - else: - raise ValueError(p) - query = select(Filter(pred, source)) - - return query http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/mllib/parsers.py ---------------------------------------------------------------------- diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py deleted file mode 100644 index 72d44ab..0000000 --- a/proton-c/mllib/parsers.py +++ /dev/null @@ -1,107 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -""" -Parsers for XML to dom. -""" -from __future__ import absolute_import - -import xml.sax.handler -from .dom import * - -class Parser: - - def __init__(self): - self.tree = Tree() - self.node = self.tree - self.nodes = [] - - def line(self, id, lineno, colno): - while self.nodes: - n = self.nodes.pop() - n._line(id, lineno, colno) - - def add(self, node): - self.node.add(node) - self.nodes.append(node) - - def start(self, name, attrs): - tag = Tag(name, *attrs) - self.add(tag) - self.node = tag - - def end(self, name): - self.balance(name) - self.node = self.node.parent - - def data(self, data): - children = self.node.children - if children and isinstance(children[-1], Data): - children[-1].data += data - else: - self.add(Data(data)) - - def comment(self, comment): - self.add(Comment(comment)) - - def entity(self, ref): - self.add(Entity(ref)) - - def character(self, ref): - self.add(Character(ref)) - - def balance(self, name = None): - while self.node != self.tree and name != self.node.name: - self.node.parent.extend(self.node.children) - del self.node.children[:] - self.node.singleton = True - self.node = self.node.parent - - -class XMLParser(xml.sax.handler.ContentHandler): - - def __init__(self): - self.parser = Parser() - self.locator = None - - def line(self): - if self.locator != None: - self.parser.line(self.locator.getSystemId(), - self.locator.getLineNumber(), - self.locator.getColumnNumber()) - - def setDocumentLocator(self, locator): - self.locator = locator - - def startElement(self, name, attrs): - self.parser.start(name, attrs.items()) - self.line() - - def endElement(self, name): - self.parser.end(name) - self.line() - - def characters(self, content): - self.parser.data(content) - self.line() - - def skippedEntity(self, name): - self.parser.entity(name) - self.line() - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/mllib/transforms.py ---------------------------------------------------------------------- diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py deleted file mode 100644 index 910b507..0000000 --- a/proton-c/mllib/transforms.py +++ /dev/null @@ -1,168 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -""" -Useful transforms for dom objects. -""" -from __future__ import absolute_import - -from . import dom -try: - from io import StringIO -except ImportError: - from cStringIO import StringIO - -class Visitor: - - def descend(self, node): - for child in node.children: - child.dispatch(self) - - def node(self, node): - self.descend(node) - - def leaf(self, leaf): - pass - -class Identity: - - def descend(self, node): - result = [] - for child in node.children: - result.append(child.dispatch(self)) - return result - - def default(self, tag): - result = dom.Tag(tag.name, *tag.attrs) - result.extend(self.descend(tag)) - return result - - def tree(self, tree): - result = dom.Tree() - result.extend(self.descend(tree)) - return result - - def tag(self, tag): - return self.default(tag) - - def leaf(self, leaf): - return leaf.__class__(leaf.data) - -class Sexp(Identity): - - def __init__(self): - self.stack = [] - self.level = 0 - self.out = "" - - def open(self, s): - self.out += "(%s" % s - self.level += len(s) + 1 - self.stack.append(s) - - def line(self, s = ""): - self.out = self.out.rstrip() - self.out += "\n" + " "*self.level + s - - def close(self): - s = self.stack.pop() - self.level -= len(s) + 1 - self.out = self.out.rstrip() - self.out += ")" - - def tree(self, tree): - self.open("+ ") - for child in tree.children: - self.line(); child.dispatch(self) - self.close() - - def tag(self, tag): - self.open("Node(%s) " % tag.name) - for child in tag.children: - self.line(); child.dispatch(self) - self.close() - - def leaf(self, leaf): - self.line("%s(%s)" % (leaf.__class__.__name__, leaf.data)) - -class Output: - - def descend(self, node): - out = StringIO() - for child in node.children: - out.write(child.dispatch(self)) - return out.getvalue() - - def default(self, tag): - out = StringIO() - out.write("<%s" % tag.name) - for k, v in tag.attrs: - out.write(' %s="%s"' % (k, v)) - out.write(">") - out.write(self.descend(tag)) - if not tag.singleton: - out.write("</%s>" % tag.name) - return out.getvalue() - - def tree(self, tree): - return self.descend(tree) - - def tag(self, tag): - return self.default(tag) - - def data(self, leaf): - return leaf.data - - def entity(self, leaf): - return "&%s;" % leaf.data - - def character(self, leaf): - raise Exception("TODO") - - def comment(self, leaf): - return "<!-- %s -->" % leaf.data - -class Empty(Output): - - def tag(self, tag): - return self.descend(tag) - - def data(self, leaf): - return "" - - def entity(self, leaf): - return "" - - def character(self, leaf): - return "" - - def comment(self, leaf): - return "" - -class Text(Empty): - - def data(self, leaf): - return leaf.data - - def entity(self, leaf): - return "&%s;" % leaf.data - - def character(self, leaf): - # XXX: is this right? - return "&#%s;" % leaf.data http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/soversion.cmake ---------------------------------------------------------------------- diff --git a/proton-c/soversion.cmake b/proton-c/soversion.cmake deleted file mode 100644 index 665edca..0000000 --- a/proton-c/soversion.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set (PN_LIB_SOMAJOR 11) -set (PN_LIB_SOMINOR "0.0") http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/ProtonConfig.cmake.in ---------------------------------------------------------------------- diff --git a/proton-c/src/ProtonConfig.cmake.in b/proton-c/src/ProtonConfig.cmake.in deleted file mode 100644 index 5e50d7c..0000000 --- a/proton-c/src/ProtonConfig.cmake.in +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Name: Proton -# Description: Qpid Proton C library -# Version: @PN_VERSION@ -# URL: http://qpid.apache.org/proton/ - -set (Proton_VERSION @PN_VERSION@) - -set (Proton_INCLUDE_DIRS @INCLUDEDIR@) -set (Proton_LIBRARIES optimized @LIBDIR@/@PROTONLIB@ debug @LIBDIR@/@PROTONLIBDEBUG@) - -set (ProtonCore_INCLUDE_DIRS @INCLUDEDIR@) -set (ProtonCore_LIBRARIES optimized @LIBDIR@/@PROTONCORELIB@ debug @LIBDIR@/@PROTONCORELIBDEBUG@) - -set (Proton_FOUND True) http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/compiler/msvc/snprintf.c ---------------------------------------------------------------------- diff --git a/proton-c/src/compiler/msvc/snprintf.c b/proton-c/src/compiler/msvc/snprintf.c deleted file mode 100644 index f9c14eb..0000000 --- a/proton-c/src/compiler/msvc/snprintf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "platform/platform.h" - -#include <stdarg.h> -#include <stdio.h> - -// [v]snprintf on Windows only matches C99 when no errors or overflow. -int pni_vsnprintf(char *buf, size_t count, const char *fmt, va_list ap) { - if (fmt == NULL) - return -1; - if ((buf == NULL) && (count > 0)) - return -1; - if (count > 0) { - int n = vsnprintf_s(buf, count, _TRUNCATE, fmt, ap); - if (n >= 0) // no overflow - return n; // same as C99 - buf[count-1] = '\0'; - } - // separate call to get needed buffer size on overflow - int n = _vscprintf(fmt, ap); - if (n >= (int) count) - return n; - return -1; -} - -int pni_snprintf(char *buf, size_t count, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int n = pni_vsnprintf(buf, count, fmt, ap); - va_end(ap); - return n; -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/core/autodetect.c ---------------------------------------------------------------------- diff --git a/proton-c/src/core/autodetect.c b/proton-c/src/core/autodetect.c deleted file mode 100644 index 00f6d98..0000000 --- a/proton-c/src/core/autodetect.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "autodetect.h" - -#define SASL_HEADER ("AMQP\x03\x01\x00\x00") -#define SSL_HEADER ("AMQP\x02\x01\x00\x00") -#define AMQP_HEADER ("AMQP\x00\x01\x00\x00") - -#define SASL_HEADER_LEN 8 - -/* - * SSLv2 Client Hello format - * http://www.mozilla.org/projects/security/pki/nss/ssl/draft02.html - * - * Bytes 0-1: RECORD-LENGTH - * Byte 2: MSG-CLIENT-HELLO (1) - * Byte 3: CLIENT-VERSION-MSB - * Byte 4: CLIENT-VERSION-LSB - * - * Allowed versions: - * 2.0 - SSLv2 - * 3.0 - SSLv3 - * 3.1 - TLS 1.0 - * 3.2 - TLS 1.1 - * 3.3 - TLS 1.2 - * - * The version sent in the Client-Hello is the latest version supported by - * the client. NSS may send version 3.x in an SSLv2 header for - * maximum compatibility. - */ -/* - * SSLv3/TLS Client Hello format - * RFC 2246 - * - * Byte 0: ContentType (handshake - 22) - * Bytes 1-2: ProtocolVersion {major, minor} - * - * Allowed versions: - * 3.0 - SSLv3 - * 3.1 - TLS 1.0 - * 3.2 - TLS 1.1 - * 3.3 - TLS 1.2 - */ -/* - * AMQP 1.0 Header - * - * Bytes 0-3: "AMQP" - * Byte 4: 0==AMQP, 2==SSL, 3==SASL - * Byte 5: 1 - * Bytes 6-7: 0 - */ -/* - * AMQP Pre 1.0 Header - * - * Bytes 0-3: 'AMQP' - * Byte 4: 1 - * Byte 5: 1 - * Byte 6: 0 (major version) - * Byte 7: Minor version - */ -pni_protocol_type_t pni_sniff_header(const char *buf, size_t len) -{ - if (len < 3) return PNI_PROTOCOL_INSUFFICIENT; - bool isSSL3Handshake = buf[0]==22 && // handshake - buf[1]==3 && buf[2]<=3; // SSL 3.0 & TLS 1.0-1.2 (v3.1-3.3) - if (isSSL3Handshake) return PNI_PROTOCOL_SSL; - - bool isFirst3AMQP = buf[0]=='A' && buf[1]=='M' && buf[2]=='Q'; - bool isFirst3SSL2CLientHello = buf[2]==1; // Client Hello - if (!isFirst3AMQP && !isFirst3SSL2CLientHello) return PNI_PROTOCOL_UNKNOWN; - - - if (len < 4) return PNI_PROTOCOL_INSUFFICIENT; - bool isAMQP = isFirst3AMQP && buf[3]=='P'; - bool isFirst4SSL2ClientHello = isFirst3SSL2CLientHello && (buf[3]==2 || buf[3]==3); - if (!isAMQP && !isFirst4SSL2ClientHello) return PNI_PROTOCOL_UNKNOWN; - - if (len < 5) return PNI_PROTOCOL_INSUFFICIENT; - bool isSSL2Handshake = buf[2] == 1 && // MSG-CLIENT-HELLO - ((buf[3] == 3 && buf[4] <= 3) || // SSL 3.0 & TLS 1.0-1.2 (v3.1-3.3) - (buf[3] == 2 && buf[4] == 0)); // SSL 2 - if (isSSL2Handshake) return PNI_PROTOCOL_SSL; - - bool isFirst5OldAMQP = isAMQP && buf[4]==1; - bool isFirst5AMQP = isAMQP && (buf[4]==0 || buf[4]==2 || buf[4]==3); - if (!isFirst5AMQP && !isFirst5OldAMQP) return PNI_PROTOCOL_UNKNOWN; - - if (len < 6) return PNI_PROTOCOL_INSUFFICIENT; - - // Both old and new versions of AMQP have 1 in byte 5 - if (buf[5]!=1) return PNI_PROTOCOL_UNKNOWN; - - // From here on it must be some sort of AMQP - if (len < 8) return PNI_PROTOCOL_INSUFFICIENT; - if (buf[6]==0 && buf[7]==0) { - // AM<QP 1.0 - if (buf[4]==0) return PNI_PROTOCOL_AMQP1; - if (buf[4]==2) return PNI_PROTOCOL_AMQP_SSL; - if (buf[4]==3) return PNI_PROTOCOL_AMQP_SASL; - } - return PNI_PROTOCOL_AMQP_OTHER; -} - -const char* pni_protocol_name(pni_protocol_type_t p) -{ - static const char* names[] = { - "Insufficient data to determine protocol", - "Unknown protocol", - "SSL/TLS connection", - "AMQP TLS layer", - "AMQP SASL layer", - "AMQP 1.0 layer", - "Pre standard AMQP connection" - }; - return names[p]; -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/core/autodetect.h ---------------------------------------------------------------------- diff --git a/proton-c/src/core/autodetect.h b/proton-c/src/core/autodetect.h deleted file mode 100644 index 12cb7d8..0000000 --- a/proton-c/src/core/autodetect.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef PROTON_AUTODETECT_H -#define PROTON_AUTODETECT_H 1 - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "proton/types.h" - -typedef enum { - PNI_PROTOCOL_INSUFFICIENT, - PNI_PROTOCOL_UNKNOWN, - PNI_PROTOCOL_SSL, - PNI_PROTOCOL_AMQP_SSL, - PNI_PROTOCOL_AMQP_SASL, - PNI_PROTOCOL_AMQP1, - PNI_PROTOCOL_AMQP_OTHER -} pni_protocol_type_t; - -pni_protocol_type_t pni_sniff_header(const char *data, size_t len); -const char* pni_protocol_name(pni_protocol_type_t p); - -#endif http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/core/buffer.c ---------------------------------------------------------------------- diff --git a/proton-c/src/core/buffer.c b/proton-c/src/core/buffer.c deleted file mode 100644 index c3015f4..0000000 --- a/proton-c/src/core/buffer.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include <proton/error.h> -#ifndef __cplusplus -#include <stdbool.h> -#endif -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -#include "buffer.h" -#include "util.h" - -struct pn_buffer_t { - size_t capacity; - size_t start; - size_t size; - char *bytes; -}; - -pn_buffer_t *pn_buffer(size_t capacity) -{ - pn_buffer_t *buf = (pn_buffer_t *) malloc(sizeof(pn_buffer_t)); - if (buf != NULL) { - buf->capacity = capacity; - buf->start = 0; - buf->size = 0; - if (capacity > 0) { - buf->bytes = (char *)malloc(capacity); - if (buf->bytes == NULL) { - free(buf); - buf = NULL; - } - } - else { - buf->bytes = NULL; - } - } - return buf; -} - -void pn_buffer_free(pn_buffer_t *buf) -{ - if (buf) { - free(buf->bytes); - free(buf); - } -} - -size_t pn_buffer_size(pn_buffer_t *buf) -{ - return buf->size; -} - -size_t pn_buffer_capacity(pn_buffer_t *buf) -{ - return buf->capacity; -} - -size_t pn_buffer_available(pn_buffer_t *buf) -{ - return buf->capacity - buf->size; -} - -static size_t pni_buffer_head(pn_buffer_t *buf) -{ - return buf->start; -} - -static size_t pni_buffer_tail(pn_buffer_t *buf) -{ - size_t tail = buf->start + buf->size; - if (tail >= buf->capacity) - tail -= buf->capacity; - return tail; -} - -static bool pni_buffer_wrapped(pn_buffer_t *buf) -{ - return buf->size && pni_buffer_head(buf) >= pni_buffer_tail(buf); -} - -static size_t pni_buffer_tail_space(pn_buffer_t *buf) -{ - if (pni_buffer_wrapped(buf)) { - return pn_buffer_available(buf); - } else { - return buf->capacity - pni_buffer_tail(buf); - } -} - -static size_t pni_buffer_head_space(pn_buffer_t *buf) -{ - if (pni_buffer_wrapped(buf)) { - return pn_buffer_available(buf); - } else { - return pni_buffer_head(buf); - } -} - -static size_t pni_buffer_head_size(pn_buffer_t *buf) -{ - if (pni_buffer_wrapped(buf)) { - return buf->capacity - pni_buffer_head(buf); - } else { - return pni_buffer_tail(buf) - pni_buffer_head(buf); - } -} - -static size_t pni_buffer_tail_size(pn_buffer_t *buf) -{ - if (pni_buffer_wrapped(buf)) { - return pni_buffer_tail(buf); - } else { - return 0; - } -} - -int pn_buffer_ensure(pn_buffer_t *buf, size_t size) -{ - size_t old_capacity = buf->capacity; - size_t old_head = pni_buffer_head(buf); - bool wrapped = pni_buffer_wrapped(buf); - - while (pn_buffer_available(buf) < size) { - buf->capacity = 2*(buf->capacity ? buf->capacity : 16); - } - - if (buf->capacity != old_capacity) { - char* new_bytes = (char *)realloc(buf->bytes, buf->capacity); - if (new_bytes) { - buf->bytes = new_bytes; - - if (wrapped) { - size_t n = old_capacity - old_head; - memmove(buf->bytes + buf->capacity - n, buf->bytes + old_head, n); - buf->start = buf->capacity - n; - } - } - } - - return 0; -} - -int pn_buffer_append(pn_buffer_t *buf, const char *bytes, size_t size) -{ - int err = pn_buffer_ensure(buf, size); - if (err) return err; - - size_t tail = pni_buffer_tail(buf); - size_t tail_space = pni_buffer_tail_space(buf); - size_t n = pn_min(tail_space, size); - - memmove(buf->bytes + tail, bytes, n); - memmove(buf->bytes, bytes + n, size - n); - - buf->size += size; - - return 0; -} - -int pn_buffer_prepend(pn_buffer_t *buf, const char *bytes, size_t size) -{ - int err = pn_buffer_ensure(buf, size); - if (err) return err; - - size_t head = pni_buffer_head(buf); - size_t head_space = pni_buffer_head_space(buf); - size_t n = pn_min(head_space, size); - - memmove(buf->bytes + head - n, bytes + size - n, n); - memmove(buf->bytes + buf->capacity - (size - n), bytes, size - n); - - if (buf->start >= size) { - buf->start -= size; - } else { - buf->start = buf->capacity - (size - buf->start); - } - - buf->size += size; - - return 0; -} - -static size_t pni_buffer_index(pn_buffer_t *buf, size_t index) -{ - size_t result = buf->start + index; - if (result >= buf->capacity) result -= buf->capacity; - return result; -} - -size_t pn_buffer_get(pn_buffer_t *buf, size_t offset, size_t size, char *dst) -{ - size = pn_min(size, buf->size); - size_t start = pni_buffer_index(buf, offset); - size_t stop = pni_buffer_index(buf, offset + size); - - if (size == 0) return 0; - - size_t sz1; - size_t sz2; - - if (start >= stop) { - sz1 = buf->capacity - start; - sz2 = stop; - } else { - sz1 = stop - start; - sz2 = 0; - } - - memmove(dst, buf->bytes + start, sz1); - memmove(dst + sz1, buf->bytes, sz2); - - return sz1 + sz2; -} - -int pn_buffer_trim(pn_buffer_t *buf, size_t left, size_t right) -{ - if (left + right > buf->size) return PN_ARG_ERR; - - buf->start += left; - if (buf->start >= buf->capacity) - buf->start -= buf->capacity; - - buf->size -= left + right; - - return 0; -} - -void pn_buffer_clear(pn_buffer_t *buf) -{ - buf->start = 0; - buf->size = 0; -} - -static void pn_buffer_rotate (pn_buffer_t *buf, size_t sz) { - if (sz == 0) return; - - unsigned c = 0, v = 0; - for (; c < buf->capacity; v++) { - unsigned t = v, tp = v + sz; - char tmp = buf->bytes[v]; - c++; - while (tp != v) { - buf->bytes[t] = buf->bytes[tp]; - t = tp; - tp += sz; - if (tp >= buf->capacity) tp -= buf->capacity; - c++; - } - buf->bytes[t] = tmp; - } -} - -int pn_buffer_defrag(pn_buffer_t *buf) -{ - pn_buffer_rotate(buf, buf->start); - buf->start = 0; - return 0; -} - -pn_bytes_t pn_buffer_bytes(pn_buffer_t *buf) -{ - if (buf) { - pn_buffer_defrag(buf); - return pn_bytes(buf->size, buf->bytes); - } else { - return pn_bytes(0, NULL); - } -} - -pn_rwbytes_t pn_buffer_memory(pn_buffer_t *buf) -{ - if (buf) { - pn_buffer_defrag(buf); - pn_rwbytes_t r = {buf->size, buf->bytes}; - return r; - } else { - pn_rwbytes_t r = {0, NULL}; - return r; - } -} - -int pn_buffer_print(pn_buffer_t *buf) -{ - printf("pn_buffer(\""); - pn_print_data(buf->bytes + pni_buffer_head(buf), pni_buffer_head_size(buf)); - pn_print_data(buf->bytes, pni_buffer_tail_size(buf)); - printf("\")"); - return 0; -} http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/src/core/buffer.h ---------------------------------------------------------------------- diff --git a/proton-c/src/core/buffer.h b/proton-c/src/core/buffer.h deleted file mode 100644 index da557ef..0000000 --- a/proton-c/src/core/buffer.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PROTON_BUFFER_H -#define PROTON_BUFFER_H 1 - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include <proton/import_export.h> -#include <proton/types.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct pn_buffer_t pn_buffer_t; - -pn_buffer_t *pn_buffer(size_t capacity); -void pn_buffer_free(pn_buffer_t *buf); -size_t pn_buffer_size(pn_buffer_t *buf); -size_t pn_buffer_capacity(pn_buffer_t *buf); -size_t pn_buffer_available(pn_buffer_t *buf); -int pn_buffer_ensure(pn_buffer_t *buf, size_t size); -int pn_buffer_append(pn_buffer_t *buf, const char *bytes, size_t size); -int pn_buffer_prepend(pn_buffer_t *buf, const char *bytes, size_t size); -size_t pn_buffer_get(pn_buffer_t *buf, size_t offset, size_t size, char *dst); -int pn_buffer_trim(pn_buffer_t *buf, size_t left, size_t right); -void pn_buffer_clear(pn_buffer_t *buf); -int pn_buffer_defrag(pn_buffer_t *buf); -pn_bytes_t pn_buffer_bytes(pn_buffer_t *buf); -pn_rwbytes_t pn_buffer_memory(pn_buffer_t *buf); -int pn_buffer_print(pn_buffer_t *buf); - -#ifdef __cplusplus -} -#endif - -#endif /* buffer.h */ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
