aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-08-06 23:33:20 +0200
committerJohannes Berg <johannes@sipsolutions.net>2009-08-06 23:33:20 +0200
commitde81095186abe74288c39dda932ccb71866ee847 (patch)
tree7b97c419ebb47e8acff8888e0fca8b47e70e86c5
parent91d5b8ddc7ca094f0821ecd4aaf85570d33a6f24 (diff)
downloaddovecot-antispam-de81095186abe74288c39dda932ccb71866ee847.tar.gz
dovecot-antispam-de81095186abe74288c39dda932ccb71866ee847.tar.xz
dovecot-antispam-de81095186abe74288c39dda932ccb71866ee847.zip
identify patchlevel in version macros
-rw-r--r--antispam-plugin.h6
-rw-r--r--dovecot-version.c22
2 files changed, 21 insertions, 7 deletions
diff --git a/antispam-plugin.h b/antispam-plugin.h
index 5c56b42..38a3be6 100644
--- a/antispam-plugin.h
+++ b/antispam-plugin.h
@@ -85,7 +85,7 @@ extern bool need_folder_hook;
* Dovecot version compat code
*/
-#if DOVECOT_VERSION_CODE(1, 1) == DOVECOT_VERSION || DOVECOT_VERSION_CODE(1, 2) == DOVECOT_VERSION
+#if DOVECOT_VERSION_CODE(1, 1, 0) == DOVECOT_VERSION || DOVECOT_VERSION_CODE(1, 2, 0) == DOVECOT_VERSION
#define __attr_unused__ ATTR_UNUSED
#define ME(err) MAIL_ERROR_ ##err,
#define PLUGIN_ID uint32_t PLUGIN_FUNCTION(id) = 0
@@ -114,7 +114,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
return o_stream_create_fd(fd, 0, TRUE);
}
-#if DOVECOT_VERSION_CODE(1, 2) == DOVECOT_VERSION
+#if DOVECOT_VERSION_CODE(1, 2, 0) == DOVECOT_VERSION
static inline struct dict *
string_dict_init(const char *uri, const char *username)
{
@@ -132,7 +132,7 @@ string_dict_init(const char *uri, const char *username)
return dict_init(uri, DICT_DATA_TYPE_STRING, username);
}
#endif
-#elif DOVECOT_VERSION_CODE(1, 0) == DOVECOT_VERSION
+#elif DOVECOT_VERSION_CODE(1, 0, 0) == DOVECOT_VERSION
#define ME(err)
#define PLUGIN_ID
#define str_array_length(x) strarray_length(x)
diff --git a/dovecot-version.c b/dovecot-version.c
index fbb7a88..fbd1f89 100644
--- a/dovecot-version.c
+++ b/dovecot-version.c
@@ -6,7 +6,7 @@
int main(int argc, char **argv)
{
char *v = PACKAGE_STRING, *e;
- int maj = 0, min = 0;
+ int maj = 0, min = 0, patch = 0;
if (strncmp(v, "dovecot ", 8) && strncmp(v, "Dovecot ", 8))
return 1;
@@ -24,11 +24,25 @@ int main(int argc, char **argv)
if (v == e)
return 1;
+ /* not end of string yet? */
+ if (*e) {
+ v = e + 1;
+
+ patch = strtol(v, &e, 10);
+ if (v == e)
+ return 1;
+ }
+
printf("/* Auto-generated file, do not edit */\n\n");
- printf("#define DOVECOT_VERSION_CODE(maj, min) ((maj)<<8 | (min))\n\n");
+ printf("#define DOVECOT_VERSION_CODE(maj, min, patch) "
+ "((maj)<<16 | ((min)<<8) | (patch))\n\n");
- printf("#define DOVECOT_VERSION 0x%.2x%.2x\n", maj, min);
- printf("#define ANTISPAM_STORAGE \"antispam-storage-%d.%d.c\"\n", maj, min);
+ printf("#define DOVECOT_VERSION "
+ "0x%.2x%.2x%.2x\n", maj, min, 0);
+ printf("#define DOVECOT_VPATCH "
+ "0x%.2x%.2x%.2x\n", maj, min, patch);
+ printf("#define ANTISPAM_STORAGE "
+ "\"antispam-storage-%d.%d.c\"\n", maj, min);
return 0;
}