51 AST_RWLIST_INSERT_HEAD(&
imagers, img, list);
53 ast_verb(5,
"Registered format '%s' (%s)\n", img->
name, img->
desc);
60 img = AST_RWLIST_REMOVE(&
imagers, img, list);
64 ast_verb(5,
"Unregistered format '%s' (%s)\n", img->
name, img->
desc);
76 static int file_exists(
char *filename)
80 res = stat(filename, &st);
86 static void make_filename(
char *buf,
int len,
const char *filename,
const char *preflang,
char *ext)
88 if (filename[0] ==
'/') {
89 if (!ast_strlen_zero(preflang))
90 snprintf(buf, len,
"%s-%s.%s", filename, preflang, ext);
92 snprintf(buf, len,
"%s.%s", filename, ext);
94 if (!ast_strlen_zero(preflang))
95 snprintf(buf, len,
"%s/%s/%s-%s.%s", ast_config_AST_DATA_DIR,
"images", filename, preflang, ext);
97 snprintf(buf, len,
"%s/%s/%s.%s", ast_config_AST_DATA_DIR,
"images", filename, ext);
113 AST_RWLIST_TRAVERSE(&
imagers, i, list) {
119 e = strsep(&stringp,
"|");
122 if ((len = file_exists(buf))) {
127 if ((len = file_exists(buf))) {
131 e = strsep(&stringp,
"|");
139 fd = open(buf, O_RDONLY);
143 lseek(fd, 0, SEEK_SET);
146 ast_log(LOG_WARNING,
"%s does not appear to be a %s file\n", buf, found->
name);
149 ast_log(LOG_WARNING,
"Unable to open '%s': %s\n", buf, strerror(errno));
151 ast_log(LOG_WARNING,
"Image file '%s' not found\n", filename);
174 #define FORMAT "%10s %10s %50s %10s\n"
175 #define FORMAT2 "%10s %10s %50s %10s\n"
181 e->
command =
"core show image formats";
183 "Usage: core show image formats\n"
184 " Displays currently registered image formats (if any).\n";
190 return CLI_SHOWUSAGE;
191 ast_cli(a->fd, FORMAT,
"Name",
"Extensions",
"Description",
"Format");
192 ast_cli(a->fd, FORMAT,
"----",
"----------",
"-----------",
"------");
194 AST_RWLIST_TRAVERSE(&
imagers, i, list) {
199 ast_cli(a->fd,
"\n%d image format%s registered.\n", count_fmt, count_fmt == 1 ?
"" :
"s");
204 AST_CLI_DEFINE(handle_core_show_image_formats,
"Displays image formats")
207 static void image_shutdown(
void)
structure associated with registering an image format
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
int(*const send_image)(struct ast_channel *chan, struct ast_frame *frame)
Display or send an image.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Support for translation of data formats. translate.c.
static void make_filename(const char *channel, char *filename, size_t size)
create the filename that will be used for a logger channel.
descriptor for a cli entry.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
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_image_init(void)
Initialize image stuff Initializes all the various image stuff. Basically just registers the cli stuf...
int ast_supports_images(struct ast_channel *chan)
Check for image support on a channel.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
struct ast_frame *(* read_image)(int fd, int len)
General Asterisk channel definitions for image handling.
General Asterisk PBX channel definitions.
void ast_image_unregister(struct ast_imager *img)
Unregister an image format.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Asterisk file paths, configured in asterisk.conf.
struct ast_frame * ast_read_image(const char *filename, const char *preflang, struct ast_format *format)
Make an image.
Scheduler Routines (derived from cheops)
Structure to describe a channel "technology", ie a channel driver See for examples: ...
int ast_send_image(struct ast_channel *chan, const char *filename)
Sends an image.
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Data structure associated with a single frame of data.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
struct ast_format * format
int ast_image_register(struct ast_imager *img)
Register image format.