changeset 10554:443927a546e2 HEAD

config: Added support for "octal integer", which is just printed as octal.
author Timo Sirainen <tss@iki.fi>
date Tue, 19 Jan 2010 14:39:24 +0200
parents b8966b8133f2
children 4d703a15d6b8
files src/config/config-request.c src/lib-settings/settings-parser.c src/lib-settings/settings-parser.h
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/config/config-request.c	Mon Jan 18 10:55:55 2010 +0200
+++ b/src/config/config-request.c	Tue Jan 19 14:39:24 2010 +0200
@@ -137,10 +137,19 @@
 			break;
 		}
 		case SET_UINT:
+		case SET_UINT_OCT:
 		case SET_TIME: {
 			const unsigned int *val = value, *dval = default_value;
-			if (dump_default || dval == NULL || *val != *dval)
-				str_printfa(ctx->value, "%u", *val);
+			if (dump_default || dval == NULL || *val != *dval) {
+				switch (def->type) {
+				case SET_UINT_OCT:
+					str_printfa(ctx->value, "0%o", *val);
+					break;
+				default:
+					str_printfa(ctx->value, "%u", *val);
+					break;
+				}
+			}
 			break;
 		}
 		case SET_STR_VARS: {
--- a/src/lib-settings/settings-parser.c	Mon Jan 18 10:55:55 2010 +0200
+++ b/src/lib-settings/settings-parser.c	Tue Jan 19 14:39:24 2010 +0200
@@ -551,6 +551,7 @@
 			return -1;
 		break;
 	case SET_UINT:
+	case SET_UINT_OCT:
 		if (get_uint(ctx, value, (unsigned int *)ptr) < 0)
 			return -1;
 		break;
@@ -1023,6 +1024,7 @@
 		switch (def->type) {
 		case SET_BOOL:
 		case SET_UINT:
+		case SET_UINT_OCT:
 		case SET_TIME:
 		case SET_SIZE:
 		case SET_STR:
@@ -1095,6 +1097,7 @@
 		switch (def->type) {
 		case SET_BOOL:
 		case SET_UINT:
+		case SET_UINT_OCT:
 		case SET_TIME:
 		case SET_SIZE:
 		case SET_STR:
@@ -1166,6 +1169,7 @@
 		break;
 	}
 	case SET_UINT:
+	case SET_UINT_OCT:
 	case SET_TIME: {
 		const unsigned int *src_uint = src;
 		unsigned int *dest_uint = dest;
@@ -1276,6 +1280,7 @@
 		switch (def->type) {
 		case SET_BOOL:
 		case SET_UINT:
+		case SET_UINT_OCT:
 		case SET_TIME:
 		case SET_SIZE:
 		case SET_STR_VARS:
--- a/src/lib-settings/settings-parser.h	Mon Jan 18 10:55:55 2010 +0200
+++ b/src/lib-settings/settings-parser.h	Tue Jan 19 14:39:24 2010 +0200
@@ -19,6 +19,7 @@
 enum setting_type {
 	SET_BOOL,
 	SET_UINT,
+	SET_UINT_OCT,
 	SET_TIME,
 	SET_SIZE,
 	SET_STR,