Procházet zdrojové kódy

mg_get_ports to return number of elements of ports and ssl filled in

* Return the number of elements of the ports and ssl arrays passed in,
  so that the caller knows how many ports the server is listening on/
  how many elements of ports/ssl are valid.
Keith Kyzivat před 11 roky
rodič
revize
b91823e741
2 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 2 1
      include/civetweb.h
  2. 2 1
      src/civetweb.c

+ 2 - 1
include/civetweb.h

@@ -228,9 +228,10 @@ const char **mg_get_valid_option_names(void);
    size is the size of the ports int array and ssl int array to fill.
    size is the size of the ports int array and ssl int array to fill.
    It is the caller's responsibility to make sure ports and ssl each
    It is the caller's responsibility to make sure ports and ssl each
    contain at least size int elements worth of memory to write into.
    contain at least size int elements worth of memory to write into.
+   Return value is the number of ports and ssl information filled in.
    The value returned is read-only. Civetweb does not allow changing
    The value returned is read-only. Civetweb does not allow changing
    configuration at run time. */
    configuration at run time. */
-void 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);
 
 
 /* Add, edit or delete the entry in the passwords file.
 /* Add, edit or delete the entry in the passwords file.
 
 

+ 2 - 1
src/civetweb.c

@@ -707,7 +707,7 @@ const char *mg_get_option(const struct mg_context *ctx, const char *name)
     }
     }
 }
 }
 
 
-void 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;
     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++)
@@ -715,6 +715,7 @@ void mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int* ss
         ssl[i] = ctx->listening_sockets[i].is_ssl;
         ssl[i] = ctx->listening_sockets[i].is_ssl;
         ports[i] = ctx->listening_ports[i];
         ports[i] = ctx->listening_ports[i];
     }
     }
+    return i;
 }
 }
 
 
 static void sockaddr_to_string(char *buf, size_t len,
 static void sockaddr_to_string(char *buf, size_t len,