fix compiler warnings
[asterisk/asterisk.git] / image.c
diff --git a/image.c b/image.c
index 7ee2b08..894e660 100755 (executable)
--- a/image.c
+++ b/image.c
@@ -1,55 +1,68 @@
 /*
- * Asterisk -- A telephony toolkit for Linux.
+ * Asterisk -- An open source telephony toolkit.
  *
- * Channel Management
- * 
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999 - 2005, Digium, Inc.
+ *
+ * Mark Spencer <markster@digium.com>
  *
- * Mark Spencer <markster@linux-support.net>
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
  *
  * This program is free software, distributed under the terms of
- * the GNU General Public License
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Image Management
+ * 
  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <pthread.h>
 #include <string.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <signal.h>
 #include <errno.h>
 #include <unistd.h>
-#include <asterisk/sched.h>
-#include <asterisk/options.h>
-#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
-#include <asterisk/logger.h>
-#include <asterisk/file.h>
-#include <asterisk/image.h>
-#include <asterisk/translate.h>
-#include <asterisk/cli.h>
+
 #include "asterisk.h"
-#include "astconf.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/sched.h"
+#include "asterisk/options.h"
+#include "asterisk/channel.h"
+#include "asterisk/logger.h"
+#include "asterisk/file.h"
+#include "asterisk/image.h"
+#include "asterisk/translate.h"
+#include "asterisk/cli.h"
+#include "asterisk/lock.h"
 
 static struct ast_imager *list;
-static pthread_mutex_t listlock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(listlock);
 
 int ast_image_register(struct ast_imager *img)
 {
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
        img->next = list;
        list = img;
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
        return 0;
 }
 
 void ast_image_unregister(struct ast_imager *img)
 {
        struct ast_imager *i, *prev = NULL;
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
        i = list;
        while(i) {
                if (i == img) {
@@ -62,16 +75,16 @@ void ast_image_unregister(struct ast_imager *img)
                prev = i;
                i = i->next;
        }
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
        if (i && (option_verbose > 1))
-               ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc);
+               ast_verbose(VERBOSE_PREFIX_2 "Unregistered format '%s' (%s)\n", img->name, img->desc);
 }
 
 int ast_supports_images(struct ast_channel *chan)
 {
-       if (!chan || !chan->pvt)
+       if (!chan || !chan->tech)
                return 0;
-       if (!chan->pvt->send_image)
+       if (!chan->tech->send_image)
                return 0;
        return 1;
 }
@@ -112,7 +125,7 @@ struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
        int len=0;
        struct ast_frame *f = NULL;
 #if 0 /* We need to have some sort of read-only lock */
-       ast_pthread_mutex_lock(&listlock);
+       ast_mutex_lock(&listlock);
 #endif 
        i = list;
        while(!found && i) {
@@ -152,7 +165,7 @@ struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
        } else
                ast_log(LOG_WARNING, "Image file '%s' not found\n", filename);
 #if 0
-       ast_pthread_mutex_unlock(&listlock);
+       ast_mutex_unlock(&listlock);
 #endif 
        return f;
 }
@@ -162,10 +175,10 @@ int ast_send_image(struct ast_channel *chan, char *filename)
 {
        struct ast_frame *f;
        int res = -1;
-       if (chan->pvt->send_image) {
+       if (chan->tech->send_image) {
                f = ast_read_image(filename, chan->language, -1);
                if (f) {
-                       res = chan->pvt->send_image(chan, f);
+                       res = chan->tech->send_image(chan, f);
                        ast_frfree(f);
                }
        }
@@ -175,14 +188,14 @@ int ast_send_image(struct ast_channel *chan, char *filename)
 static int show_image_formats(int fd, int argc, char *argv[])
 {
 #define FORMAT "%10s %10s %50s %10s\n"
-#define FORMAT2 "%10s %10s %50s %10d\n"
+#define FORMAT2 "%10s %10s %50s %10s\n"
        struct ast_imager *i;
        if (argc != 3)
                return RESULT_SHOWUSAGE;
        ast_cli(fd, FORMAT, "Name", "Extensions", "Description", "Format");
        i = list;
        while(i) {
-               ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, i->format);
+               ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, ast_getformatname(i->format));
                i = i->next;
        };
        return RESULT_SUCCESS;