Terry found this problem with running the expr2 parser on OSX. Make the #defines...
[asterisk/asterisk.git] / main / image.c
index df6b194..7096311 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <signal.h>
-#include <errno.h>
-#include <unistd.h>
 
+#include "asterisk/paths.h"    /* use ast_config_AST_DATA_DIR */
 #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"
@@ -51,27 +45,20 @@ static AST_RWLIST_HEAD_STATIC(imagers, ast_imager);
 
 int ast_image_register(struct ast_imager *img)
 {
-       ast_verb(2, "Registered format '%s' (%s)\n", img->name, img->desc);
        AST_RWLIST_WRLOCK(&imagers);
        AST_RWLIST_INSERT_HEAD(&imagers, img, list);
        AST_RWLIST_UNLOCK(&imagers);
+       ast_verb(2, "Registered format '%s' (%s)\n", img->name, img->desc);
        return 0;
 }
 
 void ast_image_unregister(struct ast_imager *img)
 {
-       struct ast_imager *i;
-       
        AST_RWLIST_WRLOCK(&imagers);
-       AST_RWLIST_TRAVERSE_SAFE_BEGIN(&imagers, i, list) {     
-               if (i == img) {
-                       AST_RWLIST_REMOVE_CURRENT(&imagers, list);
-                       break;
-               }
-       }
-       AST_RWLIST_TRAVERSE_SAFE_END
+       img = AST_RWLIST_REMOVE(&imagers, img, list);
        AST_RWLIST_UNLOCK(&imagers);
-       if (i)
+
+       if (img)
                ast_verb(2, "Unregistered format '%s' (%s)\n", img->name, img->desc);
 }
 
@@ -211,11 +198,11 @@ static char *handle_core_show_image_formats(struct ast_cli_entry *e, int cmd, st
 }
 
 struct ast_cli_entry cli_image[] = {
-       AST_CLI(handle_core_show_image_formats, "Displays image formats")
+       AST_CLI_DEFINE(handle_core_show_image_formats, "Displays image formats")
 };
 
 int ast_image_init(void)
 {
-       ast_cli_register_multiple(cli_image, sizeof(cli_image) / sizeof(struct ast_cli_entry));
+       ast_cli_register_multiple(cli_image, ARRAY_LEN(cli_image));
        return 0;
 }