Permalink
Browse files

Merge commit 'ee91109d9f163ed593907c2d3cef99b814a4048e'

Conflicts:
	examples/chat.c
	main.c
	mongoose.c
	mongoose.h
  • Loading branch information...
2 parents 6f5c519 + ee91109 commit e7a0b33db72b1faa7633f1cd4caf7c2dc2264ef4 @GerHobbelt committed Oct 1, 2012
Showing with 21 additions and 16 deletions.
  1. +2 −2 Makefile
  2. +3 −2 examples/chat.c
  3. +5 −3 main.c
  4. +11 −9 mongoose.h
View
@@ -23,8 +23,8 @@ all:
### UNIX build: linux, bsd, mac, rtems
##########################################################################
-GCC_WARNS = -W -Wall -pedantic -Wno-missing-field-initializers \
- -Wno-unused-parameter -Wno-format-zero-length -Wno-missing-braces
+GCC_WARNS = -W -Wall -pedantic
+# -Wno-missing-field-initializers -Wno-unused-parameter -Wno-format-zero-length -Wno-missing-braces
CFLAGS = -W -Wall -std=c99 -O2 $(GCC_WARNS) $(COPT)
MAC_SHARED = -flat_namespace -bundle -undefined suppress
LINFLAGS = -ldl -pthread $(CFLAGS)
View
@@ -479,9 +479,10 @@ int main(void) {
srand((unsigned) time(0));
// Setup and start Mongoose
- ctx = mg_start(&ucb, options);
- if (!ctx)
+ if ((ctx = mg_start(&ucb, options)) == NULL) {
+ printf("%s\n", "Cannot start chat server, fatal exit");
exit(EXIT_FAILURE);
+ }
// Wait until enter is pressed, then exit
printf("Chat server started on ports %s, press enter to quit.\n",
View
8 main.c
@@ -142,13 +142,15 @@ static void process_command_line_arguments(char *argv[], char **options) {
char line[MAX_CONF_FILE_LINE_SIZE], opt[sizeof(line)], val[sizeof(line)], *p;
FILE *fp = NULL;
size_t i;
+ int cmd_line_opts_start = 1;
int line_no = 0;
options[0] = NULL;
// Should we use a config file ?
if (argv[1] != NULL && argv[2] == NULL) {
snprintf(config_file, sizeof(config_file), "%s", argv[1]);
+ cmd_line_opts_start = 2;
} else if ((p = strrchr(argv[0], DIRSEP)) == NULL) {
// No command line flags specified. Look where binary lives
snprintf(config_file, sizeof(config_file), "%s", CONFIG_FILE);
@@ -206,8 +208,8 @@ static void process_command_line_arguments(char *argv[], char **options) {
(void) mg_fclose(fp);
}
- // Now handle command line flags. They override config file / default settings.
- for (i = 1; argv[i] != NULL; i += 2) {
+ // Handle command line flags. They override config file and default settings.
+ for (i = cmd_line_opts_start; argv[i] != NULL; i += 2) {
if (argv[i][0] != '-' || argv[i + 1] == NULL) {
show_usage_and_exit(ctx);
}
@@ -592,7 +594,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
DispatchMessage(&msg);
}
- // return the WM_QUIT value:
+ // Return the WM_QUIT value.
return msg.wParam;
}
#else
View
@@ -475,9 +475,10 @@ const struct mg_request_info *mg_get_request_info(const struct mg_connection *co
// Send data to the client.
-//
-// Return the number of bytes written; 0 when the connection has been closed.
-// Return -1 on error.
+// Return:
+// 0 when the connection has been closed
+// -1 on error
+// number of bytes written on success
int mg_write(struct mg_connection *, const void *buf, size_t len);
// Write the HTTP response code and the set of response headers which
@@ -811,11 +812,12 @@ int mg_extract_raw_http_header(char **buf, char **token_ref, char **value_ref);
//
// Return:
// On success, length of the decoded variable.
-// On error, -1 (variable not found, or destination buffer is too small).
-// On error, -2 (destination buffer NULL or zero length).
+// On error:
+// -1 (variable not found, or destination buffer is too small).
+// -2 (destination buffer is NULL or zero length).
//
-// Destination buffer is guaranteed to be '\0'-terminated whenever possible.
-// In case of failure, dst[0] == '\0'.
+// Destination buffer is guaranteed to be '\0' - terminated if it is not
+// NULL or zero length. In case of failure, dst[0] == '\0'.
int mg_get_var(const char *data, size_t data_len, const char *var_name,
char *buf, size_t buf_len, int is_form_url_encoded);
@@ -973,7 +975,7 @@ int mg_read_http_response_head(struct mg_connection *conn);
// Return:
// On error, NULL
// On success, opened file stream to the downloaded contents. The stream
-// is positioned at the end of the file. It is the user's responsibility
+// is positioned to the end of the file. It is the user's responsibility
// to fclose() the opened file stream.
FILE *mg_fetch(struct mg_context *ctx, const char *url, const char *path,
struct mg_connection **conn_ref);
@@ -1011,7 +1013,7 @@ const char *mg_version(void);
// MD5 hash. Example:
// char buf[33];
// mg_md5(buf, "aa", "bb", NULL);
-void mg_md5(char *buf, ...);
+void mg_md5(char buf[33], ...);
// Return the HTTP response code string for the given response code
const char *mg_get_response_code_text(int response_code);

0 comments on commit e7a0b33

Please sign in to comment.