Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_ldap_syntax_handler.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Internal LDAP Adaptive Framework Syntax Handlers
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw.h"
16 #include "afw_ldap_internal.h"
17 #include "afw_ldap_metadata.h"
18 
19 
20 static const struct berval
21 impl_ber_true = { 4, "TRUE" };
22 
23 static const struct berval
24 impl_ber_false = { 5, "FALSE" };
25 
26 static void
27 impl_x_nds_syntax_handler(
28  const afw_ldap_metadata_syntax_handler_t * *syntax_handler,
29  const afw_value_t * *data_type_id_value,
30  const afw_object_t *attribute_type_object,
31  const afw_utf8_t *id, afw_boolean_t is_single, afw_xctx_t *xctx);
32 
33 
34 static const afw_value_t *
35 impl_syntax_handler_single_binary_to_value(
36  const afw_ldap_metadata_attribute_type_t *attribute_type,
37  void *data, struct berval * *bv,
38  const afw_pool_t *p, afw_xctx_t *xctx);
39 
40 static struct berval **
41 impl_syntax_handler_single_binary_to_ber(
42  const afw_ldap_metadata_attribute_type_t *attribute_type,
43  void *data, const afw_value_t *value,
44  const afw_pool_t *p, afw_xctx_t *xctx);
45 
47 impl_syntax_handler_single_binary =
48 {
49  NULL,
50  impl_syntax_handler_single_binary_to_value,
51  impl_syntax_handler_single_binary_to_ber
52 };
53 
54 
55 static const afw_value_t *
56 impl_syntax_handler_single_boolean_to_value(
57  const afw_ldap_metadata_attribute_type_t *attribute_type,
58  void *data, struct berval * *bv,
59  const afw_pool_t *p, afw_xctx_t *xctx);
60 
61 static struct berval **
62 impl_syntax_handler_single_boolean_to_ber(
63  const afw_ldap_metadata_attribute_type_t *attribute_type,
64  void *data, const afw_value_t *value,
65  const afw_pool_t *p, afw_xctx_t *xctx);
66 
68 impl_syntax_handler_single_boolean =
69 {
70  NULL,
71  impl_syntax_handler_single_boolean_to_value,
72  impl_syntax_handler_single_boolean_to_ber
73 };
74 
75 
76 static const afw_value_t *
77 impl_syntax_handler_single_generalized_time_to_value(
78  const afw_ldap_metadata_attribute_type_t *attribute_type,
79  void *data,
80  struct berval * *bv,
81  const afw_pool_t *p, afw_xctx_t *xctx);
82 
83 static struct berval **
84 impl_syntax_handler_single_generalized_time_to_ber(
85  const afw_ldap_metadata_attribute_type_t *attribute_type,
86  void *data,
87  const afw_value_t *value,
88  const afw_pool_t *p, afw_xctx_t *xctx);
89 
91 impl_syntax_handler_single_generalized_time =
92 {
93  NULL,
94  impl_syntax_handler_single_generalized_time_to_value,
95  impl_syntax_handler_single_generalized_time_to_ber
96 };
97 
98 
99 static const afw_value_t *
100 impl_syntax_handler_single_integer_to_value(
101  const afw_ldap_metadata_attribute_type_t *attribute_type,
102  void *data, struct berval * *bv,
103  const afw_pool_t *p, afw_xctx_t *xctx);
104 
105 static struct berval **
106 impl_syntax_handler_single_integer_to_ber(
107  const afw_ldap_metadata_attribute_type_t *attribute_type,
108  void *data, const afw_value_t *value,
109  const afw_pool_t *p, afw_xctx_t *xctx);
110 
112 impl_syntax_handler_single_integer =
113 {
114  NULL,
115  impl_syntax_handler_single_integer_to_value,
116  impl_syntax_handler_single_integer_to_ber
117 };
118 
119 
120 static const afw_value_t *
121 impl_syntax_handler_single_string_to_value(
122  const afw_ldap_metadata_attribute_type_t *attribute_type,
123  void *data, struct berval * *bv,
124  const afw_pool_t *p, afw_xctx_t *xctx);
125 
126 static struct berval **
127 impl_syntax_handler_single_string_to_ber(
128  const afw_ldap_metadata_attribute_type_t *attribute_type,
129  void *data, const afw_value_t *value,
130  const afw_pool_t *p, afw_xctx_t *xctx);
131 
133 impl_syntax_handler_single_string =
134 {
135  NULL,
136  impl_syntax_handler_single_string_to_value,
137  impl_syntax_handler_single_string_to_ber
138 };
139 
140 
141 static const afw_value_t *
142 impl_syntax_handler_single_unknown_to_value(
143  const afw_ldap_metadata_attribute_type_t *attribute_type,
144  void *data, struct berval * *bv,
145  const afw_pool_t *p, afw_xctx_t *xctx);
146 
147 static struct berval **
148 impl_syntax_handler_single_unknown_to_ber(
149  const afw_ldap_metadata_attribute_type_t *attribute_type,
150  void *data, const afw_value_t *value,
151  const afw_pool_t *p, afw_xctx_t *xctx);
152 
154 impl_syntax_handler_single_unknown =
155 {
156  NULL,
157  impl_syntax_handler_single_unknown_to_value,
158  impl_syntax_handler_single_unknown_to_ber
159 };
160 
161 
162 static const afw_value_t *
163 impl_syntax_handler_list_binary_to_value(
164  const afw_ldap_metadata_attribute_type_t *attribute_type,
165  void *data, struct berval * *bv,
166  const afw_pool_t *p, afw_xctx_t *xctx);
167 
168 static struct berval **
169 impl_syntax_handler_list_binary_to_ber(
170  const afw_ldap_metadata_attribute_type_t *attribute_type,
171  void *data, const afw_value_t *value,
172  const afw_pool_t *p, afw_xctx_t *xctx);
173 
175 impl_syntax_handler_list_binary =
176 {
177  NULL,
178  impl_syntax_handler_list_binary_to_value,
179  impl_syntax_handler_list_binary_to_ber
180 };
181 
182 
183 static const afw_value_t *
184 impl_syntax_handler_list_boolean_to_value(
185  const afw_ldap_metadata_attribute_type_t *attribute_type,
186  void *data, struct berval * *bv,
187  const afw_pool_t *p, afw_xctx_t *xctx);
188 
189 static struct berval **
190 impl_syntax_handler_list_boolean_to_ber(
191  const afw_ldap_metadata_attribute_type_t *attribute_type,
192  void *data, const afw_value_t *value,
193  const afw_pool_t *p, afw_xctx_t *xctx);
194 
196 impl_syntax_handler_list_boolean =
197 {
198  NULL,
199  impl_syntax_handler_list_boolean_to_value,
200  impl_syntax_handler_list_boolean_to_ber
201 };
202 
203 
204 static const afw_value_t *
205 impl_syntax_handler_list_generalized_time_to_value(
206  const afw_ldap_metadata_attribute_type_t *attribute_type,
207  void *data,
208  struct berval * *bv,
209  const afw_pool_t *p, afw_xctx_t *xctx);
210 
211 static struct berval **
212 impl_syntax_handler_list_generalized_time_to_ber(
213  const afw_ldap_metadata_attribute_type_t *attribute_type,
214  void *data,
215  const afw_value_t *value,
216  const afw_pool_t *p, afw_xctx_t *xctx);
217 
219 impl_syntax_handler_list_generalized_time =
220 {
221  NULL,
222  impl_syntax_handler_list_generalized_time_to_value,
223  impl_syntax_handler_list_generalized_time_to_ber
224 };
225 
226 
227 static const afw_value_t *
228 impl_syntax_handler_list_integer_to_value(
229  const afw_ldap_metadata_attribute_type_t *attribute_type,
230  void *data, struct berval * *bv,
231  const afw_pool_t *p, afw_xctx_t *xctx);
232 
233 static struct berval **
234 impl_syntax_handler_list_integer_to_ber(
235  const afw_ldap_metadata_attribute_type_t *attribute_type,
236  void *data, const afw_value_t *value,
237  const afw_pool_t *p, afw_xctx_t *xctx);
238 
240 impl_syntax_handler_list_integer =
241 {
242  NULL,
243  impl_syntax_handler_list_integer_to_value,
244  impl_syntax_handler_list_integer_to_ber
245 };
246 
247 
248 static const afw_value_t *
249 impl_syntax_handler_list_string_to_value(
250  const afw_ldap_metadata_attribute_type_t *attribute_type,
251  void *data, struct berval * *bv,
252  const afw_pool_t *p, afw_xctx_t *xctx);
253 
254 static struct berval **
255 impl_syntax_handler_list_string_to_ber(
256  const afw_ldap_metadata_attribute_type_t *attribute_type,
257  void *data, const afw_value_t *value,
258  const afw_pool_t *p, afw_xctx_t *xctx);
259 
261 impl_syntax_handler_list_string =
262 {
263  NULL,
264  impl_syntax_handler_list_string_to_value,
265  impl_syntax_handler_list_string_to_ber
266 };
267 
268 
269 
270 static const afw_value_t *
271 impl_syntax_handler_list_unknown_to_value(
272  const afw_ldap_metadata_attribute_type_t *attribute_type,
273  void *data, struct berval * *bv,
274  const afw_pool_t *p, afw_xctx_t *xctx);
275 
276 static struct berval **
277 impl_syntax_handler_list_unknown_to_ber(
278  const afw_ldap_metadata_attribute_type_t *attribute_type,
279  void *data, const afw_value_t *value,
280  const afw_pool_t *p, afw_xctx_t *xctx);
281 
283 impl_syntax_handler_list_unknown =
284 {
285  NULL,
286  impl_syntax_handler_list_unknown_to_value,
287  impl_syntax_handler_list_unknown_to_ber
288 };
289 
290 
291 
292 
293 static const afw_value_t *
294 impl_syntax_handler_single_binary_to_value(
295  const afw_ldap_metadata_attribute_type_t *attribute_type,
296  void *data, struct berval * *bv,
297  const afw_pool_t *p, afw_xctx_t *xctx)
298 {
299  afw_memory_t raw;
300 
301  if (ldap_count_values_len(bv) != 1) {
302  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
303  }
304 
305  raw.ptr = afw_memory_dup((*bv)->bv_val, (*bv)->bv_len, p, xctx);
306  raw.size = (*bv)->bv_len;
307 
308  return afw_value_create_base64Binary(&raw, p, xctx);
309 }
310 
311 
312 static struct berval **
313 impl_syntax_handler_single_binary_to_ber(
314  const afw_ldap_metadata_attribute_type_t *attribute_type,
315  void *data, const afw_value_t *value,
316  const afw_pool_t *p, afw_xctx_t *xctx)
317 {
318  afw_size_t size;
319  const afw_byte_t *ptr;
320  struct berval **result;
321  const afw_data_type_t *value_data_type;
322 
323  value_data_type = afw_value_get_data_type(value, xctx);
324 
326  AFW_THROW_ERROR_Z(general, "Expecting evaluated value", xctx);
327  }
328 
329  if (afw_utf8_equal(&value_data_type->cType, &afw_s_afw_memory_t)) {
330  size = ((afw_value_hexBinary_t *)value)->internal.size;
331  ptr = ((afw_value_hexBinary_t *)value)->internal.ptr;
332  }
333  else if (afw_utf8_equal(&value_data_type->cType, &afw_s_afw_utf8_t)) {
334  size = ((afw_value_string_t *)value)->internal.len;
335  ptr = (afw_byte_t *)((afw_value_string_t *)value)->internal.s;
336  }
337  else {
338  AFW_THROW_ERROR_Z(general,
339  "Expecting a data type with cType afw_memory_t or afw_utf8_t",
340  xctx);
341  }
342 
343  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
344  result[0] = afw_pool_calloc_type(p, struct berval, xctx);
345  result[0]->bv_len = (ber_len_t)size;
346  result[0]->bv_val = (char *)ptr;
347 
348  return result;
349 }
350 
351 
352 static const afw_value_t *
353 impl_syntax_handler_single_boolean_to_value(
354  const afw_ldap_metadata_attribute_type_t *attribute_type,
355  void *data, struct berval * *bv,
356  const afw_pool_t *p, afw_xctx_t *xctx)
357 {
358  const afw_value_t *result;
359 
360  if (ldap_count_values_len(bv) != 1) {
361  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
362  }
363 
364  if ((*bv)->bv_len == 4 && memcmp((*bv)->bv_val, "TRUE", 4) == 0) {
365  result = afw_value_true;
366  }
367  else if ((*bv)->bv_len == 5 && memcmp((*bv)->bv_val, "FALSE", 5) == 0) {
368  result = afw_value_false;
369  }
370  else {
371  AFW_THROW_ERROR_Z(general, "Invalid ldap boolean value", xctx);
372  }
373 
374  return result;
375 }
376 
377 
378 static struct berval **
379 impl_syntax_handler_single_boolean_to_ber(
380  const afw_ldap_metadata_attribute_type_t *attribute_type,
381  void *data, const afw_value_t *value,
382  const afw_pool_t *p, afw_xctx_t *xctx)
383 {
384  struct berval **result;
385  const struct berval *ber;
386  afw_boolean_t b;
387 
388  b = afw_value_as_boolean(value, xctx);
389  ber = (b)
390  ? &impl_ber_true
391  : &impl_ber_false;
392 
393  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
394  result[0] = (struct berval *)ber;
395 
396  return result;
397 }
398 
399 
400 static const afw_value_t *
401 impl_syntax_handler_single_generalized_time_to_value(
402  const afw_ldap_metadata_attribute_type_t *attribute_type,
403  void *data, struct berval * *bv,
404  const afw_pool_t *p, afw_xctx_t *xctx)
405 {
406  afw_utf8_t generalized_time;
407  int count;
408  afw_dateTime_t internal;
409 
410  count = ldap_count_values_len(bv);
411  if (count != 1) {
412  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
413  }
414 
415  generalized_time.s = (*bv)->bv_val;
416  generalized_time.len = (*bv)->bv_len;
417 
418  afw_dataType_generalized_time_set_internal(&generalized_time, &internal,
419  xctx);
420 
421  return afw_value_create_dateTime(&internal, p, xctx);
422 }
423 
424 
425 static struct berval **
426 impl_syntax_handler_single_generalized_time_to_ber(
427  const afw_ldap_metadata_attribute_type_t *attribute_type,
428  void *data, const afw_value_t *value,
429  const afw_pool_t *p, afw_xctx_t *xctx)
430 {
431  struct berval **result;
432  const afw_utf8_t *s;
433 
434  /* If value is dateTime, convert it to generalized and create result. */
435  if (afw_value_is_dateTime(value)) {
437  &((const afw_value_dateTime_t *)value)->internal,
438  p, xctx);
439  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
440  result[0] = afw_pool_malloc_type(p, struct berval, xctx);
441  result[0]->bv_len = (ber_len_t)s->len;
442  result[0]->bv_val = (char *)s->s;
443  }
444 
445  /* If value is not dateTime, treat it like string. Let ldap deal with it. */
446  else {
447  result = impl_syntax_handler_single_string_to_ber(
448  attribute_type, data, value, p, xctx);
449  }
450 
451  return result;
452 }
453 
454 
455 static const afw_value_t *
456 impl_syntax_handler_single_integer_to_value(
457  const afw_ldap_metadata_attribute_type_t *attribute_type,
458  void *data, struct berval * *bv,
459  const afw_pool_t *p, afw_xctx_t *xctx)
460 {
461  afw_integer_t integer;
462  afw_utf8_t s;
463 
464  if (ldap_count_values_len(bv) != 1) {
465  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
466  }
467 
468  s.s = (*bv)->bv_val;
469  s.len = (*bv)->bv_len;
470 
471  integer = afw_number_utf8_to_integer(&s, p, xctx);
472 
473  return afw_value_create_integer(integer, p, xctx);
474 }
475 
476 
477 static struct berval **
478 impl_syntax_handler_single_integer_to_ber(
479  const afw_ldap_metadata_attribute_type_t *attribute_type,
480  void *data, const afw_value_t *value,
481  const afw_pool_t *p, afw_xctx_t *xctx)
482 {
483  /* string_to_ber will handle this correctly. */
484  return impl_syntax_handler_single_string_to_ber(
485  attribute_type, data, value, p, xctx);
486 }
487 
488 
489 static const afw_value_t *
490 impl_syntax_handler_single_string_to_value(
491  const afw_ldap_metadata_attribute_type_t *attribute_type,
492  void *data, struct berval * *bv,
493  const afw_pool_t *p, afw_xctx_t *xctx)
494 {
495  const afw_utf8_t *s;
496  int count;
497 
498  count = ldap_count_values_len(bv);
499  if (count != 1) {
500  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
501  }
502 
503  s = afw_utf8_create_copy((*bv)->bv_val, (*bv)->bv_len, p, xctx);
504  return afw_value_create_string(s, p, xctx);
505 }
506 
507 
508 static struct berval **
509 impl_syntax_handler_single_string_to_ber(
510  const afw_ldap_metadata_attribute_type_t *attribute_type,
511  void *data, const afw_value_t *value,
512  const afw_pool_t *p, afw_xctx_t *xctx)
513 {
514  struct berval **result;
515  const afw_value_string_t *string;
516 
517  if (afw_value_is_string(value)) {
518  string = (const afw_value_string_t *)value;
519  }
520  else {
521  string = (const afw_value_string_t *)
522  afw_value_convert(value,
523  afw_data_type_string, true, p, xctx);
524  }
525 
526  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
527  result[0] = afw_pool_malloc_type(p, struct berval, xctx);
528  result[0]->bv_len = (ber_len_t)string->internal.len;
529  result[0]->bv_val = (char *)string->internal.s;
530 
531  return result;
532 }
533 
534 
535 static const afw_value_t *
536 impl_syntax_handler_single_unknown_to_value(
537  const afw_ldap_metadata_attribute_type_t *attribute_type,
538  void *data, struct berval * *bv,
539  const afw_pool_t *p, afw_xctx_t *xctx)
540 {
541  int count;
542 
543  count = ldap_count_values_len(bv);
544  if (count != 1) {
545  AFW_THROW_ERROR_Z(general, "Expecting single value", xctx);
546  }
547 
548  if (afw_utf8_is_valid((*bv)->bv_val, (*bv)->bv_len, xctx)) {
549  return impl_syntax_handler_single_string_to_value(
550  attribute_type, data, bv, p, xctx);
551  }
552  else {
553  return impl_syntax_handler_single_binary_to_value(
554  attribute_type, data, bv, p, xctx);
555  }
556 }
557 
558 
559 static struct berval **
560 impl_syntax_handler_single_unknown_to_ber(
561  const afw_ldap_metadata_attribute_type_t *attribute_type,
562  void *data, const afw_value_t *value,
563  const afw_pool_t *p, afw_xctx_t *xctx)
564 {
565  /* Single binary will handle afw_utf8_t and afw_memory_t. */
566  return impl_syntax_handler_single_binary_to_ber(
567  attribute_type, data, value, p, xctx);
568 }
569 
570 
571 static const afw_value_t *
572 impl_syntax_handler_list_binary_to_value(
573  const afw_ldap_metadata_attribute_type_t *attribute_type,
574  void *data, struct berval * *bv,
575  const afw_pool_t *p, afw_xctx_t *xctx)
576 {
577  int count;
578  const afw_value_t *result;
579  const afw_list_t *list;
580  afw_memory_t *e;
581 
582  count = ldap_count_values_len(bv);
583  e = afw_pool_malloc(p, count * sizeof(afw_memory_t), xctx);
585  e, false, afw_data_type_base64Binary, count, p, xctx);
586  result = afw_value_create_list(list, p, xctx);
587 
588  for (; count > 0; count--, bv++, e++) {
589  e->ptr = afw_memory_dup((*bv)->bv_val, (*bv)->bv_len, p, xctx);
590  e->size = (*bv)->bv_len;
591  }
592 
593  return result;
594 }
595 
596 
597 static struct berval **
598 impl_syntax_handler_list_binary_to_ber(
599  const afw_ldap_metadata_attribute_type_t *attribute_type,
600  void *data, const afw_value_t *value,
601  const afw_pool_t *p, afw_xctx_t *xctx)
602 {
603  struct berval **result;
604  struct berval **bv;
605  afw_size_t count;
606  const afw_list_t *list;
607  const afw_memory_t *raw;
608  const afw_utf8_t *s;
609  const afw_iterator_t *iterator;
610  const afw_data_type_t *data_type;
611 
612  if (afw_value_is_list(value)) {
613  list = ((afw_value_list_t *)value)->internal;
614  count = afw_list_get_count(list, xctx);
615  result = afw_pool_calloc(p, sizeof(struct berval *) * (count + 1),
616  xctx);
617  data_type = afw_list_get_data_type(value, xctx);
618  if (afw_utf8_equal(&data_type->cType, &afw_s_afw_memory_t)) {
619  for (iterator = NULL, bv = result; ;bv++) {
621  list, &iterator, NULL, (const void **)&raw, xctx);
622  if (!raw) {
623  break;
624  }
625  *bv = afw_pool_malloc_type(p, struct berval, xctx);
626  (*bv)->bv_len = (ber_len_t)raw->size;
627  (*bv)->bv_val = (char *)raw->ptr;
628  }
629  }
630  else if (afw_utf8_equal(&data_type->cType, &afw_s_afw_utf8_t)) {
631  for (iterator = NULL, bv = result; ;bv++) {
633  list, &iterator, NULL, (const void **)&s, xctx);
634  if (!s) {
635  break;
636  }
637  *bv = afw_pool_malloc_type(p, struct berval, xctx);
638  (*bv)->bv_len = (ber_len_t)s->len;
639  (*bv)->bv_val = (char *)s->s;
640  }
641  }
642  else {
643  AFW_THROW_ERROR_Z(general,
644  "Expecting a data type with cType afw_memory_t or afw_utf8_t",
645  xctx);
646  }
647  }
648 
649  else {
650  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
651  data_type = afw_value_get_data_type(value, xctx);
652  if (afw_utf8_equal(&data_type->cType, &afw_s_afw_memory_t)) {
653  raw = (const afw_memory_t *)AFW_VALUE_INTERNAL(value);
654  *result = afw_pool_malloc_type(p, struct berval, xctx);
655  (*result)->bv_len = (ber_len_t)raw->size;
656  (*result)->bv_val = (char *)raw->ptr;
657  }
658  else if (afw_utf8_equal(&data_type->cType, &afw_s_afw_utf8_t)) {
659  s = (const afw_utf8_t *)AFW_VALUE_INTERNAL(value);
660  *result = afw_pool_malloc_type(p, struct berval, xctx);
661  (*result)->bv_len = (ber_len_t)s->len;
662  (*result)->bv_val = (char *)s->s;
663  }
664  else {
665  AFW_THROW_ERROR_Z(general,
666  "Expecting a data type with cType afw_memory_t or afw_utf8_t",
667  xctx);
668  }
669  }
670 
671  return result;
672 }
673 
674 
675 static const afw_value_t *
676 impl_syntax_handler_list_boolean_to_value(
677  const afw_ldap_metadata_attribute_type_t *attribute_type,
678  void *data, struct berval * *bv,
679  const afw_pool_t *p, afw_xctx_t *xctx)
680 {
681  int count;
682  const afw_value_t *result;
683  const afw_list_t *list;
684  afw_boolean_t *e;
685 
686  count = ldap_count_values_len(bv);
687  if (count == 0) {
688  return afw_data_type_boolean->empty_list_value;
689  }
690 
691  e = afw_pool_malloc(p, sizeof(afw_boolean_t) * count, xctx);
693  e, false, afw_data_type_boolean, count, p, xctx);
694  result = afw_value_create_list(list, p, xctx);
695 
696  for (; count > 0; count--, bv++, e++) {
697  if ((*bv)->bv_len == 4 && memcmp((*bv)->bv_val, "TRUE", 4) == 0) {
698  *e = true;
699  } else if ((*bv)->bv_len == 5 && memcmp((*bv)->bv_val, "FALSE", 5) == 0) {
700  *e = false;
701  } else {
702  AFW_THROW_ERROR_Z(general, "Invalid ldap boolean value", xctx);
703  }
704  }
705 
706  return result;
707 }
708 
709 
710 static struct berval **
711 impl_syntax_handler_list_boolean_to_ber(
712  const afw_ldap_metadata_attribute_type_t *attribute_type,
713  void *data, const afw_value_t *value,
714  const afw_pool_t *p, afw_xctx_t *xctx)
715 {
716  struct berval **result;
717  struct berval **bv;
718  afw_boolean_t b;
719  afw_size_t count;
720  const afw_data_type_t *data_type;
722  const afw_list_t *list;
723  const afw_iterator_t *iterator;
724  const void *internal;
725 
726  if (afw_value_is_list(value)) {
727  list = (const afw_list_t *)AFW_VALUE_INTERNAL(value);
728  count = afw_list_get_count(list, xctx);
729  }
730  else {
731  count = 1;
733  &wrapper, AFW_VALUE_INTERNAL(value), false,
734  afw_value_get_data_type(value, xctx),
735  count, p);
736  list = (const afw_list_t *)&wrapper;
737  }
738 
739  result = afw_pool_malloc(p, sizeof(struct berval *) *
740  (count + 1), xctx);
741  result[count] = NULL;
742 
743  for (iterator = NULL, bv = result; ;bv++) {
745  &iterator, &data_type, &internal, xctx);
746  if (!internal) {
747  break;
748  }
749  if (data_type == afw_data_type_boolean) {
750  b = *(afw_boolean_t *)internal;
751  }
752  else {
754  &b, internal, afw_data_type_boolean, p, xctx);
755  }
756  *bv = (struct berval *)
757  ((b)
758  ? &impl_ber_true
759  : &impl_ber_false);
760  }
761 
762  return result;
763 }
764 
765 
766 static const afw_value_t *
767 impl_syntax_handler_list_generalized_time_to_value(
768  const afw_ldap_metadata_attribute_type_t *attribute_type,
769  void *data, struct berval * *bv,
770  const afw_pool_t *p, afw_xctx_t *xctx)
771 {
772  afw_utf8_t generalized_time;
773  afw_size_t count;
774  const afw_value_t *result;
775  const afw_list_t *list;
776  afw_dateTime_t *e;
777 
778  count = ldap_count_values_len(bv);
779  if (count == 0) {
780  return afw_data_type_dateTime->empty_list_value;
781  }
782  e = afw_pool_malloc(p, sizeof(afw_dateTime_t) * count, xctx);
784  (const void *)e, false, afw_data_type_dateTime, count, p, xctx);
785  result = afw_value_create_list(list, p, xctx);
786  for (; count > 0; count--, bv++, e++) {
787  generalized_time.s = (*bv)->bv_val;
788  generalized_time.len = (*bv)->bv_len;
790  &generalized_time, e, xctx);
791  }
792 
793  return result;
794 }
795 
796 
797 static struct berval **
798 impl_syntax_handler_list_generalized_time_to_ber(
799  const afw_ldap_metadata_attribute_type_t *attribute_type,
800  void *data, const afw_value_t *value,
801  const afw_pool_t *p, afw_xctx_t *xctx)
802 {
803  struct berval **result;
804  struct berval **bv;
805  const afw_utf8_t *s;
806  const afw_dateTime_t *val;
807  const afw_list_t *list;
808  const afw_iterator_t *iterator;
809  afw_size_t count;
810 
811  /* Process single dataTime. */
812  if (afw_value_is_dateTime(value)) {
813  result = afw_pool_calloc(p, sizeof(struct berval *) * 2, xctx);
815  AFW_VALUE_INTERNAL(value), p, xctx);
816  *result = afw_pool_malloc_type(p, struct berval, xctx);
817  (*result)->bv_len = (ber_len_t)s->len;
818  (*result)->bv_val = (char *)s->s;
819  }
820 
821  /* Process list of dataTime. */
822  else if (afw_value_is_list_of_dateTime(value)) {
823  list = ((afw_value_list_t *)value)->internal;
824  count = afw_list_get_count(list, xctx);
825  result = afw_pool_calloc(p, sizeof(struct berval *) * (count + 1),
826  xctx);
827  for (iterator = NULL, bv = result; ;bv++) {
829  list, &iterator, NULL, (const void **)&val, xctx);
830  if (!val) {
831  break;
832  }
834  *bv = afw_pool_malloc_type(p, struct berval, xctx);
835  (*bv)->bv_len = (ber_len_t)s->len;
836  (*bv)->bv_val = (char *)s->s;
837  }
838  }
839 
840  /* If value is not dateTime, treat it like string. Let ldap deal with it. */
841  else {
842  result = impl_syntax_handler_list_string_to_ber(
843  attribute_type, data, value, p, xctx);
844  }
845 
846  /* Return result. */
847  return result;
848 }
849 
850 
851 static const afw_value_t *
852 impl_syntax_handler_list_integer_to_value(
853  const afw_ldap_metadata_attribute_type_t *attribute_type,
854  void *data, struct berval * *bv,
855  const afw_pool_t *p, afw_xctx_t *xctx)
856 {
857  const afw_value_t *result;
858  const afw_list_t *list;
859  afw_integer_t *e;
860  afw_utf8_t s;
861  int count;
862 
863  count = ldap_count_values_len(bv);
864  if (count == 0) {
865  return afw_data_type_integer->empty_list_value;
866  }
867  e = afw_pool_malloc(p, sizeof(afw_integer_t) * count, xctx);
869  e, false, afw_data_type_integer, count, p, xctx);
870  result = afw_value_create_list(list, p, xctx);
871 
872  for (; count > 0; count--, bv++, e++) {
873  s.s = (*bv)->bv_val;
874  s.len = (*bv)->bv_len;
875  *e = afw_number_utf8_to_integer(&s, p, xctx);
876  }
877 
878  return result;
879 }
880 
881 
882 static struct berval **
883 impl_syntax_handler_list_integer_to_ber(
884  const afw_ldap_metadata_attribute_type_t *attribute_type,
885  void *data, const afw_value_t *value,
886  const afw_pool_t *p, afw_xctx_t *xctx)
887 {
888  /* String will do this correctly. */
889  return impl_syntax_handler_list_string_to_ber(
890  attribute_type, data, value, p, xctx);
891 }
892 
893 
894 static const afw_value_t *
895 impl_syntax_handler_list_string_to_value(
896  const afw_ldap_metadata_attribute_type_t *attribute_type,
897  void *data, struct berval * *bv,
898  const afw_pool_t *p, afw_xctx_t *xctx)
899 {
900  const afw_utf8_t *s;
901  const afw_value_t *result;
902  const afw_list_t *list;
903  afw_utf8_t *e;
904  int count;
905 
906  count = ldap_count_values_len(bv);
907  if (count == 0) {
908  return afw_data_type_string->empty_list_value;
909  }
910 
911  e = afw_pool_malloc(p, sizeof(afw_utf8_t) * count, xctx);
913  e, false, afw_data_type_string, count, p, xctx);
914  result = afw_value_create_list(list, p, xctx);
915 
916  for (; count > 0; count--, bv++, e++) {
917  s = afw_utf8_create_copy((*bv)->bv_val, (*bv)->bv_len, p, xctx);
918  e->s = s->s;
919  e->len = s->len;
920  }
921 
922  return (const afw_value_t *)result;
923 }
924 
925 
926 static struct berval **
927 impl_syntax_handler_list_string_to_ber(
928  const afw_ldap_metadata_attribute_type_t *attribute_type,
929  void *data, const afw_value_t *value,
930  const afw_pool_t *p, afw_xctx_t *xctx)
931 {
932  struct berval **result;
933  struct berval **bv;
934  const afw_utf8_t *s;
935  const afw_iterator_t *iterator;
936  const afw_list_t *list;
937  const afw_data_type_t *data_type;
938  const void *internal;
939  afw_size_t count;
940 
941  /* Get the list of values. */
942  if (afw_value_is_list(value)) {
943  list = ((const afw_value_list_t *)value)->internal;
944  data_type = afw_list_get_data_type(list, xctx);
945  }
946  else {
947  data_type = afw_value_get_data_type(value, xctx);
949  AFW_VALUE_INTERNAL(value), false, data_type, 1, p, xctx);
950  }
951 
952  /* Get memory for result. */
953  count = afw_list_get_count(list, xctx);
954  result = afw_pool_malloc(p, sizeof(struct berval *) * (count + 1),
955  xctx);
956  result[count] = NULL;
957 
958  /* Iterator setting berval. */
959  for (iterator = NULL, bv = result; ;bv++) {
961  list, &iterator, NULL, &internal, xctx);
962  if (!internal) {
963  break;
964  }
965  if ((data_type = afw_data_type_string)) {
966  s = (const afw_utf8_t *)internal;
967  }
968  else {
969  s = afw_data_type_internal_to_utf8(data_type, internal, p, xctx);
970  }
971  (*bv) = afw_pool_malloc_type(p, struct berval, xctx);
972  (*bv)->bv_len = (ber_len_t)s->len;
973  (*bv)->bv_val = (char *)s->s;
974  }
975 
976  /* Return result. */
977  return result;
978 }
979 
980 
981 static const afw_value_t *
982 impl_syntax_handler_list_unknown_to_value(
983  const afw_ldap_metadata_attribute_type_t *attribute_type,
984  void *data, struct berval * *bv,
985  const afw_pool_t *p, afw_xctx_t *xctx)
986 {
987  int count;
988  struct berval * *save_bv;
989  afw_boolean_t valid_utf8;
990 
991  count = ldap_count_values_len(bv);
992  save_bv = bv;
993  valid_utf8 = true;
994  bv = save_bv;
995 
996  for (; count > 0; count--, bv++) {
997  if (!afw_utf8_is_valid((*bv)->bv_val, (*bv)->bv_len, xctx)) {
998  valid_utf8 = false;
999  break;
1000  }
1001  }
1002 
1003  return (valid_utf8)
1004  ? impl_syntax_handler_list_string_to_value(
1005  attribute_type, data, save_bv, p, xctx)
1006  : impl_syntax_handler_list_binary_to_value(
1007  attribute_type, data, save_bv, p, xctx);
1008 }
1009 
1010 
1011 const afw_value_t *
1012 afw_ldap_internal_syntax_handler_unknown_to_value(
1013  struct berval * *bv,
1014  const afw_pool_t *p, afw_xctx_t *xctx)
1015 {
1016  int count;
1017  struct berval * *save_bv;
1018  afw_boolean_t valid_utf8;
1019  const afw_value_t *result;
1020  afw_boolean_t single;
1021 
1022  count = ldap_count_values_len(bv);
1023  single = count == 1;
1024  save_bv = bv;
1025  valid_utf8 = true;
1026  bv = save_bv;
1027 
1028  for (; count > 0; count--, bv++) {
1029  if (!afw_utf8_is_valid((*bv)->bv_val, (*bv)->bv_len, xctx)) {
1030  valid_utf8 = false;
1031  break;
1032  }
1033  }
1034 
1035  if (single) {
1036  result = (valid_utf8)
1037  ? impl_syntax_handler_single_string_to_value(
1038  NULL, NULL, save_bv, p, xctx)
1039  : impl_syntax_handler_single_binary_to_value(
1040  NULL, NULL, save_bv, p, xctx);
1041  }
1042  else {
1043  result = (valid_utf8)
1044  ? impl_syntax_handler_list_string_to_value(
1045  NULL, NULL, save_bv, p, xctx)
1046  : impl_syntax_handler_list_binary_to_value(
1047  NULL, NULL, save_bv, p, xctx);
1048  }
1049  return result;
1050 }
1051 
1052 
1053 static struct berval **
1054 impl_syntax_handler_list_unknown_to_ber(
1055  const afw_ldap_metadata_attribute_type_t *attribute_type,
1056  void *data, const afw_value_t *value,
1057  const afw_pool_t *p, afw_xctx_t *xctx)
1058 {
1059  /* Bag binary will handle afw_utf8_t and afw_memory_t. */
1060  return impl_syntax_handler_list_binary_to_ber(
1061  attribute_type, data, value, p, xctx);
1062 }
1063 
1064 
1065 static void
1066 impl_x_nds_syntax_handler(
1067  const afw_ldap_metadata_syntax_handler_t * *handler,
1068  const afw_value_t * *data_type_id_value,
1069  const afw_object_t *attribute_type_object,
1070  const afw_utf8_t *syntax_id, afw_boolean_t is_single,
1071  afw_xctx_t *xctx)
1072 {
1073  afw_integer_t id;
1074 
1075  /* Reference NDK: Novell eDirectory Core Services > Values > Syntax IDs */
1076  id = afw_number_utf8_to_integer(syntax_id, xctx->p, xctx);
1077 
1078  *data_type_id_value = NULL;
1079 
1080  switch (id) {
1081 
1082  /* Used: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 24 25 29 */
1083 
1084  case 0: /* Binary string. */
1085  *handler = (is_single)
1086  ? &impl_syntax_handler_single_binary
1087  : &impl_syntax_handler_list_binary;
1088  *data_type_id_value = afw_data_type_base64Binary_id_value;
1089  break;
1090 
1091  case 1: /* names of objects in the eDirectory tree */
1092  *handler = (is_single)
1093  ? &impl_syntax_handler_single_string
1094  : &impl_syntax_handler_list_string;
1095  *data_type_id_value = afw_data_type_string_id_value;
1096  break;
1097 
1098  case 2: /* Case sensitive utf-8 */
1099  *handler = (is_single)
1100  ? &impl_syntax_handler_single_string
1101  : &impl_syntax_handler_list_string;
1102  *data_type_id_value = afw_data_type_string_id_value;
1103  break;
1104 
1105  case 3: /* Case insensitive utf-8 */
1106  *handler = (is_single)
1107  ? &impl_syntax_handler_single_string
1108  : &impl_syntax_handler_list_string;
1109  *data_type_id_value = afw_data_type_string_id_value;
1110  break;
1111 
1112  case 4: /* Printable strings as defined in CCITT X.208. */
1113  *handler = (is_single)
1114  ? &impl_syntax_handler_single_string
1115  : &impl_syntax_handler_list_string;
1116  *data_type_id_value = afw_data_type_string_id_value;
1117  break;
1118 
1119  case 5: /* Printable numeric strings as defined in CCITT X.208 */
1120  *handler = (is_single)
1121  ? &impl_syntax_handler_single_string
1122  : &impl_syntax_handler_list_string;
1123  *data_type_id_value = afw_data_type_string_id_value;
1124  break;
1125 
1126  case 6: /* List of case insensitive utf-8 strings. */
1127  *handler = &impl_syntax_handler_list_string;
1128  *data_type_id_value = afw_data_type_string_id_value;
1129  break;
1130 
1131  case 7: /* Boolean. */
1132  *handler = (is_single)
1133  ? &impl_syntax_handler_single_boolean
1134  : &impl_syntax_handler_list_boolean;
1135  *data_type_id_value = afw_data_type_boolean_id_value;
1136  break;
1137 
1138  case 8: /* Signed integer. */
1139  *handler = (is_single)
1140  ? &impl_syntax_handler_single_integer
1141  : &impl_syntax_handler_list_integer;
1142  *data_type_id_value = afw_data_type_integer_id_value;
1143  break;
1144 
1145  case 9: /* Binary string. */
1146  *handler = (is_single)
1147  ? &impl_syntax_handler_single_binary
1148  : &impl_syntax_handler_list_binary;
1149  *data_type_id_value = afw_data_type_base64Binary_id_value;
1150  break;
1151 
1152  case 10: /* Telephone number. */
1153  *handler = (is_single)
1154  ? &impl_syntax_handler_single_string
1155  : &impl_syntax_handler_list_string;
1156  *data_type_id_value = afw_data_type_string_id_value;
1157  break;
1158 
1159  case 11: /* Fax Number. */
1160  *handler = (is_single)
1161  ? &impl_syntax_handler_single_string
1162  : &impl_syntax_handler_list_string;
1163  *data_type_id_value = afw_data_type_string_id_value;
1164  break;
1165 
1166  case 12: /* Network-layer addresses in binary format */
1167  *handler = (is_single)
1168  ? &impl_syntax_handler_single_binary
1169  : &impl_syntax_handler_list_binary;
1170  *data_type_id_value = afw_data_type_base64Binary_id_value;
1171  break;
1172 
1173  case 13: /* Ordered list of octet strings. */
1174  *handler = (is_single)
1175  ? &impl_syntax_handler_single_binary
1176  : &impl_syntax_handler_list_binary;
1177  *data_type_id_value = afw_data_type_base64Binary_id_value;
1178  break;
1179 
1180  case 14: /* Email address binary. */
1181  *handler = (is_single)
1182  ? &impl_syntax_handler_single_binary
1183  : &impl_syntax_handler_list_binary;
1184  *data_type_id_value = afw_data_type_base64Binary_id_value;
1185  break;
1186 
1187  case 15: /* File system path. (might be utf8 so use unknown) */
1188  *handler = (is_single)
1189  ? &impl_syntax_handler_single_unknown
1190  : &impl_syntax_handler_list_unknown;
1191  break;
1192 
1193  case 16: /* Used by Replica attributes. */
1194  *handler = (is_single)
1195  ? &impl_syntax_handler_single_binary
1196  : &impl_syntax_handler_list_binary;
1197  *data_type_id_value = afw_data_type_base64Binary_id_value;
1198  break;
1199 
1200  case 17: /* ACL Attribute. */
1201  *handler = (is_single)
1202  ? &impl_syntax_handler_single_binary
1203  : &impl_syntax_handler_list_binary;
1204  *data_type_id_value = afw_data_type_base64Binary_id_value;
1205  break;
1206 
1207  case 18: /* Unicode strings of postal addresses. */
1208  *handler = &impl_syntax_handler_list_string;
1209  *data_type_id_value = afw_data_type_string_id_value;
1210  break;
1211 
1212  case 19: /* Mark time when a particular event occurs. */
1213  *handler = (is_single)
1214  ? &impl_syntax_handler_single_binary
1215  : &impl_syntax_handler_list_binary;
1216  *data_type_id_value = afw_data_type_base64Binary_id_value;
1217  break;
1218 
1219  case 20: /* eDirectory object class name. */
1220  *handler = (is_single)
1221  ? &impl_syntax_handler_single_string
1222  : &impl_syntax_handler_list_string;
1223  *data_type_id_value = afw_data_type_string_id_value;
1224  break;
1225 
1226  case 21: /* Binary data. */
1227  *handler = (is_single)
1228  ? &impl_syntax_handler_single_binary
1229  : &impl_syntax_handler_list_binary;
1230  *data_type_id_value = afw_data_type_base64Binary_id_value;
1231  break;
1232 
1233  case 22: /* Counter. */
1234  *handler = (is_single)
1235  ? &impl_syntax_handler_single_integer
1236  : &impl_syntax_handler_list_integer;
1237  *data_type_id_value = afw_data_type_integer_id_value;
1238  break;
1239 
1240  case 23: /* Back link. */
1241  *handler = (is_single)
1242  ? &impl_syntax_handler_single_binary
1243  : &impl_syntax_handler_list_binary;
1244  *data_type_id_value = afw_data_type_base64Binary_id_value;
1245  break;
1246 
1247  case 24: /* Unsigned integer that is time in seconds. */
1248  *handler = (is_single)
1249  ? &impl_syntax_handler_single_generalized_time
1250  : &impl_syntax_handler_list_generalized_time;
1251  *data_type_id_value = afw_data_type_dateTime_id_value;
1252  break;
1253 
1254  case 25: /* Level and an interval associated with an object name. */
1255  *handler = (is_single)
1256  ? &impl_syntax_handler_single_binary
1257  : &impl_syntax_handler_list_binary;
1258  *data_type_id_value = afw_data_type_base64Binary_id_value;
1259  break;
1260 
1261  case 26: /* Hold which is a signed integer. */
1262  *handler = (is_single)
1263  ? &impl_syntax_handler_single_integer
1264  : &impl_syntax_handler_list_integer;
1265  *data_type_id_value = afw_data_type_integer_id_value;
1266  break;
1267 
1268  case 27: /* Interval of time. */
1269  *handler = (is_single)
1270  ? &impl_syntax_handler_single_binary
1271  : &impl_syntax_handler_list_binary;
1272  break;
1273 
1274  case 29: /* Large integer. */
1275  *handler = (is_single)
1276  ? &impl_syntax_handler_single_integer
1277  : &impl_syntax_handler_list_integer;
1278  *data_type_id_value = afw_data_type_integer_id_value;
1279  break;
1280 
1281  default:
1282  *handler = (is_single)
1283  ? &impl_syntax_handler_single_unknown
1284  : &impl_syntax_handler_list_unknown;
1285  }
1286 
1287  return;
1288 }
1289 
1290 
1291 void
1293  afw_ldap_metadata_t *metadata,
1294  afw_ldap_metadata_attribute_type_t *attribute_type,
1295  afw_xctx_t *xctx)
1296 {
1297  const afw_object_t *ldap_syntax_object;
1298  const afw_utf8_t *x_nds_syntax;
1299 
1300  /* Determine syntax_handler based on syntax. */
1301  ldap_syntax_object = apr_hash_get(metadata->ldap_syntax_objects,
1302  attribute_type->syntax_oid->s,
1303  attribute_type->syntax_oid->len);
1304  if (ldap_syntax_object) {
1305 
1306  /* If there is an X-NDS_SYNTAX, assign syntax_handler based on it. */
1308  ldap_syntax_object,
1309  &afw_ldap_s_a_X_NDS_SYNTAX, xctx);
1310  if (x_nds_syntax) {
1311  impl_x_nds_syntax_handler(
1312  &attribute_type->syntax_handler,
1313  &attribute_type->data_type_id_value,
1314  attribute_type->attribute_type_object,
1315  x_nds_syntax,
1316  attribute_type->is_single, xctx);
1317  }
1318 
1320  else {
1321  attribute_type->syntax_handler = (attribute_type->is_single)
1322  ? &impl_syntax_handler_single_unknown
1323  : &impl_syntax_handler_list_unknown;
1324  }
1325  }
1326 
1327  /*
1328  * There are a number of syntaxes like 2.16.840.1.113719.1.1.5.1.0 that
1329  * are not defined and considered unknown.
1330  */
1331  else {
1332  attribute_type->syntax_handler = (attribute_type->is_single)
1333  ? &impl_syntax_handler_single_unknown
1334  : &impl_syntax_handler_list_unknown;
1335  attribute_type->never_allow_read = true;
1336  attribute_type->never_allow_write = true;
1337  }
1338 }
Adaptive Framework Core API.
Adaptive Framework LDAP Internal Header
Adaptive Framework LDAP Metadata Header.
void afw_ldap_internal_syntax_handler_assign(afw_ldap_metadata_t *metadata, afw_ldap_metadata_attribute_type_t *attribute_type, afw_xctx_t *xctx)
afw_data_type_base64Binary_id_value
Adaptive string value for "base64Binary".
afw_value_create_base64Binary(const afw_memory_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type base64Binary value.
afw_data_type_base64Binary
Data type struct for base64Binary.
afw_data_type_boolean
Data type struct for boolean.
afw_value_as_boolean(const afw_value_t *value, afw_xctx_t *xctx)
Typesafe cast of data type boolean.
afw_data_type_boolean_id_value
Adaptive string value for "boolean".
afw_data_type_dateTime_id_value
Adaptive string value for "dateTime".
#define afw_value_is_list_of_dateTime(A_VALUE)
Macro to determine if value is evaluated list of dateTime.
afw_data_type_dateTime
Data type struct for dateTime.
#define afw_value_is_dateTime(A_VALUE)
Macro to determine if value is evaluated dateTime.
afw_value_create_dateTime(const afw_dateTime_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type dateTime value.
afw_value_create_integer(afw_integer_t internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type integer value.
afw_data_type_integer_id_value
Adaptive string value for "integer".
afw_data_type_integer
Data type struct for integer.
afw_value_create_list(const afw_list_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type list value.
#define afw_value_is_list(A_VALUE)
Macro to determine if value is evaluated list.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define afw_object_old_get_property_as_string(object, property_name, xctx)
Get property function for data type string value.
afw_data_type_string
Data type struct for string.
#define afw_value_is_string(A_VALUE)
Macro to determine if value is evaluated string.
afw_data_type_string_id_value
Adaptive string value for "string".
struct afw_iterator_s afw_iterator_t
_Bool afw_boolean_t
Definition: afw_common.h:373
unsigned char afw_byte_t
A byte of memory (unsigned).
Definition: afw_common.h:208
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
#define afw_data_type_convert_internal(instance, to_internal, from_internal, to_data_type, p, xctx)
Call method convert_internal of interface afw_data_type.
#define afw_data_type_internal_to_utf8(instance, from_internal, p, xctx)
Call method internal_to_utf8 of interface afw_data_type.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define afw_list_get_next_internal(instance, iterator, data_type, internal, xctx)
Call method get_next_internal of interface afw_list.
#define afw_list_get_data_type(instance, xctx)
Call method get_data_type of interface afw_list.
#define afw_list_get_count(instance, xctx)
Call method get_count of interface afw_list.
afw_list_create_wrapper_for_array(const void *array, afw_boolean_t indirect, const afw_data_type_t *data_type, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx)
Create a immutable list wrapper for an array.
#define AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P(instance, _internal, _indirect, _data_type, _count, _p)
Helper macro to fill out afw_list_wrapper_for_array_self_t.
Definition: afw_list.h:297
void * afw_memory_dup(const void *from, apr_size_t size, const afw_pool_t *p, afw_xctx_t *xctx)
Duplicate a block of memory into specified pool.
Definition: afw_memory.h:88
afw_integer_t afw_number_utf8_to_integer(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a utf8 string to integer in specified pool.
Definition: afw_number.h:221
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
#define afw_pool_malloc_type(instance, type, xctx)
Macro to allocate uncleared memory to hold type in pool.
Definition: afw_pool.h:182
afw_dataType_generalized_time_set_internal(const afw_utf8_t *generalized_time, afw_dateTime_t *internal, afw_xctx_t *xctx)
Convert generalized time (see X.208) to internal and set.
Definition: afw_time.c:2063
afw_dateType_internal_to_generalized_time(const afw_dateTime_t *dateTime, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dateTime to generalized time (see X.208) in specified pool.
Definition: afw_time.c:2039
#define afw_utf8_create_copy(s, len, p, xctx)
Make a utf-8 sting from chars in pool specified.
Definition: afw_utf8.h:369
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
#define afw_utf8_is_valid(s, len, xctx)
Determine if series of bytes is valid utf-8.
Definition: afw_utf8.h:154
#define afw_value_get_data_type(instance, xctx)
Call method get_data_type of interface afw_value.
afw_value_false
Adaptive value false.
Definition: afw_value.h:354
#define afw_value_is_defined_and_evaluated(A_VALUE)
Macro to determine if value is defined and evaluated.
Definition: afw_value.h:481
afw_value_convert(const afw_value_t *value, const afw_data_type_t *to_data_type, afw_boolean_t required, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a value to a value/data type.
Definition: afw_value.c:584
#define AFW_VALUE_INTERNAL(_VALUE_)
Macro to get const void * of the internal of a value.
Definition: afw_value.h:856
afw_value_true
Adaptive value true.
Definition: afw_value.h:348
Interface afw_data_type public struct.
date, time, and time zone.
Definition: afw_common.h:1760
Interface afw_list public struct.
Self for immutable list wrapper for a array.
Definition: afw_list.h:237
Struct for memory pointer and size.
Definition: afw_common.h:505
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type dateTime values.
struct for data type hexBinary values.
struct for data type list values.
Interface afw_value public struct.
struct for data type string values.
Interface afw_xctx public struct.