66 strcat(buff,t1->name);
71 ast_debug(1,
"Got: %s [expect %s]\n", buff, expect);
74 static void print_list_backwards(
struct test_container *x,
char *expect)
80 strcat(buff,t1->name);
85 ast_debug(1,
"Got: %s [expect %s]\n", buff, expect);
94 static struct test1 *make_test1(
char *name)
97 strcpy(t1->name, name);
172 static void dll_tests(
void)
181 ast_debug(1,
"Test AST_DLLIST_INSERT_HEAD, AST_DLLIST_TRAVERSE, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END\n");
191 print_list(tc,
"A <=> B <=> C <=> D");
193 destroy_test_container(tc);
198 ast_debug(1,
"Test AST_DLLIST_EMPTY....OK\n");
200 ast_log(LOG_ERROR,
"Test AST_DLLIST_EMPTY....PROBLEM!!\n");
208 ast_debug(1,
"Test AST_DLLIST_INSERT_TAIL\n");
213 print_list(tc,
"A <=> B <=> C <=> D");
216 ast_debug(1,
"Test AST_DLLIST_FIRST....OK\n");
218 ast_log(LOG_ERROR,
"Test AST_DLLIST_FIRST....PROBLEM\n");
221 ast_debug(1,
"Test AST_DLLIST_LAST....OK\n");
223 ast_log(LOG_ERROR,
"Test AST_DLLIST_LAST....PROBLEM\n");
226 ast_debug(1,
"Test AST_DLLIST_NEXT....OK\n");
228 ast_log(LOG_ERROR,
"Test AST_DLLIST_NEXT....PROBLEM\n");
231 ast_debug(1,
"Test AST_DLLIST_PREV....OK\n");
233 ast_log(LOG_ERROR,
"Test AST_DLLIST_PREV....PROBLEM\n");
235 destroy_test_container(tc);
244 ast_debug(1,
"Test AST_DLLIST_INSERT_AFTER, AST_DLLIST_TRAVERSE_BACKWARDS\n");
249 print_list_backwards(tc,
"D <=> C <=> B <=> A");
251 ast_debug(1,
"Test AST_DLLIST_REMOVE_HEAD\n");
253 print_list_backwards(tc,
"D <=> C <=> B");
254 ast_debug(1,
"Test AST_DLLIST_REMOVE_HEAD\n");
256 print_list_backwards(tc,
"D <=> C");
257 ast_debug(1,
"Test AST_DLLIST_REMOVE_HEAD\n");
259 print_list_backwards(tc,
"D");
263 ast_debug(1,
"Test AST_DLLIST_REMOVE_HEAD....OK\n");
265 ast_log(LOG_ERROR,
"Test AST_DLLIST_REMOVE_HEAD....PROBLEM!!\n");
274 print_list(tc,
"A <=> B <=> D");
276 print_list(tc,
"B <=> D");
282 ast_debug(1,
"Test AST_DLLIST_REMOVE....OK\n");
284 ast_log(LOG_ERROR,
"Test AST_DLLIST_REMOVE....PROBLEM!!\n");
296 ast_debug(1,
"Test AST_DLLIST_REMOVE_CURRENT... OK\n");
298 ast_log(LOG_ERROR,
"Test AST_DLLIST_REMOVE_CURRENT... PROBLEM\n");
300 ast_debug(1,
"Test AST_DLLIST_MOVE_CURRENT, AST_DLLIST_INSERT_BEFORE_CURRENT\n");
315 print_list(tc,
"D <=> A <=> C <=> B");
317 destroy_test_container(tc);
326 ast_debug(1,
"Test: AST_DLLIST_MOVE_CURRENT_BACKWARDS and AST_DLLIST_INSERT_BEFORE_CURRENT_BACKWARDS\n");
333 print_list(tc,
"C <=> A <=> B");
339 print_list(tc,
"C <=> A");
343 print_list(tc,
"C <=> A <=> D");
348 print_list(tc,
"C <=> A <=> D");
350 destroy_test_container(tc);
353 static int unload_module(
void)
358 static int load_module(
void)
#define AST_DLLIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_DLLIST_TRAVERSE_BACKWARDS(head, var, field)
Loops over (traverses) the entries in a list in reverse order, starting at the end.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define AST_DLLIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_DLLIST_MOVE_CURRENT_BACKWARDS(newhead, field)
Move the current list entry to another list at the head.
#define AST_DLLIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_DLLIST_INSERT_AFTER(head, listelm, elm, field)
Inserts a list entry after a given entry.
#define AST_DLLIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
#define AST_DLLIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_DLLIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
A set of macros to manage doubly-linked lists.
General Asterisk PBX channel definitions.
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_DLLIST_INSERT_BEFORE_CURRENT_BACKWARDS(elm, field)
Inserts a list entry after the current entry during a backwards traversal. Since this is a backwards ...
#define ast_debug(level,...)
Log a DEBUG message.
Core PBX routines and definitions.
#define AST_DLLIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list node before the current node during a traversal.
#define ast_calloc(num, len)
A wrapper for calloc()
#define AST_DLLIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
#define AST_DLLIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_DLLIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END
Closes a safe loop traversal block.
#define AST_DLLIST_PREV(elm, field)
Returns the previous entry in the list before the given entry.
#define AST_DLLIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DLLIST_FIRST(head)
Returns the first entry contained in a list.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_DLLIST_MOVE_CURRENT(newhead, field)
Move the current list entry to another list at the tail.
#define AST_DLLIST_LAST(head)
Returns the last entry contained in a list.
#define AST_DLLIST_ENTRY(type)
Declare previous/forward links inside a list entry.