1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

librpc: add ndr_size_string_array().

Guenther
This commit is contained in:
Günther Deschner 2009-02-02 16:41:44 +01:00
parent 329b8775f5
commit 35f1e02ca4
3 changed files with 47 additions and 0 deletions

View File

@ -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_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); 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); 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); 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_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); 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);

View File

@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
ndr->depth--; 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 * Return number of elements in a string including the last (zeroed) element
*/ */

View File

@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
ndr->depth--; 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 * Return number of elements in a string including the last (zeroed) element
*/ */