40#define VARIANT_BUCKETS 7
43#define INDEX_BUCKETS 157
64 size_t str_sz = strlen(variant_str) + 1;
73 memcpy(
variant->variant, variant_str, str_sz);
113 size_t name_sz = strlen(
name) + 1;
126 if (!
info->variants) {
144 const char *
name = (flags &
OBJ_KEY) ? arg : opt2->name;
164 size_t base_dir_sz = strlen(
base_dir) + 1;
349 const char *file_identifier = filename_stripped;
350 char *file_id_str =
NULL;
361 if (
ast_asprintf(&file_id_str,
"%s/%s", subdir, filename_stripped) == -1) {
365 file_identifier = file_id_str;
382 const char *variant_str,
383 const char *filename,
384 const char *match_filename)
388 char *file_id_persist =
NULL;
391#if defined(LOW_MEMORY)
397 if (!description_file_path || !cumulative_description) {
402 ast_str_set(&description_file_path, 0,
"%s/%s/%s", index->
base_dir, variant_str, filename);
404 ast_str_set(&description_file_path, 0,
"%s/%s/%s/%s", index->
base_dir, variant_str, subdir, filename);
413 char *file_identifier, *description;
414 if (!fgets(
buf,
sizeof(
buf), f)) {
422 if (strlen(
buf) ==
sizeof(
buf) - 1 &&
buf[
sizeof(
buf) - 1] !=
'\n') {
424 while (fgets(
buf,
sizeof(
buf), f)) {
425 if (strlen(
buf) !=
sizeof(
buf) - 1 ||
buf[
sizeof(
buf) - 1] ==
'\n') {
442 file_identifier =
strsep(&description,
":");
445 if (file_id_persist) {
446 ast_str_append(&cumulative_description, 0,
"\n%s", file_identifier);
458 if (
ast_strlen_zero(match_filename) || strcmp(match_filename, file_id_persist) == 0) {
472 file_id_persist =
ast_strdup(file_identifier);
486 if (
ast_strlen_zero(match_filename) || strcmp(match_filename, file_id_persist) == 0) {
510static int read_dirs_cb(
const char *dir_name,
const char *filename,
void *obj)
516 size_t match_base_len;
517 char *subdirs = (
char *)dir_name + data->
dirname_len;
535 if (*subdirs ==
'/') {
541 match_len = strlen(subdirs) + strlen(filename) + 2;
543 snprintf(
match, match_len,
"%s%s%s", subdirs,
572 if (strcmp(
ext,
".txt") == 0) {
588 const char *variant,
const char *filename)
590 struct timeval start;
594 size_t dirname_len = strlen(index->
base_dir) + strlen(
S_OR(variant,
"")) + 1;
597 .search_filename_len = strlen(
S_OR(filename,
"")),
598 .search_variant =
S_OR(variant,
""),
607 gettimeofday(&start,
NULL);
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Generic File Format Support. Should be included by clients of the file handling routines....
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.
struct ast_format * ast_get_format_for_file_ext(const char *file_ext)
Get the ast_format associated with the given file extension.
char * strsep(char **str, const char *delims)
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk locking-related definitions:
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
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.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Support for dynamic strings.
const char * search_filename
struct ast_media_index * index
const char * search_variant
size_t search_filename_len
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.