Header for providers of file and format handling routines. Clients of these routines should include "asterisk/file.h" instead. More...


Go to the source code of this file.
Data Structures | |
| struct | ast_filestream |
| This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of memory to be used for private purposes (e.g. buffers etc.) More... | |
| struct | ast_format_def |
| Each supported file format is described by the following structure. More... | |
Defines | |
| #define | ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self) |
Functions | |
| int | __ast_format_def_register (const struct ast_format_def *f, struct ast_module *mod) |
| Register a new file format capability. Adds a format to Asterisk's format abilities. | |
| int | ast_format_def_unregister (const char *name) |
| Unregisters a file format. | |
Header for providers of file and format handling routines. Clients of these routines should include "asterisk/file.h" instead.
Definition in file mod_format.h.
| #define ast_format_def_register | ( | f | ) | __ast_format_def_register(f, ast_module_info->self) |
Definition at line 131 of file mod_format.h.
Referenced by load_module().
| int __ast_format_def_register | ( | const struct ast_format_def * | f, |
| struct ast_module * | mod | ||
| ) |
Register a new file format capability. Adds a format to Asterisk's format abilities.
| 0 | on success |
| -1 | on failure |
Definition at line 69 of file file.c.
References ast_calloc, ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_format_def::buf_size, ast_format_def::exts, f, ast_format_def::list, LOG_WARNING, ast_format_def::module, and ast_format_def::name.
{
struct ast_format_def *tmp;
AST_RWLIST_WRLOCK(&formats);
AST_RWLIST_TRAVERSE(&formats, tmp, list) {
if (!strcasecmp(f->name, tmp->name)) {
AST_RWLIST_UNLOCK(&formats);
ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", f->name);
return -1;
}
}
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
AST_RWLIST_UNLOCK(&formats);
return -1;
}
*tmp = *f;
tmp->module = mod;
if (tmp->buf_size) {
/*
* Align buf_size properly, rounding up to the machine-specific
* alignment for pointers.
*/
struct _test_align { void *a, *b; } p;
int align = (char *)&p.b - (char *)&p.a;
tmp->buf_size = ((f->buf_size + align - 1) / align) * align;
}
memset(&tmp->list, 0, sizeof(tmp->list));
AST_RWLIST_INSERT_HEAD(&formats, tmp, list);
AST_RWLIST_UNLOCK(&formats);
ast_verb(2, "Registered file format %s, extension(s) %s\n", f->name, f->exts);
return 0;
}
| int ast_format_def_unregister | ( | const char * | name | ) |
Unregisters a file format.
| name | the name of the format you wish to unregister Unregisters a format based on the name of the format. |
| 0 | on success |
| -1 | on failure to unregister |
Definition at line 106 of file file.c.
References ast_free, ast_log(), AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_format_def::list, LOG_WARNING, and ast_format_def::name.
Referenced by unload_module().
{
struct ast_format_def *tmp;
int res = -1;
AST_RWLIST_WRLOCK(&formats);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) {
if (!strcasecmp(name, tmp->name)) {
AST_RWLIST_REMOVE_CURRENT(list);
ast_free(tmp);
res = 0;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&formats);
if (!res)
ast_verb(2, "Unregistered format %s\n", name);
else
ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name);
return res;
}