Browse Source

Support multiple domains (Step 11/?)

bel2125 7 năm trước cách đây
mục cha
commit
9ed23417f3
2 tập tin đã thay đổi với 15 bổ sung2 xóa
  1. 8 1
      include/civetweb.h
  2. 7 1
      src/civetweb.c

+ 8 - 1
include/civetweb.h

@@ -418,7 +418,14 @@ CIVETWEB_API void mg_stop(struct mg_context *);
  *            specify CivetWeb configuration parameters.
  *
  * Return:
- *   to be defined
+ *   < 0 in case of an error
+ *    -1 for a parameter error
+ *    -2 invalid options
+ *    -3 initializing SSL failed
+ *    -4 mandatory domain option missing
+ *    -5 duplicate domain
+ *    -6 out of memory
+ *   > 0 index / handle of a new domain
  */
 CIVETWEB_API int mg_start_domain(struct mg_context *ctx,
                                  const char **configuration_options);

+ 7 - 1
src/civetweb.c

@@ -17566,6 +17566,7 @@ mg_start_domain(struct mg_context *ctx, const char **options)
 	/* Add element to linked list. */
 	mg_lock_context(ctx);
 
+	idx = 0;
 	dom = &(ctx->dd);
 	for (;;) {
 		if (!strcasecmp(new_dom->config[AUTHENTICATION_DOMAIN],
@@ -17577,6 +17578,10 @@ mg_start_domain(struct mg_context *ctx, const char **options)
 			mg_free(new_dom);
 			return -5;
 		}
+
+		/* Count number of domains */
+		idx++;
+
 		if (dom->next == NULL) {
 			dom->next = new_dom;
 			break;
@@ -17586,7 +17591,8 @@ mg_start_domain(struct mg_context *ctx, const char **options)
 
 	mg_unlock_context(ctx);
 
-	return 0;
+	/* Return domain number */
+	return idx;
 }
 #endif