summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-02-02 16:41:44 +0100
committerGünther Deschner <gd@samba.org>2009-02-03 15:42:29 +0100
commit35f1e02ca4c31214e85b7c25d8f695eb035871d7 (patch)
treed1ca9275dadff2f383d3876c097b68cc7eebcecf
parent329b8775f56c8a89f02646e11ba27a33080f48b1 (diff)
downloadsamba-35f1e02ca4c31214e85b7c25d8f695eb035871d7.tar.gz
samba-35f1e02ca4c31214e85b7c25d8f695eb035871d7.tar.bz2
samba-35f1e02ca4c31214e85b7c25d8f695eb035871d7.zip
librpc: add ndr_size_string_array().
Guenther
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--source3/librpc/ndr/ndr_string.c23
-rw-r--r--source4/librpc/ndr/ndr_string.c23
3 files changed, 47 insertions, 0 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 4ab0bf5f0b..7109b73d2a 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -506,6 +506,7 @@ uint32_t ndr_size_string(int ret, const char * const* string, int flags);
enum ndr_err_code ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a);
enum ndr_err_code ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a);
void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a);
+size_t ndr_size_string_array(const char **a, uint32_t count, int flags);
uint32_t ndr_string_length(const void *_var, uint32_t element_size);
enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size);
enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset);
diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c
index 86d7b26586..985d0f4daa 100644
--- a/source3/librpc/ndr/ndr_string.c
+++ b/source3/librpc/ndr/ndr_string.c
@@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_string_array(const char **a, uint32_t count, int flags)
+{
+ uint32_t i;
+ size_t size = 0;
+
+ switch (flags & LIBNDR_STRING_FLAGS) {
+ case LIBNDR_FLAG_STR_NULLTERM:
+ for (i = 0; i < count; i++) {
+ size += strlen_m_term(a[i]);
+ }
+ break;
+ case LIBNDR_FLAG_STR_NOTERM:
+ for (i = 0; i < count; i++) {
+ size += strlen_m(a[i]);
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ return size;
+}
+
/**
* Return number of elements in a string including the last (zeroed) element
*/
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index 265fa68b48..a2fcdeae29 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_string_array(const char **a, uint32_t count, int flags)
+{
+ uint32_t i;
+ size_t size = 0;
+
+ switch (flags & LIBNDR_STRING_FLAGS) {
+ case LIBNDR_FLAG_STR_NULLTERM:
+ for (i = 0; i < count; i++) {
+ size += strlen_m_term(a[i]);
+ }
+ break;
+ case LIBNDR_FLAG_STR_NOTERM:
+ for (i = 0; i < count; i++) {
+ size += strlen_m(a[i]);
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ return size;
+}
+
/**
* Return number of elements in a string including the last (zeroed) element
*/