Просмотр исходного кода

Add mg_ or MG_ prefix to all symbols in civetweb.h

Some symbols in civetweb.h are missing a mg_ or MG_ prefix.
Add these symbols with the new prefix now, so the symbols without prefix
can be phased out. See #522
bel2125 7 лет назад
Родитель
Сommit
a01b3cdd06
5 измененных файлов с 53 добавлено и 10 удалено
  1. 1 1
      docs/APIReference.md
  2. 1 1
      docs/api/mg_client_cert.md
  3. 2 2
      docs/api/mg_request_info.md
  4. 47 3
      include/civetweb.h
  5. 2 3
      src/civetweb.c

+ 1 - 1
docs/APIReference.md

@@ -31,7 +31,7 @@ The content of both structures is not defined in the interface - they are only u
 
 ## Structures
 
-* [`struct client_cert;`](api/client_cert.md)
+* [`struct mg_client_cert;`](api/mg_client_cert.md)
 * [`struct mg_client_options;`](api/mg_client_options.md)
 * [`struct mg_callbacks;`](api/mg_callbacks.md)
 * [`struct mg_form_data_handler;`](api/mg_form_data_handler.md)

+ 1 - 1
docs/api/client_cert.md → docs/api/mg_client_cert.md

@@ -1,6 +1,6 @@
 # Civetweb API Reference
 
-### `struct client_cert;`
+### `struct mg_client_cert;`
 
 ### Fields
 

+ 2 - 2
docs/api/mg_request_info.md

@@ -22,7 +22,7 @@
 |**`conn_data`**|`void *`| A pointer to connection specific user data |
 |**`num_headers`**|`int`| The number of HTTP request headers sent by the client (see http_headers) |
 |**`http_headers`**|`struct mg_header[64]`| Array of structures with the HTTP request headers sent by the client. For the number of filled header fields, ee num_headers. |
-|**`client_cert`**|`struct client_cert *`| Pointer to the client certificate information, when available. This field is only filled for https connections using client certificates. |
+|**`client_cert`**|`struct mg_client_cert *`| Pointer to the client certificate information, when available. This field is only filled for https connections using client certificates. |
 
 ### Description
 
@@ -30,6 +30,6 @@ The `mg_request_info` structure contains the client information of an existing c
 
 ### See Also
 
-* [`struct client_cert;`](client_cert.md)
+* [`struct mg_client_cert;`](mg_client_cert.md)
 * [`struct mg_header;`](mg_header.md)
 * [`mg_get_request_info();`](mg_get_request_info.md)

+ 47 - 3
include/civetweb.h

@@ -118,7 +118,7 @@ struct mg_request_info {
 	struct mg_header
 	    http_headers[MG_MAX_HEADERS]; /* Allocate maximum headers */
 
-	struct client_cert *client_cert; /* Client certificate information */
+	struct mg_client_cert *client_cert; /* Client certificate information */
 
 	const char *acceptedWebSocketSubprotocol; /* websocket subprotocol,
 	                                           * accepted during handshake */
@@ -142,6 +142,15 @@ struct mg_response_info {
 
 
 /* Client certificate information (part of mg_request_info) */
+/* New nomenclature. */
+struct mg_client_cert {
+	const char *subject;
+	const char *issuer;
+	const char *serial;
+	const char *finger;
+};
+
+/* Old nomenclature. */
 struct client_cert {
 	const char *subject;
 	const char *issuer;
@@ -559,7 +568,7 @@ struct mg_option {
 	const char *default_value;
 };
 
-
+/* Old nomenclature */
 enum {
 	CONFIG_TYPE_UNKNOWN = 0x0,
 	CONFIG_TYPE_NUMBER = 0x1,
@@ -572,6 +581,18 @@ enum {
 	CONFIG_TYPE_STRING_MULTILINE = 0x8
 };
 
+/* New nomenclature */
+enum {
+	MG_CONFIG_TYPE_UNKNOWN = 0x0,
+	MG_CONFIG_TYPE_NUMBER = 0x1,
+	MG_CONFIG_TYPE_STRING = 0x2,
+	MG_CONFIG_TYPE_FILE = 0x3,
+	MG_CONFIG_TYPE_DIRECTORY = 0x4,
+	MG_CONFIG_TYPE_BOOLEAN = 0x5,
+	MG_CONFIG_TYPE_EXT_PATTERN = 0x6,
+	MG_CONFIG_TYPE_STRING_LIST = 0x7,
+	MG_CONFIG_TYPE_STRING_MULTILINE = 0x8
+};
 
 /* Return array of struct mg_option, representing all valid configuration
    options of civetweb.c.
@@ -717,6 +738,7 @@ CIVETWEB_API void mg_unlock_context(struct mg_context *ctx);
 
 
 /* Opcodes, from http://tools.ietf.org/html/rfc6455 */
+/* Old nomenclature */
 enum {
 	WEBSOCKET_OPCODE_CONTINUATION = 0x0,
 	WEBSOCKET_OPCODE_TEXT = 0x1,
@@ -726,6 +748,15 @@ enum {
 	WEBSOCKET_OPCODE_PONG = 0xa
 };
 
+/* New nomenclature */
+enum {
+	MG_WEBSOCKET_OPCODE_CONTINUATION = 0x0,
+	MG_WEBSOCKET_OPCODE_TEXT = 0x1,
+	MG_WEBSOCKET_OPCODE_BINARY = 0x2,
+	MG_WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8,
+	MG_WEBSOCKET_OPCODE_PING = 0x9,
+	MG_WEBSOCKET_OPCODE_PONG = 0xa
+};
 
 /* Macros for enabling compiler-specific checks for printf-like arguments. */
 #undef PRINTF_FORMAT_STRING
@@ -1052,6 +1083,7 @@ struct mg_form_data_handler {
 
 /* Return values definition for the "field_found" callback in
  * mg_form_data_handler. */
+/* Old nomenclature */
 enum {
 	/* Skip this field (neither get nor store it). Continue with the
      * next field. */
@@ -1064,6 +1096,18 @@ enum {
 	FORM_FIELD_STORAGE_ABORT = 0x10
 };
 
+/* New nomenclature */
+enum {
+	/* Skip this field (neither get nor store it). Continue with the
+     * next field. */
+	MG_FORM_FIELD_STORAGE_SKIP = 0x0,
+	/* Get the field value. */
+	MG_FORM_FIELD_STORAGE_GET = 0x1,
+	/* Store the field value into a file. */
+	MG_FORM_FIELD_STORAGE_STORE = 0x2,
+	/* Stop parsing this request. Skip the remaining fields. */
+	MG_FORM_FIELD_STORAGE_ABORT = 0x10
+};
 
 /* Process form data.
  * Returns the number of fields handled, or < 0 in case of an error.
@@ -1207,7 +1251,7 @@ mg_connect_client_secure(const struct mg_client_options *client_options,
 
 
 enum { TIMEOUT_INFINITE = -1 };
-
+enum { MG_TIMEOUT_INFINITE = -1 };
 
 /* Wait for a response from the server
    Parameters:

+ 2 - 3
src/civetweb.c

@@ -13905,9 +13905,8 @@ ssl_get_client_cert_info(struct mg_connection *conn)
 			*str_finger = 0;
 		}
 
-		conn->request_info.client_cert =
-		    (struct client_cert *)mg_malloc_ctx(sizeof(struct client_cert),
-		                                        conn->ctx);
+		conn->request_info.client_cert = (struct mg_client_cert *)
+		    mg_malloc_ctx(sizeof(struct mg_client_cert), conn->ctx);
 		if (conn->request_info.client_cert) {
 			conn->request_info.client_cert->subject = mg_strdup(str_subject);
 			conn->request_info.client_cert->issuer = mg_strdup(str_issuer);