Commit f749eeb7 authored by Sergey Lyubka's avatar Sergey Lyubka

Style changes: using C++ comments everywhere

parent 60408dea
...@@ -657,18 +657,18 @@ static char *skip_quoted(char **buf, const char *delimiters, const char *whitesp ...@@ -657,18 +657,18 @@ static char *skip_quoted(char **buf, const char *delimiters, const char *whitesp
begin_word = *buf; begin_word = *buf;
end_word = begin_word + strcspn(begin_word, delimiters); end_word = begin_word + strcspn(begin_word, delimiters);
/* Check for quotechar */ // Check for quotechar
if (end_word > begin_word) { if (end_word > begin_word) {
p = end_word - 1; p = end_word - 1;
while (*p == quotechar) { while (*p == quotechar) {
/* If there is anything beyond end_word, copy it */ // If there is anything beyond end_word, copy it
if (*end_word == '\0') { if (*end_word == '\0') {
*p = '\0'; *p = '\0';
break; break;
} else { } else {
size_t end_off = strcspn(end_word + 1, delimiters); size_t end_off = strcspn(end_word + 1, delimiters);
memmove (p, end_word, end_off + 1); memmove (p, end_word, end_off + 1);
p += end_off; /* p must correspond to end_word - 1 */ p += end_off; // p must correspond to end_word - 1
end_word += end_off + 1; end_word += end_off + 1;
} }
} }
...@@ -724,29 +724,27 @@ const char *mg_get_header(const struct mg_connection *conn, const char *name) { ...@@ -724,29 +724,27 @@ const char *mg_get_header(const struct mg_connection *conn, const char *name) {
static const char *next_option(const char *list, struct vec *val, static const char *next_option(const char *list, struct vec *val,
struct vec *eq_val) { struct vec *eq_val) {
if (list == NULL || *list == '\0') { if (list == NULL || *list == '\0') {
/* End of the list */ // End of the list
list = NULL; list = NULL;
} else { } else {
val->ptr = list; val->ptr = list;
if ((list = strchr(val->ptr, ',')) != NULL) { if ((list = strchr(val->ptr, ',')) != NULL) {
/* Comma found. Store length and shift the list ptr */ // Comma found. Store length and shift the list ptr
val->len = list - val->ptr; val->len = list - val->ptr;
list++; list++;
} else { } else {
/* This value is the last one */ // This value is the last one
list = val->ptr + strlen(val->ptr); list = val->ptr + strlen(val->ptr);
val->len = list - val->ptr; val->len = list - val->ptr;
} }
if (eq_val != NULL) { if (eq_val != NULL) {
/* // Value has form "x=y", adjust pointers and lengths
* Value has form "x=y", adjust pointers and lengths // so that val points to "x", and eq_val points to "y".
* so that val points to "x", and eq_val points to "y".
*/
eq_val->len = 0; eq_val->len = 0;
eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len); eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
if (eq_val->ptr != NULL) { if (eq_val->ptr != NULL) {
eq_val->ptr++; /* Skip over '=' character */ eq_val->ptr++; // Skip over '=' character
eq_val->len = val->ptr + val->len - eq_val->ptr; eq_val->len = val->ptr + val->len - eq_val->ptr;
val->len = (eq_val->ptr - val->ptr) - 1; val->len = (eq_val->ptr - val->ptr) - 1;
} }
...@@ -797,7 +795,7 @@ static void send_http_error(struct mg_connection *conn, int status, ...@@ -797,7 +795,7 @@ static void send_http_error(struct mg_connection *conn, int status,
buf[0] = '\0'; buf[0] = '\0';
len = 0; len = 0;
/* Errors 1xx, 204 and 304 MUST NOT send a body */ // Errors 1xx, 204 and 304 MUST NOT send a body
if (status > 199 && status != 204 && status != 304) { if (status > 199 && status != 204 && status != 304) {
len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason); len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason);
cry(conn, "%s", buf); cry(conn, "%s", buf);
...@@ -1219,7 +1217,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog, ...@@ -1219,7 +1217,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
return (pid_t) pi.hProcess; return (pid_t) pi.hProcess;
} }
#endif /* !NO_CGI */ #endif // !NO_CGI
static int set_non_blocking_mode(SOCKET sock) { static int set_non_blocking_mode(SOCKET sock) {
unsigned long on = 1; unsigned long on = 1;
...@@ -1332,7 +1330,7 @@ static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf, ...@@ -1332,7 +1330,7 @@ static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf,
sent = 0; sent = 0;
while (sent < len) { while (sent < len) {
/* How many bytes we send in this iteration */ // How many bytes we send in this iteration
k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent); k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent);
if (ssl != NULL) { if (ssl != NULL) {
...@@ -1468,7 +1466,7 @@ static size_t url_decode(const char *src, size_t src_len, char *dst, ...@@ -1468,7 +1466,7 @@ static size_t url_decode(const char *src, size_t src_len, char *dst,
} }
} }
dst[j] = '\0'; /* Null-terminate the destination */ dst[j] = '\0'; // Null-terminate the destination
return j; return j;
} }
...@@ -1582,7 +1580,7 @@ static void convert_uri_to_file_name(struct mg_connection *conn, ...@@ -1582,7 +1580,7 @@ static void convert_uri_to_file_name(struct mg_connection *conn,
#if defined(_WIN32) && !defined(__SYMBIAN32__) #if defined(_WIN32) && !defined(__SYMBIAN32__)
change_slashes_to_backslashes(buf); change_slashes_to_backslashes(buf);
#endif /* _WIN32 */ #endif // _WIN32
DEBUG_TRACE(("[%s] -> [%s], [%.*s]", uri, buf, (int) vec.len, vec.ptr)); DEBUG_TRACE(("[%s] -> [%s], [%.*s]", uri, buf, (int) vec.len, vec.ptr));
} }
...@@ -2122,7 +2120,7 @@ static int parse_auth_header(struct mg_connection *conn, char *buf, ...@@ -2122,7 +2120,7 @@ static int parse_auth_header(struct mg_connection *conn, char *buf,
s++; s++;
} }
name = skip_quoted(&s, "=", " ", 0); name = skip_quoted(&s, "=", " ", 0);
/* Value is either quote-delimited, or ends at first comma or space. */ // Value is either quote-delimited, or ends at first comma or space.
if (s[0] == '\"') { if (s[0] == '\"') {
s++; s++;
value = skip_quoted(&s, "\"", " ", '\\'); value = skip_quoted(&s, "\"", " ", '\\');
...@@ -2654,7 +2652,7 @@ static int parse_http_request(char *buf, struct mg_request_info *ri) { ...@@ -2654,7 +2652,7 @@ static int parse_http_request(char *buf, struct mg_request_info *ri) {
if (is_valid_http_method(ri->request_method) && if (is_valid_http_method(ri->request_method) &&
strncmp(ri->http_version, "HTTP/", 5) == 0) { strncmp(ri->http_version, "HTTP/", 5) == 0) {
ri->http_version += 5; /* Skip "HTTP/" */ ri->http_version += 5; // Skip "HTTP/"
parse_http_headers(&buf, ri); parse_http_headers(&buf, ri);
status = 1; status = 1;
} }
...@@ -2903,7 +2901,7 @@ static void prepare_cgi_environment(struct mg_connection *conn, ...@@ -2903,7 +2901,7 @@ static void prepare_cgi_environment(struct mg_connection *conn,
#else #else
if ((s = getenv("LD_LIBRARY_PATH")) != NULL) if ((s = getenv("LD_LIBRARY_PATH")) != NULL)
addenv(blk, "LD_LIBRARY_PATH=%s", s); addenv(blk, "LD_LIBRARY_PATH=%s", s);
#endif /* _WIN32 */ #endif // _WIN32
if ((s = getenv("PERLLIB")) != NULL) if ((s = getenv("PERLLIB")) != NULL)
addenv(blk, "PERLLIB=%s", s); addenv(blk, "PERLLIB=%s", s);
...@@ -3685,7 +3683,7 @@ static int load_dll(struct mg_context *ctx, const char *dll_name, ...@@ -3685,7 +3683,7 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
// dlsym() on UNIX returns void *. ISO C forbids casts of data pointers to // dlsym() on UNIX returns void *. ISO C forbids casts of data pointers to
// function pointers. We need to use a union to make a cast. // function pointers. We need to use a union to make a cast.
u.p = dlsym(dll_handle, fp->name); u.p = dlsym(dll_handle, fp->name);
#endif /* _WIN32 */ #endif // _WIN32
if (u.fp == NULL) { if (u.fp == NULL) {
cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name); cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment