|  | @@ -152,11 +152,7 @@ int clock_gettime(int clk_id, struct timespec* t) {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #if defined(_WIN32) && !defined(__SYMBIAN32__) /* Windows specific */
 |  |  #if defined(_WIN32) && !defined(__SYMBIAN32__) /* Windows specific */
 | 
											
												
													
														|  |  #include <windows.h>
 |  |  #include <windows.h>
 | 
											
												
													
														|  | -<<<<<<< HEAD
 |  | 
 | 
											
												
													
														|  |  #include <winsock2.h>    /* DTL add for SO_EXCLUSIVE */
 |  |  #include <winsock2.h>    /* DTL add for SO_EXCLUSIVE */
 | 
											
												
													
														|  | -=======
 |  | 
 | 
											
												
													
														|  | -#include <winsock2.h>    /* DTL add for SO_EXCLUSIVE */
 |  | 
 | 
											
												
													
														|  | ->>>>>>> 8bf5a3e... inline under Solaris
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  typedef const char * SOCK_OPT_TYPE;
 |  |  typedef const char * SOCK_OPT_TYPE;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1103,16 +1099,20 @@ static int is_file_in_memory(struct mg_connection *conn, const char *path,
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  static int is_file_opened(const struct file *filep)
 |  |  static int is_file_opened(const struct file *filep)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    if (!filep)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!filep) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      return filep->membuf != NULL || filep->fp != NULL;
 |  |      return filep->membuf != NULL || filep->fp != NULL;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  static int mg_fopen(struct mg_connection *conn, const char *path,
 |  |  static int mg_fopen(struct mg_connection *conn, const char *path,
 | 
											
												
													
														|  |                      const char *mode, struct file *filep)
 |  |                      const char *mode, struct file *filep)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    if (!filep)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!filep) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      if (!is_file_in_memory(conn, path, filep)) {
 |  |      if (!is_file_in_memory(conn, path, filep)) {
 | 
											
												
													
														|  |  #ifdef _WIN32
 |  |  #ifdef _WIN32
 | 
											
												
													
														|  |          wchar_t wbuf[PATH_MAX], wmode[20];
 |  |          wchar_t wbuf[PATH_MAX], wmode[20];
 | 
											
										
											
												
													
														|  | @@ -1310,8 +1310,9 @@ void * mg_get_user_connection_data(const struct mg_connection *conn)
 | 
											
												
													
														|  |  size_t mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int* ssl)
 |  |  size_t mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int* ssl)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      size_t i;
 |  |      size_t i;
 | 
											
												
													
														|  | -    if (!ctx)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!ctx) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |      for (i = 0; i < size && i < (size_t)ctx->num_listening_sockets; i++)
 |  |      for (i = 0; i < size && i < (size_t)ctx->num_listening_sockets; i++)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          ssl[i] = ctx->listening_sockets[i].is_ssl;
 |  |          ssl[i] = ctx->listening_sockets[i].is_ssl;
 | 
											
										
											
												
													
														|  | @@ -1432,8 +1433,9 @@ const char *mg_version(void)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const struct mg_request_info *mg_get_request_info(const struct mg_connection *conn)
 |  |  const struct mg_request_info *mg_get_request_info(const struct mg_connection *conn)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    if (!conn)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!conn) {
 | 
											
												
													
														|  |          return NULL;
 |  |          return NULL;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |      return &conn->request_info;
 |  |      return &conn->request_info;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1500,18 +1502,23 @@ static const char *get_header(const struct mg_request_info *ri,
 | 
											
												
													
														|  |                                const char *name)
 |  |                                const char *name)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      int i;
 |  |      int i;
 | 
											
												
													
														|  | -    if (ri)
 |  | 
 | 
											
												
													
														|  | -    for (i = 0; i < ri->num_headers; i++)
 |  | 
 | 
											
												
													
														|  | -        if (!mg_strcasecmp(name, ri->http_headers[i].name))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ri) {
 | 
											
												
													
														|  | 
 |  | +    for (i = 0; i < ri->num_headers; i++) {
 | 
											
												
													
														|  | 
 |  | +        if (!mg_strcasecmp(name, ri->http_headers[i].name)) {
 | 
											
												
													
														|  |              return ri->http_headers[i].value;
 |  |              return ri->http_headers[i].value;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      return NULL;
 |  |      return NULL;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const char *mg_get_header(const struct mg_connection *conn, const char *name)
 |  |  const char *mg_get_header(const struct mg_connection *conn, const char *name)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    if (!conn)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!conn) {
 | 
											
												
													
														|  |          return NULL;
 |  |          return NULL;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      return get_header(&conn->request_info, name);
 |  |      return get_header(&conn->request_info, name);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1618,8 +1625,10 @@ static int should_keep_alive(const struct mg_connection *conn)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  static int should_decode_url(const struct mg_connection *conn)
 |  |  static int should_decode_url(const struct mg_connection *conn)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    if(!conn || !conn->ctx)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if(!conn || !conn->ctx) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      return (mg_strcasecmp(conn->ctx->config[DECODE_URL], "yes") == 0);
 |  |      return (mg_strcasecmp(conn->ctx->config[DECODE_URL], "yes") == 0);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1762,8 +1771,9 @@ static void send_http_error(struct mg_connection *conn, int status, const char *
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      const char *status_text = mg_get_response_code_text(status, conn);
 |  |      const char *status_text = mg_get_response_code_text(status, conn);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (conn == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (conn == NULL) {
 | 
											
												
													
														|  |          return;
 |  |          return;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      conn->status_code = status;
 |  |      conn->status_code = status;
 | 
											
												
													
														|  |      if (conn->in_error_handler ||
 |  |      if (conn->in_error_handler ||
 | 
											
										
											
												
													
														|  | @@ -2452,8 +2462,9 @@ static int mg_stat(struct mg_connection *conn, const char *path,
 | 
											
												
													
														|  |                     struct file *filep)
 |  |                     struct file *filep)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      struct stat st;
 |  |      struct stat st;
 | 
											
												
													
														|  | -    if (!filep)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (!filep) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |      if (!is_file_in_memory(conn, path, filep) && !stat(path, &st)) {
 |  |      if (!is_file_in_memory(conn, path, filep) && !stat(path, &st)) {
 | 
											
												
													
														|  |          filep->size = st.st_size;
 |  |          filep->size = st.st_size;
 | 
											
												
													
														|  |          filep->modification_time = st.st_mtime;
 |  |          filep->modification_time = st.st_mtime;
 | 
											
										
											
												
													
														|  | @@ -2539,8 +2550,9 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      (void) envblk;
 |  |      (void) envblk;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if(conn == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if(conn == NULL) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if ((pid = fork()) == -1) {
 |  |      if ((pid = fork()) == -1) {
 | 
											
												
													
														|  |          /* Parent */
 |  |          /* Parent */
 | 
											
										
											
												
													
														|  | @@ -2705,8 +2717,9 @@ static void discard_unread_request_data(struct mg_connection *conn)
 | 
											
												
													
														|  |      char buf[MG_BUF_LEN];
 |  |      char buf[MG_BUF_LEN];
 | 
											
												
													
														|  |      int to_read, nread;
 |  |      int to_read, nread;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (conn == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (conn == NULL) {
 | 
											
												
													
														|  |          return;
 |  |          return;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      to_read = sizeof(buf);
 |  |      to_read = sizeof(buf);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2790,8 +2803,9 @@ int mg_read_inner(struct mg_connection *conn, void *buf, size_t len)
 | 
											
												
													
														|  |  static char mg_getc(struct mg_connection *conn)
 |  |  static char mg_getc(struct mg_connection *conn)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      char c;
 |  |      char c;
 | 
											
												
													
														|  | -    if (conn == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (conn == NULL) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |      conn->content_len++;
 |  |      conn->content_len++;
 | 
											
												
													
														|  |      if (mg_read_inner(conn, &c, 1) <= 0)
 |  |      if (mg_read_inner(conn, &c, 1) <= 0)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
										
											
												
													
														|  | @@ -2877,8 +2891,9 @@ int mg_write(struct mg_connection *conn, const void *buf, size_t len)
 | 
											
												
													
														|  |      time_t now;
 |  |      time_t now;
 | 
											
												
													
														|  |      int64_t n, total, allowed;
 |  |      int64_t n, total, allowed;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (conn == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (conn == NULL) {
 | 
											
												
													
														|  |          return 0;
 |  |          return 0;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if (conn->throttle > 0) {
 |  |      if (conn->throttle > 0) {
 | 
											
												
													
														|  |          if ((now = time(NULL)) != conn->last_throttle_time) {
 |  |          if ((now = time(NULL)) != conn->last_throttle_time) {
 | 
											
										
											
												
													
														|  | @@ -3063,8 +3078,9 @@ int mg_get_var2(const char *data, size_t data_len, const char *name,
 | 
											
												
													
														|  |                      s = e;
 |  |                      s = e;
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  /* assert(s >= p); */
 |  |                  /* assert(s >= p); */
 | 
											
												
													
														|  | -                if (s < p)
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if (s < p) {
 | 
											
												
													
														|  |                      return -3;
 |  |                      return -3;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  /* Decode variable into destination buffer */
 |  |                  /* Decode variable into destination buffer */
 | 
											
												
													
														|  |                  len = mg_url_decode(p, (int)(s - p), dst, (int)dst_len, 1);
 |  |                  len = mg_url_decode(p, (int)(s - p), dst, (int)dst_len, 1);
 | 
											
										
											
												
													
														|  | @@ -3567,8 +3583,9 @@ static void get_mime_type(struct mg_context *ctx, const char *path,
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      path_len = strlen(path);
 |  |      path_len = strlen(path);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    if (ctx == NULL || vec == NULL)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (ctx == NULL || vec == NULL) {
 | 
											
												
													
														|  |          return;
 |  |          return;
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /* Scan user-defined mime types first, in case user wants to
 |  |      /* Scan user-defined mime types first, in case user wants to
 | 
											
												
													
														|  |         override default mime types. */
 |  |         override default mime types. */
 |