http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/cproton.i ---------------------------------------------------------------------- diff --git a/c/include/proton/cproton.i b/c/include/proton/cproton.i new file mode 100644 index 0000000..464e74b --- /dev/null +++ b/c/include/proton/cproton.i @@ -0,0 +1,1071 @@ +/* + * 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. + */ +typedef unsigned int size_t; +typedef signed int ssize_t; +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned long int uint32_t; +typedef long int int32_t; +typedef unsigned long long int uint64_t; +typedef long long int int64_t; +typedef unsigned long int uintptr_t; + +/* Parse these interface header files to generate APIs for script languages */ + +%include "proton/import_export.h" + +%ignore _PROTON_VERSION_H; +%include "proton/version.h" + +/* We cannot safely just wrap pn_bytes_t but each language binding must have a typemap for it - presumably to a string type */ +%ignore pn_bytes_t; +%ignore pn_rwbytes_t; + +/* pn_event_batch_t is not used directly by bindings */ +%ignore pn_event_batch_t; + +/* There is no need to wrap pn_class_t aa it is an internal implementation detail and cannot be used outside the library */ +%ignore pn_class_t; + +/* Ignore C APIs related to pn_atom_t - they can all be achieved with pn_data_t */ +%ignore pn_atom_t; +%ignore pn_atom_t_u; /* Seem to need this even though its nested in pn_atom_t */ +%ignore pn_data_get_atom; +%ignore pn_data_put_atom; + +%ignore pn_delivery_tag_t; +%ignore pn_decimal128_t; +%ignore pn_uuid_t; + +%include "proton/types.h" +%ignore pn_string_vformat; +%ignore pn_string_vaddf; +%immutable PN_OBJECT; +%immutable PN_VOID; +%immutable PN_WEAKREF; +/* Treat pn_handle_t like uintptr_t - syntactically it is a C void* but really it's just an int */ +%apply uintptr_t { pn_handle_t }; +%include "proton/object.h" + +%ignore pn_error_format; +%ignore pn_error_vformat; +%ignore pn_condition_format; +%ignore pn_condition_vformat; + +/* checks that ensure only allowed values are supplied or returned */ +%aggregate_check(int, check_error, + PN_EOS, PN_ERR, PN_OVERFLOW, PN_UNDERFLOW, + PN_STATE_ERR, PN_ARG_ERR, PN_TIMEOUT); + +%aggregate_check(int, check_state, + PN_LOCAL_UNINIT, PN_LOCAL_ACTIVE, PN_LOCAL_CLOSED, + PN_REMOTE_UNINIT, PN_REMOTE_ACTIVE, PN_REMOTE_CLOSED); + +%aggregate_check(int, check_disposition, 0, + PN_RECEIVED, PN_ACCEPTED, PN_REJECTED, + PN_RELEASED, PN_MODIFIED); + +%aggregate_check(int, check_trace, + PN_TRACE_OFF, PN_TRACE_RAW, PN_TRACE_FRM, PN_TRACE_DRV); + +%aggregate_check(int, check_sasl_outcome, + PN_SASL_NONE, PN_SASL_OK, PN_SASL_AUTH, + PN_SASL_SYS, PN_SASL_PERM, PN_SASL_TEMP); + + +%contract pn_code(int code) +{ + require: + check_error(code); +} + +%contract pn_error() +{ + ensure: + pn_error != NULL; +} + +%contract pn_error_free(pn_error_t *error) +{ + require: + error != NULL; +} + +%contract pn_error_clear(pn_error_t *error) +{ + require: + error != NULL; +} + +%contract pn_error_set(pn_error_t *error, int code, const char *text) +{ + require: + error != NULL; +} + +%contract pn_error_vformat(pn_error_t *error, int code, const char *fmt, va_list ap) +{ + require: + error != NULL; +} + +%contract pn_error_format(pn_error_t *error, int code, const char *fmt, ...) +{ + require: + error != NULL; +} + +%contract pn_error_code(pn_error_t *error) +{ + require: + error != NULL; +} + +%contract pn_error_text(pn_error_t *error) +{ + require: + error != NULL; +} + +%include "proton/error.h" + +%contract pn_connection(void) +{ + ensure: + pn_connection != NULL; +} + +%contract pn_connection_state(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_error(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_get_container(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_set_container(pn_connection_t *connection, const char *container) +{ + require: + connection != NULL; +} + +%contract pn_connection_get_hostname(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_set_hostname(pn_connection_t *connection, const char *hostname) +{ + require: + connection != NULL; +} + +%contract pn_connection_remote_container(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_remote_hostname(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_work_head(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_work_next(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_session(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_transport(pn_connection_t *connection) +{ + require: + connection != NULL; + ensure: + pn_transport != NULL; +} + +%contract pn_session_head(pn_connection_t *connection, pn_state_t state) +{ + require: + connection != NULL; +} + +%contract pn_session_next(pn_session_t *session, pn_state_t state) +{ + require: + session != NULL; +} + +%contract pn_link_head(pn_connection_t *connection, pn_state_t state) +{ + require: + connection != NULL; +} + +%contract pn_link_next(pn_link_t *link, pn_state_t state) +{ + require: + link != NULL; +} + +%contract pn_connection_open(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_close(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_connection_free(pn_connection_t *connection) +{ + require: + connection != NULL; +} + +%contract pn_transport_error(pn_transport_t *transport) +{ + require: + transport != NULL; +} + +%contract pn_transport_input(pn_transport_t *transport, char *bytes, size_t available) +{ + require: + transport != NULL; +} + +%contract pn_transport_output(pn_transport_t *transport, char *bytes, size_t size) +{ + require: + transport != NULL; +} + +#%contract pn_transport_tick(pn_transport_t *transport, pn_timestamp_t now) +#{ +# # this method currently always returns 0 +#} + +%contract pn_transport_trace(pn_transport_t *transport, pn_trace_t trace) +{ + require: + transport != NULL; +} + +%contract pn_transport_free(pn_transport_t *transport) +{ + require: + transport != NULL; +} + +%contract pn_session_state(pn_session_t *session) +{ + require: + session != NULL; +} + +%contract pn_session_error(pn_session_t *session) +{ + require: + session != NULL; +} + +%contract pn_sender(pn_session_t *session, const char *name) +{ + require: + session != NULL; + ensure: + pn_sender != NULL; +} + +%contract pn_receiver(pn_session_t *session, const char *name) +{ + require: + session != NULL; + ensure: + pn_receiver != NULL; +} + +%contract pn_session_connection(pn_session_t *session) +{ + require: + session != NULL; + ensure: + pn_session_connection != NULL; +} + +%contract pn_session_open(pn_session_t *session) +{ + require: + session != NULL; +} + +%contract pn_session_close(pn_session_t *session) +{ + require: + session != NULL; +} + +%contract pn_session_free(pn_session_t *session) +{ + require: + session != NULL; +} + +%contract pn_link_name(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_is_sender(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_is_receiver(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_state(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_error(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_session(pn_link_t *link) +{ + require: + link != NULL; + ensure: + pn_link_session != NULL; +} + +%contract pn_link_get_target(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_get_source(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_set_source(pn_link_t *link, const char *source) +{ + require: + link != NULL; +} + +%contract pn_link_set_target(pn_link_t *link, const char *target) +{ + require: + link != NULL; +} + +%contract pn_link_remote_source(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_remote_target(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_delivery(pn_link_t *link, pn_delivery_tag_t tag) +{ + require: + link != NULL; + ensure: + pn_delivery != NULL; +} + +%contract pn_link_current(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_advance(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_credit(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_queued(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_link_unsettled(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_unsettled_head(pn_link_t *link) +{ + require: + link != NULL; +} + +%contract pn_unsettled_next(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_link_open(pn_link_t *sender) +{ + require: + sender != NULL; +} + +%contract pn_link_close(pn_link_t *sender) +{ + require: + sender != NULL; +} + +%contract pn_link_free(pn_link_t *sender) +{ + require: + sender != NULL; +} + +%contract pn_link_send(pn_link_t *sender, const char *bytes, size_t n) +{ + require: + sender != NULL; +} + +%contract pn_link_drained(pn_link_t *sender) +{ + require: + sender != NULL; +} + +%contract pn_link_flow(pn_link_t *receiver, int credit) +{ + require: + receiver != NULL; +} + +%contract pn_link_drain(pn_link_t *receiver, int credit) +{ + require: + receiver != NULL; +} + +%contract pn_link_recv(pn_link_t *receiver, char *bytes, size_t n) +{ + require: + receiver != NULL; +} + +%contract pn_delivery_tag(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_link(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_local_state(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_remote_state(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_settled(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_pending(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_writable(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_readable(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_updated(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_clear(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_update(pn_delivery_t *delivery, pn_disposition_t disposition) +{ + require: + delivery != NULL; + check_disposition(disposition); +} + +%contract pn_delivery_settle(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%contract pn_delivery_dump(pn_delivery_t *delivery) +{ + require: + delivery != NULL; +} + +%include "proton/condition.h" +%include "proton/connection.h" +%include "proton/session.h" +%include "proton/link.h" +%include "proton/terminus.h" +%include "proton/delivery.h" +%include "proton/disposition.h" +%ignore pn_transport_vlogf; +%include "proton/transport.h" +%include "proton/event.h" + +%inline %{ + /* assume the binding does the incref in the wrapper */ + pn_event_t* pn_event_copy(pn_event_t *evt) { return evt; } +%} + +%contract pn_event_copy(pn_event_t *evt) +{ + require: + evt != NULL; +} + +%contract pn_message_free(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_clear(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_errno(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_error(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_is_durable(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_durable(pn_message_t *msg, bool durable) +{ + require: + msg != NULL; +} + +%contract pn_message_get_priority(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_priority(pn_message_t *msg, uint8_t priority) +{ + require: + msg != NULL; +} + +%contract pn_message_get_ttl(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_ttl(pn_message_t *msg, pn_millis_t ttl) +{ + require: + msg != NULL; +} + +%contract pn_message_is_first_acquirer(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_first_acquirer(pn_message_t *msg, bool first) +{ + require: + msg != NULL; +} + +%contract pn_message_get_delivery_count(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_delivery_count(pn_message_t *msg, uint32_t count) +{ + require: + msg != NULL; +} + +%contract pn_message_get_id(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_id(pn_message_t *msg, pn_atom_t id) +{ + require: + msg != NULL; +} + +%contract pn_message_get_user_id(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_user_id(pn_message_t *msg, pn_bytes_t user_id) +{ + require: + msg != NULL; +} + +%contract pn_message_get_address(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_address(pn_message_t *msg, const char *address) +{ + require: + msg != NULL; +} + +%contract pn_message_get_subject(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_subject(pn_message_t *msg, const char *subject) +{ + require: + msg != NULL; +} + +%contract pn_message_get_reply_to(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_reply_to(pn_message_t *msg, const char *reply_to) +{ + require: + msg != NULL; +} + +%contract pn_message_get_correlation_id(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_correlation_id(pn_message_t *msg, pn_atom_t atom) +{ + require: + msg != NULL; +} + +%contract pn_message_get_content_type(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_content_type(pn_message_t *msg, const char *type) +{ + require: + msg != NULL; +} + +%contract pn_message_get_content_encoding(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_content_encoding(pn_message_t *msg, const char *encoding) +{ + require: + msg != NULL; +} + +%contract pn_message_get_expiry_time(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_expiry_time(pn_message_t *msg, pn_timestamp_t time) +{ + require: + msg != NULL; +} + +%contract pn_message_get_creation_time(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_creation_time(pn_message_t *msg, pn_timestamp_t time) +{ + require: + msg != NULL; +} + +%contract pn_message_get_group_id(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_group_id(pn_message_t *msg, const char *group_id) +{ + require: + msg != NULL; +} + +%contract pn_message_get_group_sequence(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_group_sequence(pn_message_t *msg, pn_sequence_t n) +{ + require: + msg != NULL; +} + +%contract pn_message_get_reply_to_group_id(pn_message_t *msg) +{ + require: + msg != NULL; +} + +%contract pn_message_set_reply_to_group_id(pn_message_t *msg, const char *reply_to_group_id) +{ + require: + msg != NULL; +} + +%contract pn_message_decode(pn_message_t *msg, const char *bytes, size_t size) +{ + require: + msg != NULL; +} + +%contract pn_message_encode(pn_message_t *msg, char *bytes, size_t *size) +{ + require: + msg != NULL; + *size >= 0; +} + +%include "proton/message.h" + +%contract pn_sasl() +{ + ensure: + pn_sasl != NULL; +} + +%contract pn_sasl_allowed_mechs(pn_sasl_t *sasl, const char *mechanisms) +{ + require: + sasl != NULL; +} + + +%contract pn_sasl_done(pn_sasl_t *sasl, pn_sasl_outcome_t outcome) +{ + require: + sasl != NULL; + check_sasl_outcome(outcome); +} + +%contract pn_sasl_outcome(pn_sasl_t *sasl) +{ + require: + sasl != NULL; + ensure: + check_sasl_outcome(pn_sasl_outcome); +} + +%include "proton/sasl.h" + +%contract pn_messenger_name(pn_messenger_t *messenger) +{ + require: + messenger != NULL; + ensure: + pn_messenger_name != NULL; +} + +%contract pn_messenger_set_timeout(pn_messenger_t *messenger, int timeout) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_get_timeout(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_free(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_errno(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_error(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_start(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_stop(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_subscribe(pn_messenger_t *messenger, const char *source) +{ + require: + messenger != NULL; + source != NULL; +} + +%contract pn_messenger_put(pn_messenger_t *messenger, pn_message_t *msg) +{ + require: + messenger != NULL; + msg != NULL; +} + +%contract pn_messenger_send(pn_messenger_t *messenger) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_recv(pn_messenger_t *messenger, int n) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_get(pn_messenger_t *messenger, pn_message_t *msg) +{ + require: + messenger != NULL; +} + +%contract pn_messenger_outgoing(pn_messenger_t *messenger) +{ + require: + messenger != NULL; + ensure: + pn_messenger_outgoing >= 0; +} + +%contract pn_messenger_incoming(pn_messenger_t *messenger) +{ + require: + messenger != NULL; + ensure: + pn_messenger_incoming >= 0; +} + + +%include "proton/messenger.h" + +%include "proton/selectable.h" + +%include "proton/ssl.h" + +%ignore pn_decode_atoms; +%ignore pn_encode_atoms; +%ignore pn_decode_one; + +%ignore pn_print_atom; +%ignore pn_type_str; +%ignore pn_print_atoms; +%ignore pn_format_atoms; +%ignore pn_format_atom; + +%ignore pn_fill_atoms; +%ignore pn_vfill_atoms; +%ignore pn_ifill_atoms; +%ignore pn_vifill_atoms; +%ignore pn_scan_atoms; +%ignore pn_vscan_atoms; +%ignore pn_data_vfill; +%ignore pn_data_vscan; + +%include "proton/codec.h" + +%inline %{ + pn_connection_t *pn_cast_pn_connection(void *x) { return (pn_connection_t *) x; } + pn_session_t *pn_cast_pn_session(void *x) { return (pn_session_t *) x; } + pn_link_t *pn_cast_pn_link(void *x) { return (pn_link_t *) x; } + pn_delivery_t *pn_cast_pn_delivery(void *x) { return (pn_delivery_t *) x; } + pn_transport_t *pn_cast_pn_transport(void *x) { return (pn_transport_t *) x; } + pn_reactor_t *pn_cast_pn_reactor(void *x) { return (pn_reactor_t *) x; } + pn_task_t *pn_cast_pn_task(void *x) { return (pn_task_t *) x; } + pn_selectable_t *pn_cast_pn_selectable(void *x) { return (pn_selectable_t *) x; } +%} + +/* Connection driver */ +%{ +#include <proton/connection_driver.h> +%} +/* Don't wrap the pn_connection_driver_t struct, just the functions */ +%ignore pn_connection_driver_t; +%ignore pn_connection_driver_verrorf; +%ignore pn_connection_driver_logf; +%ignore pn_connection_driver_vlogf; +%include "proton/connection_driver.h" + + +%include "proton/url.h" +%include "proton/reactor.h" +%include "proton/handlers.h" +%include "proton/cid.h"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/delivery.h ---------------------------------------------------------------------- diff --git a/c/include/proton/delivery.h b/c/include/proton/delivery.h new file mode 100644 index 0000000..a4dc1b6 --- /dev/null +++ b/c/include/proton/delivery.h @@ -0,0 +1,356 @@ +#ifndef PROTON_DELIVERY_H +#define PROTON_DELIVERY_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/disposition.h> +#include <proton/type_compat.h> +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * + * @copybrief delivery + * + * @addtogroup delivery + * @{ + */ + +/** + * An AMQP delivery tag. + */ +typedef pn_bytes_t pn_delivery_tag_t; + +/** + * Construct a delivery tag. + * + * @param[in] bytes a pointer to the beginning of the tag + * @param[in] size the size of the tag + * @return the delivery tag + */ +PN_EXTERN pn_delivery_tag_t pn_dtag(const char *bytes, size_t size); + +/** + * Create a delivery on a link. + * + * Every delivery object within a link must be supplied with a unique + * tag. Links maintain a sequence of delivery object in the order that + * they are created. + * + * @param[in] link a link object + * @param[in] tag the delivery tag + * @return a newly created delivery, or NULL if there was an error + */ +PN_EXTERN pn_delivery_t *pn_delivery(pn_link_t *link, pn_delivery_tag_t tag); + +/** + * **Deprecated** - Use ::pn_delivery_attachments(). + * + * Get the application context that is associated with a delivery object. + * + * The application context for a delivery may be set using + * ::pn_delivery_set_context. + * + * @param[in] delivery the delivery whose context is to be returned. + * @return the application context for the delivery object + */ +PN_EXTERN void *pn_delivery_get_context(pn_delivery_t *delivery); + +/** + * **Deprecated** - Use ::pn_delivery_attachments(). + * + * Set a new application context for a delivery object. + * + * The application context for a delivery object may be retrieved using + * ::pn_delivery_get_context. + * + * @param[in] delivery the delivery object + * @param[in] context the application context + */ +PN_EXTERN void pn_delivery_set_context(pn_delivery_t *delivery, void *context); + +/** + * Get the attachments that are associated with a delivery object. + * + * @param[in] delivery the delivery whose attachments are to be returned. + * @return the attachments for the delivery object + */ +PN_EXTERN pn_record_t *pn_delivery_attachments(pn_delivery_t *delivery); + +/** + * Get the tag for a delivery object. + * + * @param[in] delivery a delivery object + * @return the delivery tag + */ +PN_EXTERN pn_delivery_tag_t pn_delivery_tag(pn_delivery_t *delivery); + +/** + * Get the parent link for a delivery object. + * + * @param[in] delivery a delivery object + * @return the parent link + */ +PN_EXTERN pn_link_t *pn_delivery_link(pn_delivery_t *delivery); + +/** + * Get the local disposition for a delivery. + * + * The pointer returned by this object is valid until the delivery is + * settled. + * + * @param[in] delivery a delivery object + * @return a pointer to the local disposition + */ +PN_EXTERN pn_disposition_t *pn_delivery_local(pn_delivery_t *delivery); + +/** + * Get the local disposition state for a delivery. + * + * @param[in] delivery a delivery object + * @return the local disposition state + */ +PN_EXTERN uint64_t pn_delivery_local_state(pn_delivery_t *delivery); + +/** + * Get the remote disposition for a delivery. + * + * The pointer returned by this object is valid until the delivery is + * settled. + * + * @param[in] delivery a delivery object + * @return a pointer to the remote disposition + */ +PN_EXTERN pn_disposition_t *pn_delivery_remote(pn_delivery_t *delivery); + +/** + * Get the remote disposition state for a delivery. + * + * @param[in] delivery a delivery object + * @return the remote disposition state + */ +PN_EXTERN uint64_t pn_delivery_remote_state(pn_delivery_t *delivery); + +/** + * Check if a delivery is remotely settled. + * + * @param[in] delivery a delivery object + * @return true if the delivery is settled at the remote endpoint, false otherwise + */ +PN_EXTERN bool pn_delivery_settled(pn_delivery_t *delivery); + +/** + * Get the amount of pending message data for a delivery. + * + * @param[in] delivery a delivery object + * @return the amount of pending message data in bytes + */ +PN_EXTERN size_t pn_delivery_pending(pn_delivery_t *delivery); + +/** + * Check if a delivery only has partial message data. + * + * The receiver can expect more ::PN_DELIVERY events for this delivery containing + * the remainder of this message. + * + * @param[in] delivery a delivery object + * @return true if the delivery only contains part of a message, false otherwise + */ +PN_EXTERN bool pn_delivery_partial(pn_delivery_t *delivery); + +/** + * Check if a received delivery has been aborted. + * + * An aborted delivery means the sender cannot complete this message and the + * receiver should discard any data already received. The link remains open for + * future messages. + * + * You must still call pn_delivery_settle() to free local resources. An aborted + * delivery consumes a credit, use pn_link_flow() to issue new credit as for a + * successful delivery. + * + * Calling pn_link_recv() when the current delivery is aborted returns + * ::PN_ABORTED. + * + * @see pn_delivery_abort() + * @param[in] delivery a delivery object + * @return true if the delivery has been aborted, false otherwise + */ +PN_EXTERN bool pn_delivery_aborted(pn_delivery_t *delivery); + +/** + * Check if a delivery is writable. + * + * A delivery is considered writable if it is the current delivery on + * an outgoing link, and the link has positive credit. + * + * @param[in] delivery a delivery object + * @return true if the delivery is writable, false otherwise + */ +PN_EXTERN bool pn_delivery_writable(pn_delivery_t *delivery); + +/** + * Check if a delivery is readable. + * + * A delivery is considered readable if it is the current delivery on + * an incoming link. + * + * @param[in] delivery a delivery object + * @return true if the delivery is readable, false otherwise + */ +PN_EXTERN bool pn_delivery_readable(pn_delivery_t *delivery); + +/** + * Check if a delivery is updated. + * + * A delivery is considered updated whenever the peer communicates a + * new disposition for the delivery. Once a delivery becomes updated, + * it will remain so until ::pn_delivery_clear is called. + * + * @param[in] delivery a delivery object + * @return true if the delivery is updated, false otherwise + */ +PN_EXTERN bool pn_delivery_updated(pn_delivery_t *delivery); + +/** + * Update the disposition of a delivery. + * + * When update is invoked the updated disposition of the delivery will + * be communicated to the peer. + * + * @param[in] delivery a delivery object + * @param[in] state the updated delivery state + */ +PN_EXTERN void pn_delivery_update(pn_delivery_t *delivery, uint64_t state); + +/** + * Clear the updated flag for a delivery. + * + * See ::pn_delivery_updated. + * + * @param[in] delivery a delivery object + */ +PN_EXTERN void pn_delivery_clear(pn_delivery_t *delivery); + +/** + * Return true if delivery is the current delivery for its link. + * + * @param[in] delivery a delivery object + * @return true if delivery is the current delivery for its link. + */ +PN_EXTERN bool pn_delivery_current(pn_delivery_t *delivery); + +/** + * Abort a delivery being sent. + * + * Aborting means the sender cannot complete this message. It will not send any + * more data, and data sent so far should be discarded by the receiver. The + * link remains open for future messages. + * + * If some data has already been sent on the network, an AMQP "aborted" frame + * will be sent to inform the peer. If no data has yet been sent, the delivery + * will simply be forgotten. + * + * The delivery will be freed, and cannot be used after the call. + * + * @see pn_delivery_aborted() + * + * @param[in] delivery a delivery object + */ +PN_EXTERN void pn_delivery_abort(pn_delivery_t *delivery); + +/** + * Settle a delivery. + * + * A settled delivery can never be used again. + * + * @note If pn_delivery_current(delivery) is true before the call then + * pn_link_advance(pn_delivery_link(deliver)) is called automatically. + * + * @param[in] delivery a delivery object + */ +PN_EXTERN void pn_delivery_settle(pn_delivery_t *delivery); + +/** + * Utility function for printing details of a delivery. + * + * @param[in] delivery a delivery object + */ +PN_EXTERN void pn_delivery_dump(pn_delivery_t *delivery); + +/** + * Check if a delivery is buffered. + * + * A delivery that is buffered has not yet been written to the wire. + * + * Note that returning false does not imply that a delivery was + * definitely written to the wire. If false is returned, it is not + * known whether the delivery was actually written to the wire or not. + * + * @param[in] delivery a delivery object + * @return true if the delivery is buffered + */ +PN_EXTERN bool pn_delivery_buffered(pn_delivery_t *delivery); + +/** + * Extracts the first delivery on the connection that has pending + * operations. + * + * Retrieves the first delivery on the Connection that has pending + * operations. A readable delivery indicates message data is waiting + * to be read. A writable delivery indicates that message data may be + * sent. An updated delivery indicates that the delivery's disposition + * has changed. A delivery will never be both readable and writable, + * but it may be both readable and updated or both writable and + * updated. + * + * @param[in] connection the connection + * @return the first delivery object that needs to be serviced, else + * NULL if none + */ +PN_EXTERN pn_delivery_t *pn_work_head(pn_connection_t *connection); + +/** + * Get the next delivery on the connection that needs has pending + * operations. + * + * @param[in] delivery the previous delivery retrieved from + * either pn_work_head or pn_work_next + * @return the next delivery that has pending operations, else + * NULL if none + */ +PN_EXTERN pn_delivery_t *pn_work_next(pn_delivery_t *delivery); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* delivery.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/disposition.h ---------------------------------------------------------------------- diff --git a/c/include/proton/disposition.h b/c/include/proton/disposition.h new file mode 100644 index 0000000..e80bf8f --- /dev/null +++ b/c/include/proton/disposition.h @@ -0,0 +1,238 @@ +#ifndef PROTON_DISPOSITION_H +#define PROTON_DISPOSITION_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/type_compat.h> +#include <proton/condition.h> +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * + * @copybrief pn_disposition_t + * + * @addtogroup delivery + * @{ + */ + +/** + * A delivery state. + * + * Dispositions record the current state or final outcome of a + * transfer. Every delivery contains both a local and remote + * disposition. The local disposition holds the local state of the + * delivery, and the remote disposition holds the last known remote + * state of the delivery. + */ +typedef struct pn_disposition_t pn_disposition_t; + +/** + * The PN_RECEIVED delivery state is a non terminal state indicating + * how much (if any) message data has been received for a delivery. + */ +#define PN_RECEIVED (0x0000000000000023) + +/** + * The PN_ACCEPTED delivery state is a terminal state indicating that + * the delivery was successfully processed. Once in this state there + * will be no further state changes prior to the delivery being + * settled. + */ +#define PN_ACCEPTED (0x0000000000000024) + +/** + * The PN_REJECTED delivery state is a terminal state indicating that + * the delivery could not be processed due to some error condition. + * Once in this state there will be no further state changes prior to + * the delivery being settled. + */ +#define PN_REJECTED (0x0000000000000025) + +/** + * The PN_RELEASED delivery state is a terminal state indicating that + * the delivery is being returned to the sender. Once in this state + * there will be no further state changes prior to the delivery being + * settled. + */ +#define PN_RELEASED (0x0000000000000026) + +/** + * The PN_MODIFIED delivery state is a terminal state indicating that + * the delivery is being returned to the sender and should be + * annotated by the sender prior to further delivery attempts. Once in + * this state there will be no further state changes prior to the + * delivery being settled. + */ +#define PN_MODIFIED (0x0000000000000027) + +/** + * Get the type of a disposition. + * + * Defined values are: + * + * - ::PN_RECEIVED + * - ::PN_ACCEPTED + * - ::PN_REJECTED + * - ::PN_RELEASED + * - ::PN_MODIFIED + * + * @param[in] disposition a disposition object + * @return the type of the disposition + */ +PN_EXTERN uint64_t pn_disposition_type(pn_disposition_t *disposition); + +/** + * Name of a disposition type for logging and debugging: "received", "accepted" etc. + */ +PN_EXTERN const char *pn_disposition_type_name(uint64_t disposition_type); + +/** + * Access the condition object associated with a disposition. + * + * The ::pn_condition_t object retrieved by this operation may be + * modified prior to updating a delivery. When a delivery is updated, + * the condition described by the disposition is reported to the peer + * if applicable to the current delivery state, e.g. states such as + * ::PN_REJECTED. + * + * The pointer returned by this operation is valid until the parent + * delivery is settled. + * + * @param[in] disposition a disposition object + * @return a pointer to the disposition condition + */ +PN_EXTERN pn_condition_t *pn_disposition_condition(pn_disposition_t *disposition); + +/** + * Access the disposition as a raw pn_data_t. + * + * Dispositions are an extension point in the AMQP protocol. The + * disposition interface provides setters/getters for those + * dispositions that are predefined by the specification, however + * access to the raw disposition data is provided so that other + * dispositions can be used. + * + * The ::pn_data_t pointer returned by this operation is valid until + * the parent delivery is settled. + * + * @param[in] disposition a disposition object + * @return a pointer to the raw disposition data + */ +PN_EXTERN pn_data_t *pn_disposition_data(pn_disposition_t *disposition); + +/** + * Get the section number associated with a disposition. + * + * @param[in] disposition a disposition object + * @return a section number + */ +PN_EXTERN uint32_t pn_disposition_get_section_number(pn_disposition_t *disposition); + +/** + * Set the section number associated with a disposition. + * + * @param[in] disposition a disposition object + * @param[in] section_number a section number + */ +PN_EXTERN void pn_disposition_set_section_number(pn_disposition_t *disposition, uint32_t section_number); + +/** + * Get the section offset associated with a disposition. + * + * @param[in] disposition a disposition object + * @return a section offset + */ +PN_EXTERN uint64_t pn_disposition_get_section_offset(pn_disposition_t *disposition); + +/** + * Set the section offset associated with a disposition. + * + * @param[in] disposition a disposition object + * @param[in] section_offset a section offset + */ +PN_EXTERN void pn_disposition_set_section_offset(pn_disposition_t *disposition, uint64_t section_offset); + +/** + * Check if a disposition has the failed flag set. + * + * @param[in] disposition a disposition object + * @return true if the disposition has the failed flag set, false otherwise + */ +PN_EXTERN bool pn_disposition_is_failed(pn_disposition_t *disposition); + +/** + * Set the failed flag on a disposition. + * + * @param[in] disposition a disposition object + * @param[in] failed the value of the failed flag + */ +PN_EXTERN void pn_disposition_set_failed(pn_disposition_t *disposition, bool failed); + +/** + * Check if a disposition has the undeliverable flag set. + * + * @param[in] disposition a disposition object + * @return true if the disposition has the undeliverable flag set, false otherwise + */ +PN_EXTERN bool pn_disposition_is_undeliverable(pn_disposition_t *disposition); + +/** + * Set the undeliverable flag on a disposition. + * + * @param[in] disposition a disposition object + * @param[in] undeliverable the value of the undeliverable flag + */ +PN_EXTERN void pn_disposition_set_undeliverable(pn_disposition_t *disposition, bool undeliverable); + +/** + * Access the annotations associated with a disposition. + * + * The ::pn_data_t object retrieved by this operation may be modified + * prior to updating a delivery. When a delivery is updated, the + * annotations described by the ::pn_data_t are reported to the peer + * if applicable to the current delivery state, e.g. states such as + * ::PN_MODIFIED. The ::pn_data_t must be empty or contain a symbol + * keyed map. + * + * The pointer returned by this operation is valid until the parent + * delivery is settled. + * + * @param[in] disposition a disposition object + * @return the annotations associated with the disposition + */ +PN_EXTERN pn_data_t *pn_disposition_annotations(pn_disposition_t *disposition); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* disposition.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/engine.h ---------------------------------------------------------------------- diff --git a/c/include/proton/engine.h b/c/include/proton/engine.h new file mode 100644 index 0000000..9763e07 --- /dev/null +++ b/c/include/proton/engine.h @@ -0,0 +1,42 @@ +#ifndef PROTON_ENGINE_H +#define PROTON_ENGINE_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 + */ + +#include <proton/condition.h> +#include <proton/connection.h> +#include <proton/session.h> +#include <proton/terminus.h> +#include <proton/link.h> +#include <proton/delivery.h> +#include <proton/event.h> +#include <proton/transport.h> + +/** + * @endcond + */ + +#endif /* engine.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/error.h ---------------------------------------------------------------------- diff --git a/c/include/proton/error.h b/c/include/proton/error.h new file mode 100644 index 0000000..5bb603a --- /dev/null +++ b/c/include/proton/error.h @@ -0,0 +1,133 @@ +#ifndef PROTON_ERROR_H +#define PROTON_ERROR_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 <stdarg.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * + * @copybrief error + * + * @addtogroup error + * @{ + */ + +/** + * An int error `code` and some string `text` to describe the error. + */ +typedef struct pn_error_t pn_error_t; + +#define PN_OK (0) /**< No error */ +#define PN_EOS (-1) /**< End of stream */ +#define PN_ERR (-2) /**< General error */ +#define PN_OVERFLOW (-3) /**< Overflow error */ +#define PN_UNDERFLOW (-4) /**< Underflow error */ +#define PN_STATE_ERR (-5) /**< State error */ +#define PN_ARG_ERR (-6) /**< Argument error */ +#define PN_TIMEOUT (-7) /**< Timeout */ +#define PN_INTR (-8) /**< Interrupt */ +#define PN_INPROGRESS (-9) /**< In-progress */ +#define PN_OUT_OF_MEMORY (-10) /**< Out-of-memory error */ +#define PN_ABORTED (-11) /**< Delivery aborted error */ + +/** + * Get the name of the error code. Returned pointer is to a static + * constant, do not delete. + */ +PN_EXTERN const char *pn_code(int code); + +/** + * Create an error object. + */ +PN_EXTERN pn_error_t *pn_error(void); + +/** + * Free an error object. + */ +PN_EXTERN void pn_error_free(pn_error_t *error); + +/** + * Reset the error to a "no error" state with code == 0. + */ +PN_EXTERN void pn_error_clear(pn_error_t *error); + +/** + * Set the error code and text. Makes a copy of text. + */ +PN_EXTERN int pn_error_set(pn_error_t *error, int code, const char *text); + +/** + * Set the code and set the text using a printf-style formatted + * string. + */ +PN_EXTERN int pn_error_vformat(pn_error_t *error, int code, const char *fmt, va_list ap); + +/** + * Set the code and set the text using a printf-style formatted + * string. + */ +PN_EXTERN int pn_error_format(pn_error_t *error, int code, const char *fmt, ...); + +/** + * Get the the error code. + */ +PN_EXTERN int pn_error_code(pn_error_t *error); + +/** + * Get the error text. The returned pointer is owned by the + * pn_error_t. + */ +PN_EXTERN const char *pn_error_text(pn_error_t *error); + +/** + * Copy the src error. + */ +PN_EXTERN int pn_error_copy(pn_error_t *error, pn_error_t *src); + +/** + * @cond INTERNAL + */ +#define PN_RETURN_IF_ERROR(x) \ +do {\ +int r = (x);\ +if (r < 0) return r; \ +} while (0) +/** + * @endcond + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* error.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/event.h ---------------------------------------------------------------------- diff --git a/c/include/proton/event.h b/c/include/proton/event.h new file mode 100644 index 0000000..611b65c --- /dev/null +++ b/c/include/proton/event.h @@ -0,0 +1,582 @@ +#ifndef PROTON_EVENT_H +#define PROTON_EVENT_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/type_compat.h> +#include <proton/object.h> +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * + * @copybrief event + * + * @addtogroup event + * @{ + */ + +/** + * Notification of a state change in the protocol engine. + * + * The AMQP endpoint state modeled by the protocol engine is captured + * by the following object types: @link pn_delivery_t Deliveries + * @endlink, @link pn_link_t Links @endlink, @link pn_session_t + * Sessions @endlink, @link pn_connection_t Connections @endlink, and + * @link pn_transport_t Transports @endlink. These objects are related + * as follows: + * + * - @link pn_delivery_t Deliveries @endlink always have a single + * parent Link + * - @link pn_link_t Links @endlink always have a single parent + * Session + * - @link pn_session_t Sessions @endlink always have a single parent + * Connection + * - @link pn_connection_t Connections @endlink optionally have at + * most one associated Transport + * - @link pn_transport_t Transports @endlink optionally have at most + * one associated Connection + * + * Every event has a type (see ::pn_event_type_t) that identifies what + * sort of state change has occurred along with a pointer to the + * object whose state has changed (as well as its associated objects). + * + * Events are accessed by creating a @link pn_collector_t Collector + * @endlink with ::pn_collector() and registering it with the @link + * pn_connection_t Connection @endlink of interest through use of + * ::pn_connection_collect(). Once a collector has been registered, + * ::pn_collector_peek() and ::pn_collector_pop() are used to access + * and process events. + */ +typedef struct pn_event_t pn_event_t; + +/** + * An event type. + */ +typedef enum { + /** + * Defined as a programming convenience. No event of this type will + * ever be generated. + */ + PN_EVENT_NONE = 0, + + /** + * A reactor has been started. Events of this type point to the reactor. + */ + PN_REACTOR_INIT, + + /** + * A reactor has no more events to process. Events of this type + * point to the reactor. + */ + PN_REACTOR_QUIESCED, + + /** + * A reactor has been stopped. Events of this type point to the reactor. + */ + PN_REACTOR_FINAL, + + /** + * A timer event has occurred. + */ + PN_TIMER_TASK, + + /** + * The connection has been created. This is the first event that + * will ever be issued for a connection. Events of this type point + * to the relevant connection. + */ + PN_CONNECTION_INIT, + + /** + * The connection has been bound to a transport. This event is + * issued when the ::pn_transport_bind() operation is invoked. + */ + PN_CONNECTION_BOUND, + + /** + * The connection has been unbound from its transport. This event is + * issued when the ::pn_transport_unbind() operation is invoked. + */ + PN_CONNECTION_UNBOUND, + + /** + * The local connection endpoint has been closed. Events of this + * type point to the relevant connection. + */ + PN_CONNECTION_LOCAL_OPEN, + + /** + * The remote endpoint has opened the connection. Events of this + * type point to the relevant connection. + */ + PN_CONNECTION_REMOTE_OPEN, + + /** + * The local connection endpoint has been closed. Events of this + * type point to the relevant connection. + */ + PN_CONNECTION_LOCAL_CLOSE, + + /** + * The remote endpoint has closed the connection. Events of this + * type point to the relevant connection. + */ + PN_CONNECTION_REMOTE_CLOSE, + + /** + * The connection has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a connection. + */ + PN_CONNECTION_FINAL, + + /** + * The session has been created. This is the first event that will + * ever be issued for a session. + */ + PN_SESSION_INIT, + + /** + * The local session endpoint has been opened. Events of this type + * point ot the relevant session. + */ + PN_SESSION_LOCAL_OPEN, + + /** + * The remote endpoint has opened the session. Events of this type + * point to the relevant session. + */ + PN_SESSION_REMOTE_OPEN, + + /** + * The local session endpoint has been closed. Events of this type + * point ot the relevant session. + */ + PN_SESSION_LOCAL_CLOSE, + + /** + * The remote endpoint has closed the session. Events of this type + * point to the relevant session. + */ + PN_SESSION_REMOTE_CLOSE, + + /** + * The session has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a session. + */ + PN_SESSION_FINAL, + + /** + * The link has been created. This is the first event that will ever + * be issued for a link. + */ + PN_LINK_INIT, + + /** + * The local link endpoint has been opened. Events of this type + * point ot the relevant link. + */ + PN_LINK_LOCAL_OPEN, + + /** + * The remote endpoint has opened the link. Events of this type + * point to the relevant link. + */ + PN_LINK_REMOTE_OPEN, + + /** + * The local link endpoint has been closed. Events of this type + * point ot the relevant link. + */ + PN_LINK_LOCAL_CLOSE, + + /** + * The remote endpoint has closed the link. Events of this type + * point to the relevant link. + */ + PN_LINK_REMOTE_CLOSE, + + /** + * The local link endpoint has been detached. Events of this type + * point to the relevant link. + */ + PN_LINK_LOCAL_DETACH, + + /** + * The remote endpoint has detached the link. Events of this type + * point to the relevant link. + */ + PN_LINK_REMOTE_DETACH, + + /** + * The flow control state for a link has changed. Events of this + * type point to the relevant link. + */ + PN_LINK_FLOW, + + /** + * The link has been freed and any outstanding processing has been + * completed. This is the final event that will ever be issued for a + * link. Events of this type point to the relevant link. + */ + PN_LINK_FINAL, + + /** + * A delivery has been created or updated. Events of this type point + * to the relevant delivery. + */ + PN_DELIVERY, + + /** + * The transport has new data to read and/or write. Events of this + * type point to the relevant transport. + */ + PN_TRANSPORT, + + /** + * The transport has authenticated. If this is received by a server + * the associated transport has authenticated an incoming connection + * and pn_transport_get_user() can be used to obtain the authenticated + * user. + */ + PN_TRANSPORT_AUTHENTICATED, + + /** + * Indicates that a transport error has occurred. Use + * ::pn_transport_condition() to access the details of the error + * from the associated transport. + */ + PN_TRANSPORT_ERROR, + + /** + * Indicates that the "head" or writing end of the transport has been closed. This + * means the transport will never produce more bytes for output to + * the network. Events of this type point to the relevant transport. + */ + PN_TRANSPORT_HEAD_CLOSED, + + /** + * Indicates that the tail of the transport has been closed. This + * means the transport will never be able to process more bytes from + * the network. Events of this type point to the relevant transport. + */ + PN_TRANSPORT_TAIL_CLOSED, + + /** + * Indicates that the both the head and tail of the transport are + * closed. Events of this type point to the relevant transport. + */ + PN_TRANSPORT_CLOSED, + + PN_SELECTABLE_INIT, + PN_SELECTABLE_UPDATED, + PN_SELECTABLE_READABLE, + PN_SELECTABLE_WRITABLE, + PN_SELECTABLE_ERROR, + PN_SELECTABLE_EXPIRED, + PN_SELECTABLE_FINAL, + + /** + * pn_connection_wake() was called. + * Events of this type point to the @ref pn_connection_t. + */ + PN_CONNECTION_WAKE, + + /** + * Indicates the listener has an incoming connection, call pn_listener_accept2() + * to accept it. + * Events of this type point to the @ref pn_listener_t. + */ + PN_LISTENER_ACCEPT, + + /** + * Indicates the listener has closed. pn_listener_condition() provides error information. + * Events of this type point to the @ref pn_listener_t. + */ + PN_LISTENER_CLOSE, + + /** + * Indicates pn_proactor_interrupt() was called to interrupt a proactor thread. + * Events of this type point to the @ref pn_proactor_t. + */ + PN_PROACTOR_INTERRUPT, + + /** + * Timeout set by pn_proactor_set_timeout() time limit expired. + * Events of this type point to the @ref pn_proactor_t. + */ + PN_PROACTOR_TIMEOUT, + + /** + * The proactor has become inactive: all listeners and connections were closed + * and the timeout (if set) expired or was cancelled. There will be no + * further events unless new listeners or connections are opened, or a new + * timeout is set (possibly in other threads in a multi-threaded program.) + * + * Events of this type point to the @ref pn_proactor_t. + */ + PN_PROACTOR_INACTIVE, + + /** + * The listener is listening. + * Events of this type point to the @ref pn_listener_t. + */ + PN_LISTENER_OPEN +} pn_event_type_t; + + +/** + * Get a human readable name for an event type. + * + * @param[in] type an event type + * @return a human readable name + */ +PN_EXTERN const char *pn_event_type_name(pn_event_type_t type); + +/** + * Construct a collector. + * + * A collector is used to register interest in events produced by one + * or more ::pn_connection_t objects. Collectors are not currently + * thread safe, so synchronization must be used if they are to be + * shared between multiple connection objects. + */ +PN_EXTERN pn_collector_t *pn_collector(void); + +/** + * Free a collector. + * + * @param[in] collector a collector to free, or NULL + */ +PN_EXTERN void pn_collector_free(pn_collector_t *collector); + +/** + * Release a collector. Once in a released state a collector will + * drain any internally queued events (thereby releasing any pointers + * they may hold), shrink it's memory footprint to a minimum, and + * discard any newly created events. + * + * @param[in] collector a collector object + */ +PN_EXTERN void pn_collector_release(pn_collector_t *collector); + +/** + * Drain a collector: remove and discard all events. + * + * @param[in] collector a collector object + */ +PN_EXTERN void pn_collector_drain(pn_collector_t *collector); + +/** + * Place a new event on a collector. + * + * This operation will create a new event of the given type and + * context and return a pointer to the newly created event. In some + * cases an event of the given type and context can be elided. When + * this happens, this operation will return a NULL pointer. + * + * @param[in] collector a collector object + * @param[in] clazz class of the context + * @param[in] context the event context + * @param[in] type the event type + * + * @return a pointer to the newly created event or NULL if the event + * was elided + */ + +PN_EXTERN pn_event_t *pn_collector_put(pn_collector_t *collector, + const pn_class_t *clazz, void *context, + pn_event_type_t type); + +/** + * Access the head event contained by a collector. + * + * This operation will continue to return the same event until it is + * cleared by using ::pn_collector_pop. The pointer return by this + * operation will be valid until ::pn_collector_pop is invoked or + * ::pn_collector_free is called, whichever happens sooner. + * + * @param[in] collector a collector object + * @return a pointer to the head event contained in the collector + */ +PN_EXTERN pn_event_t *pn_collector_peek(pn_collector_t *collector); + +/** + * Remove the head event on a collector. + * + * @param[in] collector a collector object + * @return true if the event was popped, false if the collector is empty + */ +PN_EXTERN bool pn_collector_pop(pn_collector_t *collector); + +/** + * Pop and return the head event, returns NULL if the collector is empty. + * The returned pointer is valid till the next call of pn_collector_next(). + * + * @param[in] collector a collector object + * @return the next event. + */ +PN_EXTERN pn_event_t *pn_collector_next(pn_collector_t *collector); + +/** + * Return the same pointer as the most recent call to pn_collector_next(). + * + * @param[in] collector a collector object + * @return a pointer to the event returned by previous call to pn_collector_next() + */ +PN_EXTERN pn_event_t *pn_collector_prev(pn_collector_t *collector); + +/** + * Check if there are more events after the current head event. If this + * returns true, then pn_collector_peek() will return an event even + * after pn_collector_pop() is called. + * + * @param[in] collector a collector object + * @return true if the collector has more than the current event + */ +PN_EXTERN bool pn_collector_more(pn_collector_t *collector); + +/** + * Get the type of an event. + * + * @param[in] event an event object + * @return the type of the event + */ +PN_EXTERN pn_event_type_t pn_event_type(pn_event_t *event); + +/** + * Get the class associated with the event context. + * + * @param[in] event an event object + * @return the class associated with the event context + */ +PN_EXTERN const pn_class_t *pn_event_class(pn_event_t *event); + +/** + * Get the context associated with an event. + */ +PN_EXTERN void *pn_event_context(pn_event_t *event); + +/** + * Get the connection associated with an event. + * + * @param[in] event an event object + * @return the connection associated with the event (or NULL) + */ +PN_EXTERN pn_connection_t *pn_event_connection(pn_event_t *event); + +/** + * Get the session associated with an event. + * + * @param[in] event an event object + * @return the session associated with the event (or NULL) + */ +PN_EXTERN pn_session_t *pn_event_session(pn_event_t *event); + +/** + * Get the link associated with an event. + * + * @param[in] event an event object + * @return the link associated with the event (or NULL) + */ +PN_EXTERN pn_link_t *pn_event_link(pn_event_t *event); + +/** + * Get the delivery associated with an event. + * + * @param[in] event an event object + * @return the delivery associated with the event (or NULL) + */ +PN_EXTERN pn_delivery_t *pn_event_delivery(pn_event_t *event); + +/** + * Get the transport associated with an event. + * + * @param[in] event an event object + * @return the transport associated with the event (or NULL) + */ +PN_EXTERN pn_transport_t *pn_event_transport(pn_event_t *event); + +/** + * Get any attachments associated with an event. + * + * @param[in] event an event object + * @return the record holding the attachments + */ +PN_EXTERN pn_record_t *pn_event_attachments(pn_event_t *event); + +/** + * If the event context object has a condition and the condition is set + * return it, otherwise return NULL. + * If the event context object has remote and local conditions, + * try the remote condition first, then the local. + */ +PN_EXTERN struct pn_condition_t *pn_event_condition(pn_event_t *event); + +/** + * **Unsettled API** - A batch of events that must be handled in sequence. + * Call pn_event_batch_next() in a loop until it returns NULL to extract + * the events. + */ +typedef struct pn_event_batch_t pn_event_batch_t; + +/* NOTE: there is deliberately no peek(), more() or other look-ahead on an event + * batch. We want to know exactly which events have been handled, next() only + * allows the user to get each event exactly once, in order. + */ + +/** + * **Unsettled API** - Remove the next event from the batch and return + * it. NULL means the batch is empty. The returned event pointer is + * valid until pn_event_batch_next() is called again on the same + * batch. + */ +PN_EXTERN pn_event_t *pn_event_batch_next(pn_event_batch_t *batch); + +/** + * @cond INTERNAL + * + * pn_event_batch_next() can be re-implemented for different behaviors in different contexts. + */ +struct pn_event_batch_t { + pn_event_t *(*next_event)(pn_event_batch_t *batch); +}; +/** + * @endcond + */ + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* event.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/handlers.h ---------------------------------------------------------------------- diff --git a/c/include/proton/handlers.h b/c/include/proton/handlers.h new file mode 100644 index 0000000..feff0fe --- /dev/null +++ b/c/include/proton/handlers.h @@ -0,0 +1,53 @@ +#ifndef PROTON_HANDLERS_H +#define PROTON_HANDLERS_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/type_compat.h> +#include <proton/reactor.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @cond INTERNAL + */ + +typedef pn_handler_t pn_handshaker_t; +typedef pn_handler_t pn_iohandler_t; +typedef pn_handler_t pn_flowcontroller_t; + +PNX_EXTERN pn_handshaker_t *pn_handshaker(void); +PNX_EXTERN pn_iohandler_t *pn_iohandler(void); +PNX_EXTERN pn_flowcontroller_t *pn_flowcontroller(int window); + +/** + * @endcond + */ + +#ifdef __cplusplus +} +#endif + +#endif /* handlers.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/c/include/proton/import_export.h ---------------------------------------------------------------------- diff --git a/c/include/proton/import_export.h b/c/include/proton/import_export.h new file mode 100644 index 0000000..14e6b82 --- /dev/null +++ b/c/include/proton/import_export.h @@ -0,0 +1,86 @@ +#ifndef PROTON_IMPORT_EXPORT_H +#define PROTON_IMPORT_EXPORT_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 + */ + +/* + Compiler specific mechanisms for managing the import and export of + symbols between shared objects. + PN_EXPORT - Export declaration + PN_IMPORT - Import declaration +*/ + +#if defined(WIN32) && !defined(PROTON_DECLARE_STATIC) +/* Import and Export definitions for Windows: */ +# define PN_EXPORT __declspec(dllexport) +# define PN_IMPORT __declspec(dllimport) +#else +/* Non-Windows (Linux, etc.) definitions */ +# define PN_EXPORT __attribute ((visibility ("default"))) +# define PN_IMPORT +#endif + + +/* For core proton library symbols */ +#if defined(qpid_proton_core_EXPORTS) || defined(qpid_proton_EXPORTS) +# define PN_EXTERN PN_EXPORT +#else +# define PN_EXTERN PN_IMPORT +#endif + +/* For proactor proton symbols */ +#if defined(qpid_proton_proactor_EXPORTS) || defined(qpid_proton_EXPORTS) +# define PNP_EXTERN PN_EXPORT +#else +# define PNP_EXTERN PN_IMPORT +#endif + +/* For extra proton symbols */ +#if defined(qpid_proton_EXPORTS) +# define PNX_EXTERN PN_EXPORT +#else +# define PNX_EXTERN PN_IMPORT +#endif + +#if ! defined(PN_USE_DEPRECATED_API) +# if defined(WIN32) +# define PN_DEPRECATED(message) __declspec(deprecated(message)) +# elif defined __GNUC__ +# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40500 +# define PN_DEPRECATED(message) __attribute__((deprecated)) +# else +# define PN_DEPRECATED(message) __attribute__((deprecated(message))) +# endif +# endif +#endif +#ifndef PN_DEPRECATED +# define PN_DEPRECATED(message) +#endif +/** + * @endcond + */ + +#endif /* import_export.h */ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org