Check-in Number:
|
4253 | |
Date: |
2001-Aug-01 13:26:56 (local)
2001-Aug-01 11:26:56 (UTC) |
User: | simons |
Branch: | callback-semantic-rewrite |
Comment: |
- Rewrote callbacks for new semantics.
- Added use of the xds_check_parameter() macro. |
Tickets: |
|
Inspections: |
|
Files: |
ossp-pkg/xds/xdr-decode-double.c
|
1.1
->
1.1.2.1
|
 
3 inserted, 1 deleted
|
ossp-pkg/xds/xdr-decode-int32.c
|
1.3
->
1.3.2.1
|
 
15 inserted, 7 deleted
|
ossp-pkg/xds/xdr-decode-int64.c
|
1.3
->
1.3.2.1
|
 
15 inserted, 7 deleted
|
ossp-pkg/xds/xdr-decode-octetstream.c
|
1.3
->
1.3.2.1
|
 
11 inserted, 8 deleted
|
ossp-pkg/xds/xdr-decode-string.c
|
1.4
->
1.4.2.1
|
 
11 inserted, 8 deleted
|
ossp-pkg/xds/xdr-decode-uint32.c
|
1.3
->
1.3.2.1
|
 
15 inserted, 7 deleted
|
ossp-pkg/xds/xdr-decode-uint64.c
|
1.3
->
1.3.2.1
|
 
14 inserted, 6 deleted
|
ossp-pkg/xds/xdr-encode-double.c
|
1.1
->
1.1.2.1
|
 
3 inserted, 1 deleted
|
ossp-pkg/xds/xdr-encode-int32.c
|
1.3.2.1
->
1.3.2.2
|
 
2 inserted, 1 deleted
|
ossp-pkg/xds/xdr-encode-int64.c
|
1.3
->
1.3.2.1
|
 
33 inserted, 26 deleted
|
ossp-pkg/xds/xdr-encode-octetstream.c
|
1.4
->
1.4.2.1
|
 
23 inserted, 17 deleted
|
ossp-pkg/xds/xdr-encode-string.c
|
1.5
->
1.5.2.1
|
 
23 inserted, 17 deleted
|
ossp-pkg/xds/xdr-encode-uint32.c
|
1.3
->
1.3.2.1
|
 
24 inserted, 16 deleted
|
ossp-pkg/xds/xdr-encode-uint64.c
|
1.3
->
1.3.2.1
|
 
28 inserted, 20 deleted
|
|
ossp-pkg/xds/xdr-decode-double.c 1.1 -> 1.1.2.1
--- xdr-decode-double.c 2001/07/23 13:04:06 1.1
+++ xdr-decode-double.c 2001/08/01 11:26:56 1.1.2.1
@@ -27,7 +27,9 @@
#include "internal.h"
-int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_double(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
return -1;
}
|
|
ossp-pkg/xds/xdr-decode-int32.c 1.3 -> 1.3.2.1
--- xdr-decode-int32.c 2001/07/23 15:33:42 1.3
+++ xdr-decode-int32.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,20 +28,28 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_int32(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_int32_t* value;
xds_uint32_t tmp;
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 4 bytes in the buffer to format our parameter. If we
+ don't have them, return an underflow error. */
+
if (buffer_size < 4)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4;
/* Get value and format it into the buffer. */
@@ -67,5 +75,5 @@
/* Done. */
- return 4;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-decode-int64.c 1.3 -> 1.3.2.1
--- xdr-decode-int64.c 2001/07/23 15:33:42 1.3
+++ xdr-decode-int64.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,20 +28,28 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_int64(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_int64_t* value;
xds_uint64_t tmp;
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 8 bytes in the buffer to format our parameter. If we
+ don't have them, return an underflow error. */
+
if (buffer_size < 8)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 8;
/* Get value and format it into the buffer. */
@@ -75,5 +83,5 @@
/* Done. */
- return 8;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-decode-octetstream.c 1.3 -> 1.3.2.1
--- xdr-decode-octetstream.c 2001/07/23 15:33:42 1.3
+++ xdr-decode-octetstream.c 2001/08/01 11:26:56 1.3.2.1
@@ -29,7 +29,9 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_octetstream(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
void** p;
size_t* p_len;
@@ -37,12 +39,11 @@
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
/* Get pointers from the stack. */
@@ -71,6 +72,8 @@
if (buffer_size < 4 + *p_len + padding)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4 + *p_len + padding;
/* Allocate buffer for the data. */
@@ -84,5 +87,5 @@
/* Done. */
- return 4 + *p_len + padding;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-decode-string.c 1.4 -> 1.4.2.1
--- xdr-decode-string.c 2001/07/23 15:33:42 1.4
+++ xdr-decode-string.c 2001/08/01 11:26:56 1.4.2.1
@@ -29,7 +29,9 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_string(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
char** p;
size_t* p_len;
@@ -37,12 +39,11 @@
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
/* Get pointers from the stack. */
@@ -71,6 +72,8 @@
if (buffer_size < 4 + *p_len + padding)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4 + *p_len + padding;
/* Allocate buffer for the data. */
@@ -85,5 +88,5 @@
/* Done. */
- return 4 + *p_len + padding;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-decode-uint32.c 1.3 -> 1.3.2.1
--- xdr-decode-uint32.c 2001/07/23 15:33:42 1.3
+++ xdr-decode-uint32.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,19 +28,27 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_uint32(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_uint32_t* value;
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 4 bytes in the buffer to format our parameter. If we
+ don't have them, return an underflow error. */
+
if (buffer_size < 4)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4;
/* Get value and format it into the buffer. */
@@ -54,5 +62,5 @@
/* Done. */
- return 4;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-decode-uint64.c 1.3 -> 1.3.2.1
--- xdr-decode-uint64.c 2001/07/23 15:33:42 1.3
+++ xdr-decode-uint64.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,19 +28,27 @@
#include <assert.h>
#include "internal.h"
-int xdr_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_uint64(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_uint64_t* value;
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 8 bytes in the buffer to format our parameter. If we
+ don't have them, return an underflow error. */
+
if (buffer_size < 8)
return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 8;
/* Get value and format it into the buffer. */
|
|
ossp-pkg/xds/xdr-encode-double.c 1.1 -> 1.1.2.1
--- xdr-encode-double.c 2001/07/23 13:04:06 1.1
+++ xdr-encode-double.c 2001/08/01 11:26:56 1.1.2.1
@@ -27,7 +27,9 @@
#include "internal.h"
-int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_double(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
return -1;
}
|
|
ossp-pkg/xds/xdr-encode-int32.c 1.3.2.1 -> 1.3.2.2
--- xdr-encode-int32.c 2001/08/01 09:54:55 1.3.2.1
+++ xdr-encode-int32.c 2001/08/01 11:26:56 1.3.2.2
@@ -46,9 +46,10 @@
/* We need 4 bytes in the buffer to format our parameter. If we
don't have them, return an overflow error. */
- *used_buffer_size = 4;
if (buffer_size < 4)
return XDS_ERR_OVERFLOW;
+ else
+ *used_buffer_size = 4;
/* Get value and format it into the buffer. */
|
|
ossp-pkg/xds/xdr-encode-int64.c 1.3 -> 1.3.2.1
--- xdr-encode-int64.c 2001/07/23 15:33:42 1.3
+++ xdr-encode-int64.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,41 +28,48 @@
#include <assert.h>
#include "internal.h"
-int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_int64(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
+ xds_uint64_t tmp;
+ xds_int64_t value;
+
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(args != NULL);
+
+ /* We need 8 bytes in the buffer to format our parameter. If we
+ don't have them, return an overflow error. */
+
+ if (buffer_size < 8)
+ return XDS_ERR_OVERFLOW;
+ else
+ *used_buffer_size = 8;
/* Get value and format it into the buffer. */
- if (buffer_size >= 8)
+ value = va_arg(*args, xds_uint64_t);
+ if (value < 0)
{
- xds_uint64_t tmp;
- xds_int64_t value = va_arg(*args, xds_uint64_t);
- if (value < 0)
- {
- value = 0 - value;
- tmp = 0 - (xds_uint64_t)value;
- }
- else
- tmp = (xds_uint64_t)value;
- ((xds_uint8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff;
- ((xds_uint8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff;
- ((xds_uint8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff;
- ((xds_uint8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff;
- ((xds_uint8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff;
- ((xds_uint8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff;
- ((xds_uint8_t*)buffer)[6] = (tmp >> 8) & 0x000000ff;
- ((xds_uint8_t*)buffer)[7] = (tmp >> 0) & 0x000000ff;
+ value = 0 - value;
+ tmp = 0 - (xds_uint64_t)value;
}
+ else
+ tmp = (xds_uint64_t)value;
+ ((xds_uint8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[6] = (tmp >> 8) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[7] = (tmp >> 0) & 0x000000ff;
/* Done. */
- return 8;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-encode-octetstream.c 1.4 -> 1.4.2.1
--- xdr-encode-octetstream.c 2001/07/23 15:33:42 1.4
+++ xdr-encode-octetstream.c 2001/08/01 11:26:56 1.4.2.1
@@ -29,7 +29,9 @@
#include <string.h>
#include "internal.h"
-int xdr_encode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_octetstream(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_uint8_t* p;
size_t p_len;
@@ -37,12 +39,11 @@
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
/* Get value from stack and calculate the correct amount of
padding. */
@@ -53,19 +54,24 @@
padding = (4 - (p_len & 0x03)) & 0x03;
assert((p_len + padding) % 4 == 0);
+ /* We need (4 + p_len + padding) bytes in the buffer to format our
+ parameter. If we don't have them, return an underflow error. */
+
+ if (buffer_size < 4 + p_len + padding)
+ return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4 + p_len + padding;
+
/* Format the values into the buffer. */
- if (buffer_size >= 4 + p_len + padding)
- {
- ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
- ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
- ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff;
- ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff;
- memmove((xds_uint8_t*)buffer+4, p, p_len);
- memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
- }
+ ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff;
+ memmove((xds_uint8_t*)buffer+4, p, p_len);
+ memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
/* Done. */
- return 4 + p_len + padding;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-encode-string.c 1.5 -> 1.5.2.1
--- xdr-encode-string.c 2001/07/23 15:33:42 1.5
+++ xdr-encode-string.c 2001/08/01 11:26:56 1.5.2.1
@@ -29,7 +29,9 @@
#include <string.h>
#include "internal.h"
-int xdr_encode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_string(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
char* p;
size_t p_len;
@@ -37,12 +39,11 @@
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
/* Get value from stack and calculate the correct amount of
padding. */
@@ -53,19 +54,24 @@
padding = (4 - (p_len & 0x03)) & 0x03;
assert((p_len + padding) % 4 == 0);
+ /* We need (4 + p_len + padding) bytes in the buffer to format our
+ parameter. If we don't have them, return an underflow error. */
+
+ if (buffer_size < 4 + p_len + padding)
+ return XDS_ERR_UNDERFLOW;
+ else
+ *used_buffer_size = 4 + p_len + padding;
+
/* Format the values into the buffer. */
- if (buffer_size >= 4 + p_len + padding)
- {
- ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
- ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
- ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff;
- ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff;
- memmove((xds_uint8_t*)buffer+4, p, p_len);
- memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
- }
+ ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff;
+ memmove((xds_uint8_t*)buffer+4, p, p_len);
+ memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
/* Done. */
- return 4 + p_len + padding;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-encode-uint32.c 1.3 -> 1.3.2.1
--- xdr-encode-uint32.c 2001/07/23 15:33:42 1.3
+++ xdr-encode-uint32.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,29 +28,37 @@
#include <assert.h>
#include "internal.h"
-int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_uint32(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
+ xds_uint32_t value;
+
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 4 bytes in the buffer to format our parameter. If we
+ don't have them, return an overflow error. */
+
+ if (buffer_size < 4)
+ return XDS_ERR_OVERFLOW;
+ else
+ *used_buffer_size = 4;
/* Get value and format it into the buffer. */
- if (buffer_size >= 4)
- {
- xds_uint32_t value = va_arg(*args, xds_uint32_t);
- ((xds_uint8_t*)buffer)[0] = (value >> 24) & 0x000000ff;
- ((xds_uint8_t*)buffer)[1] = (value >> 16) & 0x000000ff;
- ((xds_uint8_t*)buffer)[2] = (value >> 8) & 0x000000ff;
- ((xds_uint8_t*)buffer)[3] = (value >> 0) & 0x000000ff;
- }
+ value = va_arg(*args, xds_uint32_t);
+ ((xds_uint8_t*)buffer)[0] = (value >> 24) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[1] = (value >> 16) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[2] = (value >> 8) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[3] = (value >> 0) & 0x000000ff;
/* Done. */
- return 4;
+ return XDS_OK;
}
|
|
ossp-pkg/xds/xdr-encode-uint64.c 1.3 -> 1.3.2.1
--- xdr-encode-uint64.c 2001/07/23 15:33:42 1.3
+++ xdr-encode-uint64.c 2001/08/01 11:26:56 1.3.2.1
@@ -28,33 +28,41 @@
#include <assert.h>
#include "internal.h"
-int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_uint64(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
+ xds_uint64_t value;
+
/* Consistency checks. */
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
+ xds_check_parameter(xds != NULL);
+ xds_check_parameter(buffer != NULL);
+ xds_check_parameter(buffer_size != 0);
+ xds_check_parameter(used_buffer_size != NULL);
+ xds_check_parameter(args != NULL);
+
+ /* We need 8 bytes in the buffer to format our parameter. If we
+ don't have them, return an overflow error. */
+
+ if (buffer_size < 8)
+ return XDS_ERR_OVERFLOW;
+ else
+ *used_buffer_size = 8;
/* Get value and format it into the buffer. */
- if (buffer_size >= 8)
- {
- xds_uint64_t value = va_arg(*args, xds_uint64_t);
- ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
- ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
- ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
- ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
- ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
- ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
- ((xds_uint8_t*)buffer)[6] = (value >> 8) & 0x000000ff;
- ((xds_uint8_t*)buffer)[7] = (value >> 0) & 0x000000ff;
- }
+ value = va_arg(*args, xds_uint64_t);
+ ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[6] = (value >> 8) & 0x000000ff;
+ ((xds_uint8_t*)buffer)[7] = (value >> 0) & 0x000000ff;
/* Done. */
- return 8;
+ return XDS_OK;
}
|
|