Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
6083b9c5
Commit
6083b9c5
authored
Sep 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to the recent skeleton. SSL address format changed
parent
83237a02
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
873 additions
and
856 deletions
+873
-856
server.c
examples/server.c
+509
-507
unit_test.c
examples/unit_test.c
+5
-4
websocket_chat.c
examples/websocket_chat/websocket_chat.c
+1
-1
websocket_echo_server.c
examples/websocket_echo_server/websocket_echo_server.c
+1
-1
Makefile
examples/ws_ssl/Makefile
+4
-6
net_skeleton.c
examples/ws_ssl/net_skeleton.c
+1
-1
net_skeleton.h
examples/ws_ssl/net_skeleton.h
+1
-1
ssl_wrapper.c
examples/ws_ssl/ssl_wrapper.c
+1
-1
ssl_wrapper.h
examples/ws_ssl/ssl_wrapper.h
+1
-1
mongoose.c
mongoose.c
+344
-327
mongoose.h
mongoose.h
+5
-6
No files found.
examples/server.c
View file @
6083b9c5
This diff is collapsed.
Click to expand it.
examples/unit_test.c
View file @
6083b9c5
...
@@ -396,9 +396,9 @@ static const char *test_server(void) {
...
@@ -396,9 +396,9 @@ static const char *test_server(void) {
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
((
conn
=
mg_connect
(
server
,
"127.0.0.1
"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
ASSERT
((
conn
=
mg_connect
(
server
,
"127.0.0.1
:"
HTTP_PORT
))
!=
NULL
);
conn
->
connection_param
=
buf1
;
conn
->
connection_param
=
buf1
;
ASSERT
((
conn
=
mg_connect
(
server
,
"127.0.0.1
"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
ASSERT
((
conn
=
mg_connect
(
server
,
"127.0.0.1
:"
HTTP_PORT
))
!=
NULL
);
conn
->
connection_param
=
buf2
;
conn
->
connection_param
=
buf2
;
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
...
@@ -483,7 +483,7 @@ static const char *test_mg_set_option(void) {
...
@@ -483,7 +483,7 @@ static const char *test_mg_set_option(void) {
}
}
static
const
char
*
test_rewrites
(
void
)
{
static
const
char
*
test_rewrites
(
void
)
{
char
buf1
[
100
]
=
"xx"
;
char
buf1
[
100
]
=
"xx"
,
addr
[
50
]
;
struct
mg_server
*
server
=
mg_create_server
(
NULL
,
evh2
);
struct
mg_server
*
server
=
mg_create_server
(
NULL
,
evh2
);
struct
mg_connection
*
conn
;
struct
mg_connection
*
conn
;
const
char
*
port
;
const
char
*
port
;
...
@@ -492,7 +492,8 @@ static const char *test_rewrites(void) {
...
@@ -492,7 +492,8 @@ static const char *test_rewrites(void) {
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"url_rewrites"
,
"/xx=unit_test.c"
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"url_rewrites"
,
"/xx=unit_test.c"
)
==
NULL
);
ASSERT
((
port
=
mg_get_option
(
server
,
"listening_port"
))
!=
NULL
);
ASSERT
((
port
=
mg_get_option
(
server
,
"listening_port"
))
!=
NULL
);
ASSERT
((
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
port
),
0
))
!=
NULL
);
snprintf
(
addr
,
sizeof
(
addr
),
"127.0.0.1:%s"
,
port
);
ASSERT
((
conn
=
mg_connect
(
server
,
addr
))
!=
NULL
);
conn
->
connection_param
=
buf1
;
conn
->
connection_param
=
buf1
;
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
...
...
examples/websocket_chat/websocket_chat.c
View file @
6083b9c5
// Copyright (c) 2013-2014 Cesanta Software Limited
// Copyright (c) 2013-2014 Cesanta Software Limited
// $Date: 2014-09-0
8 22:30:52
UTC $
// $Date: 2014-09-0
9 17:07:55
UTC $
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
...
...
examples/websocket_echo_server/websocket_echo_server.c
View file @
6083b9c5
// Copyright (c) 2013-2014 Cesanta Software Limited
// Copyright (c) 2013-2014 Cesanta Software Limited
// $Date: 2014-09-09
08:27:3
5 UTC $
// $Date: 2014-09-09
17:07:5
5 UTC $
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
...
...
examples/ws_ssl/Makefile
View file @
6083b9c5
# Copyright (c) 2014 Cesanta Software
# Copyright (c) 2014 Cesanta Software
# All rights reserved
# All rights reserved
CFLAGS
=
-W
-Wall
-I
../..
-g
-O0
$(CFLAGS_EXTRA)
CFLAGS
=
-W
-Wall
-I
../..
-I
.
-g
-O0
$(CFLAGS_EXTRA)
NS
=
../../../net_skeleton
SW
=
../../../ssl_wrapper
SOURCES
=
ws_ssl.c ../../mongoose.c
$(NS)
/net_skeleton.c
$(SW)
/
ssl_wrapper.c
SOURCES
=
ws_ssl.c ../../mongoose.c
net_skeleton.c
ssl_wrapper.c
PROG
=
ws_ssl
PROG
=
ws_ssl
all
:
$(PROG)
all
:
$(PROG)
$(PROG)
:
$(SOURCES)
$(PROG)
:
$(SOURCES)
$(CC)
-o
$(PROG)
$(SOURCES)
\
$(CC)
-o
$(PROG)
$(SOURCES)
\
-
I
$(NS)
-
DNS_ENABLE_SSL
-DNOEMBED_NET_SKELETON
\
-DNS_ENABLE_SSL
-DNOEMBED_NET_SKELETON
\
-
I
$(SW)
-
DSSL_WRAPPER_USE_AS_LIBRARY
-lssl
$(CFLAGS)
-DSSL_WRAPPER_USE_AS_LIBRARY
-lssl
$(CFLAGS)
clean
:
clean
:
rm
-rf
$(PROG)
*
.exe
*
.dSYM
*
.obj
*
.exp .
*
o
*
.lib
rm
-rf
$(PROG)
*
.exe
*
.dSYM
*
.obj
*
.exp .
*
o
*
.lib
examples/ws_ssl/net_skeleton.c
View file @
6083b9c5
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// Alternatively, you can license this software under a commercial
// Alternatively, you can license this software under a commercial
// license, as set out in <http://cesanta.com/>.
// license, as set out in <http://cesanta.com/>.
//
//
// $Date: 2014-09-09 1
6:03:50
UTC $
// $Date: 2014-09-09 1
7:07:55
UTC $
#include "net_skeleton.h"
#include "net_skeleton.h"
...
...
examples/ws_ssl/net_skeleton.h
View file @
6083b9c5
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// Alternatively, you can license this software under a commercial
// Alternatively, you can license this software under a commercial
// license, as set out in <http://cesanta.com/>.
// license, as set out in <http://cesanta.com/>.
//
//
// $Date: 2014-09-09 1
6:03:50
UTC $
// $Date: 2014-09-09 1
7:07:55
UTC $
#ifndef NS_SKELETON_HEADER_INCLUDED
#ifndef NS_SKELETON_HEADER_INCLUDED
#define NS_SKELETON_HEADER_INCLUDED
#define NS_SKELETON_HEADER_INCLUDED
...
...
examples/ws_ssl/ssl_wrapper.c
View file @
6083b9c5
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// Alternatively, you can license this software under a commercial
// Alternatively, you can license this software under a commercial
// license, as set out in <http://cesanta.com/products.html>.
// license, as set out in <http://cesanta.com/products.html>.
//
//
// $Date: 2014-09-09 1
6:03:50
UTC $
// $Date: 2014-09-09 1
7:07:55
UTC $
#include "net_skeleton.h"
#include "net_skeleton.h"
#include "ssl_wrapper.h"
#include "ssl_wrapper.h"
...
...
examples/ws_ssl/ssl_wrapper.h
View file @
6083b9c5
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// Alternatively, you can license this software under a commercial
// Alternatively, you can license this software under a commercial
// license, as set out in <http://cesanta.com/products.html>.
// license, as set out in <http://cesanta.com/products.html>.
//
//
// $Date: 2014-09-09 1
6:03:50
UTC $
// $Date: 2014-09-09 1
7:07:55
UTC $
#ifndef SSL_WRAPPER_HEADER_INCLUDED
#ifndef SSL_WRAPPER_HEADER_INCLUDED
#define SSL_WRAPPER_HEADER_INCLUDED
#define SSL_WRAPPER_HEADER_INCLUDED
...
...
mongoose.c
View file @
6083b9c5
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
6083b9c5
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
// Alternatively, you can license this library under a commercial
// Alternatively, you can license this library under a commercial
// license, as set out in <http://cesanta.com/>.
// license, as set out in <http://cesanta.com/>.
//
//
// $Date: 2014-09-0
1 19:53:26
UTC $
// $Date: 2014-09-0
9 17:07:55
UTC $
#ifndef MONGOOSE_HEADER_INCLUDED
#ifndef MONGOOSE_HEADER_INCLUDED
#define MONGOOSE_HEADER_INCLUDED
#define MONGOOSE_HEADER_INCLUDED
...
@@ -55,7 +55,7 @@ struct mg_connection {
...
@@ -55,7 +55,7 @@ struct mg_connection {
int
wsbits
;
// First byte of the websocket frame
int
wsbits
;
// First byte of the websocket frame
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
connection_param
;
// Placeholder for connection-specific data
void
*
connection_param
;
// Placeholder for connection-specific data
void
*
callback_param
;
// Needed by mg_iterate_over_connections()
void
*
callback_param
;
};
};
struct
mg_server
;
// Opaque structure describing server instance
struct
mg_server
;
// Opaque structure describing server instance
...
@@ -95,11 +95,10 @@ const char **mg_get_valid_option_names(void);
...
@@ -95,11 +95,10 @@ const char **mg_get_valid_option_names(void);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
void
mg_set_listening_socket
(
struct
mg_server
*
,
int
sock
);
void
mg_set_listening_socket
(
struct
mg_server
*
,
int
sock
);
int
mg_get_listening_socket
(
struct
mg_server
*
);
int
mg_get_listening_socket
(
struct
mg_server
*
);
void
mg_iterate_over_connections
(
struct
mg_server
*
,
mg_handler_t
,
void
*
);
struct
mg_connection
*
mg_next
(
struct
mg_server
*
,
struct
mg_connection
*
);
struct
mg_connection
*
mg_next
(
struct
mg_server
*
,
struct
mg_connection
*
);
void
mg_wakeup_server
(
struct
mg_server
*
);
void
mg_wakeup_server
(
struct
mg_server
*
);
void
mg_wakeup_server_ex
(
struct
mg_server
*
,
mg_handler_t
,
const
char
*
,
...);
void
mg_wakeup_server_ex
(
struct
mg_server
*
,
mg_handler_t
,
const
char
*
,
...);
struct
mg_connection
*
mg_connect
(
struct
mg_server
*
,
const
char
*
,
int
,
int
);
struct
mg_connection
*
mg_connect
(
struct
mg_server
*
,
const
char
*
);
// Connection management functions
// Connection management functions
void
mg_send_status
(
struct
mg_connection
*
,
int
status_code
);
void
mg_send_status
(
struct
mg_connection
*
,
int
status_code
);
...
@@ -127,6 +126,7 @@ int mg_parse_multipart(const char *buf, int buf_len,
...
@@ -127,6 +126,7 @@ int mg_parse_multipart(const char *buf, int buf_len,
char
*
file_name
,
int
file_name_len
,
char
*
file_name
,
int
file_name_len
,
const
char
**
data
,
int
*
data_len
);
const
char
**
data
,
int
*
data_len
);
// Utility functions
// Utility functions
void
*
mg_start_thread
(
void
*
(
*
func
)(
void
*
),
void
*
param
);
void
*
mg_start_thread
(
void
*
(
*
func
)(
void
*
),
void
*
param
);
char
*
mg_md5
(
char
buf
[
33
],
...);
char
*
mg_md5
(
char
buf
[
33
],
...);
...
@@ -134,7 +134,7 @@ int mg_authorize_digest(struct mg_connection *c, FILE *fp);
...
@@ -134,7 +134,7 @@ int mg_authorize_digest(struct mg_connection *c, FILE *fp);
int
mg_url_encode
(
const
char
*
src
,
size_t
s_len
,
char
*
dst
,
size_t
dst_len
);
int
mg_url_encode
(
const
char
*
src
,
size_t
s_len
,
char
*
dst
,
size_t
dst_len
);
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
);
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
);
int
mg_terminate_ssl
(
struct
mg_connection
*
c
,
const
char
*
cert
);
int
mg_terminate_ssl
(
struct
mg_connection
*
c
,
const
char
*
cert
);
int
mg_forward
(
struct
mg_connection
*
,
const
char
*
host
,
int
port
,
int
use_ssl
);
int
mg_forward
(
struct
mg_connection
*
c
,
const
char
*
addr
);
void
*
mg_mmap
(
FILE
*
fp
,
size_t
size
);
void
*
mg_mmap
(
FILE
*
fp
,
size_t
size
);
void
mg_munmap
(
void
*
p
,
size_t
size
);
void
mg_munmap
(
void
*
p
,
size_t
size
);
...
@@ -147,7 +147,6 @@ struct mg_expansion {
...
@@ -147,7 +147,6 @@ struct mg_expansion {
void
mg_template
(
struct
mg_connection
*
,
const
char
*
text
,
void
mg_template
(
struct
mg_connection
*
,
const
char
*
text
,
struct
mg_expansion
*
expansions
);
struct
mg_expansion
*
expansions
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif // __cplusplus
#endif // __cplusplus
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment