Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / asn_random_fill.h
1 /*\r
2  * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
3  * Redistribution and modifications are permitted subject to BSD license.\r
4  */\r
5 #ifndef ASN_RANDOM_FILL\r
6 #define ASN_RANDOM_FILL\r
7 \r
8 /* Forward declarations */\r
9 struct asn_TYPE_descriptor_s;\r
10 struct asn_encoding_constraints_s;\r
11 \r
12 /*\r
13  * Initialize a structure with random data according to the type specification\r
14  * and optional member constraints.\r
15  * ARGUMENTS:\r
16  *  (max_length)        - See (approx_max_length_limit).\r
17  *  (memb_constraints)  - Member constraints, if exist.\r
18  *                        The type can be constrained differently according\r
19  *                        to PER and OER specifications, so we find a value\r
20  *                        at the intersection of these constraints.\r
21  * In case the return differs from ARFILL_OK, the (struct_ptr) contents\r
22  * and (current_length) value remain in their original state.\r
23  */\r
24 typedef struct asn_random_fill_result_s {\r
25     enum {\r
26         ARFILL_FAILED = -1, /* System error (memory?) */\r
27         ARFILL_OK = 0,      /* Initialization succeeded */\r
28         ARFILL_SKIPPED = 1  /* Not done due to (length?) constraint */\r
29     } code;\r
30     size_t length; /* Approximate number of bytes created. */\r
31 } asn_random_fill_result_t;\r
32 typedef asn_random_fill_result_t(asn_random_fill_f)(\r
33     const struct asn_TYPE_descriptor_s *td, void **struct_ptr,\r
34     const struct asn_encoding_constraints_s *memb_constraints,\r
35     size_t max_length);\r
36 \r
37 /*\r
38  * Returns 0 if the structure was properly initialized, -1 otherwise.\r
39  * The (approx_max_length_limit) specifies the approximate limit of the\r
40  * resulting structure in units closely resembling bytes. The actual result\r
41  * might be several times larger or smaller than the length limit.\r
42  */\r
43 int asn_random_fill(const struct asn_TYPE_descriptor_s *td, void **struct_ptr,\r
44                     size_t approx_max_length_limit);\r
45 \r
46 /*\r
47  * Returns a random number between min and max.\r
48  */\r
49 intmax_t asn_random_between(intmax_t min, intmax_t max);\r
50 \r
51 #endif  /* ASN_RANDOM_FILL */\r