Commit d6cbf9f7 authored by NickCis's avatar NickCis

Fixing C coding style mistakes

parent c06abbc5
// Copyright (c) 2014 Cesanta Software // Copyright (c) 2014 Cesanta Software
// All rights reserved // All rights reserved
// //
// This example demostrates basic use of Mongoose embedded web server. // This example demostrates how to use array get variables using mg_get_n_var
// $Date: 2014-09-09 22:20:23 UTC $ // $Date: 2014-09-09 22:20:23 UTC $
#include <stdio.h> #include <stdio.h>
...@@ -15,8 +15,7 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) { ...@@ -15,8 +15,7 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
{ {
mg_printf_data(conn, "Hello! Requested URI is [%s] ", conn->uri); mg_printf_data(conn, "Hello! Requested URI is [%s] ", conn->uri);
char buffer[1024]; char buffer[1024];
int ret, int i, ret;
i;
for(i=0; (ret = mg_get_n_var(conn, "foo[]", buffer, 1024, i)) > 0; i++) for(i=0; (ret = mg_get_n_var(conn, "foo[]", buffer, 1024, i)) > 0; i++)
mg_printf_data(conn, "\nfoo[%d] = %s", i, buffer); mg_printf_data(conn, "\nfoo[%d] = %s", i, buffer);
......
...@@ -5001,7 +5001,7 @@ static int get_var(const char *data, size_t data_len, const char *name, ...@@ -5001,7 +5001,7 @@ static int get_var(const char *data, size_t data_len, const char *name,
char *dst, size_t dst_len, int n) { char *dst, size_t dst_len, int n) {
const char *p, *e, *s; const char *p, *e, *s;
size_t name_len; size_t name_len;
int len; int i, len;
if (dst == NULL || dst_len == 0) { if (dst == NULL || dst_len == 0) {
len = -2; len = -2;
...@@ -5009,12 +5009,12 @@ static int get_var(const char *data, size_t data_len, const char *name, ...@@ -5009,12 +5009,12 @@ static int get_var(const char *data, size_t data_len, const char *name,
len = -1; len = -1;
dst[0] = '\0'; dst[0] = '\0';
} else { } else {
i = 0;
name_len = strlen(name); name_len = strlen(name);
e = data + data_len; e = data + data_len;
len = -1; len = -1;
dst[0] = '\0'; dst[0] = '\0';
int i = 0;
// data is "var1=val1&var2=val2...". Find variable first // data is "var1=val1&var2=val2...". Find variable first
for (p = data; p + name_len < e; p++) { for (p = data; p + name_len < e; p++) {
if ((p == data || p[-1] == '&') && p[name_len] == '=' && if ((p == data || p[-1] == '&') && p[name_len] == '=' &&
......
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