ndr_syntax_id_to_string: char *(TALLOC_CTX *, const struct ndr_syntax_id *)
ndr_token_max_list_size: size_t (void)
ndr_token_peek: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *)
+ndr_token_peek_cmp_fn: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *, comparison_fn_t)
ndr_token_retrieve: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *)
-ndr_token_retrieve_cmp_fn: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *, comparison_fn_t, bool)
ndr_token_store: enum ndr_err_code (TALLOC_CTX *, struct ndr_token_list *, const void *, uint32_t)
ndr_transfer_syntax_ndr: uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\237\350", node = "\b\000+\020H`"}, if_version = 2
ndr_transfer_syntax_ndr64: uuid = {time_low = 1903232307, time_mid = 48826, time_hi_and_version = 18743, clock_seq = "\203\031", node = "\265\333\357\234\3146"}, if_version = 1
struct ndr_token_list *list,
const void *key,
uint32_t value);
-enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list *list, const void *key, uint32_t *v,
- int(*_cmp_fn)(const void*,const void*), bool erase);
+enum ndr_err_code ndr_token_peek_cmp_fn(struct ndr_token_list *list,
+ const void *key,
+ uint32_t *v,
+ int (*_cmp_fn)(const void *,
+ const void *));
enum ndr_err_code ndr_token_retrieve(struct ndr_token_list *list, const void *key, uint32_t *v);
enum ndr_err_code ndr_token_peek(struct ndr_token_list *list, const void *key, uint32_t *v);
enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p);
/*
retrieve a token from a ndr context, using cmp_fn to match the tokens
*/
-_PUBLIC_ enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list *list,
- const void *key, uint32_t *v,
- comparison_fn_t _cmp_fn,
- bool erase)
+static enum ndr_err_code ndr_token_find(struct ndr_token_list *list,
+ const void *key,
+ uint32_t *v,
+ comparison_fn_t _cmp_fn,
+ unsigned *_i)
{
struct ndr_token *tokens = list->tokens;
unsigned i;
for (i = list->count - 1; i < list->count; i--) {
if (_cmp_fn(tokens[i].key, key) == 0) {
- goto found;
+ *_i = i;
+ *v = tokens[i].value;
+ return NDR_ERR_SUCCESS;
}
}
return NDR_ERR_TOKEN;
-found:
- *v = tokens[i].value;
- if (erase) {
- if (i != list->count - 1) {
- tokens[i] = tokens[list->count - 1];
- }
- list->count--;
- }
- return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_token_peek_cmp_fn(struct ndr_token_list *list,
+ const void *key,
+ uint32_t *v,
+ comparison_fn_t _cmp_fn)
+{
+ unsigned i;
+ return ndr_token_find(list, key, v, _cmp_fn, &i);
}
static int token_cmp_ptr(const void *a, const void *b)
_PUBLIC_ enum ndr_err_code ndr_token_retrieve(struct ndr_token_list *list,
const void *key, uint32_t *v)
{
- return ndr_token_retrieve_cmp_fn(list, key, v, token_cmp_ptr, true);
+ enum ndr_err_code err;
+ uint32_t last;
+ unsigned i;
+
+ err = ndr_token_find(list, key, v, token_cmp_ptr, &i);
+ if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
+ return err;
+ }
+
+ last = list->count - 1;
+ if (i != last) {
+ list->tokens[i] = list->tokens[last];
+ }
+ list->count--;
+
+ return NDR_ERR_SUCCESS;
}
/*
_PUBLIC_ enum ndr_err_code ndr_token_peek(struct ndr_token_list *list,
const void *key, uint32_t *v)
{
- return ndr_token_retrieve_cmp_fn(list, key, v, token_cmp_ptr, false);
+ unsigned i;
+ return ndr_token_find(list, key, v, token_cmp_ptr, &i);
}
/*