changeset 8728:da19acbae79e HEAD

imap: export imap_commands array containing all registered commands.
author Timo Sirainen <tss@iki.fi>
date Fri, 06 Feb 2009 13:38:26 -0500
parents d2c357625ef2
children b7ebdade6cbd
files src/imap/commands.c src/imap/commands.h
diffstat 2 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/commands.c	Fri Feb 06 13:10:06 2009 -0500
+++ b/src/imap/commands.c	Fri Feb 06 13:38:26 2009 -0500
@@ -56,7 +56,7 @@
 };
 #define IMAP_EXT_COMMANDS_COUNT N_ELEMENTS(imap_ext_commands)
 
-static ARRAY_DEFINE(commands, struct command);
+ARRAY_TYPE(command) imap_commands;
 static bool commands_unsorted;
 
 void command_register(const char *name, command_func_t *func,
@@ -68,7 +68,7 @@
 	cmd.name = name;
 	cmd.func = func;
 	cmd.flags = flags;
-	array_append(&commands, &cmd, 1);
+	array_append(&imap_commands, &cmd, 1);
 
 	commands_unsorted = TRUE;
 }
@@ -78,10 +78,10 @@
 	const struct command *cmd;
 	unsigned int i, count;
 
-	cmd = array_get(&commands, &count);
+	cmd = array_get(&imap_commands, &count);
 	for (i = 0; i < count; i++) {
 		if (strcasecmp(cmd[i].name, name) == 0) {
-			array_delete(&commands, i, 1);
+			array_delete(&imap_commands, i, 1);
 			return;
 		}
 	}
@@ -92,7 +92,7 @@
 void command_register_array(const struct command *cmdarr, unsigned int count)
 {
 	commands_unsorted = TRUE;
-	array_append(&commands, cmdarr, count);
+	array_append(&imap_commands, cmdarr, count);
 }
 
 void command_unregister_array(const struct command *cmdarr, unsigned int count)
@@ -122,7 +122,7 @@
 	void *base;
 	unsigned int count;
 
-	base = array_get_modifiable(&commands, &count);
+	base = array_get_modifiable(&imap_commands, &count);
 	if (commands_unsorted) {
 		qsort(base, count, sizeof(struct command), command_cmp);
                 commands_unsorted = FALSE;
@@ -134,7 +134,7 @@
 
 void commands_init(void)
 {
-	i_array_init(&commands, 64);
+	i_array_init(&imap_commands, 64);
 	commands_unsorted = FALSE;
 
         command_register_array(imap4rev1_commands, IMAP4REV1_COMMANDS_COUNT);
@@ -145,5 +145,5 @@
 {
         command_unregister_array(imap4rev1_commands, IMAP4REV1_COMMANDS_COUNT);
         command_unregister_array(imap_ext_commands, IMAP_EXT_COMMANDS_COUNT);
-	array_free(&commands);
+	array_free(&imap_commands);
 }
--- a/src/imap/commands.h	Fri Feb 06 13:10:06 2009 -0500
+++ b/src/imap/commands.h	Fri Feb 06 13:38:26 2009 -0500
@@ -29,6 +29,9 @@
 
 	enum command_flags flags;
 };
+ARRAY_DEFINE_TYPE(command, struct command);
+
+extern ARRAY_TYPE(command) imap_commands;
 
 /* Register command. Given name parameter must be permanently stored until
    command is unregistered. */