add the 'clean', 'clean-depend', and 'dist-clean' targets as .PHONY targets
[asterisk/asterisk.git] / image.c
diff --git a/image.c b/image.c
index 93a6993..ff67c03 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster@digium.com>
  *
  * \author Mark Spencer <markster@digium.com> 
  */
 
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
 
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include "asterisk/sched.h"
 #include "asterisk/options.h"
 #include "asterisk/channel.h"
@@ -94,22 +94,22 @@ static int file_exists(char *filename)
        return 0;
 }
 
-static void make_filename(char *buf, int len, char *filename, char *preflang, char *ext)
+static void make_filename(char *buf, int len, char *filename, const char *preflang, char *ext)
 {
        if (filename[0] == '/') {
-               if (preflang && strlen(preflang))
+               if (!ast_strlen_zero(preflang))
                        snprintf(buf, len, "%s-%s.%s", filename, preflang, ext);
                else
                        snprintf(buf, len, "%s.%s", filename, ext);
        } else {
-               if (preflang && strlen(preflang))
-                       snprintf(buf, len, "%s/%s/%s-%s.%s", ast_config_AST_VAR_DIR, "images", filename, preflang, ext);
+               if (!ast_strlen_zero(preflang))
+                       snprintf(buf, len, "%s/%s/%s-%s.%s", ast_config_AST_DATA_DIR, "images", filename, preflang, ext);
                else
-                       snprintf(buf, len, "%s/%s/%s.%s", ast_config_AST_VAR_DIR, "images", filename, ext);
+                       snprintf(buf, len, "%s/%s/%s.%s", ast_config_AST_DATA_DIR, "images", filename, ext);
        }
 }
 
-struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
+struct ast_frame *ast_read_image(char *filename, const char *preflang, int format)
 {
        struct ast_imager *i;
        char buf[256];
@@ -153,7 +153,7 @@ struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
                                lseek(fd, 0, SEEK_SET);
                                f = found->read_image(fd,len); 
                        } else
-                               ast_log(LOG_WARNING, "%s does not appear to be a %s file\n", buf, i->name);
+                               ast_log(LOG_WARNING, "%s does not appear to be a %s file\n", buf, found->name);
                        close(fd);
                } else
                        ast_log(LOG_WARNING, "Unable to open '%s': %s\n", buf, strerror(errno));
@@ -205,7 +205,6 @@ struct ast_cli_entry show_images =
 
 int ast_image_init(void)
 {
-       ast_cli_register(&show_images);
-       return 0;
+       return ast_cli_register(&show_images);
 }