C AMQP Protocol Engine API  0.5
proton/message.h
Go to the documentation of this file.
00001 #ifndef PROTON_MESSAGE_H
00002 #define PROTON_MESSAGE_H 1
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include <proton/import_export.h>
00026 #include <proton/types.h>
00027 #include <proton/codec.h>
00028 #include <proton/error.h>
00029 #include <sys/types.h>
00030 #ifndef __cplusplus
00031 #include <stdbool.h>
00032 #endif
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 typedef struct pn_message_t pn_message_t;
00039 
00040 typedef enum {
00041   PN_DATA,
00042   PN_TEXT,
00043   PN_AMQP,
00044   PN_JSON
00045 } pn_format_t;
00046 
00047 #define PN_DEFAULT_PRIORITY (4)
00048 
00049 PN_EXTERN pn_message_t * pn_message(void);
00050 PN_EXTERN void           pn_message_free(pn_message_t *msg);
00051 
00052 PN_EXTERN void           pn_message_clear(pn_message_t *msg);
00053 PN_EXTERN int            pn_message_errno(pn_message_t *msg);
00054 PN_EXTERN pn_error_t    *pn_message_error(pn_message_t *msg);
00055 
00056 PN_EXTERN bool           pn_message_is_inferred(pn_message_t *msg);
00057 PN_EXTERN int            pn_message_set_inferred(pn_message_t *msg, bool inferred);
00058 
00059 // standard message headers and properties
00060 PN_EXTERN bool           pn_message_is_durable            (pn_message_t *msg);
00061 PN_EXTERN int            pn_message_set_durable           (pn_message_t *msg, bool durable);
00062 
00063 PN_EXTERN uint8_t        pn_message_get_priority          (pn_message_t *msg);
00064 PN_EXTERN int            pn_message_set_priority          (pn_message_t *msg, uint8_t priority);
00065 
00066 PN_EXTERN pn_millis_t    pn_message_get_ttl               (pn_message_t *msg);
00067 PN_EXTERN int            pn_message_set_ttl               (pn_message_t *msg, pn_millis_t ttl);
00068 
00069 PN_EXTERN bool           pn_message_is_first_acquirer     (pn_message_t *msg);
00070 PN_EXTERN int            pn_message_set_first_acquirer    (pn_message_t *msg, bool first);
00071 
00072 PN_EXTERN uint32_t       pn_message_get_delivery_count    (pn_message_t *msg);
00073 PN_EXTERN int            pn_message_set_delivery_count    (pn_message_t *msg, uint32_t count);
00074 
00075 PN_EXTERN pn_data_t *    pn_message_id                    (pn_message_t *msg);
00076 PN_EXTERN pn_atom_t      pn_message_get_id                (pn_message_t *msg);
00077 PN_EXTERN int            pn_message_set_id                (pn_message_t *msg, pn_atom_t id);
00078 
00079 PN_EXTERN pn_bytes_t     pn_message_get_user_id           (pn_message_t *msg);
00080 PN_EXTERN int            pn_message_set_user_id           (pn_message_t *msg, pn_bytes_t user_id);
00081 
00082 PN_EXTERN const char *   pn_message_get_address           (pn_message_t *msg);
00083 PN_EXTERN int            pn_message_set_address           (pn_message_t *msg, const char *address);
00084 
00085 PN_EXTERN const char *   pn_message_get_subject           (pn_message_t *msg);
00086 PN_EXTERN int            pn_message_set_subject           (pn_message_t *msg, const char *subject);
00087 
00088 PN_EXTERN const char *   pn_message_get_reply_to          (pn_message_t *msg);
00089 PN_EXTERN int            pn_message_set_reply_to          (pn_message_t *msg, const char *reply_to);
00090 
00091 PN_EXTERN pn_data_t *    pn_message_correlation_id        (pn_message_t *msg);
00092 PN_EXTERN pn_atom_t      pn_message_get_correlation_id    (pn_message_t *msg);
00093 PN_EXTERN int            pn_message_set_correlation_id    (pn_message_t *msg, pn_atom_t atom);
00094 
00095 PN_EXTERN const char *   pn_message_get_content_type      (pn_message_t *msg);
00096 PN_EXTERN int            pn_message_set_content_type      (pn_message_t *msg, const char *type);
00097 
00098 PN_EXTERN const char *   pn_message_get_content_encoding  (pn_message_t *msg);
00099 PN_EXTERN int            pn_message_set_content_encoding  (pn_message_t *msg, const char *encoding);
00100 
00101 PN_EXTERN pn_timestamp_t pn_message_get_expiry_time       (pn_message_t *msg);
00102 PN_EXTERN int            pn_message_set_expiry_time       (pn_message_t *msg, pn_timestamp_t time);
00103 
00104 PN_EXTERN pn_timestamp_t pn_message_get_creation_time     (pn_message_t *msg);
00105 PN_EXTERN int            pn_message_set_creation_time     (pn_message_t *msg, pn_timestamp_t time);
00106 
00107 PN_EXTERN const char *   pn_message_get_group_id          (pn_message_t *msg);
00108 PN_EXTERN int            pn_message_set_group_id          (pn_message_t *msg, const char *group_id);
00109 
00110 PN_EXTERN pn_sequence_t  pn_message_get_group_sequence    (pn_message_t *msg);
00111 PN_EXTERN int            pn_message_set_group_sequence    (pn_message_t *msg, pn_sequence_t n);
00112 
00113 PN_EXTERN const char *   pn_message_get_reply_to_group_id (pn_message_t *msg);
00114 PN_EXTERN int            pn_message_set_reply_to_group_id (pn_message_t *msg, const char *reply_to_group_id);
00115 
00116 PN_EXTERN pn_format_t pn_message_get_format(pn_message_t *message);
00117 PN_EXTERN int pn_message_set_format(pn_message_t *message, pn_format_t format);
00118 
00119 PN_EXTERN int pn_message_load(pn_message_t *message, const char *data, size_t size);
00120 PN_EXTERN int pn_message_load_data(pn_message_t *message, const char *data, size_t size);
00121 PN_EXTERN int pn_message_load_text(pn_message_t *message, const char *data, size_t size);
00122 PN_EXTERN int pn_message_load_amqp(pn_message_t *message, const char *data, size_t size);
00123 PN_EXTERN int pn_message_load_json(pn_message_t *message, const char *data, size_t size);
00124 
00125 PN_EXTERN int pn_message_save(pn_message_t *message, char *data, size_t *size);
00126 PN_EXTERN int pn_message_save_data(pn_message_t *message, char *data, size_t *size);
00127 PN_EXTERN int pn_message_save_text(pn_message_t *message, char *data, size_t *size);
00128 PN_EXTERN int pn_message_save_amqp(pn_message_t *message, char *data, size_t *size);
00129 PN_EXTERN int pn_message_save_json(pn_message_t *message, char *data, size_t *size);
00130 
00131 PN_EXTERN pn_data_t *pn_message_instructions(pn_message_t *msg);
00132 PN_EXTERN pn_data_t *pn_message_annotations(pn_message_t *msg);
00133 PN_EXTERN pn_data_t *pn_message_properties(pn_message_t *msg);
00134 PN_EXTERN pn_data_t *pn_message_body(pn_message_t *msg);
00135 
00136 PN_EXTERN int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size);
00137 PN_EXTERN int pn_message_encode(pn_message_t *msg, char *bytes, size_t *size);
00138 
00139 PN_EXTERN ssize_t pn_message_data(char *dst, size_t available, const char *src, size_t size);
00140 
00141 #ifdef __cplusplus
00142 }
00143 #endif
00144 
00145 #endif /* message.h */