qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jr...@apache.org
Subject [43/51] [partial] qpid-proton git commit: PROTON-1728: Reorganize the source tree
Date Thu, 05 Apr 2018 19:34:18 GMT
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/type_compat.h
----------------------------------------------------------------------
diff --git a/c/include/proton/type_compat.h b/c/include/proton/type_compat.h
new file mode 100644
index 0000000..12a96e6
--- /dev/null
+++ b/c/include/proton/type_compat.h
@@ -0,0 +1,149 @@
+#ifndef PROTON_TYPE_COMPAT_H
+#define PROTON_TYPE_COMPAT_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.
+ *
+ */
+
+/**
+ * @cond INTERNAL
+ */
+
+/* Get Boolean */
+#if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
+# if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 || _MSC_VER >=1800
+#  include <stdbool.h>
+# else
+/* Need to get bool/true/false manually */
+#  if _MSC_VER
+#   define bool char
+#   define false 0
+#   define true 1
+#   define __bool_true_false_are_defined
+#  else
+#   error "No definitions for bool/true/false"
+#  endif
+# endif
+#endif
+/*
+ * Handle special cases for stdint.h and the definition for ssize_t.
+ * Third party libraries (e.g. Boost) may provide competing solutions.
+ *
+ * The effects of this include file may be controlled by overrides:
+ *  PN_DEFINE_STDINT/PN_NODEFINE_STDINT   : turn on/off definition of int64_t etc.
+ *  PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
+ *  PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
+ */
+
+/* Honor positive overrides */
+#if defined(PN_DEFINE_STDINT)
+# define PNI_DEFINE_STDINT
+#endif
+#if defined(PN_INCLUDE_STDINT)
+# define PNI_INCLUDE_STDINT)
+#endif
+#if defined(PN_DEFINE_SSIZE_T)
+# define PNI_DEFINE_SSIZE_T
+#endif
+
+/* Determine default action */
+#ifndef _MSC_VER
+/* Not Windows and not using Visual Studio */
+
+/* MBED_BUILD_TIMESTAMP is used to detect whether Proton is being built on www.mbed.org with
+the ARM compiler. In that case ssize_t needs to be defined in this file. */
+#if defined(MBED_BUILD_TIMESTAMP)
+#  define PNI_DEFINE_SSIZE_T
+#else
+#include <sys/types.h>
+#endif /* defined(MBED_LIBRARY_VERSION) */
+
+# ifndef PNI_INCLUDE_STDINT
+#  define PNI_INCLUDE_STDINT
+# endif
+#else
+/* all versions of Visual Studio */
+# ifndef PNI_DEFINE_SSIZE_T
+/* ssize_t def is needed, unless third party definition interferes, e.g. python/swig */
+#  ifndef Py_CONFIG_H
+#   define PNI_DEFINE_SSIZE_T
+#  endif
+# endif
+
+# if (_MSC_VER < 1600)
+/* VS 2008 and earlier */
+#  ifndef PNI_DEFINE_STDINT
+#   define PNI_DEFINE_STDINT
+#  endif
+# else
+/* VS 2010 and newer */
+#  ifndef PNI_INCLUDE_STDINT
+#   define PNI_INCLUDE_STDINT
+#  endif
+
+# endif /* (_MSC_VER < 1600) */
+#endif /*_MSC_VER */
+
+/* Honor negative overrides */
+#ifdef PN_NODEFINE_SSIZE_T
+# undef PNI_DEFINE_SSIZE_T
+#endif
+#ifdef PN_NODEFINE_STDINT
+# undef PNI_DEFINE_STDINT
+#endif
+#ifdef PN_NOINCLUDE_STDINT
+# undef PNI_INCLUDE_STDINT
+#endif
+
+#ifdef PNI_INCLUDE_STDINT
+# include <stdint.h>
+#endif
+
+#ifdef PNI_DEFINE_SSIZE_T
+# ifdef _MSC_VER
+#  include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+# else
+typedef intptr_t ssize_t;
+# endif
+#endif /* PNI_DEFINE_SSIZE_T */
+
+#ifdef PNI_DEFINE_STDINT
+# ifdef _MSC_VER
+
+typedef signed __int8 int8_t;
+typedef signed __int16 int16_t;
+typedef signed __int32 int32_t;
+typedef signed __int64 int64_t;
+
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+
+# else /* _MSC_VER */
+#  error stdint.h definitions not kown
+# endif
+#endif /* PNI_DEFINE_SSIZE_T */
+/**
+ * @endcond
+ */
+
+#endif /* type_compat.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/types.h
----------------------------------------------------------------------
diff --git a/c/include/proton/types.h b/c/include/proton/types.h
new file mode 100644
index 0000000..9df0cc6
--- /dev/null
+++ b/c/include/proton/types.h
@@ -0,0 +1,456 @@
+#ifndef PROTON_TYPES_H
+#define PROTON_TYPES_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 <stddef.h>
+#include <proton/type_compat.h>
+
+/**
+ * @file
+ *
+ * @copybrief types
+ *
+ * @defgroup core Core
+ * @brief Core protocol entities and event handling.
+ *
+ * @defgroup connection Connection
+ * @brief A connection to a remote AMQP peer.
+ * @ingroup core
+ *
+ * @defgroup session Session
+ * @brief A container of links.
+ * @ingroup core
+ *
+ * @defgroup link Link
+ * @brief A channel for transferring messages.
+ * @ingroup core
+ *
+ * @defgroup terminus Terminus
+ * @brief A source or target for messages.
+ * @ingroup core
+ *
+ * @defgroup message Message
+ * @brief A mutable holder of application content.
+ * @ingroup core
+ *
+ * @defgroup delivery Delivery
+ * @brief A message transfer.
+ * @ingroup core
+ *
+ * @defgroup condition Condition
+ * @brief An endpoint error state.
+ * @ingroup core
+ *
+ * @defgroup event Event
+ * @brief Protocol and transport events.
+ * @ingroup core
+ *
+ * @defgroup transport Transport
+ * @brief A network channel supporting an AMQP connection.
+ * @ingroup core
+ *
+ * @defgroup sasl SASL
+ * @brief SASL secure transport layer.
+ * @ingroup core
+ *
+ * @defgroup ssl SSL
+ * @brief SSL secure transport layer.
+ * @ingroup core
+ *
+ * @defgroup error Error
+ * @brief A Proton API error.
+ * @ingroup core
+ *
+ * @defgroup types Types
+ * @brief AMQP and API data types.
+ *
+ * @defgroup amqp_types AMQP data types
+ * @brief AMQP data types.
+ * @ingroup types
+ *
+ * @defgroup api_types API data types
+ * @brief Additional data types used in the API.
+ * @ingroup types
+ *
+ * @defgroup codec Codec
+ * @brief AMQP data encoding and decoding.
+ *
+ * @defgroup data Data
+ * @brief A data structure for AMQP data.
+ * @ingroup codec
+ *
+ * @defgroup io IO
+ * @brief **Unsettled API** - Interfaces for IO integration.
+ *
+ * @defgroup proactor Proactor
+ * @brief **Unsettled API** - An API for multithreaded IO.
+ * @ingroup io
+ *
+ * @defgroup proactor_events Proactor events
+ * @brief **Unsettled API** - Events used by the proactor.
+ * @ingroup io
+ *
+ * @defgroup listener Listener
+ * @brief **Unsettled API** - A listener for incoming connections.
+ * @ingroup io
+ *
+ * @defgroup connection_driver Connection driver
+ * @brief **Unsettled API** - An API for low-level IO integration.
+ * @ingroup io
+ *
+ * @defgroup messenger Messenger
+ * @brief **Deprecated** - Use the @ref proactor API or Qpid Proton C++.
+ *
+ * @defgroup url URL
+ * @brief **Deprecated** - Use a third-party URL library.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A sequence number.
+ *
+ * @ingroup api_types
+ */
+typedef int32_t  pn_sequence_t;
+
+/**
+ * A span of time in milliseconds.
+ *
+ * @ingroup api_types
+ */
+typedef uint32_t pn_millis_t;
+
+/**
+ * The maximum value for @ref pn_millis_t.
+ *
+ * @ingroup api_types
+ */
+#define PN_MILLIS_MAX (~0U)
+
+/**
+ * A span of time in seconds.
+ *
+ * @ingroup api_types
+ */
+typedef uint32_t pn_seconds_t;
+
+/**
+ * A 64-bit timestamp in milliseconds since the Unix epoch.
+ *
+ * @ingroup amqp_types
+ */
+typedef int64_t pn_timestamp_t;
+
+/**
+ * A 32-bit Unicode code point.
+ *
+ * @ingroup amqp_types
+ */
+typedef uint32_t pn_char_t;
+
+/**
+ * A 32-bit decimal floating-point number.
+ *
+ * @ingroup amqp_types
+ */
+typedef uint32_t pn_decimal32_t;
+
+/**
+ * A 64-bit decimal floating-point number.
+ *
+ * @ingroup amqp_types
+ */
+typedef uint64_t pn_decimal64_t;
+
+/**
+ * A 128-bit decimal floating-point number.
+ *
+ * @ingroup amqp_types
+ */
+typedef struct {
+  char bytes[16];
+} pn_decimal128_t;
+
+/**
+ * A 16-byte universally unique identifier.
+ *
+ * @ingroup amqp_types
+ */
+typedef struct {
+  char bytes[16];
+} pn_uuid_t;
+
+/**
+ * A const byte buffer.
+ *
+ * @ingroup api_types
+ */
+typedef struct pn_bytes_t {
+  size_t size;
+  const char *start;
+} pn_bytes_t;
+
+/**
+ * Create a @ref pn_bytes_t
+ *
+ * @ingroup api_types
+ */
+PN_EXTERN pn_bytes_t pn_bytes(size_t size, const char *start);
+
+static const pn_bytes_t pn_bytes_null = { 0, NULL };
+
+/**
+ * A non-const byte buffer.
+ *
+ * @ingroup api_types
+ */
+typedef struct pn_rwbytes_t {
+  size_t size;
+  char *start;
+} pn_rwbytes_t;
+
+/**
+ * Create a @ref pn_rwbytes_t
+ *
+ * @ingroup api_types
+ */
+PN_EXTERN pn_rwbytes_t pn_rwbytes(size_t size, char *start);
+
+static const pn_rwbytes_t pn_rwbytes_null = { 0, NULL };
+
+/**
+ * Holds the state flags for an AMQP endpoint.
+ *
+ * A pn_state_t is an integral value with flags that encode both the
+ * local and remote state of an AMQP Endpoint (@link pn_connection_t
+ * Connection @endlink, @link pn_session_t Session @endlink, or @link
+ * pn_link_t Link @endlink). The local portion of the state may be
+ * accessed using ::PN_LOCAL_MASK, and the remote portion may be
+ * accessed using ::PN_REMOTE_MASK. Individual bits may be accessed
+ * using ::PN_LOCAL_UNINIT, ::PN_LOCAL_ACTIVE, ::PN_LOCAL_CLOSED, and
+ * ::PN_REMOTE_UNINIT, ::PN_REMOTE_ACTIVE, ::PN_REMOTE_CLOSED.
+ *
+ * Every AMQP endpoint (@link pn_connection_t Connection @endlink,
+ * @link pn_session_t Session @endlink, or @link pn_link_t Link
+ * @endlink) starts out in an uninitialized state and then proceeds
+ * linearly to an active and then closed state. This lifecycle occurs
+ * at both endpoints involved, and so the state model for an endpoint
+ * includes not only the known local state, but also the last known
+ * state of the remote endpoint.
+ *
+ * @ingroup connection
+ */
+typedef int pn_state_t;
+
+/**
+ * An AMQP Connection object.
+ *
+ * A pn_connection_t object encapsulates all of the endpoint state
+ * associated with an AMQP Connection. A pn_connection_t object
+ * contains zero or more ::pn_session_t objects, which in turn contain
+ * zero or more ::pn_link_t objects. Each ::pn_link_t object contains
+ * an ordered sequence of ::pn_delivery_t objects. A link is either a
+ * sender or a receiver but never both.
+ *
+ * @ingroup connection
+ */
+typedef struct pn_connection_t pn_connection_t;
+
+/**
+ * An AMQP Session object.
+ *
+ * A pn_session_t object encapsulates all of the endpoint state
+ * associated with an AMQP Session. A pn_session_t object contains
+ * zero or more ::pn_link_t objects.
+ *
+ * @ingroup session
+ */
+typedef struct pn_session_t pn_session_t;
+
+/**
+ * An AMQP Link object.
+ *
+ * A pn_link_t object encapsulates all of the endpoint state
+ * associated with an AMQP Link. A pn_link_t object contains an
+ * ordered sequence of ::pn_delivery_t objects representing in-flight
+ * deliveries. A pn_link_t may be either sender or a receiver but
+ * never both.
+ *
+ * A pn_link_t object maintains a pointer to the *current* delivery
+ * within the ordered sequence of deliveries contained by the link
+ * (See ::pn_link_current). The *current* delivery is the target of a
+ * number of operations associated with the link, such as sending
+ * (::pn_link_send) and receiving (::pn_link_recv) message data.
+ *
+ * @ingroup link
+ */
+typedef struct pn_link_t pn_link_t;
+
+/**
+ * An AMQP Delivery object.
+ *
+ * A pn_delivery_t object encapsulates all of the endpoint state
+ * associated with an AMQP Delivery. Every delivery exists within the
+ * context of a ::pn_link_t object.
+ *
+ * The AMQP model for settlement is based on the lifecycle of a
+ * delivery at an endpoint. At each end of a link, a delivery is
+ * created, it exists for some period of time, and finally it is
+ * forgotten, aka settled. Note that because this lifecycle happens
+ * independently at both the sender and the receiver, there are
+ * actually four events of interest in the combined lifecycle of a
+ * given delivery:
+ *
+ *   - created at sender
+ *   - created at receiver
+ *   - settled at sender
+ *   - settled at receiver
+ *
+ * Because the sender and receiver are operating concurrently, these
+ * events can occur in a variety of different orders, and the order of
+ * these events impacts the types of failures that may occur when
+ * transferring a delivery. Eliminating scenarios where the receiver
+ * creates the delivery first, we have the following possible
+ * sequences of interest:
+ *
+ * Sender presettles (aka at-most-once):
+ * -------------------------------------
+ *
+ *   1. created at sender
+ *   2. settled at sender
+ *   3. created at receiver
+ *   4. settled at receiver
+ *
+ * In this configuration the sender settles (i.e. forgets about) the
+ * delivery before it even reaches the receiver, and if anything
+ * should happen to the delivery in-flight, there is no way to
+ * recover, hence the "at most once" semantics.
+ *
+ * Receiver settles first (aka at-least-once):
+ * -------------------------------------------
+ *
+ *   1. created at sender
+ *   2. created at receiver
+ *   3. settled at receiver
+ *   4. settled at sender
+ *
+ * In this configuration the receiver settles the delivery first, and
+ * the sender settles once it sees the receiver has settled. Should
+ * anything happen to the delivery in-flight, the sender can resend,
+ * however the receiver may have already forgotten the delivery and so
+ * it could interpret the resend as a new delivery, hence the "at
+ * least once" semantics.
+ *
+ * Receiver settles second (aka exactly-once):
+ * -------------------------------------------
+ *
+ *   1. created at sender
+ *   2. created at receiver
+ *   3. settled at sender
+ *   4. settled at receiver
+ *
+ * In this configuration the receiver settles only once it has seen
+ * that the sender has settled. This provides the sender the option to
+ * retransmit, and the receiver has the option to recognize (and
+ * discard) duplicates, allowing for exactly once semantics.
+ *
+ * Note that in the last scenario the sender needs some way to know
+ * when it is safe to settle. This is where delivery state comes in.
+ * In addition to these lifecycle related events surrounding
+ * deliveries there is also the notion of a delivery state that can
+ * change over the lifetime of a delivery, e.g. it might start out as
+ * nothing, transition to ::PN_RECEIVED and then transition to
+ * ::PN_ACCEPTED. In the first two scenarios the delivery state isn't
+ * required, however in final scenario the sender would typically
+ * trigger settlement based on seeing the delivery state transition to
+ * a terminal state like ::PN_ACCEPTED or ::PN_REJECTED.
+ *
+ * In practice settlement is controlled by application policy, so
+ * there may well be more options here, e.g. a sender might not settle
+ * strictly based on what has happened at the receiver, it might also
+ * choose to impose some time limit and settle after that period has
+ * expired, or it could simply have a sliding window of the last N
+ * deliveries and settle the oldest whenever a new one comes along.
+ *
+ * @ingroup delivery
+ */
+typedef struct pn_delivery_t pn_delivery_t;
+
+/**
+ * An event collector.
+ *
+ * A pn_collector_t may be used to register interest in being notified
+ * of high level events that can occur to the various objects
+ * representing AMQP endpoint state. See ::pn_event_t for more
+ * details.
+ *
+ * @ingroup event
+ */
+typedef struct pn_collector_t pn_collector_t;
+
+/**
+ * A listener for incoming connections.
+ *
+ * @ingroup listener
+ */
+typedef struct pn_listener_t pn_listener_t;
+
+/**
+ * A network channel supporting an AMQP connection.
+ *
+ * A pn_transport_t encapsulates the transport related state of all
+ * AMQP endpoint objects associated with a physical network connection
+ * at a given point in time.
+ *
+ * @ingroup transport
+ */
+typedef struct pn_transport_t pn_transport_t;
+
+/**
+ * A harness for multithreaded IO.
+ *
+ * @ingroup proactor
+ */
+typedef struct pn_proactor_t pn_proactor_t;
+
+/**
+ * @cond INTERNAL
+ *
+ * An event handler
+ *
+ * A pn_handler_t is target of ::pn_event_t dispatched by the pn_reactor_t
+ */
+typedef struct pn_handler_t pn_handler_t;
+/**
+ * @endcond
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* types.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/url.h
----------------------------------------------------------------------
diff --git a/c/include/proton/url.h b/c/include/proton/url.h
new file mode 100644
index 0000000..ad239ce
--- /dev/null
+++ b/c/include/proton/url.h
@@ -0,0 +1,128 @@
+#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
+ *
+ * @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/blob/37136940/c/include/proton/version.h.in
----------------------------------------------------------------------
diff --git a/c/include/proton/version.h.in b/c/include/proton/version.h.in
new file mode 100644
index 0000000..133b0bb
--- /dev/null
+++ b/c/include/proton/version.h.in
@@ -0,0 +1,29 @@
+#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/blob/37136940/c/src/ProtonConfig.cmake.in
----------------------------------------------------------------------
diff --git a/c/src/ProtonConfig.cmake.in b/c/src/ProtonConfig.cmake.in
new file mode 100644
index 0000000..5b23be0
--- /dev/null
+++ b/c/src/ProtonConfig.cmake.in
@@ -0,0 +1,50 @@
+#
+# 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 (Proton_FOUND True)
+
+set (Proton_Core_INCLUDE_DIRS  @INCLUDEDIR@)
+set (Proton_Core_LIBRARIES     optimized @LIBDIR@/@PROTONCORELIB@ debug @LIBDIR@/@PROTONCORELIBDEBUG@)
+set (Proton_Core_FOUND True)
+
+set (HAS_PROACTOR @HAS_PROACTOR@)
+if (HAS_PROACTOR)
+  set (Proton_Proactor_INCLUDE_DIRS  @INCLUDEDIR@)
+  set (Proton_Proactor_LIBRARIES     optimized @LIBDIR@/@PROTONPROACTORLIB@ debug @LIBDIR@/@PROTONPROACTORLIBDEBUG@)
+  set (Proton_Proactor_FOUND True)
+endif()
+
+# Check for all required components
+foreach(comp ${Proton_FIND_COMPONENTS})
+  if(NOT Proton_${comp}_FOUND)
+    if(Proton_FIND_REQUIRED_${comp})
+      set(Proton_FOUND FALSE)
+      set(Proton_NOT_FOUND_MESSAGE "Didn't find required component ${comp}")
+    endif()
+  endif()
+endforeach()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/src/compiler/msvc/snprintf.c
----------------------------------------------------------------------
diff --git a/c/src/compiler/msvc/snprintf.c b/c/src/compiler/msvc/snprintf.c
new file mode 100644
index 0000000..49a853c
--- /dev/null
+++ b/c/src/compiler/msvc/snprintf.c
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+// Note: [v]snprintf behavior changed in VS2015 to be C99 compliant.
+// vsnprintf_s is unchanged.  This platform code can go away some day.
+
+
+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/blob/37136940/c/src/core/autodetect.c
----------------------------------------------------------------------
diff --git a/c/src/core/autodetect.c b/c/src/core/autodetect.c
new file mode 100644
index 0000000..00f6d98
--- /dev/null
+++ b/c/src/core/autodetect.c
@@ -0,0 +1,135 @@
+/*
+ *
+ * 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/blob/37136940/c/src/core/autodetect.h
----------------------------------------------------------------------
diff --git a/c/src/core/autodetect.h b/c/src/core/autodetect.h
new file mode 100644
index 0000000..12cb7d8
--- /dev/null
+++ b/c/src/core/autodetect.h
@@ -0,0 +1,40 @@
+#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/blob/37136940/c/src/core/buffer.c
----------------------------------------------------------------------
diff --git a/c/src/core/buffer.c b/c/src/core/buffer.c
new file mode 100644
index 0000000..e990581
--- /dev/null
+++ b/c/src/core/buffer.c
@@ -0,0 +1,320 @@
+/*
+ *
+ * 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)
+{
+  if (!size) return 0;
+  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;
+
+  // In special case where we trim everything just clear buffer
+  if (left + right == buf->size) {
+    pn_buffer_clear(buf);
+    return 0;
+  }
+  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_quote(pn_buffer_t *buf, pn_string_t *str, size_t n)
+{
+  size_t hsize = pni_buffer_head_size(buf);
+  size_t tsize = pni_buffer_tail_size(buf);
+  if (hsize >= n) {
+    pn_quote(str, buf->bytes + pni_buffer_head(buf), n);
+    return 0;
+  }
+  pn_quote(str, buf->bytes + pni_buffer_head(buf), hsize);
+  pn_quote(str, buf->bytes, pn_min(tsize, n-hsize));
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/src/core/buffer.h
----------------------------------------------------------------------
diff --git a/c/src/core/buffer.h b/c/src/core/buffer.h
new file mode 100644
index 0000000..7193f8f
--- /dev/null
+++ b/c/src/core/buffer.h
@@ -0,0 +1,55 @@
+#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/object.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_quote(pn_buffer_t *buf, pn_string_t *string, size_t n);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* buffer.h */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message