50 struct _filenames *filenames)
59 if ((res = rmdir(dir_name)) < 0) {
67 struct _filenames *filenames,
int num)
82 for (i = 0; i < num; ++i) {
122 char *full_path =
ast_alloca(strlen(dir_name) + strlen(filename) + 2);
124 sprintf(full_path,
"%s/%s", dir_name, filename);
127 if (stat(full_path, &statbuf)) {
129 full_path, strerror(
errno));
133 return strcmp(obj, filename) ? 0 :
FOUND;
138 char tmp_dir[] =
"/tmp/tmpdir.XXXXXX";
140 struct _filenames filenames;
142 const int num_files = 10 + (
ast_random() % 10);
146 info->name =
"read_dir_test";
147 info->category =
"/main/file/";
148 info->summary =
"Read a directory's content";
149 info->description =
"Iterate over directories looking for a file.";
165 ast_str_set(&tmp_sub_dir, 0,
"%s/XXXXXX", tmp_dir);
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_TEST_REGISTER(cb)
static int test_files_destroy(struct ast_test *test, char *dir_name, struct _filenames *filenames)
static int load_module(void)
#define ast_str_alloca(init_len)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_file_read_dirs(const char *dir_name, ast_file_on_file on_file, void *obj, int max_depth)
Recursively iterate through files and directories up to max_depth.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Asterisk file paths, configured in asterisk.conf.
#define ast_test_status_update(a, b, c...)
long int ast_random(void)
AST_VECTOR(_filenames, struct ast_str *)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
char * mkdtemp(char *template_s)
#define AST_TEST_UNREGISTER(cb)
static void rm_file(struct ast_str *filename)
static int unload_module(void)
static char * test_files_get_one(struct _filenames *filenames, int num)
Vector container support.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
AST_TEST_DEFINE(read_dirs_test)
static int test_files_create(struct ast_test *test, char *dir_name, struct _filenames *filenames, int num)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static int handle_find_file(const char *dir_name, const char *filename, void *obj)
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.