71 for (field =
set; field; field = field->
next) {
74 if (!strcmp(field->
name,
"joe")) {
80 if (!transformed_field) {
85 transformed_field->
next = transformed;
86 transformed = transformed_field;
358 info->name =
"wizard_registration";
359 info->category =
"/main/sorcery/";
360 info->summary =
"sorcery wizard registration and unregistration unit test";
362 "Test registration and unregistration of a sorcery wizard";
400 info->category =
"/main/sorcery/";
401 info->summary =
"sorcery open/close unit test";
403 "Test opening of sorcery and registry operations";
471 info->name =
"apply_default";
472 info->category =
"/main/sorcery/";
473 info->summary =
"sorcery default wizard unit test";
475 "Test setting default type wizard in sorcery";
512 info->name =
"apply_config";
513 info->category =
"/main/sorcery/";
514 info->summary =
"sorcery object mapping configuration unit test";
516 "Test configured object mapping in sorcery";
554 info->name =
"object_register";
555 info->category =
"/main/sorcery/";
556 info->summary =
"sorcery object type registration unit test";
558 "Test object type registration in sorcery";
593 info->name =
"object_register_without_mapping";
594 info->category =
"/main/sorcery/";
595 info->summary =
"sorcery object type registration (without mapping) unit test";
597 "Test object type registration when no mapping exists in sorcery";
622 info->name =
"object_field_register";
623 info->category =
"/main/sorcery/";
624 info->summary =
"sorcery object field registration unit test";
626 "Test object field registration in sorcery with a provided id";
671 info->name =
"object_fields_register";
672 info->category =
"/main/sorcery/";
673 info->summary =
"sorcery object regex fields registration unit test";
675 "Test object regex fields registration in sorcery with a provided id";
722 info->name =
"object_alloc_with_id";
723 info->category =
"/main/sorcery/";
724 info->summary =
"sorcery object allocation (with id) unit test";
726 "Test object allocation in sorcery with a provided id";
752 }
else if ((obj->bob != 5) || (obj->joe != 10)) {
768 info->name =
"object_alloc_without_id";
769 info->category =
"/main/sorcery/";
770 info->summary =
"sorcery object allocation (without id) unit test";
772 "Test object allocation in sorcery with no provided id";
804 info->name =
"object_copy";
805 info->category =
"/main/sorcery/";
806 info->summary =
"sorcery object copy unit test";
808 "Test object copy in sorcery";
832 }
else if (
copy == obj) {
835 }
else if (
copy->bob != obj->bob) {
838 }
else if (
copy->joe != obj->joe) {
841 }
else if (!
copy->jim) {
844 }
else if (
copy->jim == obj->jim) {
847 }
else if (strcmp(
copy->jim->value, obj->jim->value)) {
850 }
else if (!
copy->jim->next) {
853 }
else if (strcmp(
copy->jim->next->value, obj->jim->next->value)) {
855 copy->jim->value,
copy->jim->next->value, obj->jim->value, obj->jim->next->value);
871 info->name =
"object_copy_native";
872 info->category =
"/main/sorcery/";
873 info->summary =
"sorcery object native copy unit test";
875 "Test object native copy in sorcery";
899 }
else if (
copy == obj) {
902 }
else if (
copy->bob != 10) {
905 }
else if (
copy->joe != 20) {
908 }
else if (!
copy->jim) {
911 }
else if (strcmp(
copy->jim->value,
"444")) {
931 info->name =
"object_diff";
932 info->category =
"/main/sorcery/";
933 info->summary =
"sorcery object diff unit test";
935 "Test object diffing in sorcery";
969 }
else if (!changes) {
974 for (field = changes; field; field = field->
next) {
975 if (!strcmp(field->
name,
"joe")) {
976 if (strcmp(field->
value,
"42")) {
978 "Object diff produced unexpected value '%s' for joe\n", field->
value);
981 }
else if (!strcmp(field->
name,
"jim")) {
983 if (!strcmp(field->
value,
"555")) {
985 "Object diff produced unexpected value '%s' for jim\n", field->
value);
1014 info->name =
"object_diff_native";
1015 info->category =
"/main/sorcery/";
1016 info->summary =
"sorcery object native diff unit test";
1018 "Test native object diffing in sorcery";
1049 }
else if (!changes) {
1054 for (field = changes; field; field = field->
next) {
1055 if (!strcmp(field->
name,
"yes")) {
1056 if (strcmp(field->
value,
"itworks")) {
1079 info->name =
"objectset_create";
1080 info->category =
"/main/sorcery/";
1081 info->summary =
"sorcery object set creation unit test";
1083 "Test object set creation in sorcery";
1104 for (field = objset; field; field = field->
next) {
1105 if (!strcmp(field->
name,
"bob")) {
1106 if (strcmp(field->
value,
"5")) {
1110 }
else if (!strcmp(field->
name,
"joe")) {
1111 if (strcmp(field->
value,
"10")) {
1115 }
else if (!strcmp(field->
name,
"jim")) {
1116 if (strcmp(field->
value,
"444")) {
1120 }
else if (!strcmp(field->
name,
"jack")) {
1121 if (strcmp(field->
value,
"888,999")) {
1144 info->name =
"objectset_json_create";
1145 info->category =
"/main/sorcery/";
1146 info->summary =
"sorcery json object set creation unit test";
1148 "Test object set creation (for JSON format) in sorcery";
1211 info->name =
"objectset_create_regex";
1212 info->category =
"/main/sorcery/";
1213 info->summary =
"sorcery object set creation with regex fields unit test";
1215 "Test object set creation with regex fields in sorcery";
1244 for (field = objset; field; field = field->
next) {
1245 if (!strcmp(field->
name,
"toast-bob")) {
1246 if (strcmp(field->
value,
"10")) {
1268 info->name =
"objectset_apply";
1269 info->category =
"/main/sorcery/";
1270 info->summary =
"sorcery object apply unit test";
1272 "Test object set applying in sorcery";
1294 }
else if (obj->joe != 25) {
1311 info->name =
"objectset_apply_handler";
1312 info->category =
"/main/sorcery/";
1313 info->summary =
"sorcery object apply handler unit test";
1315 "Test object set apply handler call in sorcery";
1364 info->name =
"objectset_apply_invalid";
1365 info->category =
"/main/sorcery/";
1366 info->summary =
"sorcery object invalid apply unit test";
1368 "Test object set applying of an invalid set in sorcery";
1390 }
else if ((obj->bob != 5) || (obj->joe != 10)) {
1406 info->name =
"objectset_transform";
1407 info->category =
"/main/sorcery/";
1408 info->summary =
"sorcery object set transformation unit test";
1410 "Test object set transformation in sorcery";
1449 if (obj->bob != 5) {
1452 }
else if (obj->joe == 10) {
1455 }
else if (obj->joe != 5000) {
1472 info->name =
"objectset_apply_fields";
1473 info->category =
"/main/sorcery/";
1474 info->summary =
"sorcery object apply regex fields unit test";
1476 "Test object set apply with regex fields in sorcery";
1506 }
else if (obj->bob != 256) {
1524 info->name =
"extended_fields";
1525 info->category =
"/main/sorcery/";
1526 info->summary =
"sorcery object extended fields unit test";
1528 "Test extended fields support in sorcery";
1553 }
else if (strcmp(
value,
"toast")) {
1562 }
else if (strcmp(
value,
"supreme")) {
1571 }
else if (strcmp(
value,
"canadian")) {
1589 info->name =
"changeset_create";
1590 info->category =
"/main/sorcery/";
1591 info->summary =
"sorcery changeset creation unit test";
1593 "Test changeset creation in sorcery";
1603 tmp->next = original;
1610 tmp->next = original;
1617 tmp->next = modified;
1624 tmp->next = modified;
1630 }
else if (!changes) {
1636 if (!strcmp(
tmp->name,
"bananas")) {
1637 if (strcmp(
tmp->value,
"green")) {
1659 info->name =
"changeset_create_unchanged";
1660 info->category =
"/main/sorcery/";
1661 info->summary =
"sorcery changeset creation unit test when no changes exist";
1663 "Test changeset creation in sorcery when no changes actually exist";
1673 tmp->next = original;
1680 tmp->next = original;
1686 }
else if (changes) {
1708 }
else if (changes) {
1723 info->name =
"object_create";
1724 info->category =
"/main/sorcery/";
1725 info->summary =
"sorcery object creation unit test";
1727 "Test object creation in sorcery";
1758 info->name =
"object_retrieve_id";
1759 info->category =
"/main/sorcery/";
1760 info->summary =
"sorcery object retrieval using id unit test";
1762 "Test object retrieval using id in sorcery";
1816 info->name =
"object_retrieve_field";
1817 info->category =
"/main/sorcery/";
1818 info->summary =
"sorcery object retrieval using a specific field unit test";
1820 "Test object retrieval using a specific field in sorcery";
1879 info->name =
"object_retrieve_multiple_all";
1880 info->category =
"/main/sorcery/";
1881 info->summary =
"sorcery multiple object retrieval unit test";
1883 "Test multiple object retrieval in sorcery";
1936 info->name =
"object_retrieve_multiple_field";
1937 info->category =
"/main/sorcery/";
1938 info->summary =
"sorcery multiple object retrieval unit test";
1940 "Test multiple object retrieval in sorcery using fields";
2001 info->name =
"object_retrieve_regex";
2002 info->category =
"/main/sorcery/";
2003 info->summary =
"sorcery multiple object retrieval using regex unit test";
2005 "Test multiple object retrieval in sorcery using regular expression for matching";
2069 info->name =
"object_update";
2070 info->category =
"/main/sorcery/";
2071 info->summary =
"sorcery object update unit test";
2073 "Test object updating in sorcery";
2109 }
else if (obj != obj2) {
2124 info->name =
"object_update_uncreated";
2125 info->category =
"/main/sorcery/";
2126 info->summary =
"sorcery object update unit test";
2128 "Test updating of an uncreated object in sorcery";
2159 info->name =
"object_delete";
2160 info->category =
"/main/sorcery/";
2161 info->summary =
"sorcery object deletion unit test";
2163 "Test object deletion in sorcery";
2206 info->name =
"object_delete_uncreated";
2207 info->category =
"/main/sorcery/";
2208 info->summary =
"sorcery object deletion unit test";
2210 "Test object deletion of an uncreated object in sorcery";
2244 info->name =
"object_is_stale";
2245 info->category =
"/main/sorcery/";
2246 info->summary =
"sorcery object staleness unit test";
2248 "Test whether sorcery will query a wizard correctly if asked\n"
2249 "if an object is stale.";
2323 info->name =
"caching_wizard_behavior";
2324 info->category =
"/main/sorcery/";
2325 info->summary =
"sorcery caching wizard behavior unit test";
2327 "Test internal behavior of caching wizards";
2387 }
else if (obj == obj2) {
2433 info->name =
"object_type_observer";
2434 info->category =
"/main/sorcery/";
2435 info->summary =
"sorcery object type observer unit test";
2437 "Test that object type observers get called when they should";
2477 struct timespec
end = {
2478 .tv_sec = start.tv_sec + 10,
2479 .tv_nsec = start.tv_usec * 1000,
2500 struct timespec
end = {
2501 .tv_sec = start.tv_sec + 10,
2502 .tv_nsec = start.tv_usec * 1000,
2523 struct timespec
end = {
2524 .tv_sec = start.tv_sec + 10,
2525 .tv_nsec = start.tv_usec * 1000,
2543 struct timespec
end = {
2544 .tv_sec = start.tv_sec + 10,
2545 .tv_nsec = start.tv_usec * 1000,
2579 info->name =
"configuration_file_wizard";
2580 info->category =
"/main/sorcery/";
2581 info->summary =
"sorcery configuration file wizard unit test";
2583 "Test the configuration file wizard in sorcery";
2590 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard test\n");
2602 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2622 }
else if (obj->bob != 98) {
2625 }
else if (obj->joe != 41) {
2642 info->name =
"configuration_file_wizard_with_file_integrity";
2643 info->category =
"/main/sorcery/";
2644 info->summary =
"sorcery configuration file wizard file integrity unit test";
2646 "Test the configuration file wizard with file integrity turned on in sorcery";
2653 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard_with_file_integrity test\n");
2665 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2696 info->name =
"configuration_file_wizard_with_criteria";
2697 info->category =
"/main/sorcery/";
2698 info->summary =
"sorcery configuration file wizard with criteria unit test";
2700 "Test the configuration file wizard with criteria matching in sorcery";
2707 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard_with_criteria test\n");
2719 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2755 info->name =
"configuration_file_wizard_retrieve_field";
2756 info->category =
"/main/sorcery/";
2757 info->summary =
"sorcery configuration file wizard field retrieval unit test";
2759 "Test the configuration file wizard retrieval using field in sorcery";
2766 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard_retrieve_field test\n");
2778 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2813 info->name =
"configuration_file_wizard_retrieve_multiple";
2814 info->category =
"/main/sorcery/";
2815 info->summary =
"sorcery configuration file wizard multiple retrieval unit test";
2817 "Test the configuration file wizard multiple retrieval in sorcery";
2824 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard_retrieve_multiple test\n");
2841 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2889 info->name =
"configuration_file_wizard_retrieve_multiple_all";
2890 info->category =
"/main/sorcery/";
2891 info->summary =
"sorcery configuration file wizard multiple retrieve all unit test";
2893 "Test the configuration file wizard multiple retrieve all in sorcery";
2900 ast_test_status_update(
test,
"Test sorcery configuration file wizard file not present - skipping configuration_file_wizard_retrieve_multiple_all test\n");
2912 ast_test_status_update(
test,
"Could not set a default wizard of the 'config' type, so skipping since it may not be loaded\n");
2943 char expression[256];
2947 info->name =
"dialplan_function";
2948 info->category =
"/main/sorcery/";
2949 info->summary =
"AST_SORCERY dialplan function";
2951 "Test the AST_SORCERY dialplan function";
2978 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"notest_sorcery",
"test",
"blah",
"bob");
2986 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"test_sorcery",
"notest",
"blah",
"bob");
2994 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"test_sorcery",
"test",
"noid",
"bob");
3002 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"test_sorcery",
"test",
"blah",
"nobob");
3010 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"test_sorcery",
"test",
"blah",
"bob");
3023 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,single,1)",
"test_sorcery",
"test",
"blah",
"bob");
3036 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,single,2)",
"test_sorcery",
"test",
"blah",
"bob");
3048 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s)",
"test_sorcery",
"test",
"blah",
"jim");
3061 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,single,2)",
"test_sorcery",
"test",
"blah",
"jim");
3074 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,concat,|)",
"test_sorcery",
"test",
"blah",
"jim");
3087 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,noconcat,3)",
"test_sorcery",
"test",
"blah",
"jim");
3095 snprintf(expression,
sizeof(expression),
"AST_SORCERY(%s,%s,%s,%s,single,|)",
"test_sorcery",
"test",
"blah",
"jim");
3114 info->name =
"object_field_registered";
3115 info->category =
"/main/sorcery/";
3116 info->summary =
"ast_sorcery_is_object_field_registered unit test";
3118 "Test ast_sorcery_is_object_field_registered in sorcery";
3153 if (!strcmp(wizard->
name,
"test")) {
3160 if (!strcmp(
name,
"test_sorcery")) {
3178 info->name =
"global_observation";
3179 info->category =
"/main/sorcery/";
3180 info->summary =
"global sorcery observation test";
3182 "Test observation of sorcery (global)";
3218 if (!strcmp(
name,
"test_sorcery") && !reloaded) {
3226 if (!strcmp(
name,
"test_sorcery") && reloaded) {
3233 const char *wizard_args,
void *wizard_data)
3235 if (!strcmp(
name,
"test_sorcery") && !strcmp(object_type,
"test_object_type")
3236 && !strcmp(wizard->
name,
"memory") && !strcmp(wizard_args,
"memwiz")) {
3244 if (!strcmp(
name,
"test_sorcery") && !strcmp(object_type,
"test_object_type")) {
3252 if (!strcmp(
name,
"test_sorcery") && !strcmp(object_type,
"test_object_type")
3261 if (!strcmp(
name,
"test_sorcery") && !strcmp(object_type,
"test_object_type")
3277 info->name =
"instance_observation";
3278 info->category =
"/main/sorcery/";
3279 info->summary =
"sorcery instance observation test";
3281 "Test observation of sorcery (instance)";
3360 if (!strcmp(
name,
"test") && !strcmp(object_type,
"test_object_type")
3374 if (!strcmp(
name,
"test") && !strcmp(object_type,
"test_object_type")
3391 info->name =
"wizard_observation";
3392 info->category =
"/main/sorcery/";
3393 info->summary =
"sorcery wizard observation test";
3395 "Test observation of sorcery (wizard)";
3462 info->name =
"wizard_apply_and_insert";
3463 info->category =
"/main/sorcery/";
3464 info->summary =
"sorcery wizard apply and insert test";
3466 "sorcery wizard apply and insert test";
3487 ast_test_validate(
test,
3492 ast_test_validate(
test,
3495 ast_test_validate(
test,
3497 ast_test_validate(
test, strcmp(
"test", wizard->name) == 0);
3501 ast_test_validate(
test,
3504 ast_test_validate(
test,
3507 ast_test_validate(
test,
3511 ast_test_validate(
test,
3514 ast_test_validate(
test,
3516 ast_test_validate(
test, strcmp(
"test2", wizard->name) == 0);
3517 ast_test_validate(
test, strcmp(
"test2data", data) == 0);
3521 ast_test_validate(
test,
3523 ast_test_validate(
test, strcmp(
"test", wizard->name) == 0);
3528 ast_test_validate(
test,
3531 ast_test_validate(
test,
3534 ast_test_validate(
test,
3537 ast_test_validate(
test,
3542 ast_test_validate(
test,
3544 ast_test_validate(
test,
3548 ast_test_validate(
test,
3551 ast_test_validate(
test,
3554 ast_test_validate(
test,
3556 ast_test_validate(
test, strcmp(
"test2", wizard->name) == 0);
3557 ast_test_validate(
test, strcmp(
"test2data", data) == 0);
3565 .
name =
"test-read-only",
3579 info->name =
"wizard_read_only";
3580 info->category =
"/main/sorcery/";
3581 info->summary =
"sorcery wizard read-only test";
3583 "sorcery wizard read-only test";
3606 ast_test_validate(
test,
3609 ast_test_validate(
test,
3613 ast_test_validate(
test, strcmp(wizard->
name, wizard1->name) == 0);
3615 ast_test_validate(
test,
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
static const char config[]
static int apply_config(struct aco_info *info)
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
@ OPT_UINT_T
Type for default option handler for unsigned integers.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
static int set(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
char * strsep(char **str, const char *delims)
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
Support for logging to various files, console and syslog Configuration in file logger....
Asterisk JSON abstraction layer.
struct ast_json * ast_json_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json_iter * ast_json_object_iter_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
struct ast_json_iter * ast_json_object_iter(struct ast_json *object)
Get an iterator pointing to the first field in a JSON object.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
const char * ast_json_object_iter_key(struct ast_json_iter *iter)
Get the key from an iterator.
#define ast_cond_destroy(cond)
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
pthread_cond_t ast_cond_t
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
static struct ast_sorcery * sorcery
Sorcery Data Access Layer API.
#define ast_sorcery_object_type_insert_wizard(sorcery, object_type_name, wizard_type_name, wizard_args, flags, position, wizard, wizard_data)
Insert an additional object wizard mapping at a specific position in the wizard list returning wizard...
const char * ast_sorcery_object_get_extended(const void *object, const char *name)
Get an extended field value from a sorcery object.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
#define ast_sorcery_object_field_register_nodoc(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object without documentation.
int ast_sorcery_wizard_unregister(const struct ast_sorcery_wizard *interface)
Unregister a sorcery wizard.
#define ast_sorcery_objectset_create(sorcery, object)
Create an object set (KVP list) for an object.
int ast_sorcery_object_fields_register(struct ast_sorcery *sorcery, const char *type, const char *regex, aco_option_handler config_handler, sorcery_fields_handler sorcery_handler)
Register a regex for multiple fields within an object.
#define ast_sorcery_object_field_register_custom_nodoc(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers without documentation.
int ast_sorcery_object_set_extended(const void *object, const char *name, const char *value)
Set an extended field value on a sorcery object.
#define ast_sorcery_insert_wizard_mapping(sorcery, type, name, data, caching, position)
Insert an additional object wizard mapping at a specific position in the wizard list.
void ast_sorcery_instance_observer_remove(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Remove an observer from a sorcery instance.
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
@ AST_RETRIEVE_FLAG_DEFAULT
Default retrieval flags.
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
void ast_sorcery_wizard_observer_remove(struct ast_sorcery_wizard *interface, const struct ast_sorcery_wizard_observer *callbacks)
Remove an observer from a sorcery wizard.
const char * ast_sorcery_object_get_type(const void *object)
Get the type of a sorcery object.
void ast_sorcery_object_set_copy_handler(struct ast_sorcery *sorcery, const char *type, sorcery_copy_handler copy)
Set the copy handler for an object type.
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
struct ast_sorcery_object_type * ast_sorcery_get_object_type(const struct ast_sorcery *sorcery, const char *type)
Get the sorcery object type given a type name.
int ast_sorcery_diff(const struct ast_sorcery *sorcery, const void *original, const void *modified, struct ast_variable **changes)
Create a changeset of two objects.
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
void ast_sorcery_reload(const struct ast_sorcery *sorcery)
Inform any wizards to reload persistent objects.
int ast_sorcery_get_wizard_mapping_count(struct ast_sorcery *sorcery, const char *type)
Return the number of wizards mapped to an object type.
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
void ast_sorcery_load_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to load persistent objects.
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply)
Register an internal, hidden object type.
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
#define ast_sorcery_remove_wizard_mapping(sorcery, type, name)
Remove an object wizard mapping.
#define ast_sorcery_apply_config(sorcery, name)
int ast_sorcery_changeset_create(const struct ast_variable *original, const struct ast_variable *modified, struct ast_variable **changes)
Create a changeset given two object sets.
#define ast_sorcery_wizard_register(interface)
See __ast_sorcery_wizard_register()
int ast_sorcery_is_object_field_registered(const struct ast_sorcery_object_type *object_type, const char *field_name)
Determine if a particular object field has been registered with sorcery.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
int ast_sorcery_objectset_apply(const struct ast_sorcery *sorcery, void *object, struct ast_variable *objectset)
Apply an object set (KVP list) to an object.
int ast_sorcery_get_wizard_mapping(struct ast_sorcery *sorcery, const char *type, int index, struct ast_sorcery_wizard **wizard, void **data)
By index, return a wizard mapped to an object type.
int ast_sorcery_wizard_observer_add(struct ast_sorcery_wizard *wizard, const struct ast_sorcery_wizard_observer *callbacks)
Add an observer to a sorcery wizard.
void ast_sorcery_global_observer_remove(const struct ast_sorcery_global_observer *callbacks)
Remove a global observer from sorcery.
#define ast_sorcery_apply_default(sorcery, type, name, data)
struct ast_json * ast_sorcery_objectset_json_create(const struct ast_sorcery *sorcery, const void *object)
Create an object set in JSON format for an object.
int ast_sorcery_global_observer_add(const struct ast_sorcery_global_observer *callbacks)
Add a global observer to sorcery.
#define ast_sorcery_open()
Open a new sorcery structure.
void ast_sorcery_reload_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to reload persistent objects.
int ast_sorcery_is_stale(const struct ast_sorcery *sorcery, void *object)
Determine if a sorcery object is stale with respect to its backing datastore.
int ast_sorcery_instance_observer_add(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Add an observer to a sorcery instance.
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
struct ast_sorcery * ast_sorcery_retrieve_by_module_name(const char *module_name)
Retrieves an existing sorcery instance by module name.
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
void * ast_sorcery_copy(const struct ast_sorcery *sorcery, const void *object)
Create a copy of an object.
@ AST_SORCERY_WIZARD_APPLY_ALLOW_DUPLICATE
@ AST_SORCERY_WIZARD_APPLY_READONLY
#define ast_sorcery_object_type_remove_wizard(sorcery, object_type_name, wizard_type_name, wizard_args)
Remove an object wizard mapping.
@ AST_SORCERY_APPLY_SUCCESS
@ AST_SORCERY_APPLY_DEFAULT_UNNECESSARY
void ast_sorcery_object_set_diff_handler(struct ast_sorcery *sorcery, const char *type, sorcery_diff_handler diff)
Set the diff handler for an object type.
#define ast_sorcery_object_type_apply_wizard(sorcery, object_type_name, wizard_type_name, wizard_args, flags, wizard, wizard_data)
Apply additional object wizard mappings returning wizard information.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Structure used to handle boolean flags.
Iterator for JSON object key/values.
Abstract JSON element (object, array, string, int, ...).
Structure for mutex and tracking information.
Interface for the global sorcery observer.
Interface for the sorcery instance observer.
Structure for registered object type.
Interface for a sorcery object type observer.
void(* created)(const void *object)
Callback for when an object is created.
Interface for the sorcery wizard observer.
Interface for a sorcery wizard.
const char * name
Name of the wizard.
Full structure for sorcery.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Test structure for caching.
unsigned int updated
Whether the object has been updated in the cache or not.
struct test_sorcery_object object
Object to return when asked.
unsigned int is_stale
Whether the object is stale or not.
unsigned int deleted
Whether the object has been deleted from the cache or not.
unsigned int created
Whether the object has been created in the cache or not.
Test structure for observer.
ast_cond_t cond
Condition for notification.
const void * updated
Pointer to the update object.
const void * created
Pointer to the created object.
const void * deleted
Pointer to the deleted object.
unsigned int loaded
Whether the type has been loaded.
ast_mutex_t lock
Lock for notification.
struct ast_variable * jack
struct ast_variable * jim
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static int event_observed
static void wizard_reloaded_observer(const char *name, const struct ast_sorcery_wizard *wizard, const char *object_type, int reloaded)
static void wizard_loaded_observer(const char *name, const struct ast_sorcery_wizard *wizard, const char *object_type, int reloaded)
static struct ast_sorcery * alloc_and_initialize_sorcery(void)
static void object_type_reloaded_observer(const char *name, const struct ast_sorcery *sorcery, const char *object_type, int reloaded)
static void sorcery_observer_deleted(const void *object)
static int sorcery_test_delete(const struct ast_sorcery *sorcery, void *data, void *object)
static struct ast_sorcery_wizard test_wizard2
static void test_sorcery_object_destroy(void *obj)
Internal function to destroy a test object.
static void * test_sorcery_object_alloc(const char *id)
Internal function to allocate a test object.
static void sorcery_test_load(void *data, const struct ast_sorcery *sorcery, const char *type)
static void instance_loaded_observer(const char *name, const struct ast_sorcery *sorcery, int reloaded)
static void sorcery_observer_updated(const void *object)
static struct ast_sorcery_wizard test_wizard
Dummy sorcery wizards, not actually used so we only populate the name and nothing else.
AST_TEST_DEFINE(wizard_registration)
static int jim_vl(const void *obj, struct ast_variable **fields)
static void object_type_loaded_observer(const char *name, const struct ast_sorcery *sorcery, const char *object_type, int reloaded)
static int test_sorcery_copy(const void *src, void *dst)
Internal function which copies pre-defined data into an object, natively.
static int test_sorcery_regex_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Internal function which sets some values.
static struct sorcery_test_caching cache
Global scope caching structure for testing.
static void * wizard2_data
static int test_sorcery_diff(const void *original, const void *modified, struct ast_variable **changes)
Internal function which creates a pre-defined diff natively.
static struct ast_sorcery_wizard test_read_only_wizard
static void object_type_registered_observer(const char *name, struct ast_sorcery *sorcery, const char *object_type)
static int sorcery_test_update(const struct ast_sorcery *sorcery, void *data, void *object)
static const struct ast_sorcery_observer test_observer
Test sorcery observer implementation.
static void wizard_mapped_observer(const char *name, struct ast_sorcery *sorcery, const char *object_type, struct ast_sorcery_wizard *wizard, const char *wizard_args, void *wizard_data)
static int jack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int sorcery_test_is_stale(const struct ast_sorcery *sorcery, void *data, void *object)
static void wizard_observer(const char *name, const struct ast_sorcery_wizard *wizard)
static int apply_handler_called
Global scope apply handler integer to make sure it executed.
static int jim_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void instance_observer(const char *name, struct ast_sorcery *sorcery)
static int load_module(void)
static void * sorcery_test_retrieve_id(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
static int test_apply_handler(const struct ast_sorcery *sorcery, void *obj)
Simple apply handler which sets global scope integer to 1 if called.
static void * sorcery_test_open(const char *data)
static struct sorcery_test_observer observer
Global scope observer structure for testing.
static struct ast_variable * test_sorcery_transform(struct ast_variable *set)
Internal function for object set transformation.
static int unload_module(void)
static void sorcery_test_close(void *data)
static void instance_reloaded_observer(const char *name, const struct ast_sorcery *sorcery, int reloaded)
static int sorcery_test_create(const struct ast_sorcery *sorcery, void *data, void *object)
static int test_sorcery_regex_fields(const void *obj, struct ast_variable **fields)
Internal function which creates some ast_variable structures.
static int jack_str(const void *obj, const intptr_t *args, char **buf)
static void sorcery_observer_created(const void *object)
static void sorcery_observer_loaded(const char *object_type)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.