summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-06-17 21:40:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:23 -0500
commit82dfe0b29b4d090a20e0bc07a22ee47a5f38330a (patch)
tree943ea812dc54e9c40249117fceab250d6f5ecf67 /source4/librpc
parentcd39847e815bea73b6bcae63541dd36b1715aa6c (diff)
downloadsamba-82dfe0b29b4d090a20e0bc07a22ee47a5f38330a.tar.gz
samba-82dfe0b29b4d090a20e0bc07a22ee47a5f38330a.tar.bz2
samba-82dfe0b29b4d090a20e0bc07a22ee47a5f38330a.zip
r7702: Implement [charset()] attribute.
(This used to be commit 7012e10bb6252a7e602e80f05c914a783610088c)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/idl/echo.idl4
-rw-r--r--source4/librpc/ndr/ndr_string.c38
2 files changed, 39 insertions, 3 deletions
diff --git a/source4/librpc/idl/echo.idl b/source4/librpc/idl/echo.idl
index d841a0974a..a6f52d9d15 100644
--- a/source4/librpc/idl/echo.idl
+++ b/source4/librpc/idl/echo.idl
@@ -34,8 +34,8 @@ interface rpcecho
/* test strings */
void echo_TestCall (
- [in] unistr *s1,
- [out] unistr *s2
+ [in,string,charset(CH_UTF16)] uint16 *s1,
+ [out,string,charset(CH_UTF16)] uint16 *s2
);
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index af9783ed95..95e9df39f0 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -587,8 +587,10 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, const void *_var, uin
const char *var = _var;
uint32_t i;
+ var += element_size*(count-1);
+
for (i = 0; i < element_size; i++) {
- if (var+element_size*(count-1)+i != 0) {
+ if (var[i] != 0) {
return NT_STATUS_UNSUCCESSFUL;
}
}
@@ -596,3 +598,37 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, const void *_var, uin
return NT_STATUS_OK;
}
+
+NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, char **var, uint32_t length, uint8_t byte_mul, int chset)
+{
+ int ret;
+ NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ length*byte_mul,
+ (void **)var);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
+ NDR_CHECK(ndr_pull_advance(ndr, length*byte_mul));
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, int chset)
+{
+ int ret;
+ NDR_PUSH_NEED_BYTES(ndr, byte_mul*length);
+ ret = convert_string(CH_UNIX, chset,
+ var, length,
+ ndr->data+ndr->offset,
+ byte_mul*length);
+ if (ret == -1) {
+ return ndr_push_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
+ ndr->offset += byte_mul*length;
+
+ return NT_STATUS_OK;
+}