Author: metze
Date: 2005-03-15 14:25:59 +0000 (Tue, 15 Mar 2005)
New Revision: 5796

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5796

Log:
add ndr_* function for int8 and int16

metze

Modified:
   branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c    2005-03-15 14:16:41 UTC 
(rev 5795)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c    2005-03-15 14:25:59 UTC 
(rev 5796)
@@ -57,8 +57,19 @@
 }
 
 /*
-  parse a uint8
+  parse a int8_t
 */
+NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
+{
+       NDR_PULL_NEED_BYTES(ndr, 1);
+       *v = (int8_t)CVAL(ndr->data, ndr->offset);
+       ndr->offset += 1;
+       return NT_STATUS_OK;
+}
+
+/*
+  parse a uint8_t
+*/
 NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
 {
        NDR_PULL_NEED_BYTES(ndr, 1);
@@ -67,9 +78,20 @@
        return NT_STATUS_OK;
 }
 
+/*
+  parse a int16_t
+*/
+NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
+{
+       NDR_PULL_ALIGN(ndr, 2);
+       NDR_PULL_NEED_BYTES(ndr, 2);
+       *v = (uint16_t)NDR_SVAL(ndr, ndr->offset);
+       ndr->offset += 2;
+       return NT_STATUS_OK;
+}
 
 /*
-  parse a uint16
+  parse a uint16_t
 */
 NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
 {
@@ -80,27 +102,26 @@
        return NT_STATUS_OK;
 }
 
-
 /*
-  parse a uint32_t
+  parse a int32_t
 */
-NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
+NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
 {
        NDR_PULL_ALIGN(ndr, 4);
        NDR_PULL_NEED_BYTES(ndr, 4);
-       *v = NDR_IVAL(ndr, ndr->offset);
+       *v = NDR_IVALS(ndr, ndr->offset);
        ndr->offset += 4;
        return NT_STATUS_OK;
 }
 
 /*
-  parse a int32_t
+  parse a uint32_t
 */
-NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
+NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
 {
        NDR_PULL_ALIGN(ndr, 4);
        NDR_PULL_NEED_BYTES(ndr, 4);
-       *v = NDR_IVALS(ndr, ndr->offset);
+       *v = NDR_IVAL(ndr, ndr->offset);
        ndr->offset += 4;
        return NT_STATUS_OK;
 }
@@ -243,7 +264,6 @@
        return ndr_pull_bytes(ndr, data, n);
 }
 
-
 /*
   pull an array of uint16
 */
@@ -304,10 +324,19 @@
        return NT_STATUS_OK;
 }
 
+/*
+  push a int8_t
+*/
+NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
+{
+       NDR_PUSH_NEED_BYTES(ndr, 1);
+       SCVAL(ndr->data, ndr->offset, (uint8_t)v);
+       ndr->offset += 1;
+       return NT_STATUS_OK;
+}
 
-
 /*
-  push a uint8
+  push a uint8_t
 */
 NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
 {
@@ -318,8 +347,20 @@
 }
 
 /*
-  push a uint16
+  push a int16_t
 */
+NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
+{
+       NDR_PUSH_ALIGN(ndr, 2);
+       NDR_PUSH_NEED_BYTES(ndr, 2);
+       NDR_SSVAL(ndr, ndr->offset, (uint16_t)v);
+       ndr->offset += 2;
+       return NT_STATUS_OK;
+}
+
+/*
+  push a uint16_t
+*/
 NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
 {
        NDR_PUSH_ALIGN(ndr, 2);
@@ -330,25 +371,25 @@
 }
 
 /*
-  push a uint32_t
+  push a int32_t
 */
-NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
+NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
 {
        NDR_PUSH_ALIGN(ndr, 4);
        NDR_PUSH_NEED_BYTES(ndr, 4);
-       NDR_SIVAL(ndr, ndr->offset, v);
+       NDR_SIVALS(ndr, ndr->offset, v);
        ndr->offset += 4;
        return NT_STATUS_OK;
 }
 
 /*
-  push a int32_t
+  push a uint32_t
 */
-NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
+NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
 {
        NDR_PUSH_ALIGN(ndr, 4);
        NDR_PUSH_NEED_BYTES(ndr, 4);
-       NDR_SIVALS(ndr, ndr->offset, v);
+       NDR_SIVAL(ndr, ndr->offset, v);
        ndr->offset += 4;
        return NT_STATUS_OK;
 }
@@ -380,7 +421,7 @@
 }
 
 /*
-  push a int64
+  push a dlong
 */
 NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v)
 {
@@ -1127,19 +1168,24 @@
        }
 }
 
+void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v)
+{
+       ndr->print(ndr, "%-25s: %d", name, v);
+}
+
 void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v)
 {
        ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v);
 }
 
-void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v)
+void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v)
 {
-       ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v);
+       ndr->print(ndr, "%-25s: %d", name, v);
 }
 
-void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v)
+void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v)
 {
-       ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
+       ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v);
 }
 
 void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v)
@@ -1147,6 +1193,11 @@
        ndr->print(ndr, "%-25s: %d", name, v);
 }
 
+void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v)
+{
+       ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
+}
+
 void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v)
 {
        ndr->print(ndr, "%-25s: 0x%08x%08x (%llu)", name,

Reply via email to