OSSP CVS Repository

ossp - Check-in [4204]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4204
Date: 2001-Jul-18 13:30:19 (local)
2001-Jul-18 11:30:19 (UTC)
User:simons
Branch:
Comment: Added XDR encoding engines for int32 and uint32.
Tickets:
Inspections:
Files:
ossp-pkg/xds/Makefile      1.13 -> 1.14     1 inserted, 1 deleted
ossp-pkg/xds/xdr-encode-int.c      added-> 1.1
ossp-pkg/xds/xds.h      1.16 -> 1.17     3 inserted, 0 deleted

ossp-pkg/xds/Makefile 1.13 -> 1.14

--- Makefile     2001/07/09 17:44:47     1.13
+++ Makefile     2001/07/18 11:30:19     1.14
@@ -15,7 +15,7 @@
 
 OBJS            = decode.o destroy.o encode.o getbuffer.o init.o register.o \
                   setbuffer.o unregister.o vdecode.o vencode.o find-engine.o \
-                  set-capacity.o
+                  set-capacity.o xdr-encode-int.o
 
 .c.o:
         $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) -c $<


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

*** /dev/null    Sat Nov 23 01:16:15 2024
--- -    Sat Nov 23 01:16:18 2024
***************
*** 0 ****
--- 1,91 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <assert.h>
+ #include "internal.h"
+ 
+ int xdr_encode_int32(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 >= 4)
+        {
+        u_int32_t tmp;
+        int32_t value = va_arg(*args, u_int32_t);
+        if (value < 0)
+            {
+            value = 0 - value;
+            tmp = 0 - (u_int32_t)value;
+            }
+        else
+            tmp = (u_int32_t)value;
+        ((u_int8_t*)buffer)[0] = (tmp >> 24) & 0x000000ff;
+        ((u_int8_t*)buffer)[1] = (tmp >> 16) & 0x000000ff;
+        ((u_int8_t*)buffer)[2] = (tmp >>  8) & 0x000000ff;
+        ((u_int8_t*)buffer)[3] = (tmp >>  0) & 0x000000ff;
+        }
+ 
+     /* Done. */
+ 
+     return 4;
+     }
+ 
+ int xdr_encode_uint32(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 >= 4)
+        {
+        u_int32_t value = va_arg(*args, u_int32_t);
+        ((u_int8_t*)buffer)[0] = (value >> 24) & 0x000000ff;
+        ((u_int8_t*)buffer)[1] = (value >> 16) & 0x000000ff;
+        ((u_int8_t*)buffer)[2] = (value >>  8) & 0x000000ff;
+        ((u_int8_t*)buffer)[3] = (value >>  0) & 0x000000ff;
+        }
+ 
+     /* Done. */
+ 
+     return 4;
+     }


ossp-pkg/xds/xds.h 1.16 -> 1.17

--- xds.h        2001/07/16 17:50:07     1.16
+++ xds.h        2001/07/18 11:30:19     1.17
@@ -70,4 +70,7 @@
 int xds_vencode(xds_t* xds, const char* fmt, va_list args);
 int xds_vdecode(xds_t* xds, const char* fmt, va_list args);
 
+int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
+int xdr_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
+
 #endif /* !defined(__LIBXDS_H__) */

CVSTrac 2.0.1