PROTON-2429: Introduce restricted pn_msgid_t typedef
This is a typedef for pn_atom_t but indicates that the values are
restricted to be the subset that is allowed in message id and
correlation id.
diff --git a/c/include/proton/codec.h b/c/include/proton/codec.h
index cc2e2f2..5cd54ad 100644
--- a/c/include/proton/codec.h
+++ b/c/include/proton/codec.h
@@ -301,6 +301,17 @@
} pn_atom_t;
/**
+ * A type that holds scalar AMQP values that are valid for
+ * message id and correlation id fields.
+ *
+ * This is actually another name for ::pn_atom_t as it is just a
+ * restricted version of that type.
+ *
+ * @ingroup api_types
+ */
+typedef pn_atom_t pn_msgid_t;
+
+/**
* @addtogroup data
* @{
*/
diff --git a/c/include/proton/message.h b/c/include/proton/message.h
index 80b9e00..6a31eaf 100644
--- a/c/include/proton/message.h
+++ b/c/include/proton/message.h
@@ -286,7 +286,7 @@
* @param[in] msg a message object
* @return the message id
*/
-PN_EXTERN pn_atom_t pn_message_get_id (pn_message_t *msg);
+PN_EXTERN pn_msgid_t pn_message_get_id (pn_message_t *msg);
/**
* Set the id for a message.
@@ -299,7 +299,7 @@
* @param[in] id the new value of the message id
* @return zero on success or an error code on failure
*/
-PN_EXTERN int pn_message_set_id (pn_message_t *msg, pn_atom_t id);
+PN_EXTERN int pn_message_set_id (pn_message_t *msg, pn_msgid_t id);
/**
* Get the user id for a message.
@@ -443,7 +443,7 @@
* @param[in] msg a message object
* @return the message id
*/
-PN_EXTERN pn_atom_t pn_message_get_correlation_id (pn_message_t *msg);
+PN_EXTERN pn_msgid_t pn_message_get_correlation_id (pn_message_t *msg);
/**
* Set the correlation id for a message.
@@ -456,7 +456,7 @@
* @param[in] id the new value of the message id
* @return zero on success or an error code on failure
*/
-PN_EXTERN int pn_message_set_correlation_id (pn_message_t *msg, pn_atom_t id);
+PN_EXTERN int pn_message_set_correlation_id (pn_message_t *msg, pn_msgid_t id);
/**
* Get the content_type for a message.
diff --git a/c/src/core/message.c b/c/src/core/message.c
index a52dce8..987ff20 100644
--- a/c/src/core/message.c
+++ b/c/src/core/message.c
@@ -481,12 +481,14 @@
assert(msg);
return msg->id;
}
-pn_atom_t pn_message_get_id(pn_message_t *msg)
+
+pn_msgid_t pn_message_get_id(pn_message_t *msg)
{
assert(msg);
return pn_data_get_atom(msg->id);
}
-int pn_message_set_id(pn_message_t *msg, pn_atom_t id)
+
+int pn_message_set_id(pn_message_t *msg, pn_msgid_t id)
{
assert(msg);
pn_data_rewind(msg->id);
@@ -552,12 +554,14 @@
assert(msg);
return msg->correlation_id;
}
-pn_atom_t pn_message_get_correlation_id(pn_message_t *msg)
+
+pn_msgid_t pn_message_get_correlation_id(pn_message_t *msg)
{
assert(msg);
return pn_data_get_atom(msg->correlation_id);
}
-int pn_message_set_correlation_id(pn_message_t *msg, pn_atom_t atom)
+
+int pn_message_set_correlation_id(pn_message_t *msg, pn_msgid_t id)
{
assert(msg);
pn_data_rewind(msg->correlation_id);