replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / extlibs / tinycbor / tinycbor / src / cborencoder_close_container_checked.c
index aad2ebf..cad8335 100644 (file)
 ****************************************************************************/
 
 #define _BSD_SOURCE 1
+#define _DEFAULT_SOURCE 1
+#ifndef __STDC_LIMIT_MACROS
+#  define __STDC_LIMIT_MACROS 1
+#endif
+
 #include "cbor.h"
 #include "cborconstants_p.h"
 #include "compilersupport_p.h"
 
 #include "assert_p.h"       /* Always include last */
 
+/**
+ * \addtogroup CborEncoding
+ * @{
+ */
+
+/**
+ *
+ * Closes the CBOR container (array or map) provided by \a containerEncoder and
+ * updates the CBOR stream provided by \a encoder. Both parameters must be the
+ * same as were passed to cbor_encoder_create_array() or
+ * cbor_encoder_create_map().
+ *
+ * Unlike cbor_encoder_close_container(), this function checks that the number
+ * of items (or pair of items, in the case of a map) was correct. If the number
+ * of items inserted does not match the length originally passed to
+ * cbor_encoder_create_array() or cbor_encoder_create_map(), this function
+ * returns either CborErrorTooFewItems or CborErrorTooManyItems.
+ *
+ * \sa cbor_encoder_create_array(), cbor_encoder_create_map()
+ */
 CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborEncoder *containerEncoder)
 {
     const uint8_t *ptr = encoder->ptr;
@@ -39,7 +64,7 @@ CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborE
     if (containerEncoder->flags & CborIteratorFlag_UnknownLength || encoder->end == NULL)
         return err;
 
-    // check what the original length was
+    /* check what the original length was */
     uint64_t actually_added;
     err = extract_number(&ptr, encoder->ptr, &actually_added);
     if (err)
@@ -53,3 +78,5 @@ CborError cbor_encoder_close_container_checked(CborEncoder *encoder, const CborE
     return actually_added == containerEncoder->added ? CborNoError :
            actually_added < containerEncoder->added ? CborErrorTooManyItems : CborErrorTooFewItems;
 }
+
+/** @} */