summaryrefslogtreecommitdiffstats
path: root/tinySIGCOMP/src/tcomp_compressor_dummy.c
diff options
context:
space:
mode:
Diffstat (limited to 'tinySIGCOMP/src/tcomp_compressor_dummy.c')
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor_dummy.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/tinySIGCOMP/src/tcomp_compressor_dummy.c b/tinySIGCOMP/src/tcomp_compressor_dummy.c
index 34d062d..f5efdf6 100755
--- a/tinySIGCOMP/src/tcomp_compressor_dummy.c
+++ b/tinySIGCOMP/src/tcomp_compressor_dummy.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -43,62 +43,62 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// @brief Dummy compressor as per RFC 4896 subclause 11. This function is used to create uncompressed sigcomp message.
-/// Used if none match.
+/// Used if none match.
///
-/// @param [in,out] lpCompartment The compartment to use.
-/// @param [in,out] input_ptr The input buffer containing the message to compress.
-/// @param input_size The size of the input buffer.
-/// @param [in,out] output_ptr The output buffer where to copy the compressed message.
+/// @param [in,out] lpCompartment The compartment to use.
+/// @param [in,out] input_ptr The input buffer containing the message to compress.
+/// @param input_size The size of the input buffer.
+/// @param [in,out] output_ptr The output buffer where to copy the compressed message.
/// @param [in,out] output_size The size of the output buffer.
-/// @param stream Indicates whether it's a stream buffer or not.
+/// @param stream Indicates whether it's a stream buffer or not.
///
-/// @return 1 if succedd and 0 otherwise.
+/// @return 1 if succedd and 0 otherwise.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t tcomp_compressor_dummy_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, tsk_size_t input_size, void *output_ptr, tsk_size_t *output_size, tsk_bool_t stream)
{
- tcomp_buffer_handle_t *output_buffer = tcomp_buffer_create_null();
- tsk_size_t pointer = 0;
- uint8_t *header;
- uint32_t codeLen;
-
- tcomp_buffer_referenceBuff(output_buffer, (uint8_t*)output_ptr, *output_size);
- header = tcomp_buffer_getBufferAtPos(output_buffer, pointer++);
-
- /* SigComp Header */
- if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)){
- /* Return the requested feedback */
- *header = 0xfc; /* T=1 */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
- pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
- }
- else{
- *header = 0xf8;
- }
-
- codeLen = UNCOMPRESSED_BYTECODE_LENGTH;
- /* first byte for codelen */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) = ((codeLen>>4)& 0x00ff);
-
- /* last 4 bits for codelen */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer) = ((codeLen & 0x000f)<<4);
-
- /* first and last 4 bits for destination */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) |= UNCOMPRESSED_BYTECODE_DESTINATION_CODE;
-
- /*
- * Upload UDVM bytecode
- */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), (uint8_t*)DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE, codeLen);
- pointer += codeLen;
-
- /*
- * Copy data uncompressed
- */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), input_ptr, input_size);
- pointer += input_size;
- *output_size = (pointer);
-
- TSK_OBJECT_SAFE_FREE(output_buffer);
-
- return tsk_true;
+ tcomp_buffer_handle_t *output_buffer = tcomp_buffer_create_null();
+ tsk_size_t pointer = 0;
+ uint8_t *header;
+ uint32_t codeLen;
+
+ tcomp_buffer_referenceBuff(output_buffer, (uint8_t*)output_ptr, *output_size);
+ header = tcomp_buffer_getBufferAtPos(output_buffer, pointer++);
+
+ /* SigComp Header */
+ if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)) {
+ /* Return the requested feedback */
+ *header = 0xfc; /* T=1 */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
+ pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
+ }
+ else {
+ *header = 0xf8;
+ }
+
+ codeLen = UNCOMPRESSED_BYTECODE_LENGTH;
+ /* first byte for codelen */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) = ((codeLen>>4)& 0x00ff);
+
+ /* last 4 bits for codelen */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer) = ((codeLen & 0x000f)<<4);
+
+ /* first and last 4 bits for destination */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) |= UNCOMPRESSED_BYTECODE_DESTINATION_CODE;
+
+ /*
+ * Upload UDVM bytecode
+ */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), (uint8_t*)DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE, codeLen);
+ pointer += codeLen;
+
+ /*
+ * Copy data uncompressed
+ */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), input_ptr, input_size);
+ pointer += input_size;
+ *output_size = (pointer);
+
+ TSK_OBJECT_SAFE_FREE(output_buffer);
+
+ return tsk_true;
}
OpenPOWER on IntegriCloud