diff mbox series

webserver: set type for "api" to int

Message ID 1520767245-21091-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series webserver: set type for "api" to int | expand

Commit Message

Stefano Babic March 11, 2018, 11:20 a.m. UTC
api can be just set to 1 or 2. Use an integer instead of
a string to define it in configuration file.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 mongoose/mongoose_interface.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 87f556f..65e7a08 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -33,7 +33,7 @@ 
 #define MG_ROOT "."
 
 enum MONGOOSE_API_VERSION {
-	MONGOOSE_API_V1,
+	MONGOOSE_API_V1 = 1,
 	MONGOOSE_API_V2
 };
 
@@ -471,12 +471,18 @@  static int mongoose_settings(void *elem, void  __attribute__ ((__unused__)) *dat
 		opts->ssl_key = strdup(tmp);
 	}
 #endif
-	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "api", tmp);
-	if (strlen(tmp)) {
-		opts->api_version = (!strcmp(tmp, "1")) ?
-					MONGOOSE_API_V1 :
-					MONGOOSE_API_V2;
+	/*
+	 * Get API Version
+	 */
+	get_field(LIBCFG_PARSER, elem, "api", &opts->api_version);
+	switch(opts->api_version) {
+	case MONGOOSE_API_V1:
+	case MONGOOSE_API_V2:
+		break;
+	default:
+		opts->api_version = MONGOOSE_API_V2;
 	}
+
 	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "global-auth-file", tmp);
 	if (strlen(tmp)) {
 		opts->global_auth_file = strdup(tmp);