dovecot-2.2: lib-master: Added version_string_verify_full()

dovecot at dovecot.org dovecot at dovecot.org
Thu Mar 14 15:41:49 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/9a8eaf97559d
changeset: 16022:9a8eaf97559d
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 14 15:24:48 2013 +0200
description:
lib-master: Added version_string_verify_full()

diffstat:

 src/lib-master/master-service.c |  21 ++++++++++++++++++++-
 src/lib-master/master-service.h |   4 ++++
 2 files changed, 24 insertions(+), 1 deletions(-)

diffs (51 lines):

diff -r e5b5e2ce7578 -r 9a8eaf97559d src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Thu Mar 14 15:25:07 2013 +0200
+++ b/src/lib-master/master-service.c	Thu Mar 14 15:24:48 2013 +0200
@@ -1002,6 +1002,16 @@
 bool version_string_verify(const char *line, const char *service_name,
 			   unsigned major_version)
 {
+	unsigned int minor_version;
+
+	return version_string_verify_full(line, service_name,
+					  major_version, &minor_version);
+}
+
+bool version_string_verify_full(const char *line, const char *service_name,
+				unsigned major_version,
+				unsigned int *minor_version_r)
+{
 	unsigned int service_name_len = strlen(service_name);
 	bool ret;
 
@@ -1015,7 +1025,16 @@
 	line += service_name_len + 1;
 
 	T_BEGIN {
-		ret = str_uint_equals(t_strcut(line, '\t'), major_version);
+		const char *p = strchr(line, '\t');
+
+		if (p == NULL)
+			ret = FALSE;
+		else {
+			ret = str_uint_equals(t_strdup_until(line, p),
+					      major_version);
+			if (str_to_uint(p+1, minor_version_r) < 0)
+				ret = FALSE;
+		}
 	} T_END;
 	return ret;
 }
diff -r e5b5e2ce7578 -r 9a8eaf97559d src/lib-master/master-service.h
--- a/src/lib-master/master-service.h	Thu Mar 14 15:25:07 2013 +0200
+++ b/src/lib-master/master-service.h	Thu Mar 14 15:24:48 2013 +0200
@@ -155,5 +155,9 @@
    VERSION <tab> service_name <tab> major version <tab> minor version */
 bool version_string_verify(const char *line, const char *service_name,
 			   unsigned major_version);
+/* Same as version_string_verify(), but return the minor version. */
+bool version_string_verify_full(const char *line, const char *service_name,
+				unsigned major_version,
+				unsigned int *minor_version_r);
 
 #endif


More information about the dovecot-cvs mailing list