OSSP CVS Repository

ossp - Difference in ossp-pkg/xds/xdr-encode-int.c versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/xds/xdr-encode-int.c 1.1 -> 1.2

--- xdr-encode-int.c     2001/07/18 11:30:19     1.1
+++ xdr-encode-int.c     2001/07/18 16:59:27     1.2
@@ -89,3 +89,73 @@
 
     return 4;
     }
+
+int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+    {
+    /* 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;
+
+    /* Get value and format it into the buffer. */
+
+    if (buffer_size >= 8)
+        {
+        u_int64_t tmp;
+        int64_t value = va_arg(*args, u_int64_t);
+        if (value < 0)
+            {
+            value = 0 - value;
+            tmp = 0 - (u_int64_t)value;
+            }
+        else
+            tmp = (u_int64_t)value;
+        ((u_int8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff;
+        ((u_int8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff;
+        ((u_int8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff;
+        ((u_int8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff;
+        ((u_int8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff;
+        ((u_int8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff;
+        ((u_int8_t*)buffer)[6] = (tmp >>  8) & 0x000000ff;
+        ((u_int8_t*)buffer)[7] = (tmp >>  0) & 0x000000ff;
+        }
+
+    /* Done. */
+
+    return 8;
+    }
+
+int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+    {
+    /* 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;
+
+    /* Get value and format it into the buffer. */
+
+    if (buffer_size >= 8)
+        {
+        u_int64_t value = va_arg(*args, u_int64_t);
+        ((u_int8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
+        ((u_int8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
+        ((u_int8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
+        ((u_int8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
+        ((u_int8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
+        ((u_int8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
+        ((u_int8_t*)buffer)[6] = (value >>  8) & 0x000000ff;
+        ((u_int8_t*)buffer)[7] = (value >>  0) & 0x000000ff;
+        }
+
+    /* Done. */
+
+    return 8;
+    }

CVSTrac 2.0.1